From fc54048d5da503a3964865aa425ebdbeee905feb Mon Sep 17 00:00:00 2001 From: MaysWind Date: Wed, 29 Mar 2017 09:06:43 +0800 Subject: [PATCH] show notification after modifying configurations which need to reload page --- src/langs/zh_CN.txt | 2 ++ src/scripts/config/defaultLanguage.js | 2 ++ src/scripts/controllers/settings-ariang.js | 29 +++++++++++++++++++ .../services/ariaNgNotificationService.js | 2 +- src/views/settings-ariang.html | 8 +++++ 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/langs/zh_CN.txt b/src/langs/zh_CN.txt index ad79856..897c045 100644 --- a/src/langs/zh_CN.txt +++ b/src/langs/zh_CN.txt @@ -147,6 +147,8 @@ Downloading Count=正在下载数量 Waiting Count=正在等待数量 Stopped Count=已停止数量 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=显示密钥 Hide Secret=隐藏密钥 Aria2 Version=Aria2 版本 diff --git a/src/scripts/config/defaultLanguage.js b/src/scripts/config/defaultLanguage.js index a5de56a..e9614a5 100644 --- a/src/scripts/config/defaultLanguage.js +++ b/src/scripts/config/defaultLanguage.js @@ -151,6 +151,8 @@ '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.': 'Configuration has been modified, please reload the page for the changes to take effect.', + 'Refresh': 'Refresh', 'Show Secret': 'Show Secret', 'Hide Secret': 'Hide Secret', 'Aria2 Version': 'Aria2 Version', diff --git a/src/scripts/controllers/settings-ariang.js b/src/scripts/controllers/settings-ariang.js index 5126909..956371c 100644 --- a/src/scripts/controllers/settings-ariang.js +++ b/src/scripts/controllers/settings-ariang.js @@ -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) { var extendType = $routeParams.extendType; + var lastRefreshPageNotification = null; var getFinalTitle = function () { 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 = { currentTab: 'global', languages: ariaNgLanguages, @@ -88,6 +105,7 @@ }; $scope.setTitleRefreshInterval = function (value) { + setNeedRefreshPage(); ariaNgSettingService.setTitleRefreshInterval(value); }; @@ -110,14 +128,18 @@ }; $scope.setGlobalStatRefreshInterval = function (value) { + setNeedRefreshPage(); ariaNgSettingService.setGlobalStatRefreshInterval(value); }; $scope.setDownloadTaskRefreshInterval = function (value) { + setNeedRefreshPage(); ariaNgSettingService.setDownloadTaskRefreshInterval(value); }; $scope.addNewRpcSetting = function () { + setNeedRefreshPage(); + var newRpcSetting = ariaNgSettingService.addNewRpcSetting(); $scope.context.rpcSettings.push(newRpcSetting); @@ -125,6 +147,7 @@ }; $scope.updateRpcSetting = function (setting, field) { + setNeedRefreshPage(); ariaNgSettingService.updateRpcSetting(setting, field); }; @@ -132,6 +155,8 @@ 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 () { + setNeedRefreshPage(); + var index = $scope.context.rpcSettings.indexOf(setting); ariaNgSettingService.removeRpcSetting(setting); $scope.context.rpcSettings.splice(index, 1); @@ -155,6 +180,10 @@ $window.location.reload(); }; + $scope.refreshPage = function () { + $window.location.reload(); + }; + $('[data-toggle="popover"]').popover(); $rootScope.loadPromise = $timeout(function () {}, 100); diff --git a/src/scripts/services/ariaNgNotificationService.js b/src/scripts/services/ariaNgNotificationService.js index 318a12b..455e6a3 100644 --- a/src/scripts/services/ariaNgNotificationService.js +++ b/src/scripts/services/ariaNgNotificationService.js @@ -68,7 +68,7 @@ options.type = 'primary'; } - Notification[options.type](options); + return Notification[options.type](options); }, notifyTaskComplete: function (task) { this.notifyViaBrowser('Download Completed', (task && task.taskName ? task.taskName : '')); diff --git a/src/views/settings-ariang.html b/src/views/settings-ariang.html index 23a82fe..91a223e 100644 --- a/src/views/settings-ariang.html +++ b/src/views/settings-ariang.html @@ -209,3 +209,11 @@ +