mirror of
https://github.com/zoriya/flood.git
synced 2025-12-06 07:16:18 +00:00
client: add "Download .torrent" context menu item
This commit is contained in:
@@ -31,19 +31,6 @@ const InlineTorrentPropertyCheckbox: FC<{property: keyof TorrentProperties}> = o
|
||||
),
|
||||
);
|
||||
|
||||
const handleTorrentDownload = (hash: TorrentProperties['hash']): void => {
|
||||
const {baseURI} = ConfigStore;
|
||||
const link = document.createElement('a');
|
||||
|
||||
link.download = '';
|
||||
link.href = `${baseURI}api/torrents/${hash}/contents/all/data`;
|
||||
link.style.display = 'none';
|
||||
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
};
|
||||
|
||||
const getContextMenuItems = (torrent: TorrentProperties): Array<ContextMenuItem> => {
|
||||
const changePriorityFuncRef = createRef<() => number>();
|
||||
|
||||
@@ -129,11 +116,38 @@ const getContextMenuItems = (torrent: TorrentProperties): Array<ContextMenuItem>
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
action: 'torrentDownload',
|
||||
label: TorrentContextMenuActions.torrentDownload.id,
|
||||
action: 'downloadContents',
|
||||
label: TorrentContextMenuActions.downloadContents.id,
|
||||
clickHandler: (e) => {
|
||||
e.preventDefault();
|
||||
handleTorrentDownload(getLastSelectedTorrent());
|
||||
|
||||
const link = document.createElement('a');
|
||||
|
||||
link.download = '';
|
||||
link.href = `${ConfigStore.baseURI}api/torrents/${getLastSelectedTorrent()}/contents/all/data`;
|
||||
link.style.display = 'none';
|
||||
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
action: 'downloadMetainfo',
|
||||
label: TorrentContextMenuActions.downloadMetainfo.id,
|
||||
clickHandler: (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const link = document.createElement('a');
|
||||
|
||||
link.download = '';
|
||||
link.href = `${ConfigStore.baseURI}api/torrents/${TorrentStore.selectedTorrents.join(',')}/metainfo`;
|
||||
link.style.display = 'none';
|
||||
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -23,8 +23,11 @@ const TorrentContextMenuActions = {
|
||||
torrentDetails: {
|
||||
id: 'torrents.list.context.details',
|
||||
},
|
||||
torrentDownload: {
|
||||
id: 'torrents.list.context.download',
|
||||
downloadContents: {
|
||||
id: 'torrents.list.context.download.contents',
|
||||
},
|
||||
downloadMetainfo: {
|
||||
id: 'torrents.list.context.download.metainfo',
|
||||
},
|
||||
generateMagnet: {
|
||||
id: 'torrents.list.context.generate.magnet',
|
||||
|
||||
@@ -2209,10 +2209,16 @@
|
||||
"value": "Torrent Details"
|
||||
}
|
||||
],
|
||||
"torrents.list.context.download": [
|
||||
"torrents.list.context.download.contents": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Download"
|
||||
"value": "Download Contents"
|
||||
}
|
||||
],
|
||||
"torrents.list.context.download.metainfo": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Download .torrent"
|
||||
}
|
||||
],
|
||||
"torrents.list.context.generate.magnet": [
|
||||
|
||||
@@ -316,7 +316,8 @@
|
||||
"torrents.list.context.generate.magnet": "Generate Magnet Link",
|
||||
"torrents.list.context.move": "Set Torrent Location",
|
||||
"torrents.list.context.pause": "Pause",
|
||||
"torrents.list.context.download": "Download",
|
||||
"torrents.list.context.download.contents": "Download Contents",
|
||||
"torrents.list.context.download.metainfo": "Download .torrent",
|
||||
"torrents.list.context.initial.seeding": "Initial Seeding",
|
||||
"torrents.list.context.priority": "Priority",
|
||||
"torrents.list.context.remove": "Remove",
|
||||
|
||||
@@ -57,7 +57,8 @@ const defaultFloodSettings: Readonly<FloodSettings> = {
|
||||
{id: 'move', visible: true},
|
||||
{id: 'setTrackers', visible: false},
|
||||
{id: 'torrentDetails', visible: true},
|
||||
{id: 'torrentDownload', visible: true},
|
||||
{id: 'downloadContents', visible: true},
|
||||
{id: 'downloadMetainfo', visible: false},
|
||||
{id: 'generateMagnet', visible: false},
|
||||
{id: 'setInitialSeeding', visible: false},
|
||||
{id: 'setSequential', visible: false},
|
||||
|
||||
Reference in New Issue
Block a user