aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/views
diff options
context:
space:
mode:
authorNotkea2020-01-10 22:31:47 +0100
committerGitHub2020-01-10 22:31:47 +0100
commit7042ffc06326fa8ffe70f5a59747709250166c16 (patch)
treedbfc7567bd106e03a47b499d2a07cecb6b8d6305 /viewer/src/views
parentc9264b0a0a7e1cb92ef7d9a391cee2c94376cff3 (diff)
parent27b51018525dbb7a6edb3073819d82245387ddd3 (diff)
downloadldgallery-7042ffc06326fa8ffe70f5a59747709250166c16.tar.gz
Merge pull request #34 from pacien/develop
first working prototype
Diffstat (limited to 'viewer/src/views')
-rw-r--r--viewer/src/views/Gallery.vue104
-rw-r--r--viewer/src/views/GalleryDirectory.vue45
-rw-r--r--viewer/src/views/GalleryPicture.vue40
-rw-r--r--viewer/src/views/GallerySearch.vue44
-rw-r--r--viewer/src/views/GalleryThumbnail.vue48
-rw-r--r--viewer/src/views/MainLayout.vue121
-rw-r--r--viewer/src/views/PanelLeft.vue42
-rw-r--r--viewer/src/views/PanelTop.vue86
8 files changed, 530 insertions, 0 deletions
diff --git a/viewer/src/views/Gallery.vue b/viewer/src/views/Gallery.vue
new file mode 100644
index 0000000..fad7cc3
--- /dev/null
+++ b/viewer/src/views/Gallery.vue
@@ -0,0 +1,104 @@
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
new file mode 100644
index 0000000..eb98595
--- /dev/null
+++ b/viewer/src/views/GalleryDirectory.vue
@@ -0,0 +1,45 @@
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 <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>
31
32<script lang="ts">
33import { Component, Vue, Prop } from "vue-property-decorator";
34import GalleryThumbnail from "./GalleryThumbnail.vue";
35
36@Component({
37 components: { GalleryThumbnail },
38})
39export default class GalleryDirectory extends Vue {
40 @Prop({ required: true }) readonly directory!: Gallery.Directory;
41}
42</script>
43
44<style lang="scss">
45</style>
diff --git a/viewer/src/views/GalleryPicture.vue b/viewer/src/views/GalleryPicture.vue
new file mode 100644
index 0000000..3689cb3
--- /dev/null
+++ b/viewer/src/views/GalleryPicture.vue
@@ -0,0 +1,40 @@
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 <img :src="pictureSrc" />
23 </div>
24</template>
25
26<script lang="ts">
27import { Component, Vue, Prop } from "vue-property-decorator";
28
29@Component
30export default class GalleryPicture extends Vue {
31 @Prop({ required: true }) readonly picture!: Gallery.Picture;
32
33 get pictureSrc() {
34 return `${process.env.VUE_APP_DATA_URL}${this.picture.properties.resource}`;
35 }
36}
37</script>
38
39<style lang="scss">
40</style>
diff --git a/viewer/src/views/GallerySearch.vue b/viewer/src/views/GallerySearch.vue
new file mode 100644
index 0000000..7e61f89
--- /dev/null
+++ b/viewer/src/views/GallerySearch.vue
@@ -0,0 +1,44 @@
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>