From 8da141744ef17d714bd2e065758e0e2b2553000e Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Fri, 17 Nov 2023 18:32:24 -0800 Subject: [PATCH] Implemented Gallery view for media files. --- frontend/src/App.vue | 1 - frontend/src/assets/main.css | 3 +- frontend/src/components/FileExplorer.vue | 39 ++-- frontend/src/components/Gallery.vue | 243 ++++++++++++++++++++++ frontend/src/components/GalleryFigure.vue | 99 +++++++++ frontend/src/components/HeaderMain.vue | 1 + frontend/src/components/MediaPreview.vue | 94 +++++++++ frontend/src/components/SelectBox.vue | 23 ++ frontend/src/repositories/Document.ts | 8 + frontend/src/stores/main.ts | 2 + frontend/src/views/ExplorerView.vue | 67 +++++- 11 files changed, 553 insertions(+), 27 deletions(-) create mode 100644 frontend/src/components/Gallery.vue create mode 100644 frontend/src/components/GalleryFigure.vue create mode 100644 frontend/src/components/MediaPreview.vue create mode 100644 frontend/src/components/SelectBox.vue diff --git a/frontend/src/App.vue b/frontend/src/App.vue index f21bd91..4abd6d9 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -133,4 +133,3 @@ onUnmounted(() => { }) export type { Path } -@/stores/main diff --git a/frontend/src/assets/main.css b/frontend/src/assets/main.css index 8080aa6..5af8f6c 100644 --- a/frontend/src/assets/main.css +++ b/frontend/src/assets/main.css @@ -14,7 +14,7 @@ /* The following are overridden by responsive layouts */ --root-font-size: 1rem; --header-font-size: 1rem; - --header-height: calc(6.5 * var(--header-font-size)); + --header-height: 4rem; } @media (prefers-color-scheme: dark) { :root { @@ -48,6 +48,7 @@ :root { --header-font-size: calc(10px + 10 * 100vh / 600); /* 20px at 600px height */ --root-font-size: 0.8rem; + --header-height: 2rem; } header .breadcrumb > * { padding-top: calc(8 + 8 * 100vh / 600) !important; diff --git a/frontend/src/components/FileExplorer.vue b/frontend/src/components/FileExplorer.vue index cb9ad5a..cdd4b10 100644 --- a/frontend/src/components/FileExplorer.vue +++ b/frontend/src/components/FileExplorer.vue @@ -28,11 +28,11 @@ - + {{ doc.name }} -
Nothing to see here
+ + diff --git a/frontend/src/components/GalleryFigure.vue b/frontend/src/components/GalleryFigure.vue new file mode 100644 index 0000000..d27116b --- /dev/null +++ b/frontend/src/components/GalleryFigure.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/frontend/src/components/HeaderMain.vue b/frontend/src/components/HeaderMain.vue index 251b30f..ae82434 100644 --- a/frontend/src/components/HeaderMain.vue +++ b/frontend/src/components/HeaderMain.vue @@ -72,6 +72,7 @@ watchEffect(() => { const settingsMenu = (e: Event) => { // show the context menu const items = [] + items.push({ label: 'Gallery', onClick: () => store.gallery = !store.gallery }) if (store.user.isLoggedIn) { items.push({ label: `Logout ${store.user.username ?? ''}`, onClick: () => store.logout() }) } else { diff --git a/frontend/src/components/MediaPreview.vue b/frontend/src/components/MediaPreview.vue new file mode 100644 index 0000000..f402c38 --- /dev/null +++ b/frontend/src/components/MediaPreview.vue @@ -0,0 +1,94 @@ + + + + + diff --git a/frontend/src/components/SelectBox.vue b/frontend/src/components/SelectBox.vue new file mode 100644 index 0000000..dbda660 --- /dev/null +++ b/frontend/src/components/SelectBox.vue @@ -0,0 +1,23 @@ + + + diff --git a/frontend/src/repositories/Document.ts b/frontend/src/repositories/Document.ts index 7607083..9887dd6 100644 --- a/frontend/src/repositories/Document.ts +++ b/frontend/src/repositories/Document.ts @@ -36,6 +36,14 @@ export class Doc { get urlrouter(): string { return this.url.replace(/^\/#/, '') } + get img(): boolean { + const ext = this.name.split('.').pop()?.toLowerCase() + return ['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif', 'svg'].includes(ext || '') + } + get ext(): string { + const ext = this.name.split('.').pop() + return ext ? ext.toLowerCase() : '' + } } export type errorEvent = { error: { diff --git a/frontend/src/stores/main.ts b/frontend/src/stores/main.ts index bcdb5a2..70f461b 100644 --- a/frontend/src/stores/main.ts +++ b/frontend/src/stores/main.ts @@ -23,6 +23,8 @@ export const useMainStore = defineStore({ fileExplorer: null as any, error: '' as string, connected: false, + gallery: false, + cursor: shallowRef(null), server: {} as Record, prefs: { sortListing: '' as SortOrder, diff --git a/frontend/src/views/ExplorerView.vue b/frontend/src/views/ExplorerView.vue index 78f6021..e283ffe 100644 --- a/frontend/src/views/ExplorerView.vue +++ b/frontend/src/views/ExplorerView.vue @@ -1,19 +1,40 @@ + +