From 24cc2138cf12dc432df92e4b0b03318d5a98ed88 Mon Sep 17 00:00:00 2001 From: CzBiX Date: Sat, 14 Sep 2019 18:07:03 +0800 Subject: [PATCH] Add general panel --- .travis.yml | 1 + src/Api.ts | 10 ++ src/components/dialogs/InfoDialog.vue | 20 ++- src/components/dialogs/TorrentInfo.vue | 171 +++++++++++++++++++++++++ src/filters.ts | 12 +- vue.config.js | 3 +- 6 files changed, 211 insertions(+), 6 deletions(-) create mode 100644 src/components/dialogs/TorrentInfo.vue diff --git a/.travis.yml b/.travis.yml index d5451d6..9270a29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ before_deploy: echo tagged as $TRAVIS_TAG; fi # Pack for release + # see https://github.com/qbittorrent/qBittorrent/pull/10485, fixed in qb v4.2.0 - cp dist/public/{index,login}.html - cp INSTALL.md dist - zip -r dist.zip dist diff --git a/src/Api.ts b/src/Api.ts index cb837a9..5bbe60e 100644 --- a/src/Api.ts +++ b/src/Api.ts @@ -149,6 +149,16 @@ class Api { }).then(Api.handleResponse); } + public getTorrentProperties(hash: string) { + const params = { + hash, + }; + + return this.axios.get('/torrents/properties', { + params, + }).then(Api.handleResponse); + } + private actionTorrents(action: string, hashes: string[], extra?: any) { const params: any = { hashes: hashes.join('|'), diff --git a/src/components/dialogs/InfoDialog.vue b/src/components/dialogs/InfoDialog.vue index e8d5613..90f3cfd 100644 --- a/src/components/dialogs/InfoDialog.vue +++ b/src/components/dialogs/InfoDialog.vue @@ -14,9 +14,9 @@ - + Trackers @@ -28,6 +28,19 @@ --> + + + + + import _ from 'lodash'; import Vue from 'vue'; +import TorrentInfo from './TorrentInfo.vue'; import Trackers from './Trackers.vue'; import Peers from './Peers.vue'; import Panel from './Panel.vue'; export default Vue.extend({ components: { + TorrentInfo, Trackers, Peers, Panel, @@ -119,6 +134,7 @@ export default Vue.extend({ .v-card__text { min-height: 200px; + padding: 0 8px 8px; } } diff --git a/src/components/dialogs/TorrentInfo.vue b/src/components/dialogs/TorrentInfo.vue new file mode 100644 index 0000000..b40f133 --- /dev/null +++ b/src/components/dialogs/TorrentInfo.vue @@ -0,0 +1,171 @@ + + + + + \ No newline at end of file diff --git a/src/filters.ts b/src/filters.ts index 77d680d..568850f 100644 --- a/src/filters.ts +++ b/src/filters.ts @@ -78,19 +78,25 @@ export function formatDuration(value: number, options?: DurationOptions) { // parts.push(result + units[index]); // } + if (!parts.length) { + return '0'; + } + return parts.join(' '); } Vue.filter('formatDuration', formatDuration); -Vue.filter('formatTimestamp', (timestamp: number) => { - if (timestamp === null) { +export function formatTimestamp(timestamp: number) { + if (timestamp == null || timestamp === -1) { return ''; } const m = dayjs.unix(timestamp); return m.format('YYYY-MM-DD HH:mm:ss'); -}); +} + +Vue.filter('formatTimestamp', formatTimestamp); export function formatAsDuration(date: number, options?: DurationOptions) { const duration = (Date.now() / 1000) - date; diff --git a/vue.config.js b/vue.config.js index 6f094f6..4e8a57f 100644 --- a/vue.config.js +++ b/vue.config.js @@ -6,9 +6,10 @@ module.exports = { }, devServer: { + port: 8000, proxy: { '/api': { - target: 'http://192.168.1.2:8080', + target: 'http://qb.test:8080', }, }, },