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(
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};
})()).
/**
......
......@@ -24,10 +24,8 @@
<div class="dashboard-student-search">
<center>
<h3>ÖĞRENCİ</h3>
<input type="text" placeholder="Öğrenci ara" ng-model="student_kw"
ng-keyup="search('Ogrenci')"><span
class="fa fa-search"
ng-click="search('Ogrenci')"></span>
<input type="text" placeholder="Öğrenci ara" ng-model="student_kw" ng-keyup="search('ogrenci')">
<span class="fa fa-search" ng-click="search('ogrenci')"></span>
</center>
<div class="dashboard-search-results">
<ul ng-if="students.length > 0">
......@@ -42,14 +40,13 @@
<div class="dashboard-personnel-search">
<center>
<h3>PERSONEL</h3>
<input type="text" placeholder="Personel ara" ng-model="staff_kw"
ng-keyup="search('Personel')"><span
class="fa fa-search" ng-click="search('Personel')"></span>
<input type="text" placeholder="Personel ara" ng-model="staff_kw" ng-keyup="search('personel')">
<span class="fa fa-search" ng-click="search('personel')"></span>
</center>
<div class="dashboard-search-results">
<ul ng-if="staffs.length > 0">
<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>
</ul>
</div>
......
......@@ -22,29 +22,33 @@ 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);
//.success(function (data) {
// return data.results;
//});
};
$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
};
......
......@@ -49,7 +49,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};
})()).
/**
......
......@@ -47,28 +47,37 @@ 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) {
if ($rootScope.collapsed === false) {
jQuery("span.menu-text").css("display" , "none");
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");
$scope.collapsed = true;
$rootScope.collapsed = true;
$rootScope.sidebarPinned = false;
} else {
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(".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 () {
};
});
/**
* selected user directive
*/
app.directive('selectedUser', function () {
return {
templateUrl: 'shared/templates/directives/selected-user.html',
restrict: 'E',
replace: true
};
});
/**
* sidebar directive
* changes breadcrumb when an item selected
......@@ -120,22 +141,45 @@ app.directive('sidebar', ['$location', function () {
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);
$http.get(RESTURL.url + 'menu/').success(function (data) {
//$scope.allMenuItems = angular.copy(data.generic);
$scope.menuItems = data;
// $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'];
}
});
});
//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'];
// }
// });
//});
$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; },
function (newindex, oldindex) {
if (newindex > -1) {
......
......@@ -5,11 +5,11 @@
* (GPLv3). See LICENSE.txt for details.
*/
$(function() {
$('#side-menu').metisMenu();
});
//$(function() {
//
// $('#side-menu').metisMenu();
//
//});
//Loads the correct sidebar on window load,
//collapses the sidebar on window resize.
......
......@@ -3,6 +3,7 @@
<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>-->
......
<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">
<a href="" class="logo"><img src="/img/brand-logo.png" /></a>
</div>
......@@ -12,11 +12,11 @@
</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
<a href="" ng-click="check($index+1)"><i class="fa fa-wrench fa-fw"></i> {{ key }}<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>
<li ng-repeat="v in item"><a ng-href="#/{{v[1]}}"
ng-click="breadcrumb([key, v[0]])">{{v[0]}}</a></li>
</ul>
<!-- /.nav-second-level -->
</li>
......
......@@ -67,8 +67,6 @@ app.config(['$httpProvider', function ($httpProvider) {
// 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">' +
......@@ -88,6 +86,7 @@ app.config(['$httpProvider', function ($httpProvider) {
'</div>' +
'</div>' +
'</div>').modal()
$location.path("/500");
}
return $q.reject(rejection);
}
......
......@@ -16,7 +16,7 @@
"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