add utility method

This commit is contained in:
MaysWind 2016-06-05 23:23:24 +08:00
parent 5cdee35f2f
commit 5027707dec
3 changed files with 14 additions and 6 deletions

View file

@ -8,7 +8,7 @@
var keys = aria2SettingService.getAvailableGlobalOptionsKeys(type);
if (!keys) {
ariaNgCommonService.alert('Type is illegal!');
ariaNgCommonService.showError('Type is illegal!');
return;
}

View file

@ -45,7 +45,7 @@
}
if (error.message == 'Unauthorized') {
ariaNgCommonService.alert('rpc.error.' + error.message);
ariaNgCommonService.showError('rpc.error.' + error.message);
return;
}
}

View file

@ -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')
};