From 898ba000bb7cec24d257caebc357d5576e8240d2 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Fri, 18 Dec 2015 11:20:17 +0100 Subject: [PATCH] Change notification system. --- accountant/frontend/static/js/accounts.js | 16 ++++++++++++---- accountant/frontend/static/js/app.js | 2 +- accountant/frontend/static/js/operations.js | 17 +++++++++++++---- accountant/frontend/static/js/scheduler.js | 16 ++++++++++++---- accountant/frontend/templates/layout.html | 18 ++++-------------- 5 files changed, 42 insertions(+), 27 deletions(-) diff --git a/accountant/frontend/static/js/accounts.js b/accountant/frontend/static/js/accounts.js index 9bbba98..e0691b9 100644 --- a/accountant/frontend/static/js/accounts.js +++ b/accountant/frontend/static/js/accounts.js @@ -28,8 +28,8 @@ accountantApp .controller( "AccountController", [ - "$scope", "Account", "notificationService", - function($scope, Account, notificationService) { + "$scope", "Account", "notify", + function($scope, Account, notify) { /* * Return the class for an account current value compared to authorized @@ -114,7 +114,11 @@ accountantApp return 0; }); - notificationService.success("Account #" + data.id + " saved."); + notify({ + message: "Account #" + data.id + " saved.", + classes: "alert-success", + position: "right" + }); return data; }); @@ -131,7 +135,11 @@ accountantApp function(result) { if(result) { account.$delete().then(function() { - notificationService.success("Account #" + id + " deleted."); + notify({ + message: "Account #" + id + " deleted.", + classes: "alert-success", + position: "right" + }); // Remove account from array. $scope.accounts.splice($index, 1); diff --git a/accountant/frontend/static/js/app.js b/accountant/frontend/static/js/app.js index 248a478..c921f53 100644 --- a/accountant/frontend/static/js/app.js +++ b/accountant/frontend/static/js/app.js @@ -18,8 +18,8 @@ var accountantApp = angular.module("accountantApp", [ 'ngResource', 'ngRoute', "mgcrea.ngStrap", "highcharts-ng", - "jlareau.pnotify", "http-auth-interceptor", + "cgNotify", "Storage.Service", "xeditable" ]) diff --git a/accountant/frontend/static/js/operations.js b/accountant/frontend/static/js/operations.js index b8eeae5..7c7da8d 100644 --- a/accountant/frontend/static/js/operations.js +++ b/accountant/frontend/static/js/operations.js @@ -318,8 +318,8 @@ accountantApp */ .controller( "OperationController", [ - "$scope", "$rootScope", "$routeParams", "notificationService", "Operation", - function($scope, $rootScope, $routeParams, notificationService, Operation) { + "$scope", "$rootScope", "$routeParams", "notify", "Operation", + function($scope, $rootScope, $routeParams, notify, Operation) { // List of operations. $scope.operations = []; @@ -394,7 +394,12 @@ accountantApp operation.confirmed = true; return operation.$save().then(function(data) { - notificationService.success("Operation #" + data.id + " saved."); + notify({ + message: "Operation #" + data.id + " saved.", + classes: "alert-success", + position: "right" + }); + $scope.$emit("operationSavedEvent", data); }); }; @@ -410,7 +415,11 @@ accountantApp function(result) { if(result) { operation.$delete().then(function() { - notificationService.success("Operation #" + id + " deleted."); + notify({ + message: "Operation #" + id + " deleted.", + classes: "alert-success", + position: "right" + }); // Remove operation from array. $scope.operation.splice($index, 1); diff --git a/accountant/frontend/static/js/scheduler.js b/accountant/frontend/static/js/scheduler.js index cb88820..97d712b 100644 --- a/accountant/frontend/static/js/scheduler.js +++ b/accountant/frontend/static/js/scheduler.js @@ -26,8 +26,8 @@ accountantApp .controller( "SchedulerController", [ - "$scope", "$rootScope", "$routeParams", "notificationService", "ScheduledOperation", - function($scope, $rootScope, $routeParams, notificationService, ScheduledOperation) { + "$scope", "$rootScope", "$routeParams", "notify", "ScheduledOperation", + function($scope, $rootScope, $routeParams, notify, ScheduledOperation) { // Operation store. $scope.operations = []; @@ -66,7 +66,11 @@ accountantApp } return operation.$save().then(function(data) { - notificationService.success("Operation #" + data.id + " saved."); + notify({ + message: "Operation #" + data.id + " saved.", + classes: "alert-success", + position: "right" + }); }); }; @@ -92,7 +96,11 @@ accountantApp function(result) { if(result) { operation.$delete().then(function() { - notificationService.success("Operation #" + id + " deleted."); + notify({ + message: "Operation #" + id + " deleted.", + classes: "alert-success", + position: "right" + }); // Remove account from array. $scope.operations.splice($index, 1); diff --git a/accountant/frontend/templates/layout.html b/accountant/frontend/templates/layout.html index 26a574e..6d6fc99 100644 --- a/accountant/frontend/templates/layout.html +++ b/accountant/frontend/templates/layout.html @@ -52,19 +52,6 @@ - - - - - - - - - - - - - @@ -74,10 +61,13 @@ - + + + +