added growl style notification for errors

This commit is contained in:
Matteo Pagliazzi
2013-10-30 19:29:46 +01:00
parent 1490380e53
commit e2331e5194
6 changed files with 12 additions and 18 deletions

View File

@@ -147,9 +147,11 @@ window.habitrpg = angular.module('habitrpg',
function error(response) {
//var status = response.status;
response.data = (response.data.err) ? response.data.err : response.data;
if (response.status == 0) response.data = 'Server currently unreachable';
if (response.status == 0) response.data = 'Server currently unreachable.';
if (response.status == 500) response.data += ' (see Chrome console for more details).';
$rootScope.flash.errors.push(response.status + ': ' + response.data);
var error = response.status == 0 ? response.data : ('Error ' + response.status + ': ' + response.data);
$rootScope.$broadcast('responseError', error);
console.log(arguments);
return $q.reject(response);
}

View File

@@ -61,5 +61,9 @@ habitrpg.controller('NotificationCtrl',
Notification.lvl();
}
});
$rootScope.$on('responseError', function(ev, error){
Notification.error(error);
});
}
]);

View File

@@ -10,7 +10,6 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
$rootScope.User = User;
$rootScope.user = User.user;
$rootScope.settings = User.settings;
$rootScope.flash = {errors: [], warnings: []};
// Angular UI Router
$rootScope.$state = $state;

View File

@@ -65,6 +65,9 @@ angular.module("notificationServices", [])
},
death: function(){
growl("<i class='icon-death'></i> Respawn!", "death");
},
error: function(error){
growl("<i class='icon-exclamation-sign'></i> " + error, "error");
}
};
}

View File

@@ -1,6 +0,0 @@
<Title:>
{{status}}
<Body:>
<h1>{{status}}</h1>
<p>{{message}}</p>

View File

@@ -101,14 +101,6 @@ html
#notification-area(ng-controller='NotificationCtrl')
#wrap
// Errors
.unstyled.alert.alert-error(ng-repeat='error in flash.errors track by $index')
| {{error}}
button.close(type='button', ng-click='dismissErrorOrWarning("errors", $index)') &times;
.unstyled.alert.alert-error(ng-repeat='error in flash.warnings track by $index')
| {{error}}
button.close(type='button', ng-click='dismissErrorOrWarning("warnings", $index)') &times;
//if they hide the header, we still need user-menu visible
div(ng-if='user.preferences.hideHeader')
include ./shared/header/menu