split ariang settings into global and RPC settings

This commit is contained in:
MaysWind 2016-08-13 22:51:42 +08:00
parent 8800745ba3
commit 2c29a52afb
4 changed files with 182 additions and 116 deletions

View file

@ -7,6 +7,8 @@ Confirm=确认
Cancel=取消 Cancel=取消
True=是 True=是
False=否 False=否
Global=全局
RPC=RPC
New=新建 New=新建
Start=开始下载任务 Start=开始下载任务
Pause=暂停下载任务 Pause=暂停下载任务

View file

@ -11,6 +11,8 @@
'Cancel': 'Cancel', 'Cancel': 'Cancel',
'True': 'True', 'True': 'True',
'False': 'False', 'False': 'False',
'Global': 'Global',
'RPC': 'RPC',
'New': 'New', 'New': 'New',
'Start': 'Start', 'Start': 'Start',
'Pause': 'Pause', 'Pause': 'Pause',

View file

@ -2,13 +2,43 @@
'use strict'; 'use strict';
angular.module('ariaNg').controller('AriaNgSettingsController', ['$rootScope', '$scope', '$timeout', 'ariaNgLanguages', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgNotificationService', function ($rootScope, $scope, $timeout, ariaNgLanguages, ariaNgCommonService, ariaNgSettingService, ariaNgNotificationService) { angular.module('ariaNg').controller('AriaNgSettingsController', ['$rootScope', '$scope', '$timeout', 'ariaNgLanguages', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgNotificationService', function ($rootScope, $scope, $timeout, ariaNgLanguages, ariaNgCommonService, ariaNgSettingService, ariaNgNotificationService) {
var tabOrders = ['global', 'rpc'];
$scope.context = { $scope.context = {
currentTab: 'global',
languages: ariaNgLanguages, languages: ariaNgLanguages,
availableTime: ariaNgCommonService.getTimeOptions([1000, 2000, 3000, 5000, 10000, 30000, 60000], true), availableTime: ariaNgCommonService.getTimeOptions([1000, 2000, 3000, 5000, 10000, 30000, 60000], true),
trueFalseOptions: [{name: 'True', value: true}, {name: 'False', value: false}], trueFalseOptions: [{name: 'True', value: true}, {name: 'False', value: false}],
settings: ariaNgSettingService.getAllOptions() settings: ariaNgSettingService.getAllOptions()
}; };
$scope.changeTab = function (tabName) {
$scope.context.currentTab = tabName;
};
$rootScope.swipeActions.extentLeftSwipe = function () {
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
if (tabIndex < tabOrders.length - 1) {
$scope.changeTab(tabOrders[tabIndex + 1]);
return true;
} else {
return false;
}
};
$rootScope.swipeActions.extentRightSwipe = function () {
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
if (tabIndex > 0) {
$scope.changeTab(tabOrders[tabIndex - 1]);
return true;
} else {
return false;
}
};
$scope.settingService = ariaNgSettingService; $scope.settingService = ariaNgSettingService;
$scope.isSupportNotification = function () { $scope.isSupportNotification = function () {

View file

@ -1,122 +1,154 @@
<section class="content no-padding"> <section class="content no-padding">
<div class="settings-table striped hoverable"> <div class="nav-tabs-custom">
<div class="row"> <ul class="nav nav-tabs">
<div class="setting-key setting-key-without-desc col-sm-4"> <li ng-class="{'active': context.currentTab == 'global'}">
<span translate>Language</span> <a class="pointer-cursor" ng-click="changeTab('global')" translate>Global</a>
</li>
<li ng-class="{'active': context.currentTab == 'rpc'}">
<a class="pointer-cursor" ng-click="changeTab('rpc')" translate>RPC</a>
</li>
</ul>
<div class="tab-content no-padding">
<div class="tab-pane" ng-class="{'active': context.currentTab == 'global'}">
<div class="settings-table striped hoverable">
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Language</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;" ng-model="context.settings.language"
ng-options="type as language.displayName for (type, language) in context.languages"
ng-change="settingService.setLanguage(context.settings.language)">
</select>
</div>
</div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Page Title</span>
<i class="icon-primary fa fa-question-circle"
ng-tooltip="{{'Supported Placeholder: AriaNg Title ${title}, Downloading Count ${downloading}, Waiting Count ${waiting}, Stopped Count ${stopped}, Download Speed ${downspeed}, Upload Speed ${upspeed}.'| translate}}"
ng-tooltip-container="body" ng-tooltip-placement="right"></i>
</div>
<div class="setting-value col-sm-8">
<input class="form-control" type="text" ng-model="context.settings.title"
ng-change="settingService.setTitle(context.settings.title)"/>
</div>
</div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Page Title Refresh Interval</span>
<span class="asterisk">*</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;"
ng-model="context.settings.titleRefreshInterval"
ng-change="settingService.setTitleRefreshInterval(context.settings.titleRefreshInterval)"
ng-options="time.optionValue as (time.name | translate: {value: time.value}) for time in context.availableTime">
</select>
</div>
</div>
<div class="row" ng-if="isSupportNotification()">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Enable Browser Notification</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;"
ng-model="context.settings.browserNotification"
ng-change="setEnableBrowserNotification(context.settings.browserNotification)"
ng-options="option.value as (option.name | translate) for option in context.trueFalseOptions">
</select>
</div>
</div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Global Stat Refresh Interval</span>
<span class="asterisk">*</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;"
ng-model="context.settings.globalStatRefreshInterval"
ng-change="settingService.setGlobalStatRefreshInterval(context.settings.globalStatRefreshInterval)"
ng-options="time.optionValue as (time.name | translate: {value: time.value}) for time in context.availableTime">
</select>
</div>
</div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Download Task Refresh Interval</span>
<span class="asterisk">*</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;"
ng-model="context.settings.downloadTaskRefreshInterval"
ng-change="settingService.setDownloadTaskRefreshInterval(context.settings.downloadTaskRefreshInterval)"
ng-options="time.optionValue as (time.name | translate: {value: time.value}) for time in context.availableTime">
</select>
</div>
</div>
<div class="row tip no-background no-hover">
<span class="asterisk">*</span>
<span translate>Changes to the settings take effect after refreshing page.</span>
</div>
</div>
</div> </div>
<div class="setting-value col-sm-8"> <div class="tab-pane" ng-class="{'active': context.currentTab == 'rpc'}">
<select class="form-control" style="width: 100%;" ng-model="context.settings.language" <div class="settings-table striped hoverable">
ng-options="type as language.displayName for (type, language) in context.languages" <div class="row">
ng-change="settingService.setLanguage(context.settings.language)"> <div class="setting-key setting-key-without-desc col-sm-4">
</select> <span translate>Aria2 RPC Host</span>
</div> <span class="asterisk">*</span>
</div> </div>
<div class="row"> <div class="setting-value col-sm-8">
<div class="setting-key setting-key-without-desc col-sm-4"> <div class="input-group">
<span translate>Page Title</span> <span class="input-group-addon" ng-bind="context.settings.protocol + '://'"></span>
<i class="icon-primary fa fa-question-circle" ng-tooltip="{{'Supported Placeholder: AriaNg Title ${title}, Downloading Count ${downloading}, Waiting Count ${waiting}, Stopped Count ${stopped}, Download Speed ${downspeed}, Upload Speed ${upspeed}.'| translate}}" <input class="form-control" type="text" ng-model="context.settings.rpcHost"
ng-tooltip-container="body" ng-tooltip-placement="right"></i> ng-change="settingService.setRpcHost(context.settings.rpcHost)"/>
</div> <span class="input-group-addon" style="border-left: 0">:</span>
<div class="setting-value col-sm-8"> <span class="input-group-addon" ng-bind="context.settings.rpcPort"></span>
<input class="form-control" type="text" ng-model="context.settings.title" ng-change="settingService.setTitle(context.settings.title)"/> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="setting-key setting-key-without-desc col-sm-4"> <div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Page Title Refresh Interval</span> <span translate>Aria2 RPC Port</span>
<span class="asterisk">*</span> <span class="asterisk">*</span>
</div> </div>
<div class="setting-value col-sm-8"> <div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;" ng-model="context.settings.titleRefreshInterval" <input class="form-control" type="text" ng-model="context.settings.rpcPort"
ng-change="settingService.setTitleRefreshInterval(context.settings.titleRefreshInterval)" ng-change="settingService.setRpcPort(context.settings.rpcPort)"/>
ng-options="time.optionValue as (time.name | translate: {value: time.value}) for time in context.availableTime"> </div>
</select> </div>
</div> <div class="row">
</div> <div class="setting-key setting-key-without-desc col-sm-4">
<div class="row"> <span translate>Aria2 RPC Protocol</span>
<div class="setting-key setting-key-without-desc col-sm-4"> <span class="asterisk">*</span>
<span translate>Aria2 RPC Host</span> </div>
<span class="asterisk">*</span> <div class="setting-value col-sm-8">
</div> <select class="form-control" style="width: 100%;" ng-model="context.settings.protocol"
<div class="setting-value col-sm-8"> ng-change="settingService.setProtocol(context.settings.protocol)">
<div class="input-group"> <option value="http" translate>Http</option>
<span class="input-group-addon" ng-bind="context.settings.protocol + '://'"></span> <option value="https" translate>Https</option>
<input class="form-control" type="text" ng-model="context.settings.rpcHost" ng-change="settingService.setRpcHost(context.settings.rpcHost)"/> <option value="ws" translate>WebSocket</option>
<span class="input-group-addon" style="border-left: 0">:</span> <option value="wss" translate>WebSocket (Security)</option>
<span class="input-group-addon" ng-bind="context.settings.rpcPort"></span> </select>
</div>
</div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Aria2 RPC Secret Token</span>
<span class="asterisk">*</span>
</div>
<div class="setting-value col-sm-8">
<input class="form-control" type="password" ng-model="context.settings.secret"
ng-change="settingService.setSecret(context.settings.secret)"/>
</div>
</div>
<div class="row tip no-background no-hover">
<span class="asterisk">*</span>
<span translate>Changes to the settings take effect after refreshing page.</span>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Aria2 RPC Port</span>
<span class="asterisk">*</span>
</div>
<div class="setting-value col-sm-8">
<input class="form-control" type="text" ng-model="context.settings.rpcPort" ng-change="settingService.setRpcPort(context.settings.rpcPort)"/>
</div>
</div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Aria2 RPC Protocol</span>
<span class="asterisk">*</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;" ng-model="context.settings.protocol" ng-change="settingService.setProtocol(context.settings.protocol)">
<option value="http" translate>Http</option>
<option value="https" translate>Https</option>
<option value="ws" translate>WebSocket</option>
<option value="wss" translate>WebSocket (Security)</option>
</select>
</div>
</div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Aria2 RPC Secret Token</span>
<span class="asterisk">*</span>
</div>
<div class="setting-value col-sm-8">
<input class="form-control" type="password" ng-model="context.settings.secret" ng-change="settingService.setSecret(context.settings.secret)"/>
</div>
</div>
<div class="row" ng-if="isSupportNotification()">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Enable Browser Notification</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;" ng-model="context.settings.browserNotification"
ng-change="setEnableBrowserNotification(context.settings.browserNotification)"
ng-options="option.value as (option.name | translate) for option in context.trueFalseOptions">
</select>
</div>
</div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Global Stat Refresh Interval</span>
<span class="asterisk">*</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;" ng-model="context.settings.globalStatRefreshInterval"
ng-change="settingService.setGlobalStatRefreshInterval(context.settings.globalStatRefreshInterval)"
ng-options="time.optionValue as (time.name | translate: {value: time.value}) for time in context.availableTime">
</select>
</div>
</div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Download Task Refresh Interval</span>
<span class="asterisk">*</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;" ng-model="context.settings.downloadTaskRefreshInterval"
ng-change="settingService.setDownloadTaskRefreshInterval(context.settings.downloadTaskRefreshInterval)"
ng-options="time.optionValue as (time.name | translate: {value: time.value}) for time in context.availableTime">
</select>
</div>
</div>
<div class="row tip no-background no-hover">
<span class="asterisk">*</span>
<span translate>Changes to the settings take effect after refreshing page.</span>
</div>
</div> </div>
</section> </section>