Migrate to toastr.

This commit is contained in:
Alexis Lahouze 2017-07-22 09:17:50 +02:00
parent 68df4e5ce2
commit 801d2ae380
1 changed files with 21 additions and 13 deletions

View File

@ -1,3 +1,7 @@
import { Logger } from '@nsalaun/ng-logger';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ToastrService } from 'ngx-toastr';
var scheduleFormTmpl = require('./schedule.form.tmpl.html'),
scheduleDeleteTmpl = require('./schedule.delete.tmpl.html');
@ -8,7 +12,7 @@ export class ScheduleController{
constructor(
private $stateParams,
private Notification,
private toastrService: ToastrService,
private ScheduledOperation,
private $modal
) {
@ -42,14 +46,14 @@ export class ScheduleController{
* Save operation.
*/
save = function(operation) {
return operation.$save().then(function(operation) {
this.Notification.success('Scheduled operation #' + operation.id + ' saved.');
return operation.$save().then((operation) => {
this.toastrService.success('Scheduled operation #' + operation.id + ' saved.');
this.operations = this.load();
return operation;
}, function(result){
this.Notification.error(
}, (result) => {
this.toastrService.error(
'Error while saving scheduled operation: ' + result.message
);
});
@ -66,7 +70,7 @@ export class ScheduleController{
controller: function($scope, title, operation, $delete) {
$scope.title = title;
$scope.operation = operation;
$scope.$delete = function() {
$scope.$delete = () => {
$scope.$hide();
$delete($scope.operation);
};
@ -74,7 +78,9 @@ export class ScheduleController{
locals: {
title: title,
operation: operation,
$delete: this.delete
$delete: (operation) => {
this.delete(operation);
}
}
});
};
@ -85,14 +91,14 @@ export class ScheduleController{
delete = function(operation) {
var id = operation.id;
return operation.$delete().then(function() {
this.Notification.success('Scheduled operation #' + id + ' deleted.');
return operation.$delete().then(() => {
this.toastrService.success('Scheduled operation #' + id + ' deleted.');
this.operations = this.load();
return operation;
}, function(result) {
this.Notification.error(
}, (result) => {
this.toastrService.error(
'An error occurred while trying to delete scheduled operation #' +
id + ':<br />' + result
);
@ -116,7 +122,7 @@ export class ScheduleController{
controller: function($scope, title, operation, $save) {
$scope.title = title;
$scope.operation = operation;
$scope.$save = function() {
$scope.$save = () => {
$scope.$hide();
$save($scope.operation);
};
@ -124,7 +130,9 @@ export class ScheduleController{
locals: {
title: title,
operation: operation,
$save: this.save
$save: (operation) => {
this.save(operation);
}
}
});
};