show notification after modifying configurations which need to reload page

This commit is contained in:
MaysWind 2017-03-29 09:06:43 +08:00
parent 6176de56e9
commit fc54048d5d
5 changed files with 42 additions and 1 deletions

View file

@ -147,6 +147,8 @@ Downloading Count=正在下载数量
Waiting Count=正在等待数量 Waiting Count=正在等待数量
Stopped Count=已停止数量 Stopped Count=已停止数量
You have disabled notification in your browser. You should change your browser's settings before you enable this function.=您已经在浏览器中禁用通知功能. 如需使用此功能, 请修改您浏览器的设置. You have disabled notification in your browser. You should change your browser's settings before you enable this function.=您已经在浏览器中禁用通知功能. 如需使用此功能, 请修改您浏览器的设置.
Configuration has been modified, please reload the page for the changes to take effect.=配置已经修改, 请重新加载页面使其生效.
Refresh=立即刷新
Show Secret=显示密钥 Show Secret=显示密钥
Hide Secret=隐藏密钥 Hide Secret=隐藏密钥
Aria2 Version=Aria2 版本 Aria2 Version=Aria2 版本

View file

@ -151,6 +151,8 @@
'Waiting Count': 'Waiting Count', 'Waiting Count': 'Waiting Count',
'Stopped Count': 'Stopped Count', 'Stopped Count': 'Stopped Count',
'You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.': 'You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.', 'You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.': 'You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.',
'Configuration has been modified, please reload the page for the changes to take effect.': 'Configuration has been modified, please reload the page for the changes to take effect.',
'Refresh': 'Refresh',
'Show Secret': 'Show Secret', 'Show Secret': 'Show Secret',
'Hide Secret': 'Hide Secret', 'Hide Secret': 'Hide Secret',
'Aria2 Version': 'Aria2 Version', 'Aria2 Version': 'Aria2 Version',

View file

