Commit 724f794c authored by Evren Kutar's avatar Evren Kutar

500 error show on modal & angular update to 1.4.7

parent a91d4a5b
...@@ -28,13 +28,13 @@ ...@@ -28,13 +28,13 @@
</label> </label>
</td> </td>
<th scope="row" style="text-align:center">{{$index}}</th> <th scope="row" style="text-align:center">{{$index}}</th>
<td ng-repeat="k in object" ng-if="nobjects[0]=='-1' && $index>0"> <td ng-repeat="k in object track by $index" ng-if="nobjects[0]=='-1' && $index>0">
<a ng-href="#/crud/{{model}}/{{object[0]}}">{{object[1]}}</a> <a ng-href="#/crud/{{model}}/{{object[0]}}">{{object[1]}}</a>
</td> </td>
<td ng-repeat="(key,value) in object" ng-if="nobjects[0]!='-1' && $index>0"> <td ng-repeat="(key,value) in object track by $index" ng-if="nobjects[0]!='-1' && $index>0">
<a ng-href="#/crud/{{model}}/{{object[0]}}" ng-if="$index==1">{{value}}</a> <a ng-href="#/crud/{{model}}/{{object[0]}}" ng-if="$index==1">{{object[key]}}</a>
<span ng-if="$index!=1">{{value}}</span> <span ng-if="$index!=1">{{object[key]}}</span>
</td> </td>
<td> <td>
<a ng-href="#/crud/{{model}}/edit/{{object[0]}}">Edit</a><br> <a ng-href="#/crud/{{model}}/edit/{{object[0]}}">Edit</a><br>
......
...@@ -7,12 +7,99 @@ ...@@ -7,12 +7,99 @@
'use strict'; 'use strict';
// TODO: clean console log items
angular.module('ulakbus.dashboard', ['ngRoute']) angular.module('ulakbus.dashboard', ['ngRoute'])
.controller('DashCtrl', function ($scope, $rootScope) { .controller('DashCtrl', function ($scope, $rootScope, $timeout, $http, RESTURL) {
$scope.section = function (section_index) { $scope.section = function (section_index) {
$rootScope.section = section_index; $rootScope.section = section_index;
}; };
});
\ No newline at end of file $scope.what = "";
$scope.listitems = [];
$scope.search = function (where) {
$timeout(function () {
if ($scope.what.length > 3) {
// if input length greater than 3 search for the value
$http.post(RESTURL.url + where, {"query": $scope.what})
.success(function (data) {
$scope.listitems = data;
});
}
});
};
// when select a user from list
//$http.post(RESTURL.url + 'crud/').success(function (data) {
// $scope.allMenuItems = angular.copy(data.app_models);
// $scope.menuItems = []; // angular.copy($scope.allMenuItems);
// // at start define breadcrumblinks for breadcrumb
// angular.forEach(data.app_models, function (value, key) {
// angular.forEach(value[1], function (v, k) {
// if (v[1] === $location.path().split('/')[2]) {
// $rootScope.breadcrumblinks = [value[0], v[0]];
// $scope.menuItems = [$scope.allMenuItems[key]];
// } else {
// $rootScope.breadcrumblinks = ['Panel'];
// }
// });
// });
//});
//$rootScope.$watch(function ($rootScope) {
// return $rootScope.section;
// },
// function (newindex, oldindex) {
// if (newindex > -1) {
// $scope.menuItems = [$scope.allMenuItems[newindex]];
// $scope.collapseVar = 1;
// $timeout(function () {
// $('#side-menu').metisMenu();
// });
// }
// });
//
//$scope.selectedMenu = $location.path();
//$scope.collapseVar = 0;
//$scope.multiCollapseVar = 0;
//
//$scope.check = function (x) {
//
// if (x === $scope.collapseVar) {
// $scope.collapseVar = 0;
// } else {
// $scope.collapseVar = x;
// }
//
//};
//
//// breadcrumb function changes breadcrumb items and itemlist must be list
//$scope.breadcrumb = function (itemlist) {
// $rootScope.breadcrumblinks = itemlist;
// // showSaveButton is used for to show or not to show save button on top of the page
// $rootScope.showSaveButton = false;
//};
//
//$scope.multiCheck = function (y) {
//
// if (y === $scope.multiCollapseVar) {
// $scope.multiCollapseVar = 0;
// } else {
// $scope.multiCollapseVar = y;
// }
//};
})
//.directive('sidebar', ['$location', function () {
// return {
// templateUrl: 'shared/templates/directives/sidebar.html',
// restrict: 'E',
// replace: true,
// scope: {},
// controller: function ($scope, $rootScope, $http, RESTURL, $location, $timeout) {
//
//
// }
// };
//}]);
...@@ -35,13 +35,13 @@ app.config(['$httpProvider', function ($httpProvider) { ...@@ -35,13 +35,13 @@ app.config(['$httpProvider', function ($httpProvider) {
} }
// if (response.data.client_cmd) { // if (response.data.client_cmd) {
//$location.path(response.data.screen); //$location.path(response.data.screen);
// } // }
return response; return response;
}, },
'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();
} }
...@@ -65,8 +65,29 @@ app.config(['$httpProvider', function ($httpProvider) { ...@@ -65,8 +65,29 @@ app.config(['$httpProvider', function ($httpProvider) {
$location.path("/404"); $location.path("/404");
} }
// server 500 error returns with -1 on status. // server 500 error returns with -1 on status.
if (rejection.status === -1 && rejection.config.data.model) { //if (rejection.status === -1 && rejection.config.data.model) {
$location.path("/500"); if (rejection.status === 500) {
// todo: redirect to 500
//$location.path("/500");
$('<div class="modal">' +
'<div class="modal-dialog" style="width:1024px;" role="document">' +
'<div class="modal-content">' +
'<div class="modal-header">' +
'<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span' +
' aria-hidden="true">&times;</span></button>' +
'<h4 class="modal-title" id="exampleModalLabel">500 Server Error</h4>' +
'</div>' +
'<div class="modal-body">' +
'<p><pre>' +
rejection.data.error +
'</pre></p>' +
'</div>' +
'<div class="modal-footer">' +
'<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>' +
'</div>' +
'</div>' +
'</div>' +
'</div>').modal()
} }
return $q.reject(rejection); return $q.reject(rejection);
} }
......
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
"license": "GPL", "license": "GPL",
"private": false, "private": false,
"dependencies": { "dependencies": {
"angular": "1.3.20", "angular": "1.4.7",
"json3": "~3.3.2", "json3": "~3.3.2",
"es5-shim": "~4.1.10", "es5-shim": "~4.1.10",
"angular-mocks": "1.3.20", "angular-mocks": "1.4.x",
"angular-route": "1.3.20", "angular-route": "1.4.x",
"angular-resource": "1.3.20", "angular-resource": "1.4.x",
"angular-cookies": "1.3.20", "angular-cookies": "1.4.x",
"angular-bootstrap": "0.13.1", "angular-bootstrap": "0.13.1",
"font-awesome": "4.3.0", "font-awesome": "4.3.0",
"angular-schema-form": "0.8.3", "angular-schema-form": "0.8.3",
...@@ -24,6 +24,6 @@ ...@@ -24,6 +24,6 @@
"angular-gettext": "2.1.0" "angular-gettext": "2.1.0"
}, },
"resolutions": { "resolutions": {
"angular": "1.3.20" "angular": "1.4.7"
} }
} }
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