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
|
appDS2.directive('ds2Menu', function () {
return {
restrict: 'A', //This means 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/ds2Left_menu.html",
controller: ['$scope','$filter','$http','$timeout','$cookies','LeftMenuServiceDS2', function ($scope, $filter, $http, $timeout, $cookies, LeftMenuServiceDS2) {
$scope.menuData = [];
$scope.leftChildData = [];
$scope.leftParentData = [];
$scope.leftMenuItems = [];
$scope.app_name = "";
$scope.app_name_full = "";
LeftMenuServiceDS2.getLeftMenu().then(function(response){
var j = response;
if (j && j !== "null" && j !== "undefined"){
$scope.leftParentData = JSON.parse(j.data);
$scope.leftChildData = JSON.parse(j.data2);
} else {
console.log("ds2Menu::controller: unexpected getLeftMenu response");
return;
}
var leftParentList = $scope.leftParentData;
var leftChildItemList = $scope.leftChildData;
for (var i = 0; i < leftParentList.length; i++) {
var parentItem = {};
parentItem.name = leftParentList[i].label;
parentItem.imageSrc = leftParentList[i].imageSrc;
// Add link to items with no subitems
if (leftChildItemList[i].length == 0)
parentItem.href = leftParentList[i].action;
parentItem.menuItems = [];
for (var j = 0; j < leftChildItemList[i].length; j++) {
if (leftChildItemList[i][j].label != null && leftChildItemList[i][j].label.length > 0) {
var childItem = {};
childItem.name = leftChildItemList[i][j].label;
childItem.href = leftChildItemList[i][j].action;
parentItem.menuItems.push(childItem)
}
}
$scope.menuData.push(parentItem);
}
},function(error){
console.log("ds2Menu::controller: getLeftMenu failed", error);
});
LeftMenuServiceDS2.getAppName().then(function(response){
var j = response;
try {
if (j && j !== "null" && j!== "undefined"){
$scope.app_name_full = j.data;
var processed_app_name = j.data;
var n = processed_app_name.length;
if (n > 15) {
n = 15;
}
$scope.app_name = processed_app_name.substr(0, n);
} else {
throw "Get app_name respsone is not an object/is empty";
}
} catch (e) {
console.log("error happened while trying to get app name "+e);
return;
}
},function(error){
console.log("error happened while calling getAppName "+error);
});
$scope.drawerOpen = true;
}]
}
});
|