Commit 505aee42 authored by Evren Kutar's avatar Evren Kutar

search for user

selected user to header
parent 70bf9c58
...@@ -44,7 +44,9 @@ var app = angular.module( ...@@ -44,7 +44,9 @@ var app = angular.module(
var urlfromqstr = location.href.split('?')[1].split('=')[1]; var urlfromqstr = location.href.split('?')[1].split('=')[1];
backendurl = decodeURIComponent(urlfromqstr.replace(/\+/g, " ")); backendurl = decodeURIComponent(urlfromqstr.replace(/\+/g, " "));
document.cookie = "backendurl="+backendurl; document.cookie = "backendurl="+backendurl;
window.location.href = window.location.href.split('?')[0];
} }
return {url: backendurl}; return {url: backendurl};
})()). })()).
/** /**
......
...@@ -24,10 +24,8 @@ ...@@ -24,10 +24,8 @@
<div class="dashboard-student-search"> <div class="dashboard-student-search">
<center> <center>
<h3>ÖĞRENCİ</h3> <h3>ÖĞRENCİ</h3>
<input type="text" placeholder="Öğrenci ara" ng-model="student_kw" <input type="text" placeholder="Öğrenci ara" ng-model="student_kw" ng-keyup="search('ogrenci')">
ng-keyup="search('Ogrenci')"><span <span class="fa fa-search" ng-click="search('ogrenci')"></span>
class="fa fa-search"
ng-click="search('Ogrenci')"></span>
</center> </center>
<div class="dashboard-search-results"> <div class="dashboard-search-results">
<ul ng-if="students.length > 0"> <ul ng-if="students.length > 0">
...@@ -42,14 +40,13 @@ ...@@ -42,14 +40,13 @@
<div class="dashboard-personnel-search"> <div class="dashboard-personnel-search">
<center> <center>
<h3>PERSONEL</h3> <h3>PERSONEL</h3>
<input type="text" placeholder="Personel ara" ng-model="staff_kw" <input type="text" placeholder="Personel ara" ng-model="staff_kw" ng-keyup="search('personel')">
ng-keyup="search('Personel')"><span <span class="fa fa-search" ng-click="search('personel')"></span>
class="fa fa-search" ng-click="search('Personel')"></span>
</center> </center>
<div class="dashboard-search-results"> <div class="dashboard-search-results">
<ul ng-if="staffs.length > 0"> <ul ng-if="staffs.length > 0">
<li ng-repeat="staff in staffs"> <li ng-repeat="staff in staffs">
<a href="javascript:void(0)" ng-click="select(staff)">{{staff}}</a> <a href="javascript:void(0)" ng-click="select(staff)">{{staff[0]}}</a>
</li> </li>
</ul> </ul>
</div> </div>
......
...@@ -22,29 +22,33 @@ angular.module('ulakbus.dashboard', ['ngRoute']) ...@@ -22,29 +22,33 @@ angular.module('ulakbus.dashboard', ['ngRoute'])
$scope.search = function (where) { $scope.search = function (where) {
$timeout(function () { $timeout(function () {
if (where === 'Personel') { if (where === 'personel') {
// if input length greater than 3 search for the value // if input length greater than 2 search for the value
if ($scope.staff_kw.length > 3) { if ($scope.staff_kw.length > 2) {
$scope.staffs = $scope.getItems(where, $scope.staff_kw); $scope.getItems(where, $scope.staff_kw).success(function (data) {
$scope.staffs = data.results;
});
} }
} }
if (where === 'Ogrenci') { if (where === 'ogrenci') {
if ($scope.student_kw.length > 3) { if ($scope.student_kw.length > 2) {
$scope.students = $scope.getItems(where, $scope.student_kw); $scope.getItems(where, $scope.student_kw).success(function (data) {
$scope.students = data.results;
})
} }
} }
}); });
}; };
$scope.getItems = function (where, params) { $scope.getItems = function (where, what) {
$http.post(RESTURL.url + where, {"query": params}) return $http.get(RESTURL.url + 'ara/' + where + '/' + what);
.success(function (data) { //.success(function (data) {
return data; // return data.results;
}); //});
}; };
$scope.select = function (who) { $scope.select = function (who) {
$rootScope.who = who; $rootScope.selectedUser = {name: who[0], tcno: who[1], key: who[2]};
// todo: get 'who's related transactions and manipulate sidebar menu // todo: get 'who's related transactions and manipulate sidebar menu
}; };
......
...@@ -49,7 +49,9 @@ var app = angular.module( ...@@ -49,7 +49,9 @@ var app = angular.module(
var urlfromqstr = location.href.split('?')[1].split('=')[1]; var urlfromqstr = location.href.split('?')[1].split('=')[1];
backendurl = decodeURIComponent(urlfromqstr.replace(/\+/g, " ")); backendurl = decodeURIComponent(urlfromqstr.replace(/\+/g, " "));
document.cookie = "backendurl="+backendurl; document.cookie = "backendurl="+backendurl;
window.location.href = window.location.href.split('?')[0];
} }
return {url: backendurl}; return {url: backendurl};
})()). })()).
/** /**
......
...@@ -47,28 +47,37 @@ app.directive('headerNotification', function ($http, $interval, RESTURL) { ...@@ -47,28 +47,37 @@ app.directive('headerNotification', function ($http, $interval, RESTURL) {
* toggle collapses sidebar menu when clicked menu button * toggle collapses sidebar menu when clicked menu button
*/ */
app.directive('collapseMenu', function () { app.directive('collapseMenu', function ($timeout) {
return { return {
templateUrl: 'shared/templates/directives/menuCollapse.html', templateUrl: 'shared/templates/directives/menuCollapse.html',
restrict: 'E', restrict: 'E',
replace: true, replace: true,
link: function ($scope) { scope: {},
$scope.collapsed = false; controller: function ($scope, $rootScope) {
$rootScope.collapsed = false;
$rootScope.sidebarPinned = false;
$scope.collapseToggle = function () { $scope.collapseToggle = function () {
if ($scope.collapsed === false) { if ($rootScope.collapsed === false) {
jQuery("span.menu-text").css("display" , "none"); jQuery("span.menu-text").css("display" , "none");
jQuery(".sidebar").css("width" , "62px"); jQuery(".sidebar").css("width" , "62px");
jQuery(".manager-view").css("z-index" , "9999").css("width" , "calc(100% - 62px)"); jQuery(".manager-view").css("width" , "calc(100% - 62px)");
jQuery(".sidebar footer").css("display" , "none"); jQuery(".sidebar footer").css("display" , "none");
$scope.collapsed = true; $rootScope.collapsed = true;
$rootScope.sidebarPinned = false;
} else { } else {
jQuery("span.menu-text").fadeIn(400); jQuery("span.menu-text").fadeIn(400);
jQuery(".sidebar").css("z-index" , "0").css("width" , "250px"); jQuery(".sidebar").css("width" , "250px");
jQuery(".manager-view").css("width" , "calc(100% - 250px)"); jQuery(".manager-view").css("width" , "calc(100% - 250px)");
jQuery(".sidebar footer").fadeIn(400); jQuery(".sidebar footer").fadeIn(400);
$scope.collapsed = false; $rootScope.collapsed = false;
$rootScope.sidebarPinned = true;
} }
}; };
$timeout(function(){
$scope.collapseToggle();
});
} }
}; };
}); });
...@@ -107,6 +116,18 @@ app.directive('headerBreadcrumb', function () { ...@@ -107,6 +116,18 @@ app.directive('headerBreadcrumb', function () {
}; };
}); });
/**
* selected user directive
*/
app.directive('selectedUser', function () {
return {
templateUrl: 'shared/templates/directives/selected-user.html',
restrict: 'E',
replace: true
};
});
/** /**
* sidebar directive * sidebar directive
* changes breadcrumb when an item selected * changes breadcrumb when an item selected
...@@ -120,22 +141,45 @@ app.directive('sidebar', ['$location', function () { ...@@ -120,22 +141,45 @@ app.directive('sidebar', ['$location', function () {
replace: true, replace: true,
scope: {}, scope: {},
controller: function ($scope, $rootScope, $http, RESTURL, $location, $timeout) { controller: function ($scope, $rootScope, $http, RESTURL, $location, $timeout) {
$http.post(RESTURL.url + 'crud/').success(function (data) { $http.get(RESTURL.url + 'menu/').success(function (data) {
$scope.allMenuItems = angular.copy(data.app_models); //$scope.allMenuItems = angular.copy(data.generic);
$scope.menuItems = []; // angular.copy($scope.allMenuItems); $scope.menuItems = data;
// $scope.menuItems = []; // angular.copy($scope.allMenuItems);
// at start define breadcrumblinks for breadcrumb // at start define breadcrumblinks for breadcrumb
angular.forEach(data.app_models, function (value, key) { //angular.forEach(data.app_models, function (value, key) {
angular.forEach(value[1], function (v, k) { // angular.forEach(value[1], function (v, k) {
if (v[1] === $location.path().split('/')[2]) { // if (v[1] === $location.path().split('/')[2]) {
$rootScope.breadcrumblinks = [value[0], v[0]]; // $rootScope.breadcrumblinks = [value[0], v[0]];
$scope.menuItems = [$scope.allMenuItems[key]]; // $scope.menuItems = [$scope.allMenuItems[key]];
} else { // } else {
$rootScope.breadcrumblinks = ['Panel']; // $rootScope.breadcrumblinks = ['Panel'];
} // }
}); // });
}); //});
$timeout(function(){$('#side-menu').metisMenu()});
}); });
$scope.openSidebar = function () {
if ($rootScope.sidebarPinned === false) {
jQuery("span.menu-text").fadeIn(400);
jQuery(".sidebar").css("width" , "250px");
jQuery(".manager-view").css("width" , "calc(100% - 250px)");
jQuery(".sidebar footer").fadeIn(400);
$rootScope.collapsed = false;
}
};
$scope.closeSidebar = function () {
if ($rootScope.sidebarPinned === false) {
jQuery("span.menu-text").css("display" , "none");
jQuery(".sidebar").css("width" , "62px");
jQuery(".manager-view").css("width" , "calc(100% - 62px)");
jQuery(".sidebar footer").css("display" , "none");
$rootScope.collapsed = true;
}
};
$rootScope.$watch(function ($rootScope) {return $rootScope.section; }, $rootScope.$watch(function ($rootScope) {return $rootScope.section; },
function (newindex, oldindex) { function (newindex, oldindex) {
if (newindex > -1) { if (newindex > -1) {
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
* (GPLv3). See LICENSE.txt for details. * (GPLv3). See LICENSE.txt for details.
*/ */
$(function() { //$(function() {
//
$('#side-menu').metisMenu(); // $('#side-menu').metisMenu();
//
}); //});
//Loads the correct sidebar on window load, //Loads the correct sidebar on window load,
//collapses the sidebar on window resize. //collapses the sidebar on window resize.
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<header-breadcrumb></header-breadcrumb> <header-breadcrumb></header-breadcrumb>
<loaderdiv><div></div></loaderdiv> <loaderdiv><div></div></loaderdiv>
<!--<div class="loader">Loading...</div>--> <!--<div class="loader">Loading...</div>-->
<selected-user class="pull-right"></selected-user>
</div> </div>
<!--<div id="header-buttons" ng-class="{hidden: $root.showSaveButton != true}">--> <!--<div id="header-buttons" ng-class="{hidden: $root.showSaveButton != true}">-->
<!--<button type="button" class="btn btn-primary" ng-click="triggerSubmit()">Kaydet</button>--> <!--<button type="button" class="btn btn-primary" ng-click="triggerSubmit()">Kaydet</button>-->
......
<p ng-if="$root.selectedUser.name">Kullanıcı: {{$root.selectedUser.name}}</p>
\ 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"> <div class="brand">
<a href="" class="logo"><img src="/img/brand-logo.png" /></a> <a href="" class="logo"><img src="/img/brand-logo.png" /></a>
</div> </div>
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
</li> </li>
<li ng-repeat="(key, item) in menuItems" ng-class="{active: collapseVar == $index+1}">{{dropDown}} <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 <a href="" ng-click="check($index+1)"><i class="fa fa-wrench fa-fw"></i> {{ key }}<span
class="fa arrow"></span></a> class="fa arrow"></span></a>
<ul class="nav nav-second-level"> <ul class="nav nav-second-level">
<li ng-repeat="(k, v) in item[1]"><a href="#/crud/{{v[1]}}" <li ng-repeat="v in item"><a ng-href="#/{{v[1]}}"
ng-click="breadcrumb([item[0], v[0]])">{{v[0]}}</a></li> ng-click="breadcrumb([key, v[0]])">{{v[0]}}</a></li>
</ul> </ul>
<!-- /.nav-second-level --> <!-- /.nav-second-level -->
</li> </li>
......
...@@ -67,8 +67,6 @@ app.config(['$httpProvider', function ($httpProvider) { ...@@ -67,8 +67,6 @@ app.config(['$httpProvider', function ($httpProvider) {
// 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) {
if (rejection.status === 500) { if (rejection.status === 500) {
// todo: redirect to 500
//$location.path("/500");
$('<div class="modal">' + $('<div class="modal">' +
'<div class="modal-dialog" style="width:1024px;" role="document">' + '<div class="modal-dialog" style="width:1024px;" role="document">' +
'<div class="modal-content">' + '<div class="modal-content">' +
...@@ -88,6 +86,7 @@ app.config(['$httpProvider', function ($httpProvider) { ...@@ -88,6 +86,7 @@ app.config(['$httpProvider', function ($httpProvider) {
'</div>' + '</div>' +
'</div>' + '</div>' +
'</div>').modal() '</div>').modal()
$location.path("/500");
} }
return $q.reject(rejection); return $q.reject(rejection);
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"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",
"angular-loading-bar": "~0.7.0", "angular-loading-bar": "~0.8.0",
"angular-ui-router": "~0.2.15", "angular-ui-router": "~0.2.15",
"angular-toggle-switch": "~1.2.1", "angular-toggle-switch": "~1.2.1",
"metisMenu": "~1.1.3", "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