aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/store/galleryStore.ts
diff options
context:
space:
mode:
authorZero~Informatique2020-02-12 00:09:34 +0100
committerZero~Informatique2020-02-12 00:10:22 +0100
commit19d40a5ee98fb1f244612155acc559ff2f21bf6b (patch)
tree836e46364b95197da1d643880e9ab259dce32076 /viewer/src/store/galleryStore.ts
parente61a7c84f1a1753186980ff1990ee146395ddfc1 (diff)
downloadldgallery-19d40a5ee98fb1f244612155acc559ff2f21bf6b.tar.gz
viewer: implemented config.json
Note: The DevServer needs to know when the file is from the App, or from the FileSystem. We use a tilde to make this separation. The tilde URL is declared in '.env.development' GitHub: Resolves #32
Diffstat (limited to 'viewer/src/store/galleryStore.ts')
-rw-r--r--viewer/src/store/galleryStore.ts18
1 files changed, 16 insertions, 2 deletions
diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts
index 1c95fe7..bcd4bc9 100644
--- a/viewer/src/store/galleryStore.ts
+++ b/viewer/src/store/galleryStore.ts
@@ -27,12 +27,17 @@ const VuexModule = createModule({
27 27
28export default class GalleryStore extends VuexModule { 28export default class GalleryStore extends VuexModule {
29 29
30 config: Gallery.Config | null = null;
30 galleryItemsRoot: Gallery.Item | null = null; 31 galleryItemsRoot: Gallery.Item | null = null;
31 tags: Tag.Index = {}; 32 tags: Tag.Index = {};
32 currentPath: string = "/"; 33 currentPath: string = "/";
33 34
34 // --- 35 // ---
35 36
37 @mutation setConfig(config: Gallery.Config) {
38 this.config = config;
39 }
40
36 @mutation setGalleryItemsRoot(galleryItemsRoot: Gallery.Item) { 41 @mutation setGalleryItemsRoot(galleryItemsRoot: Gallery.Item) {
37 this.galleryItemsRoot = galleryItemsRoot; 42 this.galleryItemsRoot = galleryItemsRoot;
38 } 43 }
@@ -59,9 +64,18 @@ export default class GalleryStore extends VuexModule {
59 64
60 // --- 65 // ---
61 66
67 // Fetches the gallery's JSON config
68 @action async fetchConfig() {
69 return fetch(`${process.env.VUE_APP_DATA_URL}config.json`)
70 .then(config => config.json())
71 .then(this.setConfig);
72 }
73
62 // Fetches the gallery's JSON metadata 74 // Fetches the gallery's JSON metadata
63 @action async fetchGalleryItems(url: string) { 75 @action async fetchGalleryItems() {
64 return fetch(url) 76 const root = this.config?.galleryRoot ?? '';
77 const timestamp = this.config?.generationTimestamp ?? 0;
78 return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json?${timestamp}`)
65 .then(response => response.json()) 79 .then(response => response.json())
66 .then(this.setGalleryItemsRoot) 80 .then(this.setGalleryItemsRoot)
67 .then(this.indexTags); 81 .then(this.indexTags);