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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/// <reference path="../../../Scripts/underscore.js" />
/// <reference path="../../common/utils/enums.js" />
/// <reference path="../nav-bar-util.js" />
// AppNavBarController controller for the navigation bar of the application. This controller is responsible for
// manage the different types of the tabs and corresponding menus.
frameworkModule.controller('AppNavController', ['$rootScope', '$scope', '$log', '$state' ,'loginContext', 'application', 'userService', '$translate', 'vatSessionService', '$interval', 'workflowService',
function ($rootScope, $scope, $log, $state ,loginContext, application, userService, $translate, vatSessionService, $interval, workflowService) {
'use strict';
$log.debug('AppNavController.ctor()...');
$scope.companyName = loginContext.projectCustomerName;
$scope.loginUserName = loginContext.userName;
$scope.tpUrl = loginContext.tpUrl;
$scope.hasUnreadMsg = true;
$scope.msgNum = 0;
$scope.showSubMenu = true;
$scope.linkAdmin = false;
$scope.specialUser = $scope.loginUserName.toLowerCase();
$scope.hasQuerySummaryDashboardCode = false;
var interval = $interval(function () {
var data = vatSessionService.userPermission;
if (data.isAdmin == undefined) return;
if (data.isAdmin || (data.navigationUrlList && data.navigationUrlList.length > 0)) {
$scope.linkAdmin = true;
}
$interval.cancel(interval);
$scope.hasQuerySummaryDashboardCode = window.PWC.isHavePermission(constant.vatPermission.dataAnalysis.dashboard.querySummaryDashboardCode, data);
}, 500);
//userService.getUserPermission(loginContext.userName).success(function (data) {
// if (data) {
// if (data.isAdmin || (data.navigationUrlList && data.navigationUrlList.length > 0)) {
// $rootScope.linkAdmin = true;
// }
// $scope.hasQuerySummaryDashboardCode = window.PWC.isHavePermission(constant.vatPermission.dashboard.querySummaryDashboardCode, data)
// }
//});
$rootScope.$on('notification-read', function () {
$scope.msgNum--;
});
var getNotificationInfo = function () {
$scope.notificationCriteriaX = {
isFirstTimeLoading: false,
filterType: "MAIN",
serviceType: 2,
mainFilter: "UNREAD",
singleNode: null,
singleTask: null,
multipleNode: null,
multipleTask: null,
multipleStatus: null,
multipleDueDate: null,
multiplePriority: null,
multipleType: null,
searchKeyword: ""
};
workflowService.getPushNotifications($scope.notificationCriteriaX).success(function (notifications) {
if (notifications != null && notifications.notificationList != null)
$scope.msgNum = notifications.notificationList.length;
});
};
$scope.setDashboardFlag = function () {
vatSessionService.urlFromAnalyze = false;
return true;
};
$scope.toggleSubMenu = function (showsub) {
$scope.showSubMenu = !$scope.showSubMenu;
//$scope.$emit(application.events.showSubMenu, {direction:'up', show:$scope.showSubMenu});
};
$scope.showChangePassword = function () {
$("#changePasswordModal").modal('show');
$('.user-menu').css('display', 'none');
}
$scope.toggleUserMenu = function (event) {
if (event.target.parentElement.className === 'user-info' || event.target.parentElement.className === 'ng-binding') {
$('.user-menu').toggle();
}
event.stopPropagation();
};
var initSubHeader = function () {
var enterSubHeader = false;
$('[hover-show]').hover(function () {
var className = $(this).attr('hover-show');
$('.nav-sub-container').hide();
$('.nav-sub-container.' + className).show();
}, function () {
setTimeout(function () { //等待 nav-sub-container hover 设置上对应的值
if (enterSubHeader) {
var className = $(this).attr('hover-show');
$('.nav-sub-container.' + className).hide();
}
}, 200);
});
$('.nav-sub-container').hover(function () {
enterSubHeader = true;
}, function () {
enterSubHeader = false;
$('.nav-sub-container').hide();
});
};
//设置 菜单选中状态
var initState = function(){
$($('.nav-container .nav-element-left a')[0]).addClass('active');
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
$log.debug("$stateChangeStart: toState="+toState.name);
$('.nav-container .nav-element-left a').removeClass('active');
$($('.nav-container .nav-element-left a')[getMenuIndex(toState.name)]).addClass('active');
});
};
var getMenuIndex = function(name){
switch(name){
case 'GlobalSearch': return 0;
case 'summary': return 0;
case 'summaryDashboard': return 3;
case 'RiskPanel': return 3;
case 'DataSummary': return 3;
default: return 2;
};
};
$scope.search = function(){
PWC.simulateProgress();
$state.go('GlobalSearch');
};
$(document).click(function (event) {
$('.user-menu').css('display', 'none');
event.stopPropagation();
});
(function initialize() {
initSubHeader();
initState();
getNotificationInfo();
})();
}
]);