diff --git a/src/Api.ts b/src/Api.ts index d2b719d..9d9bddd 100644 --- a/src/Api.ts +++ b/src/Api.ts @@ -38,10 +38,11 @@ class Api { } public getMainData(rid?: number) { + const params = { + rid, + }; return this.axios.get('/sync/maindata', { - params: { - rid, - }, + params, }); } @@ -66,6 +67,27 @@ class Api { return this.axios.get('/log/main').then(this.handleResponse); } + public deleteTorrents(hashes: string[], deleteFiles: boolean) { + return this.actionTorrents('delete', hashes, {deleteFiles}); + } + + public pauseTorrents(hashes: string[]) { + return this.actionTorrents('pause', hashes); + } + + public resumeTorrents(hashes: string[]) { + return this.actionTorrents('resume', hashes); + } + + private actionTorrents(action: string, hashes: string[], extra?: any) { + const params: any = { + hashes: hashes.join('|'), + ...extra, + }; + const data = new URLSearchParams(params); + return this.axios.post('/torrents/' + action, data).then(this.handleResponse); + } + private handleResponse(resp: AxiosResponse) { return resp.data; } diff --git a/src/App.vue b/src/App.vue index 2f9a742..9fd631e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,6 +9,7 @@ diff --git a/src/components/AddForm.vue b/src/components/AddForm.vue index a9f8d4f..a580770 100644 --- a/src/components/AddForm.vue +++ b/src/components/AddForm.vue @@ -37,6 +37,7 @@ :rules="[v => !!v || 'URLs is required']" :rows="$vuetify.breakpoint.xsOnly ? 1 : 3" required + autofocus /> @@ -128,6 +129,7 @@ export default Vue.extend({ this.submitting = false; this.dialog = false; + this.params.urls = null; }, }, }); diff --git a/src/components/LoginForm.vue b/src/components/LoginForm.vue index b3b15c6..3bb3f0c 100644 --- a/src/components/LoginForm.vue +++ b/src/components/LoginForm.vue @@ -48,11 +48,11 @@