Feature: add growl for notification

This commit is contained in:
2015-10-01 12:03:47 +00:00
parent d7847bc6b5
commit 2d3d18ba9b
7 changed files with 32 additions and 17 deletions

View File

@@ -4,7 +4,7 @@
var HOST = 'http://cloudbudget-febbweiss.c9.io/api';
angular
.module('cloudbudget', ['ngRoute', 'routes', 'ngCookies', 'xeditable'])
.module('cloudbudget', ['ngRoute', 'ngAnimate', 'routes', 'angular-growl', 'config', 'ngCookies', 'xeditable'])
.constant('apiRoutes', {
'host' : HOST,
'port' : "80",

15
public/js/config.js Normal file
View File

@@ -0,0 +1,15 @@
(function() {
'use strict';
angular
.module('config', [])
.config(config);
config.$inject = ['growlProvider'];
function config(growlProvider) {
growlProvider.globalReversedOrder(true);
growlProvider.globalTimeToLive(5000);
growlProvider.globalDisableCountDown(true);
};
})();

View File

@@ -6,8 +6,9 @@
.config(config);
config.$inject = ['$routeProvider', '$locationProvider'];
function config($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
controller: 'HomeController',

View File

@@ -5,9 +5,9 @@
.module('cloudbudget')
.factory('FlashService', FlashService);
FlashService.$inject = ['$rootScope'];
FlashService.$inject = ['$rootScope', 'growl'];
function FlashService($rootScope) {
function FlashService($rootScope, growl) {
var service = {};
service.success = success;
@@ -35,19 +35,11 @@
}
function success(message, keepAfterLocationChange) {
$rootScope.flash = {
message: message,
type: 'success',
keepAfterLocationChange: keepAfterLocationChange
};
growl.success(message,{title: 'Success!'});
}
function error(message, keepAfterLocationChange) {
$rootScope.flash = {
message: message,
type: 'error',
keepAfterLocationChange: keepAfterLocationChange
};
growl.error(message, {title: 'Error!'});
}
}
})();