mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
added growl style notification for errors
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -61,5 +61,9 @@ habitrpg.controller('NotificationCtrl',
|
||||
Notification.lvl();
|
||||
}
|
||||
});
|
||||
|
||||
$rootScope.$on('responseError', function(ev, error){
|
||||
Notification.error(error);
|
||||
});
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<Title:>
|
||||
{{status}}
|
||||
|
||||
<Body:>
|
||||
<h1>{{status}}</h1>
|
||||
<p>{{message}}</p>
|
||||
@@ -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)') ×
|
||||
.unstyled.alert.alert-error(ng-repeat='error in flash.warnings track by $index')
|
||||
| {{error}}
|
||||
button.close(type='button', ng-click='dismissErrorOrWarning("warnings", $index)') ×
|
||||
|
||||
//if they hide the header, we still need user-menu visible
|
||||
div(ng-if='user.preferences.hideHeader')
|
||||
include ./shared/header/menu
|
||||
|
||||
Reference in New Issue
Block a user