aboutsummaryrefslogtreecommitdiff
path: root/viewer/src
diff options
context:
space:
mode:
authorZero~Informatique2020-09-11 21:06:31 +0200
committerG.Fouet2020-09-11 21:53:18 +0200
commiteb636568643e892491fd925f7a92fc3feba6a67e (patch)
tree1a82841f45e757f020c3ed9c84ad21cc456ae8a3 /viewer/src
parentf89ed0bd94ea570d9e6533301783d13b13033db0 (diff)
downloadldgallery-eb636568643e892491fd925f7a92fc3feba6a67e.tar.gz
viewer: config.json url parameter + index.json configuration
github: resolves #160
Diffstat (limited to 'viewer/src')
-rw-r--r--viewer/src/@types/gallery.d.ts3
-rw-r--r--viewer/src/store/galleryStore.ts11
2 files changed, 11 insertions, 3 deletions
diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts
index 56feff0..b756331 100644
--- a/viewer/src/@types/gallery.d.ts
+++ b/viewer/src/@types/gallery.d.ts
@@ -20,7 +20,8 @@
20declare namespace Gallery { 20declare namespace Gallery {
21 interface Config { 21 interface Config {
22 galleryRoot: string; 22 galleryRoot: string;
23 initialTagDisplayLimit: number; 23 galleryIndex?: string;
24 initialTagDisplayLimit?: number;
24 } 25 }
25 26
26 interface GalleryProperties { 27 interface GalleryProperties {
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 {
85 85
86 // Fetches the gallery's JSON config 86 // Fetches the gallery's JSON config
87 @action async fetchConfig() { 87 @action async fetchConfig() {
88 return fetch(`${process.env.VUE_APP_DATA_URL}config.json`, { cache: "no-cache" }) 88 return fetch(`${process.env.VUE_APP_DATA_URL}${GalleryStore.getUrlConfig()}`, { cache: "no-cache" })
89 .then(response => response.json()) 89 .then(response => response.json())
90 .then(this.setConfig); 90 .then(this.setConfig);
91 } 91 }
@@ -93,7 +93,8 @@ export default class GalleryStore extends VuexModule {
93 // Fetches the gallery's JSON metadata 93 // Fetches the gallery's JSON metadata
94 @action async fetchGalleryItems() { 94 @action async fetchGalleryItems() {
95 const root = this.config?.galleryRoot ?? ""; 95 const root = this.config?.galleryRoot ?? "";
96 return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) 96 const index = this.config?.galleryIndex ?? "index.json";
97 return fetch(`${process.env.VUE_APP_DATA_URL}${root}${index}`, { cache: "no-cache" })
97 .then(response => response.json()) 98 .then(response => response.json())
98 .then(this.setGalleryIndex) 99 .then(this.setGalleryIndex)
99 .then(this.indexTags) 100 .then(this.indexTags)
@@ -121,4 +122,10 @@ export default class GalleryStore extends VuexModule {
121 this.setCurrentSearch(results); 122 this.setCurrentSearch(results);
122 return results; 123 return results;
123 } 124 }
125
126 private static getUrlConfig() {
127 let search = window.location.search;
128 if (search.length > 1) return search.substr(1) + ".json";
129 return "config.json";
130 }
124} 131}