From 5027707dec4e0b6f0980f36d36577361acaf9e45 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 5 Jun 2016 23:23:24 +0800 Subject: [PATCH] add utility method --- app/scripts/controllers/settings-aria2.js | 2 +- app/scripts/services/aria2RpcService.js | 2 +- app/scripts/services/ariaNgCommonService.js | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/scripts/controllers/settings-aria2.js b/app/scripts/controllers/settings-aria2.js index 70400f7..1461d50 100644 --- a/app/scripts/controllers/settings-aria2.js +++ b/app/scripts/controllers/settings-aria2.js @@ -8,7 +8,7 @@ var keys = aria2SettingService.getAvailableGlobalOptionsKeys(type); if (!keys) { - ariaNgCommonService.alert('Type is illegal!'); + ariaNgCommonService.showError('Type is illegal!'); return; } diff --git a/app/scripts/services/aria2RpcService.js b/app/scripts/services/aria2RpcService.js index 929f7ee..5e8bb6f 100644 --- a/app/scripts/services/aria2RpcService.js +++ b/app/scripts/services/aria2RpcService.js @@ -45,7 +45,7 @@ } if (error.message == 'Unauthorized') { - ariaNgCommonService.alert('rpc.error.' + error.message); + ariaNgCommonService.showError('rpc.error.' + error.message); return; } } diff --git a/app/scripts/services/ariaNgCommonService.js b/app/scripts/services/ariaNgCommonService.js index cf94f0a..a80b083 100644 --- a/app/scripts/services/ariaNgCommonService.js +++ b/app/scripts/services/ariaNgCommonService.js @@ -9,22 +9,30 @@ return hashedId; }, - alert: function (text) { + showDialog: function (title, text, type) { $timeout(function () { SweetAlert.swal({ - title: $translate.instant('Error'), + title: $translate.instant(title), text: $translate.instant(text), - type: 'error', + type: type, confirmButtonText: $translate.instant('OK') }); }, 100); }, - confirm: function (title, text, type, callback) { + showError: function (text) { + this.showDialog('Error', text, 'error'); + }, + showOperationSucceeded: function (text) { + this.showDialog('Operation Succeeded', text, 'success'); + }, + confirm: function (title, text, type, callback, notClose) { var options = { title: $translate.instant(title), text: $translate.instant(text), type: type, showCancelButton: true, + showLoaderOnConfirm: !!notClose, + closeOnConfirm: !notClose, confirmButtonText: $translate.instant('OK'), cancelButtonText: $translate.instant('Cancel') };