From a681accaa7617892bb7c53248aa9030a4eb47f50 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Sat, 28 Dec 2019 04:52:30 +0100 Subject: viewer: Tag propositions. Disabled directory indexation. Note: The propositions are not based on the current search results, but on the searched tags, which doesn't seem to be the correct way. We'll probably have to move the search results to a store for global visibility. --- viewer/src/@types/gallery/index.d.ts | 3 +- viewer/src/@types/tag/index.d.ts | 2 +- viewer/src/components/LdProposition.vue | 75 +++++++++++++++++++++++++++++++++ viewer/src/locales/en.json | 3 +- viewer/src/plugins/fontawesome.ts | 6 ++- viewer/src/store/galleryStore.ts | 6 ++- viewer/src/views/PanelLeft.vue | 2 + 7 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 viewer/src/components/LdProposition.vue diff --git a/viewer/src/@types/gallery/index.d.ts b/viewer/src/@types/gallery/index.d.ts index b47c812..310c865 100644 --- a/viewer/src/@types/gallery/index.d.ts +++ b/viewer/src/@types/gallery/index.d.ts @@ -9,7 +9,7 @@ declare namespace Gallery { title: string, date: string, description: string, - tags: string[], + tags: RawTag[], path: string, thumbnail: { path: string, @@ -28,4 +28,5 @@ declare namespace Gallery { type: "directory", items: Item[] } + type RawTag = string; } \ No newline at end of file diff --git a/viewer/src/@types/tag/index.d.ts b/viewer/src/@types/tag/index.d.ts index 6a0c605..181f47a 100644 --- a/viewer/src/@types/tag/index.d.ts +++ b/viewer/src/@types/tag/index.d.ts @@ -1,6 +1,6 @@ declare namespace Tag { interface Node { - tag: string; + tag: Gallery.RawTag; items: Gallery.Item[]; children: Index; } diff --git a/viewer/src/components/LdProposition.vue b/viewer/src/components/LdProposition.vue new file mode 100644 index 0000000..b23c14a --- /dev/null +++ b/viewer/src/components/LdProposition.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/viewer/src/locales/en.json b/viewer/src/locales/en.json index d885872..4c9f5d4 100644 --- a/viewer/src/locales/en.json +++ b/viewer/src/locales/en.json @@ -5,5 +5,6 @@ "panelLeft.mode": "Mode", "mode.navigation": "Navigation", "mode.search": "Search", - "search.no-results": "No results" + "search.no-results": "No results", + "panelLeft.propositions": "Proposed tags" } \ No newline at end of file diff --git a/viewer/src/plugins/fontawesome.ts b/viewer/src/plugins/fontawesome.ts index ba31c9e..7308afe 100644 --- a/viewer/src/plugins/fontawesome.ts +++ b/viewer/src/plugins/fontawesome.ts @@ -6,7 +6,9 @@ import { faExpandArrowsAlt, faFolder, faSearch, - faTag + faTag, + faPlus, + faMinus, } from "@fortawesome/free-solid-svg-icons"; library.add( @@ -14,6 +16,8 @@ library.add( faFolder, faSearch, faTag, + faPlus, + faMinus, ); Vue.component("fa-icon", FontAwesomeIcon); diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 8a611ea..179fbe2 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -44,6 +44,10 @@ export default class GalleryStore extends VuexModule { // 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; @@ -54,8 +58,6 @@ export default class GalleryStore extends VuexModule { lastPart = part; } } - if (item.properties.type === "directory") - item.properties.items.forEach(item => this.pushTagsForItem(index, item)); } // Searches for an item by path from a root item (navigation) diff --git a/viewer/src/views/PanelLeft.vue b/viewer/src/views/PanelLeft.vue index c187ce6..df1fe54 100644 --- a/viewer/src/views/PanelLeft.vue +++ b/viewer/src/views/PanelLeft.vue @@ -4,6 +4,8 @@

{{$t('panelLeft.filters')}}

+

{{$t('panelLeft.propositions')}}

+ -- cgit v1.2.3