From f93a728091e52ae5144a51fb6203fde8cdf02558 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Wed, 4 Jan 2023 23:55:10 +1100 Subject: Add event info modal Add InfoModal.vue, SCollapsible.vue, and icons. Update Timeline.vue, App.vue, lib.ts, and store.ts to display modal. For testing, send/use dummy EventInfo from server (still waiting on image downloads). --- src/lib.ts | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src/lib.ts') diff --git a/src/lib.ts b/src/lib.ts index 86b28a8..6f1a1fe 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -267,6 +267,28 @@ export class HistEvent { this.pop = pop; } } +export class ImgInfo { + url: string; + license: string; + artist: string; + credit: string; + constructor(url: string, license: string, artist: string, credit: string){ + this.url = url; + this.license = license; + this.artist = artist; + this.credit = credit; + } +} +export class EventInfo { + desc: string; + wikiId: number; + imgInfo: ImgInfo; + constructor(desc: string, wikiId: number, imgInfo: ImgInfo){ + this.desc = desc; + this.wikiId = wikiId; + this.imgInfo = imgInfo; + } +} export function cmpHistEvent(event: HistEvent, event2: HistEvent){ const cmp = event.start.cmp(event2.start); return cmp != 0 ? cmp : event.id - event2.id; @@ -288,6 +310,9 @@ export async function queryServer(params: URLSearchParams, serverDataUrl=SERVER_ console.log(`Error with querying ${url.toString()}: ${error}`); return null; } + if (responseObj == null){ + console.log('WARNING: Server gave null response'); + } return responseObj; } export function getImagePath(imgId: number): string { @@ -315,7 +340,18 @@ export type EventResponseJson = { events: HistEventJson[], unitCounts: {[x: number]: number} | null, } -export function jsonToHistDate(json: HistDateJson): HistDate{ +export type EventInfoJson = { + desc: string, + wikiId: number, + imgInfo: ImgInfoJson, +} +export type ImgInfoJson = { + url: string, + license: string, + artist: string, + credit: string, +} +export function jsonToHistDate(json: HistDateJson): HistDate { return new HistDate(json.gcal, json.year, json.month, json.day); } export function jsonToHistEvent(json: HistEventJson): HistEvent { @@ -331,6 +367,12 @@ export function jsonToHistEvent(json: HistEventJson): HistEvent { json.pop, ); } +export function jsonToEventInfo(json: EventInfoJson): EventInfo { + return new EventInfo(json.desc, json.wikiId, jsonToImgInfo(json.imgInfo)); +} +export function jsonToImgInfo(json: ImgInfoJson): ImgInfo { + return new ImgInfo(json.url, json.license, json.artist, json.credit); +} // For dates in a timeline const currentDate = new Date(); -- cgit v1.2.3