From 12eb302bcc93405f81b676b1a29a9731a5fec9be Mon Sep 17 00:00:00 2001
From: pacien
Date: Sun, 30 Oct 2022 17:40:33 +0100
Subject: viewer/command: add item download button
This adds a download button which allows the user to save the current
item as a file.
This is necessary because some item viewers do not expose a download
option on their own.
The download icon appears together with the other command buttons at the
top-left corner of the screen, replacing the listing sorting menu which
is only relevant for item lists (directory and search views).
GitHub: closes #308
---
changelog.md | 1 +
viewer/ldgallery-viewer.7.md | 1 +
viewer/src/locales/en.yml | 1 +
viewer/src/views/layout/top/LayoutCommand.vue | 46 ++++++++++++++++++++++++---
viewer/src/views/layout/top/LayoutTop.vue | 5 ++-
5 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/changelog.md b/changelog.md
index 0cf3194..07a6d3a 100644
--- a/changelog.md
+++ b/changelog.md
@@ -7,6 +7,7 @@ release. Releases are tracked and referred to using git tags.
## [next release]
- New features:
- viewer: add `CTRL-K` keyboard shortcut for quick search.
+ - viewer: added a button to download the current item.
- Bug fixes:
- compiler: fix detection of dimensions of EXIF-rotated pictures.
Rebuild the gallery with `--rebuild-all` to purge erroneous cached data.
diff --git a/viewer/ldgallery-viewer.7.md b/viewer/ldgallery-viewer.7.md
index 736f61f..46509fb 100644
--- a/viewer/ldgallery-viewer.7.md
+++ b/viewer/ldgallery-viewer.7.md
@@ -41,6 +41,7 @@ Items of the following formats can be opened and visualised within the web appli
* PDFs
Formats which are not listed above or which are not supported by the user's web browser are offered for download instead of being directly displayed in the same window.
+The item being visualised can be downloaded using the download button at the top-left corner.
# KEYBOARD SHORTCUTS
diff --git a/viewer/src/locales/en.yml b/viewer/src/locales/en.yml
index acbe24b..86ecd49 100644
--- a/viewer/src/locales/en.yml
+++ b/viewer/src/locales/en.yml
@@ -1,6 +1,7 @@
command:
back: Go back
parent: Go to parent directory
+ download: Download
search:
clear: Clear
search: Search
diff --git a/viewer/src/views/layout/top/LayoutCommand.vue b/viewer/src/views/layout/top/LayoutCommand.vue
index 8919da3..d930fd2 100644
--- a/viewer/src/views/layout/top/LayoutCommand.vue
+++ b/viewer/src/views/layout/top/LayoutCommand.vue
@@ -2,7 +2,7 @@
-- pictures into a searchable web gallery.
--
-- Copyright (C) 2019-2022 Guillaume FOUET
--- 2020 Pacien TRAN-GIRARD
+-- 2020-2022 Pacien TRAN-GIRARD
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as
@@ -33,7 +33,24 @@
size="lg"
/>
-
+
+
+
+
+
+
, required: true },
+ item: { type: Object as PropType- , required: true },
});
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const uiStore = useUiStore();
+const galleryStore = useGalleryStore();
+const navigation = useNavigation();
+
+const isListing = computedEager(() => !props.item || isDirectory(props.item));
+const itemFileName = computed(() => navigation.getFileName(props.item));
+const itemResourceUrl = computed(() =>
+ isDownloadableItem(props.item)
+ ? galleryStore.resourceRoot + props.item.properties.resource
+ : '',
+);
const commandToggleSearchPanelIcon = computed(() => uiStore.fullWidth ? faSearch : faAngleDoubleLeft);
const isRoot = computedEager(() => props.currentItemPath.length <= 1 && !uiStore.searchMode);
diff --git a/viewer/src/views/layout/top/LayoutTop.vue b/viewer/src/views/layout/top/LayoutTop.vue
index b755c42..0362840 100644
--- a/viewer/src/views/layout/top/LayoutTop.vue
+++ b/viewer/src/views/layout/top/LayoutTop.vue
@@ -19,7 +19,10 @@
-
+