+
+
@@ -47,11 +47,9 @@ export default class LdPicture extends Vue {
flex-wrap: wrap;
align-items: center;
justify-content: space-evenly;
+
& > a {
margin: 2px;
}
- & .noresult {
- margin-top: 40px;
- }
}
diff --git a/viewer/src/locales/en.json b/viewer/src/locales/en.json
index e6c1df2..c011552 100644
--- a/viewer/src/locales/en.json
+++ b/viewer/src/locales/en.json
@@ -7,7 +7,8 @@
"tag-propositions.addition": "Include all items with this tag",
"tag-propositions.intersection": "Search for this tag",
"tag-propositions.item-count": "Item count",
- "gallery.unknowntype": "Unknown item type",
+ "gallery.unknown-type": "Could not display item of unknown type",
+ "gallery.unknown-resource": "Resource not found",
"command.search": "Open/close search panel",
"command.search.clear": "Clear",
"command.search.search": "Search",
diff --git a/viewer/src/plugins/fontawesome.ts b/viewer/src/plugins/fontawesome.ts
index 480e8e0..933bce6 100644
--- a/viewer/src/plugins/fontawesome.ts
+++ b/viewer/src/plugins/fontawesome.ts
@@ -23,6 +23,7 @@ import { library, config } from "@fortawesome/fontawesome-svg-core";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import {
faFolder,
+ faFolderOpen,
faEraser,
faSearch,
faPlus,
@@ -38,6 +39,7 @@ import {
library.add(
faFolder,
+ faFolderOpen,
faEraser,
faSearch,
faPlus,
diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index 7c6d11b..08c8218 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -18,18 +18,14 @@
-->
+
-
-
-
-
{{$t("gallery.unknowntype")}}
+
--
cgit v1.2.3
From f328a730b516f5e9104f85e553c083c2865660a8 Mon Sep 17 00:00:00 2001
From: pacien
Date: Mon, 4 May 2020 00:10:39 +0200
Subject: viewer/galleryStore: unify resource root parametrisation
---
viewer/src/components/LdPicture.vue | 2 +-
viewer/src/components/LdThumbnail.vue | 2 +-
viewer/src/store/galleryStore.ts | 4 ++++
3 files changed, 6 insertions(+), 2 deletions(-)
(limited to 'viewer')
diff --git a/viewer/src/components/LdPicture.vue b/viewer/src/components/LdPicture.vue
index de46bcb..78829ec 100644
--- a/viewer/src/components/LdPicture.vue
+++ b/viewer/src/components/LdPicture.vue
@@ -76,7 +76,7 @@ export default class LdPicture extends Vue {
}
pictureSrc(resource: string) {
- return `${process.env.VUE_APP_DATA_URL}${this.$galleryStore.config!.galleryRoot}${resource}`;
+ return this.$galleryStore.resourceRoot + resource;
}
generateSlowLoadingStyle() {
diff --git a/viewer/src/components/LdThumbnail.vue b/viewer/src/components/LdThumbnail.vue
index e774f00..bfcc595 100644
--- a/viewer/src/components/LdThumbnail.vue
+++ b/viewer/src/components/LdThumbnail.vue
@@ -47,7 +47,7 @@ export default class LdThumbnail extends Vue {
loading: boolean = false;
pictureSrc(resource: string) {
- return `${process.env.VUE_APP_DATA_URL}${this.$galleryStore.config!.galleryRoot}${resource}`;
+ return this.$galleryStore.resourceRoot + resource;
}
pictureStyle() {
diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts
index 0cffdd9..a57122c 100644
--- a/viewer/src/store/galleryStore.ts
+++ b/viewer/src/store/galleryStore.ts
@@ -79,6 +79,10 @@ export default class GalleryStore extends VuexModule {
return this.galleryIndex?.properties.galleryTitle ?? "ldgallery";
}
+ get resourceRoot(): string {
+ return process.env.VUE_APP_DATA_URL + this.config!.galleryRoot;
+ }
+
// ---
// Fetches the gallery's JSON config
--
cgit v1.2.3
From 35456c6183c199b23ded85838414eb28a6d4b60f Mon Sep 17 00:00:00 2001
From: pacien
Date: Mon, 4 May 2020 00:11:31 +0200
Subject: viewer/LdDownload: add generic file download handler
GitHub: closes #209
---
viewer/src/@types/gallery.d.ts | 1 +
viewer/src/components/LdDownload.vue | 67 ++++++++++++++++++++++++++++++++++
viewer/src/locales/en.json | 2 +-
viewer/src/plugins/fontawesome.ts | 2 +
viewer/src/views/GalleryNavigation.vue | 5 +--
5 files changed, 72 insertions(+), 5 deletions(-)
create mode 100644 viewer/src/components/LdDownload.vue
(limited to 'viewer')
diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts
index 066aedf..3246894 100644
--- a/viewer/src/@types/gallery.d.ts
+++ b/viewer/src/@types/gallery.d.ts
@@ -55,6 +55,7 @@ declare namespace Gallery {
}
interface OtherProperties {
type: "other",
+ resource: string
}
interface PictureProperties {
type: "picture",
diff --git a/viewer/src/components/LdDownload.vue b/viewer/src/components/LdDownload.vue
new file mode 100644
index 0000000..3b13e99
--- /dev/null
+++ b/viewer/src/components/LdDownload.vue
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
diff --git a/viewer/src/locales/en.json b/viewer/src/locales/en.json
index c011552..824064e 100644
--- a/viewer/src/locales/en.json
+++ b/viewer/src/locales/en.json
@@ -7,8 +7,8 @@
"tag-propositions.addition": "Include all items with this tag",
"tag-propositions.intersection": "Search for this tag",
"tag-propositions.item-count": "Item count",
- "gallery.unknown-type": "Could not display item of unknown type",
"gallery.unknown-resource": "Resource not found",
+ "download.download-file-fmt": "Download {0}",
"command.search": "Open/close search panel",
"command.search.clear": "Clear",
"command.search.search": "Search",
diff --git a/viewer/src/plugins/fontawesome.ts b/viewer/src/plugins/fontawesome.ts
index 933bce6..886d680 100644
--- a/viewer/src/plugins/fontawesome.ts
+++ b/viewer/src/plugins/fontawesome.ts
@@ -35,6 +35,7 @@ import {
faAngleRight,
faAngleDoubleLeft,
faFile,
+ faFileDownload,
} from "@fortawesome/free-solid-svg-icons";
library.add(
@@ -51,6 +52,7 @@ library.add(
faAngleRight,
faAngleDoubleLeft,
faFile,
+ faFileDownload,
);
config.autoAddCss = false;
diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index 08c8218..2e40409 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -65,10 +65,7 @@ export default class GalleryNavigation extends Vue {
return { component: "ld-picture", properties: { picture: this.$galleryStore.currentItem } };
default:
- return {
- component: "ld-error",
- properties: { icon: "file", message: this.$t("gallery.unknown-type") }
- };
+ return { component: "ld-download", properties: { item: this.$galleryStore.currentItem } };
}
}
}
--
cgit v1.2.3
From c175db32132201cefec699b69f71fb23bdd2c687 Mon Sep 17 00:00:00 2001
From: pacien
Date: Fri, 8 May 2020 19:03:09 +0200
Subject: viewer/LdDownload: fix item type and remove getters
For consistency.
---
viewer/src/components/LdDownload.vue | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
(limited to 'viewer')
diff --git a/viewer/src/components/LdDownload.vue b/viewer/src/components/LdDownload.vue
index 3b13e99..f86d455 100644
--- a/viewer/src/components/LdDownload.vue
+++ b/viewer/src/components/LdDownload.vue
@@ -20,10 +20,10 @@
@@ -32,19 +32,19 @@
import { Component, Prop, Vue } from "vue-property-decorator";
@Component export default class LdDownload extends Vue {
- @Prop({ required: true }) readonly item!: Gallery.Item;
+ @Prop({ required: true }) readonly item!: Gallery.Other;
- get itemResource(): string {
- return (this.item.properties as Gallery.OtherProperties).resource;
+ itemResource(): string {
+ return this.item.properties.resource;
}
- get itemFileName(): string {
- const timeStamped = this.itemResource.split("/").pop() ?? "";
+ itemFileName(): string {
+ const timeStamped = this.itemResource().split("/").pop() ?? "";
return timeStamped.split("?")[0];
}
- get itemDownloadUrl(): string {
- return this.$galleryStore.resourceRoot + this.itemResource;
+ itemDownloadUrl(): string {
+ return this.$galleryStore.resourceRoot + this.itemResource();
}
}
--
cgit v1.2.3
From 3cf40298471995fddea8a66860353a2b1ceeeeee Mon Sep 17 00:00:00 2001
From: pacien
Date: Fri, 8 May 2020 19:04:29 +0200
Subject: viewer/LdError: fix prop constructor type
---
viewer/src/components/LdError.vue | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'viewer')
diff --git a/viewer/src/components/LdError.vue b/viewer/src/components/LdError.vue
index 5e266ab..4b958dc 100644
--- a/viewer/src/components/LdError.vue
+++ b/viewer/src/components/LdError.vue
@@ -31,8 +31,8 @@
import { Component, Prop, Vue } from "vue-property-decorator";
@Component export default class LdError extends Vue {
- @Prop({ required: true }) readonly icon!: string;
- @Prop({ required: true }) readonly message!: string;
+ @Prop({ required: true, type: String }) readonly icon!: string;
+ @Prop({ required: true, type: String }) readonly message!: string;
}
--
cgit v1.2.3
From e02b09f405c81fd3eb612b0bb1f78f5860b0a5e8 Mon Sep 17 00:00:00 2001
From: pacien
Date: Fri, 8 May 2020 19:10:52 +0200
Subject: viewer/style/global: factorise flex centering container
---
viewer/src/assets/scss/global.scss | 11 +++++++++++
viewer/src/components/LdDownload.vue | 9 +--------
viewer/src/components/LdError.vue | 9 +--------
3 files changed, 13 insertions(+), 16 deletions(-)
(limited to 'viewer')
diff --git a/viewer/src/assets/scss/global.scss b/viewer/src/assets/scss/global.scss
index 9444548..5d2e6dc 100644
--- a/viewer/src/assets/scss/global.scss
+++ b/viewer/src/assets/scss/global.scss
@@ -51,6 +51,17 @@ button svg + span {
align-items: center;
}
+/**
+ * Class for containers that centers its content vertically and horizontally,
+ * preferably sticking to the container start if the container is smaller than the content.
+ */
+.container-vh-centering {
+ min-height: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
// === Links
.link {
diff --git a/viewer/src/components/LdDownload.vue b/viewer/src/components/LdDownload.vue
index f86d455..aea4123 100644
--- a/viewer/src/components/LdDownload.vue
+++ b/viewer/src/components/LdDownload.vue
@@ -19,7 +19,7 @@
-->
-
+
--
cgit v1.2.3
From e9e46a3b3392ab435f7414729592b2b5af4071b6 Mon Sep 17 00:00:00 2001
From: pacien
Date: Mon, 18 May 2020 20:05:14 +0200
Subject: compiler: add pdf resource type
---
viewer/src/@types/gallery.d.ts | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
(limited to 'viewer')
diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts
index 04df1bb..7345ef9 100644
--- a/viewer/src/@types/gallery.d.ts
+++ b/viewer/src/@types/gallery.d.ts
@@ -40,6 +40,9 @@ declare namespace Gallery {
interface PlainText extends Item {
properties: PlainTextProperties,
}
+ interface PDF extends Item {
+ properties: PDFProperties,
+ }
interface Directory extends Item {
properties: DirectoryProperties,
}
@@ -50,7 +53,7 @@ declare namespace Gallery {
tags: RawTag[],
path: string,
thumbnail?: Thumbnail
- properties: OtherProperties | PictureProperties | PlainTextProperties | DirectoryProperties,
+ properties: OtherProperties | PictureProperties | PlainTextProperties | PDFProperties | DirectoryProperties,
}
interface Resolution {
width: number,
@@ -69,6 +72,10 @@ declare namespace Gallery {
type: "plaintext",
resource: string,
}
+ interface PDFProperties {
+ type: "pdf",
+ resource: string,
+ }
interface DirectoryProperties {
type: "directory",
items: Item[]
@@ -78,5 +85,5 @@ declare namespace Gallery {
resolution: Resolution
}
type RawTag = string;
- type ItemType = "other" | "picture" | "plaintext" | "directory";
+ type ItemType = "other" | "picture" | "plaintext" | "pdf" | "directory";
}
--
cgit v1.2.3
From 185b84fbed180e4d2da7d4cc2ee91a3481f47406 Mon Sep 17 00:00:00 2001
From: pacien
Date: Mon, 18 May 2020 20:05:32 +0200
Subject: viewer: add icon for pdf files
---
viewer/src/plugins/fontawesome-icons.ts | 1 +
viewer/src/services/navigation.ts | 2 ++
2 files changed, 3 insertions(+)
(limited to 'viewer')
diff --git a/viewer/src/plugins/fontawesome-icons.ts b/viewer/src/plugins/fontawesome-icons.ts
index b5df176..ffe3709 100644
--- a/viewer/src/plugins/fontawesome-icons.ts
+++ b/viewer/src/plugins/fontawesome-icons.ts
@@ -32,5 +32,6 @@ export {
faAngleDoubleLeft,
faFile,
faFileAlt,
+ faFilePdf,
faFileDownload,
} from "@fortawesome/free-solid-svg-icons";
diff --git a/viewer/src/services/navigation.ts b/viewer/src/services/navigation.ts
index 4d3b376..7d1ae50 100644
--- a/viewer/src/services/navigation.ts
+++ b/viewer/src/services/navigation.ts
@@ -72,6 +72,8 @@ export default class Navigation {
return "image";
case "plaintext":
return "file-alt";
+ case "pdf":
+ return "file-pdf";
case "directory":
return "folder";
case "other":
--
cgit v1.2.3
From 226e0beb50061844470bd8a717a74307b975bd96 Mon Sep 17 00:00:00 2001
From: pacien
Date: Mon, 18 May 2020 20:06:22 +0200
Subject: viewer: add pdf viewer
Based on native browser rendering.
GitHub: closes #211
---
viewer/src/components/LdPdfViewer.vue | 50 ++++++++++++++++++++++++++++++++++
viewer/src/views/GalleryNavigation.vue | 1 +
2 files changed, 51 insertions(+)
create mode 100644 viewer/src/components/LdPdfViewer.vue
(limited to 'viewer')
diff --git a/viewer/src/components/LdPdfViewer.vue b/viewer/src/components/LdPdfViewer.vue
new file mode 100644
index 0000000..78ff3d2
--- /dev/null
+++ b/viewer/src/components/LdPdfViewer.vue
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index b5f06a2..e1c860b 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -25,6 +25,7 @@
+
--
cgit v1.2.3
From 037db071d42d4a7fdb8ed5cf88bc2c37fba4ae93 Mon Sep 17 00:00:00 2001
From: pacien
Date: Tue, 19 May 2020 21:04:50 +0200
Subject: viewer/css/global: factorise util classes
---
viewer/src/assets/scss/global.scss | 8 ++++++++
viewer/src/components/LdPdfViewer.vue | 10 +++-------
viewer/src/components/LdPlainTextViewer.vue | 11 ++---------
3 files changed, 13 insertions(+), 16 deletions(-)
(limited to 'viewer')
diff --git a/viewer/src/assets/scss/global.scss b/viewer/src/assets/scss/global.scss
index 5d2e6dc..f95a54d 100644
--- a/viewer/src/assets/scss/global.scss
+++ b/viewer/src/assets/scss/global.scss
@@ -36,6 +36,9 @@ button svg + span {
.nowrap {
white-space: nowrap;
}
+.no-scroll {
+ overflow: hidden;
+}
.no-scroll-x {
overflow-x: hidden;
}
@@ -51,6 +54,11 @@ button svg + span {
align-items: center;
}
+.fill {
+ width: 100%;
+ height: 100%;
+}
+
/**
* Class for containers that centers its content vertically and horizontally,
* preferably sticking to the container start if the container is smaller than the content.
diff --git a/viewer/src/components/LdPdfViewer.vue b/viewer/src/components/LdPdfViewer.vue
index 78ff3d2..20055cc 100644
--- a/viewer/src/components/LdPdfViewer.vue
+++ b/viewer/src/components/LdPdfViewer.vue
@@ -20,9 +20,9 @@
-
+
--
cgit v1.2.3
From e20f99b74b55fdb3edbcfe5bfdb700fc1a5e9574 Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Fri, 22 May 2020 04:07:34 +0200
Subject: viewer: npm build:report command, to generate ./dist/report.html
---
viewer/.vscode/tasks.json | 86 ++++++++++++++++++++++++++---------------------
viewer/package.json | 1 +
2 files changed, 49 insertions(+), 38 deletions(-)
(limited to 'viewer')
diff --git a/viewer/.vscode/tasks.json b/viewer/.vscode/tasks.json
index 102002d..cb1cdb2 100644
--- a/viewer/.vscode/tasks.json
+++ b/viewer/.vscode/tasks.json
@@ -1,39 +1,49 @@
{
- // See https://go.microsoft.com/fwlink/?LinkId=733558
- // for the documentation about the tasks.json format
- "version": "2.0.0",
- "tasks": [
- {
- "type": "npm",
- "script": "build",
- "group": {
- "kind": "build",
- "isDefault": true
- },
- "problemMatcher": [
- "$tsc"
- ]
- },
- {
- "type": "npm",
- "script": "serve",
- "problemMatcher": [
- "$tsc"
- ]
- },
- {
- "type": "npm",
- "script": "lint-autoformat",
- "problemMatcher": [
- "$tsc"
- ]
- },
- {
- "type": "npm",
- "script": "lint",
- "problemMatcher": [
- "$tsc"
- ]
- }
- ]
-}
\ No newline at end of file
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "type": "npm",
+ "script": "build",
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ },
+ "problemMatcher": [
+ "$tsc"
+ ]
+ },
+ {
+ "type": "npm",
+ "script": "serve",
+ "problemMatcher": [
+ "$tsc"
+ ]
+ },
+ {
+ "type": "npm",
+ "script": "lint-autoformat",
+ "problemMatcher": [
+ "$tsc"
+ ]
+ },
+ {
+ "type": "npm",
+ "script": "lint",
+ "problemMatcher": [
+ "$tsc"
+ ]
+ },
+ {
+ "type": "npm",
+ "script": "build:report",
+ "problemMatcher": [
+ "$tsc"
+ ],
+ "group": "build",
+ "label": "npm: build:report",
+ "detail": "vue-cli-service build --report",
+ }
+ ]
+}
diff --git a/viewer/package.json b/viewer/package.json
index 0e2c48f..d1bb5a2 100644
--- a/viewer/package.json
+++ b/viewer/package.json
@@ -7,6 +7,7 @@
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build --modern",
+ "build:report": "vue-cli-service build --report",
"lint": "vue-cli-service lint --no-fix",
"lint-autoformat": "vue-cli-service lint --fix",
"i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue|ts)' --locales './src/locales/*.json'"
--
cgit v1.2.3
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
(limited to 'viewer')
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
.
*/
+import { ItemType } from "@/@types/ItemType";
+
export default class Navigation {
// Searches for an item by path from a root item (navigation)
public static searchCurrentItemPath(root: Gallery.Item, path: string): Gallery.Item[] {
if (path === root.path) return [root];
- if (root.properties.type === "directory" && path.startsWith(root.path)) {
+ if (root.properties.type === ItemType.DIRECTORY && path.startsWith(root.path)) {
const itemChain = root.properties.items
.map(item => this.searchCurrentItemPath(item, path))
.find(itemChain => itemChain.length > 0);
@@ -40,14 +42,14 @@ export default class Navigation {
}
// Checks if the type of an item matches
- public static checkType(item: Gallery.Item | null, type: Gallery.ItemType | null): boolean {
+ public static checkType(item: Gallery.Item | null, type: ItemType | null): boolean {
return (item?.properties.type ?? null) === type;
}
public static getLastDirectory(itemPath: Gallery.Item[]): Gallery.Directory {
for (let idx = itemPath.length - 1; idx >= 0; idx--) {
const item = itemPath[idx];
- if (Navigation.checkType(item, "directory")) return item as Gallery.Directory;
+ if (Navigation.checkType(item, ItemType.DIRECTORY)) return item as Gallery.Directory;
}
throw new Error("No directory found");
}
@@ -56,11 +58,11 @@ export default class Navigation {
public static directoriesFirst(items: Gallery.Item[]) {
return [
...items
- .filter(child => Navigation.checkType(child, "directory"))
+ .filter(child => Navigation.checkType(child, ItemType.DIRECTORY))
.sort((a, b) => a.title.localeCompare(b.title)),
...items
- .filter(child => !Navigation.checkType(child, "directory")),
+ .filter(child => !Navigation.checkType(child, ItemType.DIRECTORY)),
];
}
@@ -68,19 +70,13 @@ export default class Navigation {
public static getIcon(item: Gallery.Item): string {
if (item.path.length <= 1) return "home";
switch (item.properties.type) {
- case "picture":
- return "image";
- case "plaintext":
- return "file-alt";
- case "pdf":
- return "file-pdf";
- case "video":
- return "file-video";
- case "audio":
- return "file-audio";
- case "directory":
- return "folder";
- case "other":
+ case ItemType.PICTURE: return "image";
+ case ItemType.PLAINTEXT: return "file-alt";
+ case ItemType.PDF: return "file-pdf";
+ case ItemType.VIDEO: return "file-video";
+ case ItemType.AUDIO: return "file-audio";
+ case ItemType.DIRECTORY: return "folder";
+ case ItemType.OTHER: