hide browser notification setting when protocol is http or https

This commit is contained in:
MaysWind 2016-06-29 23:30:01 +08:00
parent 754580db42
commit 7cd76f5571
3 changed files with 22 additions and 15 deletions

View file

@ -6,12 +6,16 @@
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()
supportBrowserNotification: ariaNgNotificationService.isSupportBrowserNotification()
}; };
$scope.settingService = ariaNgSettingService; $scope.settingService = ariaNgSettingService;
$scope.isSupportNotification = function () {
return ariaNgNotificationService.isSupportBrowserNotification() &&
ariaNgSettingService.isUseWebSocket($scope.context.settings.protocol);
};
$scope.setEnableBrowserNotification = function (value) { $scope.setEnableBrowserNotification = function (value) {
ariaNgSettingService.setBrowserNotification(value); ariaNgSettingService.setBrowserNotification(value);

View file

@ -132,8 +132,11 @@
setProtocol: function (value) { setProtocol: function (value) {
setOption('protocol', value); setOption('protocol', value);
}, },
isUseWebSocket: function () { isUseWebSocket: function (protocol) {
var protocol = this.getProtocol(); if (!protocol) {
protocol = this.getProtocol();
}
return protocol == 'ws' || protocol == 'wss'; return protocol == 'ws' || protocol == 'wss';
}, },
getSecret: function () { getSecret: function () {

View file

@ -33,17 +33,6 @@
</select> </select>
</div> </div>
</div> </div>
<div class="row" ng-if="context.supportBrowserNotification">
<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="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>Aria2 RPC Host</span> <span translate>Aria2 RPC Host</span>
@ -90,6 +79,17 @@
<input class="form-control" type="password" ng-model="context.settings.secret" ng-change="settingService.setSecret(context.settings.secret)"/> <input class="form-control" type="password" ng-model="context.settings.secret" ng-change="settingService.setSecret(context.settings.secret)"/>
</div> </div>
</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="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>Global Stat Refresh Interval</span> <span translate>Global Stat Refresh Interval</span>