Commit 71d8ed25 authored by Evren Kutar's avatar Evren Kutar

error pages redirect relevant url

parent cc2ed499
...@@ -103,4 +103,7 @@ docs/_build/ ...@@ -103,4 +103,7 @@ docs/_build/
# PyBuilder # PyBuilder
target/ target/
coverage/ coverage/
\ No newline at end of file
sync
*.rdb
\ No newline at end of file
...@@ -298,8 +298,7 @@ module.exports = function (grunt) { ...@@ -298,8 +298,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-preprocess'); grunt.loadNpmTasks('grunt-preprocess');
grunt.loadNpmTasks('grunt-env'); grunt.loadNpmTasks('grunt-env');
//grunt.registerTask('dev', ['env:dev', 'preprocess:dev', 'html2js:dev', 'connect:server', 'watch:dev']); grunt.registerTask('dev', ['env:dev', 'preprocess:dev', 'html2js:dev', 'connect:server', 'watch:dev']);
grunt.registerTask('dev', ['env:dev', 'preprocess:dev', 'html2js:dev', 'watch:dev']);
grunt.registerTask('test', ['bower', 'karma:continuous']); grunt.registerTask('test', ['bower', 'karma:continuous']);
grunt.registerTask('i18n', ['nggettext_extract', 'nggettext_compile']); grunt.registerTask('i18n', ['nggettext_extract', 'nggettext_compile']);
grunt.registerTask('default', [ grunt.registerTask('default', [
......
...@@ -24,7 +24,7 @@ app.directive('logout', function ($http, $location, RESTURL) { ...@@ -24,7 +24,7 @@ app.directive('logout', function ($http, $location, RESTURL) {
/** /**
* headerNotification directive for header * headerNotification directive for header
*/ */
app.directive('headerNotification', function ($http, $interval) { app.directive('headerNotification', function ($http, $interval, RESTURL) {
return { return {
templateUrl: 'shared/templates/directives/header-notification.html', templateUrl: 'shared/templates/directives/header-notification.html',
restrict: 'E', restrict: 'E',
...@@ -32,7 +32,7 @@ app.directive('headerNotification', function ($http, $interval) { ...@@ -32,7 +32,7 @@ app.directive('headerNotification', function ($http, $interval) {
link: function ($scope) { link: function ($scope) {
$interval(function () { $interval(function () {
// todo: change url to backend // todo: change url to backend
$http.get("http://google.com").success(function (data) { $http.post(RESTURL+"crud").success(function (data) {
$scope.notifications = data; $scope.notifications = data;
}); });
}, 15000); }, 15000);
......
...@@ -41,11 +41,11 @@ app.config(['$httpProvider', function ($httpProvider) { ...@@ -41,11 +41,11 @@ app.config(['$httpProvider', function ($httpProvider) {
}, },
'responseError': function (rejection) { 'responseError': function (rejection) {
// if unauthorized then redirect to login page // if unauthorized then redirect to login page
if (rejection.status === 400) { if (rejection.status === 400) {
$location.reload(); $location.reload();
} }
if (rejection.status === 401) { if (rejection.status === 401) {
//$rootScope.loggedInUser = false;
if ($location.path() === "/login") { if ($location.path() === "/login") {
console.log("show errors on login form"); console.log("show errors on login form");
} else { } else {
...@@ -55,16 +55,17 @@ app.config(['$httpProvider', function ($httpProvider) { ...@@ -55,16 +55,17 @@ app.config(['$httpProvider', function ($httpProvider) {
if (rejection.status === 403) { if (rejection.status === 403) {
if (rejection.data.is_login === true) { if (rejection.data.is_login === true) {
$rootScope.loggedInUser = true; $rootScope.loggedInUser = true;
console.log('user logged in');
if ($location.path() === "/login") { if ($location.path() === "/login") {
$location.path("/dashboard"); $location.path("/dashboard");
} }
} }
} }
if (rejection.status === 404) { if (rejection.status === 404) {
console.log(404);
$location.path("/404"); $location.path("/404");
} }
if (rejection.status === 500) { // server 500 error returns with -1 on status.
if (rejection.status === -1 && rejection.config.data.model) {
$location.path("/500"); $location.path("/500");
} }
return $q.reject(rejection); return $q.reject(rejection);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment