From d19b534c1d84022a7af3f605b3649e77f2cc45a5 Mon Sep 17 00:00:00 2001 From: Hendrik Luup Date: Sun, 10 Mar 2024 14:18:54 +0200 Subject: [PATCH 1/2] feat(web): show sequential download status in inspector --- web/src/inspector.js | 9 +++++++++ web/src/torrent.js | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/web/src/inspector.js b/web/src/inspector.js index ed662200b..d97561fac 100644 --- a/web/src/inspector.js +++ b/web/src/inspector.js @@ -91,6 +91,7 @@ export class Inspector extends EventTarget { ['availability', 'Availability:'], ['uploaded', 'Uploaded:'], ['downloaded', 'Downloaded:'], + ['sequential_download', 'Sequential download:'], ['state', 'State:'], ['running_time', 'Running time:'], ['remaining_time', 'Remaining:'], @@ -563,6 +564,14 @@ export class Inspector extends EventTarget { const link = torrents[0].getMagnetLink(); e.info.magnetLink.innerHTML = ``; } + + // Sequential Download + const isSequential = torrents.reduce((acc, cur) => { + cur = cur.isSequentialDownload() ? 'Yes' : 'No'; + return acc !== none && acc !== cur ? mixed : cur; + }, none); + + setTextContent(e.info.sequential_download, isSequential); } /// PEERS PAGE diff --git a/web/src/torrent.js b/web/src/torrent.js index 404dafd83..2ac761f05 100644 --- a/web/src/torrent.js +++ b/web/src/torrent.js @@ -255,6 +255,9 @@ export class Torrent extends EventTarget { isSeeding() { return this.getStatus() === Torrent._StatusSeed; } + isSequentialDownload() { + return this.fields.sequentialDownload; + } isStopped() { return this.getStatus() === Torrent._StatusStopped; } @@ -607,6 +610,7 @@ Torrent.Fields.Stats = [ 'rateUpload', 'recheckProgress', 'seedRatioMode', + 'sequentialDownload', 'seedRatioLimit', 'sizeWhenDone', 'status', From 2ec40cea02f1db5440393777a670fb4d1b72f69f Mon Sep 17 00:00:00 2001 From: Hendrik Luup Date: Sun, 10 Mar 2024 14:49:46 +0200 Subject: [PATCH 2/2] feat(web): add context menu items for sequential downloading --- web/src/action-manager.js | 8 ++++++++ web/src/context-menu.js | 3 +++ web/src/remote.js | 15 +++++++++++++++ web/src/transmission.js | 14 ++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/web/src/action-manager.js b/web/src/action-manager.js index 4b64cf76c..e70eac22b 100644 --- a/web/src/action-manager.js +++ b/web/src/action-manager.js @@ -12,6 +12,14 @@ export class ActionManager extends EventTarget { shortcut: 'D', text: 'Deselect all', }, + 'disable-sequential-downloading': { + enabled: true, + text: 'Disable sequential downloading', + }, + 'enable-sequential-downloading': { + enabled: true, + text: 'Enable sequential downloading', + }, 'move-bottom': { enabled: false, text: 'Move to the back of the queue' }, 'move-down': { enabled: false, text: 'Move down in the queue' }, 'move-top': { enabled: false, text: 'Move to the front of the queue' }, diff --git a/web/src/context-menu.js b/web/src/context-menu.js index 309135269..7dcf2e6f3 100644 --- a/web/src/context-menu.js +++ b/web/src/context-menu.js @@ -94,6 +94,9 @@ export class ContextMenu extends EventTarget { add_item('remove-selected-torrents', true); add_item('trash-selected-torrents', true); add_separator(); + add_item('enable-sequential-downloading'); + add_item('disable-sequential-downloading'); + add_separator(); add_item('verify-selected-torrents'); add_item('show-move-dialog'); add_item('show-rename-dialog'); diff --git a/web/src/remote.js b/web/src/remote.js index 1c7b5b7db..6d0130d33 100644 --- a/web/src/remote.js +++ b/web/src/remote.js @@ -281,6 +281,21 @@ export class Remote { }); } + _setSequentialDownload(torrentIds, state, callback) { + const args = { + ids: torrentIds, + sequentialDownload: state, + }; + this.sendRequest({ arguments: args, method: 'torrent-set' }, callback); + } + + disableSequentialDownload(torrentIds, callback) { + this._setSequentialDownload(torrentIds, false, callback); + } + enableSequentialDownload(torrentIds, callback) { + this._setSequentialDownload(torrentIds, true, callback); + } + // Added queue calls moveTorrentsToTop(torrent_ids, callback, context) { this.sendTorrentActionRequests( diff --git a/web/src/transmission.js b/web/src/transmission.js index 7b10f8d93..251cdca42 100644 --- a/web/src/transmission.js +++ b/web/src/transmission.js @@ -170,6 +170,12 @@ export class Transmission extends EventTarget { ? Prefs.DisplayFull : Prefs.DisplayCompact; break; + case 'enable-sequential-downloading': + this._enableSequentialDownload(this.getSelectedTorrents()); + break; + case 'disable-sequential-downloading': + this._disableSequentialDownload(this.getSelectedTorrents()); + break; case 'trash-selected-torrents': this._removeSelectedTorrents(true); break; @@ -853,6 +859,14 @@ TODO: fix this when notifications get fixed this, ); } + _enableSequentialDownload(torrents) { + this.remote.enableSequentialDownload(Transmission._getTorrentIds(torrents)); + } + _disableSequentialDownload(torrents) { + this.remote.disableSequentialDownload( + Transmission._getTorrentIds(torrents), + ); + } _verifyTorrents(torrents) { this.remote.verifyTorrents( Transmission._getTorrentIds(torrents),