From 29ca154c22b761c4fc977e304441a76b2abeb65c Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 14 May 2017 14:16:46 +0800 Subject: [PATCH] support modifying which page should be navigated to after creating a new task --- src/langs/zh_CN.txt | 3 +++ src/scripts/config/constants.js | 3 ++- src/scripts/config/defaultLanguage.js | 3 +++ src/scripts/controllers/new.js | 20 ++++++++++++++++---- src/scripts/controllers/settings-ariang.js | 4 ++++ src/scripts/services/ariaNgSettingService.js | 6 ++++++ src/views/settings-ariang.html | 12 ++++++++++++ 7 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/langs/zh_CN.txt b/src/langs/zh_CN.txt index ab45073..d6721c9 100644 --- a/src/langs/zh_CN.txt +++ b/src/langs/zh_CN.txt @@ -141,6 +141,9 @@ Add New RPC Setting=添加新 RPC 配置 Are you sure you want to remove rpc setting "{{rpcName}}"?=您是否要删除 RPC 设置 "{{rpcName}}"? Global Stat Refresh Interval=全局状态刷新间隔 Download Task Refresh Interval=下载任务刷新间隔 +After Creating A New Task=当创建新任务后 +Navigate to Task List Page=转到任务列表页面 +Navigate to Task Detail Page=转到任务详情页面 Supported Placeholder=支持的占位符 AriaNg Title=AriaNg 标题 Downloading Count=正在下载数量 diff --git a/src/scripts/config/constants.js b/src/scripts/config/constants.js index 5d02e03..cc75b7f 100644 --- a/src/scripts/config/constants.js +++ b/src/scripts/config/constants.js @@ -29,6 +29,7 @@ secret: '', extendRpcServers: [], globalStatRefreshInterval: 1000, - downloadTaskRefreshInterval: 1000 + downloadTaskRefreshInterval: 1000, + afterCreatingNewTask: 'task-list' }); }()); diff --git a/src/scripts/config/defaultLanguage.js b/src/scripts/config/defaultLanguage.js index 28486cb..518a9bc 100644 --- a/src/scripts/config/defaultLanguage.js +++ b/src/scripts/config/defaultLanguage.js @@ -145,6 +145,9 @@ 'Are you sure you want to remove rpc setting "{{rpcName}}"?': 'Are you sure you want to remove rpc setting "{{rpcName}}"?', 'Global Stat Refresh Interval': 'Global Stat Refresh Interval', 'Download Task Refresh Interval': 'Download Task Refresh Interval', + 'After Creating A New Task': 'After Creating A New Task', + 'Navigate to Task List Page': 'Navigate to Task List Page', + 'Navigate to Task Detail Page': 'Navigate to Task Detail Page', 'Supported Placeholder': 'Supported Placeholder', 'AriaNg Title': 'AriaNg Title', 'Downloading Count': 'Downloading Count', diff --git a/src/scripts/controllers/new.js b/src/scripts/controllers/new.js index 0ddb556..361601d 100644 --- a/src/scripts/controllers/new.js +++ b/src/scripts/controllers/new.js @@ -1,7 +1,7 @@ (function () { 'use strict'; - angular.module('ariaNg').controller('NewTaskController', ['$rootScope', '$scope', '$location', '$timeout', 'ariaNgCommonService', 'ariaNgFileService', 'aria2SettingService', 'aria2TaskService', function ($rootScope, $scope, $location, $timeout, ariaNgCommonService, ariaNgFileService, aria2SettingService, aria2TaskService) { + angular.module('ariaNg').controller('NewTaskController', ['$rootScope', '$scope', '$location', '$timeout', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgFileService', 'aria2SettingService', 'aria2TaskService', function ($rootScope, $scope, $location, $timeout, ariaNgCommonService, ariaNgSettingService, ariaNgFileService, aria2SettingService, aria2TaskService) { var tabOrders = ['links', 'options']; var downloadByLinks = function (pauseOnAdded, responseCallback) { @@ -130,10 +130,22 @@ return; } - if (pauseOnAdded) { - $location.path('/waiting'); + var firstTask = null; + + if (response.results && response.results.length > 0) { + firstTask = response.results[0]; + } else if (response) { + firstTask = response; + } + + if (ariaNgSettingService.getAfterCreatingNewTask() === 'task-detail' && firstTask && firstTask.data) { + $location.path('/task/detail/' + firstTask.data); } else { - $location.path('/downloading'); + if (pauseOnAdded) { + $location.path('/waiting'); + } else { + $location.path('/downloading'); + } } }; diff --git a/src/scripts/controllers/settings-ariang.js b/src/scripts/controllers/settings-ariang.js index 1ad32ed..30bd9d9 100644 --- a/src/scripts/controllers/settings-ariang.js +++ b/src/scripts/controllers/settings-ariang.js @@ -102,6 +102,10 @@ ariaNgSettingService.setLanguage(value); }; + $scope.setAfterCreatingNewTask = function (value) { + ariaNgSettingService.setAfterCreatingNewTask(value); + }; + $scope.setDebugMode = function (value) { ariaNgSettingService.setDebugMode(value); }; diff --git a/src/scripts/services/ariaNgSettingService.js b/src/scripts/services/ariaNgSettingService.js index d239bed..4704496 100644 --- a/src/scripts/services/ariaNgSettingService.js +++ b/src/scripts/services/ariaNgSettingService.js @@ -186,6 +186,12 @@ setTitleRefreshInterval: function (value) { setOption('titleRefreshInterval', Math.max(parseInt(value), 0)); }, + getAfterCreatingNewTask: function () { + return getOption('afterCreatingNewTask'); + }, + setAfterCreatingNewTask: function (value) { + setOption('afterCreatingNewTask', value); + }, getBrowserNotification: function () { return getOption('browserNotification'); }, diff --git a/src/views/settings-ariang.html b/src/views/settings-ariang.html index 97ad502..a0c01bf 100644 --- a/src/views/settings-ariang.html +++ b/src/views/settings-ariang.html @@ -115,6 +115,18 @@ +
+
+ After Creating A New Task +
+
+ +
+
* Changes to the settings take effect after refreshing page.