aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/services/navigation.ts
diff options
context:
space:
mode:
authorZero~Informatique2020-06-20 16:50:49 +0200
committerOzoneGrif2020-06-28 14:11:13 +0200
commit170d7a61f720ece9dc4b347b19f5a8213f1d8984 (patch)
tree3a7af0595faea4a98437f8f73b3172529bda3a1d /viewer/src/services/navigation.ts
parent06355c9cebce469d3d827d48043387144c2458a5 (diff)
downloadldgallery-170d7a61f720ece9dc4b347b19f5a8213f1d8984.tar.gz
viewer: prettier formatting based on eslint-prettier plugin
Diffstat (limited to 'viewer/src/services/navigation.ts')
-rw-r--r--viewer/src/services/navigation.ts24
1 files changed, 11 insertions, 13 deletions
diff --git a/viewer/src/services/navigation.ts b/viewer/src/services/navigation.ts
index a7e752c..5b0716d 100644
--- a/viewer/src/services/navigation.ts
+++ b/viewer/src/services/navigation.ts
@@ -20,6 +20,15 @@
20import { ItemType } from "@/@types/ItemType"; 20import { ItemType } from "@/@types/ItemType";
21 21
22export default class Navigation { 22export default class Navigation {
23 static readonly ICON_BY_TYPE: Record<ItemType, string> = {
24 directory: "folder",
25 picture: "image",
26 plaintext: "file-alt",
27 pdf: "file-pdf",
28 video: "file-video",
29 audio: "file-audio",
30 other: "file",
31 };
23 32
24 // Searches for an item by path from a root item (navigation) 33 // Searches for an item by path from a root item (navigation)
25 public static searchCurrentItemPath(root: Gallery.Item, path: string): Gallery.Item[] { 34 public static searchCurrentItemPath(root: Gallery.Item, path: string): Gallery.Item[] {
@@ -61,25 +70,14 @@ export default class Navigation {
61 .filter(child => Navigation.checkType(child, ItemType.DIRECTORY)) 70 .filter(child => Navigation.checkType(child, ItemType.DIRECTORY))
62 .sort((a, b) => a.title.localeCompare(b.title)), 71 .sort((a, b) => a.title.localeCompare(b.title)),
63 72
64 ...items 73 ...items.filter(child => !Navigation.checkType(child, ItemType.DIRECTORY)),
65 .filter(child => !Navigation.checkType(child, ItemType.DIRECTORY)),
66 ]; 74 ];
67 } 75 }
68 76
69 // Get the icon for an item 77 // Get the icon for an item
70 public static getIcon(item: Gallery.Item): string { 78 public static getIcon(item: Gallery.Item): string {
71 if (item.path.length <= 1) return "home"; 79 if (item.path.length <= 1) return "home";
72 switch (item.properties.type) { 80 return Navigation.ICON_BY_TYPE[item.properties.type];
73 case ItemType.PICTURE: return "image";
74 case ItemType.PLAINTEXT: return "file-alt";
75 case ItemType.PDF: return "file-pdf";
76 case ItemType.VIDEO: return "file-video";
77 case ItemType.AUDIO: return "file-audio";
78 case ItemType.DIRECTORY: return "folder";
79 case ItemType.OTHER:
80 default:
81 return "file";
82 }
83 } 81 }
84 82
85 // Get the file name of an item, without its cache timestamp 83 // Get the file name of an item, without its cache timestamp