Commit 47d06718 authored by Evren Kutar's avatar Evren Kutar

Merge branch '#11dashboard_new'

parents 70bf9c58 8ac44d4f
......@@ -18,6 +18,22 @@ body {
background-color:#999;
}
.badge {
border-radius: 100%;
width: 22px;
height: 22px;
padding: 0;
position: absolute;
z-index: 1;
line-height: 19px;
top: 4px;
left: 2px;
background-color: rgba(220, 112, 0, 1);
border: 2px solid #a61229;
font-family: 'robotomedium';
font-weight: normal;
}
.form-control {
box-shadow:none;
border-radius:0;
......@@ -485,7 +501,7 @@ select {
width: 100%;
max-height: calc(85% - 139px);
background: #fff;
display:none;
/*display:none;*/ /** angular template will hndle this */
}
.sidebar-person-info .identity {
......@@ -1592,3 +1608,31 @@ table.dataTable thead .sorting:after {
background-size: 100px 100px;
}
/* page transitions */
.slide {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
.slide.ng-enter,
.slide.ng-leave {
-webkit-transition: all 1s ease;
transition: all 1s ease;
}
.slide.ng-enter {
left: 100%;
}
.slide.ng-enter-active {
left: 0;
}
.slide.ng-leave {
left: 0;
}
.slide.ng-leave-active {
left: -100%;
}
/* end page transitions */
......@@ -20,6 +20,7 @@ var app = angular.module(
'ulakbus.auth',
'ulakbus.error_pages',
'ulakbus.crud',
'ulakbus.wf',
'ulakbus.version',
//'schemaForm',
'gettext',
......@@ -44,7 +45,9 @@ var app = angular.module(
var urlfromqstr = location.href.split('?')[1].split('=')[1];
backendurl = decodeURIComponent(urlfromqstr.replace(/\+/g, " "));
document.cookie = "backendurl="+backendurl;
window.location.href = window.location.href.split('?')[0];
}
return {url: backendurl};
})()).
/**
......
'use strict';
app.config(['$routeProvider', function ($routeProvider) {
app.config(['$routeProvider', function ($routeProvider, $route) {
$routeProvider
.when('/login', {
templateUrl: 'components/auth/login.html',
......@@ -10,30 +10,26 @@ app.config(['$routeProvider', function ($routeProvider) {
templateUrl: 'components/dashboard/dashboard.html',
controller: 'DashCtrl'
})
// .when('/500', {
// templateUrl: 'components/uitemplates/500.html',
// controller: '500Ctrl'
// })
// .when('/404', {
// templateUrl: 'components/uitemplates/404.html',
// controller: '404Ctrl'
// })
.when('/crud/:model/add', {
.when('/crud/add/:model/:param/:id', {
templateUrl: 'components/crud/templates/add.html',
controller: 'CRUDAddEditCtrl'
})
.when('/crud/:model/edit/:id', {
.when('/crud/edit/:model/:param/:id/:key', {
templateUrl: 'components/crud/templates/add.html',
controller: 'CRUDAddEditCtrl'
})
.when('/crud/:model', {
.when('/crud/:model/:param/:id', {
templateUrl: 'components/crud/templates/list.html',
controller: 'CRUDListCtrl'
})
.when('/crud/:model/:id', {
.when('/crud/detail/:model/:param/:id/:key', {
templateUrl: 'components/crud/templates/show.html',
controller: 'CRUDShowCtrl'
})
.when('/:model/', {
templateUrl: 'components/wf/templates/add.html',
controller: 'WFAddEditCtrl'
})
.otherwise({redirectTo: '/dashboard'});
}])
.run(function ($rootScope) {
......
......@@ -12,7 +12,6 @@ auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Gener
$scope.url = 'login';
$scope.form_params = {};
$scope.form_params['clear_wf'] = 1;
// todo: change simple login when api ready
Generator.get_form($scope).then(function(data){
$scope.form = [
{ key: "username", type: "string", title: "Kullanıcı Adı"},
......@@ -32,80 +31,4 @@ auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Gener
console.log("not valid");
}
}
});
auth.factory('LoginService', function ($http, $rootScope, $location, $log, $cookies, $window, Session, RESTURL) {
var loginService = {};
loginService.login = function (url, credentials) {
credentials = {login_crd: credentials, cmd: "do"};
return $http
.post(RESTURL.url + url, credentials)
.success(function (data, status, headers, config) {
//$window.sessionStorage.token = data.token;
//$rootScope.loggedInUser = true;
})
.error(function (data, status, headers, config) {
// Erase the token if the user fails to log in
//delete $window.sessionStorage.token;
// Handle login errors here
return data;
});
//.then(function (res) {
// $log.info(res.data[0]);
// res.data = res.data[0];
// if (res.data.success) {
// $rootScope.loggedInUser = true;
// $location.path("/dashboard");
// var session = Session.create(res.data.id, res.data.user.id,
// res.data.user.role);
// $log.info(session);
// $cookies.put('sessionId', 123456);
// console.log($cookies.getAll());
// return res.data.user;
// }
//});
};
loginService.logout = function() {
$http.post(RESTURL.url + 'logout', {}).then(function(){
$rootScope.loggedInUser = false;
$location.path("/login");
});
};
loginService.isAuthenticated = function () {
return !!Session.userId;
};
loginService.isAuthorized = function (authorizedRoles) {
if (!angular.isArray(authorizedRoles)) {
authorizedRoles = [authorizedRoles];
}
return (loginService.isAuthenticated() &&
loginService.indexOf(Session.userRole) !== -1);
};
loginService.isValidEmail = function (email) {
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return re.test(email);
};
return loginService;
});
// TODO: initial service not working!!
auth.service('Session', function () {
this.create = function (sessionId, userId, userRole) {
this.id = sessionId;
this.userId = userId;
this.userRole = userRole;
};
this.destroy = function () {
this.id = null;
this.userId = null;
this.userRole = null;
};
});
\ No newline at end of file
......@@ -17,10 +17,10 @@ var crud = angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formSe
*/
crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams) {
$scope.url = 'crud';
$scope.form_params = {'model': $routeParams.model};
if ($routeParams.id) {
$scope.form_params['object_id'] = $routeParams.id;
$scope.url = 'crud/';
$scope.form_params = {'model': $routeParams.model, param: $routeParams.param, id: $routeParams.id};
if ($routeParams.key) {
$scope.form_params['object_id'] = $routeParams.key;
$scope.form_params['cmd'] = 'edit';
}
else {
......@@ -37,11 +37,10 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
if (form.$valid) {
Generator.submit($scope)
.success(function(data){
debugger;
$location.path('/crud/'+$scope.form_params.model).search(data);
.success(function (data) {
$location.path('/crud/' + $scope.form_params.model).search(data);
})
.error(function(data){
.error(function (data) {
$scope.message = data.title;
});
}
......@@ -54,10 +53,10 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
*/
crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeParams) {
$scope.url = 'crud';
$scope.form_params = {"model": $routeParams.model};
$scope.url = 'crud/';
$scope.form_params = $routeParams;
if ($routeParams.nobjects){
if ($routeParams.nobjects) {
$scope.nobjects = $routeParams.nobjects;
$scope.model = $routeParams.model;
} else {
......@@ -73,21 +72,33 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
/**
* CRUD Show Controller
*/
crud.controller('CRUDShowCtrl', function ($scope, $rootScope, Generator, $routeParams) {
$scope.url = 'crud';
$scope.form_params = {"object_id": $routeParams.id, "cmd": "show", "model": $routeParams.model};
// call generator's get_single_itemfunc
crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generator, $routeParams) {
$scope.url = 'crud/';
$scope.form_params = {
"id": $routeParams.id,
"object_id": $routeParams.key,
"cmd": "show",
param: $routeParams.param,
"model": $routeParams.model
};
// call generator's get_single_item func
Generator.get_single_item($scope).then(function (res) {
console.log(res.data.nobjects);
// if no data to show redirect to add/edit view
//if (res.data.nobjects[0] === "-1") {
// $location.path('crud/' + $scope.form_params.model + '/' + $scope.form_params.param + '/' + $scope.form_params.object_id + '/edit');
//}
$scope.listobjects = {};
$scope.object = res.data.object;
angular.forEach($scope.object, function (value, key) {
if(typeof value == 'object'){
if (typeof value == 'object') {
$scope.listobjects[key] = value;
delete $scope.object[key];
}
});
}); debugger;
$scope.model = $routeParams.model;
})
});
});
\ No newline at end of file
<h1>{{ schema.title }}</h1>
<form id="formgenerated" name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model"></form>
<form id="formgenerated" name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(formgenerated)"></form>
<div ng-repeat="node in Node">
<h3>{{ node.title }}
......
<div class="starter-template">
<h1>{{model}} <a href="#/crud/{{model}}/add"><button type="button" class="btn btn-primary">Ekle</button></a></h1>
<h1>{{model}}
<a href="#/crud/add/{{model}}/{{form_params.param}}/{{form_params.id}}">
<button type="button" class="btn btn-primary">Ekle</button>
</a>
</h1>
<div class="row" ng-if="!nobjects[1]">
<div class="col-md-12">
<p class="no-content">Listelenecek içerik yok.</p>
......@@ -29,15 +33,17 @@
</td>
<th scope="row" style="text-align:center">{{$index}}</th>
<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/detail/{{model}}/{{form_params.param}}/{{form_params.id}}/{{object[0]}}">{{object[1]}}</a>
</td>
<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">{{object[key]}}</a>
<a ng-href="#/crud/detail/{{model}}/{{form_params.param}}/{{form_params.id}}/{{object[0]}}"
ng-if="$index==1">{{object[key]}}</a>
<span ng-if="$index!=1">{{object[key]}}</span>
</td>
<td>
<a ng-href="#/crud/{{model}}/edit/{{object[0]}}">Edit</a><br>
<a ng-href="#/crud/edit/{{model}}/{{form_params.param}}/{{form_params.id}}/{{object[0]}}">Edit</a>
<br>
</td>
</tr>
</tbody>
......
This diff is collapsed.
......@@ -9,11 +9,16 @@
angular.module('ulakbus.dashboard', ['ngRoute'])
.controller('DashCtrl', function ($scope, $rootScope, $timeout, $http, RESTURL) {
.controller('DashCtrl', function ($scope, $rootScope, $timeout, $http, $cookies, RESTURL) {
$scope.section = function (section_index) {
$rootScope.section = section_index;
};
// to show search box based on authz
$scope.$on("authz", function (event, data) {
$scope.menuitems = data;
});
$scope.student_kw = "";
$scope.staff_kw = "";
......@@ -22,102 +27,65 @@ angular.module('ulakbus.dashboard', ['ngRoute'])
$scope.search = function (where) {
$timeout(function () {
if (where === 'Personel') {
// if input length greater than 3 search for the value
if ($scope.staff_kw.length > 3) {
$scope.staffs = $scope.getItems(where, $scope.staff_kw);
if (where === 'personel') {
// if input length greater than 2 search for the value
if ($scope.staff_kw.length > 2) {
$scope.getItems(where, $scope.staff_kw).success(function (data) {
$scope.staffs = data.results;
});
}
}
if (where === 'Ogrenci') {
if ($scope.student_kw.length > 3) {
$scope.students = $scope.getItems(where, $scope.student_kw);
if (where === 'ogrenci') {
if ($scope.student_kw.length > 2) {
$scope.getItems(where, $scope.student_kw).success(function (data) {
$scope.students = data.results;
})
}
}
});
};
$scope.getItems = function (where, params) {
$http.post(RESTURL.url + where, {"query": params})
.success(function (data) {
return data;
});
$scope.getItems = function (where, what) {
return $http.get(RESTURL.url + 'ara/' + where + '/' + what);
};
$scope.select = function (who) {
$rootScope.who = who;
// todo: get 'who's related transactions and manipulate sidebar menu
$scope.select = function (who, type) {
$rootScope.selectedUser = {name: who[0], tcno: who[1], key: who[2]};
// get 'who's related transactions and manipulate sidebar menu
$rootScope.$broadcast("menuitems", type);
// save selected user and type to cookie
// its a development issue and will be deleted todo: remove at production
//$cookies.put("selectedUserName", who[0]);
//$cookies.put("selectedUserTcNo", who[1]);
//$cookies.put("selectedUserKey", who[2]);
//$cookies.put("selectedUserType", type);
};
// 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;
// }
//};
// if selected user in cookie, set selectedUser
//if ($cookies.getAll()["selectedUser"]) {
// $rootScope.selectedUser = {name: $cookies.get("selectedUserName"), tcno: $cookies.get("selectedUserTcNo"), key: $cookies.get("selectedUserKey")};
//}
$scope.$on("notifications", function (event, data) {
$scope.notifications = data;
});
})
//.directive('sidebar', ['$location', function () {
// return {
// templateUrl: 'shared/templates/directives/sidebar.html',
// restrict: 'E',
// replace: true,
// scope: {},
// controller: function ($scope, $rootScope, $http, RESTURL, $location, $timeout) {
//
//
// }
// };
//}]);
.directive('sidebarNotifications', function () {
return {
templateUrl: 'shared/templates/directives/sidebar-notification.html',
restrict: 'E',
replace: true,
link: function ($scope) {
// sidebar notifications from rootScope broadcast
//$scope.$on("notifications", function (event, data) {
// $scope.notifications = data;
//});
}
}
});
......@@ -29,11 +29,11 @@ describe('dashboard controller module', function () {
expect($controller).toBeDefined();
}));
it('should define section', function() {
var $scope = {};
var controller = $controller('DashCtrl', { $scope: $scope });
$scope.section('test_section');
expect($rootScope.section).toBe('test_section');
});
//it('should define section', function() {
// var $scope = {};
// var controller = $controller('DashCtrl', { $scope: $scope });
// $scope.section('test_section');
// expect($rootScope.section).toBe('test_section');
//});
});
});
\ No newline at end of file
......@@ -9,11 +9,11 @@
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/500', {
.when('/error/500', {
templateUrl: 'components/error_pages/500.html',
controller: '500Ctrl'
})
.when('/404', {
.when('/error/404', {
templateUrl: 'components/error_pages/404.html',
controller: '404Ctrl'
});
......
<h1>{{ schema.title }}</h1>
<form id="formgenerated" name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model"
ng-submit="onSubmit(formgenerated)"></form>
<div ng-repeat="node in Node">
<h3>{{ node.title }}
<span ng-if="node.lengthModels < 1">
<a href="javascript:void(0);" modal-for-nodes="{{node.schema.model_name}},Node">
<i class="fa fa-plus-circle fa-fw"></i>
</a>
</span>
</h3>
<div class="node-table">
<ng-include src="'shared/templates/nodeTable.html'"></ng-include>
</div>
<hr>
</div>
<div ng-repeat="node in ListNode">
<h3>{{ node.title }}
<span>
<a href="javascript:void(0);" modal-for-nodes="{{node.schema.model_name}},ListNode,add">
<i class="fa fa-plus-circle fa-fw"></i>
</a>
</span>
</h3>
<div class="list-node-table">
<ng-include src="'shared/templates/nodeTable.html'"></ng-include>
</div>
<hr>
</div>
<!--<button id="submitbutton" type="button" class="btn btn-primary" ng-click="onSubmit(formgenerated)">Kaydet</button>-->
<!-- <button type="button" class="btn btn-warning">Düzenle</button> todo: make it conditional -->
<!-- <button type="button" class="btn btn-danger">İptal</button> todo: turn back to previous page -->
\ No newline at end of file
<div ng-app="ulakbus.crud">
<div class="col-md-6">
<h1>{{ schema.title }}</h1>
<form name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(formgenerated)"></form>
</div>
</div>
\ No newline at end of file
<div class="starter-template">
<h1>{{model}} <a href="#/crud/{{model}}/add"><button type="button" class="btn btn-primary">Ekle</button></a></h1>
<div class="row" ng-if="!nobjects[1]">
<div class="col-md-12">
<p class="no-content">Listelenecek içerik yok.</p>
</div>
</div>
<div class="tablescroll" ng-if="nobjects[1]">
<table class="table table-bordered" style="background-color:#fff;">
<thead>
<tr>
<th colspan="2">
<label>
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
Hepsini Seç
</label>
</th>
<th ng-repeat="value in nobjects[0]" ng-if="nobjects[0]!='-1'">{{ value }}</th>
<th ng-if="nobjects[0]=='-1'">{{ model }}</th>
<th>action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="object in nobjects" ng-if="$index>0">
<td width="60">
<label>
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
</label>
</td>
<th scope="row" style="text-align:center">{{$index}}</th>
<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>
</td>
<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">{{object[key]}}</a>
<span ng-if="$index!=1">{{object[key]}}</span>
</td>
<td>
<a ng-href="#/crud/{{model}}/edit/{{object[0]}}">Edit</a><br>
</td>
</tr>
</tbody>
</table>
</div>
<br/>
<hr/>
<div class="btn-group" ng-if="nobjects[1]">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
İşlemler <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="">İşlem 1</a></li>
<li><a href="">İşlem 2</a></li>
<li><a href="">İşlem 3</a></li>
<li role="separator" class="divider"></li>
<li><a href="">İşlem 4</a></li>
</ul>
</div>
<hr>
</div>
\ No newline at end of file
<!--<div class="starter-template">-->
<!--<h1>{{model}}</h1>-->
<!--<p ng-repeat="(key, value) in object"><span class="col-md-3">{{ key }}:</span>{{value}}</p>-->
<!--</div>-->
<div class="starter-template">
<div class="personnel-info-container">
<div class="personnel-info-left">
<!--<div class="generic-profile-picture">-->
<!--<img src="../../img/sample-profile-pic.jpg" />-->
<!--</div>-->
<div class="info-block">
<div class="info-block-header">
<h1>{{model}}</h1>
</div>
<!-- end of info-block-header -->
<div class="info-block-body" ng-repeat="(key, value) in object">
<dl class="dl-horizontal">
<dt>{{ key }}</dt>
<dd>{{value}}</dd>
</dl>
</div>
<!-- end of info-block-body -->
</div>
<!--<ul>-->
<!--<li ng-repeat="(key, value) in object"><span class="col-md-3">{{ key }}:</span>{{value}}</li>-->
<!--<li>Pozisyon</li>-->
<!--<li><i class="fa fa-phone"></i> (+90) 123 456 7890</li>-->
<!--<li><i class="fa fa-envelope"></i> samplemail@mail.com</li>-->
<!--<li><i class="fa fa-map-marker"></i> Gülbahçe Mah. İzmir Teknoloji Geliştirme Bölgesi A9 Blok 215/A IYTE Campus, URLA/IZMIR</li></li>-->
<!--</ul>-->
</div>
<!-- end of personnel-info-left -->
<div class="personnel-info-right">
<div class="info-block" ng-repeat="(key, value) in listobjects">
<div class="info-block-header">
<h2>{{key}}</h2>
</div>
<!-- end of info-block-header -->
<div class="info-block-body" ng-repeat="(k, v) in value">
<dl class="dl-horizontal">
<dt>{{k}}</dt>
<dd>{{v}}</dd>
</dl>
</div>
<!-- end of info-block-body -->
</div>
<!-- end of info block -->
<!-- end of info block -->
</div>
<!-- personnel-info-left -->
</div>
<!-- end of personnel-info-container -->
</div>
\ No newline at end of file
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
'use strict';
var wf = angular.module('ulakbus.wf', ['ui.bootstrap', 'schemaForm', 'formService']);
/**
* CRUDAddEditCtrl is a controller
* which provide a form with form generator.
*/
wf.controller('WFAddEditCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams) {
$scope.url = ""; debugger;
$scope.form_params = {'model': $routeParams.model};
//if ($routeParams.id) {
// $scope.form_params['object_id'] = $routeParams.id;
// $scope.form_params['cmd'] = 'edit';
//}
//else {
// $scope.form_params['cmd'] = 'add';
//}
// get form with generator
if ($routeParams.model) {
Generator.get_form($scope);
}
$scope.onSubmit = function (form) {
$scope.$broadcast('schemaFormValidate');
if (form.$valid) {
Generator.submit($scope)
.success(function(data){
})
.error(function(data){
//$scope.message = data.title;
});
}
};
});
/**
* WorkFlow List Controller
*/
wf.controller('WFListCtrl', function ($scope, $rootScope, Generator, $routeParams) {
$scope.url = "";
$scope.form_params = $routeParams;
if ($routeParams.nobjects){
$scope.nobjects = $routeParams.nobjects;
$scope.model = $routeParams.model;
} else {
// call generator's get_list func
Generator.get_list($scope)
.then(function (res) {
$scope.nobjects = res.data.nobjects;
$scope.model = $routeParams.model;
});
}
});
/**
* WorkFlow Show Controller
*/
wf.controller('WFShowCtrl', function ($scope, $rootScope, Generator, $routeParams) {
$scope.url = "";
$scope.form_params = {"object_id": $routeParams.id, "cmd": "show", "model": $routeParams.model};
// call generator's get_single_itemfunc
Generator.get_single_item($scope).then(function (res) {
$scope.listobjects = {};
$scope.object = res.data.object;
angular.forEach($scope.object, function (value, key) {
if(typeof value == 'object'){
$scope.listobjects[key] = value;
delete $scope.object[key];
}
});
$scope.model = $routeParams.model;
})
});
\ No newline at end of file
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
'use strict';
describe('crud controller module', function () {
beforeEach(module('ulakbus'));
beforeEach(module('ulakbus.crud'));
var $controller;
beforeEach(inject(function (_$controller_) {
$controller = _$controller_;
}));
describe('crud add controller', function() {
it('should get form', function() {
var $scope = {};
var controller = $controller('CRUDAddEditCtrl', { $scope: $scope });
expect($scope).not.toEqual(null);
});
});
// todo: chack if needed for these tests
// describe('crud list controller', function() {
// it('should get list', function() {
// var $scope = {};
// var controller = $controller('CRUDListCtrl', { $scope: $scope });
// expect($scope).not.toEqual(null);
// });
// });
// describe('crud show controller', function() {
// it('should get single item', function() {
// var $scope = {};
// var controller = $controller('CRUDShowCtrl', { $scope: $scope });
// expect($scope).not.toEqual(null);
// });
// });
describe('crud controller', function () {
it('should have CRUDAddEditCtrl', inject(function ($controller) {
expect($controller).toBeDefined();
}));
it('should have CRUDListCtrl', inject(function ($controller) {
expect($controller).toBeDefined();
}));
it('should have CRUDShowCtrl', inject(function ($controller) {
expect($controller).toBeDefined();
}));
});
});
\ No newline at end of file
......@@ -13,6 +13,7 @@
<title>ULAKBUS</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/img/favicon.ico">
<link rel="stylesheet" href="bower_components/angular-bootstrap/ui-bootstrap-csp.css">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="app.css">
......@@ -100,6 +101,7 @@
<script src="components/auth/auth_service.js"></script>
<script src="components/dashboard/dashboard_controller.js"></script>
<script src="components/crud/crud_controller.js"></script>
<script src="components/wf/wf_controller.js"></script>
<script src="components/uitemplates/uitemplates.js"></script>
<script src="components/error_pages/error_controller.js"></script>
<script src="components/version/interpolate-filter.js"></script>
......
......@@ -13,6 +13,7 @@
<title>ULAKBUS</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/img/favicon.ico">
<!-- @if NODE_ENV == 'DEVELOPMENT' -->
<link rel="stylesheet" href="bower_components/angular-bootstrap/ui-bootstrap-csp.css">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
......@@ -108,6 +109,7 @@
<script src="components/auth/auth_service.js"></script>
<script src="components/dashboard/dashboard_controller.js"></script>
<script src="components/crud/crud_controller.js"></script>
<script src="components/wf/wf_controller.js"></script>
<script src="components/uitemplates/uitemplates.js"></script>
<script src="components/error_pages/error_controller.js"></script>
<script src="components/version/interpolate-filter.js"></script>
......
......@@ -20,6 +20,7 @@ var app = angular.module(
'ulakbus.auth',
'ulakbus.error_pages',
'ulakbus.crud',
'ulakbus.wf',
'ulakbus.version',
//'schemaForm',
'gettext',
......@@ -49,7 +50,9 @@ var app = angular.module(
var urlfromqstr = location.href.split('?')[1].split('=')[1];
backendurl = decodeURIComponent(urlfromqstr.replace(/\+/g, " "));
document.cookie = "backendurl="+backendurl;
window.location.href = window.location.href.split('?')[0];
}
return {url: backendurl};
})()).
/**
......
......@@ -26,19 +26,26 @@ app.directive('logout', function ($http, $location, RESTURL) {
* headerNotification directive for header
*/
app.directive('headerNotification', function ($http, $interval, RESTURL) {
app.directive('headerNotification', function ($http, $rootScope, $interval, RESTURL) {
return {
templateUrl: 'shared/templates/directives/header-notification.html',
restrict: 'E',
replace: true,
//link: function ($scope) {
// $interval(function () {
// // todo: change url to backend
// $http.post(RESTURL+"crud").success(function (data) {
// $scope.notifications = data;
// });
// }, 15000);
//}
link: function ($scope) {
$interval(function () {
// ignore loading bar here
$http.get(RESTURL.url+"notify", {ignoreLoadingBar: true}).success(function (data) {
// notification categories:
// 1: tasks, 2: messages, 3: announcements, 4: recents
$scope.notifications = {1: [], 2: [], 3: [], 4: []};
angular.forEach(data.notifications, function (value, key) {
$scope.notifications[value.type].push(value);
});
$rootScope.$broadcast("notifications", $scope.notifications);
});
}, 5000);
}
};
});
......@@ -47,28 +54,34 @@ app.directive('headerNotification', function ($http, $interval, RESTURL) {
* toggle collapses sidebar menu when clicked menu button
*/
app.directive('collapseMenu', function () {
app.directive('collapseMenu', function ($timeout) {
return {
templateUrl: 'shared/templates/directives/menuCollapse.html',
restrict: 'E',
replace: true,
link: function ($scope) {
$scope.collapsed = false;
scope: {},
controller: function ($scope, $rootScope) {
$rootScope.collapsed = false;
$rootScope.sidebarPinned = false;
$scope.collapseToggle = function () {
if ($scope.collapsed === false) {
jQuery("span.menu-text").css("display" , "none");
if ($rootScope.collapsed === false) {
jQuery(".sidebar").css("width" , "62px");
jQuery(".manager-view").css("z-index" , "9999").css("width" , "calc(100% - 62px)");
jQuery(".sidebar footer").css("display" , "none");
$scope.collapsed = true;
jQuery(".manager-view").css("width" , "calc(100% - 62px)");
$rootScope.collapsed = true;
$rootScope.sidebarPinned = false;
} else {
jQuery("span.menu-text").fadeIn(400);
jQuery(".sidebar").css("z-index" , "0").css("width" , "250px");
jQuery("span.menu-text, span.arrow, .sidebar footer").fadeIn(400);
jQuery(".sidebar").css("width" , "250px");
jQuery(".manager-view").css("width" , "calc(100% - 250px)");
jQuery(".sidebar footer").fadeIn(400);
$scope.collapsed = false;
$rootScope.collapsed = false;
$rootScope.sidebarPinned = true;
}
};
$timeout(function(){
$scope.collapseToggle();
});
}
};
});
......@@ -107,10 +120,26 @@ app.directive('headerBreadcrumb', function () {
};
});
/**
* selected user directive
*/
app.directive('selectedUser', function () {
return {
templateUrl: 'shared/templates/directives/selected-user.html',
restrict: 'E',
replace: false,
link: function ($scope, $rootScope) {
$scope.selectedUser = $rootScope.selectedUser;
}
};
});
/**
* sidebar directive
* changes breadcrumb when an item selected
* consists of menu items of related user or transaction
* controller communicates with dashboard controller to shape menu items and authz
*/
app.directive('sidebar', ['$location', function () {
......@@ -119,31 +148,57 @@ app.directive('sidebar', ['$location', function () {
restrict: 'E',
replace: true,
scope: {},
controller: function ($scope, $rootScope, $http, RESTURL, $location, $timeout) {
$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'];
}
});
controller: function ($scope, $rootScope, $cookies, $route, $http, RESTURL, $location, $timeout) {
var sidebarmenu = $('#side-menu');
sidebarmenu.metisMenu();
$http.get(RESTURL.url + 'menu/')
.success(function (data) {
$scope.allMenuItems = angular.copy(data);
// broadcast for authorized menu items, consume in dashboard
$rootScope.$broadcast("authz", data);
$scope.menuItems = {"other": $scope.allMenuItems.other};
// if selecteduser on cookie then add related part to the menu
//if ($cookies.get("selectedUserType")) {
// $scope.menuItems[$cookies.get("selectedUserType")] = $scope.allMenuItems[$cookies.get("selectedUserType")];
//}
$timeout(function(){sidebarmenu.metisMenu()});
});
// changing menu items by listening for broadcast
$scope.$on("menuitems", function (event, data) {
$scope.menuItems[data] = $scope.allMenuItems[data];
$scope.menuItems["other"] = $scope.allMenuItems['other'];
$timeout(function(){sidebarmenu.metisMenu()});
});
$scope.openSidebar = function () {
if ($rootScope.sidebarPinned === false) {
jQuery("span.menu-text, span.arrow, .sidebar footer, #side-menu").fadeIn(400);
jQuery(".sidebar").css("width" , "250px");
jQuery(".manager-view").css("width" , "calc(100% - 250px)");
$rootScope.collapsed = false;
}
};
$scope.closeSidebar = function () {
if ($rootScope.sidebarPinned === false) {
jQuery(".sidebar").css("width" , "62px");
jQuery(".manager-view").css("width" , "calc(100% - 62px)");
$rootScope.collapsed = true;
}
};
$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();
});
}
});
......@@ -162,9 +217,13 @@ app.directive('sidebar', ['$location', function () {
};
// breadcrumb function changes breadcrumb items and itemlist must be list
$scope.breadcrumb = function (itemlist) {
$scope.breadcrumb = function (itemlist, $event) {
//if ($event.target.href==location.href) {
// $route.reload();
//}
$rootScope.breadcrumblinks = itemlist;
// showSaveButton is used for to show or not to show save button on top of the page
// todo: remove button
$rootScope.showSaveButton = false;
};
......@@ -176,7 +235,6 @@ app.directive('sidebar', ['$location', function () {
$scope.multiCollapseVar = y;
}
};
}
};
}]);
......
<ul class="nav navbar-top-links navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">
<div class="badge" ng-if="notifications[2].length > 0">{{notifications[2].length}}</div>
<i class="fa fa-envelope fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-messages">
......@@ -28,6 +29,7 @@
<!-- /.dropdown -->
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">
<div class="badge" ng-if="notifications[1].length > 0">{{notifications[1].length}}</div>
<i class="fa fa-tasks fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<!--<ul class="dropdown-menu dropdown-tasks">-->
......@@ -59,6 +61,7 @@
<!-- /.dropdown -->
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">
<div class="badge" ng-if="notifications[3].length > 0">{{notifications[3].length}}</div>
<i class="fa fa-bell fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<!--<ul class="dropdown-menu dropdown-alerts">-->
......
<div class="manager-view-header" ng-class="{hidden: $root.loggedInUser != true}">
<div class="manager-view-header">
<div class="clearfix">
<header-breadcrumb></header-breadcrumb>
<loaderdiv><div></div></loaderdiv>
<!--<div class="loader">Loading...</div>-->
<selected-user class="pull-right"></selected-user>
</div>
<!--<div id="header-buttons" ng-class="{hidden: $root.showSaveButton != true}">-->
<!--<button type="button" class="btn btn-primary" ng-click="triggerSubmit()">Kaydet</button>-->
......
<a href="#" data-toggle="tooltip" data-placement="bottom" title="Tooltip on left">İşlem: {{$root.selectedUser.name}}</a>
<!-- sidebar-person-info -->
<!--<div class="tooltip" role="tooltip">-->
<!--&lt;!&ndash;<button class="btn btn-primary close-sidebar-person-info">Profili Kapat</button>&ndash;&gt;-->
<!--<div class="identity">-->
<!--<div class="identity-header clearfix">-->
<!--<img src="../../../img/sample-profile-pic.jpg">-->
<!--<div class="pull-left">-->
<!--<p class="identity-name">{{$root.selectedUser.name}}</p>-->
<!--&lt;!&ndash;<p class="identity-surname">Öğümsöğütlü</p>&ndash;&gt;-->
<!--</div>-->
<!--</div>-->
<!--&lt;!&ndash; end of identity-header &ndash;&gt;-->
<!--<div class="identity-info">-->
<!--<div class="clearfix">-->
<!--<span class="fa fa-phone"></span> <div>539 241 65 08</div>-->
<!--</div>-->
<!--<div class="clearfix">-->
<!--<span class="fa fa-envelope"></span>-->
<!--<div>erkanogum@gmail.com</div>-->
<!--</div>-->
<!--<div class="clearfix">-->
<!--<span class="fa fa-home"></span>-->
<!--<div>İşçi Blokları Mah. 1524. sokak B Blok 6. Kat A Kanat 27 numara</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--&lt;!&ndash; end of identity &ndash;&gt;-->
<!--<div class="person-actions">-->
<!--<ul>-->
<!--<li><a href="#"><span class="fa fa-trash"></span> Action 1</a></li>-->
<!--<li><a href="#"><span class="fa fa-trash"></span> Action 2</a></li>-->
<!--<li><a href="#"><span class="fa fa-trash"></span> Action 3</a></li>-->
<!--<li><a href="#"><span class="fa fa-trash"></span> Action 4</a></li>-->
<!--<li><a href="#"><span class="fa fa-trash"></span> Action 5</a></li>-->
<!--</ul>-->
<!--</div>-->
<!--&lt;!&ndash; end of person-actions &ndash;&gt;-->
<!--</div>-->
<!-- end of sidebar-person-info -->
\ No newline at end of file
<div class="right-sidebar">
<div class="right-sidebar-box">
<div class="right-sidebar-messages">
<div class="right-sidebar-title clearfix">
<h3>Mesajlar</h3>
<span><a href="javascript:void(0)">Tüm Mesajlar</a></span>
</div>
<!-- end of right-sidebar-title -->
<div class="right-sidebar-message-block" ng-repeat="notify in notifications[2] | limitTo:5">
<a class="clearfix" href="javascript:void(0)">
<img src="../../../img/sample-profile-pic.jpg">
<div class="right-sidebar-message-content">
<div>{{notify.title}}</div>
<div>{{notify.body}}</div>
<div>16:05</div>
</div>
<!-- end of right-sidebar-message-content -->
</a>
</div>
<!-- end of right-sidebar-message-block -->
</div>
<!-- end of right-sidebar-messages -->
</div>
<!-- end of right-sidebar-box -->
<div class="right-sidebar-box">
<div class="right-sidebar-tasks">
<div class="right-sidebar-title clearfix">
<h3>Görevler</h3>
<span><a href="javascript:void(0)">Tüm Görevler</a></span>
</div>
<!-- end of right-sidebar-title -->
<!--<div class="right-sidebar-task-block">-->
<!--<div class="task-type">Devam Eden Görevler</div>-->
<!--<a href="javascript:void(0)">-->
<!--<div class="task-title">Öğrenci Kayıt</div>-->
<!--<div class="progress">-->
<!--<div class="progress-bar" role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em; width:25%;">-->
<!--25%-->
<!--</div>-->
<!--</div>-->
<!--&lt;!&ndash; end of progress &ndash;&gt;-->
<!--</a>-->
<!--</div>-->
<!-- end of right-sidebar-task-block -->
<div class="right-sidebar-task-block">
<div class="task-type">Onay Bekleyen Görevler</div>
<a href="javascript:void(0)" ng-repeat="notify in notifications[1] | limitTo:5">
<div class="task-title">{{notify.title}}</div>
</a>
</div>
<!-- end of right-sidebar-task-block -->
</div>
<!-- end of right-sidebar-tasks -->
</div>
<!-- end of right-sidebar-box -->
<div class="right-sidebar-box">
<div class="right-sidebar-announcements">
<div class="right-sidebar-title clearfix">
<h3>Duyurular</h3>
<span><a href="javascript:void(0)">Tüm Duyurular</a></span>
</div>
<!-- end of right-sidebar-title -->
<div class="right-sidebar-announcement-block">
<a href="javascript:void(0)" ng-repeat="notify in notifications[3] | limitTo:5">{{notify.body}}</a>
</div>
<!-- end of right-sidebar-status-block -->
</div>
<!-- end of right-sidebar-status -->
</div>
<!-- end of right-sidebar-box -->
<div class="right-sidebar-box">
<div class="right-sidebar-last-actions">
<div class="right-sidebar-title clearfix">
<h3>Son İşlemler</h3>
<span><a href="javascript:void(0)">Tüm İşlemler</a></span>
</div>
<!-- end of right-sidebar-title -->
<div class="right-sidebar-last-action-block">
<a href="javascript:void(0)">Birinci dönem bitimine 10 gün kaldı.</a>
<a href="javascript:void(0)">Ders seçimi işlemleri xx tarihinde başlayacaktır.</a>
</div>
<!-- end of right-sidebar-status-block -->
</div>
<!-- end of right-sidebar-status -->
</div>
<!-- end of right-sidebar-box -->
</div>
<!-- end of right-sidebar -->
\ No newline at end of file
<div class="navbar-default sidebar" role="navigation">
<div class="navbar-default sidebar" role="navigation" ng-mouseenter="openSidebar()" ng-mouseleave="closeSidebar()">
<div class="brand">
<a href="" class="logo"><img src="/img/brand-logo.png" /></a>
</div>
<div class="sidebar-nav navbar-collapse">
<ul class="nav in" id="side-menu" ng-class="{hidden: $root.loggedInUser != true}">
<!--<sidebar-search></sidebar-search>-->
<li ui-sref-active="active">
<a href="#/dashboard" ng-click="breadcrumb(['Panel'])"><i class="fa fa-dashboard fa-fw"></i>
<span class="menu-text">Panel</span>
<span class="menu-text" ng-class="{hidden: $root.collapsed}">Panel</span>
</a>
</li>
<li ng-repeat="(key, item) in menuItems" ng-class="{active: collapseVar == $index+1}">{{dropDown}}
<a href="" ng-click="check($index+1)"><i class="fa fa-wrench fa-fw"></i> {{ item[0] }}<span
class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li ng-repeat="(k, v) in item[1]"><a href="#/crud/{{v[1]}}"
ng-click="breadcrumb([item[0], v[0]])">{{v[0]}}</a></li>
<a href="" ng-click="check($index+1)">
<i class="fa fa-fw fa-cogs"
ng-class="{
'other': 'fa fa-fw fa-wrench',
'ogrenci': 'fa fa-fw fa-university',
'personel': 'fa fa-fw fa-users'}[key]"></i>
<span class="menu-text" ng-class="{hidden: $root.collapsed}">{{ key }}</span>
<span class="fa arrow" ng-class="{hidden: $root.collapsed}"></span>
</a>
<ul class="nav nav-second-level" ng-class="{hidden: $root.collapsed}">
<li ng-repeat="v in item">
<a ng-if="key == 'other'" ng-href="#{{v.url}}/{{$root.selectedUser.key}}"
ng-click="breadcrumb([key, v.text], $event)">{{v.text}}</a>
<a ng-if="key == 'ogrenci' || key == 'personel'"
ng-href="#{{v.url}}/{{v.param}}/{{$root.selectedUser.key}}"
ng-click="breadcrumb([key, v.text], $event)">{{v.text}}</a>
</li>
</ul>
<!-- /.nav-second-level -->
</li>
</ul>
</div>
<!-- /.sidebar-collapse -->
<!-- sidebar-person-info -->
<div class="sidebar-person-info">
<button class="btn btn-primary close-sidebar-person-info">Profili Kapat</button>
<div class="identity">
<div class="identity-header clearfix">
<img src="../../../img/sample-profile-pic.jpg">
<div class="pull-left">
<p class="identity-name">Erkan</p>
<p class="identity-surname">Öğümsöğütlü</p>
</div>
</div>
<!-- end of identity-header -->
<div class="identity-info">
<div class="clearfix">
<span class="fa fa-phone"></span> <div>539 241 65 08</div>
</div>
<div class="clearfix">
<span class="fa fa-envelope"></span>
<div>erkanogum@gmail.com</div>
</div>
<div class="clearfix">
<span class="fa fa-home"></span>
<div>İşçi Blokları Mah. 1524. sokak B Blok 6. Kat A Kanat 27 numara</div>
</div>
</div>
</div>
<!-- end of identity -->
<div class="person-actions">
<ul>
<li><a href="#"><span class="fa fa-trash"></span> Action 1</a></li>
<li><a href="#"><span class="fa fa-trash"></span> Action 2</a></li>
<li><a href="#"><span class="fa fa-trash"></span> Action 3</a></li>
<li><a href="#"><span class="fa fa-trash"></span> Action 4</a></li>
<li><a href="#"><span class="fa fa-trash"></span> Action 5</a></li>
</ul>
</div>
<!-- end of person-actions -->
</div>
<!-- end of sidebar-person-info -->
<footer>
<footer ng-class="{hidden: $root.collapsed}">
<span>v <app-version></app-version> &copy; ZetaOps</span>
</footer>
</div>
This diff is collapsed.
......@@ -17,7 +17,7 @@ describe('form service module', function () {
it('should generate url', inject(['Generator',
function (Generator) {
expect(Generator.group).not.toBe(null);
var generated_url = Generator.makeUrl('test');
var generated_url = Generator.makeUrl({url: 'test', form_params: {}});
expect(generated_url).toEqual("http://api.ulakbus.net/test");
}])
);
......@@ -82,7 +82,8 @@ describe('form service module', function () {
},
model: {
email: 'test@test.com', id: 2, name: 'travolta'
}
},
form_params: {}
};
var form_json = {
......@@ -95,6 +96,7 @@ describe('form service module', function () {
}, required: [], type: 'object', title: 'servicetest'
},
model: {email: 'test@test.com', id: 2, name: 'travolta'},
form_params: {}
};
var form_generated = Generator.prepareFormItems(scope);
......@@ -168,7 +170,7 @@ describe('form service module', function () {
it('should get list',
inject(function (Generator, $httpBackend, RESTURL) {
$httpBackend.expectPOST(RESTURL.url + 'test', {cmd: 'list'})
$httpBackend.expectGET(RESTURL.url + 'test/personel')
.respond(200, {
items: {
"client_cmd": "list_objects",
......@@ -193,8 +195,8 @@ describe('form service module', function () {
}
});
var cred = {cmd: 'list'};
Generator.get_list({url: 'test', form_params: cred})
var cred = {cmd: 'list', model: "personel", object_id: "5821bc25a90aa1"};
Generator.get_list({url: 'test/', form_params: cred})
.then(function (data) {
expect(data.data.items.token).toEqual("0122b2843f504c15821bc25a90aa1370");
});
......@@ -206,7 +208,7 @@ describe('form service module', function () {
it('should get single item',
inject(function (Generator, $httpBackend, RESTURL) {
$httpBackend.expectPOST(RESTURL.url + 'test', {cmd: 'show'})
$httpBackend.expectPOST(RESTURL.url + 'test/personel?personel_id=123')
.respond(200, {
items: {
"client_cmd": "show_object",
......@@ -219,8 +221,8 @@ describe('form service module', function () {
}
});
var cred = {cmd: 'show'};
Generator.get_list({url: 'test', form_params: cred})
var cred = {cmd: 'show', model: 'personel', param: 'personel_id', id: '123'};
Generator.get_single_item({url: 'test/', form_params: cred})
.then(function (data) {
expect(data.data.items.token).toEqual("da73993f439549e7855fd82deafbbc99");
});
......@@ -232,14 +234,14 @@ describe('form service module', function () {
it('should submit form',
inject(function (Generator, $httpBackend, RESTURL) {
$httpBackend.expectPOST(RESTURL.url + 'student/add')
$httpBackend.expectPOST(RESTURL.url + 'student/add/testmodel')
.respond(200, {data: 'OK'});
var scope = {
model: {email: 'test@test.com'},
form_params: {cmd: 'add', model: 'testmodel'},
token: '123456',
url: 'student/add'
url: 'student/add/'
};
Generator.submit(scope)
.success(function(){
......
......@@ -10,7 +10,7 @@ app.config(['$httpProvider', function ($httpProvider) {
* the interceptor for all requests to check response
* 4xx - 5xx errors will be handled here
*/
$httpProvider.interceptors.push(function ($q, $rootScope, $location) {
$httpProvider.interceptors.push(function ($q, $rootScope, $location, $timeout) {
return {
'request': function (config) {
// todo: delete console logs
......@@ -46,10 +46,9 @@ app.config(['$httpProvider', function ($httpProvider) {
$location.reload();
}
if (rejection.status === 401) {
$location.path('/login');
if ($location.path() === "/login") {
console.log("show errors on login form");
} else {
$location.path('/login');
}
}
if (rejection.status === 403) {
......@@ -62,13 +61,11 @@ app.config(['$httpProvider', function ($httpProvider) {
}
if (rejection.status === 404) {
console.log(404);
$location.path("/404");
$location.path("/error/404");
}
// server 500 error returns with -1 on status.
//if (rejection.status === -1 && rejection.config.data.model) {
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">' +
......@@ -87,7 +84,8 @@ app.config(['$httpProvider', function ($httpProvider) {
'</div>' +
'</div>' +
'</div>' +
'</div>').modal()
'</div>').modal();
$location.path("/error/500");
}
return $q.reject(rejection);
}
......
......@@ -10,13 +10,14 @@
"json3": "~3.3.2",
"es5-shim": "~4.1.10",
"angular-mocks": "1.4.x",
"angular-animate": "1.4.x",
"angular-route": "1.4.x",
"angular-resource": "1.4.x",
"angular-cookies": "1.4.x",
"angular-bootstrap": "0.13.1",
"font-awesome": "4.3.0",
"angular-schema-form": "0.8.3",
"angular-loading-bar": "~0.7.0",
"angular-loading-bar": "~0.8.0",
"angular-ui-router": "~0.2.15",
"angular-toggle-switch": "~1.2.1",
"metisMenu": "~1.1.3",
......
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