diff --git a/bower.json b/bower.json
index 9738f46d4c..ecfe2fc439 100644
--- a/bower.json
+++ b/bower.json
@@ -10,6 +10,7 @@
"angular-messages": "~1.5.0",
"angular-mocks": "~1.5.0",
"angular-resource": "~1.5.0",
+ "angular-ui-notification": "~0.2.0",
"angular-ui-router": "~0.2.18",
"bootstrap": "~3.3.6",
"ng-file-upload": "^12.1.0",
diff --git a/config/assets/default.js b/config/assets/default.js
index a2ea678f13..ff8cb81f4a 100644
--- a/config/assets/default.js
+++ b/config/assets/default.js
@@ -9,7 +9,8 @@ module.exports = {
// bower:css
'public/lib/bootstrap/dist/css/bootstrap.css',
'public/lib/bootstrap/dist/css/bootstrap-theme.css',
- 'public/lib/ng-img-crop/compile/unminified/ng-img-crop.css'
+ 'public/lib/ng-img-crop/compile/unminified/ng-img-crop.css',
+ 'public/lib/angular-ui-notification/dist/angular-ui-notification.css'
// endbower
],
js: [
@@ -22,6 +23,7 @@ module.exports = {
'public/lib/angular-messages/angular-messages.js',
'public/lib/angular-mocks/angular-mocks.js',
'public/lib/angular-resource/angular-resource.js',
+ 'public/lib/angular-ui-notification/dist/angular-ui-notification.js',
'public/lib/angular-ui-router/release/angular-ui-router.js',
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js',
// endbower
diff --git a/config/assets/production.js b/config/assets/production.js
index 7ad2b2f1b4..ed52e98e5d 100644
--- a/config/assets/production.js
+++ b/config/assets/production.js
@@ -10,6 +10,7 @@ module.exports = {
'public/lib/bootstrap/dist/css/bootstrap.min.css',
'public/lib/bootstrap/dist/css/bootstrap-theme.min.css',
'public/lib/ng-img-crop/compile/minified/ng-img-crop.css',
+ 'public/lib/angular-ui-notification/dist/angular-ui-notification.min.css'
// endbower
],
js: [
@@ -20,6 +21,7 @@ module.exports = {
'public/lib/angular-messages/angular-messages.min.js',
'public/lib/angular-mocks/angular-mocks.js',
'public/lib/angular-resource/angular-resource.min.js',
+ 'public/lib/angular-ui-notification/dist/angular-ui-notification.min.js',
'public/lib/angular-ui-router/release/angular-ui-router.min.js',
'public/lib/ng-file-upload/ng-file-upload.min.js',
'public/lib/ng-img-crop/compile/minified/ng-img-crop.js',
diff --git a/modules/articles/client/controllers/admin/article.client.controller.js b/modules/articles/client/controllers/admin/article.client.controller.js
index 219390dfd3..97f730d3de 100644
--- a/modules/articles/client/controllers/admin/article.client.controller.js
+++ b/modules/articles/client/controllers/admin/article.client.controller.js
@@ -5,14 +5,13 @@
.module('articles.admin')
.controller('ArticlesAdminController', ArticlesAdminController);
- ArticlesAdminController.$inject = ['$scope', '$state', '$window', 'articleResolve', 'Authentication'];
+ ArticlesAdminController.$inject = ['$scope', '$state', '$window', 'articleResolve', 'Authentication', 'Notification'];
- function ArticlesAdminController($scope, $state, $window, article, Authentication) {
+ function ArticlesAdminController($scope, $state, $window, article, Authentication, Notification) {
var vm = this;
vm.article = article;
vm.authentication = Authentication;
- vm.error = null;
vm.form = {};
vm.remove = remove;
vm.save = save;
@@ -22,6 +21,7 @@
if ($window.confirm('Are you sure you want to delete?')) {
vm.article.$remove(function() {
$state.go('admin.articles.list');
+ Notification.success({ message: ' Article deleted successfully!' });
});
}
}
@@ -40,10 +40,11 @@
function successCallback(res) {
$state.go('admin.articles.list'); // should we send the User to the list or the updated Article's view?
+ Notification.success({ message: ' Article saved successfully!' });
}
function errorCallback(res) {
- vm.error = res.data.message;
+ Notification.error({ message: res.data.message, title: ' Article save error!' });
}
}
}
diff --git a/modules/articles/client/controllers/articles.client.controller.js b/modules/articles/client/controllers/articles.client.controller.js
index 58d2c7d561..40708dd9c1 100644
--- a/modules/articles/client/controllers/articles.client.controller.js
+++ b/modules/articles/client/controllers/articles.client.controller.js
@@ -12,7 +12,6 @@
vm.article = article;
vm.authentication = Authentication;
- vm.error = null;
}
}());
diff --git a/modules/articles/client/views/admin/form-article.client.view.html b/modules/articles/client/views/admin/form-article.client.view.html
index f7d20e8fa6..15f05dbee8 100644
--- a/modules/articles/client/views/admin/form-article.client.view.html
+++ b/modules/articles/client/views/admin/form-article.client.view.html
@@ -24,9 +24,6 @@
{{vm.article._id ? 'Edit Article' : 'New Article'}}
-
-
-
diff --git a/modules/articles/tests/client/admin.articles.client.controller.tests.js b/modules/articles/tests/client/admin.articles.client.controller.tests.js
index 2b99aa483e..52b206e43e 100644
--- a/modules/articles/tests/client/admin.articles.client.controller.tests.js
+++ b/modules/articles/tests/client/admin.articles.client.controller.tests.js
@@ -9,7 +9,8 @@
$state,
Authentication,
ArticlesService,
- mockArticle;
+ mockArticle,
+ Notification;
// The $resource service augments the response object with methods for updating and deleting the resource.
// If we were to use the standard toEqual matcher, our tests would fail because the test values would not match
@@ -36,7 +37,7 @@
// The injector ignores leading and trailing underscores here (i.e. _$httpBackend_).
// This allows us to inject a service but then attach it to a variable
// with the same name as the service.
- beforeEach(inject(function ($controller, $rootScope, _$state_, _$httpBackend_, _Authentication_, _ArticlesService_) {
+ beforeEach(inject(function ($controller, $rootScope, _$state_, _$httpBackend_, _Authentication_, _ArticlesService_, _Notification_) {
// Set a new global scope
$scope = $rootScope.$new();
@@ -45,6 +46,7 @@
$state = _$state_;
Authentication = _Authentication_;
ArticlesService = _ArticlesService_;
+ Notification = _Notification_;
// create mock article
mockArticle = new ArticlesService({
@@ -66,6 +68,8 @@
// Spy on state go
spyOn($state, 'go');
+ spyOn(Notification, 'error');
+ spyOn(Notification, 'success');
}));
describe('vm.save() as create', function () {
@@ -89,11 +93,13 @@
$scope.vm.save(true);
$httpBackend.flush();
+ // Test Notification success was called
+ expect(Notification.success).toHaveBeenCalledWith({ message: ' Article saved successfully!' });
// Test URL redirection after the article was created
expect($state.go).toHaveBeenCalledWith('admin.articles.list');
}));
- it('should set $scope.vm.error if error', function () {
+ it('should call Notification.error if error', function () {
var errorMessage = 'this is an error message';
$httpBackend.expectPOST('api/articles', sampleArticlePostData).respond(400, {
message: errorMessage
@@ -102,7 +108,7 @@
$scope.vm.save(true);
$httpBackend.flush();
- expect($scope.vm.error).toBe(errorMessage);
+ expect(Notification.error).toHaveBeenCalledWith({ message: errorMessage, title: ' Article save error!' });
});
});
@@ -120,11 +126,13 @@
$scope.vm.save(true);
$httpBackend.flush();
+ // Test Notification success was called
+ expect(Notification.success).toHaveBeenCalledWith({ message: ' Article saved successfully!' });
// Test URL location to new object
expect($state.go).toHaveBeenCalledWith('admin.articles.list');
}));
- it('should set $scope.vm.error if error', inject(function (ArticlesService) {
+ it('should call Notification.error if error', inject(function (ArticlesService) {
var errorMessage = 'error';
$httpBackend.expectPUT(/api\/articles\/([0-9a-fA-F]{24})$/).respond(400, {
message: errorMessage
@@ -133,7 +141,7 @@
$scope.vm.save(true);
$httpBackend.flush();
- expect($scope.vm.error).toBe(errorMessage);
+ expect(Notification.error).toHaveBeenCalledWith({ message: errorMessage, title: ' Article save error!' });
}));
});
@@ -152,6 +160,7 @@
$scope.vm.remove();
$httpBackend.flush();
+ expect(Notification.success).toHaveBeenCalledWith({ message: ' Article deleted successfully!' });
expect($state.go).toHaveBeenCalledWith('admin.articles.list');
});
diff --git a/modules/core/client/app/config.js b/modules/core/client/app/config.js
index 754a6cbcd6..a8a093a5e0 100644
--- a/modules/core/client/app/config.js
+++ b/modules/core/client/app/config.js
@@ -6,7 +6,7 @@
var service = {
applicationEnvironment: window.env,
applicationModuleName: applicationModuleName,
- applicationModuleVendorDependencies: ['ngResource', 'ngAnimate', 'ngMessages', 'ui.router', 'ui.bootstrap', 'ngFileUpload', 'ngImgCrop'],
+ applicationModuleVendorDependencies: ['ngResource', 'ngAnimate', 'ngMessages', 'ui.router', 'ui.bootstrap', 'ngFileUpload', 'ngImgCrop', 'ui-notification'],
registerModule: registerModule
};
@@ -20,4 +20,17 @@
// Add the module to the AngularJS configuration file
angular.module(applicationModuleName).requires.push(moduleName);
}
+
+ // Angular-ui-notification configuration
+ angular.module('ui-notification').config(function(NotificationProvider) {
+ NotificationProvider.setOptions({
+ delay: 2000,
+ startTop: 20,
+ startRight: 10,
+ verticalSpacing: 20,
+ horizontalSpacing: 20,
+ positionX: 'right',
+ positionY: 'bottom'
+ });
+ });
}(window));
diff --git a/modules/users/client/controllers/admin/user.client.controller.js b/modules/users/client/controllers/admin/user.client.controller.js
index 8c4a1bb04b..53ac51e726 100644
--- a/modules/users/client/controllers/admin/user.client.controller.js
+++ b/modules/users/client/controllers/admin/user.client.controller.js
@@ -5,9 +5,9 @@
.module('users.admin')
.controller('UserController', UserController);
- UserController.$inject = ['$scope', '$state', '$window', 'Authentication', 'userResolve'];
+ UserController.$inject = ['$scope', '$state', '$window', 'Authentication', 'userResolve', 'Notification'];
- function UserController($scope, $state, $window, Authentication, user) {
+ function UserController($scope, $state, $window, Authentication, user, Notification) {
var vm = this;
vm.authentication = Authentication;
@@ -22,9 +22,11 @@
user.$remove();
vm.users.splice(vm.users.indexOf(user), 1);
+ Notification.success('User deleted successfully!');
} else {
vm.user.$remove(function () {
$state.go('admin.users');
+ Notification.success({ message: ' User deleted successfully!' });
});
}
}
@@ -43,8 +45,9 @@
$state.go('admin.user', {
userId: user._id
});
+ Notification.success({ message: ' User saved successfully!' });
}, function (errorResponse) {
- vm.error = errorResponse.data.message;
+ Notification.error({ message: errorResponse.data.message, title: ' User update error!' });
});
}
diff --git a/modules/users/client/controllers/authentication.client.controller.js b/modules/users/client/controllers/authentication.client.controller.js
index 96cca04f46..34ddeffd3f 100644
--- a/modules/users/client/controllers/authentication.client.controller.js
+++ b/modules/users/client/controllers/authentication.client.controller.js
@@ -5,9 +5,9 @@
.module('users')
.controller('AuthenticationController', AuthenticationController);
- AuthenticationController.$inject = ['$scope', '$state', 'UsersService', '$location', '$window', 'Authentication', 'PasswordValidator'];
+ AuthenticationController.$inject = ['$scope', '$state', 'UsersService', '$location', '$window', 'Authentication', 'PasswordValidator', 'Notification'];
- function AuthenticationController($scope, $state, UsersService, $location, $window, Authentication, PasswordValidator) {
+ function AuthenticationController($scope, $state, UsersService, $location, $window, Authentication, PasswordValidator, Notification) {
var vm = this;
vm.authentication = Authentication;
@@ -17,7 +17,9 @@
vm.callOauthProvider = callOauthProvider;
// Get an eventual error defined in the URL query string:
- vm.error = $location.search().err;
+ if ($location.search().err) {
+ Notification.error({ message: $location.search().err });
+ }
// If user is signed in then redirect back home
if (vm.authentication.user) {
@@ -25,7 +27,6 @@
}
function signup(isValid) {
- vm.error = null;
if (!isValid) {
$scope.$broadcast('show-errors-check-validity', 'vm.userForm');
@@ -39,7 +40,6 @@
}
function signin(isValid) {
- vm.error = null;
if (!isValid) {
$scope.$broadcast('show-errors-check-validity', 'vm.userForm');
@@ -67,25 +67,25 @@
function onUserSignupSuccess(response) {
// If successful we assign the response to the global user model
vm.authentication.user = response;
-
+ Notification.success({ message: ' Signup successful!' });
// And redirect to the previous or home page
$state.go($state.previous.state.name || 'home', $state.previous.params);
}
function onUserSignupError(response) {
- vm.error = response.data.message;
+ Notification.error({ message: response.data.message, title: ' Signup Error!', delay: 6000 });
}
function onUserSigninSuccess(response) {
// If successful we assign the response to the global user model
vm.authentication.user = response;
-
+ Notification.info({ message: 'Welcome ' + response.firstName });
// And redirect to the previous or home page
$state.go($state.previous.state.name || 'home', $state.previous.params);
}
function onUserSigninError(response) {
- vm.error = response.data.message;
+ Notification.error({ message: response.data.message, title: ' Signin Error!', delay: 6000 });
}
}
}());
diff --git a/modules/users/client/controllers/password.client.controller.js b/modules/users/client/controllers/password.client.controller.js
index fe015c7844..856d87f7ff 100644
--- a/modules/users/client/controllers/password.client.controller.js
+++ b/modules/users/client/controllers/password.client.controller.js
@@ -5,9 +5,9 @@
.module('users')
.controller('PasswordController', PasswordController);
- PasswordController.$inject = ['$scope', '$stateParams', 'UsersService', '$location', 'Authentication', 'PasswordValidator'];
+ PasswordController.$inject = ['$scope', '$stateParams', 'UsersService', '$location', 'Authentication', 'PasswordValidator', 'Notification'];
- function PasswordController($scope, $stateParams, UsersService, $location, Authentication, PasswordValidator) {
+ function PasswordController($scope, $stateParams, UsersService, $location, Authentication, PasswordValidator, Notification) {
var vm = this;
vm.resetUserPassword = resetUserPassword;
@@ -22,7 +22,6 @@
// Submit forgotten password account id
function askForPasswordReset(isValid) {
- vm.success = vm.error = null;
if (!isValid) {
$scope.$broadcast('show-errors-check-validity', 'vm.forgotPasswordForm');
@@ -37,7 +36,6 @@
// Change user password
function resetUserPassword(isValid) {
- vm.success = vm.error = null;
if (!isValid) {
$scope.$broadcast('show-errors-check-validity', 'vm.resetPasswordForm');
@@ -55,13 +53,13 @@
function onRequestPasswordResetSuccess(response) {
// Show user success message and clear form
vm.credentials = null;
- vm.success = response.message;
+ Notification.success({ message: response.message, title: ' Password reset email sent successfully!' });
}
function onRequestPasswordResetError(response) {
// Show user error message and clear form
vm.credentials = null;
- vm.error = response.data.message;
+ Notification.error({ message: response.data.message, title: ' Failed to send password reset email!', delay: 4000 });
}
function onResetPasswordSuccess(response) {
@@ -70,12 +68,13 @@
// Attach user profile
Authentication.user = response;
+ Notification.success({ message: ' Password reset successful!' });
// And redirect to the index page
$location.path('/password/reset/success');
}
function onResetPasswordError(response) {
- vm.error = response.data.message;
+ Notification.error({ message: response.data.message, title: ' Password reset failed!', delay: 4000 });
}
}
}());
diff --git a/modules/users/client/controllers/settings/change-password.client.controller.js b/modules/users/client/controllers/settings/change-password.client.controller.js
index a95b032b60..8602dfe8ef 100644
--- a/modules/users/client/controllers/settings/change-password.client.controller.js
+++ b/modules/users/client/controllers/settings/change-password.client.controller.js
@@ -5,9 +5,9 @@
.module('users')
.controller('ChangePasswordController', ChangePasswordController);
- ChangePasswordController.$inject = ['$scope', '$http', 'Authentication', 'UsersService', 'PasswordValidator'];
+ ChangePasswordController.$inject = ['$scope', '$http', 'Authentication', 'UsersService', 'PasswordValidator', 'Notification'];
- function ChangePasswordController($scope, $http, Authentication, UsersService, PasswordValidator) {
+ function ChangePasswordController($scope, $http, Authentication, UsersService, PasswordValidator, Notification) {
var vm = this;
vm.user = Authentication.user;
@@ -16,7 +16,6 @@
// Change user password
function changeUserPassword(isValid) {
- vm.success = vm.error = null;
if (!isValid) {
$scope.$broadcast('show-errors-check-validity', 'vm.passwordForm');
@@ -31,13 +30,12 @@
function onChangePasswordSuccess(response) {
// If successful show success message and clear form
- $scope.$broadcast('show-errors-reset', 'vm.passwordForm');
- vm.success = true;
+ Notification.success({ message: ' Password Changed Successfully' });
vm.passwordDetails = null;
}
function onChangePasswordError(response) {
- vm.error = response.data.message;
+ Notification.error({ message: response.data.message, title: ' Password change failed!' });
}
}
}());
diff --git a/modules/users/client/controllers/settings/change-profile-picture.client.controller.js b/modules/users/client/controllers/settings/change-profile-picture.client.controller.js
index 411b62a14e..ca378c78f5 100644
--- a/modules/users/client/controllers/settings/change-profile-picture.client.controller.js
+++ b/modules/users/client/controllers/settings/change-profile-picture.client.controller.js
@@ -5,16 +5,15 @@
.module('users')
.controller('ChangeProfilePictureController', ChangeProfilePictureController);
- ChangeProfilePictureController.$inject = ['$timeout', 'Authentication', 'Upload'];
+ ChangeProfilePictureController.$inject = ['$timeout', 'Authentication', 'Upload', 'Notification'];
- function ChangeProfilePictureController($timeout, Authentication, Upload) {
+ function ChangeProfilePictureController($timeout, Authentication, Upload, Notification) {
var vm = this;
vm.user = Authentication.user;
vm.fileSelected = false;
vm.upload = function (dataUrl, name) {
- vm.success = vm.error = null;
Upload.upload({
url: 'api/users/picture',
@@ -35,7 +34,7 @@
// Called after the user has successfully uploaded a new picture
function onSuccessItem(response) {
// Show success message
- vm.success = true;
+ Notification.success({ message: ' Change profile picture successful!' });
// Populate user object
vm.user = Authentication.user = response;
@@ -50,7 +49,7 @@
vm.fileSelected = false;
// Show error message
- vm.error = response.message;
+ Notification.error({ message: response.message, title: ' Change profile picture failed!' });
}
}
}());
diff --git a/modules/users/client/controllers/settings/edit-profile.client.controller.js b/modules/users/client/controllers/settings/edit-profile.client.controller.js
index 1a1d3ee43a..f6c5a2b405 100644
--- a/modules/users/client/controllers/settings/edit-profile.client.controller.js
+++ b/modules/users/client/controllers/settings/edit-profile.client.controller.js
@@ -5,9 +5,9 @@
.module('users')
.controller('EditProfileController', EditProfileController);
- EditProfileController.$inject = ['$scope', '$http', '$location', 'UsersService', 'Authentication'];
+ EditProfileController.$inject = ['$scope', '$http', '$location', 'UsersService', 'Authentication', 'Notification'];
- function EditProfileController($scope, $http, $location, UsersService, Authentication) {
+ function EditProfileController($scope, $http, $location, UsersService, Authentication, Notification) {
var vm = this;
vm.user = Authentication.user;
@@ -15,7 +15,6 @@
// Update a user profile
function updateUserProfile(isValid) {
- vm.success = vm.error = null;
if (!isValid) {
$scope.$broadcast('show-errors-check-validity', 'vm.userForm');
@@ -28,10 +27,10 @@
user.$update(function (response) {
$scope.$broadcast('show-errors-reset', 'vm.userForm');
- vm.success = true;
+ Notification.success({ message: ' Edit profile successful!' });
Authentication.user = response;
}, function (response) {
- vm.error = response.data.message;
+ Notification.error({ message: response.data.message, title: ' Edit profile failed!' });
});
}
}
diff --git a/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js b/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js
index 6ba564f97e..1551fce1c0 100644
--- a/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js
+++ b/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js
@@ -5,9 +5,9 @@
.module('users')
.controller('SocialAccountsController', SocialAccountsController);
- SocialAccountsController.$inject = ['$scope', 'UsersService', 'Authentication'];
+ SocialAccountsController.$inject = ['$scope', 'UsersService', 'Authentication', 'Notification'];
- function SocialAccountsController($scope, UsersService, Authentication) {
+ function SocialAccountsController($scope, UsersService, Authentication, Notification) {
var vm = this;
vm.user = Authentication.user;
@@ -27,7 +27,6 @@
// Remove a user social account
function removeUserSocialAccount(provider) {
- vm.success = vm.error = null;
UsersService.removeSocialAccount(provider)
.then(onRemoveSocialAccountSuccess)
@@ -36,12 +35,12 @@
function onRemoveSocialAccountSuccess(response) {
// If successful show success message and clear form
- vm.success = true;
+ Notification.success({ message: ' Removed successfully!' });
vm.user = Authentication.user = response;
}
function onRemoveSocialAccountError(response) {
- vm.error = response.message;
+ Notification.error({ message: response.message, title: ' Remove failed!' });
}
}
}());
diff --git a/modules/users/client/views/admin/edit-user.client.view.html b/modules/users/client/views/admin/edit-user.client.view.html
index 559af2812c..3687a28095 100644
--- a/modules/users/client/views/admin/edit-user.client.view.html
+++ b/modules/users/client/views/admin/edit-user.client.view.html
@@ -31,9 +31,6 @@ User
-
-
-
diff --git a/modules/users/client/views/authentication/signup.client.view.html b/modules/users/client/views/authentication/signup.client.view.html
index edd6214e23..2c593322d9 100644
--- a/modules/users/client/views/authentication/signup.client.view.html
+++ b/modules/users/client/views/authentication/signup.client.view.html
@@ -51,9 +51,6 @@ Or sign up using your email
or
Sign in
-
-
-
diff --git a/modules/users/client/views/password/forgot-password.client.view.html b/modules/users/client/views/password/forgot-password.client.view.html
index 07fca823a4..b549ee70a6 100644
--- a/modules/users/client/views/password/forgot-password.client.view.html
+++ b/modules/users/client/views/password/forgot-password.client.view.html
@@ -13,12 +13,6 @@ Restore your password
-
-
-
-
-
-
diff --git a/modules/users/client/views/password/reset-password.client.view.html b/modules/users/client/views/password/reset-password.client.view.html
index ca0763704d..be7f4e7cc8 100644
--- a/modules/users/client/views/password/reset-password.client.view.html
+++ b/modules/users/client/views/password/reset-password.client.view.html
@@ -28,12 +28,6 @@ Reset your password
-
-
-
-
-
-
diff --git a/modules/users/client/views/settings/change-password.client.view.html b/modules/users/client/views/settings/change-password.client.view.html
index 8ab0045d50..f01dfd5aed 100644
--- a/modules/users/client/views/settings/change-password.client.view.html
+++ b/modules/users/client/views/settings/change-password.client.view.html
@@ -34,12 +34,6 @@
-
- Password Changed Successfully
-
-
-
-
diff --git a/modules/users/client/views/settings/change-profile-picture.client.view.html b/modules/users/client/views/settings/change-profile-picture.client.view.html
index 721c34bb46..0e4fccc8a9 100644
--- a/modules/users/client/views/settings/change-profile-picture.client.view.html
+++ b/modules/users/client/views/settings/change-profile-picture.client.view.html
@@ -12,7 +12,7 @@
-
+
@@ -23,12 +23,6 @@
{{vm.progress}}% Complete
-
- Profile Picture Changed Successfully
-
-
-
-
diff --git a/modules/users/client/views/settings/edit-profile.client.view.html b/modules/users/client/views/settings/edit-profile.client.view.html
index 62ab91984c..76b25bf8d5 100644
--- a/modules/users/client/views/settings/edit-profile.client.view.html
+++ b/modules/users/client/views/settings/edit-profile.client.view.html
@@ -34,12 +34,6 @@
-
- Profile Saved Successfully
-
-
-
-
diff --git a/modules/users/tests/client/authentication.client.controller.tests.js b/modules/users/tests/client/authentication.client.controller.tests.js
index 0eafab51b1..dbbbd5b091 100644
--- a/modules/users/tests/client/authentication.client.controller.tests.js
+++ b/modules/users/tests/client/authentication.client.controller.tests.js
@@ -9,7 +9,8 @@
$httpBackend,
$stateParams,
$state,
- $location;
+ $location,
+ Notification;
beforeEach(function () {
jasmine.addMatchers({
@@ -32,7 +33,7 @@
// The injector ignores leading and trailing underscores here (i.e. _$httpBackend_).
// This allows us to inject a service but then attach it to a variable
// with the same name as the service.
- beforeEach(inject(function ($controller, $rootScope, _$location_, _$stateParams_, _$httpBackend_) {
+ beforeEach(inject(function ($controller, $rootScope, _$location_, _$stateParams_, _$httpBackend_, _Notification_) {
// Set a new global scope
scope = $rootScope.$new();
@@ -40,6 +41,11 @@
$stateParams = _$stateParams_;
$httpBackend = _$httpBackend_;
$location = _$location_;
+ Notification = _Notification_;
+
+ // Spy on Notification
+ spyOn(Notification, 'error');
+ spyOn(Notification, 'success');
// Initialize the Authentication controller
AuthenticationController = $controller('AuthenticationController as vm', {
@@ -107,8 +113,8 @@
scope.vm.signin(true);
$httpBackend.flush();
- // Test scope value
- expect(scope.vm.error).toEqual('Missing credentials');
+ // Test Notification.error is called
+ expect(Notification.error).toHaveBeenCalledWith({ message: 'Missing credentials', title: ' Signin Error!', delay: 6000 });
});
it('should fail to log in with wrong credentials', function () {
@@ -124,8 +130,8 @@
scope.vm.signin(true);
$httpBackend.flush();
- // Test scope value
- expect(scope.vm.error).toEqual('Unknown user');
+ // Test Notification.error is called
+ expect(Notification.error).toHaveBeenCalledWith({ message: 'Unknown user', title: ' Signin Error!', delay: 6000 });
});
});
@@ -140,7 +146,7 @@
// test scope value
expect(scope.vm.authentication.user.username).toBe('Fred');
- expect(scope.vm.error).toEqual(null);
+ expect(Notification.success).toHaveBeenCalledWith({ message: ' Signup successful!' });
expect($location.url()).toBe('/');
});
@@ -153,8 +159,8 @@
scope.vm.signup(true);
$httpBackend.flush();
- // Test scope value
- expect(scope.vm.error).toBe('Username already exists');
+ // Test Notification.error is called
+ expect(Notification.error).toHaveBeenCalledWith({ message: 'Username already exists', title: ' Signup Error!', delay: 6000 });
});
});
});
diff --git a/modules/users/tests/client/edit-profile.client.controller.tests.js b/modules/users/tests/client/edit-profile.client.controller.tests.js
index a8c6874acf..fcb73bafcc 100644
--- a/modules/users/tests/client/edit-profile.client.controller.tests.js
+++ b/modules/users/tests/client/edit-profile.client.controller.tests.js
@@ -8,7 +8,8 @@
$httpBackend,
$location,
Authentication,
- UsersService;
+ UsersService,
+ Notification;
// The $resource service augments the response object with methods for updating and deleting the resource.
// If we were to use the standard toEqual matcher, our tests would fail because the test values would not match
@@ -35,7 +36,7 @@
// The injector ignores leading and trailing underscores here (i.e. _$httpBackend_).
// This allows us to inject a service but then attach it to a variable
// with the same name as the service.
- beforeEach(inject(function ($controller, $rootScope, _$location_, _$httpBackend_, _Authentication_, _UsersService_) {
+ beforeEach(inject(function ($controller, $rootScope, _$location_, _$httpBackend_, _Authentication_, _UsersService_, _Notification_) {
// Set a new global scope
$scope = $rootScope.$new();
@@ -44,6 +45,11 @@
$location = _$location_;
Authentication = _Authentication_;
UsersService = _UsersService_;
+ Notification = _Notification_;
+
+ // Spy on Notification
+ spyOn(Notification, 'error');
+ spyOn(Notification, 'success');
// Mock logged in user
Authentication.user = {
@@ -72,10 +78,10 @@
$scope.vm.updateUserProfile(true);
$httpBackend.flush();
- expect($scope.vm.success).toBe(true);
+ expect(Notification.success).toHaveBeenCalledWith({ message: ' Edit profile successful!' });
}));
- it('should set vm.error if error', inject(function (UsersService) {
+ it('should call Notification.error if error', inject(function (UsersService) {
var errorMessage = 'error';
$httpBackend.expectPUT(/api\/users/).respond(400, {
message: errorMessage
@@ -84,7 +90,7 @@
$scope.vm.updateUserProfile(true);
$httpBackend.flush();
- expect($scope.vm.error).toBe(errorMessage);
+ expect(Notification.error).toHaveBeenCalledWith({ message: errorMessage, title: ' Edit profile failed!' });
}));
});
diff --git a/modules/users/tests/client/password.client.controller.tests.js b/modules/users/tests/client/password.client.controller.tests.js
index cb486bc167..fc8637cd78 100644
--- a/modules/users/tests/client/password.client.controller.tests.js
+++ b/modules/users/tests/client/password.client.controller.tests.js
@@ -9,7 +9,8 @@
$httpBackend,
$stateParams,
$location,
- $window;
+ $window,
+ Notification;
beforeEach(function() {
jasmine.addMatchers({
@@ -57,7 +58,7 @@
});
describe('Logged out user', function() {
- beforeEach(inject(function($controller, $rootScope, _$window_, _$stateParams_, _$httpBackend_, _$location_) {
+ beforeEach(inject(function($controller, $rootScope, _$window_, _$stateParams_, _$httpBackend_, _$location_, _Notification_) {
// Set a new global scope
scope = $rootScope.$new();
@@ -68,6 +69,10 @@
$location.path = jasmine.createSpy().and.returnValue(true);
$window = _$window_;
$window.user = null;
+ Notification = _Notification_;
+
+ spyOn(Notification, 'error');
+ spyOn(Notification, 'success');
// Initialize the Authentication controller
PasswordController = $controller('PasswordController as vm', {
@@ -88,15 +93,6 @@
scope.vm.credentials = credentials;
});
- it('should clear scope.success and scope.error', function() {
- scope.vm.success = 'test';
- scope.vm.error = 'test';
- scope.vm.askForPasswordReset(true);
-
- expect(scope.vm.success).toBeNull();
- expect(scope.vm.error).toBeNull();
- });
-
describe('POST error', function() {
var errorMessage = 'No account with that username has been found';
beforeEach(function() {
@@ -112,8 +108,8 @@
expect(scope.vm.credentials).toBe(null);
});
- it('should set error to response message', function() {
- expect(scope.vm.error).toBe(errorMessage);
+ it('should call Notification.error with response message', function() {
+ expect(Notification.error).toHaveBeenCalledWith({ message: errorMessage, title: ' Failed to send password reset email!', delay: 4000 });
});
});
@@ -132,8 +128,8 @@
expect(scope.vm.credentials).toBe(null);
});
- it('should set success to response message', function() {
- expect(scope.vm.success).toBe(successMessage);
+ it('should call Notification.success with response message', function() {
+ expect(Notification.success).toHaveBeenCalledWith({ message: successMessage, title: ' Password reset email sent successfully!' });
});
});
});
@@ -148,16 +144,7 @@
scope.vm.passwordDetails = passwordDetails;
});
- it('should clear scope.success and scope.vm.error', function() {
- scope.vm.success = 'test';
- scope.vm.error = 'test';
- scope.vm.resetUserPassword(true);
-
- expect(scope.vm.success).toBeNull();
- expect(scope.vm.error).toBeNull();
- });
-
- it('POST error should set scope.error to response message', function() {
+ it('POST error should call Notification.error with response message', function() {
var errorMessage = 'Passwords do not match';
$httpBackend.when('POST', 'api/auth/reset/' + token, passwordDetails).respond(400, {
'message': errorMessage
@@ -166,7 +153,7 @@
scope.vm.resetUserPassword(true);
$httpBackend.flush();
- expect(scope.vm.error).toBe(errorMessage);
+ expect(Notification.error).toHaveBeenCalledWith({ message: errorMessage, title: ' Password reset failed!', delay: 4000 });
});
describe('POST success', function() {
@@ -188,7 +175,8 @@
expect(scope.vm.authentication.user.username).toEqual(user.username);
});
- it('should redirect to password reset success view', function() {
+ it('should redirect to password reset success view with Notification.success', function() {
+ expect(Notification.success).toHaveBeenCalledWith({ message: ' Password reset successful!' });
expect($location.path).toHaveBeenCalledWith('/password/reset/success');
});
});
diff --git a/modules/users/tests/e2e/users.e2e.tests.js b/modules/users/tests/e2e/users.e2e.tests.js
index 5e95d584c2..a6584bb8f3 100644
--- a/modules/users/tests/e2e/users.e2e.tests.js
+++ b/modules/users/tests/e2e/users.e2e.tests.js
@@ -272,7 +272,7 @@ describe('Users E2E Tests:', function () {
// Click Submit button
element(by.css('button[type=submit]')).click();
// Password Error
- expect(element.all(by.css('strong')).get(0).getText()).toBe('Email already exists');
+ expect(element.all(by.css('.message')).get(0).getText()).toBe('Email already exists');
});
it('Should report Username already exists', function () {
@@ -291,7 +291,7 @@ describe('Users E2E Tests:', function () {
// Click Submit button
element(by.css('button[type=submit]')).click();
// Password Error
- expect(element.all(by.css('strong')).get(0).getText()).toBe('Username already exists');
+ expect(element.all(by.css('.message')).get(0).getText()).toBe('Username already exists');
});
});
@@ -436,7 +436,7 @@ describe('Users E2E Tests:', function () {
// Click Submit button
element(by.css('button[type=submit]')).click();
// Password Changed
- expect(element.all(by.css('.text-success')).get(0).getText()).toBe('Password Changed Successfully');
+ expect(element.all(by.css('.ui-notification')).get(0).getText()).toBe('Password Changed Successfully');
});
});
});