From 665139f7d25a64f66e1149a6403fc26efcbabb2a Mon Sep 17 00:00:00 2001
From: pacien
Date: Sun, 3 May 2020 23:07:51 +0200
Subject: viewer/GalleryNavigation: better error messages

Introducing a generic error page with some icon and a different error for unknown resources

GitHub: closes #190
---
 viewer/src/views/GalleryNavigation.vue | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

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 @@
 -->
 
 <template>
+  <!-- TODO: eliminate intermediate div -->
   <div>
-    <gallery-search v-if="query.length" :path="path" />
-    <gallery-directory v-else-if="checkType('directory')" :directory="$galleryStore.currentItem" />
-    <ld-picture v-else-if="checkType('picture')" :picture="$galleryStore.currentItem" />
-    <div v-else>{{$t("gallery.unknowntype")}}</div>
+    <component :is="dispatch().component" v-bind="dispatch().properties" />
   </div>
 </template>
 
 <script lang="ts">
 import { Component, Vue, Prop, Watch } from "vue-property-decorator";
-import { Operation } from "@/@types/Operation";
-import Navigation from "@/services/navigation";
 import GalleryDirectory from "./GalleryDirectory.vue";
 import GallerySearch from "@/views/GallerySearch.vue";
 
@@ -52,8 +48,28 @@ export default class GalleryNavigation extends Vue {
     this.$galleryStore.setCurrentPath(this.path);
   }
 
-  private checkType(type: Gallery.ItemType): boolean {
-    return Navigation.checkType(this.$galleryStore.currentItem, type);
+  dispatch(): { component: string, properties: {} } {
+    switch (this.$galleryStore.currentItem?.properties.type ?? null) {
+      case null:
+        return {
+          component: "ld-error",
+          properties: { icon: "folder-open", message: this.$t("gallery.unknown-resource") }
+        };
+
+      case "directory":
+        return this.query.length > 0
+          ? { component: "gallery-search", properties: { path: this.path } }
+          : { component: "gallery-directory", properties: { directory: this.$galleryStore.currentItem } };
+
+      case "picture":
+        return { component: "ld-picture", properties: { picture: this.$galleryStore.currentItem } };
+
+      default:
+        return {
+          component: "ld-error",
+          properties: { icon: "file", message: this.$t("gallery.unknown-type") }
+        };
+    }
   }
 }
 </script>
-- 
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/views/GalleryNavigation.vue | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

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 34bcf9339c86f145442b9edc799416462bf21fc5 Mon Sep 17 00:00:00 2001
From: pacien
Date: Fri, 8 May 2020 19:28:07 +0200
Subject: viewer/GalleryNavigation: revert to static template component
 dispatching

We'll see for dynamic component loading later.
---
 viewer/src/views/GalleryNavigation.vue | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index 2e40409..f36fc8a 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -20,12 +20,17 @@
 <template>
   <!-- TODO: eliminate intermediate div -->
   <div>
-    <component :is="dispatch().component" v-bind="dispatch().properties" />
+    <ld-error v-if="checkType(null)" icon="folder-open" :message="$t('gallery.unknown-resource')" />
+    <gallery-search v-else-if="checkType('directory') && query.length > 0" :path="path" />
+    <gallery-directory v-else-if="checkType('directory')" :directory="$galleryStore.currentItem" />
+    <ld-picture v-else-if="checkType('picture')" :picture="$galleryStore.currentItem" />
+    <ld-download v-else :item="$galleryStore.currentItem" />
   </div>
 </template>
 
 <script lang="ts">
 import { Component, Vue, Prop, Watch } from "vue-property-decorator";
+import Navigation from "@/services/navigation";
 import GalleryDirectory from "./GalleryDirectory.vue";
 import GallerySearch from "@/views/GallerySearch.vue";
 
@@ -48,25 +53,8 @@ export default class GalleryNavigation extends Vue {
     this.$galleryStore.setCurrentPath(this.path);
   }
 
