summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/welcome-controller.js
blob: b2b3a43be2fd0a7c97393eb3b4f056ff1a160ae1 (plain)
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
appDS2
		.directive(
				'integer',
				function() {
					return {
						require : 'ngModel',
						link : function(scope, ele, attr, ctrl) {
							ctrl.$parsers.unshift(function(viewValue) {
								if (viewValue === '' || viewValue === null
										|| typeof viewValue === 'undefined') {
									return null;
								}
								return parseInt(viewValue, 10);
							});
						}
					};
				})

		.controller(
				'welcomeController',
				function($scope, $interval, $http, $modal, $log, ManifestService) {

					$scope.testMsg = "Welcome Page1";
					$scope.gridsterOpts = {
						columns : 6, // the width of the grid, in columns
						pushing : true, // whether to push other items out of
										// the way on move or resize
						floating : true, // whether to automatically float
											// items up so they stack (you can
											// temporarily disable if you are
											// adding unsorted items with
											// ng-repeat)
						width : 'auto', // can be an integer or 'auto'. 'auto'
										// scales gridster to be the full width
										// of its containing element
						colWidth : 'auto', // can be an integer or 'auto'.
											// 'auto' uses the pixel width of
											// the element divided by 'columns'
						rowHeight : 60, // can be an integer or 'match'. Match
										// uses the colWidth, giving you square
										// widgets.
						margins : [ 10, 10 ], // the pixel distance between
												// each widget
						outerMargin : true, // whether margins apply to outer
											// edges of the grid
						swapping : true,
						draggable : {
							enabled : true, // whether dragging items is
											// supported
							stop : function(event, uiWidget, $element) {
								$scope.setCookie();
							} // optional callback fired when item is finished
								// dragging
						}

					};

					/*
					 * $scope.gridsterOpts = { columns: 6, width: 'auto',
					 * colWidth: '230', rowHeight: '120', margins: [10, 10],
					 * outerMargin: true, pushing: true, floating: true,
					 * swapping: true };
					 */

					$scope.toggleMinMax = function(index, tileName) {
						if (tileName == '') {
							$scope.standardItems[index].max = !$scope.standardItems[index].max;
							if ($scope.standardItems[index].max)
								$scope.standardItems[index].sizeY = $scope.standardItems[index].maxHeight;
							else
								$scope.standardItems[index].sizeY = 0;
						} else {
							$scope.tileTemp = $scope.$eval(tileName);
							var tileMax = $parse(tileName + '.max');
							tileMax.assign($scope, !$scope.$eval(tileName).max);
							var tileSizeY = $parse(tileName + '.sizeY');
							if ($scope.tileTemp.max)
								tileSizeY.assign($scope,
										$scope.tileTemp.maxHeight);
							else
								tileSizeY.assign($scope, 0);
						}
					};

					// These map directly to gridsterItem options
					// IMPORTANT: Items should be placed in the grid in the
					// order in which
					// they should appear.
					// In most cases the sorting should be by row ASC, col ASC
					$scope.standardItems = [
							{
								sizeX : 2,
								sizeY : 8,
								maxHeight : 8,
								row : 0,
								col : 0,
								headerText : 'Dashboard',
								max : false

							},
							{
								sizeX : 2,
								sizeY : 5,
								maxHeight : 5,
								row : 0,
								col : 2,
								headerText : 'Donut Chart',
								max : false

							},/*
								 * { sizeX : 1, sizeY : 5, maxHeight : 5, row :
								 * 0, col : 2, headerText : 'Area Chart', max :
								 * false },
								 */
							{
								sizeX : 2,
								sizeY : 5,
								maxHeight : 5,
								row : 8,
								col : 0,
								headerText : 'Pie Chart',
								max : false
							},
							/*
							 * { sizeX : 1, sizeY : 5, maxHeight : 5, row : 8,
							 * col : 1, headerText : 'Line Chart', max : false },
							 */
							{
								sizeX : 2,
								sizeY : 5,
								maxHeight : 5,
								row : 8,
								col : 4,
								headerText : 'Gauges',
								max : false
							},
							{
								sizeX : 2,
								sizeY : 8,
								maxHeight : 8,
								row : 16,
								col : 0,
								headerText : 'Traffic distribution by day of week',
								max : false
							},
							{
								sizeX : 2,
								sizeY : 8,
								maxHeight : 8,
								row : 16,
								col : 2,
								headerText : 'Busy hour traffic analysis by day of week',
								max : false
							}, {
								sizeX : 2,
								sizeY : 6,
								maxHeight : 7,
								row : 24,
								col : 4,
								headerText : 'Additional Samples',
								max : false
							}, {
								sizeX : 2,
								sizeY : 8,
								maxHeight : 8,
								row : 24,
								col : 2,
								headerText : 'Sticky Notes',
								max : false
							}, {
								sizeX : 6,
								sizeY : 10,
								maxHeight : 10,
								row : 32,
								col : 0,
								headerText : 'Service Configuration',
								max : false
							} ];

					/*
					 * $.each($scope.standardItems, function(i, a) {
					 * $scope.toggleMinMax(i, ''); });
					 */
					var counter = 0;
					angular.forEach($scope.standardItems, function(i, a) {
						$scope.toggleMinMax(counter, '');
						counter = counter + 1;
					});

					$scope.activeTabId = 'Monday';
					// for generic tabs

					$scope.selectedTrafficDay = [ {
						title : 'Mon',
						url : '#Monday'
					}, {
						title : 'Tue',
						url : '#Tuesday'
					}, {
						title : 'Wed',
						url : '#Wednesday'
					}, {
						title : 'Thu',
						url : '#Thursday'
					}, {
						title : 'Fri',
						url : '#Friday'
					}, {
						title : 'Sat',
						url : '#Saturday'
					}, {
						title : 'Sun',
						url : '#Sunday'
					} ];

					$scope.currentSelectedDayTab = '#Monday';

					$scope.onClickTab1 = function(Daytab) {
						$scope.currentSelectedDayTab = Daytab.url;
					}

					$scope.isActiveTab1 = function(tabUrl) {
						return tabUrl == $scope.currentSelectedDayTab;
					}

					$scope.gTabs = [ {
						title : 'Monday',
						id : 'Monday',
						url : '#Monday',
						selected : true
					}, {
						title : 'Tuesday',
						id : 'Tuesday',
						url : '#Tuesday'
					}, {
						title : 'Wednesday',
						id : 'Wednesday',
						url : '#Wednesday'
					}, {
						title : 'Thursday',
						id : 'Thursday',
						url : '#Thursday'
					}, {
						title : 'Friday',
						id : 'Friday',
						url : '#Friday'
					}, {
						title : 'Saturday',
						id : 'Saturday',
						url : '#Saturday'
					}, {
						title : 'Sunday',
						id : 'Sunday',
						url : '#Sunday'
					} ];

					$scope.BusyHourTraffic = [ {
						title : 'BH SNRC DLSTX - Incoming',
						url : '#Incoming'
					}, {
						title : 'BH SNRC DLSTX - Outgoing',
						url : '#Outgoing'
					}, {
						title : 'BH National - Default',
						url : '#Default'
					}, {
						title : 'BH National - Priority',
						url : '#Priority'
					}, {
						title : 'BH National',
						url : '#BHNational'
					}

					];

					$scope.currentSelectedBusyHourTraffic = '#Incoming';

					$scope.onClickTab2 = function(TrafficTab) {
						$scope.currentSelectedBusyHourTraffic = TrafficTab.url;
					}

					$scope.isActiveTab2 = function(tabUrl) {
						return tabUrl == $scope.currentSelectedBusyHourTraffic;
					}

					$scope.activeTabId2 = 'Incoming';
					// for generic tabs
					$scope.gTabs2 = [ {
						title : 'BH SNRC DLSTX - Incoming',
						id : 'Incoming',
						url : '#Incoming',
						selected : true
					}, {
						title : 'BH SNRC DLSTX - Outgoing',
						id : 'Outgoing',
						url : '#Outgoing'
					}, {
						title : 'BH National - Default',
						id : 'Default',
						url : '#Default'
					}, {
						title : 'BH National - Priority',
						id : 'Priority',
						url : '#Priority'
					}, {
						title : 'BH National',
						id : 'BHNational',
						url : '#BHNational'
					} ];

					$scope.activeTabId3 = 'Incoming';
					// for generic tabs
					$scope.gTabs3 = [ {
						title : 'BH SNRC DLSTX - Incoming',
						id : 'Incoming',
						url : '#Incoming',
						selected : true
					}, {
						title : 'BH SNRC DLSTX - Outgoing',
						id : 'Outgoing',
						url : '#Outgoing'
					}, {
						title : 'BH National - Default',
						id : 'Default',
						url : '#Default'
					}, {
						title : 'BH National - Priority',
						id : 'Priority',
						url : '#Priority'
					}, {
						title : 'BH National',
						id : 'BHNational',
						url : '#BHNational'
					} ];

					/*
					 * $scope.$watch('activeTabId', function(newVal) {
					 * alert(newval); $('#'+newval).show(); }, true);
					 */

					$scope.toggleEastToWest = function() {
						$("#toggle").toggle('slide');
						if ($("#leftIcon").is(":visible")) {
							$("#rightIcon").show();
							$("#leftIcon").hide();
						} else if ($("#rightIcon").is(":visible")) {
							$("#rightIcon").hide();
							$("#leftIcon").show();
						}
					};

					$scope.group1 = {
						open : true
					};
					$scope.group2 = {
						open : true
					};
					$scope.group3 = {
						open : true
					};
					$scope.group4 = {
						open : true
					};
					$scope.group5 = {
						open : true
					};
					$scope.group6 = {
						open : true
					};
					$scope.group7 = {
						open : true
					};
					$scope.group71 = {
						open : true
					};
					$scope.group8 = {
						open : true
					};
					$scope.group9 = {
						open : true
					};
					$scope.group10 = {
						open : true
					};
					$scope.group11 = {
						open : true
					};
					$scope.group12 = {
						open : false
					};
					
			// Fetch manifest info
			$scope.manifest = {};
			ManifestService.getManifest()
   			.then(function(jsonObj) {
   				// $log.debug("welcome-controller: getManifest returned " + JSON.stringify(jsonObj));
   				if (jsonObj.error) {
   					$log.error('welcome-controller: failed to get manifest: ' + JSON.stringify(jsonObj));
   				}
   				else {
   					$scope.manifest=jsonObj;
   				}
   			},function(error){
   				$log.error("welcome-controller: getManifest failed: " + error);
   			});    	
					

				});