From 74c1c5e34787ac57299c8cbd874e9dcc56da406d Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Fri, 22 May 2020 04:14:48 +0200
Subject: viewer: Enumerated item types
---
viewer/src/@types/ItemType.ts | 11 +++++++++++
viewer/src/@types/gallery.d.ts | 27 +++++++++++++--------------
viewer/src/services/indexfactory.ts | 3 ++-
viewer/src/services/navigation.ts | 34 +++++++++++++++-------------------
viewer/src/views/GalleryNavigation.vue | 26 ++++++++++++++++++--------
5 files changed, 59 insertions(+), 42 deletions(-)
create mode 100644 viewer/src/@types/ItemType.ts
diff --git a/viewer/src/@types/ItemType.ts b/viewer/src/@types/ItemType.ts
new file mode 100644
index 0000000..31a395b
--- /dev/null
+++ b/viewer/src/@types/ItemType.ts
@@ -0,0 +1,11 @@
+// TODO: Convert all ambiant types related to LdGallery to modules
+
+export enum ItemType {
+ OTHER = "other",
+ PICTURE = "picture",
+ PLAINTEXT = "plaintext",
+ PDF = "pdf",
+ VIDEO = "video",
+ AUDIO = "audio",
+ DIRECTORY = "directory",
+}
diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts
index 2407f98..151ae92 100644
--- a/viewer/src/@types/gallery.d.ts
+++ b/viewer/src/@types/gallery.d.ts
@@ -60,44 +60,44 @@ declare namespace Gallery {
path: string,
thumbnail?: Thumbnail
properties: OtherProperties
- | PictureProperties
- | PlainTextProperties
- | PDFProperties
- | VideoProperties
- | AudioProperties
- | DirectoryProperties,
+ | PictureProperties
+ | PlainTextProperties
+ | PDFProperties
+ | VideoProperties
+ | AudioProperties
+ | DirectoryProperties,
}
interface Resolution {
width: number,
height: number,
}
interface OtherProperties {
- type: "other",
+ type: import("./ItemType").ItemType.OTHER,
resource: string
}
interface PictureProperties {
- type: "picture",
+ type: import("./ItemType").ItemType.PICTURE,
resource: string,
resolution: Resolution
}
interface PlainTextProperties {
- type: "plaintext",
+ type: import("./ItemType").ItemType.PLAINTEXT,
resource: string,
}
interface PDFProperties {
- type: "pdf",
+ type: import("./ItemType").ItemType.PDF,
resource: string,
}
interface VideoProperties {
- type: "video",
+ type: import("./ItemType").ItemType.VIDEO,
resource: string,
}
interface AudioProperties {
- type: "audio",
+ type: import("./ItemType").ItemType.AUDIO,
resource: string,
}
interface DirectoryProperties {
- type: "directory",
+ type: import("./ItemType").ItemType.DIRECTORY,
items: Item[]
}
interface Thumbnail {
@@ -105,5 +105,4 @@ declare namespace Gallery {
resolution: Resolution
}
type RawTag = string;
- type ItemType = "other" | "picture" | "plaintext" | "pdf" | "video" | "audio" | "directory";
}
diff --git a/viewer/src/services/indexfactory.ts b/viewer/src/services/indexfactory.ts
index e402185..00abc05 100644
--- a/viewer/src/services/indexfactory.ts
+++ b/viewer/src/services/indexfactory.ts
@@ -18,6 +18,7 @@
*/
import { Operation } from "@/@types/Operation";
+import { ItemType } from "@/@types/ItemType";
import Navigation from "@/services/navigation";
export default class IndexFactory {
@@ -30,7 +31,7 @@ export default class IndexFactory {
// Pushes all tags for a root item (and its children) to the index
private static pushTagsForItem(tagsIndex: Tag.Index, item: Gallery.Item): void {
- if (item.properties.type === "directory") {
+ if (item.properties.type === ItemType.DIRECTORY) {
item.properties.items.forEach(item => this.pushTagsForItem(tagsIndex, item));
return; // Directories are not indexed
}
diff --git a/viewer/src/services/navigation.ts b/viewer/src/services/navigation.ts
index 068d081..a7e752c 100644
--- a/viewer/src/services/navigation.ts
+++ b/viewer/src/services/navigation.ts
@@ -17,12 +17,14 @@
-- along with this program. If not, see