Change notification system.

This commit is contained in:
Alexis Lahouze 2015-12-18 11:20:17 +01:00
parent 8bcabee6dd
commit 898ba000bb
5 changed files with 42 additions and 27 deletions

View File

@ -28,8 +28,8 @@ accountantApp
.controller( .controller(
"AccountController", [ "AccountController", [
"$scope", "Account", "notificationService", "$scope", "Account", "notify",
function($scope, Account, notificationService) { function($scope, Account, notify) {
/* /*
* Return the class for an account current value compared to authorized * Return the class for an account current value compared to authorized
@ -114,7 +114,11 @@ accountantApp
return 0; return 0;
}); });
notificationService.success("Account #" + data.id + " saved."); notify({
message: "Account #" + data.id + " saved.",
classes: "alert-success",
position: "right"
});
return data; return data;
}); });
@ -131,7 +135,11 @@ accountantApp
function(result) { function(result) {
if(result) { if(result) {
account.$delete().then(function() { account.$delete().then(function() {
notificationService.success("Account #" + id + " deleted."); notify({
message: "Account #" + id + " deleted.",
classes: "alert-success",
position: "right"
});
// Remove account from array. // Remove account from array.
$scope.accounts.splice($index, 1); $scope.accounts.splice($index, 1);

View File

@ -18,8 +18,8 @@ var accountantApp = angular.module("accountantApp", [
'ngResource', 'ngRoute', 'ngResource', 'ngRoute',
"mgcrea.ngStrap", "mgcrea.ngStrap",
"highcharts-ng", "highcharts-ng",
"jlareau.pnotify",
"http-auth-interceptor", "http-auth-interceptor",
"cgNotify",
"Storage.Service", "Storage.Service",
"xeditable" "xeditable"
]) ])

View File

@ -318,8 +318,8 @@ accountantApp
*/ */
.controller( .controller(
"OperationController", [ "OperationController", [
"$scope", "$rootScope", "$routeParams", "notificationService", "Operation", "$scope", "$rootScope", "$routeParams", "notify", "Operation",
function($scope, $rootScope, $routeParams, notificationService, Operation) { function($scope, $rootScope, $routeParams, notify, Operation) {
// List of operations. // List of operations.
$scope.operations = []; $scope.operations = [];
@ -394,7 +394,12 @@ accountantApp
operation.confirmed = true; operation.confirmed = true;
return operation.$save().then(function(data) { 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); $scope.$emit("operationSavedEvent", data);
}); });
}; };
@ -410,7 +415,11 @@ accountantApp
function(result) { function(result) {
if(result) { if(result) {
operation.$delete().then(function() { operation.$delete().then(function() {
notificationService.success("Operation #" + id + " deleted."); notify({
message: "Operation #" + id + " deleted.",
classes: "alert-success",
position: "right"
});
// Remove operation from array. // Remove operation from array.
$scope.operation.splice($index, 1); $scope.operation.splice($index, 1);

View File

@ -26,8 +26,8 @@ accountantApp
.controller( .controller(
"SchedulerController", [ "SchedulerController", [
"$scope", "$rootScope", "$routeParams", "notificationService", "ScheduledOperation", "$scope", "$rootScope", "$routeParams", "notify", "ScheduledOperation",
function($scope, $rootScope, $routeParams, notificationService, ScheduledOperation) { function($scope, $rootScope, $routeParams, notify, ScheduledOperation) {
// Operation store. // Operation store.
$scope.operations = []; $scope.operations = [];
@ -66,7 +66,11 @@ accountantApp
} }
return operation.$save().then(function(data) { 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) { function(result) {
if(result) { if(result) {
operation.$delete().then(function() { operation.$delete().then(function() {
notificationService.success("Operation #" + id + " deleted."); notify({
message: "Operation #" + id + " deleted.",
classes: "alert-success",
position: "right"
});
// Remove account from array. // Remove account from array.
$scope.operations.splice($index, 1); $scope.operations.splice($index, 1);

View File

@ -52,19 +52,6 @@
<!-- Highstocks --> <!-- Highstocks -->
<script type="text/javascript" src="{{ url_for('bower.static', filename='highstock-release/highstock.js') }}"></script> <script type="text/javascript" src="{{ url_for('bower.static', filename='highstock-release/highstock.js') }}"></script>
<!-- Pines Notify -->
<link href="{{ url_for('bower.static', filename='pines-notify/pnotify.core.css') }}" rel="stylesheet">
<link href="{{ url_for('bower.static', filename='pines-notify/pnotify.buttons.css') }}" rel="stylesheet">
<link href="{{ url_for('bower.static', filename='pines-notify/pnotify.history.css') }}" rel="stylesheet">
<link href="{{ url_for('bower.static', filename='pines-notify/pnotify.picon.css') }}" rel="stylesheet">
<script type="text/javascript" src="{{ url_for('bower.static', filename='pines-notify/pnotify.core.js') }}"></script>
<script type="text/javascript" src="{{ url_for('bower.static', filename='pines-notify/pnotify.buttons.js') }}"></script>
<script type="text/javascript" src="{{ url_for('bower.static', filename='pines-notify/pnotify.callbacks.js') }}"></script>
<script type="text/javascript" src="{{ url_for('bower.static', filename='pines-notify/pnotify.confirm.js') }}"></script>
<script type="text/javascript" src="{{ url_for('bower.static', filename='pines-notify/pnotify.desktop.js') }}"></script>
<script type="text/javascript" src="{{ url_for('bower.static', filename='pines-notify/pnotify.history.js') }}"></script>
<script type="text/javascript" src="{{ url_for('bower.static', filename='pines-notify/pnotify.nonblock.js') }}"></script>
<!-- AngularJS core --> <!-- AngularJS core -->
<script type="text/javascript" src="{{ url_for('bower.static', filename='angular/angular.js') }}"></script> <script type="text/javascript" src="{{ url_for('bower.static', filename='angular/angular.js') }}"></script>
@ -74,10 +61,13 @@
<script type="text/javascript" src="{{ url_for('bower.static', filename='angular-strap/dist/angular-strap.js') }}"></script> <script type="text/javascript" src="{{ url_for('bower.static', filename='angular-strap/dist/angular-strap.js') }}"></script>
<script type="text/javascript" src="{{ url_for('bower.static', filename='angular-strap/dist/angular-strap.tpl.js') }}"></script> <script type="text/javascript" src="{{ url_for('bower.static', filename='angular-strap/dist/angular-strap.tpl.js') }}"></script>
<script type="text/javascript" src="{{ url_for('bower.static', filename='highcharts-ng/dist/highcharts-ng.js') }}"></script> <script type="text/javascript" src="{{ url_for('bower.static', filename='highcharts-ng/dist/highcharts-ng.js') }}"></script>
<script type="text/javascript" src="{{ url_for('bower.static', filename='angular-pnotify/src/angular-pnotify.js') }}"></script>
<script type="text/javascript" src="{{ url_for('bower.static', filename='angular-http-auth/src/http-auth-interceptor.js') }}"></script> <script type="text/javascript" src="{{ url_for('bower.static', filename='angular-http-auth/src/http-auth-interceptor.js') }}"></script>
<script type="text/javascript" src="{{ url_for('bower.static', filename='meanie-angular-storage/release/meanie-angular-storage.js') }}"></script> <script type="text/javascript" src="{{ url_for('bower.static', filename='meanie-angular-storage/release/meanie-angular-storage.js') }}"></script>
<!-- Angular Notify -->
<link href="{{ url_for('bower.static', filename='angular-notify/dist/angular-notify.css') }}" rel="stylesheet">
<script type="text/javascript" src="{{ url_for('bower.static', filename='angular-notify/dist/angular-notify.js') }}"></script>
<!-- xeditable --> <!-- xeditable -->
<link href="{{ url_for('bower.static', filename='angular-xeditable/dist/css/xeditable.css') }}" rel="stylesheet"> <link href="{{ url_for('bower.static', filename='angular-xeditable/dist/css/xeditable.css') }}" rel="stylesheet">
<script type="text/javascript" src="{{ url_for('bower.static', filename='angular-xeditable/dist/js/xeditable.js') }}"></script> <script type="text/javascript" src="{{ url_for('bower.static', filename='angular-xeditable/dist/js/xeditable.js') }}"></script>