-  dispatch(): { component: string, properties: {} } {
-    switch (this.$galleryStore.currentItem?.properties.type ?? null) {
-      case null:
-        return {
-          component: "ld-error",
-          properties: { icon: "folder-open", message: this.$t("gallery.unknown-resource") }
-        };
-
-      case "directory":
-        return this.query.length > 0
-          ? { component: "gallery-search", properties: { path: this.path } }
-          : { component: "gallery-directory", properties: { directory: this.$galleryStore.currentItem } };
-
-      case "picture":
-        return { component: "ld-picture", properties: { picture: this.$galleryStore.currentItem } };
-
-      default:
-        return { component: "ld-download", properties: { item: this.$galleryStore.currentItem } };
-    }
+  checkType(type: Gallery.ItemType | null): boolean {
+    return Navigation.checkType(this.$galleryStore.currentItem, type);
   }
 }
 </script>
-- 
cgit v1.2.3


From 8063119d3ee2182a595b2e53ee2bbc557a8a56c3 Mon Sep 17 00:00:00 2001
From: pacien
Date: Wed, 13 May 2020 00:18:46 +0200
Subject: viewer: add plain text file viewer

GitHub: closes #213
---
 viewer/src/views/GalleryNavigation.vue | 1 +
 1 file changed, 1 insertion(+)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index f36fc8a..b5f06a2 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -24,6 +24,7 @@
     <gallery-search v-else-if="checkType('directory') && query.length > 0" :path="path" />
     <gallery-directory v-else-if="checkType('directory')" :directory="$galleryStore.currentItem" />
     <ld-picture v-else-if="checkType('picture')" :picture="$galleryStore.currentItem" />
+    <ld-plain-text-viewer v-else-if="checkType('plaintext')" :plain-text-item="$galleryStore.currentItem" />
     <ld-download v-else :item="$galleryStore.currentItem" />
   </div>
 </template>
-- 
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/views/GalleryNavigation.vue | 1 +
 1 file changed, 1 insertion(+)

(limited to 'viewer/src/views/GalleryNavigation.vue')

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 @@
     <gallery-directory v-else-if="checkType('directory')" :directory="$galleryStore.currentItem" />
     <ld-picture v-else-if="checkType('picture')" :picture="$galleryStore.currentItem" />
     <ld-plain-text-viewer v-else-if="checkType('plaintext')" :plain-text-item="$galleryStore.currentItem" />
+    <ld-pdf-viewer v-else-if="checkType('pdf')" :pdf-item="$galleryStore.currentItem" />
     <ld-download v-else :item="$galleryStore.currentItem" />
   </div>
 </template>
-- 
cgit v1.2.3


From bc640b96052d657d22e0afbc05dc1ab4d0289bfb Mon Sep 17 00:00:00 2001
From: pacien
Date: Tue, 19 May 2020 21:10:37 +0200
Subject: viewer/LdVideoViewer: add video viewer

GitHub: closes #222
---
 viewer/src/views/GalleryNavigation.vue | 1 +
 1 file changed, 1 insertion(+)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index e1c860b..df738b8 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -26,6 +26,7 @@
     <ld-picture v-else-if="checkType('picture')" :picture="$galleryStore.currentItem" />
     <ld-plain-text-viewer v-else-if="checkType('plaintext')" :plain-text-item="$galleryStore.currentItem" />
     <ld-pdf-viewer v-else-if="checkType('pdf')" :pdf-item="$galleryStore.currentItem" />
+    <ld-video-viewer v-else-if="checkType('video')" :video-item="$galleryStore.currentItem" />
     <ld-download v-else :item="$galleryStore.currentItem" />
   </div>
 </template>
-- 
cgit v1.2.3


From 9adf35eef92ee0842a080a6462ba13d4a17eb5e3 Mon Sep 17 00:00:00 2001
From: pacien
Date: Tue, 19 May 2020 21:11:07 +0200
Subject: viewer/LdAudioViewer: add audio viewer

