From f328a730b516f5e9104f85e553c083c2865660a8 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 4 May 2020 00:10:39 +0200 Subject: viewer/galleryStore: unify resource root parametrisation --- viewer/src/store/galleryStore.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'viewer/src/store/galleryStore.ts') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 0cffdd9..a57122c 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -79,6 +79,10 @@ export default class GalleryStore extends VuexModule { return this.galleryIndex?.properties.galleryTitle ?? "ldgallery"; } + get resourceRoot(): string { + return process.env.VUE_APP_DATA_URL + this.config!.galleryRoot; + } + // --- // Fetches the gallery's JSON config -- cgit v1.2.3 From 170d7a61f720ece9dc4b347b19f5a8213f1d8984 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Sat, 20 Jun 2020 16:50:49 +0200 Subject: viewer: prettier formatting based on eslint-prettier plugin --- viewer/src/store/galleryStore.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'viewer/src/store/galleryStore.ts') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index a57122c..5458f20 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -23,11 +23,10 @@ import Navigation from "@/services/navigation"; const VuexModule = createModule({ namespaced: "galleryStore", - strict: true -}) + strict: true, +}); export default class GalleryStore extends VuexModule { - config: Gallery.Config | null = null; galleryIndex: Gallery.Index | null = null; tagsIndex: Tag.Index = {}; @@ -65,8 +64,7 @@ export default class GalleryStore extends VuexModule { get currentItemPath(): Gallery.Item[] { const root = this.galleryIndex?.tree; - if (root) - return Navigation.searchCurrentItemPath(root, this.currentPath); + if (root) return Navigation.searchCurrentItemPath(root, this.currentPath); return []; } -- cgit v1.2.3 From e6c2a8d9653ffde924632ca2f260c3a8cddc14ed Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 11 Sep 2020 00:15:04 +0200 Subject: viewer: item display order github: resolves #28 --- viewer/src/store/galleryStore.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'viewer/src/store/galleryStore.ts') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 5458f20..768adb6 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -31,7 +31,7 @@ export default class GalleryStore extends VuexModule { galleryIndex: Gallery.Index | null = null; tagsIndex: Tag.Index = {}; tagsCategories: Tag.Category[] = []; - currentPath: string = "/"; + currentPath: string | null = null; currentSearch: Tag.Search[] = []; // --- @@ -64,7 +64,7 @@ export default class GalleryStore extends VuexModule { get currentItemPath(): Gallery.Item[] { const root = this.galleryIndex?.tree; - if (root) return Navigation.searchCurrentItemPath(root, this.currentPath); + if (root && this.currentPath) return Navigation.searchCurrentItemPath(root, this.currentPath); return []; } -- cgit v1.2.3 From eb636568643e892491fd925f7a92fc3feba6a67e Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 11 Sep 2020 21:06:31 +0200 Subject: viewer: config.json url parameter + index.json configuration github: resolves #160 --- viewer/src/store/galleryStore.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'viewer/src/store/galleryStore.ts') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 768adb6..b672551 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -85,7 +85,7 @@ export default class GalleryStore extends VuexModule { // Fetches the gallery's JSON config @action async fetchConfig() { - return fetch(`${process.env.VUE_APP_DATA_URL}config.json`, { cache: "no-cache" }) + return fetch(`${process.env.VUE_APP_DATA_URL}${GalleryStore.getUrlConfig()}`, { cache: "no-cache" }) .then(response => response.json()) .then(this.setConfig); } @@ -93,7 +93,8 @@ export default class GalleryStore extends VuexModule { // Fetches the gallery's JSON metadata @action async fetchGalleryItems() { const root = this.config?.galleryRoot ?? ""; - return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) + const index = this.config?.galleryIndex ?? "index.json"; + return fetch(`${process.env.VUE_APP_DATA_URL}${root}${index}`, { cache: "no-cache" }) .then(response => response.json()) .then(this.setGalleryIndex) .then(this.indexTags) @@ -121,4 +122,10 @@ export default class GalleryStore extends VuexModule { this.setCurrentSearch(results); return results; } + + private static getUrlConfig() { + let search = window.location.search; + if (search.length > 1) return search.substr(1) + ".json"; + return "config.json"; + } } -- cgit v1.2.3 From 7a8eba922ad34182628f80cf2496d8654abe91e6 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Sat, 12 Sep 2020 06:26:39 +0200 Subject: viewer: improved network errors handling --- viewer/src/store/galleryStore.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'viewer/src/store/galleryStore.ts') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index b672551..5d599aa 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -85,20 +85,22 @@ export default class GalleryStore extends VuexModule { // Fetches the gallery's JSON config @action async fetchConfig() { - return fetch(`${process.env.VUE_APP_DATA_URL}${GalleryStore.getUrlConfig()}`, { cache: "no-cache" }) - .then(response => response.json()) + await fetch(`${process.env.VUE_APP_DATA_URL}${GalleryStore.getUrlConfig()}`, { cache: "no-cache" }) + .then(GalleryStore.responseToJson) .then(this.setConfig); + return this.config!; } // Fetches the gallery's JSON metadata @action async fetchGalleryItems() { const root = this.config?.galleryRoot ?? ""; const index = this.config?.galleryIndex ?? "index.json"; - return fetch(`${process.env.VUE_APP_DATA_URL}${root}${index}`, { cache: "no-cache" }) - .then(response => response.json()) + await fetch(`${process.env.VUE_APP_DATA_URL}${root}${index}`, { cache: "no-cache" }) + .then(GalleryStore.responseToJson) .then(this.setGalleryIndex) .then(this.indexTags) .then(this.indexTagCategories); + return this.galleryIndex!; } // Indexes the gallery @@ -128,4 +130,9 @@ export default class GalleryStore extends VuexModule { if (search.length > 1) return search.substr(1) + ".json"; return "config.json"; } + + private static responseToJson(response: Response) { + if (!response.ok) throw new Error(`${response.status}: ${response.statusText}`); + return response.json(); + } } -- cgit v1.2.3