diff options
author | pacien | 2022-09-04 18:18:27 +0200 |
---|---|---|
committer | pacien | 2022-09-04 18:18:27 +0200 |
commit | 11bbbae2850b9c45da697a8ed9626495a50a38c0 (patch) | |
tree | ff2713118f8b45d36905bfea2933f08d8e70066d /viewer/src/views | |
parent | e93f7b1eb84c083d67567115284c0002a3a7d5fc (diff) | |
parent | 8349be992b46b77dee921f484cfbff8b758ff756 (diff) | |
download | ldgallery-11bbbae2850b9c45da697a8ed9626495a50a38c0.tar.gz |
Merge branch 'develop': release v2.1v2.1
GitHub: related to #315
Diffstat (limited to 'viewer/src/views')
25 files changed, 2023 insertions, 292 deletions
diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue index fd1f19a..0869aaf 100644 --- a/viewer/src/views/GalleryNavigation.vue +++ b/viewer/src/views/GalleryNavigation.vue | |||
@@ -1,7 +1,7 @@ | |||
1 | <!-- ldgallery - A static generator which turns a collection of tagged | 1 | <!-- ldgallery - A static generator which turns a collection of tagged |
2 | -- pictures into a searchable web gallery. | 2 | -- pictures into a searchable web gallery. |
3 | -- | 3 | -- |
4 | -- Copyright (C) 2019-2020 Guillaume FOUET | 4 | -- Copyright (C) 2019-2022 Guillaume FOUET |
5 | -- | 5 | -- |
6 | -- This program is free software: you can redistribute it and/or modify | 6 | -- This program is free software: you can redistribute it and/or modify |
7 | -- it under the terms of the GNU Affero General Public License as | 7 | -- it under the terms of the GNU Affero General Public License as |
@@ -19,62 +19,63 @@ | |||
19 | 19 | ||
20 | <template> | 20 | <template> |
21 | <div> | 21 | <div> |
22 | <ld-error v-if="isError" icon="folder-open" :message="$t('gallery.unknown-resource')" /> | 22 | <LdNotice |
23 | <gallery-search v-else-if="isSearch" :path="path" /> | 23 | v-if="isError" |
24 | <component :is="componentName" v-else :item="$galleryStore.currentItem" /> | 24 | :icon="faFolderOpen" |
25 | :message="t('gallery.unknown-resource')" | ||
26 | /> | ||
27 | <GallerySearch v-else-if="isSearch" /> | ||
28 | <component | ||
29 | :is="componentName" | ||
30 | v-else | ||
31 | :key="componentKey" | ||
32 | :item="galleryStore.currentItem" | ||
33 | /> | ||
25 | </div> | 34 | </div> |
26 | </template> | 35 | </template> |
27 | 36 | ||
28 | <script lang="ts"> | 37 | <script setup lang="ts"> |
29 | import { Component, Vue, Prop, Watch } from "vue-property-decorator"; | 38 | import { ItemType } from '@/@types/itemType'; |
30 | import { ItemType } from "@/@types/ItemType"; | 39 | import LdNotice from '@/components/LdNotice.vue'; |
31 | import Navigation from "@/services/navigation"; | 40 | import { isDirectory } from '@/services/itemGuards'; |
32 | import GallerySearch from "@/views/GallerySearch.vue"; | 41 | import { useGalleryStore } from '@/store/galleryStore'; |
42 | import { faFolderOpen } from '@fortawesome/free-solid-svg-icons'; | ||
43 | import { computedEager } from '@vueuse/shared'; | ||
44 | import { computed, watchEffect } from 'vue'; | ||
45 | import { useI18n } from 'vue-i18n'; | ||
46 | import GallerySearch from './GallerySearch.vue'; | ||
47 | import AudioViewer from './item_handlers/AudioViewer.vue'; | ||
48 | import DirectoryViewer from './item_handlers/DirectoryViewer.vue'; | ||
49 | import DownloadViewer from './item_handlers/DownloadViewer.vue'; | ||
50 | import MarkdownViewer from './item_handlers/MarkdownViewer.vue'; | ||
51 | import PdfViewer from './item_handlers/PdfViewer.vue'; | ||
52 | import PictureViewer from './item_handlers/PictureViewer.vue'; | ||
53 | import PlainTextViewer from './item_handlers/PlainTextViewer.vue'; | ||
54 | import VideoViewer from './item_handlers/VideoViewer.vue'; | ||
33 | 55 | ||
34 | @Component({ | 56 | const props = defineProps({ |
35 | components: { | 57 | path: { type: String, required: true }, |
36 | GallerySearch, | 58 | query: { type: Array<string>, required: true }, |
37 | }, | 59 | }); |
38 | }) | ||
39 | export default class GalleryNavigation extends Vue { | ||
40 | @Prop(String) readonly path!: string; | ||
41 | @Prop(Array) readonly query!: string[]; | ||
42 | 60 | ||
43 | readonly COMPONENT_BY_TYPE: Record<ItemType, string> = { | 61 | const { t } = useI18n(); |
44 | directory: "ld-directory", | 62 | const galleryStore = useGalleryStore(); |
45 | picture: "ld-picture", | ||
46 | plaintext: "ld-plain-text-viewer", | ||
47 | pdf: "ld-pdf-viewer", | ||
48 | video: "ld-video-viewer", | ||
49 | audio: "ld-audio-viewer", | ||
50 | other: "ld-download", | ||
51 | }; | ||
52 | 63 | ||
53 | mounted() { | 64 | const COMPONENT_BY_TYPE: Record<ItemType, unknown> = { |
54 | this.pathChanged(); | 65 | directory: DirectoryViewer, |
55 | } | 66 | picture: PictureViewer, |
67 | plaintext: PlainTextViewer, | ||
68 | markdown: MarkdownViewer, | ||
69 | pdf: PdfViewer, | ||
70 | video: VideoViewer, | ||
71 | audio: AudioViewer, | ||
72 | other: DownloadViewer, | ||
73 | }; | ||
56 | 74 | ||
57 | get isError() { | 75 | const isError = computedEager(() => !galleryStore.currentItem?.properties.type); |
58 | return this.checkType(null); | 76 | const isSearch = computedEager(() => isDirectory(galleryStore.currentItem) && props.query.length > 0); |
59 | } | 77 | const componentName = computed(() => COMPONENT_BY_TYPE[galleryStore.currentItem?.properties.type ?? ItemType.OTHER]); |
78 | const componentKey = computed(() => galleryStore.currentItem?.path ?? ''); | ||
60 | 79 | ||
61 | get isSearch() { | 80 | watchEffect(() => (galleryStore.currentPath = props.path)); |
62 | return this.checkType(ItemType.DIRECTORY) && this.query.length > 0; | ||
63 | } | ||
64 | |||
65 | get componentName() { | ||
66 | return this.COMPONENT_BY_TYPE[this.$galleryStore.currentItem?.properties.type ?? ItemType.OTHER]; | ||
67 | } | ||
68 | |||
69 | @Watch("path") | ||
70 | pathChanged() { | ||
71 | this.$galleryStore.setCurrentPath(this.path); | ||
72 | } | ||
73 | |||
74 | checkType(type: ItemType | null): boolean { | ||
75 | return Navigation.checkType(this.$galleryStore.currentItem, type); | ||
76 | } | ||
77 | } | ||
78 | </script> | 81 | </script> |
79 | |||
80 | <style lang="scss"></style> | ||
diff --git a/viewer/src/views/GallerySearch.vue b/viewer/src/views/GallerySearch.vue index fec7216..d148b9c 100644 --- a/viewer/src/views/GallerySearch.vue +++ b/viewer/src/views/GallerySearch.vue | |||
@@ -1,7 +1,7 @@ | |||
1 | <!-- ldgallery - A static generator which turns a collection of tagged | 1 | <!-- ldgallery - A static generator which turns a collection of tagged |
2 | -- pictures into a searchable web gallery. | 2 | -- pictures into a searchable web gallery. |
3 | -- | 3 | -- |
4 | -- Copyright (C) 2019-2020 Guillaume FOUET | 4 | -- Copyright (C) 2019-2022 Guillaume FOUET |
5 | -- | 5 | -- |
6 | -- This program is free software: you can redistribute it and/or modify | 6 | -- This program is free software: you can redistribute it and/or modify |
7 | -- it under the terms of the GNU Affero General Public License as | 7 | -- it under the terms of the GNU Affero General Public License as |
@@ -18,40 +18,39 @@ | |||
18 | --> | 18 | --> |
19 | 19 | ||
20 | <template> | 20 | <template> |
21 | <ld-gallery :items="items" :noresult="noResult" /> | 21 | <GalleryTiles |
22 | :items="items.filteredByPath" | ||
23 | :noresult-message="noResult" | ||
24 | /> | ||
22 | </template> | 25 | </template> |
23 | 26 | ||
24 | <script lang="ts"> | 27 | <script setup lang="ts"> |
25 | import { Component, Vue, Prop } from "vue-property-decorator"; | 28 | import { useIndexSearch } from '@/services/indexSearch'; |
26 | import { Operation } from "@/@types/Operation"; | 29 | import { useGalleryStore } from '@/store/galleryStore'; |
27 | import IndexSearch from "@/services/indexsearch"; | 30 | import { useUiStore } from '@/store/uiStore'; |
28 | 31 | import { computed, onUnmounted } from 'vue'; | |
29 | @Component | 32 | import { useI18n } from 'vue-i18n'; |
30 | export default class GalleryPicture extends Vue { | 33 | import GalleryTiles from './GalleryTiles.vue'; |
31 | @Prop(String) readonly path!: string; | 34 | |
32 | otherCount: number = 0; | 35 | const { t } = useI18n(); |
33 | 36 | const uiStore = useUiStore(); | |
34 | mounted() { | 37 | const galleryStore = useGalleryStore(); |
35 | this.$uiStore.toggleFullscreen(false); | 38 | const indexSearch = useIndexSearch(); |
36 | this.$uiStore.toggleSearchMode(true); | 39 | |
37 | } | 40 | uiStore.toggleFullscreen(false); |
38 | 41 | uiStore.searchMode = true; | |
39 | destroyed() { | 42 | onUnmounted(() => { |
40 | this.$uiStore.toggleSearchMode(false); | 43 | uiStore.searchMode = false; |
41 | this.$galleryStore.setCurrentSearch([]); | 44 | galleryStore.currentSearch = []; |
42 | } | 45 | }); |
43 | 46 | ||
44 | get items() { |