GitHub: closes #158
---
 viewer/src/views/GalleryNavigation.vue | 1 +
 1 file changed, 1 insertion(+)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index df738b8..9fc40e1 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -27,6 +27,7 @@
     <ld-plain-text-viewer v-else-if="checkType('plaintext')" :plain-text-item="$galleryStore.currentItem" />
     <ld-pdf-viewer v-else-if="checkType('pdf')" :pdf-item="$galleryStore.currentItem" />
     <ld-video-viewer v-else-if="checkType('video')" :video-item="$galleryStore.currentItem" />
+    <ld-audio-viewer v-else-if="checkType('audio')" :audio-item="$galleryStore.currentItem" />
     <ld-download v-else :item="$galleryStore.currentItem" />
   </div>
 </template>
-- 
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/views/GalleryNavigation.vue | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index 9fc40e1..b141d44 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -21,19 +21,26 @@
   <!-- TODO: eliminate intermediate div -->
   <div>
     <ld-error v-if="checkType(null)" icon="folder-open" :message="$t('gallery.unknown-resource')" />
-    <gallery-search v-else-if="checkType('directory') && query.length > 0" :path="path" />
-    <gallery-directory v-else-if="checkType('directory')" :directory="$galleryStore.currentItem" />
-    <ld-picture v-else-if="checkType('picture')" :picture="$galleryStore.currentItem" />
-    <ld-plain-text-viewer v-else-if="checkType('plaintext')" :plain-text-item="$galleryStore.currentItem" />
-    <ld-pdf-viewer v-else-if="checkType('pdf')" :pdf-item="$galleryStore.currentItem" />
-    <ld-video-viewer v-else-if="checkType('video')" :video-item="$galleryStore.currentItem" />
-    <ld-audio-viewer v-else-if="checkType('audio')" :audio-item="$galleryStore.currentItem" />
+    <gallery-search v-else-if="checkType(ItemType.DIRECTORY) && query.length > 0" :path="path" />
+    <gallery-directory
+      v-else-if="checkType(ItemType.DIRECTORY)"
+      :directory="$galleryStore.currentItem"
+    />
+    <ld-picture v-else-if="checkType(ItemType.PICTURE)" :picture="$galleryStore.currentItem" />
+    <ld-plain-text-viewer
+      v-else-if="checkType(ItemType.PLAINTEXT)"
+      :plain-text-item="$galleryStore.currentItem"
+    />
+    <ld-pdf-viewer v-else-if="checkType(ItemType.PDF)" :pdf-item="$galleryStore.currentItem" />
+    <ld-video-viewer v-else-if="checkType(ItemType.VIDEO)" :video-item="$galleryStore.currentItem" />
+    <ld-audio-viewer v-else-if="checkType(ItemType.AUDIO)" :audio-item="$galleryStore.currentItem" />
     <ld-download v-else :item="$galleryStore.currentItem" />
   </div>
 </template>
 
 <script lang="ts">
 import { Component, Vue, Prop, Watch } from "vue-property-decorator";
+import { ItemType } from "@/@types/ItemType";
 import Navigation from "@/services/navigation";
 import GalleryDirectory from "./GalleryDirectory.vue";
 import GallerySearch from "@/views/GallerySearch.vue";