@ -3,11 +3,28 @@
angular.module('ariaNg').controller('AriaNgSettingsController', ['$rootScope', '$scope', '$routeParams', '$window', '$interval', '$timeout', 'ariaNgLanguages', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgMonitorService', 'ariaNgNotificationService', 'ariaNgTitleService', function ($rootScope, $scope, $routeParams, $window, $interval, $timeout, ariaNgLanguages, ariaNgCommonService, ariaNgSettingService, ariaNgMonitorService, ariaNgNotificationService, ariaNgTitleService) { angular.module('ariaNg').controller('AriaNgSettingsController', ['$rootScope', '$scope', '$routeParams', '$window', '$interval', '$timeout', 'ariaNgLanguages', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgMonitorService', 'ariaNgNotificationService', 'ariaNgTitleService', function ($rootScope, $scope, $routeParams, $window, $interval, $timeout, ariaNgLanguages, ariaNgCommonService, ariaNgSettingService, ariaNgMonitorService, ariaNgNotificationService, ariaNgTitleService) {
var extendType = $routeParams.extendType; var extendType = $routeParams.extendType;
var lastRefreshPageNotification = null;
var getFinalTitle = function () { var getFinalTitle = function () {
return ariaNgTitleService.getFinalTitleByGlobalStat(ariaNgMonitorService.getCurrentGlobalStat()); return ariaNgTitleService.getFinalTitleByGlobalStat(ariaNgMonitorService.getCurrentGlobalStat());
}; };
var setNeedRefreshPage = function () {
if (lastRefreshPageNotification) {
return;
}
lastRefreshPageNotification = ariaNgNotificationService.notifyInPage('', 'Configuration has been modified, please reload the page for the changes to take effect.', {
delay: false,
type: 'info',
templateUrl: 'setting-changed-notification.html',
scope: $scope,
onClose: function () {
lastRefreshPageNotification = null;
}
});
};
$scope.context = { $scope.context = {
currentTab: 'global', currentTab: 'global',
languages: ariaNgLanguages, languages: ariaNgLanguages,
@ -88,6 +105,7 @@
}; };
$scope.setTitleRefreshInterval = function (value) { $scope.setTitleRefreshInterval = function (value) {
setNeedRefreshPage();
ariaNgSettingService.setTitleRefreshInterval(value); ariaNgSettingService.setTitleRefreshInterval(value);
}; };
@ -110,14 +128,18 @@
}; };
$scope.setGlobalStatRefreshInterval = function (value) { $scope.setGlobalStatRefreshInterval = function (value) {
setNeedRefreshPage();
ariaNgSettingService.setGlobalStatRefreshInterval(value); ariaNgSettingService.setGlobalStatRefreshInterval(value);
}; };
$scope.setDownloadTaskRefreshInterval = function (value) { $scope.setDownloadTaskRefreshInterval = function (value) {
setNeedRefreshPage();
ariaNgSettingService.setDownloadTaskRefreshInterval(value); ariaNgSettingService.setDownloadTaskRefreshInterval(value);
}; };
$scope.addNewRpcSetting = function () { $scope.addNewRpcSetting = function () {
setNeedRefreshPage();
var newRpcSetting = ariaNgSettingService.addNewRpcSetting(); var newRpcSetting = ariaNgSettingService.addNewRpcSetting();
$scope.context.rpcSettings.push(newRpcSetting); $scope.context.rpcSettings.push(newRpcSetting);
@ -125,6 +147,7 @@
}; };
$scope.updateRpcSetting = function (setting, field) { $scope.updateRpcSetting = function (setting, field) {
setNeedRefreshPage();
ariaNgSettingService.updateRpcSetting(setting, field); ariaNgSettingService.updateRpcSetting(setting, field);
}; };
@ -132,6 +155,8 @@
var rpcName = (setting.rpcAlias ? setting.rpcAlias : setting.rpcHost + ':' + setting.rpcPort); var rpcName = (setting.rpcAlias ? setting.rpcAlias : setting.rpcHost + ':' + setting.rpcPort);
ariaNgCommonService.confirm('Confirm Remove', 'Are you sure you want to remove rpc setting "{{rpcName}}"?', 'warning', function () { ariaNgCommonService.confirm('Confirm Remove', 'Are you sure you want to remove rpc setting "{{rpcName}}"?', 'warning', function () {
setNeedRefreshPage();
var index = $scope.context.rpcSettings.indexOf(setting); var index = $scope.context.rpcSettings.indexOf(setting);
ariaNgSettingService.removeRpcSetting(setting); ariaNgSettingService.removeRpcSetting(setting);
$scope.context.rpcSettings.splice(index, 1); $scope.context.rpcSettings.splice(index, 1);
@ -155,6 +180,10 @@
$window.location.reload(); $window.location.reload();
}; };
$scope.refreshPage = function () {
$window.location.reload();
};
$('[data-toggle="popover"]').popover(); $('[data-toggle="popover"]').popover();
$rootScope.loadPromise = $timeout(function () {}, 100); $rootScope.loadPromise = $timeout(function () {}, 100);

View file

@ -68,7 +68,7 @@
options.type = 'primary'; options.type = 'primary';
} }
Notification[options.type](options); return Notification[options.type](options);
}, },
notifyTaskComplete: function (task) { notifyTaskComplete: function (task) {
this.notifyViaBrowser('Download Completed', (task && task.taskName ? task.taskName : '')); this.notifyViaBrowser('Download Completed', (task && task.taskName ? task.taskName : ''));

View file

@ -209,3 +209,11 @@
</div> </div>
</div> </div>
</section> </section>
<script id="setting-changed-notification.html" type="text/ng-template">
<div class="ui-notification custom-template">
<div class="message" ng-bind-html="message"></div>
<div class="message">
<a class="btn btn-small btn-primary close-notification" ng-click="refreshPage()" translate>Refresh</a>
</div>
</div>
</script>