aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/store
diff options
context:
space:
mode:
authorZero~Informatique2020-04-28 03:47:39 +0200
committerZero~Informatique2020-04-28 03:47:50 +0200
commitccecfd9421f4550a71134cd46e1388e486f8c564 (patch)
tree9711ed24320150d24d85a124de3fd6177052eeb0 /viewer/src/store
parent113bff3c4dcc1976f24df16d4224e1871e665ae0 (diff)
downloadldgallery-ccecfd9421f4550a71134cd46e1388e486f8c564.tar.gz
viewer: global formatting unification
Diffstat (limited to 'viewer/src/store')
-rw-r--r--viewer/src/store/galleryStore.ts190
-rw-r--r--viewer/src/store/index.ts10
-rw-r--r--viewer/src/store/uiStore.ts30
3 files changed, 115 insertions, 115 deletions
diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts
index 352a266..0cffdd9 100644
--- a/viewer/src/store/galleryStore.ts
+++ b/viewer/src/store/galleryStore.ts
@@ -18,105 +18,105 @@
18*/ 18*/
19 19
20import { createModule, mutation, action } from "vuex-class-component"; 20import { createModule, mutation, action } from "vuex-class-component";
21import IndexFactory from '@/services/indexfactory'; 21import IndexFactory from "@/services/indexfactory";
22import Navigation from '@/services/navigation'; 22import Navigation from "@/services/navigation";
23 23
24const VuexModule = createModule({ 24const VuexModule = createModule({
25 namespaced: "galleryStore", 25 namespaced: "galleryStore",
26 strict: true 26 strict: true
27}) 27})
28 28
29export default class GalleryStore extends VuexModule { 29export default class GalleryStore extends VuexModule {
30 30
31 config: Gallery.Config | null = null; 31 config: Gallery.Config | null = null;
32 galleryIndex: Gallery.Index | null = null; 32 galleryIndex: Gallery.Index | null = null;
33 tagsIndex: Tag.Index = {}; 33 tagsIndex: Tag.Index = {};
34 tagsCategories: Tag.Category[] = []; 34 tagsCategories: Tag.Category[] = [];
35 currentPath: string = "/"; 35 currentPath: string = "/";
36 currentSearch: Tag.Search[] = []; 36 currentSearch: Tag.Search[] = [];
37 37
38 // --- 38 // ---
39 39
40 @mutation private setConfig(config: Gallery.Config) { 40 @mutation private setConfig(config: Gallery.Config) {
41 this.config = config; 41 this.config = config;
42 } 42 }
43 43
44 @mutation setGalleryIndex(galleryIndex: Gallery.Index) { 44 @mutation setGalleryIndex(galleryIndex: Gallery.Index) {
45 this.galleryIndex = Object.freeze(galleryIndex); 45 this.galleryIndex = Object.freeze(galleryIndex);
46 } 46 }
47 47
48 @mutation private setTagsIndex(tagsIndex: Tag.Index) { 48 @mutation private setTagsIndex(tagsIndex: Tag.Index) {
49 this.tagsIndex = Object.freeze(tagsIndex); 49 this.tagsIndex = Object.freeze(tagsIndex);
50 } 50 }
51 51
52 @mutation private setTagsCategories(tagsCategories: Tag.Category[]) { 52 @mutation private setTagsCategories(tagsCategories: Tag.Category[]) {
53 this.tagsCategories = tagsCategories; 53 this.tagsCategories = tagsCategories;
54 } 54 }
55 55
56 @mutation setCurrentPath(currentPath: string) { 56 @mutation setCurrentPath(currentPath: string) {
57 this.currentPath = currentPath; 57 this.currentPath = currentPath;
58 } 58 }
59 59
60 @mutation setCurrentSearch(currentSearch: Tag.Search[]) { 60 @mutation setCurrentSearch(currentSearch: Tag.Search[]) {
61 this.currentSearch = currentSearch; 61 this.currentSearch = currentSearch;
62 } 62 }
63 63
64 // --- 64 // ---
65 65
66 get currentItemPath(): Gallery.Item[] { 66 get currentItemPath(): Gallery.Item[] {
67 const root = this.galleryIndex?.tree; 67 const root = this.galleryIndex?.tree;
68 if (root) 68 if (root)
69 return Navigation.searchCurrentItemPath(root, this.currentPath); 69 return Navigation.searchCurrentItemPath(root, this.currentPath);
70 return []; 70 return [];
71 } 71 }
72 72
73 get currentItem(): Gallery.Item | null { 73 get currentItem(): Gallery.Item | null {
74 const path = this.currentItemPath; 74 const path = this.currentItemPath;
75 return path.length > 0 ? path[path.length - 1] : null; 75 return path.length > 0 ? path[path.length - 1] : null;
76 } 76 }
77 77
78 get galleryTitle(): string { 78 get galleryTitle(): string {
79 return this.galleryIndex?.properties.galleryTitle ?? "ldgallery"; 79 return this.galleryIndex?.properties.galleryTitle ?? "ldgallery";
80 } 80 }
81 81
82 // --- 82 // ---
83 83
84 // Fetches the gallery's JSON config 84 // Fetches the gallery's JSON config
85 @action async fetchConfig() { 85 @action async fetchConfig() {
86 return fetch(`${process.env.VUE_APP_DATA_URL}config.json`, { cache: "no-cache" }) 86 return fetch(`${process.env.VUE_APP_DATA_URL}config.json`, { cache: "no-cache" })
87 .then(response => response.json()) 87 .then(response => response.json())
88 .then(this.setConfig); 88 .then(this.setConfig);
89 } 89 }
90 90
91 // Fetches the gallery's JSON metadata 91 // Fetches the gallery's JSON metadata
92 @action async fetchGalleryItems() { 92 @action async fetchGalleryItems() {
93 const root = this.config?.galleryRoot ?? ''; 93 const root = this.config?.galleryRoot ?? "";
94 return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) 94 return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" })
95 .then(response => response.json()) 95 .then(response => response.json())
96 .then(this.setGalleryIndex) 96 .then(this.setGalleryIndex)
97 .then(this.indexTags) 97 .then(this.indexTags)
98 .then(this.indexTagCategories); 98 .then(this.indexTagCategories);
99 } 99 }
100 100
101 // Indexes the gallery 101 // Indexes the gallery
102 @action async indexTags() { 102 @action async indexTags() {
103 const root = this.galleryIndex?.tree ?? null; 103 const root = this.galleryIndex?.tree ?? null;
104 const index = IndexFactory.generateTags(root); 104 const index = IndexFactory.generateTags(root);
105 this.setTagsIndex(index); 105 this.setTagsIndex(index);
106 return index; 106 return index;
107 } 107 }
108 108
109 // Indexes the proposed categories 109 // Indexes the proposed categories
110 @action async indexTagCategories() { 110 @action async indexTagCategories() {
111 const categories = IndexFactory.generateCategories(this.tagsIndex, this.galleryIndex?.properties.tagCategories); 111 const categories = IndexFactory.generateCategories(this.tagsIndex, this.galleryIndex?.properties.tagCategories);
112 this.setTagsCategories(categories); 112 this.setTagsCategories(categories);
113 return categories; 113 return categories;
114 } 114 }
115 115
116 // Searches for tags 116 // Searches for tags
117 @action async search(filters: string[]) { 117 @action async search(filters: string[]) {
118 const results = filters.flatMap(filter => IndexFactory.searchTags(this.tagsIndex, filter, true)); 118 const results = filters.flatMap(filter => IndexFactory.searchTags(this.tagsIndex, filter, true));
119 this.setCurrentSearch(results); 119 this.setCurrentSearch(results);
120 return results; 120 return results;
121 } 121 }
122} 122}
diff --git a/viewer/src/store/index.ts b/viewer/src/store/index.ts
index 956d4fd..d5339e8 100644
--- a/viewer/src/store/index.ts
+++ b/viewer/src/store/index.ts
@@ -17,12 +17,12 @@
17-- along with this program. If not, see <https://www.gnu.org/licenses/>. 17-- along with this program. If not, see <https://www.gnu.org/licenses/>.
18*/ 18*/
19 19
20import Vue from 'vue' 20import Vue from "vue"
21import Vuex from 'vuex' 21import Vuex from "vuex"
22import { extractVuexModule } from "vuex-class-component"; 22import { extractVuexModule } from "vuex-class-component";
23import { createProxy } from "vuex-class-component"; 23import { createProxy } from "vuex-class-component";
24import UIStore from '@/store/uiStore'; 24import UIStore from "@/store/uiStore";
25import GalleryStore from '@/store/galleryStore'; 25import GalleryStore from "@/store/galleryStore";
26 26
27Vue.use(Vuex) 27Vue.use(Vuex)
28 28
@@ -37,7 +37,7 @@ const store = new Vuex.Store({
37Vue.use((vue) => vue.prototype.$uiStore = createProxy(store, UIStore)); 37Vue.use((vue) => vue.prototype.$uiStore = createProxy(store, UIStore));
38Vue.use((vue) => vue.prototype.$galleryStore = createProxy(store, GalleryStore)); 38Vue.use((vue) => vue.prototype.$galleryStore = createProxy(store, GalleryStore));
39 39
40declare module 'vue/types/vue' { 40declare module "vue/types/vue" {
41 interface Vue { 41 interface Vue {
42 $uiStore: UIStore, 42 $uiStore: UIStore,
43 $galleryStore: GalleryStore 43 $galleryStore: GalleryStore
diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts
index 2bd315c..892d35e 100644
--- a/viewer/src/store/uiStore.ts
+++ b/viewer/src/store/uiStore.ts
@@ -20,27 +20,27 @@
20import { createModule, mutation, action } from "vuex-class-component"; 20import { createModule, mutation, action } from "vuex-class-component";
21 21
22const VuexModule = createModule({ 22const VuexModule = createModule({
23 namespaced: "uiStore", 23 namespaced: "uiStore",
24 strict: true 24 strict: true
25}) 25})
26 26
27export default class UIStore extends VuexModule { 27export default class UIStore extends VuexModule {
28 28
29 fullscreen: boolean = false; 29 fullscreen: boolean = false;
30 fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); 30 fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT);
31 searchMode: boolean = false; 31 searchMode: boolean = false;
32 32
33 // ---