From c4a51940295d514dd52f48b6f18638ac554224f4 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Wed, 29 Jan 2020 05:35:35 +0100 Subject: viewer: Tag auto-completion should be more flexible. Resolves #38 --- viewer/src/store/galleryStore.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index c4a039f..663340f 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -18,6 +18,7 @@ */ import { createModule, mutation, action } from "vuex-class-component"; +import Tools from '@/tools'; const VuexModule = createModule({ namespaced: "galleryStore", @@ -88,7 +89,7 @@ export default class GalleryStore extends VuexModule { const parts = tag.split('.'); let lastPart: string | null = null; for (const part of parts) { - if (!index[part]) index[part] = { tag: part, items: [], children: {} }; + if (!index[part]) index[part] = { tag: part, tagfiltered: Tools.normalize(part), items: [], children: {} }; if (!index[part].items.includes(item)) index[part].items.push(item); if (lastPart) index[lastPart].children[part] = index[part]; lastPart = part; -- cgit v1.2.3 From 118666b4c3faeaeaf153a2ea7172764a3cbcffab Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Wed, 29 Jan 2020 23:04:30 +0100 Subject: viewer: the loader now correctly waits for the json to be loaded and indexes to be processed before displaying the UI. resolves #61 --- viewer/src/store/galleryStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 663340f..b2ff74e 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -61,7 +61,7 @@ export default class GalleryStore extends VuexModule { // Fetches the gallery's JSON metadata @action async fetchGalleryItems(url: string) { - fetch(url) + return fetch(url) .then(response => response.json()) .then(this.setGalleryItemsRoot) .then(this.indexTags); -- cgit v1.2.3 From 252dd6fc6f53ecd8b28e05a0514429472d53d08e Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 31 Jan 2020 06:46:31 +0100 Subject: viewer: finalized the command buttons. added the 'up to parent' command --- viewer/src/store/uiStore.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'viewer/src/store') diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 6bcc538..f7484de 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -27,6 +27,7 @@ const VuexModule = createModule({ export default class UIStore extends VuexModule { fullscreen: boolean = false; + fullWidth: boolean = true; mode: "navigation" | "search" = "navigation"; currentTags: Tag.Search[] = []; @@ -46,6 +47,10 @@ export default class UIStore extends VuexModule { this.fullscreen = !this.fullscreen; } + @mutation toggleFullWidth() { + this.fullWidth = !this.fullWidth; + } + @mutation setModeNavigation() { this.mode = "navigation"; } -- cgit v1.2.3 From 1e0b65a0a4556810ad4a7acac764a57a7daf8cf0 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 31 Jan 2020 07:10:34 +0100 Subject: viewer: minor code cleaning --- viewer/src/store/galleryStore.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index b2ff74e..1c95fe7 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -46,15 +46,15 @@ export default class GalleryStore extends VuexModule { } get currentItemPath(): Gallery.Item[] { - const galleryItemsRoot = this.galleryItemsRoot; - if (galleryItemsRoot) - return GalleryStore.searchCurrentItemPath(galleryItemsRoot, this.currentPath); + const root = this.galleryItemsRoot; + if (root) + return GalleryStore.searchCurrentItemPath(root, this.currentPath); return []; } get currentItem(): Gallery.Item | null { - const currentItemPath = this.currentItemPath; - return currentItemPath.length > 0 ? currentItemPath[currentItemPath.length - 1] : null; + const path = this.currentItemPath; + return path.length > 0 ? path[path.length - 1] : null; } // --- @@ -69,9 +69,9 @@ export default class GalleryStore extends VuexModule { // Indexes the gallery @action async indexTags() { + const root = this.galleryItemsRoot; let index = {}; - if (this.galleryItemsRoot) - GalleryStore.pushTagsForItem(index, this.galleryItemsRoot); + if (root) GalleryStore.pushTagsForItem(index, root); console.log("Index: ", index); this.setTags(index); } -- cgit v1.2.3 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/store/galleryStore.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'viewer/src/store') 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({ export default class GalleryStore extends VuexModule { + config: Gallery.Config | null = null; galleryItemsRoot: Gallery.Item | null = null; tags: Tag.Index = {}; currentPath: string = "/"; // --- + @mutation setConfig(config: Gallery.Config) { + this.config = config; + } + @mutation setGalleryItemsRoot(galleryItemsRoot: Gallery.Item) { this.galleryItemsRoot = galleryItemsRoot; } @@ -59,9 +64,18 @@ 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`) + .then(config => 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); -- cgit v1.2.3 From af4660b4c4fea455dfffbf2d966bae425ed6effb Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Wed, 12 Feb 2020 21:25:07 +0100 Subject: viewer: project configuration - eof-last enforced --- viewer/src/store/galleryStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 1c95fe7..5ab0c33 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -108,4 +108,4 @@ export default class GalleryStore extends VuexModule { } return []; } -} \ No newline at end of file +} -- cgit v1.2.3 From 1763c8ce725098100618079553a9ec4f79386a5d Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Thu, 13 Feb 2020 17:44:34 +0100 Subject: viewer: no-cache for config.json and index.json --- viewer/src/store/galleryStore.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index bcd4bc9..6f5f0ad 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -66,7 +66,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`) + return fetch(`${process.env.VUE_APP_DATA_URL}config.json`, { cache: "no-cache" }) .then(config => config.json()) .then(this.setConfig); } @@ -75,7 +75,7 @@ export default class GalleryStore extends VuexModule { @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}`) + return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) .then(response => response.json()) .then(this.setGalleryItemsRoot) .then(this.indexTags); -- cgit v1.2.3 From 3503459d9c6e1f601702d79a560514dc44462277 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Thu, 13 Feb 2020 19:44:36 +0100 Subject: viewer: fixed travis error (cherry picked from commit 63fd4f6956bba4158a0d35e64862a69427da08e6) --- viewer/src/store/galleryStore.ts | 1 - 1 file changed, 1 deletion(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index d774588..e7d70f8 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -74,7 +74,6 @@ export default class GalleryStore extends VuexModule { // Fetches the gallery's JSON metadata @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`, { cache: "no-cache" }) .then(response => response.json()) .then(this.setGalleryItemsRoot) -- cgit v1.2.3 From 370e3db3455f548699ff5e046e0f8dcc304991ac Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 14 Feb 2020 09:19:53 +0100 Subject: viewer: major code and search mode overhaul Updated libraries to the lastest version SCSS Formatter as suggested VSC extensions Renamed toolbar-color by scrollbar-color LD components use Props in favor of touching the stores directly (when possible) Moved most common algorithms to a "services" folder Complete search overhaul (lots of code change) --- viewer/src/store/galleryStore.ts | 51 +++++++--------------------------------- viewer/src/store/uiStore.ts | 22 ++--------------- 2 files changed, 10 insertions(+), 63 deletions(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index e7d70f8..d2b28dd 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -18,7 +18,8 @@ */ import { createModule, mutation, action } from "vuex-class-component"; -import Tools from '@/tools'; +import IndexFactory from '@/services/indexfactory'; +import Navigation from '@/services/navigation'; const VuexModule = createModule({ namespaced: "galleryStore", @@ -29,7 +30,7 @@ export default class GalleryStore extends VuexModule { config: Gallery.Config | null = null; galleryItemsRoot: Gallery.Item | null = null; - tags: Tag.Index = {}; + tagsIndex: Tag.Index = {}; currentPath: string = "/"; // --- @@ -42,8 +43,8 @@ export default class GalleryStore extends VuexModule { this.galleryItemsRoot = galleryItemsRoot; } - @mutation private setTags(tags: Tag.Index) { - this.tags = tags; + @mutation private setTagsIndex(tagsIndex: Tag.Index) { + this.tagsIndex = tagsIndex; } @mutation setCurrentPath(currentPath: string) { @@ -53,7 +54,7 @@ export default class GalleryStore extends VuexModule { get currentItemPath(): Gallery.Item[] { const root = this.galleryItemsRoot; if (root) - return GalleryStore.searchCurrentItemPath(root, this.currentPath); + return Navigation.searchCurrentItemPath(root, this.currentPath); return []; } @@ -67,7 +68,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" }) - .then(config => config.json()) + .then(response => response.json()) .then(this.setConfig); } @@ -82,43 +83,7 @@ export default class GalleryStore extends VuexModule { // Indexes the gallery @action async indexTags() { - const root = this.galleryItemsRoot; - let index = {}; - if (root) GalleryStore.pushTagsForItem(index, root); - console.log("Index: ", index); - this.setTags(index); - } - - // --- - - // Pushes all tags for a root item (and its children) to the index - private static pushTagsForItem(index: Tag.Index, item: Gallery.Item) { - console.log("IndexingTagsFor: ", item.path); - if (item.properties.type === "directory") { - item.properties.items.forEach(item => this.pushTagsForItem(index, item)); - return; // Directories are not indexed - } - for (const tag of item.tags) { - const parts = tag.split('.'); - let lastPart: string | null = null; - for (const part of parts) { - if (!index[part]) index[part] = { tag: part, tagfiltered: Tools.normalize(part), items: [], children: {} }; - if (!index[part].items.includes(item)) index[part].items.push(item); - if (lastPart) index[lastPart].children[part] = index[part]; - lastPart = part; - } - } + this.setTagsIndex(IndexFactory.generateTags(this.galleryItemsRoot)); } - // Searches for an item by path from a root item (navigation) - private static searchCurrentItemPath(item: Gallery.Item, path: string): Gallery.Item[] { - if (path === item.path) return [item]; - if (item.properties.type === "directory" && path.startsWith(item.path)) { - const itemChain = item.properties.items - .map(item => this.searchCurrentItemPath(item, path)) - .find(itemChain => itemChain.length > 0); - if (itemChain) return [item, ...itemChain]; - } - return []; - } } diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index f7484de..5b6e1ca 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -28,18 +28,8 @@ export default class UIStore extends VuexModule { fullscreen: boolean = false; fullWidth: boolean = true; - mode: "navigation" | "search" = "navigation"; - currentTags: Tag.Search[] = []; - - // --- - - get isModeSearch() { - return this.mode === "search"; - } - - get isModeNavigation() { - return this.mode === "navigation"; - } + searchMode: boolean = false; + searchFilters: Tag.Search[] = []; // --- @@ -50,12 +40,4 @@ export default class UIStore extends VuexModule { @mutation toggleFullWidth() { this.fullWidth = !this.fullWidth; } - - @mutation setModeNavigation() { - this.mode = "navigation"; - } - - @mutation setModeSearch() { - this.mode = "search"; - } } -- cgit v1.2.3 From 2766f5f9a491c5f7ebf1eeac1c970daec3656be2 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 25 Feb 2020 16:03:00 +0100 Subject: transverse: combine item tree and gallery-wide properties GitHub: closes #142 --- viewer/src/store/galleryStore.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index d2b28dd..cd09996 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -77,6 +77,7 @@ export default class GalleryStore extends VuexModule { const root = this.config?.galleryRoot ?? ''; return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) .then(response => response.json()) + .then(index => index.tree) .then(this.setGalleryItemsRoot) .then(this.indexTags); } -- cgit v1.2.3 From 7c2a2ff46469d5e8f44fb3ec7feae5f798e0baf8 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Thu, 27 Feb 2020 17:23:32 +0100 Subject: viewer: architectural fixes and improvements Make use of VueX's strict mode (which is different from vuex-class-component strict mode) Fixed issues and bad-practices with search filter tags mutations Correctly implement the new index.json format --- viewer/src/store/galleryStore.ts | 23 +++++++++++++++-------- viewer/src/store/index.ts | 3 ++- viewer/src/store/uiStore.ts | 1 - 3 files changed, 17 insertions(+), 10 deletions(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index cd09996..84673b5 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -29,9 +29,10 @@ const VuexModule = createModule({ export default class GalleryStore extends VuexModule { config: Gallery.Config | null = null; - galleryItemsRoot: Gallery.Item | null = null; + galleryIndex: Gallery.Index | null = null; tagsIndex: Tag.Index = {}; currentPath: string = "/"; + currentSearch: Tag.Search[] = []; // --- @@ -39,20 +40,26 @@ export default class GalleryStore extends VuexModule { this.config = config; } - @mutation setGalleryItemsRoot(galleryItemsRoot: Gallery.Item) { - this.galleryItemsRoot = galleryItemsRoot; + @mutation setGalleryIndex(galleryIndex: Gallery.Index) { + this.galleryIndex = Object.freeze(galleryIndex); } @mutation private setTagsIndex(tagsIndex: Tag.Index) { - this.tagsIndex = tagsIndex; + this.tagsIndex = Object.freeze(tagsIndex); } @mutation setCurrentPath(currentPath: string) { this.currentPath = currentPath; } + @mutation setCurrentSearch(currentSearch: Tag.Search[]) { + this.currentSearch = currentSearch; + } + + // --- + get currentItemPath(): Gallery.Item[] { - const root = this.galleryItemsRoot; + const root = this.galleryIndex?.tree; if (root) return Navigation.searchCurrentItemPath(root, this.currentPath); return []; @@ -77,14 +84,14 @@ export default class GalleryStore extends VuexModule { const root = this.config?.galleryRoot ?? ''; return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) .then(response => response.json()) - .then(index => index.tree) - .then(this.setGalleryItemsRoot) + .then(this.setGalleryIndex) .then(this.indexTags); } // Indexes the gallery @action async indexTags() { - this.setTagsIndex(IndexFactory.generateTags(this.galleryItemsRoot)); + const root = this.galleryIndex?.tree ?? null; + this.setTagsIndex(IndexFactory.generateTags(root)); } } diff --git a/viewer/src/store/index.ts b/viewer/src/store/index.ts index 0277fa4..956d4fd 100644 --- a/viewer/src/store/index.ts +++ b/viewer/src/store/index.ts @@ -30,7 +30,8 @@ const store = new Vuex.Store({ modules: { ...extractVuexModule(UIStore), ...extractVuexModule(GalleryStore) - } + }, + strict: process.env.NODE_ENV !== "production", }); Vue.use((vue) => vue.prototype.$uiStore = createProxy(store, UIStore)); diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 5b6e1ca..1e63b3e 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -29,7 +29,6 @@ export default class UIStore extends VuexModule { fullscreen: boolean = false; fullWidth: boolean = true; searchMode: boolean = false; - searchFilters: Tag.Search[] = []; // --- -- cgit v1.2.3 From fd8064319e352a0083c9e282125e658a44e4dabb Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Thu, 27 Feb 2020 22:30:58 +0100 Subject: viewer: set page title New version, making use of the galleryTitle property, from gallery.yaml --- viewer/src/store/galleryStore.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 84673b5..9950f5b 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -70,6 +70,10 @@ export default class GalleryStore extends VuexModule { return path.length > 0 ? path[path.length - 1] : null; } + get galleryTitle(): string { + return this.galleryIndex?.properties.galleryTitle ?? "ldgallery"; + } + // --- // Fetches the gallery's JSON config -- cgit v1.2.3 From 5672ee664abece41adeb59a8b2863d58d1b9b380 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 28 Feb 2020 04:05:02 +0100 Subject: viewer: show/hide the left panel depending on the viewport's width at init GitHub: Resolves #103 --- viewer/src/store/uiStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 1e63b3e..1d0d62f 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -27,7 +27,7 @@ const VuexModule = createModule({ export default class UIStore extends VuexModule { fullscreen: boolean = false; - fullWidth: boolean = true; + fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); searchMode: boolean = false; // --- -- cgit v1.2.3 From 8d889762872501eebd5edb5d7cacddfd4cd55ad4 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 28 Feb 2020 04:09:40 +0100 Subject: viewer: more minor architectural improvement --- viewer/src/store/galleryStore.ts | 2 +- viewer/src/store/uiStore.ts | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 9950f5b..bc43ed2 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -36,7 +36,7 @@ export default class GalleryStore extends VuexModule { // --- - @mutation setConfig(config: Gallery.Config) { + @mutation private setConfig(config: Gallery.Config) { this.config = config; } diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 1e63b3e..21f9ce9 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -21,7 +21,7 @@ import { createModule, mutation, action } from "vuex-class-component"; const VuexModule = createModule({ namespaced: "uiStore", - strict: false + strict: true }) export default class UIStore extends VuexModule { @@ -32,11 +32,15 @@ export default class UIStore extends VuexModule { // --- - @mutation toggleFullscreen() { - this.fullscreen = !this.fullscreen; + @mutation toggleFullscreen(value?: boolean) { + this.fullscreen = value ?? !this.fullscreen; } - @mutation toggleFullWidth() { - this.fullWidth = !this.fullWidth; + @mutation toggleFullWidth(value?: boolean) { + this.fullWidth = value ?? !this.fullWidth; + } + + @mutation toggleSearchMode(value?: boolean) { + this.searchMode = value ?? !this.searchMode; } } -- cgit v1.2.3 From 7f0b8367a2092c5ffd69e9e46d055cbd605c0e3a Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 28 Feb 2020 18:50:12 +0100 Subject: viewer: more minor architectural and performance improvement --- viewer/src/store/galleryStore.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index bc43ed2..4a5de0f 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -95,7 +95,15 @@ export default class GalleryStore extends VuexModule { // Indexes the gallery @action async indexTags() { const root = this.galleryIndex?.tree ?? null; - this.setTagsIndex(IndexFactory.generateTags(root)); + const index = IndexFactory.generateTags(root); + this.setTagsIndex(index); + return index; } + // Searches for tags + @action async search(filters: string[]) { + const results = filters.flatMap(filter => IndexFactory.searchTags(this.tagsIndex, filter, true)); + this.setCurrentSearch(results); + return results; + } } -- cgit v1.2.3 From 577f49ab6e1fd9cd8007804a13dea1471ee2fb1f Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 3 Apr 2020 03:42:35 +0200 Subject: viewer: tag categories implementation GitHub: Resolves #29 --- viewer/src/store/galleryStore.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 4a5de0f..352a266 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -31,6 +31,7 @@ export default class GalleryStore extends VuexModule { config: Gallery.Config | null = null; galleryIndex: Gallery.Index | null = null; tagsIndex: Tag.Index = {}; + tagsCategories: Tag.Category[] = []; currentPath: string = "/"; currentSearch: Tag.Search[] = []; @@ -48,6 +49,10 @@ export default class GalleryStore extends VuexModule { this.tagsIndex = Object.freeze(tagsIndex); } + @mutation private setTagsCategories(tagsCategories: Tag.Category[]) { + this.tagsCategories = tagsCategories; + } + @mutation setCurrentPath(currentPath: string) { this.currentPath = currentPath; } @@ -89,7 +94,8 @@ export default class GalleryStore extends VuexModule { return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) .then(response => response.json()) .then(this.setGalleryIndex) - .then(this.indexTags); + .then(this.indexTags) + .then(this.indexTagCategories); } // Indexes the gallery @@ -100,6 +106,13 @@ export default class GalleryStore extends VuexModule { return index; } + // Indexes the proposed categories + @action async indexTagCategories() { + const categories = IndexFactory.generateCategories(this.tagsIndex, this.galleryIndex?.properties.tagCategories); + this.setTagsCategories(categories); + return categories; + } + // Searches for tags @action async search(filters: string[]) { const results = filters.flatMap(filter => IndexFactory.searchTags(this.tagsIndex, filter, true)); -- cgit v1.2.3 From ccecfd9421f4550a71134cd46e1388e486f8c564 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Tue, 28 Apr 2020 03:47:39 +0200 Subject: viewer: global formatting unification --- viewer/src/store/galleryStore.ts | 190 +++++++++++++++++++-------------------- viewer/src/store/index.ts | 10 +-- viewer/src/store/uiStore.ts | 30 +++---- 3 files changed, 115 insertions(+), 115 deletions(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 352a266..0cffdd9 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -18,105 +18,105 @@ */ import { createModule, mutation, action } from "vuex-class-component"; -import IndexFactory from '@/services/indexfactory'; -import Navigation from '@/services/navigation'; +import IndexFactory from "@/services/indexfactory"; +import Navigation from "@/services/navigation"; const VuexModule = createModule({ - namespaced: "galleryStore", - strict: true + namespaced: "galleryStore", + strict: true }) export default class GalleryStore extends VuexModule { - config: Gallery.Config | null = null; - galleryIndex: Gallery.Index | null = null; - tagsIndex: Tag.Index = {}; - tagsCategories: Tag.Category[] = []; - currentPath: string = "/"; - currentSearch: Tag.Search[] = []; - - // --- - - @mutation private setConfig(config: Gallery.Config) { - this.config = config; - } - - @mutation setGalleryIndex(galleryIndex: Gallery.Index) { - this.galleryIndex = Object.freeze(galleryIndex); - } - - @mutation private setTagsIndex(tagsIndex: Tag.Index) { - this.tagsIndex = Object.freeze(tagsIndex); - } - - @mutation private setTagsCategories(tagsCategories: Tag.Category[]) { - this.tagsCategories = tagsCategories; - } - - @mutation setCurrentPath(currentPath: string) { - this.currentPath = currentPath; - } - - @mutation setCurrentSearch(currentSearch: Tag.Search[]) { - this.currentSearch = currentSearch; - } - - // --- - - get currentItemPath(): Gallery.Item[] { - const root = this.galleryIndex?.tree; - if (root) - return Navigation.searchCurrentItemPath(root, this.currentPath); - return []; - } - - get currentItem(): Gallery.Item | null { - const path = this.currentItemPath; - return path.length > 0 ? path[path.length - 1] : null; - } - - get galleryTitle(): string { - return this.galleryIndex?.properties.galleryTitle ?? "ldgallery"; - } - - // --- - - // Fetches the gallery's JSON config - @action async fetchConfig() { - return fetch(`${process.env.VUE_APP_DATA_URL}config.json`, { cache: "no-cache" }) - .then(response => response.json()) - .then(this.setConfig); - } - - // 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" }) - .then(response => response.json()) - .then(this.setGalleryIndex) - .then(this.indexTags) - .then(this.indexTagCategories); - } - - // Indexes the gallery - @action async indexTags() { - const root = this.galleryIndex?.tree ?? null; - const index = IndexFactory.generateTags(root); - this.setTagsIndex(index); - return index; - } - - // Indexes the proposed categories - @action async indexTagCategories() { - const categories = IndexFactory.generateCategories(this.tagsIndex, this.galleryIndex?.properties.tagCategories); - this.setTagsCategories(categories); - return categories; - } - - // Searches for tags - @action async search(filters: string[]) { - const results = filters.flatMap(filter => IndexFactory.searchTags(this.tagsIndex, filter, true)); - this.setCurrentSearch(results); - return results; - } + config: Gallery.Config | null = null; + galleryIndex: Gallery.Index | null = null; + tagsIndex: Tag.Index = {}; + tagsCategories: Tag.Category[] = []; + currentPath: string = "/"; + currentSearch: Tag.Search[] = []; + + // --- + + @mutation private setConfig(config: Gallery.Config) { + this.config = config; + } + + @mutation setGalleryIndex(galleryIndex: Gallery.Index) { + this.galleryIndex = Object.freeze(galleryIndex); + } + + @mutation private setTagsIndex(tagsIndex: Tag.Index) { + this.tagsIndex = Object.freeze(tagsIndex); + } + + @mutation private setTagsCategories(tagsCategories: Tag.Category[]) { + this.tagsCategories = tagsCategories; + } + + @mutation setCurrentPath(currentPath: string) { + this.currentPath = currentPath; + } + + @mutation setCurrentSearch(currentSearch: Tag.Search[]) { + this.currentSearch = currentSearch; + } + + // --- + + get currentItemPath(): Gallery.Item[] { + const root = this.galleryIndex?.tree; + if (root) + return Navigation.searchCurrentItemPath(root, this.currentPath); + return []; + } + + get currentItem(): Gallery.Item | null { + const path = this.currentItemPath; + return path.length > 0 ? path[path.length - 1] : null; + } + + get galleryTitle(): string { + return this.galleryIndex?.properties.galleryTitle ?? "ldgallery"; + } + + // --- + + // Fetches the gallery's JSON config + @action async fetchConfig() { + return fetch(`${process.env.VUE_APP_DATA_URL}config.json`, { cache: "no-cache" }) + .then(response => response.json()) + .then(this.setConfig); + } + + // 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" }) + .then(response => response.json()) + .then(this.setGalleryIndex) + .then(this.indexTags) + .then(this.indexTagCategories); + } + + // Indexes the gallery + @action async indexTags() { + const root = this.galleryIndex?.tree ?? null; + const index = IndexFactory.generateTags(root); + this.setTagsIndex(index); + return index; + } + + // Indexes the proposed categories + @action async indexTagCategories() { + const categories = IndexFactory.generateCategories(this.tagsIndex, this.galleryIndex?.properties.tagCategories); + this.setTagsCategories(categories); + return categories; + } + + // Searches for tags + @action async search(filters: string[]) { + const results = filters.flatMap(filter => IndexFactory.searchTags(this.tagsIndex, filter, true)); + this.setCurrentSearch(results); + return results; + } } diff --git a/viewer/src/store/index.ts b/viewer/src/store/index.ts index 956d4fd..d5339e8 100644 --- a/viewer/src/store/index.ts +++ b/viewer/src/store/index.ts @@ -17,12 +17,12 @@ -- along with this program. If not, see . */ -import Vue from 'vue' -import Vuex from 'vuex' +import Vue from "vue" +import Vuex from "vuex" import { extractVuexModule } from "vuex-class-component"; import { createProxy } from "vuex-class-component"; -import UIStore from '@/store/uiStore'; -import GalleryStore from '@/store/galleryStore'; +import UIStore from "@/store/uiStore"; +import GalleryStore from "@/store/galleryStore"; Vue.use(Vuex) @@ -37,7 +37,7 @@ const store = new Vuex.Store({ Vue.use((vue) => vue.prototype.$uiStore = createProxy(store, UIStore)); Vue.use((vue) => vue.prototype.$galleryStore = createProxy(store, GalleryStore)); -declare module 'vue/types/vue' { +declare module "vue/types/vue" { interface Vue { $uiStore: UIStore, $galleryStore: GalleryStore diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 2bd315c..892d35e 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -20,27 +20,27 @@ import { createModule, mutation, action } from "vuex-class-component"; const VuexModule = createModule({ - namespaced: "uiStore", - strict: true + namespaced: "uiStore", + strict: true }) export default class UIStore extends VuexModule { - fullscreen: boolean = false; - fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); - searchMode: boolean = false; + fullscreen: boolean = false; + fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); + searchMode: boolean = false; - // --- + // --- - @mutation toggleFullscreen(value?: boolean) { - this.fullscreen = value ?? !this.fullscreen; - } + @mutation toggleFullscreen(value?: boolean) { + this.fullscreen = value ?? !this.fullscreen; + } - @mutation toggleFullWidth(value?: boolean) { - this.fullWidth = value ?? !this.fullWidth; - } + @mutation toggleFullWidth(value?: boolean) { + this.fullWidth = value ?? !this.fullWidth; + } - @mutation toggleSearchMode(value?: boolean) { - this.searchMode = value ?? !this.searchMode; - } + @mutation toggleSearchMode(value?: boolean) { + this.searchMode = value ?? !this.searchMode; + } } -- cgit v1.2.3