diff --git a/platypush/backend/http/webapp/src/components/File/Browser.vue b/platypush/backend/http/webapp/src/components/File/Browser.vue index 538065e2b..dc41e1db3 100644 --- a/platypush/backend/http/webapp/src/components/File/Browser.vue +++ b/platypush/backend/http/webapp/src/components/File/Browser.vue @@ -27,7 +27,7 @@ -
+
@@ -35,11 +35,11 @@
-
+
+ v-if="hasPlay && file.type !== 'directory'" />
@@ -58,7 +58,7 @@ export default { name: "Browser", components: {DropdownItem, Dropdown, Loading}, mixins: [Utils, MediaUtils], - emits: ['back', 'path-change', 'play'], + emits: ['back', 'path-change', 'play', 'input'], props: { hasBack: { @@ -96,6 +96,23 @@ export default { return this.files.filter((file) => (file?.name || '').toLowerCase().indexOf(this.filter.toLowerCase()) >= 0) }, + hasPlay() { + return this.isMedia && this.files.some((file) => this.mediaExtensions.has(file.name.split('.').pop()?.toLowerCase())) + }, + + fileActions() { + if (!this.hasPlay) + return [] + + return [ + { + iconClass: 'fa fa-play', + text: 'Play', + onClick: (file) => this.$emit('play', {type: 'file', url: `file://${file.path}`}), + }, + ] + }, + pathTokens() { if (!this.path?.length) return ['/'] @@ -128,10 +145,26 @@ export default { else this.path = [...this.pathTokens].slice(0, -1).join('/').slice(1) }, + + onItemSelect(file) { + if (file.type === 'directory') + this.path = file.path + else + this.$emit('input', file.path) + }, + }, + + watch: { + initialPath() { + this.path = this.initialPath + }, + + path() { + this.refresh() + }, }, mounted() { - this.$watch(() => this.path, () => this.refresh()) this.refresh() }, } diff --git a/platypush/backend/http/webapp/src/components/elements/FileSelector.vue b/platypush/backend/http/webapp/src/components/elements/FileSelector.vue new file mode 100644 index 000000000..175093ad9 --- /dev/null +++ b/platypush/backend/http/webapp/src/components/elements/FileSelector.vue @@ -0,0 +1,116 @@ + + + + +