aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/views
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/views')
-rw-r--r--viewer/src/views/Gallery.vue104
-rw-r--r--viewer/src/views/GalleryDirectory.vue24
-rw-r--r--viewer/src/views/GalleryNavigation.vue62
-rw-r--r--viewer/src/views/GalleryPicture.vue40
-rw-r--r--viewer/src/views/GallerySearch.vue42
-rw-r--r--viewer/src/views/GalleryThumbnail.vue48
-rw-r--r--viewer/src/views/MainLayout.vue71
-rw-r--r--viewer/src/views/PanelLeft.vue78
-rw-r--r--viewer/src/views/PanelTop.vue64
9 files changed, 237 insertions, 296 deletions
diff --git a/viewer/src/views/Gallery.vue b/viewer/src/views/Gallery.vue
deleted file mode 100644
index fad7cc3..0000000
--- a/viewer/src/views/Gallery.vue
+++ /dev/null
@@ -1,104 +0,0 @@
1<!-- ldgallery - A static generator which turns a collection of tagged
2-- pictures into a searchable web gallery.
3--
4-- Copyright (C) 2019-2020 Guillaume FOUET
5--
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
8-- published by the Free Software Foundation, either version 3 of the
9-- License, or (at your option) any later version.
10--
11-- This program is distributed in the hope that it will be useful,
12-- but WITHOUT ANY WARRANTY; without even the implied warranty of
13-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-- GNU Affero General Public License for more details.
15--
16-- You should have received a copy of the GNU Affero General Public License
17-- along with this program. If not, see <https://www.gnu.org/licenses/>.
18-->
19
20<template>
21 <div>
22 <gallery-search v-if="$uiStore.isModeSearch" :items="currentSearch" />
23 <gallery-directory v-else-if="checkType('directory')" :directory="$galleryStore.currentItem" />
24 <gallery-picture v-else-if="checkType('picture')" :picture="$galleryStore.currentItem" />
25 <div v-else>{{$t("gallery.unknowntype")}}</div>
26 </div>
27</template>
28
29<script lang="ts">
30import { Component, Vue, Prop, Watch } from "vue-property-decorator";
31import { Operation } from '@/@types/tag/Operation';
32import GallerySearch from "./GallerySearch.vue";
33import GalleryDirectory from "./GalleryDirectory.vue";
34import GalleryPicture from "./GalleryPicture.vue";
35
36@Component({
37 components: { GallerySearch, GalleryDirectory, GalleryPicture },
38})
39export default class Gallery extends Vue {
40 @Prop(String) readonly pathMatch!: string;
41
42 mounted() {
43 this.pathChanged()
44 }
45
46 @Watch("pathMatch")
47 pathChanged() {
48 console.log("Path: ", this.pathMatch);
49 this.$galleryStore.setCurrentPath(this.pathMatch);
50 }
51
52 // Results of the search (by tags)
53 get currentSearch(): Gallery.Item[] {
54 const byOperation = this.extractTagsByOperation(this.$uiStore.currentTags);
55 const intersection = this.extractIntersection(byOperation);
56 const substraction = this.extractSubstraction(byOperation);
57 return this.aggregateAll(byOperation, intersection, substraction);
58 }
59
60 // ---
61
62 private checkType(type: string): boolean {
63 return this.$galleryStore.currentItem?.properties.type === type ?? false;
64 }
65
66 private extractTagsByOperation(currentTags: Tag.Search[]): Tag.SearchByOperation {
67 let byOperation: Tag.SearchByOperation = {};
68 Object.values(Operation)
69 .forEach(operation => byOperation[operation] = currentTags.filter(tag => tag.operation === operation));
70 return byOperation;
71 }
72
73 private extractIntersection(byOperation: Tag.SearchByOperation): Set<Gallery.Item> {
74 let intersection = new Set<Gallery.Item>();
75 if (byOperation[Operation.INTERSECTION].length > 0) {
76 byOperation[Operation.INTERSECTION]
77 .map(tag => tag.items)
78 .reduce((a,b) => a.filter(c => b.includes(c)))
79 .flatMap(items=>items)
80 .forEach(item => intersection.add(item));
81 }
82 return intersection;
83 }
84
85 private extractSubstraction(byOperation: Tag.SearchByOperation): Set<Gallery.Item> {
86 let substraction = new Set<Gallery.Item>();
87 if (byOperation[Operation.SUBSTRACTION].length > 0) {
88 byOperation[Operation.SUBSTRACTION]
89 .flatMap(tag => tag.items)
90 .forEach(item => substraction.add(item));
91 }
92 return substraction;
93 }
94
95 private aggregateAll(byOperation: Tag.SearchByOperation, intersection: Set<Gallery.Item>, substraction: Set<Gallery.Item>): Gallery.Item[] {
96 byOperation[Operation.ADDITION].flatMap(tag => tag.items).forEach(item => intersection.add(item));
97 substraction.forEach(item => intersection.delete(item));
98 return [...intersection];
99 }
100}
101</script>
102
103<style lang="scss">
104</style>
diff --git a/viewer/src/views/GalleryDirectory.vue b/viewer/src/views/GalleryDirectory.vue
index eb98595..30f651c 100644
--- a/viewer/src/views/GalleryDirectory.vue
+++ b/viewer/src/views/GalleryDirectory.vue
@@ -18,26 +18,24 @@
18--> 18-->
19 19
20<template> 20<template>
21 <div> 21 <ld-gallery :items="orderedItems()" :noresult="$t('directory.no-results')" />
22 <div class="flex">
23 <div v-for="(item) in directory.properties.items" :key="item.path">
24 <router-link :to="item.path">
25 <gallery-thumbnail :item="item" />
26 </router-link>
27 </div>
28 </div>
29 </div>
30</template> 22</template>
31 23
32<script lang="ts"> 24<script lang="ts">
33import { Component, Vue, Prop } from "vue-property-decorator"; 25import { Component, Vue, Prop } from "vue-property-decorator";
34import GalleryThumbnail from "./GalleryThumbnail.vue"; 26import Navigation from "@/services/navigation";
35 27
36@Component({ 28@Component
37 components: { GalleryThumbnail },
38})
39export default class GalleryDirectory extends Vue { 29export default class GalleryDirectory extends Vue {
40 @Prop({ required: true }) readonly directory!: Gallery.Directory; 30 @Prop({ required: true }) readonly directory!: Gallery.Directory;
31
32 mounted() {
33 this.$uiStore.toggleFullscreen(false);
34 }
35
36 orderedItems() {
37 return Navigation.directoriesFirst(this.directory.properties.items);
38 }
41} 39}
42</script> 40</script>
43 41
diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
new file mode 100644
index 0000000..7c6d11b
--- /dev/null
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -0,0 +1,62 @@
1<!-- ldgallery - A static generator which turns a collection of tagged
2-- pictures into a searchable web gallery.
3--
4-- Copyright (C) 2019-2020 Guillaume FOUET
5--
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
8-- published by the Free Software Foundation, either version 3 of the
9-- License, or (at your option) any later version.
10--
11-- This program is distributed in the hope that it will be useful,
12-- but WITHOUT ANY WARRANTY; without even the implied warranty of
13-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-- GNU Affero General Public License for more details.
15--
16-- You should have received a copy of the GNU Affero General Public License
17-- along with this program. If not, see <https://www.gnu.org/licenses/>.
18-->
19
20<template>
21 <div>
22 <gallery-search v-if="query.length" :path="path" />
23 <gallery-directory v-else-if="checkType('directory')" :directory="$galleryStore.currentItem" />
24 <ld-picture v-else-if="checkType('picture')" :picture="$galleryStore.currentItem" />
25 <div v-else>{{$t("gallery.unknowntype")}}</div>
26 </div>
27</template>
28
29<script lang="ts">
30import { Component, Vue, Prop, Watch } from "vue-property-decorator";
31import { Operation } from "@/@types/Operation";
32import Navigation from "@/services/navigation";
33import GalleryDirectory from "./GalleryDirectory.vue";
34import GallerySearch from "@/views/GallerySearch.vue";
35
36@Component({
37 components: {
38 GalleryDirectory,
39 GallerySearch,
40 },
41})
42export default class GalleryNavigation extends Vue {
43 @Prop(String) readonly path!: string;
44 @Prop(Array) readonly query!: string[];
45
46 mounted() {
47 this.pathChanged();
48 }
49
50 @Watch("path")
51 pathChanged() {
52 this.$galleryStore.setCurrentPath(this.path);
53 }
54
55 private checkType(type: Gallery.ItemType): boolean {
56 return Navigation.checkType(this.$galleryStore.currentItem, type);
57 }
58}
59</script>
60
61<style lang="scss">
62</style>
diff --git a/viewer/src/views/GalleryPicture.vue b/viewer/src/views/GalleryPicture.vue
deleted file mode 100644
index 3689cb3..0000000
--- a/viewer/src/views/GalleryPicture.vue
+++ /dev/null
@@ -1,40 +0,0 @@
1<!-- ldgallery - A static generator which turns a collection of tagged