@@ -48,6 +55,9 @@ export default class GalleryNavigation extends Vue {
   @Prop(String) readonly path!: string;
   @Prop(Array) readonly query!: string[];
 
+  // For the template
+  readonly ItemType = Object.freeze(ItemType);
+
   mounted() {
     this.pathChanged();
   }
@@ -57,7 +67,7 @@ export default class GalleryNavigation extends Vue {
     this.$galleryStore.setCurrentPath(this.path);
   }
 
-  checkType(type: Gallery.ItemType | null): boolean {
+  checkType(type: ItemType | null): boolean {
     return Navigation.checkType(this.$galleryStore.currentItem, type);
   }
 }
-- 
cgit v1.2.3


From 4393f8f25025ea600dae30be2d6ad9067496ba40 Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Sat, 20 Jun 2020 06:04:39 +0200
Subject: viewer: component dispatch (no functional change)

a cleaner way to add new components to LdGallery
---
 viewer/src/views/GalleryNavigation.vue | 44 ++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 20 deletions(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index b141d44..843550f 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -18,23 +18,10 @@
 -->
 
 <template>
-  <!-- TODO: eliminate intermediate div -->
   <div>
-    <ld-error v-if="checkType(null)" icon="folder-open" :message="$t('gallery.unknown-resource')" />
-    <gallery-search v-else-if="checkType(ItemType.DIRECTORY) && query.length > 0" :path="path" />
-    <gallery-directory
-      v-else-if="checkType(ItemType.DIRECTORY)"
-      :directory="$galleryStore.currentItem"
-    />
-    <ld-picture v-else-if="checkType(ItemType.PICTURE)" :picture="$galleryStore.currentItem" />
-    <ld-plain-text-viewer
-      v-else-if="checkType(ItemType.PLAINTEXT)"
-      :plain-text-item="$galleryStore.currentItem"
-    />
-    <ld-pdf-viewer v-else-if="checkType(ItemType.PDF)" :pdf-item="$galleryStore.currentItem" />
-    <ld-video-viewer v-else-if="checkType(ItemType.VIDEO)" :video-item="$galleryStore.currentItem" />
-    <ld-audio-viewer v-else-if="checkType(ItemType.AUDIO)" :audio-item="$galleryStore.currentItem" />
-    <ld-download v-else :item="$galleryStore.currentItem" />
+    <ld-error v-if="isError" icon="folder-open" :message="$t('gallery.unknown-resource')" />
+    <gallery-search v-else-if="isSearch" :path="path" />
+    <component :is="componentName" v-else :item="$galleryStore.currentItem" />
   </div>
 </template>
 
@@ -42,12 +29,10 @@
 import { Component, Vue, Prop, Watch } from "vue-property-decorator";
 import { ItemType } from "@/@types/ItemType";
 import Navigation from "@/services/navigation";
-import GalleryDirectory from "./GalleryDirectory.vue";
 import GallerySearch from "@/views/GallerySearch.vue";
 
 @Component({
   components: {
-    GalleryDirectory,
     GallerySearch,
   },
 })
@@ -55,13 +40,32 @@ export default class GalleryNavigation extends Vue {
   @Prop(String) readonly path!: string;
   @Prop(Array) readonly query!: string[];
 
-  // For the template
-  readonly ItemType = Object.freeze(ItemType);
+  readonly COMPONENT_BY_TYPE: Record<ItemType, string> = {
+    directory: "ld-directory",
+    picture: "ld-picture",
+    plaintext: "ld-plain-text-viewer",
+    pdf: "ld-pdf-viewer",
+    video: "ld-video-viewer",
+    audio: "ld-audio-viewer",
+    other: "ld-download",
+  };
 
   mounted() {
     this.pathChanged();
   }
 
+  get isError() {
+    return this.checkType(null);
+  }
+
+  get isSearch() {
+    return this.checkType(ItemType.DIRECTORY) && this.query.length > 0;
+  }
+
+  get componentName() {
+    return this.COMPONENT_BY_TYPE[this.$galleryStore.currentItem?.properties.type ?? ItemType.OTHER];
+  }
+
   @Watch("path")
   pathChanged() {
     this.$galleryStore.setCurrentPath(this.path);
-- 
cgit v1.2.3


From 170d7a61f720ece9dc4b347b19f5a8213f1d8984 Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Sat, 20 Jun 2020 16:50:49 +0200
Subject: viewer: prettier formatting based on eslint-prettier plugin

---
 viewer/src/views/GalleryNavigation.vue | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index 843550f..fd1f19a 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -77,5 +77,4 @@ export default class GalleryNavigation extends Vue {
 }
 </script>
 
-<style lang="scss">
-</style>
+<style lang="scss"></style>
-- 
cgit v1.2.3

