diff --git a/src/Api.ts b/src/Api.ts index 890cb60..3deba0c 100644 --- a/src/Api.ts +++ b/src/Api.ts @@ -67,6 +67,10 @@ class Api { return this.axios.get('/log/main').then(this.handleResponse); } + public toggleSpeedLimitsMode() { + return this.axios.post('/transfer/toggleSpeedLimitsMode'); + } + public deleteTorrents(hashes: string[], deleteFiles: boolean) { return this.actionTorrents('delete', hashes, {deleteFiles}); } diff --git a/src/components/Footer.vue b/src/components/Footer.vue index 86e7158..e79b432 100644 --- a/src/components/Footer.vue +++ b/src/components/Footer.vue @@ -3,44 +3,70 @@ - qBittorrent {{ app.version }} - - - - API version: {{ app.apiVersion }} + + + + API version: {{ app.apiVersion }} + + Disk free: {{ info.free_space_on_disk | formatSize }} + + + Torrents: {{ allTorrents.length }} ({{ totalSize | formatSize }}) + - - Torrents size: {{ allTorrents.length }} ({{ totalSize | formatSize }}) - - DHT: {{ info.dht_nodes }} nodes - - - - Network {{ info.connection_status }} - - + + + + + Network {{ info.connection_status }} + + + + + + + + + Alternative speed limits {{ speedLimited ? 'enabled' : 'disabled' }} + + + mdi-download {{ info.dl_info_speed | formatSize }}/s - ({{ info.dl_info_data | formatSize }}/{{ info.alltime_dl | formatSize }}) + + [{{ info.dl_info_data | formatSize }}/{{ info.alltime_dl | formatSize }}] @@ -48,7 +74,10 @@ mdi-upload {{ info.up_info_speed | formatSize }}/s - ({{ info.up_info_data | formatSize }}/{{ info.alltime_ul | formatSize }}) + + [{{ info.up_info_data | formatSize }}/{{ info.alltime_ul | formatSize }}] @@ -65,6 +94,7 @@ export default Vue.extend({ data() { return { app: null, + speedLimited: false, }; }, @@ -80,8 +110,8 @@ export default Vue.extend({ connectionIconColor(status: string) { const statusMap: any = { connected: 'success', - firewalled: 'info', - disconnected: 'warning', + firewalled: 'warning', + disconnected: 'error', }; return statusMap[status]; }, @@ -100,6 +130,19 @@ export default Vue.extend({ totalSize() { return _.sumBy(this.allTorrents, 'size'); }, + speedModeBind() { + if (this.speedLimited) { + return { + class: 'speed-limited', + color: 'warning', + } + } + + return { + class: null, + color: 'success' + } + }, }, methods: { @@ -114,10 +157,15 @@ export default Vue.extend({ version, apiVersion, }; }, + async toggleSpeedLimitsMode() { + this.speedLimited = !this.speedLimited; + await api.toggleSpeedLimitsMode(); + }, }, async created() { if (this.isDataReady) { + this.speedLimited = this.info.use_alt_speed_limits; await this.getAppInfo(); } }, @@ -128,6 +176,9 @@ export default Vue.extend({ await this.getAppInfo(); } }, + 'info.use_alt_speed_limits'(v) { + this.speedLimited = v; + }, }, }); @@ -137,4 +188,7 @@ export default Vue.extend({ display: flex; align-items: center; } +.speed-limited { + transform: scaleX(-1); +} diff --git a/src/components/Torrents.vue b/src/components/Torrents.vue index 69cd818..d3c5071 100644 --- a/src/components/Torrents.vue +++ b/src/components/Torrents.vue @@ -90,8 +90,8 @@ {{ row.item.state }} {{ row.item.num_seeds }}/{{ row.item.num_complete }} {{ row.item.num_leechs }}/{{ row.item.num_incomplete }} - {{ formatNetworkSpeed(row.item.dlspeed) }} - {{ formatNetworkSpeed(row.item.upspeed) }} + {{ row.item.dlspeed | formatNetworkSpeed }} + {{ row.item.upspeed | formatNetworkSpeed }} {{ row.item.eta | formatDuration({dayLimit: 100}) }} {{ row.item.ratio.toFixed(2) }} @@ -200,6 +200,13 @@ export default Vue.extend({ const color = progress >= 0.5 ? 'white' : 'black'; return color + '--text'; }, + formatNetworkSpeed(speed: number) { + if (speed === 0) { + return null; + } + + return formatSize(speed) + '/s'; + }, }, methods: { @@ -218,13 +225,6 @@ export default Vue.extend({ async setTorrentsCategory(category: string) { await api.setTorrentsCategory(this.selectedHashes, category); }, - formatNetworkSpeed(speed: number) { - if (speed === 0) { - return null; - } - - return formatSize(speed) + '/s'; - }, }, watch: {