Commit 340d9636 authored by Evren Kutar's avatar Evren Kutar

if selected user add it to cookies

parent 827706c0
......@@ -30,7 +30,7 @@
<div class="dashboard-search-results">
<ul ng-if="students.length > 0">
<li ng-repeat="student in students">
<a href="javascript:void(0)" ng-click="select(student)">{{student}}</a>
<a href="javascript:void(0)" ng-click="select(student, 'ogrenci')">{{student}}</a>
</li>
</ul>
</div>
......@@ -46,7 +46,7 @@
<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[0]}}</a>
<a href="javascript:void(0)" ng-click="select(staff, 'personel')">{{staff[0]}}</a>
</li>
</ul>
</div>
......
......@@ -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 = "";
......@@ -47,81 +52,26 @@ angular.module('ulakbus.dashboard', ['ngRoute'])
//});
};
$scope.select = function (who) {
$scope.select = function (who, type) {
$rootScope.selectedUser = {name: who[0], tcno: who[1], key: who[2]};
// todo: get 'who's related transactions and manipulate sidebar menu
};
// when select a user from list
// get 'who's related transactions and manipulate sidebar menu
$rootScope.$broadcast("menuitems", type);
// save selected user and type to cookie
$cookies.put("selectedUserName", who[0]);
$cookies.put("selectedUserTcNo", who[1]);
$cookies.put("selectedUserKey", who[2]);
$cookies.put("selectedUserType", type);
console.log($cookies.getAll());
};
//$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'];
// }
// });
// });
//});
// 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")};
//$rootScope.$broadcast("menuitems", $cookies.get("selectedUserType"));
console.log($cookies.getAll());
}
//$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) {
//
//
// }
// };
//}]);
});
......@@ -59,19 +59,14 @@ app.directive('collapseMenu', function ($timeout) {
$scope.collapseToggle = function () {
if ($rootScope.collapsed === false) {
//jQuery("span.menu-text, span.arrow, .sidebar footer").css("display" , "none");
jQuery(".sidebar").css("width" , "62px");
jQuery(".manager-view").css("width" , "calc(100% - 62px)");
//jQuery(".sidebar footer").css("display" , "none");
//jQuery(".menu-text").hide();
$rootScope.collapsed = true;
$rootScope.sidebarPinned = false;
} else {
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);
//jQuery(".menu-text").show();
$rootScope.collapsed = false;
$rootScope.sidebarPinned = true;
}
......@@ -126,7 +121,10 @@ app.directive('selectedUser', function () {
return {
templateUrl: 'shared/templates/directives/selected-user.html',
restrict: 'E',
replace: true
replace: false,
link: function ($scope, $rootScope) {
$scope.selectedUser = $rootScope.selectedUser;
}
};
});
......@@ -134,6 +132,7 @@ app.directive('selectedUser', function () {
* 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 () {
......@@ -142,25 +141,32 @@ app.directive('sidebar', ['$location', function () {
restrict: 'E',
replace: true,
scope: {},
controller: function ($scope, $rootScope, $http, RESTURL, $location, $timeout) {
$('#side-menu').metisMenu();
controller: function ($scope, $rootScope, $cookies, $http, RESTURL, $location, $timeout) {
var sidebarmenu = $('#side-menu');
sidebarmenu.metisMenu();
$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'];
// }
// });
//});
$timeout(function(){$('#side-menu').metisMenu()});
$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 () {
......@@ -218,7 +224,6 @@ app.directive('sidebar', ['$location', function () {
$scope.multiCollapseVar = y;
}
};
}
};
}]);
......
<p ng-if="$root.selectedUser.name">İşlem: {{$root.selectedUser.name}}</p>
\ No newline at end of file
<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">
<!--<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">{{$root.selectedUser.name}}</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 -->
\ No newline at end of file
......@@ -2,6 +2,7 @@
<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>-->
......@@ -33,47 +34,7 @@
</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 ng-class="{hidden: $root.collapsed}">
<span>v <app-version></app-version> &copy; ZetaOps</span>
......
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