b2b3a43be2fd0a7c97393eb3b4f056ff1a160ae1
[portal/sdk.git] /
1 appDS2
2                 .directive(
3                                 'integer',
4                                 function() {
5                                         return {
6                                                 require : 'ngModel',
7                                                 link : function(scope, ele, attr, ctrl) {
8                                                         ctrl.$parsers.unshift(function(viewValue) {
9                                                                 if (viewValue === '' || viewValue === null
10                                                                                 || typeof viewValue === 'undefined') {
11                                                                         return null;
12                                                                 }
13                                                                 return parseInt(viewValue, 10);
14                                                         });
15                                                 }
16                                         };
17                                 })
18
19                 .controller(
20                                 'welcomeController',
21                                 function($scope, $interval, $http, $modal, $log, ManifestService) {
22
23                                         $scope.testMsg = "Welcome Page1";
24                                         $scope.gridsterOpts = {
25                                                 columns : 6, // the width of the grid, in columns
26                                                 pushing : true, // whether to push other items out of
27                                                                                 // the way on move or resize
28                                                 floating : true, // whether to automatically float
29                                                                                         // items up so they stack (you can
30                                                                                         // temporarily disable if you are
31                                                                                         // adding unsorted items with
32                                                                                         // ng-repeat)
33                                                 width : 'auto', // can be an integer or 'auto'. 'auto'
34                                                                                 // scales gridster to be the full width
35                                                                                 // of its containing element
36                                                 colWidth : 'auto', // can be an integer or 'auto'.
37                                                                                         // 'auto' uses the pixel width of
38                                                                                         // the element divided by 'columns'
39                                                 rowHeight : 60, // can be an integer or 'match'. Match
40                                                                                 // uses the colWidth, giving you square
41                                                                                 // widgets.
42                                                 margins : [ 10, 10 ], // the pixel distance between
43                                                                                                 // each widget
44                                                 outerMargin : true, // whether margins apply to outer
45                                                                                         // edges of the grid
46                                                 swapping : true,
47                                                 draggable : {
48                                                         enabled : true, // whether dragging items is
49                                                                                         // supported
50                                                         stop : function(event, uiWidget, $element) {
51                                                                 $scope.setCookie();
52                                                         } // optional callback fired when item is finished
53                                                                 // dragging
54                                                 }
55
56                                         };
57
58                                         /*
59                                          * $scope.gridsterOpts = { columns: 6, width: 'auto',
60                                          * colWidth: '230', rowHeight: '120', margins: [10, 10],
61                                          * outerMargin: true, pushing: true, floating: true,
62                                          * swapping: true };
63                                          */
64
65                                         $scope.toggleMinMax = function(index, tileName) {
66                                                 if (tileName == '') {
67                                                         $scope.standardItems[index].max = !$scope.standardItems[index].max;
68                                                         if ($scope.standardItems[index].max)
69                                                                 $scope.standardItems[index].sizeY = $scope.standardItems[index].maxHeight;
70                                                         else
71                                                                 $scope.standardItems[index].sizeY = 0;
72                                                 } else {
73                                                         $scope.tileTemp = $scope.$eval(tileName);
74                                                         var tileMax = $parse(tileName + '.max');
75                                                         tileMax.assign($scope, !$scope.$eval(tileName).max);
76                                                         var tileSizeY = $parse(tileName + '.sizeY');
77                                                         if ($scope.tileTemp.max)
78                                                                 tileSizeY.assign($scope,
79                                                                                 $scope.tileTemp.maxHeight);
80                                                         else
81                                                                 tileSizeY.assign($scope, 0);
82                                                 }
83                                         };
84
85                                         // These map directly to gridsterItem options
86                                         // IMPORTANT: Items should be placed in the grid in the
87                                         // order in which
88                                         // they should appear.
89                                         // In most cases the sorting should be by row ASC, col ASC
90                                         $scope.standardItems = [
91                                                         {
92                                                                 sizeX : 2,
93                                                                 sizeY : 8,
94                                                                 maxHeight : 8,
95                                                                 row : 0,
96                                                                 col : 0,
97                                                                 headerText : 'Dashboard',
98                                                                 max : false
99
100                                                         },
101                                                         {
102                                                                 sizeX : 2,
103                                                                 sizeY : 5,
104                                                                 maxHeight : 5,
105                                                                 row : 0,
106                                                                 col : 2,
107                                                                 headerText : 'Donut Chart',
108                                                                 max : false
109
110                                                         },/*
111                                                                  * { sizeX : 1, sizeY : 5, maxHeight : 5, row :
112                                                                  * 0, col : 2, headerText : 'Area Chart', max :
113                                                                  * false },
114                                                                  */
115                                                         {
116                                                                 sizeX : 2,
117                                                                 sizeY : 5,
118                                                                 maxHeight : 5,
119                                                                 row : 8,
120                                                                 col : 0,
121                                                                 headerText : 'Pie Chart',
122                                                                 max : false
123                                                         },
124                                                         /*
125                                                          * { sizeX : 1, sizeY : 5, maxHeight : 5, row : 8,
126                                                          * col : 1, headerText : 'Line Chart', max : false },
127                                                          */
128                                                         {
129                                                                 sizeX : 2,
130                                                                 sizeY : 5,
131                                                                 maxHeight : 5,
132                                                                 row : 8,
133                                                                 col : 4,
134                                                                 headerText : 'Gauges',
135                                                                 max : false
136                                                         },
137                                                         {
138                                                                 sizeX : 2,
139                                                                 sizeY : 8,
140                                                                 maxHeight : 8,
141                                                                 row : 16,
142                                                                 col : 0,
143                                                                 headerText : 'Traffic distribution by day of week',
144                                                                 max : false
145                                                         },
146                                                         {
147                                                                 sizeX : 2,
148                                                                 sizeY : 8,
149                                                                 maxHeight : 8,
150                                                                 row : 16,
151                                                                 col : 2,
152                                                                 headerText : 'Busy hour traffic analysis by day of week',
153                                                                 max : false
154                                                         }, {
155                                                                 sizeX : 2,
156                                                                 sizeY : 6,
157                                                                 maxHeight : 7,
158                                                                 row : 24,
159                                                                 col : 4,
160                                                                 headerText : 'Additional Samples',
161                                                                 max : false
162                                                         }, {
163                                                                 sizeX : 2,
164                                                                 sizeY : 8,
165                                                                 maxHeight : 8,
166                                                                 row : 24,
167                                                                 col : 2,
168                                                                 headerText : 'Sticky Notes',
169                                                                 max : false
170                                                         }, {
171                                                                 sizeX : 6,
172                                                                 sizeY : 10,
173                                                                 maxHeight : 10,
174                                                                 row : 32,
175                                                                 col : 0,
176                                                                 headerText : 'Service Configuration',
177                                                                 max : false
178                                                         } ];
179
180                                         /*
181                                          * $.each($scope.standardItems, function(i, a) {
182                                          * $scope.toggleMinMax(i, ''); });
183                                          */
184                                         var counter = 0;
185                                         angular.forEach($scope.standardItems, function(i, a) {
186                                                 $scope.toggleMinMax(counter, '');
187                                                 counter = counter + 1;
188                                         });
189
190                                         $scope.activeTabId = 'Monday';
191                                         // for generic tabs
192
193                                         $scope.selectedTrafficDay = [ {
194                                                 title : 'Mon',
195                                                 url : '#Monday'
196                                         }, {
197                                                 title : 'Tue',
198                                                 url : '#Tuesday'
199                                         }, {
200                                                 title : 'Wed',
201                                                 url : '#Wednesday'
202                                         }, {
203                                                 title : 'Thu',
204                                                 url : '#Thursday'
205                                         }, {
206                                                 title : 'Fri',
207                                                 url : '#Friday'
208                                         }, {
209                                                 title : 'Sat',
210                                                 url : '#Saturday'
211                                         }, {
212                                                 title : 'Sun',
213                                                 url : '#Sunday'
214                                         } ];
215
216                                         $scope.currentSelectedDayTab = '#Monday';
217
218                                         $scope.onClickTab1 = function(Daytab) {
219                                                 $scope.currentSelectedDayTab = Daytab.url;
220                                         }
221
222                                         $scope.isActiveTab1 = function(tabUrl) {
223                                                 return tabUrl == $scope.currentSelectedDayTab;
224                                         }
225
226                                         $scope.gTabs = [ {
227                                                 title : 'Monday',
228                                                 id : 'Monday',
229                                                 url : '#Monday',
230                                                 selected : true
231                                         }, {
232                                                 title : 'Tuesday',
233                                                 id : 'Tuesday',
234                                                 url : '#Tuesday'
235                                         }, {
236                                                 title : 'Wednesday',
237                                                 id : 'Wednesday',
238                                                 url : '#Wednesday'
239                                         }, {
240                                                 title : 'Thursday',
241                                                 id : 'Thursday',
242                                                 url : '#Thursday'
243                                         }, {
244                                                 title : 'Friday',
245                                                 id : 'Friday',
246                                                 url : '#Friday'
247                                         }, {
248                                                 title : 'Saturday',
249                                                 id : 'Saturday',
250                                                 url : '#Saturday'
251                                         }, {
252                                                 title : 'Sunday',
253                                                 id : 'Sunday',
254                                                 url : '#Sunday'
255                                         } ];
256
257                                         $scope.BusyHourTraffic = [ {
258                                                 title : 'BH SNRC DLSTX - Incoming',
259                                                 url : '#Incoming'
260                                         }, {
261                                                 title : 'BH SNRC DLSTX - Outgoing',
262                                                 url : '#Outgoing'
263                                         }, {
264                                                 title : 'BH National - Default',
265                                                 url : '#Default'
266                                         }, {
267                                                 title : 'BH National - Priority',
268                                                 url : '#Priority'
269                                         }, {
270                                                 title : 'BH National',
271                                                 url : '#BHNational'
272                                         }
273
274                                         ];
275
276                                         $scope.currentSelectedBusyHourTraffic = '#Incoming';
277
278                                         $scope.onClickTab2 = function(TrafficTab) {
279                                                 $scope.currentSelectedBusyHourTraffic = TrafficTab.url;
280                                         }
281
282                                         $scope.isActiveTab2 = function(tabUrl) {
283                                                 return tabUrl == $scope.currentSelectedBusyHourTraffic;
284                                         }
285
286                                         $scope.activeTabId2 = 'Incoming';
287                                         // for generic tabs
288                                         $scope.gTabs2 = [ {
289                                                 title : 'BH SNRC DLSTX - Incoming',
290                                                 id : 'Incoming',
291                                                 url : '#Incoming',
292                                                 selected : true
293                                         }, {
294                                                 title : 'BH SNRC DLSTX - Outgoing',
295                                                 id : 'Outgoing',
296                                                 url : '#Outgoing'
297                                         }, {
298                                                 title : 'BH National - Default',
299                                                 id : 'Default',
300                                                 url : '#Default'
301                                         }, {
302                                                 title : 'BH National - Priority',
303                                                 id : 'Priority',
304                                                 url : '#Priority'
305                                         }, {
306                                                 title : 'BH National',
307                                                 id : 'BHNational',
308                                                 url : '#BHNational'
309                                         } ];
310
311                                         $scope.activeTabId3 = 'Incoming';
312                                         // for generic tabs
313                                         $scope.gTabs3 = [ {
314                                                 title : 'BH SNRC DLSTX - Incoming',
315                                                 id : 'Incoming',
316                                                 url : '#Incoming',
317                                                 selected : true
318                                         }, {
319                                                 title : 'BH SNRC DLSTX - Outgoing',
320                                                 id : 'Outgoing',
321                                                 url : '#Outgoing'
322                                         }, {
323                                                 title : 'BH National - Default',
324                                                 id : 'Default',
325                                                 url : '#Default'
326                                         }, {
327                                                 title : 'BH National - Priority',
328                                                 id : 'Priority',
329                                                 url : '#Priority'
330                                         }, {
331                                                 title : 'BH National',
332                                                 id : 'BHNational',
333                                                 url : '#BHNational'
334                                         } ];
335
336                                         /*
337                                          * $scope.$watch('activeTabId', function(newVal) {
338                                          * alert(newval); $('#'+newval).show(); }, true);
339                                          */
340
341                                         $scope.toggleEastToWest = function() {
342                                                 $("#toggle").toggle('slide');
343                                                 if ($("#leftIcon").is(":visible")) {
344                                                         $("#rightIcon").show();
345                                                         $("#leftIcon").hide();
346                                                 } else if ($("#rightIcon").is(":visible")) {
347                                                         $("#rightIcon").hide();
348                                                         $("#leftIcon").show();
349                                                 }
350                                         };
351
352                                         $scope.group1 = {
353                                                 open : true
354                                         };
355                                         $scope.group2 = {
356                                                 open : true
357                                         };
358                                         $scope.group3 = {
359                                                 open : true
360                                         };
361                                         $scope.group4 = {
362                                                 open : true
363                                         };
364                                         $scope.group5 = {
365                                                 open : true
366                                         };
367                                         $scope.group6 = {
368                                                 open : true
369                                         };
370                                         $scope.group7 = {
371                                                 open : true
372                                         };
373                                         $scope.group71 = {
374                                                 open : true
375                                         };
376                                         $scope.group8 = {
377                                                 open : true
378                                         };
379                                         $scope.group9 = {
380                                                 open : true
381                                         };
382                                         $scope.group10 = {
383                                                 open : true
384                                         };
385                                         $scope.group11 = {
386                                                 open : true
387                                         };
388                                         $scope.group12 = {
389                                                 open : false
390                                         };
391                                         
392                         // Fetch manifest info
393                         $scope.manifest = {};
394                         ManifestService.getManifest()
395                         .then(function(jsonObj) {
396                                 // $log.debug("welcome-controller: getManifest returned " + JSON.stringify(jsonObj));
397                                 if (jsonObj.error) {
398                                         $log.error('welcome-controller: failed to get manifest: ' + JSON.stringify(jsonObj));
399                                 }
400                                 else {
401                                         $scope.manifest=jsonObj;
402                                 }
403                         },function(error){
404                                 $log.error("welcome-controller: getManifest failed: " + error);
405                         });     
406                                         
407
408                                 });