use select control to edit interval time

This commit is contained in:
MaysWind 2016-06-04 13:39:18 +08:00
parent 9de0eee96c
commit 2dff6fd9c7
5 changed files with 79 additions and 17 deletions

View file

@ -85,10 +85,11 @@
"Unknown": "未知",
"Total Count": "共计",
"Bytes": "字节",
"Hours": "小时",
"Minutes": "分",
"Seconds": "秒",
"Milliseconds": "毫秒",
"(0 is disabled)": "(0为禁用)",
"Disabled": "禁用",
"Changes to the settings take effect after refreshing page.": "设置将在页面刷新后生效.",
"Type is illegal!": "类型错误!",
"none": "无",
@ -105,6 +106,16 @@
"notice": "一般 (Notice)",
"warn": "警告 (Warn)",
"error": "错误 (Error)",
"format": {
"time.millisecond": "{{value}} 毫秒",
"time.milliseconds": "{{value}} 毫秒",
"time.second": "{{value}} 秒",
"time.seconds": "{{value}} 秒",
"time.minute": "{{value}} 分钟",
"time.minutes": "{{value}} 分钟",
"time.hour": "{{value}} 小时",
"time.hours": "{{value}} 小时"
},
"options": {
"dir.name": "下载路径",
"dir.description": "",

View file

@ -89,10 +89,11 @@
'Unknown': 'Unknown',
'Total Count': 'Total Count',
'Bytes': 'Bytes',
'Hours': 'Hours',
'Minutes': 'Minutes',
'Seconds': 'Seconds',
'Milliseconds': 'Milliseconds',
'(0 is disabled)': '(0 is disabled)',
'Disabled': 'Disabled',
'Changes to the settings take effect after refreshing page.': 'Changes to the settings take effect after refreshing page.',
'Type is illegal!': 'Type is illegal!',
'none': 'None',
@ -109,6 +110,16 @@
'notice': 'Notice',
'warn': 'Warn',
'error': 'Error',
'format': {
'time.millisecond': '{{value}} Millisecond',
'time.milliseconds': '{{value}} Milliseconds',
'time.second': '{{value}} Second',
'time.seconds': '{{value}} Seconds',
'time.minute': '{{value}} Minute',
'time.minutes': '{{value}} Minutes',
'time.hour': '{{value}} Hour',
'time.hours': '{{value}} Hours',
},
'options': {
'dir.name': 'Download Path',
'dir.description': '',

View file

@ -1,8 +1,9 @@
(function () {
'use strict';
angular.module('ariaNg').controller('AriaNgSettingsController', ['$scope', 'ariaNgLanguages', 'ariaNgSettingService', function ($scope, ariaNgLanguages, ariaNgSettingService) {
angular.module('ariaNg').controller('AriaNgSettingsController', ['$scope', 'ariaNgLanguages', 'ariaNgCommonService', 'ariaNgSettingService', function ($scope, ariaNgLanguages, ariaNgCommonService, ariaNgSettingService) {
$scope.languages = ariaNgLanguages;
$scope.availableTime = ariaNgCommonService.getTimeOptions([1000, 2000, 3000, 5000, 10000, 30000, 60000], true);
$scope.settings = ariaNgSettingService.getAllOptions();
$scope.settingService = ariaNgSettingService;
}]);

View file

@ -110,6 +110,49 @@
});
return obj;
},
getTimeOptions: function (timeList, withDisabled) {
var options = [];
if (withDisabled) {
options.push({
name: 'Disabled',
value: 0,
optionValue: 0
});
}
if (!angular.isArray(timeList) || timeList.length < 1) {
return options;
}
for (var i = 0; i < timeList.length; i++) {
var time = timeList[i];
var name = '';
var value = time;
if (time < 1000) {
value = time;
name = (value == 1 ? 'format.time.millisecond' : 'format.time.milliseconds');
} else if (time < 1000 * 60) {
value = time / 1000;
name = (value == 1 ? 'format.time.second' : 'format.time.seconds');
} else if (time < 1000 * 60 * 24) {
value = time / 1000 / 60;
name = (value == 1 ? 'format.time.minute' : 'format.time.minutes');
} else {
value = time / 1000 / 60 / 24;
name = (value == 1 ? 'format.time.hour' : 'format.time.hours');
}
options.push({
name: name,
value: value,
optionValue: time
})
}
return options;
}
};
}]);

View file

@ -47,31 +47,27 @@
</div>
</div>
<div class="row">
<div class="setting-key col-sm-4">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Global Stat Refresh Interval</span>
<span class="asterisk">*</span>
<span class="description" translate>(0 is disabled)</span>
</div>
<div class="setting-value col-sm-8">
<div class="input-group">
<input class="form-control" type="text" ng-model="settings.globalStatRefreshInterval"
ng-change="settingService.setGlobalStatRefreshInterval(settings.globalStatRefreshInterval)"/>
<span class="input-group-addon" translate>Milliseconds</span>
</div>
<select class="form-control" style="width: 100%;" ng-model="settings.globalStatRefreshInterval"
ng-change="settingService.setGlobalStatRefreshInterval(settings.globalStatRefreshInterval)"
ng-options="time.optionValue as (time.name | translate: {value: time.value}) for time in availableTime">
</select>
</div>
</div>
<div class="row">
<div class="setting-key col-sm-4">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Download Task Refresh Interval</span>
<span class="asterisk">*</span>
<span class="description" translate>(0 is disabled)</span>
</div>
<div class="setting-value col-sm-8">
<div class="input-group">
<input class="form-control" type="text" ng-model="settings.downloadTaskRefreshInterval"
ng-change="settingService.setDownloadTaskRefreshInterval(settings.downloadTaskRefreshInterval)"/>
<span class="input-group-addon" translate>Milliseconds</span>
</div>
<select class="form-control" style="width: 100%;" ng-model="settings.downloadTaskRefreshInterval"
ng-change="settingService.setDownloadTaskRefreshInterval(settings.downloadTaskRefreshInterval)"
ng-options="time.optionValue as (time.name | translate: {value: time.value}) for time in availableTime">
</select>
</div>
</div>
<div class="row tip">