From 6dfe2324c1a8c73fdb200fb6a31c20e2082c1d6f Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 12 Nov 2023 15:53:46 +0100 Subject: [PATCH] [UI] Added navigation crumbs to the file browser. --- .../webapp/src/components/File/Browser.vue | 118 +++++++++++++++--- 1 file changed, 100 insertions(+), 18 deletions(-) diff --git a/platypush/backend/http/webapp/src/components/File/Browser.vue b/platypush/backend/http/webapp/src/components/File/Browser.vue index 4ff7a2018e..437eaef380 100644 --- a/platypush/backend/http/webapp/src/components/File/Browser.vue +++ b/platypush/backend/http/webapp/src/components/File/Browser.vue @@ -2,27 +2,46 @@
-
-
- - .. -
+ -
-
- - - {{ file.name }} - +
+
+
+ + .. +
-
- - - +
+
+ + + {{ file.name }} + +
+ +
+ + + +
@@ -39,9 +58,14 @@ export default { name: "Browser", components: {DropdownItem, Dropdown, Loading}, mixins: [Utils, MediaUtils], - emits: ['path-change'], + emits: ['back', 'path-change', 'play'], props: { + hasBack: { + type: Boolean, + default: false, + }, + initialPath: { type: String, }, @@ -71,11 +95,24 @@ export default { return this.files.filter((file) => (file?.name || '').toLowerCase().indexOf(this.filter.toLowerCase()) >= 0) }, + + pathTokens() { + if (!this.path?.length) + return ['/'] + + return ['/', ...this.path.split(/(? { + // Scroll to the end of the path navigator + this.$refs.nav.scrollLeft = 99999 + // Scroll to the top of the items list + this.$refs.items.scrollTop = 0 + }) try { this.files = await this.request('file.list', {path: this.path}) @@ -84,6 +121,13 @@ export default { this.loading = false } }, + + onBack() { + if (!this.path?.length || this.path === '/') + this.$emit('back') + else + this.path = [...this.pathTokens].slice(0, -1).join('/').slice(1) + }, }, mounted() { @@ -96,12 +140,50 @@ export default {