diff --git a/src/Api.ts b/src/Api.ts
index 9bde463..cf7fa30 100644
--- a/src/Api.ts
+++ b/src/Api.ts
@@ -143,15 +143,11 @@ class Api {
}
public editTracker(hash: string, origUrl: string, newUrl: string) {
- const params = {
- hash,
- origUrl,
- newUrl,
- };
+ return this.actionTorrents('editTracker', [hash], { origUrl, newUrl });
+ }
- return this.axios.get('/torrents/editTracker', {
- params,
- }).then(Api.handleResponse);
+ public setTorrentLocation(hashes: string[], location: string) {
+ return this.actionTorrents('setLocation', hashes, { location });
}
public getTorrentProperties(hash: string) {
diff --git a/src/components/Drawer.vue b/src/components/Drawer.vue
index 5fb5974..9aebcc2 100644
--- a/src/components/Drawer.vue
+++ b/src/components/Drawer.vue
@@ -209,7 +209,7 @@ export default class Drawer extends Vue {
const title = `${category.name} (${value.length})`;
const append = `[${size}]`;
return {
- icon: 'mdi-folder-open', title, key: category.key, append,
+ icon: 'mdi-folder', title, key: category.key, append,
};
});
}
@@ -257,7 +257,7 @@ export default class Drawer extends Vue {
select: 'category',
children: [
{
- icon: 'mdi-folder-open', title: `${tr('all')} (${this.allTorrents.length})`, key: null, append: `[${totalSize}]`,
+ icon: 'mdi-folder', title: `${tr('all')} (${this.allTorrents.length})`, key: null, append: `[${totalSize}]`,
},
...this.buildCategoryGroup(),
],
diff --git a/src/components/GlobalDialog.vue b/src/components/GlobalDialog.vue
index ebcbe53..24e68eb 100644
--- a/src/components/GlobalDialog.vue
+++ b/src/components/GlobalDialog.vue
@@ -101,6 +101,8 @@ export default {
value.value = !!v;
if (!v) {
input.value = undefined
+ } else {
+ input.value = v.content.value
}
});
watch(value, (v) => {
diff --git a/src/components/Torrents.vue b/src/components/Torrents.vue
index bc71b03..200983e 100644
--- a/src/components/Torrents.vue
+++ b/src/components/Torrents.vue
@@ -50,10 +50,10 @@
- mdi-folder
+ mdi-folder-star
@@ -66,7 +66,7 @@
@click="setTorrentsCategory(item.key)"
>
- mdi-folder-open
+ mdi-folder
@@ -92,6 +92,14 @@
vertical
inset
/>
+
+ mdi-folder-marker
+
import Vue from 'vue'
-import { mapState, mapGetters, mapMutations } from 'vuex'
-import { intersection, difference } from 'lodash'
+import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
+import { intersection, difference, uniqBy } from 'lodash'
import { tr } from '@/locale'
import ConfirmDeleteDialog from './dialogs/ConfirmDeleteDialog.vue'
@@ -353,6 +361,9 @@ function getStateInfo(state: string) {
'showDialog',
'showSnackBar',
]),
+ ...mapActions([
+ 'asyncShowDialog',
+ ]),
},
})
export default class Torrents extends Vue {
@@ -394,6 +405,7 @@ export default class Torrents extends Vue {
updateConfig!: (_: ConfigPayload) => void
showDialog!: (_: DialogConfig) => void
showSnackBar!: (_: SnackBarConfig) => void
+ asyncShowDialog!: (_: DialogConfig) => Promise
get loading() {
return !this.isDataReady;
@@ -462,15 +474,12 @@ export default class Torrents extends Vue {
if (!this.hasSelected) {
this.selectedRows = this.allTorrents;
}
- const v = await new Promise((resolve) => {
- this.showDialog({
- content: {
- title: 'Reannounce Torrents',
- text: 'Are you sure want to reannounce torrents?',
- type: DialogType.OkCancel,
- callback: resolve,
- },
- });
+ const v = await this.asyncShowDialog({
+ content: {
+ title: 'Reannounce Torrents',
+ text: 'Are you sure want to reannounce torrents?',
+ type: DialogType.OkCancel,
+ },
});
if (!v) {
@@ -502,6 +511,35 @@ export default class Torrents extends Vue {
this.showSnackBar({text: 'Rechecking'});
}
+ async setTorrentLocation() {
+ const savePaths = uniqBy(this.selectedRows, 'save_path');
+
+ const oldPath = savePaths.length > 1 ? '' : savePaths[0].save_path
+ const v = await this.asyncShowDialog({
+ content: {
+ title: tr('title.set_location'),
+ text: '',
+ type: DialogType.Input,
+ value: oldPath,
+ },
+ });
+
+ if (!v) {
+ return;
+ }
+
+ this.showSnackBar({text: tr('label.moving')});
+
+ try {
+ await api.setTorrentLocation(this.selectedHashes, v);
+ } catch (e) {
+ this.showSnackBar({text: e});
+ return;
+ }
+
+ this.showSnackBar({text: tr('label.moved')});
+ }
+
setTorrentsCategory(category: string) {
this.categoryToSet = category;
this.toSetCategory = this.selectedRows;
diff --git a/src/locale/en.ts b/src/locale/en.ts
index b1be4ed..8c2973b 100644
--- a/src/locale/en.ts
+++ b/src/locale/en.ts
@@ -57,8 +57,9 @@ export default {
_: 'Title',
add_torrents: 'Add Torrents',
delete_torrents: 'Delete Torrents',
- set_category: 'Set category',
- edit_tracker: 'Edit tracker',
+ set_category: 'Set Category',
+ edit_tracker: 'Edit Tracker',
+ set_location: 'Set Location',
},
label: {
@@ -76,6 +77,8 @@ export default {
adding: 'Adding…',
reloading: 'Reloading…',
deleting: 'Deleting…',
+ moving: 'Moving…',
+ moved: 'Moved',
},
msg: {
diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts
index 3ffabfa..71729b3 100644
--- a/src/locale/zh-CN.ts
+++ b/src/locale/zh-CN.ts
@@ -59,6 +59,7 @@ export default {
delete_torrents: '删除种子',
set_category: '设置分类',
edit_tracker: '编辑 Tracker',
+ set_location: '修改文件位置',
},
label: {
@@ -76,6 +77,8 @@ export default {
adding: '添加…',
reloading: '刷新中…',
deleting: '删除中…',
+ moving: '移动中…',
+ moved: '已移动',
},
msg: {
diff --git a/src/store/types.ts b/src/store/types.ts
index 5f17dd7..3c7bc45 100644
--- a/src/store/types.ts
+++ b/src/store/types.ts
@@ -42,6 +42,7 @@ export interface DialogConfig {
rules?: CallableFunction[];
placeholder?: string;
+ value?: string;
};
width?: string;
}