Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions src/components/NoiFlightControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,22 @@ export default {
// this.search()
// }
},

resolveTypedAirport() {
if (!this.airportSelectFieldValue) return;

const typed = this.airportSelectFieldValue.trim().toUpperCase();

if (this.airports[typed]) {
this.airport = {
value: typed,
label: `${this.airports[typed].name} (${typed})`
};

this.airportSelectFieldValue = `${this.airports[typed].name} (${typed})`;
}
},

airlineLink(flight) {
let dep = DateTime.fromFormat(flight.departure.date, "yyyy-LL-dd", "UTC");
let loc =
Expand Down Expand Up @@ -615,6 +631,9 @@ export default {
this.search();
},
async search() {

this.resolveTypedAirport();

//form validation
let formValidationResponse = this.validateForm();
if (formValidationResponse.result == false) {
Expand Down Expand Up @@ -743,7 +762,18 @@ export default {

return false;
},
async getData(paramsObj = {}) {
async getData(paramsObj = {}) {
const cacheKey = JSON.stringify(paramsObj);

// Return cached data if available
if (
this.tripDataCache &&
this.tripDataCache.key === cacheKey
) {
console.log("Using cached Trip data");
return this.tripDataCache.data;
}

let allItems = [];
let pageNumber = 1;
const pageSize = 500;
Expand All @@ -770,11 +800,21 @@ export default {
pageNumber++;
}

return {
const result = {
data: {
Items: allItems,
},
};

// Store in cache
this.tripDataCache = {
key: cacheKey,
data: result,
};

console.log("Cached", allItems.length, "trips");

return result;
},
async fetchSchedules() {
try {
Expand Down Expand Up @@ -1109,7 +1149,10 @@ export default {
//on mount component
mounted: function () {
//init local airport
this.localAirportKey = this.options.localAirport;
this.localAirportKey = (
this.options.localAirport || "BZO"
).toUpperCase();

if (!this.airports[this.localAirportKey]) {
this.localAirportKey = "BZO";
}
Expand Down Expand Up @@ -1162,6 +1205,7 @@ export default {
week: 13,
month: 7,
},
tripDataCache: null,
period: { label: "Day", value: "day" },
selectedTimeIntervalIndex: 0,

Expand Down
Loading