support modifying which page should be navigated to after creating a new task

This commit is contained in:
MaysWind 2017-05-14 14:16:46 +08:00
parent a3e77f665a
commit 29ca154c22
7 changed files with 46 additions and 5 deletions

View file

@ -141,6 +141,9 @@ Add New RPC Setting=添加新 RPC 配置
Are you sure you want to remove rpc setting "{{rpcName}}"?=您是否要删除 RPC 设置 "{{rpcName}}"? Are you sure you want to remove rpc setting "{{rpcName}}"?=您是否要删除 RPC 设置 "{{rpcName}}"?
Global Stat Refresh Interval=全局状态刷新间隔 Global Stat Refresh Interval=全局状态刷新间隔
Download Task Refresh Interval=下载任务刷新间隔 Download Task Refresh Interval=下载任务刷新间隔
After Creating A New Task=当创建新任务后
Navigate to Task List Page=转到任务列表页面
Navigate to Task Detail Page=转到任务详情页面
Supported Placeholder=支持的占位符 Supported Placeholder=支持的占位符
AriaNg Title=AriaNg 标题 AriaNg Title=AriaNg 标题
Downloading Count=正在下载数量 Downloading Count=正在下载数量

View file

@ -29,6 +29,7 @@
secret: '', secret: '',
extendRpcServers: [], extendRpcServers: [],
globalStatRefreshInterval: 1000, globalStatRefreshInterval: 1000,
downloadTaskRefreshInterval: 1000 downloadTaskRefreshInterval: 1000,
afterCreatingNewTask: 'task-list'
}); });
}()); }());

View file

@ -145,6 +145,9 @@
'Are you sure you want to remove rpc setting "{{rpcName}}"?': 'Are you sure you want to remove rpc setting "{{rpcName}}"?', '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', 'Global Stat Refresh Interval': 'Global Stat Refresh Interval',
'Download Task Refresh Interval': 'Download Task 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', 'Supported Placeholder': 'Supported Placeholder',
'AriaNg Title': 'AriaNg Title', 'AriaNg Title': 'AriaNg Title',
'Downloading Count': 'Downloading Count', 'Downloading Count': 'Downloading Count',

View file

@ -1,7 +1,7 @@
(function () { (function () {
'use strict'; '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 tabOrders = ['links', 'options'];
var downloadByLinks = function (pauseOnAdded, responseCallback) { var downloadByLinks = function (pauseOnAdded, responseCallback) {
@ -130,10 +130,22 @@
return; return;
} }
if (pauseOnAdded) { var firstTask = null;
$location.path('/waiting');
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 { } else {
$location.path('/downloading'); if (pauseOnAdded) {
$location.path('/waiting');
} else {
$location.path('/downloading');
}
} }
}; };

View file

@ -102,6 +102,10 @@
ariaNgSettingService.setLanguage(value); ariaNgSettingService.setLanguage(value);
}; };
$scope.setAfterCreatingNewTask = function (value) {
ariaNgSettingService.setAfterCreatingNewTask(value);
};
$scope.setDebugMode = function (value) { $scope.setDebugMode = function (value) {
ariaNgSettingService.setDebugMode(value); ariaNgSettingService.setDebugMode(value);
}; };

View file

@ -186,6 +186,12 @@
setTitleRefreshInterval: function (value) { setTitleRefreshInterval: function (value) {
setOption('titleRefreshInterval', Math.max(parseInt(value), 0)); setOption('titleRefreshInterval', Math.max(parseInt(value), 0));
}, },
getAfterCreatingNewTask: function () {
return getOption('afterCreatingNewTask');
},
setAfterCreatingNewTask: function (value) {
setOption('afterCreatingNewTask', value);
},
getBrowserNotification: function () { getBrowserNotification: function () {
return getOption('browserNotification'); return getOption('browserNotification');
}, },

View file

@ -115,6 +115,18 @@
</select> </select>
</div> </div>
</div> </div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>After Creating A New Task</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;" ng-model="context.settings.afterCreatingNewTask"
ng-change="setAfterCreatingNewTask(context.settings.afterCreatingNewTask)">
<option value="task-list" translate>Navigate to Task List Page</option>
<option value="task-detail" translate>Navigate to Task Detail Page</option>
</select>
</div>
</div>
<div class="row tip no-background no-hover"> <div class="row tip no-background no-hover">
<span class="asterisk">*</span> <span class="asterisk">*</span>
<span translate>Changes to the settings take effect after refreshing page.</span> <span translate>Changes to the settings take effect after refreshing page.</span>