diff --git a/platypush/backend/http/webapp/src/components/panels/Media/Index.vue b/platypush/backend/http/webapp/src/components/panels/Media/Index.vue index ad372bb83b..b6a59d36ea 100644 --- a/platypush/backend/http/webapp/src/components/panels/Media/Index.vue +++ b/platypush/backend/http/webapp/src/components/panels/Media/Index.vue @@ -46,7 +46,7 @@ @download="download" v-if="selectedView === 'search'" /> - @@ -92,7 +92,7 @@ import MediaView from "@/components/Media/View"; import Nav from "@/components/panels/Media/Nav"; import Results from "@/components/panels/Media/Results"; import Subtitles from "@/components/panels/Media/Subtitles"; -import TorrentView from "@/components/panels/Torrent/View"; +import Transfers from "@/components/panels/Torrent/Transfers"; import UrlPlayer from "@/components/panels/Media/UrlPlayer"; export default { @@ -107,7 +107,7 @@ export default { Nav, Results, Subtitles, - TorrentView, + Transfers, UrlPlayer, }, diff --git a/platypush/backend/http/webapp/src/components/panels/Torrent/Header.vue b/platypush/backend/http/webapp/src/components/panels/Torrent/Header.vue index 0b0052b611..f21707347c 100644 --- a/platypush/backend/http/webapp/src/components/panels/Torrent/Header.vue +++ b/platypush/backend/http/webapp/src/components/panels/Torrent/Header.vue @@ -1,27 +1,119 @@ @@ -46,6 +138,9 @@ export default { align-items: center; &.right { + position: absolute; + font-size: 1.1em; + right: calc(#{$torrent-nav-width} / 4); justify-content: right; } } @@ -54,7 +149,6 @@ export default { background: none; padding: 0 .25em; border: 0; - margin-right: .25em; &:hover { color: $default-hover-fg-2; @@ -63,6 +157,7 @@ export default { form { width: 100%; + display: flex; padding: 0; border: 0; border-radius: 0; @@ -70,8 +165,36 @@ export default { background: initial; } + .button-container { + width: 3em; + position: relative; + padding: 0; + } + + :deep(.loading) { + width: 5em; + font-size: 1em; + left: -0.5em; + border-radius: 0 1em 1em 0; + } + + [type=submit] { + width: 100%; + height: 100%; + background: $default-bg-4; + border: $default-border-2; + border-radius: 0 1em 1em 0; + margin-left: -.5em; + cursor: pointer; + + &:hover { + background: $hover-bg-3; + } + } + .search-box { width: 100%; + max-width: 600px; margin-left: .5em; input[type=search] { diff --git a/platypush/backend/http/webapp/src/components/panels/Torrent/Info.vue b/platypush/backend/http/webapp/src/components/panels/Torrent/Info.vue new file mode 100644 index 0000000000..3304c5938d --- /dev/null +++ b/platypush/backend/http/webapp/src/components/panels/Torrent/Info.vue @@ -0,0 +1,120 @@ + + + + + diff --git a/platypush/backend/http/webapp/src/components/panels/Torrent/Nav.vue b/platypush/backend/http/webapp/src/components/panels/Torrent/Nav.vue new file mode 100644 index 0000000000..ff71df22d2 --- /dev/null +++ b/platypush/backend/http/webapp/src/components/panels/Torrent/Nav.vue @@ -0,0 +1,109 @@ + + + + + diff --git a/platypush/backend/http/webapp/src/components/panels/Torrent/Panel.vue b/platypush/backend/http/webapp/src/components/panels/Torrent/Panel.vue index b042404b85..1f31e7bf77 100644 --- a/platypush/backend/http/webapp/src/components/panels/Torrent/Panel.vue +++ b/platypush/backend/http/webapp/src/components/panels/Torrent/Panel.vue @@ -1,24 +1,78 @@ diff --git a/platypush/backend/http/webapp/src/components/panels/Torrent/Results.vue b/platypush/backend/http/webapp/src/components/panels/Torrent/Results.vue new file mode 100644 index 0000000000..f352a4924f --- /dev/null +++ b/platypush/backend/http/webapp/src/components/panels/Torrent/Results.vue @@ -0,0 +1,188 @@ + + + + + diff --git a/platypush/backend/http/webapp/src/components/panels/Torrent/View.vue b/platypush/backend/http/webapp/src/components/panels/Torrent/Transfers.vue similarity index 71% rename from platypush/backend/http/webapp/src/components/panels/Torrent/View.vue rename to platypush/backend/http/webapp/src/components/panels/Torrent/Transfers.vue index 86347fda1d..34125d9add 100644 --- a/platypush/backend/http/webapp/src/components/panels/Torrent/View.vue +++ b/platypush/backend/http/webapp/src/components/panels/Torrent/Transfers.vue @@ -9,8 +9,8 @@
@@ -22,11 +22,11 @@
- - - + + + @@ -96,6 +96,15 @@
Save path
+ +
+
Files
+ +
@@ -126,26 +135,31 @@ import Dropdown from "@/components/elements/Dropdown"; import DropdownItem from "@/components/elements/DropdownItem"; export default { - name: "View", - emits: ['play', 'play-with-captions'], + emits: [ + 'pause', + 'play', + 'play-with-captions', + 'refresh', + 'remove', + 'resume', + ], components: {Dropdown, DropdownItem, Loading, Modal}, mixins: [Utils, MediaUtils], props: { - pluginName: { - type: String, - required: true, - }, - isMedia: { type: Boolean, default: false, }, + + transfers: { + type: Object, + default: () => ({}), + }, }, data() { return { loading: false, - transfers: {}, selectedItem: null, } }, @@ -158,79 +172,6 @@ export default { return this.transfers[this.selectedItem].files.map((file) => file.split('/').pop()) }, }, - - methods: { - torrentId(torrent) { - if (torrent?.hash && torrent.hash.length) - return torrent.hash - - return torrent.url - }, - - async refresh() { - this.loading = true - - try { - this.transfers = Object.values(await this.request(`${this.pluginName}.status`) || {}) - .reduce((obj, torrent) => { - obj[this.torrentId(torrent)] = torrent - return obj - }, {}) - } finally { - this.loading = false - } - }, - - async pause(torrent) { - await this.request(`${this.pluginName}.pause`, {torrent: torrent}) - await this.refresh() - }, - - async resume(torrent) { - await this.request(`${this.pluginName}.resume`, {torrent: torrent}) - await this.refresh() - }, - - async remove(torrent) { - await this.request(`${this.pluginName}.remove`, {torrent: torrent}) - await this.refresh() - }, - - onTorrentUpdate(torrent) { - this.transfers[this.torrentId(torrent)] = torrent - }, - - onTorrentRemove(torrent) { - const torrentId = this.torrentId(torrent) - if (torrentId in this.transfers) - delete this.transfers[torrentId] - }, - }, - - mounted() { - this.refresh() - - this.subscribe( - this.onTorrentUpdate,'on-torrent-update', - 'platypush.message.event.torrent.TorrentQueuedEvent', - 'platypush.message.event.torrent.TorrentDownloadedMetadataEvent', - 'platypush.message.event.torrent.TorrentDownloadStartEvent', - 'platypush.message.event.torrent.TorrentDownloadProgressEvent', - 'platypush.message.event.torrent.TorrentResumedEvent', - 'platypush.message.event.torrent.TorrentPausedEvent', - 'platypush.message.event.torrent.TorrentSeedingStartEvent', - 'platypush.message.event.torrent.TorrentStateChangeEvent', - 'platypush.message.event.torrent.TorrentDownloadStopEvent', - 'platypush.message.event.torrent.TorrentDownloadCompletedEvent') - - this.subscribe(this.onTorrentRemove,'on-torrent-remove', - 'platypush.message.event.torrent.TorrentRemovedEvent') - }, - - destroy() { - this.unsubscribe('on-torrent-update') - this.unsubscribe('on-torrent-remove') - }, } diff --git a/platypush/backend/http/webapp/src/components/panels/Torrent/vars.scss b/platypush/backend/http/webapp/src/components/panels/Torrent/vars.scss index 9bb0cf0a33..f1d0f7744d 100644 --- a/platypush/backend/http/webapp/src/components/panels/Torrent/vars.scss +++ b/platypush/backend/http/webapp/src/components/panels/Torrent/vars.scss @@ -1 +1,2 @@ $torrent-header-height: 3.3em; +$torrent-nav-width: 2.8em; diff --git a/platypush/backend/http/webapp/vue.config.js b/platypush/backend/http/webapp/vue.config.js index 56aeb5541f..1ff73b8cdf 100644 --- a/platypush/backend/http/webapp/vue.config.js +++ b/platypush/backend/http/webapp/vue.config.js @@ -38,6 +38,7 @@ module.exports = { '^/ws/requests': wsProxy, '^/ws/shell': wsProxy, '^/execute': httpProxy, + '^/file': httpProxy, '^/auth': httpProxy, '^/camera/': httpProxy, '^/sound/': httpProxy, diff --git a/platypush/plugins/media/search/torrent.py b/platypush/plugins/media/search/torrent.py index 70b890799f..f83f750e89 100644 --- a/platypush/plugins/media/search/torrent.py +++ b/platypush/plugins/media/search/torrent.py @@ -6,10 +6,19 @@ class TorrentMediaSearcher(MediaSearcher): def search(self, query, **kwargs): self.logger.info('Searching torrents for "{}"'.format(query)) - torrents = get_plugin(self.media_plugin.torrent_plugin if self.media_plugin else 'torrent') + torrents = get_plugin( + self.media_plugin.torrent_plugin if self.media_plugin else 'torrent' + ) if not torrents: raise RuntimeError('Torrent plugin not available/configured') - return torrents.search(query, ).output + + return [ + torrent + for torrent in torrents.search( + query, + ).output + if torrent.get('is_media') + ] # vim:sw=4:ts=4:et: