Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backlog data support and fix focus-visible issue #113

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
59 changes: 51 additions & 8 deletions src/TempoLite.vue
Original file line number Diff line number Diff line change
@@ -810,12 +810,13 @@ interface TimezoneInfo {
name: string;
}

import { getTimestamps, getExtendedRangeTimestamps } from "./timestamps";
import { getTimestamps, getExtendedRangeTimestamps, getBacklogTimestamps } from "./timestamps";

const erdTimestamps: number[] = [];
const newTimestamps: number[] = [];

const cloudTimestamps: number[] = [];
const backlogTimestamps: number[] = []; // Generated by Copilot

const fosterTimestamps = [
1698838920000,
@@ -1002,6 +1003,7 @@ export default defineComponent({
fosterTimestamps,
timestampsLoaded: false,
preload: true,
backlogTimestamps, // Generated by Copilot

singleDateSelected: new Date(),

@@ -1465,23 +1467,44 @@ export default defineComponent({
// },

async updateTimestamps() {
// Get extended range timestamps
getExtendedRangeTimestamps().then(ts => {
this.extendedRangeTimestamps = ts;
}
);
});

// Get backlog timestamps
getBacklogTimestamps().then((ts) => {
this.backlogTimestamps = ts.released;
this.cloudTimestamps = this.cloudTimestamps.concat(ts.clouds);
}).catch(err => {
console.error('Error loading backlog timestamps:', err);
});

// Get regular timestamps
return getTimestamps().then((ts) => {
this.erdTimestamps = ts.early_release;
this.erdTimestamps = ts.early_release ?? [];
this.newTimestamps = ts.released;
this.timestamps = this.timestamps.concat(this.erdTimestamps, this.newTimestamps).sort();
this.cloudTimestamps = ts.clouds;
this.timestamps = this.timestamps.concat(
this.erdTimestamps,
this.newTimestamps,
this.backlogTimestamps
).sort();
this.cloudTimestamps = this.cloudTimestamps.concat(ts.clouds);
});
},

getCloudFilename(date: Date): string {
const filename = this.getTempoFilename(date);
const backlog = this.backlogTimestamps.includes(date.getTime());
if (this.useHighRes) {
if (backlog) {
return 'https://tempo.si.edu/data2/backlog/clouds/images/' + filename;
}
return 'https://raw.githubusercontent.com/johnarban/tempo-data-holdings/main/clouds/images/' + filename;
} else {
if (backlog) {
return 'https://tempo.si.edu/data2/backlog/clouds/images/resized_images/' + filename;
}
return 'https://raw.githubusercontent.com/johnarban/tempo-data-holdings/main/clouds/images/resized_images/' + filename;
}
},
@@ -1491,14 +1514,24 @@ export default defineComponent({
},

getTempoDataUrl(timestamp: number): string {
// Check if timestamp is from backlog first
if (this.backlogTimestamps.includes(timestamp)) {
// Generated by Copilot
if (this.useHighRes) {
return 'https://tempo.si.edu/data2/backlog/released/images/';
}
return 'https://tempo.si.edu/data2/backlog/released/images/resized_images/';
}

// Extended range check
if (this.showExtendedRange && this.extendedRangeTimestamps.includes(timestamp)) {
console.log('extended range');
// return 'https://raw.githubusercontent.com/johnarban/tempo-data-holdings/main/data_range_0_300/released/images/';
if (this.useHighRes) {
return 'https://raw.githubusercontent.com/johnarban/tempo-data-holdings/main/data_range_0_300/released/images/';
}
return 'https://raw.githubusercontent.com/johnarban/tempo-data-holdings/main/data_range_0_300/released/images/resized_images/';
}

// Other sources
if (this.fosterTimestamps.includes(timestamp)) {
return 'https://tempo-images-bucket.s3.amazonaws.com/tempo-lite/';
}
@@ -1739,6 +1772,15 @@ export default defineComponent({
this.singleDateSelected = this.uniqueDays[this.uniqueDays.length-1];
},

backlogTimestamps(newValue) {
// Generated by Copilot
if (newValue.length > 0) {
// Update the combined timestamps array with backlog data
this.timestamps = [...this.timestamps, ...newValue].sort();
console.log(`Added ${newValue.length} backlog timestamps`);
}
},

radio(value: number | null) {
if (value == null) {
// this.minIndex = 0;
@@ -2372,6 +2414,7 @@ i.mdi-menu-down {

// From Sara Soueidan (https://www.sarasoueidan.com/blog/focus-indicators/) & Erik Kroes (https://www.erikkroes.nl/blog/the-universal-focus-state/)
:focus-visible:not(.v-field__input input),
:focus-visible:not(.v-overlay__content),
button:focus-visible,
.focus-visible,
.v-selection-control--focus-visible .v-selection-control__input {
18 changes: 17 additions & 1 deletion src/timestamps.ts
Original file line number Diff line number Diff line change
@@ -51,8 +51,17 @@ export async function fetchLaFireManifest(): Promise<LAManifest> {

}

export async function fetchBacklogManifest(): Promise<Manifest> {
console.log("fetching backlog manifest");
const url = "https://tempo.si.edu/data2/backlog/manifest.json";
// try to use cache busting, but if that fails try with plain url
return fetch(`${url}?version=${Date.now()}}`)
.then((response) => response.json())
.catch(() => fetch(url).then((response) => response.json()));
}

interface Timestamps {
early_release: number[];
early_release?: number[];
released: number[];
clouds: number[];
}
@@ -70,4 +79,11 @@ export async function getExtendedRangeTimestamps(): Promise<number[]> {
const ts = manifest['data_range_0_300/released'].timestamps;
// console.log(ts.map(t => new Date(t)));
return ts;
}

export async function getBacklogTimestamps(): Promise<Timestamps> {
const manifest = await fetchBacklogManifest();
const released = manifest.released;
const clouds = manifest.clouds;
return { released: released.timestamps, clouds: clouds.timestamps };
}