Explorar o código

merge AriaNg commit(https://github.com/mayswind/AriaNg/commit/ffe6835c588b7ab94c4412a52d9f12902a51f793)

MaysWind %!s(int64=3) %!d(string=hai) anos
pai
achega
af6a1e85bd

+ 6 - 6
app/scripts/controllers/command.js

@@ -1,14 +1,14 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').controller('CommandController', ['$rootScope', '$window', '$location', '$routeParams', 'ariaNgDefaultOptions', 'ariaNgCommonService', 'ariaNgLocalizationService', 'ariaNgLogService', 'ariaNgSettingService', 'aria2TaskService', 'aria2SettingService', function ($rootScope, $window, $location, $routeParams, ariaNgDefaultOptions, ariaNgCommonService, ariaNgLocalizationService, ariaNgLogService, ariaNgSettingService, aria2TaskService, aria2SettingService) {
+    angular.module('ariaNg').controller('CommandController', ['$rootScope', '$window', '$location', '$routeParams', 'ariaNgDefaultOptions', 'ariaNgCommonService', 'ariaNgLogService', 'ariaNgSettingService', 'aria2TaskService', 'aria2SettingService', function ($rootScope, $window, $location, $routeParams, ariaNgDefaultOptions, ariaNgCommonService, ariaNgLogService, ariaNgSettingService, aria2TaskService, aria2SettingService) {
         var path = $location.path();
 
         var doNewTaskCommand = function (url, params) {
             try {
                 url = ariaNgCommonService.base64UrlDecode(url);
             } catch (ex) {
-                ariaNgLocalizationService.showError('URL is not base64 encoded!');
+                ariaNgCommonService.showError('URL is not base64 encoded!');
                 return false;
             }
 
@@ -59,12 +59,12 @@
             ariaNgLogService.info('[CommandController] set rpc: ' + rpcProtocol + '://' + rpcHost + ':' + rpcPort + '/' + rpcInterface + ', secret: ' + secret);
 
             if (!rpcProtocol || (rpcProtocol !== 'http' && rpcProtocol !== 'https' && rpcProtocol !== 'ws' && rpcProtocol !== 'wss')) {
-                ariaNgLocalizationService.showError('Protocol is invalid!');
+                ariaNgCommonService.showError('Protocol is invalid!');
                 return false;
             }
 
             if (!rpcHost) {
-                ariaNgLocalizationService.showError('RPC host cannot be empty!');
+                ariaNgCommonService.showError('RPC host cannot be empty!');
                 return false;
             }
 
@@ -72,7 +72,7 @@
                 try {
                     secret = ariaNgCommonService.base64UrlDecode(secret);
                 } catch (ex) {
-                    ariaNgLocalizationService.showError('RPC secret is not base64 encoded!');
+                    ariaNgCommonService.showError('RPC secret is not base64 encoded!');
                     return false;
                 }
             }
@@ -108,7 +108,7 @@
             } else if (path.indexOf('/settings/rpc/set') === 0) {
                 return doSetRpcCommand(params.protocol, params.host, params.port, params.interface, params.secret);
             } else {
-                ariaNgLocalizationService.showError('Parameter is invalid!');
+                ariaNgCommonService.showError('Parameter is invalid!');
                 return false;
             }
         };

+ 2 - 2
app/scripts/controllers/debug.js

@@ -1,7 +1,7 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').controller('AriaNgDebugController', ['$rootScope', '$scope', '$location', '$timeout', 'ariaNgConstants', 'ariaNgLocalizationService', 'ariaNgLogService', 'ariaNgSettingService', function ($rootScope, $scope, $location, $timeout, ariaNgConstants, ariaNgLocalizationService, ariaNgLogService, ariaNgSettingService) {
+    angular.module('ariaNg').controller('AriaNgDebugController', ['$rootScope', '$scope', '$location', '$timeout', 'ariaNgConstants', 'ariaNgCommonService', 'ariaNgLogService', 'ariaNgSettingService', function ($rootScope, $scope, $location, $timeout, ariaNgConstants, ariaNgCommonService, ariaNgLogService, ariaNgSettingService) {
         $scope.logMaxCount = ariaNgConstants.cachedDebugLogsLimit;
         $scope.currentLog = null;
 
@@ -24,7 +24,7 @@
 
         $rootScope.loadPromise = $timeout(function () {
             if (!ariaNgSettingService.isEnableDebugMode()) {
-                ariaNgLocalizationService.showError('Access Denied!', function () {
+                ariaNgCommonService.showError('Access Denied!', function () {
                     if (!ariaNgSettingService.isEnableDebugMode()) {
                         $location.path('/settings/ariang');
                     }

+ 9 - 9
app/scripts/controllers/main.js

@@ -1,7 +1,7 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').controller('MainController', ['$rootScope', '$scope', '$route', '$window', '$location', '$document', '$interval', 'clipboard', 'aria2RpcErrors', 'ariaNgCommonService', 'ariaNgNotificationService', 'ariaNgLocalizationService', 'ariaNgSettingService', 'ariaNgMonitorService', 'ariaNgTitleService', 'aria2TaskService', 'aria2SettingService', 'ariaNgNativeElectronService', function ($rootScope, $scope, $route, $window, $location, $document, $interval, clipboard, aria2RpcErrors, ariaNgCommonService, ariaNgNotificationService, ariaNgLocalizationService, ariaNgSettingService, ariaNgMonitorService, ariaNgTitleService, aria2TaskService, aria2SettingService, ariaNgNativeElectronService) {
+    angular.module('ariaNg').controller('MainController', ['$rootScope', '$scope', '$route', '$window', '$location', '$document', '$interval', 'clipboard', 'aria2RpcErrors', 'ariaNgCommonService', 'ariaNgNotificationService', 'ariaNgSettingService', 'ariaNgMonitorService', 'ariaNgTitleService', 'aria2TaskService', 'aria2SettingService', 'ariaNgNativeElectronService', function ($rootScope, $scope, $route, $window, $location, $document, $interval, clipboard, aria2RpcErrors, ariaNgCommonService, ariaNgNotificationService, ariaNgSettingService, ariaNgMonitorService, ariaNgTitleService, aria2TaskService, aria2SettingService, ariaNgNativeElectronService) {
         var pageTitleRefreshPromise = null;
         var globalStatRefreshPromise = null;
 
@@ -160,7 +160,7 @@
 
             $rootScope.loadPromise = invoke(gids, function (response) {
                 if (response.hasError && gids.length > 1) {
-                    ariaNgLocalizationService.showError('Failed to change some tasks state.');
+                    ariaNgCommonService.showError('Failed to change some tasks state.');
                 }
 
                 if (!response.hasSuccess) {
@@ -186,10 +186,10 @@
         };
 
         $scope.retryTask = function (task) {
-            ariaNgLocalizationService.confirm('Confirm Retry', 'Are you sure you want to retry the selected task? AriaNg will create same task after clicking OK.', 'info', function () {
+            ariaNgCommonService.confirm('Confirm Retry', 'Are you sure you want to retry the selected task? AriaNg will create same task after clicking OK.', 'info', function () {
                 $rootScope.loadPromise = aria2TaskService.retryTask(task.gid, function (response) {
                     if (!response.success) {
-                        ariaNgLocalizationService.showError('Failed to retry this task.');
+                        ariaNgCommonService.showError('Failed to retry this task.');
                         return;
                     }
 
@@ -258,11 +258,11 @@
                 }
             }
 
-            ariaNgLocalizationService.confirm('Confirm Retry', 'Are you sure you want to retry the selected task? AriaNg will create same task after clicking OK.', 'info', function () {
+            ariaNgCommonService.confirm('Confirm Retry', 'Are you sure you want to retry the selected task? AriaNg will create same task after clicking OK.', 'info', function () {
                 $rootScope.loadPromise = aria2TaskService.retryTasks(retryableTasks, function (response) {
                     refreshGlobalStat(true);
 
-                    ariaNgLocalizationService.showInfo('Operation Result', '{successCount} tasks have been retried and {failedCount} tasks are failed.', function () {
+                    ariaNgCommonService.showInfo('Operation Result', '{successCount} tasks have been retried and {failedCount} tasks are failed.', function () {
                         var actionAfterRetryingTask = ariaNgSettingService.getAfterRetryingTask();
 
                         if (response.hasSuccess) {
@@ -297,7 +297,7 @@
             var removeTasks = function () {
                 $rootScope.loadPromise = aria2TaskService.removeTasks(tasks, function (response) {
                     if (response.hasError && tasks.length > 1) {
-                        ariaNgLocalizationService.showError('Failed to remove some task(s).');
+                        ariaNgCommonService.showError('Failed to remove some task(s).');
                     }
 
                     if (!response.hasSuccess) {
@@ -317,14 +317,14 @@
             };
 
             if (ariaNgSettingService.getConfirmTaskRemoval()) {
-                ariaNgLocalizationService.confirm('Confirm Remove', 'Are you sure you want to remove the selected task?', 'warning', removeTasks);
+                ariaNgCommonService.confirm('Confirm Remove', 'Are you sure you want to remove the selected task?', 'warning', removeTasks);
             } else {
                 removeTasks();
             };
         };
 
         $scope.clearStoppedTasks = function () {
-            ariaNgLocalizationService.confirm('Confirm Clear', 'Are you sure you want to clear stopped tasks?', 'warning', function () {
+            ariaNgCommonService.confirm('Confirm Clear', 'Are you sure you want to clear stopped tasks?', 'warning', function () {
                 $rootScope.loadPromise = aria2TaskService.clearStoppedTasks(function (response) {
                     if (!response.success) {
                         return;

+ 5 - 5
app/scripts/controllers/new.js

@@ -1,7 +1,7 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').controller('NewTaskController', ['$rootScope', '$scope', '$location', '$timeout', 'ariaNgFileTypes', 'ariaNgCommonService', 'ariaNgLocalizationService', 'ariaNgLogService', 'ariaNgFileService', 'ariaNgSettingService', 'aria2TaskService', 'aria2SettingService', 'ariaNgNativeElectronService', function ($rootScope, $scope, $location, $timeout, ariaNgFileTypes, ariaNgCommonService, ariaNgLocalizationService, ariaNgLogService, ariaNgFileService, ariaNgSettingService, aria2TaskService, aria2SettingService, ariaNgNativeElectronService) {
+    angular.module('ariaNg').controller('NewTaskController', ['$rootScope', '$scope', '$location', '$timeout', 'ariaNgFileTypes', 'ariaNgCommonService', 'ariaNgLogService', 'ariaNgFileService', 'ariaNgSettingService', 'aria2TaskService', 'aria2SettingService', 'ariaNgNativeElectronService', function ($rootScope, $scope, $location, $timeout, ariaNgFileTypes, ariaNgCommonService, ariaNgLogService, ariaNgFileService, ariaNgSettingService, aria2TaskService, aria2SettingService, ariaNgNativeElectronService) {
         var tabStatusItems = [
             {
                 name: 'links',
@@ -142,13 +142,13 @@
                     ariaNgLogService.error('[NewTaskController] get file via electron error', result.exception);
 
                     if (result.exception.code === 'ENOENT') {
-                        ariaNgLocalizationService.showError('native.error.file-not-found', null, {
+                        ariaNgCommonService.showError('native.error.file-not-found', null, {
                             textParams: {
                                 filepath: result.exception.path
                             }
                         });
                     } else {
-                        ariaNgLocalizationService.showError(result.exception.code);
+                        ariaNgCommonService.showError(result.exception.code);
                     }
                 }
             });
@@ -663,7 +663,7 @@
                 $scope.context.taskType = 'torrent';
                 $scope.changeTab('links');
             }, function (error) {
-                ariaNgLocalizationService.showError(error);
+                ariaNgCommonService.showError(error);
             }, angular.element('#file-holder'));
         };
 
@@ -680,7 +680,7 @@
                 $scope.context.taskType = 'metalink';
                 $scope.changeTab('options');
             }, function (error) {
-                ariaNgLocalizationService.showError(error);
+                ariaNgCommonService.showError(error);
             }, angular.element('#file-holder'));
         };
 

+ 2 - 2
app/scripts/controllers/settings-aria2.js

@@ -1,7 +1,7 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').controller('Aria2SettingsController', ['$rootScope', '$scope', '$location', 'ariaNgConstants', 'ariaNgLocalizationService', 'aria2SettingService', function ($rootScope, $scope, $location, ariaNgConstants, ariaNgLocalizationService, aria2SettingService) {
+    angular.module('ariaNg').controller('Aria2SettingsController', ['$rootScope', '$scope', '$location', 'ariaNgConstants', 'ariaNgCommonService', 'aria2SettingService', function ($rootScope, $scope, $location, ariaNgConstants, ariaNgCommonService, aria2SettingService) {
         var location = $location.path().substring($location.path().lastIndexOf('/') + 1);
 
         $scope.context = {
@@ -9,7 +9,7 @@
                 var keys = aria2SettingService.getAvailableGlobalOptionsKeys(type);
 
                 if (!keys) {
-                    ariaNgLocalizationService.showError('Type is illegal!');
+                    ariaNgCommonService.showError('Type is illegal!');
                     return;
                 }
 

+ 12 - 12
app/scripts/controllers/settings-ariang.js

@@ -47,7 +47,7 @@
                 return;
             }
 
-            lastRefreshPageNotification = ariaNgLocalizationService.notifyInPage('', 'Configuration has been modified, please reload the page for the changes to take effect.', {
+            lastRefreshPageNotification = ariaNgNotificationService.notifyInPage('', 'Configuration has been modified, please reload the page for the changes to take effect.', {
                 delay: false,
                 type: 'info',
                 templateUrl: 'views/notification-reloadable.html',
@@ -116,21 +116,21 @@
 
                     if (!response || !response.data || !response.data.tag_name) {
                         ariaNgLogService.warn('[AriaNgSettingsController.checkUpdate] data format of latest version is invalid', response);
-                        ariaNgLocalizationService.showError('Failed to get latest version!');
+                        ariaNgCommonService.showError('Failed to get latest version!');
                         return;
                     }
 
                     var latestVersion = response.data.tag_name;
 
                     if (ariaNgVersionService.compareVersion($scope.context.ariaNgNativeVersion, latestVersion) >= 0) {
-                        ariaNgLocalizationService.showInfo('Check Update', 'You have installed the latest version!');
+                        ariaNgCommonService.showInfo('Check Update', 'You have installed the latest version!');
                         $scope.context.isCurrentLatestVersion = true;
                     } else {
                         ariaNgNativeElectronService.openProjectReleaseLink();
                     }
                 }).catch(function onError(response) {
                     ariaNgLogService.error('[AriaNgSettingsController.checkUpdate] failed to get latest version', response);
-                    ariaNgLocalizationService.showError('Failed to get latest version!');
+                    ariaNgCommonService.showError('Failed to get latest version!');
                 });
         };
 
@@ -204,7 +204,7 @@
                 ariaNgNotificationService.requestBrowserPermission(function (result) {
                     if (!result.granted) {
                         $scope.context.settings.browserNotification = false;
-                        ariaNgLocalizationService.showError('You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.');
+                        ariaNgCommonService.showError('You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.');
                     }
                 });
             }
@@ -300,7 +300,7 @@
             }, function (result) {
                 $scope.context.importSettings = result.content;
             }, function (error) {
-                ariaNgLocalizationService.showError(error);
+                ariaNgCommonService.showError(error);
             }, angular.element('#import-file-holder'));
         };
 
@@ -311,18 +311,18 @@
                 settingsObj = JSON.parse(settings);
             } catch (e) {
                 ariaNgLogService.error('[AriaNgSettingsController.importSettings] parse settings json error', e);
-                ariaNgLocalizationService.showError('Invalid settings data format!');
+                ariaNgCommonService.showError('Invalid settings data format!');
                 return;
             }
 
             if (!angular.isObject(settingsObj) || angular.isArray(settingsObj)) {
                 ariaNgLogService.error('[AriaNgSettingsController.importSettings] settings json is not object');
-                ariaNgLocalizationService.showError('Invalid settings data format!');
+                ariaNgCommonService.showError('Invalid settings data format!');
                 return;
             }
 
             if (settingsObj) {
-                ariaNgLocalizationService.confirm('Confirm Import', 'Are you sure you want to import all settings?', 'warning', function () {
+                ariaNgCommonService.confirm('Confirm Import', 'Are you sure you want to import all settings?', 'warning', function () {
                     ariaNgSettingService.importAllOptions(settingsObj);
                     $window.location.reload();
                 });
@@ -364,7 +364,7 @@
         $scope.removeRpcSetting = function (setting) {
             var rpcName = (setting.rpcAlias ? setting.rpcAlias : setting.rpcHost + ':' + setting.rpcPort);
 
-            ariaNgLocalizationService.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 currentIndex = $scope.getCurrentRpcTabIndex();
@@ -396,14 +396,14 @@
         };
 
         $scope.resetSettings = function () {
-            ariaNgLocalizationService.confirm('Confirm Reset', 'Are you sure you want to reset all settings?', 'warning', function () {
+            ariaNgCommonService.confirm('Confirm Reset', 'Are you sure you want to reset all settings?', 'warning', function () {
                 ariaNgSettingService.resetSettings();
                 $window.location.reload();
             });
         };
 
         $scope.clearHistory = function () {
-            ariaNgLocalizationService.confirm('Confirm Clear', 'Are you sure you want to clear all settings history?', 'warning', function () {
+            ariaNgCommonService.confirm('Confirm Clear', 'Are you sure you want to clear all settings history?', 'warning', function () {
                 aria2SettingService.clearSettingsHistorys();
                 $window.location.reload();
             });

+ 4 - 4
app/scripts/controllers/status.js

@@ -1,7 +1,7 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').controller('Aria2StatusController', ['$rootScope', '$scope', '$timeout', 'ariaNgLocalizationService', 'ariaNgSettingService', 'aria2SettingService', function ($rootScope, $scope, $timeout, ariaNgLocalizationService, ariaNgSettingService, aria2SettingService) {
+    angular.module('ariaNg').controller('Aria2StatusController', ['$rootScope', '$scope', '$timeout', 'ariaNgCommonService', 'ariaNgSettingService', 'aria2SettingService', function ($rootScope, $scope, $timeout, ariaNgCommonService, ariaNgSettingService, aria2SettingService) {
         $scope.context = {
             host: ariaNgSettingService.getCurrentRpcUrl(),
             serverStatus: null,
@@ -19,16 +19,16 @@
         $scope.saveSession = function () {
             return aria2SettingService.saveSession(function (response) {
                 if (response.success && response.data === 'OK') {
-                    ariaNgLocalizationService.showOperationSucceeded('Session has been saved successfully.');
+                    ariaNgCommonService.showOperationSucceeded('Session has been saved successfully.');
                 }
             });
         };
 
         $scope.shutdown = function () {
-            ariaNgLocalizationService.confirm('Confirm Shutdown', 'Are you sure you want to shutdown aria2?', 'warning', function (status) {
+            ariaNgCommonService.confirm('Confirm Shutdown', 'Are you sure you want to shutdown aria2?', 'warning', function (status) {
                 return aria2SettingService.shutdown(function (response) {
                     if (response.success && response.data === 'OK') {
-                        ariaNgLocalizationService.showOperationSucceeded('Aria2 has been shutdown successfully.');
+                        ariaNgCommonService.showOperationSucceeded('Aria2 has been shutdown successfully.');
                     }
                 });
             }, true);

+ 9 - 9
app/scripts/core/root.js

@@ -1,7 +1,7 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').run(['$window', '$rootScope', '$location', '$document', '$timeout', 'ariaNgCommonService', 'ariaNgLocalizationService', 'ariaNgLogService', 'ariaNgSettingService', 'aria2TaskService', 'ariaNgNativeElectronService', function ($window, $rootScope, $location, $document, $timeout, ariaNgCommonService, ariaNgLocalizationService, ariaNgLogService, ariaNgSettingService, aria2TaskService, ariaNgNativeElectronService) {
+    angular.module('ariaNg').run(['$window', '$rootScope', '$location', '$document', '$timeout', 'ariaNgCommonService', 'ariaNgNotificationService', 'ariaNgLogService', 'ariaNgSettingService', 'aria2TaskService', 'ariaNgNativeElectronService', function ($window, $rootScope, $location, $document, $timeout, ariaNgCommonService, ariaNgNotificationService, ariaNgLogService, ariaNgSettingService, aria2TaskService, ariaNgNativeElectronService) {
         var autoRefreshAfterPageLoad = false;
 
         var isUrlMatchUrl2 = function (url, url2) {
@@ -77,7 +77,7 @@
                 angular.element('.main-sidebar').addClass('blur');
                 angular.element('.navbar').addClass('blur');
                 angular.element('.content-body').addClass('blur');
-                ariaNgLocalizationService.notifyInPage('', 'You cannot use AriaNg because this browser does not meet the minimum requirements for data storage.', {
+                ariaNgNotificationService.notifyInPage('', 'You cannot use AriaNg because this browser does not meet the minimum requirements for data storage.', {
                     type: 'error',
                     delay: false
                 });
@@ -517,13 +517,13 @@
         });
 
         ariaNgNativeElectronService.onMainProcessShowError(function (event, message) {
-            ariaNgLocalizationService.showError(message);
+            ariaNgCommonService.showError(message);
         });
 
         ariaNgSettingService.setDebugMode(ariaNgNativeElectronService.isDevMode());
 
         ariaNgSettingService.onApplicationCacheUpdated(function () {
-            ariaNgLocalizationService.notifyInPage('', 'Application cache has been updated, please reload the page for the changes to take effect.', {
+            ariaNgNotificationService.notifyInPage('', 'Application cache has been updated, please reload the page for the changes to take effect.', {
                 delay: false,
                 type: 'info',
                 templateUrl: 'views/notification-reloadable.html'
@@ -531,7 +531,7 @@
         });
 
         ariaNgSettingService.onFirstAccess(function () {
-            ariaNgLocalizationService.notifyInPage('', 'Tap to configure and get started with AriaNg.', {
+            ariaNgNotificationService.notifyInPage('', 'Tap to configure and get started with AriaNg.', {
                 delay: false,
                 onClose: function () {
                     $location.path('/settings/ariang');
@@ -540,7 +540,7 @@
         });
 
         aria2TaskService.onFirstSuccess(function (event) {
-            ariaNgLocalizationService.notifyInPage('', 'is connected', {
+            ariaNgNotificationService.notifyInPage('', 'is connected', {
                 type: 'success',
                 contentPrefix: event.rpcName + ' '
             });
@@ -579,15 +579,15 @@
         });
 
         aria2TaskService.onTaskCompleted(function (event) {
-            ariaNgLocalizationService.notifyTaskComplete(event.task);
+            ariaNgNotificationService.notifyTaskComplete(event.task);
         });
 
         aria2TaskService.onBtTaskCompleted(function (event) {
-            ariaNgLocalizationService.notifyBtTaskComplete(event.task);
+            ariaNgNotificationService.notifyBtTaskComplete(event.task);
         });
 
         aria2TaskService.onTaskErrorOccur(function (event) {
-            ariaNgLocalizationService.notifyTaskError(event.task);
+            ariaNgNotificationService.notifyTaskError(event.task);
         });
 
         $rootScope.$on('$locationChangeStart', function (event) {

+ 2 - 2
app/scripts/directives/settingDialog.js

@@ -1,7 +1,7 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').directive('ngSettingDialog', ['ariaNgLocalizationService', 'aria2SettingService', function (ariaNgLocalizationService, aria2SettingService) {
+    angular.module('ariaNg').directive('ngSettingDialog', ['ariaNgCommonService', 'aria2SettingService', function (ariaNgCommonService, aria2SettingService) {
         return {
             restrict: 'E',
             templateUrl: 'views/setting-dialog.html',
@@ -30,7 +30,7 @@
                     var keys = aria2SettingService.getAria2QuickSettingsAvailableOptions(type);
 
                     if (!keys) {
-                        ariaNgLocalizationService.showError('Type is illegal!');
+                        ariaNgCommonService.showError('Type is illegal!');
                         return;
                     }
 

+ 3 - 3
app/scripts/services/aria2RpcService.js

@@ -1,7 +1,7 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').factory('aria2RpcService', ['$q', 'aria2RpcConstants', 'aria2RpcErrors', 'aria2AllOptions', 'ariaNgCommonService', 'ariaNgLocalizationService', 'ariaNgLogService', 'ariaNgSettingService', 'aria2HttpRpcService', 'aria2WebSocketRpcService', function ($q, aria2RpcConstants, aria2RpcErrors, aria2AllOptions, ariaNgCommonService, ariaNgLocalizationService, ariaNgLogService, ariaNgSettingService, aria2HttpRpcService, aria2WebSocketRpcService) {
+    angular.module('ariaNg').factory('aria2RpcService', ['$q', 'aria2RpcConstants', 'aria2RpcErrors', 'aria2AllOptions', 'ariaNgCommonService', 'ariaNgLogService', 'ariaNgSettingService', 'aria2HttpRpcService', 'aria2WebSocketRpcService', function ($q, aria2RpcConstants, aria2RpcErrors, aria2AllOptions, ariaNgCommonService, ariaNgLogService, ariaNgSettingService, aria2HttpRpcService, aria2WebSocketRpcService) {
         var rpcImplementService = ariaNgSettingService.isCurrentRpcUseWebSocket() ? aria2WebSocketRpcService : aria2HttpRpcService;
         var isConnected = false;
         var secret = ariaNgSettingService.getCurrentRpcSecret();
@@ -123,10 +123,10 @@
             ariaNgLogService.error('[aria2RpcService.processError] ' + error.message, error);
 
             if (aria2RpcErrors[error.message] && aria2RpcErrors[error.message].tipTextKey) {
-                ariaNgLocalizationService.showError(aria2RpcErrors[error.message].tipTextKey);
+                ariaNgCommonService.showError(aria2RpcErrors[error.message].tipTextKey);
                 return true;
             } else {
-                ariaNgLocalizationService.showError(error.message);
+                ariaNgCommonService.showError(error.message);
                 return true;
             }
         };

+ 80 - 34
app/scripts/services/ariaNgCommonService.js

@@ -1,7 +1,49 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').factory('ariaNgCommonService', ['$location', '$timeout', 'base64', 'moment', 'SweetAlert', 'ariaNgConstants', function ($location, $timeout, base64, moment, SweetAlert, ariaNgConstants) {
+    angular.module('ariaNg').factory('ariaNgCommonService', ['$location', '$timeout', 'base64', 'moment', 'SweetAlert', 'ariaNgConstants', 'ariaNgLocalizationService', function ($location, $timeout, base64, moment, SweetAlert, ariaNgConstants, ariaNgLocalizationService) {
+        var showDialog = function (title, text, type, callback, options) {
+            $timeout(function () {
+                SweetAlert.swal({
+                    title: title,
+                    text: text,
+                    type: type,
+                    confirmButtonText: options && options.confirmButtonText || null
+                }, function () {
+                    if (callback) {
+                        callback();
+                    }
+                });
+            }, 100);
+        };
+
+        var showConfirmDialog = function (title, text, type, callback, notClose, extendSettings) {
+            var options = {
+                title: title,
+                text: text,
+                type: type,
+                showCancelButton: true,
+                showLoaderOnConfirm: !!notClose,
+                closeOnConfirm: !notClose,
+                confirmButtonText: extendSettings && extendSettings.confirmButtonText || null,
+                cancelButtonText: extendSettings && extendSettings.cancelButtonText || null
+            };
+
+            if (type === 'warning') {
+                options.confirmButtonColor = '#F39C12';
+            }
+
+            SweetAlert.swal(options, function (isConfirm) {
+                if (!isConfirm) {
+                    return;
+                }
+
+                if (callback) {
+                    callback();
+                }
+            });
+        }
+
         return {
             base64Encode: function (value) {
                 return base64.encode(value);
@@ -18,45 +60,49 @@
 
                 return hashedId;
             },
-            showDialog: function (title, text, type, callback, options) {
-                $timeout(function () {
-                    SweetAlert.swal({
-                        title: title,
-                        text: text,
-                        type: type,
-                        confirmButtonText: options && options.confirmButtonText || null
-                    }, function () {
-                        if (callback) {
-                            callback();
-                        }
-                    });
-                }, 100);
+            showDialog: function (title, text, type, callback, extendSettings) {
+                if (!extendSettings) {
+                    extendSettings = {};
+                }
+
+                if (title) {
+                    title = ariaNgLocalizationService.getLocalizedText(title);
+                }
+
+                if (text) {
+                    text = ariaNgLocalizationService.getLocalizedText(text, extendSettings.textParams);
+                }
+
+                extendSettings.confirmButtonText = ariaNgLocalizationService.getLocalizedText('OK');
+
+                showDialog(title, text, type, callback, extendSettings);
+            },
+            showInfo: function (title, text, callback, extendSettings) {
+                this.showDialog(title, text, 'info', callback, extendSettings);
+            },
+            showError: function (text, callback, extendSettings) {
+                this.showDialog('Error', text, 'error', callback, extendSettings);
+            },
+            showOperationSucceeded: function (text, callback) {
+                this.showDialog('Operation Succeeded', text, 'success', callback);
             },
             confirm: function (title, text, type, callback, notClose, extendSettings) {
-                var options = {
-                    title: title,
-                    text: text,
-                    type: type,
-                    showCancelButton: true,
-                    showLoaderOnConfirm: !!notClose,
-                    closeOnConfirm: !notClose,
-                    confirmButtonText: extendSettings && extendSettings.confirmButtonText || null,
-                    cancelButtonText: extendSettings && extendSettings.cancelButtonText || null
-                };
+                if (!extendSettings) {
+                    extendSettings = {};
+                }
 
-                if (type === 'warning') {
-                    options.confirmButtonColor = '#F39C12';
+                if (title) {
+                    title = ariaNgLocalizationService.getLocalizedText(title);
                 }
 
-                SweetAlert.swal(options, function (isConfirm) {
-                    if (!isConfirm) {
-                        return;
-                    }
+                if (text) {
+                    text = ariaNgLocalizationService.getLocalizedText(text, extendSettings.textParams);
+                }
 
-                    if (callback) {
-                        callback();
-                    }
-                });
+                extendSettings.confirmButtonText = ariaNgLocalizationService.getLocalizedText('OK');
+                extendSettings.cancelButtonText = ariaNgLocalizationService.getLocalizedText('Cancel');
+
+                showConfirmDialog(title, text, type, callback, notClose, extendSettings);
             },
             closeAllDialogs: function () {
                 SweetAlert.close();

+ 2 - 2
app/scripts/services/ariaNgLanguageLoader.js

@@ -1,7 +1,7 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').factory('ariaNgLanguageLoader', ['$http', '$q', 'ariaNgConstants', 'ariaNgLanguages', 'ariaNgAssetsCacheService', 'ariaNgNotificationService', 'ariaNgLocalizationService', 'ariaNgLogService', 'ariaNgStorageService', 'ariaNgNativeElectronService', function ($http, $q, ariaNgConstants, ariaNgLanguages, ariaNgAssetsCacheService, ariaNgNotificationService, ariaNgLocalizationService, ariaNgLogService, ariaNgStorageService, ariaNgNativeElectronService) {
+    angular.module('ariaNg').factory('ariaNgLanguageLoader', ['$http', '$q', 'ariaNgConstants', 'ariaNgLanguages', 'ariaNgAssetsCacheService', 'ariaNgNotificationService', 'ariaNgLogService', 'ariaNgStorageService', 'ariaNgNativeElectronService', function ($http, $q, ariaNgConstants, ariaNgLanguages, ariaNgAssetsCacheService, ariaNgNotificationService, ariaNgLogService, ariaNgStorageService, ariaNgNativeElectronService) {
         var getKeyValuePair = function (line) {
             for (var i = 0; i < line.length; i++) {
                 if (i > 0 && line.charAt(i - 1) !== '\\' && line.charAt(i) === '=') {
@@ -156,7 +156,7 @@
 
                 if (languageUpdated) {
                     ariaNgLogService.info('[ariaNgLanguageLoader] load language resource successfully, and resource is updated');
-                    ariaNgLocalizationService.notifyInPage('', 'Language resource has been updated, please reload the page for the changes to take effect.', {
+                    ariaNgNotificationService.notifyInPage('', 'Language resource has been updated, please reload the page for the changes to take effect.', {
                         delay: false,
                         type: 'info',
                         templateUrl: 'views/notification-reloadable.html'

+ 1 - 84
app/scripts/services/ariaNgLocalizationService.js

@@ -1,7 +1,7 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').factory('ariaNgLocalizationService', ['$translate', 'amMoment', 'ariaNgCommonService', 'ariaNgNotificationService', function ($translate, amMoment, ariaNgCommonService, ariaNgNotificationService) {
+    angular.module('ariaNg').factory('ariaNgLocalizationService', ['$translate', 'amMoment', function ($translate, amMoment) {
         return {
             applyLanguage: function (lang) {
                 $translate.use(lang);
@@ -14,89 +14,6 @@
             },
             getLongDateFormat: function () {
                 return this.getLocalizedText('format.longdate');
-            },
-            showDialog: function (title, text, type, callback, extendSettings) {
-                if (!extendSettings) {
-                    extendSettings = {};
-                }
-
-                if (title) {
-                    title = this.getLocalizedText(title);
-                }
-
-                if (text) {
-                    text = this.getLocalizedText(text, extendSettings.textParams);
-                }
-
-                extendSettings.confirmButtonText = this.getLocalizedText('OK');
-
-                ariaNgCommonService.showDialog(title, text, type, callback, extendSettings);
-            },
-            showInfo: function (title, text, callback, extendSettings) {
-                this.showDialog(title, text, 'info', callback, extendSettings);
-            },
-            showError: function (text, callback, extendSettings) {
-                this.showDialog('Error', text, 'error', callback, extendSettings);
-            },
-            showOperationSucceeded: function (text, callback) {
-                this.showDialog('Operation Succeeded', text, 'success', callback);
-            },
-            confirm: function (title, text, type, callback, notClose, extendSettings) {
-                if (!extendSettings) {
-                    extendSettings = {};
-                }
-
-                if (title) {
-                    title = this.getLocalizedText(title);
-                }
-
-                if (text) {
-                    text = this.getLocalizedText(text, extendSettings.textParams);
-                }
-
-                extendSettings.confirmButtonText = this.getLocalizedText('OK');
-                extendSettings.cancelButtonText = this.getLocalizedText('Cancel');
-
-                ariaNgCommonService.confirm(title, text, type, callback, notClose, extendSettings);
-            },
-            notifyViaBrowser: function (title, content, options) {
-                if (title) {
-                    title = this.getLocalizedText(title);
-                }
-
-                if (content) {
-                    content = this.getLocalizedText(content);
-                }
-
-                return ariaNgNotificationService.notifyViaBrowser(title, content, options);
-            },
-            notifyInPage: function (title, content, options) {
-                if (!options) {
-                    options = {};
-                }
-
-                if (title) {
-                    title = this.getLocalizedText(title, options.titleParams);
-                }
-
-                if (content) {
-                    content = this.getLocalizedText(content, options.contentParams);
-
-                    if (options.contentPrefix) {
-                        content = options.contentPrefix + content;
-                    }
-                }
-
-                return ariaNgNotificationService.notifyInPage(title, content, options);
-            },
-            notifyTaskComplete: function (task) {
-                this.notifyViaBrowser('Download Completed', (task && task.taskName ? task.taskName : ''));
-            },
-            notifyBtTaskComplete: function (task) {
-                this.notifyViaBrowser('BT Download Completed', (task && task.taskName ? task.taskName : ''));
-            },
-            notifyTaskError: function (task) {
-                this.notifyViaBrowser('Download Error', (task && task.taskName ? task.taskName : ''));
             }
         };
     }]);

+ 59 - 18
app/scripts/services/ariaNgNotificationService.js

@@ -1,7 +1,7 @@
 (function () {
     'use strict';
 
-    angular.module('ariaNg').factory('ariaNgNotificationService', ['$window', 'Notification', 'ariaNgSettingService', function ($window, Notification, ariaNgSettingService) {
+    angular.module('ariaNg').factory('ariaNgNotificationService', ['$window', 'Notification', 'ariaNgLocalizationService', 'ariaNgSettingService', function ($window, Notification, ariaNgLocalizationService, ariaNgSettingService) {
         var isSupportBrowserNotification = !!$window.Notification;
 
         var isBrowserNotifactionGranted = function (permission) {
@@ -47,6 +47,41 @@
             new $window.Notification(title, options);
         };
 
+        var notifyViaBrowser = function (title, content, options) {
+            if (!options) {
+                options = {};
+            }
+
+            options.body = content;
+
+            if (isSupportBrowserNotification && ariaNgSettingService.getBrowserNotification()) {
+                showBrowserNotifaction(title, options);
+            }
+        };
+
+        var notifyInPage = function (title, content, options) {
+            if (!options) {
+                options = {};
+            }
+
+            if (!content) {
+                options.message = title;
+            } else {
+                options.title = title;
+                options.message = content;
+            }
+
+            if (!options.type || !Notification[options.type]) {
+                options.type = 'primary';
+            }
+
+            if (!options.positionY) {
+                options.positionY = 'bottom';
+            }
+
+            return Notification[options.type](options);
+        };
+
         return {
             isSupportBrowserNotification: function () {
                 return isSupportBrowserNotification;
@@ -74,37 +109,43 @@
                 });
             },
             notifyViaBrowser: function (title, content, options) {
-                if (!options) {
-                    options = {};
+                if (title) {
+                    title = ariaNgLocalizationService.getLocalizedText(title);
                 }
 
-                options.body = content;
-
-                if (isSupportBrowserNotification && ariaNgSettingService.getBrowserNotification()) {
-                    showBrowserNotifaction(title, options);
+                if (content) {
+                    content = ariaNgLocalizationService.getLocalizedText(content);
                 }
+
+                return notifyViaBrowser(title, content, options);
+            },
+            notifyTaskComplete: function (task) {
+                this.notifyViaBrowser('Download Completed', (task && task.taskName ? task.taskName : ''));
+            },
+            notifyBtTaskComplete: function (task) {
+                this.notifyViaBrowser('BT Download Completed', (task && task.taskName ? task.taskName : ''));
+            },
+            notifyTaskError: function (task) {
+                this.notifyViaBrowser('Download Error', (task && task.taskName ? task.taskName : ''));
             },
             notifyInPage: function (title, content, options) {
                 if (!options) {
                     options = {};
                 }
 
-                if (!content) {
-                    options.message = title;
-                } else {
-                    options.title = title;
-                    options.message = content;
+                if (title) {
+                    title = ariaNgLocalizationService.getLocalizedText(title, options.titleParams);
                 }
 
-                if (!options.type || !Notification[options.type]) {
-                    options.type = 'primary';
-                }
+                if (content) {
+                    content = ariaNgLocalizationService.getLocalizedText(content, options.contentParams);
 
-                if (!options.positionY) {
-                    options.positionY = 'bottom';
+                    if (options.contentPrefix) {
+                        content = options.contentPrefix + content;
+                    }
                 }
 
-                return Notification[options.type](options);
+                return notifyInPage(title, content, options);
             },
             clearNotificationInPage: function () {
                 Notification.clearAll();