Commit b14dd974 authored by Evren Kutar's avatar Evren Kutar

#34 client cmd command parse and redirect with data to controller

route updates [regex before static urls]
parent 58f7c699
......@@ -10,45 +10,56 @@ app.config(['$routeProvider', function ($routeProvider, $route) {
templateUrl: 'components/dashboard/dashboard.html',
controller: 'DashCtrl'
})
//.when('/crud/:model/:param/:id/add', {
// templateUrl: 'components/crud/templates/add.html',
// controller: 'CRUDAddEditCtrl'
//})
//.when('/crud/:model/:param/:id/edit/:key', {
// templateUrl: 'components/crud/templates/add.html',
// controller: 'CRUDAddEditCtrl'
//})
//.when('/crud/:model/:param/:id/list', {
// templateUrl: 'components/crud/templates/list.html',
// controller: 'CRUDListCtrl'
//})
//.when('/crud/:model/:param/:id/detail/:key', {
// templateUrl: 'components/crud/templates/show.html',
// controller: 'CRUDShowCtrl'
//})
.when('/dev/settings', {
templateUrl: 'components/devSettings/devSettings.html',
controller: 'DevSettingsCtrl'
})
.when('/debug/list', {
templateUrl: 'components/debug/debug.html',
controller: 'DebugCtrl'
})
// use crud without selected user
.when('/crud/:model/list', {
// important: regex urls must be defined later than static ones
.when('/:wf/', {
templateUrl: 'components/wf/templates/add.html',
controller: 'CRUDCtrl'
})
.when('/:wf/list', {
templateUrl: 'components/crud/templates/list.html',
controller: 'CRUDListCtrl'
})
.when('/crud/:model/add', {
.when('/:wf/add', {
templateUrl: 'components/crud/templates/add.html',
controller: 'CRUDAddEditCtrl'
})
.when('/crud/:model/edit/:key', {
.when('/:wf/edit/:key', {
templateUrl: 'components/crud/templates/add.html',
controller: 'CRUDAddEditCtrl'
})
.when('/crud/:model/detail/:key', {
.when('/:wf/detail/:key', {
templateUrl: 'components/crud/templates/show.html',
controller: 'CRUDShowCtrl'
})
// wf links just need model
.when('/:model/', {
.when('/:wf/:model', {
templateUrl: 'components/wf/templates/add.html',
controller: 'WFAddEditCtrl'
controller: 'CRUDCtrl'
})
.when('/:wf/:model/list', {
templateUrl: 'components/crud/templates/list.html',
controller: 'CRUDListCtrl'
})
.when('/:wf/:model/add', {
templateUrl: 'components/crud/templates/add.html',
controller: 'CRUDAddEditCtrl'
})
.when('/:wf/:model/edit/:key', {
templateUrl: 'components/crud/templates/add.html',
controller: 'CRUDAddEditCtrl'
})
.when('/:wf/:model/detail/:key', {
templateUrl: 'components/crud/templates/show.html',
controller: 'CRUDShowCtrl'
})
.otherwise({redirectTo: '/dashboard'});
}])
......
......@@ -9,48 +9,68 @@
var crud = angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService']);
/**
*
*/
crud.service('CrudUtility', function () {
return {
generateParam: function (scope, routeParams) {
// define api request url path
scope.url = routeParams.wf;
angular.forEach(routeParams, function (value, key) {
if (key.indexOf('_id') > -1) {
scope.param = key;
scope.param_id = value;
}
});
scope.form_params = {
model: routeParams.model,
param: scope.param,
id: scope.param_id,
wf: routeParams.wf,
object_id: routeParams.key
};
return scope;
},
listPageItems: function (scope, pageData) {
angular.forEach(['objects', 'model', 'addLink'], function (value, key) {
scope[value] = pageData[value];
});
}
}
});
/**
*
*/
crud.controller('CRUDCtrl', function ($scope, $routeParams, Generator, CrudUtility) {
CrudUtility.generateParam($scope, $routeParams);
Generator.get_wf($scope);
});
/**
* CRUDAddEditCtrl is a controller
* which provide a form with form generator.
*/
crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams) {
$scope.url = 'crud/';
crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams, CrudUtility) {
CrudUtility.generateParam($scope, $routeParams);
angular.forEach($routeParams, function (value, key) {
if (key.indexOf('_id') > -1) {
$scope.param = key;
$scope.param_id = value;
}
});
$scope.form_params = {'model': $routeParams.model, param: $scope.param, id: $scope.param_id};
if ($routeParams.key) {
$scope.form_params['object_id'] = $routeParams.key;
$scope.form_params['cmd'] = 'edit';
}
else {
$scope.form_params['cmd'] = 'add';
}
$scope.form_params['cmd'] = 'form';
// get form with generator
if ($routeParams.model) {
if ($routeParams.pageData) {
console.log(Generator.getPageData());
Generator.generate($scope, Generator.getPageData());
} else {
Generator.get_form($scope);
}
$scope.onSubmit = function (form) {
//$scope.$broadcast('schemaFormValidate');
debugger;
//if (form.$valid) {
Generator.submit($scope)
.success(function (data) {
})
.error(function (data) {
$scope.message = data.title;
});
//}
$scope.$broadcast('schemaFormValidate');
if (form.$valid) {
Generator.submit($scope);
}
};
});
......@@ -59,27 +79,19 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
* CRUD List Controller
*/
crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeParams) {
$scope.url = 'crud/';
angular.forEach($routeParams, function (value, key) {
if (key.indexOf('_id') > -1) {
$scope.param = key;
$scope.param_id = value;
}
});
$scope.form_params = {'model': $routeParams.model, param: $scope.param, id: $scope.param_id};
crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeParams, CrudUtility) {
CrudUtility.generateParam($scope, $routeParams);
$scope.form_params['cmd'] = 'list';
if ($routeParams.nobjects) {
$scope.nobjects = $routeParams.nobjects;
$scope.model = $routeParams.model;
$scope.addLink = $routeParams.addLink;
} else {
if ($routeParams.pageData) {
var pageData = Generator.getPageData();
CrudUtility.listPageItems($scope, pageData);
}
else {
// call generator's get_list func
Generator.get_list($scope)
.then(function (res) {
$scope.nobjects = res.data.nobjects;
$scope.model = $routeParams.model;
$scope.addLink = res.data.addLink;
CrudUtility.listPageItems($scope, res.Data);
});
}
});
......@@ -87,23 +99,9 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
/**
* CRUD Show Controller
*/
crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generator, $routeParams) {
$scope.url = 'crud/';
angular.forEach($routeParams, function (value, key) {
if (key.indexOf('_id') > -1) {
$scope.param = key;
$scope.param_id = value;
}
});
$scope.form_params = {
"id": $scope.param_id,
"object_id": $routeParams.key,
"cmd": "show",
param: $scope.param,
"model": $routeParams.model
};
crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generator, $routeParams, CrudUtility) {
CrudUtility.generateParam($scope, $routeParams);
$scope.form_params['cmd'] = 'show';
// call generator's get_single_item func
Generator.get_single_item($scope).then(function (res) {
$scope.listobjects = {};
......
......@@ -4,12 +4,12 @@
<button type="button" class="btn btn-primary">Ekle</button>
</a>
</h1>
<div class="row" ng-if="!nobjects[1]">
<div class="row" ng-if="!objects[1]">
<div class="col-md-12">
<p class="no-content">Listelenecek içerik yok.</p>
</div>
</div>
<div class="tablescroll" ng-if="nobjects[1]">
<div class="tablescroll" ng-if="objects[1]">
<table class="table table-bordered" style="background-color:#fff;">
<thead>
<tr>
......@@ -19,13 +19,13 @@
Hepsini Seç
</label>
</td>
<td ng-repeat="value in nobjects[0]" ng-if="nobjects[0]!='-1' && !$last">{{ value }}</td>
<td ng-if="nobjects[0]=='-1'">{{ model }}</td>
<td ng-repeat="value in objects[0]" ng-if="objects[0]!='-1' && !$last">{{ value }}</td>
<td ng-if="objects[0]=='-1'">{{ model }}</td>
<td>action</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="object in nobjects" ng-if="$index>0">
<tr ng-repeat="object in objects" ng-if="$index>0">
<td width="60">
<label>
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
......@@ -33,16 +33,16 @@
</td>
<td scope="row" style="text-align:center">{{$index}}</td>
<!-- below 2 of object will not be listed there for ng repeat loops 2 less -->
<td ng-repeat="k in object track by $index" ng-if="nobjects[0]=='-1' && $index>0 && !$last">
<a ng-href="{{object[object.length-1].detailLink}}">{{object[1]}}</a>
<td ng-repeat="field in object.fields track by $index" ng-if="objects[0]=='-1'">
<a ng-href="{{object.detailLink}}">{{field}}</a>
</td>
<td ng-repeat="(key,value) in object track by $index" ng-if="nobjects[0]!='-1' && $index>0 && !$last">
<a ng-href="{{object[object.length-1].detailLink}}" ng-if="$index==1">{{object[key]}}</a>
<td ng-repeat="(key,value) in object.fieldset track by $index" ng-if="objects[0]!='-1'">
<a ng-href="{{object.detailLink}}" ng-if="$index==1">{{object.fields}}</a>
<span ng-if="$index!=1">{{object[key]}}</span>
</td>
<td>
<a ng-href="{{object[object.length-1].editLink}}">Edit</a>
<a ng-href="{{object.editLink}}">Edit</a>
<br>
</td>
</tr>
......@@ -52,7 +52,7 @@
<br/>
<hr/>
<div class="btn-group" ng-if="nobjects[1]">
<div class="btn-group" ng-if="objects[1]">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
İşlemler <span class="caret"></span>
......
......@@ -7,105 +7,9 @@
'use strict';
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/debug/list', {
templateUrl: 'components/debug/debug.html',
controller: 'DebugCtrl'
});
}]);
angular.module('ulakbus.debug', ['ngRoute'])
.controller('DebugCtrl', function ($scope, $rootScope, $location) {
// todo: define breadcrumb
//$scope.$on("debug_queries", function (event, data) {
// $scope.debug_queries.push(data);
//});
$scope.debug_queries = $rootScope.debug_queries;
//$scope.debug_queries = [{
// "url": "http://ulakbus-remote-dev.zetaops.io:18188/notify",
// "queries": [
// {
// "TIMESTAMP": 1446666305.753408,
// "TIME": 0.0362,
// "BUCKET": "models_personel",
// "QUERY_PARAMS": {
// "sort": "timestamp desc",
// "rows": 1000
// },
// "QUERY": "tckn:123* AND -deleted:True"
// },
// {
// "TIMESTAMP": 1446666492.017113,
// "BUCKET": "models_kurum_disi_gorevlendirme_bilgileri",
// "SERIALIZATION": 0.00078,
// "SAVE_IS_NEW": true,
// "KEY": "ZZjOPrcdfW1w8EASYRastvEWKaA",
// "TIME": 0.01684
// },
// {
// "TIMESTAMP": 1446666305.789678,
// "BUCKET": "models_personel",
// "KEY": "TILjcZZpBzbVXdFMCWkYjNMnDSi",
// "TIME": 0.00425
// },
// {
// "TIMESTAMP": 1446666305.798089,
// "BUCKET": "models_personel",
// "KEY": "2yBUSlyr2WQp4l6xL79ehPCDR35",
// "TIME": 0.00335
// },
// {
// "TIMESTAMP": 1446666305.810038,
// "BUCKET": "models_personel",
// "KEY": "WTbiwac9tjtEQ2TZxmJh7eSb3CF",
// "TIME": 0.00548
// },
// {
// "TIMESTAMP": 1446666305.819372,
// "BUCKET": "models_personel",
// "KEY": "FmV5il0bAIwCBE1Zuk63WXfC9Vd",
// "TIME": 0.00305
// },
// {
// "TIMESTAMP": 1446666305.82646,
// "BUCKET": "models_personel",
// "KEY": "6SZXvENlJKuDtD8e9b1mHxDqc4Y",
// "TIME": 0.00305
// },
// {
// "TIMESTAMP": 1446666305.832966,
// "BUCKET": "models_personel",
// "KEY": "YPjWATvtR54JdY5BxVWYUh5AbeB",
// "TIME": 0.04506
// },
// {
// "TIMESTAMP": 1446666305.882205,
// "BUCKET": "models_personel",
// "KEY": "UGYo52etHUacK5uP1v91oGX8JDU",
// "TIME": 0.01335
// },
// {
// "TIMESTAMP": 1446666305.899335,
// "BUCKET": "models_personel",
// "KEY": "doZJrm6phbFwyuWZk9LYf05u4z",
// "TIME": 0.00291
// },
// {
// "TIMESTAMP": 1446666305.906138,
// "BUCKET": "models_personel",
// "KEY": "CZDKGx57MKufxrZNgNb2j9EQ9Mz",
// "TIME": 0.0098
// },
// {
// "TIMESTAMP": 1446666305.919088,
// "BUCKET": "models_personel",
// "KEY": "BW6nTAnpBQAIuj8LL98wOV1DJMC",
// "TIME": 0.00257
// }
// ]}]
});
\ No newline at end of file
......@@ -7,14 +7,6 @@
'use strict';
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/dev/settings', {
templateUrl: 'components/devSettings/devSettings.html',
controller: 'DevSettingsCtrl'
});
}]);
angular.module('ulakbus.devSettings', ['ngRoute'])
.controller('DevSettingsCtrl', function ($scope, $cookies, $rootScope, RESTURL) {
......
......@@ -54,7 +54,6 @@ app.directive('headerNotification', function ($http, $rootScope, $cookies, $inte
// check notifications every 5 seconds
$interval(function () {
if ($cookies.get("notificate") == "on") {
console.log('get notification call - interval');
$scope.getNotifications();
}
}, 5000);
......@@ -130,7 +129,6 @@ app.directive('headerSubMenu', function ($location) {
replace: true,
link: function ($scope) {
$scope.$on('$routeChangeStart', function () {
console.log($location.path()); //
$scope.style = $location.path() === '/dashboard' ? 'width:calc(100% - 300px);' : 'width:%100 !important;';
});
}
......@@ -201,6 +199,14 @@ app.directive('sidebar', ['$location', function () {
angular.forEach(items, function (value, key) {
newItems[value.kategori] = newItems[value.kategori] || [];
value['baseCategory'] = baseCategory;
// todo: generate urls here
//value['url'] = '#/wf' + value.wf;
//if (value.model) {
// value['url'] += '/model/' + value.model;
//}
value['wf'] = value.url.split('/')[0];
value['model'] = value.url.split('/')[1];
newItems[value.kategori].push(value);
});
return newItems;
......@@ -210,7 +216,8 @@ app.directive('sidebar', ['$location', function () {
$scope.allMenuItems[key] = reGroupMenuItems(value, key);
});
// broadcast for authorized menu items, consume in dashboard
// broadcast for authorized menu items, consume in dashboard to show search inputs and/or
// related items
$rootScope.$broadcast("authz", data);
$scope.menuItems = $scope.prepareMenu({other: $scope.allMenuItems.other});
......
......@@ -24,26 +24,12 @@
</a>
<ul class="nav nav-second-level" ng-class="{hidden: $root.collapsed}">
<li ng-repeat="(k, v) in item">
<a ng-if="v['baseCategory'] == 'other'" ng-href="#{{v.url}}"
<a ng-if="v['baseCategory'] == 'other'" ng-href="#{{v.url}}" ng-
ng-click="breadcrumb([key, v.text], $event)">{{v.text}}</a>
<a ng-if="v['baseCategory'] == 'ogrenci' || v['baseCategory'] == 'personel'"
ng-href="#{{v.url}}/list?{{v.param}}={{$root.selectedUser.key}}"
ng-href="#/{{v.wf}}/{{v.model}}?{{v.param}}={{$root.selectedUser.key}}"
ng-click="breadcrumb([key, v.text], $event)">{{v.text}}</a>
</li>
<!--<li ng-repeat="(key2, item2) in item">-->
<!--<a href="#">{{key2}} <span class="fa arrow"></span></a>-->
<!--<ul class="nav nav-third-level collapse in" aria-expanded="true">-->
<!--<li ng-repeat="(k,v) in item2">-->
<!--<a ng-if="key == 'other'" ng-href="#{{v.url}}"-->
<!--ng-click="breadcrumb([key, v.text], $event)">{{v.text}}</a>-->
<!--<a ng-if="key == 'ogrenci' || key == 'personel'"-->
<!--ng-href="#{{v.url}}/list?{{v.param}}={{$root.selectedUser.key}}"-->
<!--ng-click="breadcrumb([key, v.text], $event)">{{v.text}}</a>-->
<!--</li>-->
<!--</ul>-->
<!--&lt;!&ndash; /.nav-third-level &ndash;&gt;-->
<!--</li>-->
</ul>
<!-- /.nav-second-level -->
</li>
......
This diff is collapsed.
......@@ -173,21 +173,9 @@ describe('form service module', function () {
$httpBackend.expectGET(RESTURL.url + 'test/personel')
.respond(200, {
items: {
"client_cmd": "list_objects",
"objects": [
{
"data": {
"ad": "firstname",
"tckn": "12345678910",
"timestamp": 1444133895215881,
"soyad": "lastname",
"deleted": false,
"cep_telefonu": "05552223333"
},
"key": "4MsKRH9435cdKOzKCITNPml5bhB"
}],
"client_cmd": "list_objects",
"is_login": true,
"nobjects":[
"objects":[
["Ad\u0131", "Soyad\u0131", "TC No", "Durum"],
["4MsKRH9435cdKOzKCITNPml5bhB", "firstname", "lastname", "dksoap", false]
],
......
{
"name": "ulakbus-ui",
"description": "UI project for ulakbüs",
"version": "0.0.1",
"description": "UI for Ulakbüs",
"version": "0.4.0",
"homepage": "https://github.com/zetaops/ulakbus-ui",
"license": "GPL",
"private": false,
......@@ -18,7 +18,6 @@
"font-awesome": "4.3.0",
"angular-schema-form": "0.8.3",
"angular-loading-bar": "~0.8.0",
"angular-ui-router": "~0.2.15",
"angular-toggle-switch": "~1.2.1",
"metisMenu": "~1.1.3",
"angular-chart.js": "~0.5.2",
......
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