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(
"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);

View File

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

View File

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

View File

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

View File

@ -52,19 +52,6 @@
<!-- Highstocks -->
<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 -->
<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.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='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='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 -->
<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>