From 19d40a5ee98fb1f244612155acc559ff2f21bf6b Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Wed, 12 Feb 2020 00:09:34 +0100 Subject: 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 --- viewer/src/@types/gallery.d.ts | 5 +++++ viewer/src/components/LdPicture.vue | 12 +++++++----- viewer/src/components/LdThumbnail.vue | 7 +++---- viewer/src/store/galleryStore.ts | 18 ++++++++++++++++-- viewer/src/views/MainLayout.vue | 3 ++- 5 files changed, 33 insertions(+), 12 deletions(-) (limited to 'viewer/src') diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts index 1987416..865f621 100644 --- a/viewer/src/@types/gallery.d.ts +++ b/viewer/src/@types/gallery.d.ts @@ -18,6 +18,11 @@ */ declare namespace Gallery { + interface Config { + generationTimestamp: number, + galleryRoot: string, + } + interface Other extends Item { properties: OtherProperties, } diff --git a/viewer/src/components/LdPicture.vue b/viewer/src/components/LdPicture.vue index 8a9a08e..a5faeb3 100644 --- a/viewer/src/components/LdPicture.vue +++ b/viewer/src/components/LdPicture.vue @@ -28,7 +28,7 @@ @dragscrollend="dragScrollClickFix.onDragScrollEnd()" > diff --git a/viewer/src/components/LdThumbnail.vue b/viewer/src/components/LdThumbnail.vue index 17c7659..13468e1 100644 --- a/viewer/src/components/LdThumbnail.vue +++ b/viewer/src/components/LdThumbnail.vue @@ -21,7 +21,7 @@
config.json()) + .then(this.setConfig); + } + // Fetches the gallery's JSON metadata - @action async fetchGalleryItems(url: string) { - return fetch(url) + @action async fetchGalleryItems() { + const root = this.config?.galleryRoot ?? ''; + const timestamp = this.config?.generationTimestamp ?? 0; + return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json?${timestamp}`) .then(response => response.json()) .then(this.setGalleryItemsRoot) .then(this.indexTags); diff --git a/viewer/src/views/MainLayout.vue b/viewer/src/views/MainLayout.vue index 12388a9..63a1b83 100644 --- a/viewer/src/views/MainLayout.vue +++ b/viewer/src/views/MainLayout.vue @@ -60,7 +60,8 @@ export default class MainLayout extends Vue { fetchGalleryItems() { this.isLoading = true; this.$galleryStore - .fetchGalleryItems(`${process.env.VUE_APP_DATA_URL}index.json`) + .fetchConfig() + .then(this.$galleryStore.fetchGalleryItems) .finally(() => (this.isLoading = false)) .catch(this.displayError); } -- cgit v1.2.3