From ed0991e0a5b3985dbea40d343dc6a3c8224e1f32 Mon Sep 17 00:00:00 2001 From: Larsluph <22910497+Larsluph@users.noreply.github.com> Date: Sun, 5 Nov 2023 18:55:24 +0100 Subject: [PATCH] feat(ShareLimit): Add torrent share limit dialog --- .../Dashboard/TRC/RightClickMenu.vue | 4 +- src/components/Dialogs/ShareLimitDialog.vue | 133 ++++++++++++++++++ src/composables/TorrentBuilder.ts | 5 +- src/locales/en.json | 9 ++ src/stores/maindata.ts | 7 +- src/types/qbit/models/Torrent.ts | 2 + src/types/vuetorrent/Torrent.ts | 3 +- 7 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 src/components/Dialogs/ShareLimitDialog.vue diff --git a/src/components/Dashboard/TRC/RightClickMenu.vue b/src/components/Dashboard/TRC/RightClickMenu.vue index 2d58ba47..9b72156c 100644 --- a/src/components/Dashboard/TRC/RightClickMenu.vue +++ b/src/components/Dashboard/TRC/RightClickMenu.vue @@ -3,6 +3,7 @@ import RightClickMenuEntry from '@/components/Dashboard/TRC/RightClickMenuEntry. import ConfirmDeleteDialog from '@/components/Dialogs/ConfirmDeleteDialog.vue' import MoveTorrentDialog from '@/components/Dialogs/MoveTorrentDialog.vue' import RenameTorrentDialog from '@/components/Dialogs/RenameTorrentDialog.vue' +import ShareLimitDialog from '@/components/Dialogs/ShareLimitDialog.vue' import SpeedLimitDialog from '@/components/Dialogs/SpeedLimitDialog.vue' import { useDashboardStore } from '@/stores/dashboard' import { useDialogStore } from '@/stores/dialog' @@ -103,7 +104,7 @@ function setUploadLimit() { } function setShareLimit() { - //TODO: dialogStore.createDialog(ShareLimitDialog, { hash: hash.value }) + dialogStore.createDialog(ShareLimitDialog, { hash: hash.value }) } async function exportTorrents() { @@ -231,7 +232,6 @@ const menuData = computed(() => [ { text: t('dashboard.right_click.speed_limit.share'), icon: 'mdi-account-group', - hidden: true, action: setShareLimit } ] diff --git a/src/components/Dialogs/ShareLimitDialog.vue b/src/components/Dialogs/ShareLimitDialog.vue new file mode 100644 index 00000000..3f9150c8 --- /dev/null +++ b/src/components/Dialogs/ShareLimitDialog.vue @@ -0,0 +1,133 @@ + + + + + \ No newline at end of file diff --git a/src/composables/TorrentBuilder.ts b/src/composables/TorrentBuilder.ts index 0525862a..1d9397ca 100644 --- a/src/composables/TorrentBuilder.ts +++ b/src/composables/TorrentBuilder.ts @@ -28,6 +28,7 @@ export function useTorrentBuilder() { f_l_piece_prio: data.f_l_piece_prio, forced: data.force_start, hash: data.hash, + inactive_seeding_time_limit: data.inactive_seeding_time_limit, infohash_v1: data.infohash_v1, infohash_v2: data.infohash_v2, last_activity: data.last_activity, @@ -38,10 +39,10 @@ export function useTorrentBuilder() { priority: data.priority, progress: data.progress, ratio: Math.round(data.ratio * 100) / 100, - ratio_limit: data.max_ratio, - ratio_time_limit: data.max_seeding_time, + ratio_limit: data.ratio_limit, savePath: data.save_path, seeding_time: data.seeding_time, + seeding_time_limit: data.seeding_time_limit, seen_complete: data.seen_complete, seq_dl: data.seq_dl, size: data.size, diff --git a/src/locales/en.json b/src/locales/en.json index 6683493d..abd82de5 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -550,6 +550,15 @@ "download": "Set Download Speed Limit", "upload": "Set Upload Speed Limit", "label": "Speed Limit" + }, + "share_limit": { + "title": "Set Share Ratio Limit", + "global": "Use global share limit", + "disabled": "Set no share limit", + "enabled": "Set share limit to", + "ratio_limit": "Ratio", + "seeding_time_limit": "Total minutes", + "inactive_seeding_time_limit": "Inactive minutes" } }, "settings": { diff --git a/src/stores/maindata.ts b/src/stores/maindata.ts index 2a637f2b..b43768f3 100644 --- a/src/stores/maindata.ts +++ b/src/stores/maindata.ts @@ -311,6 +311,10 @@ export const useMaindataStore = defineStore('maindata', () => { return await qbit.setUploadLimit(hashes, limit) } + async function setShareLimit(hashes: string[], ratioLimit: number, seedingTimeLimit: number, inactiveSeedingTimeLimit: number) { + return await qbit.setShareLimit(hashes, ratioLimit, seedingTimeLimit, inactiveSeedingTimeLimit) + } + return { categories, isUpdatingMaindata, @@ -364,7 +368,8 @@ export const useMaindataStore = defineStore('maindata', () => { setTorrentFilePriority, exportTorrent, setDownloadLimit, - setUploadLimit + setUploadLimit, + setShareLimit } }, { persist: { diff --git a/src/types/qbit/models/Torrent.ts b/src/types/qbit/models/Torrent.ts index a3a6cbfe..850dc372 100644 --- a/src/types/qbit/models/Torrent.ts +++ b/src/types/qbit/models/Torrent.ts @@ -35,6 +35,7 @@ export default interface Torrent { force_start: boolean /** Torrent hash */ hash: string + inactive_seeding_time_limit: number /** Torrent SHA1 Hash */ infohash_v1: string /** Torrent SHA256 Hash (only in LibTorrent v2) */ @@ -43,6 +44,7 @@ export default interface Torrent { last_activity: number /** Magnet URI corresponding to this torrent */ magnet_uri: string + max_inactive_seeding_time: number /** Maximum share ratio until torrent is stopped from seeding/uploading */ max_ratio: number /** Maximum seeding time (seconds) until torrent is stopped from seeding */ diff --git a/src/types/vuetorrent/Torrent.ts b/src/types/vuetorrent/Torrent.ts index 028cb0ee..f8e8190b 100644 --- a/src/types/vuetorrent/Torrent.ts +++ b/src/types/vuetorrent/Torrent.ts @@ -19,6 +19,7 @@ export default interface Torrent { f_l_piece_prio: boolean forced: boolean hash: string + inactive_seeding_time_limit: number infohash_v1: string infohash_v2: string last_activity: number @@ -30,9 +31,9 @@ export default interface Torrent { progress: number ratio: number ratio_limit: number - ratio_time_limit: number savePath: string seeding_time: number + seeding_time_limit: number seen_complete: number seq_dl: boolean size: number