Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Start page showing all tasks available #1639

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10,647 changes: 10,647 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,9 @@
"webpack-hot-middleware": "^2.25.3",
"webpack-merge": "^5.8.0",
"worker-loader": "^3.0.8"
},
"volta": {
"node": "16.20.2",
"npm": "6.14.18"
}
}
3 changes: 3 additions & 0 deletions src/main/menus/touchBar.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"type": "group",
"id": "task.task-list",
"items": [
{
"type": "button", "icon": "task-history", "command": "application:task-list", "command-arg": { "status": "all-tasks" }
},
{
"type": "button", "icon": "task-active", "command": "application:task-list", "command-arg": { "status": "active" }
},
Expand Down
26 changes: 24 additions & 2 deletions src/renderer/api/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default class Api {
}

updateActiveTaskOption (options) {
this.fetchTaskList({ type: 'active' })
this.fetchTaskList({ type: 'all-tasks' })
.then((data) => {
if (isEmpty(data)) {
return
Expand Down Expand Up @@ -223,6 +223,26 @@ export default class Api {
})
}

fetchUnfilteredTaskList (params = {}) {
const { offset = 0, num = 20, keys } = params
const activeArgs = compactUndefined([keys])
const waitingArgs = compactUndefined([offset, num, keys])
return new Promise((resolve, reject) => {
this.client.multicall([
['aria2.tellActive', ...activeArgs],
['aria2.tellWaiting', ...waitingArgs],
['aria2.tellStopped', ...waitingArgs]
]).then((data) => {
console.log('[Motrix] fetch downloading task list data:', data)
const result = mergeTaskResult(data)
resolve(result)
}).catch((err) => {
console.log('[Motrix] fetch downloading task list fail:', err)
reject(err)
})
})
}

fetchWaitingTaskList (params = {}) {
const { offset = 0, num = 20, keys } = params
const args = compactUndefined([offset, num, keys])
Expand All @@ -244,14 +264,16 @@ export default class Api {
fetchTaskList (params = {}) {
const { type } = params
switch (type) {
case 'all-tasks':
return this.fetchUnfilteredTaskList(params)
case 'active':
return this.fetchDownloadingTaskList(params)
case 'waiting':
return this.fetchWaitingTaskList(params)
case 'stopped':
return this.fetchStoppedTaskList(params)
default:
return this.fetchDownloadingTaskList(params)
return this.fetchUnfilteredTaskList(params)
}
}

Expand Down
14 changes: 12 additions & 2 deletions src/renderer/components/Subnav/TaskSubnav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
<nav class="subnav-inner">
<h3>{{ title }}</h3>
<ul>
<li
@click="() => nav('all-tasks')"
:class="[ current === 'all-tasks' ? 'active' : '' ]"
>
<i class="subnav-icon">
<mo-icon name="menu-task" width="20" height="20" />
</i>
<span>{{ $t('task.all-tasks') }}</span>
</li>
<li
@click="() => nav('active')"
:class="[ current === 'active' ? 'active' : '' ]"
Expand Down Expand Up @@ -34,6 +43,7 @@
</template>

<script>
import '@/components/Icons/task-history'
import '@/components/Icons/task-start'
import '@/components/Icons/task-pause'
import '@/components/Icons/task-stop'
Expand All @@ -43,7 +53,7 @@
props: {
current: {
type: String,
default: 'active'
default: 'all-tasks'
}
},
computed: {
Expand All @@ -52,7 +62,7 @@
}
},
methods: {
nav (status = 'active') {
nav (status = 'all-tasks') {
this.$router.push({
path: `/task/${status}`
}).catch(err => {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/Task/AddTask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
this.$store.dispatch('app/hideAddTaskDialog')
if (this.form.newTaskShowDownloading) {
this.$router.push({
path: '/task/active'
path: '/task/all-tasks'
}).catch(err => {
console.log(err)
})
Expand Down
7 changes: 6 additions & 1 deletion src/renderer/components/Task/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
props: {
status: {
type: String,
default: 'active'
default: 'all-tasks'
}
},
computed: {
Expand All @@ -77,6 +77,11 @@
}),
subnavs () {
return [
{
key: 'all-tasks',
title: this.$t('task.all-tasks'),
route: '/task/all-tasks'
},
{
key: 'active',
title: this.$t('task.active'),
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default new Router({
alias: '/',
component: require('@/components/Task/Index').default,
props: {
status: 'active'
status: 'all-tasks'
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/store/modules/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EMPTY_STRING, TASK_STATUS } from '@shared/constants'
import { checkTaskIsBT, intersection } from '@shared/utils'

const state = {
currentList: 'active',
currentList: 'all-tasks',
taskDetailVisible: false,
currentTaskGid: EMPTY_STRING,
enabledFetchPeers: false,
Expand Down
1 change: 1 addition & 0 deletions src/shared/locales/en-US/task.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
'all-tasks': 'All Tasks',
'active': 'Downloading',
'waiting': 'Waiting',
'stopped': 'Stopped',
Expand Down
1 change: 1 addition & 0 deletions src/shared/locales/pt-BR/task.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
'all-tasks': 'Todas Tarefas',
'active': 'Baixando',
'waiting': 'Aguardando',
'stopped': 'Parou',
Expand Down