Skip to content

Commit

Permalink
Merge branch 'release/v0.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
fratsloos committed Aug 27, 2022
2 parents a03267e + 5209f54 commit 377a099
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 50 deletions.
2 changes: 1 addition & 1 deletion dist/fr24_card.js

Large diffs are not rendered by default.

105 changes: 64 additions & 41 deletions readme.md

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/javascript/config/columns.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
},
"age": {
"styles": ["align-right"],
"weight": 3,
"weight": 2,
"popup": true
},
"aircraft_type": {
"weight": 2,
"popup": true
}
}
9 changes: 9 additions & 0 deletions src/javascript/fr24_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ class Fr24Card extends HTMLElement {
const states =
this._hass.states[this._config.entity].attributes[this._config.attribute];

if (typeof states === "undefined") {
return;
}

// If no distance service, disable the column
this._availableColumns.distance.show = true;
if (this._distance.isSetUp() === false) {
Expand Down Expand Up @@ -283,6 +287,11 @@ class Fr24Card extends HTMLElement {
* Renders the HTML table with the aircrafts in it
*/
_renderTable() {
// Check for data
if (this._aircrafts.length === 0) {
throw new Error("No data found, check configuration and JSON output");
}

// Create a new table
const table = new Table();
const needsUnits = this._config.units_in_table === true;
Expand Down
14 changes: 11 additions & 3 deletions src/javascript/helpers/aircraft.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export default class Aircraft {
this.lat = state.lat ?? null;
this.lon = state.lon ?? null;
this.seen = state.seen ?? 100;
this.aircraft_type = state.t ?? null;

// ICAO data
const icao = new ICAO();
const country = icao.country.find(this.hex);
const registration = icao.registration.lookup(this.hex);

// Set flag based on ICAO data
this.flag =
Expand All @@ -36,8 +36,16 @@ export default class Aircraft {
: null;
this.country = country !== null ? country.country : null;

// Set registration based on ICAO data
this.registration = registration;
// Registration, either from JSON or calculated
const hasRegistration = typeof state.r !== "undefined" && state.r !== "";
if (hasRegistration) {
this.registration = state.r;
} else {
const registration = icao.registration.lookup(this.hex);

// Set registration based on ICAO data
this.registration = registration;
}

// Calculate distance if distance service is setup
this.distance = distance.isSetUp()
Expand Down
3 changes: 2 additions & 1 deletion src/javascript/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"speed": "Geschwindigkeit",
"distance": "Entfernung",
"track": "Pfad",
"age": "Letzte Nachricht"
"age": "Letzte Nachricht",
"aircraft_type": "Typ"
},
"data": {
"not_available": "N/V"
Expand Down
3 changes: 2 additions & 1 deletion src/javascript/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"speed": "Speed",
"distance": "Distance",
"track": "Track",
"age": "Last message"
"age": "Last message",
"aircraft_type": "Type"
},
"data": {
"not_available": "N/A"
Expand Down
3 changes: 2 additions & 1 deletion src/javascript/lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"speed": "Snelheid",
"distance": "Afstand",
"track": "Richting",
"age": "Laatste bericht"
"age": "Laatste bericht",
"aircraft_type": "Type"
},
"data": {
"not_available": "Nb"
Expand Down
3 changes: 2 additions & 1 deletion src/javascript/lang/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"speed": "Hitrost",
"distance": "Razdalja",
"track": "Smer",
"age": "Zaznano pred"
"age": "Zaznano pred",
"aircraft_type": "Vrsta"
},
"data": {
"not_available": "N/A"
Expand Down

0 comments on commit 377a099

Please sign in to comment.