aboutsummaryrefslogtreecommitdiff
path: root/viewer
diff options
context:
space:
mode:
Diffstat (limited to 'viewer')
-rw-r--r--viewer/package-lock.json8
-rw-r--r--viewer/package.json1
-rw-r--r--viewer/src/assets/scss/theme.scss2
-rw-r--r--viewer/src/components/LdCommand.vue1
-rw-r--r--viewer/src/components/LdCommandSort.vue57
-rw-r--r--viewer/src/components/LdGallery.vue6
-rw-r--r--viewer/src/locales/en.json4
-rw-r--r--viewer/src/plugins/buefy.ts3
-rw-r--r--viewer/src/plugins/fontawesome-icons.ts3
-rw-r--r--viewer/src/services/itemSortFn.ts28
-rw-r--r--viewer/src/store/galleryStore.ts4
-rw-r--r--viewer/src/store/uiStore.ts8
-rw-r--r--viewer/src/views/MainLayout.vue8
13 files changed, 127 insertions, 6 deletions
diff --git a/viewer/package-lock.json b/viewer/package-lock.json
index 5898393..6b57e8e 100644
--- a/viewer/package-lock.json
+++ b/viewer/package-lock.json
@@ -1191,6 +1191,14 @@
1191 "@fortawesome/fontawesome-common-types": "^0.2.30" 1191 "@fortawesome/fontawesome-common-types": "^0.2.30"
1192 } 1192 }
1193 }, 1193 },
1194 "@fortawesome/free-regular-svg-icons": {
1195 "version": "5.14.0",
1196 "resolved": "https://registry.npmjs.org/@fortawesome/free-regular-svg-icons/-/free-regular-svg-icons-5.14.0.tgz",
1197 "integrity": "sha512-6LCFvjGSMPoUQbn3NVlgiG4CY5iIY8fOm+to/D6QS/GvdqhDt+xZklQeERdCvVRbnFa1ITc1rJHPRXqkX5wztQ==",
1198 "requires": {
1199 "@fortawesome/fontawesome-common-types": "^0.2.30"
1200 }
1201 },
1194 "@fortawesome/free-solid-svg-icons": { 1202 "@fortawesome/free-solid-svg-icons": {
1195 "version": "5.14.0", 1203 "version": "5.14.0",
1196 "resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.14.0.tgz", 1204 "resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.14.0.tgz",
diff --git a/viewer/package.json b/viewer/package.json
index 74e0636..892125a 100644
--- a/viewer/package.json
+++ b/viewer/package.json
@@ -15,6 +15,7 @@
15 "dependencies": { 15 "dependencies": {
16 "@fortawesome/fontawesome-svg-core": "1.2.30", 16 "@fortawesome/fontawesome-svg-core": "1.2.30",
17 "@fortawesome/free-solid-svg-icons": "5.14.0", 17 "@fortawesome/free-solid-svg-icons": "5.14.0",
18 "@fortawesome/free-regular-svg-icons": "5.14.0",
18 "@fortawesome/vue-fontawesome": "2.0.0", 19 "@fortawesome/vue-fontawesome": "2.0.0",
19 "@types/hammerjs": "2.0.36", 20 "@types/hammerjs": "2.0.36",
20 "@types/marked": "1.1.0", 21 "@types/marked": "1.1.0",
diff --git a/viewer/src/assets/scss/theme.scss b/viewer/src/assets/scss/theme.scss
index c59eba9..19fe673 100644
--- a/viewer/src/assets/scss/theme.scss
+++ b/viewer/src/assets/scss/theme.scss
@@ -54,6 +54,8 @@ $button-focus-color: $button-color;
54$button-focus-border-color: $link; 54$button-focus-border-color: $link;
55$button-focus-box-shadow-size: 0; 55$button-focus-box-shadow-size: 0;
56$body-line-height: 1.5; 56$body-line-height: 1.5;
57$dropdown-item-color: $palette-900;
58$dropdown-item-active-color: $palette-900;
57 59
58// Custom components 60// Custom components
59 61
diff --git a/viewer/src/components/LdCommand.vue b/viewer/src/components/LdCommand.vue
index d3705de..6059162 100644
--- a/viewer/src/components/LdCommand.vue
+++ b/viewer/src/components/LdCommand.vue
@@ -23,6 +23,7 @@
23 <a class="link" :title="$t('command.search')" @click="$uiStore.toggleFullWidth()"> 23 <a class="link" :title="$t('command.search')" @click="$uiStore.toggleFullWidth()">
24 <fa-icon :icon="commandToggleSearchPanelIcon" size="lg" /> 24 <fa-icon :icon="commandToggleSearchPanelIcon" size="lg" />
25 </a> 25 </a>
26 <ld-command-sort />
26 <a 27 <a
27 :class="{ disabled: isEntryPoint }" 28 :class="{ disabled: isEntryPoint }"
28 class="link command-secondary" 29 class="link command-secondary"
diff --git a/viewer/src/components/LdCommandSort.vue b/viewer/src/components/LdCommandSort.vue
new file mode 100644
index 0000000..1d2eac3
--- /dev/null
+++ b/viewer/src/components/LdCommandSort.vue
@@ -0,0 +1,57 @@
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-- 2020 Pacien TRAN-GIRARD
6--
7-- This program is free software: you can redistribute it and/or modify
8-- it under the terms of the GNU Affero General Public License as
9-- published by the Free Software Foundation, either version 3 of the
10-- License, or (at your option) any later version.
11--
12-- This program is distributed in the hope that it will be useful,
13-- but WITHOUT ANY WARRANTY; without even the implied warranty of
14-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-- GNU Affero General Public License for more details.
16--
17-- You should have received a copy of the GNU Affero General Public License
18-- along with this program. If not, see <https://www.gnu.org/licenses/>.
19-->
20
21<template>
22 <b-dropdown v-model="selectedSort" :mobile-modal="false" append-to-body @change="onChangeSort">
23 <a slot="trigger" class="link">
24 <fa-icon icon="sort-amount-down" size="lg" />
25 </a>
26 <b-dropdown-item v-for="(sort, idx) in SORTS" :key="idx" :value="idx">
27 <fa-icon :icon="['far', idx === selectedSort ? 'dot-circle' : 'circle']" />
28 <span :class="$style.ml1">{{ sort.name }}</span>
29 </b-dropdown-item>
30 </b-dropdown>
31</template>
32
33<script lang="ts">
34import { Component, Vue, Prop } from "vue-property-decorator";
35import { RawLocation } from "vue-router";
36import ItemSortFn from "@/services/itemSortFn";
37
38@Component
39export default class LdCommandSort extends Vue {
40 readonly SORTS = [
41 { name: this.$t("command.sort.byName"), fn: ItemSortFn.sortByName },
42 { name: this.$t("command.sort.byDateDesc"), fn: ItemSortFn.sortByDateDesc },
43 ];
44
45 selectedSort = 0;
46
47 onChangeSort(newValue: number) {
48 this.$uiStore.setSortFn(this.SORTS[newValue].fn);
49 }
50}
51</script>
52
53<style lang="scss" module>
54.ml1 {
55 margin-left: 0.5em;
56}
57</style>
diff --git a/viewer/src/components/LdGallery.vue b/viewer/src/components/LdGallery.vue
index 5a72d99..0c0a43c 100644
--- a/viewer/src/components/LdGallery.vue
+++ b/viewer/src/components/LdGallery.vue
@@ -20,7 +20,7 @@
20<template> 20<template>
21 <ld-error v-if="hasNoResults" icon="search" :message="noresult" /> 21 <ld-error v-if="hasNoResults" icon="search" :message="noresult" />
22 <div v-else class="thumbnail-tiles"> 22 <div v-else class="thumbnail-tiles">
23 <router-link v-for="item in items" :key="item.path" :to="item.path"> 23 <router-link v-for="item in sortedItems" :key="item.path" :to="item.path">
24 <ld-thumbnail :item="item" /> 24 <ld-thumbnail :item="item" />
25 </router-link> 25 </router-link>
26 </div> 26 </div>
@@ -35,6 +35,10 @@ export default class LdPicture extends Vue {
35 @Prop({ type: Array, required: true }) readonly items!: Gallery.Item[]; 35 @Prop({ type: Array, required: true }) readonly items!: Gallery.Item[];
36 @Prop(String) readonly noresult?: string; 36 @Prop(String) readonly noresult?: string;
37 37
38 get sortedItems() {
39 return this.items.sort(this.$uiStore.sortFn);
40 }
41
38 get hasNoResults(): boolean { 42 get hasNoResults(): boolean {
39 return Boolean(this.noresult) && this.items.length === 0; 43 return Boolean(this.noresult) && this.items.length === 0;
40 } 44 }
diff --git a/viewer/src/locales/en.json b/viewer/src/locales/en.json
index b36ac57..915f600 100644
--- a/viewer/src/locales/en.json
+++ b/viewer/src/locales/en.json
@@ -17,5 +17,7 @@
17 "directory.no-results": "Empty directory", 17 "directory.no-results": "Empty directory",
18 "panelLeft.propositions.other": "other filters", 18 "panelLeft.propositions.other": "other filters",
19 "panelLeft.information.title": "Information", 19 "panelLeft.information.title": "Information",
20 "tag-propositions.showmore": "show more ({0})" 20 "tag-propositions.showmore": "show more ({0})",
21 "command.sort.byName": "By name",
22 "command.sort.byDateDesc": "By most recent"
21} 23}
diff --git a/viewer/src/plugins/buefy.ts b/viewer/src/plugins/buefy.ts
index 7a71019..4794ad9 100644
--- a/viewer/src/plugins/buefy.ts
+++ b/viewer/src/plugins/buefy.ts
@@ -29,6 +29,8 @@ import Button from "buefy/src/components/button";
29import SnackBar from "buefy/src/components/snackbar"; 29import SnackBar from "buefy/src/components/snackbar";
30// @ts-ignore 30// @ts-ignore
31import Tag from "buefy/src/components/tag"; 31import Tag from "buefy/src/components/tag";
32// @ts-ignore
33import DropDown from "buefy/src/components/dropdown";
32 34
33import "@/assets/scss/buefy.scss"; 35import "@/assets/scss/buefy.scss";
34 36
@@ -37,6 +39,7 @@ Vue.use(Loading);
37Vue.use(Button); 39Vue.use(Button);
38Vue.use(SnackBar); 40Vue.use(SnackBar);
39Vue.use(Tag); 41Vue.use(Tag);
42Vue.use(DropDown);
40 43
41declare module "vue/types/vue" { 44declare module "vue/types/vue" {
42 interface Vue { 45 interface Vue {
diff --git a/viewer/src/plugins/fontawesome-icons.ts b/viewer/src/plugins/fontawesome-icons.ts
index 8d136a6..4b50641 100644
--- a/viewer/src/plugins/fontawesome-icons.ts
+++ b/viewer/src/plugins/fontawesome-icons.ts
@@ -39,4 +39,7 @@ export {
39 faCaretUp, 39 faCaretUp,
40 faCaretDown, 40 faCaretDown,
41 faAngleDoubleDown, 41 faAngleDoubleDown,
42 faSortAmountDown,
42} from "@fortawesome/free-solid-svg-icons"; 43} from "@fortawesome/free-solid-svg-icons";
44
45export { faCircle, faDotCircle } from "@fortawesome/free-regular-svg-icons";
diff --git a/viewer/src/services/itemSortFn.ts b/viewer/src/services/itemSortFn.ts
new file mode 100644
index 0000000..ec9942c
--- /dev/null
+++ b/viewer/src/services/itemSortFn.ts
@@ -0,0 +1,28 @@
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
20export default class ItemSortFn {
21 static sortByName(left: Gallery.Item, right: Gallery.Item): number {
22 return left.title.localeCompare(right.title);