From 2d3d18ba9bd911587c664c92ffde5cf343efc405 Mon Sep 17 00:00:00 2001 From: febbweiss Date: Thu, 1 Oct 2015 12:03:47 +0000 Subject: [PATCH] Feature: add growl for notification --- bower.json | 4 +++- karma.conf.js | 2 ++ public/index.html | 7 +++++-- public/js/app.js | 2 +- public/js/config.js | 15 +++++++++++++++ public/js/routes.js | 3 ++- public/js/services/flash.service.js | 16 ++++------------ 7 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 public/js/config.js diff --git a/bower.json b/bower.json index 1d55bb6..e012065 100644 --- a/bower.json +++ b/bower.json @@ -8,7 +8,9 @@ "animate.css": "~3.3.0", "bootstrap": "~3.3.5", "font-awesome": "~4.4.0", - "angular-xeditable": "~0.1.9" + "angular-xeditable": "~0.1.9", + "angular-growl-v2": "~0.7.5", + "angular-animate": "~1.4.7" }, "devDependencies": { "angular-mocks": "~1.4.4" diff --git a/karma.conf.js b/karma.conf.js index 02d8fa5..859ba7f 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -19,6 +19,8 @@ module.exports = function(config) { 'public/libs/angular-route/angular-route.js', 'public/libs/angular-cookies/angular-cookies.js', 'public/libs/angular-xeditable/dist/js/xeditable.min.js', + 'public/libs/angular-growl-v2/build/angular-growl.min.js', + 'public/libs/angular-animate/angular-animate.min.js', 'public/libs/angular-mocks/angular-mocks.js', 'public/js/**/*.js', 'public/**/*.controller.js', diff --git a/public/index.html b/public/index.html index c1cb949..b503289 100644 --- a/public/index.html +++ b/public/index.html @@ -8,6 +8,7 @@ +
@@ -21,8 +22,7 @@
- -
+
@@ -38,9 +38,12 @@ + + + diff --git a/public/js/app.js b/public/js/app.js index 3e966ec..80325c3 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -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", diff --git a/public/js/config.js b/public/js/config.js new file mode 100644 index 0000000..79b91eb --- /dev/null +++ b/public/js/config.js @@ -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); + }; +})(); \ No newline at end of file diff --git a/public/js/routes.js b/public/js/routes.js index aff061f..8c267a0 100644 --- a/public/js/routes.js +++ b/public/js/routes.js @@ -6,8 +6,9 @@ .config(config); config.$inject = ['$routeProvider', '$locationProvider']; - + function config($routeProvider, $locationProvider) { + $routeProvider .when('/', { controller: 'HomeController', diff --git a/public/js/services/flash.service.js b/public/js/services/flash.service.js index 8374a5a..8cc5d9c 100644 --- a/public/js/services/flash.service.js +++ b/public/js/services/flash.service.js @@ -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!'}); } } })(); \ No newline at end of file