1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
appDS2.directive('ds2Header', function () {
return {
restrict: 'A', //This menas that it will be used as an attribute and NOT as an element. I don't like creating custom HTML elements
replace: false,
templateUrl: "app/fusion/scripts/DS2-view-models/ds2Header.html",
controller: ['$scope', '$filter','$http','$timeout', '$log','UserInfoServiceDS2', 'HeaderServiceDS2', '$window', '$cookies','$cookieStore', function ($scope, $filter, $http, $timeout, $log,UserInfoServiceDS2,HeaderServiceDS2, $window, $cookies,$cookieStore) {
// copy from existing DS1
/*Define fields*/
$scope.userName;
$scope.userFirstName;
$scope.userId;
$scope.userEmail;
$scope.redirectUrl;
$scope.contactUsUrl;
$scope.getAccessUrl;
$scope.menuItems = [];
$scope.showHeader = ($cookieStore.get("show_app_header") == undefined ? true : $cookies.get("show_app_header") );
/***************functions**************/
/*getting user info from session*/
$scope.getUserNameFromSession = function(){
UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
.then(function (res) {
$scope.contactUsUrl=res.contactUsLink;
$scope.userName = res.userName;
$scope.userId = res.userid;
$scope.userEmail = res.email;
$scope.userFirstName = res.firstName;
$scope.redirectUrl = res.portalUrl;
$scope.getAccessUrl = res.getAccessUrl;
});
}
$scope.returnToPortal=function(){
window.location.href = $scope.redirectUrl;
}
/*Menu Structure*/
var menuStructureConvert = function(menuItems) {
$scope.megaMenuDataObjectTemp =
[{
text: "Manage",
children: menuItems
},
{
text: "Support",
children: [
{
label:"Contact Us",
action:$scope.contactUsUrl,
childMenus:[]
},
{
label:"Get Access",
action:$scope.getAccessUrl,
childMenus:[]
}]
}];
return $scope.megaMenuDataObjectTemp;
};
$scope.getMenu=function() {
$scope.getUserNameFromSession();
var promise = HeaderServiceDS2.getMenu();
promise.then(
function(res) {
if(res==null || res==''){
$log.error('failed to get menu');
$scope.getUserNameFromSession();
}else{
$scope.parentMenu = JSON.parse(res.data);
$scope.childMenu = JSON.parse(res.data2);
for(var i=0; i<$scope.parentMenu.length;i++){
$scope.parentMenu[i].childMenus = ($scope.childMenu[i]);
}
$scope.menuItems = menuStructureConvert($scope.parentMenu);
}
},
function(err) {
$log.error('getMenu failed', err);
}
);
}
$scope.adjustHeader=function() {
$scope.showHeader = ($cookies.get("show_app_header") == undefined ? true : $cookies.get("show_app_header"));
// console.log($scope.showHeader);
if ($scope.showHeader==true) {
document.getElementById('page-content').style.marginTop = "45px";
}else{
document.getElementById('page-content').style.marginTop = "0px";
}
}; // adjustHeader
$scope.$on('$routeChangeSuccess', function () {
$scope.adjustHeader();
});
$scope.getUserNameFromSession();
$scope.getMenu();
}]
}
});
appDS2.filter("ellipsis", function(){
return function(text, length){
if (text) {
var ellipsis = text.length > length ? "..." : "";
return text.slice(0, length) + ellipsis;
};
return text;
}
});
|