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') 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