Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / static / fusion / raptor / ebz / report_chart_wizard.js
1 app.controller('ChartController', function ($scope, $rootScope, $timeout, $window, $http, $routeParams,modalService) {
2         //$scope.test="1223";
3         //alert($scope.chartType.value);
4         
5         $scope.populateChrtWzdFields = function() {
6                 
7                 $scope.reportRunJson = {};
8         //      console.log($routeParams.reportId); 
9                 $http.get("raptor.htm?action=chart.json&c_master="+$routeParams.reportId).then(function (response) {
10                         //$scope.myData = JSON.stringify(response.data);  
11                 //      response.data.rangeAxisList[0].rangeColorJSON = {};  
12                         $scope.reportRunJson = response.data;
13                         //  $scope.chrtheight =  $scope.reportRunJson.height;
14                 //      console.log(JSON.stringify($scope.reportRunJson));
15                 /*        if ($scope.reportRunJson.showTitle==false)
16                                   $scope.reportRunJson.showTitle="false";
17                           else 
18                                   $scope.reportRunJson.showTitle="true"; */
19                           
20                           console.log($scope.reportRunJson);
21                           
22                           
23                           
24                           
25                           
26                           //Set chart type
27                           if ($scope.reportRunJson.chartTypeJSON) {
28                                   var chrtTypeValue = $scope.reportRunJson.chartTypeJSON.value;
29                                          for(var i = 0; i < $scope.chartTypes.length; i++) {
30                                                     var obj = $scope.chartTypes[i];
31                                                     //console.log(obj.id);
32                                                     if ($scope.chartTypes[i].value==chrtTypeValue) {
33                                                         $scope.reportRunJson.chartTypeJSON.index=$scope.chartTypes[i].index;
34                                                         $scope.reportRunJson.chartTypeJSON.title=$scope.chartTypes[i].title;
35                                                     }
36         
37                                         }
38                           }      
39                                  
40                                 //Set Domain Axis
41                                  if ($scope.reportRunJson.domainAxisJSON) {
42                                           var domaninAxisValue = $scope.reportRunJson.domainAxisJSON.value;
43                                                  for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) {
44                                                            if ($scope.reportRunJson.chartColumnJSONList[i].value==domaninAxisValue) {
45                                                                 $scope.reportRunJson.domainAxisJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index;
46                                                                 $scope.reportRunJson.domainAxisJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title;
47                                                             }
48                 
49                                                 }
50                                   }
51                                  
52                                 //Set Category
53                                  if ($scope.reportRunJson.categoryAxisJSON) {
54                                           var categoryAxisValue = $scope.reportRunJson.categoryAxisJSON.value;
55                                                  for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) {
56                                                            if ($scope.reportRunJson.chartColumnJSONList[i].value==categoryAxisValue) {
57                                                                 $scope.reportRunJson.categoryAxisJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index;
58                                                                 $scope.reportRunJson.categoryAxisJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title;
59                                                             }
60                 
61                                                 }
62                                   }
63                                  
64                                 //Set range axis label
65                 if ($scope.reportRunJson.rangeAxisList) {
66                         for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) { 
67                                  
68                                  if ($scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON) {
69                                           var rangeAxisLabelValue = $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.value;
70                                                  for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) {
71                                                            if ($scope.reportRunJson.chartColumnJSONList[i].value==rangeAxisLabelValue) {
72                                                                 $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index;
73                                                                 $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title;
74                                                             }
75                 
76                                                 }
77                                   }
78                         }
79                 }
80                                 
81                                 
82                                 //set range linetype
83                                 if ($scope.reportRunJson.rangeAxisList) {
84                                         for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) { 
85                                                  if ($scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON != null && $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value != ""
86                                                          && $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value != null) {
87                                                          var lineTypeValue = $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value;
88                                                          for(var i = 0; i < $scope.lineTypes.length; i++) {
89                                                                     if ($scope.lineTypes[i].value==lineTypeValue) {
90                                                                         $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.index=$scope.lineTypes[i].index;
91                                                                         $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.title=$scope.lineTypes[i].title;
92                                                                     }
93                                                 
94                                                         }
95                                                 } else {
96                                                         $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON = null;
97                                                 }  
98                                         }
99                                 
100                                 }
101                                 //set range color
102                                 if ($scope.reportRunJson.rangeAxisList) {
103                                         for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) { 
104                                                  if ($scope.reportRunJson.rangeAxisList[j].rangeColorJSON != null && $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value != ""
105                                                          && $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value != null) {
106                                                          var colorValue = $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value; 
107                                 
108                                                          for(var i = 0; i < $scope.rangeColors.length; i++) {
109                                                                  
110                                                                  if ($scope.rangeColors[i].value==colorValue) {
111                                                                          $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.index=$scope.rangeColors[i].index;
112                                                                          $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.title=$scope.rangeColors[i].title;
113                                                                  }
114                                                          }
115                                                  }else {
116                                                          $scope.reportRunJson.rangeAxisList[j].rangeColorJSON = null; 
117                                                  }
118                                         }
119                                 }
120                                  
121                                  
122                           
123                           
124                           /*      var data = $.param({
125                                   json: JSON.stringify($scope.reportRunJson)
126                         });
127                           console.log(data);
128                           $http.post("/ecomp-sdk-app/testraptorchart", JSON.stringify($scope.reportRunJson)).success(function(data, status) {
129                             console.log(data);
130                             console.log(status);
131                             
132                         })*/
133                           
134                   });
135                 
136                 
137         /*      $scope.chrtwidth =  $scope.reportRunJson.width;
138                 
139                 $scope.chrtheight =  $scope.reportRunJson.height;
140                 $scope.title="false";
141                 $scope.domainAxes = $scope.reportRunJson.chartColumnJSONList;
142                 $scope.categories = $scope.reportRunJson.chartColumnJSONList;
143                 $scope.rangeAxes = $scope.reportRunJson.chartColumnJSONList; */
144                 
145          //     $scope.Color = $scope.rangeColors;
146          //     $scope.lineType = $scope.lineTypes;
147          //     $scope.praxis = $scope.reportRunJson.primaryAxisLabel;
148          //     $scope.secaxis = $scope.reportRunJson.secondaryAxisLabel;
149          //     $scope.raxisminrange = $scope.reportRunJson.minRange;
150          //     $scope.raxismaxrange = $scope.reportRunJson.maxRange;
151          //     $scope.reportRunJson.legendangle = "up_45";
152                 $scope.legend = "true";
153         //      $scope.animate = "true";
154         //      $scope.topmargin = $scope.reportRunJson.topMargin;
155         //      $scope.bottommargin = $scope.reportRunJson.bottomMargin;
156         //      $scope.leftmargin = $scope.reportRunJson.leftMargin;
157         //      $scope.rightmargin = $scope.reportRunJson.rightMargin;
158         //      $scope.tt1=false;
159         
160         
161         
162         }
163         
164         $scope.saveChartData = function() {
165                 //console.log(JSON.stringify($scope.reportRunJson));
166         
167                 //Converting string variables to numbers
168                 $scope.reportRunJson.commonChartOptions.rightMargin = Number($scope.reportRunJson.commonChartOptions.rightMargin);
169                 $scope.reportRunJson.commonChartOptions.topMargin = Number($scope.reportRunJson.commonChartOptions.topMargin);
170                 $scope.reportRunJson.commonChartOptions.bottomMargin = Number($scope.reportRunJson.commonChartOptions.bottomMargin);
171                 $scope.reportRunJson.commonChartOptions.leftMargin = Number($scope.reportRunJson.commonChartOptions.leftMargin);
172         
173                 //Concatenate range Y axis with range label with pipe delimiter
174                 /* if ($scope.reportRunJson.rangeAxisList) {
175                                 
176                                 for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) { 
177                                         
178                                         if ($scope.reportRunJson.rangeAxisList[j].rangeYAxis) {
179                                                 if ($scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON != "" && $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON != null) {
180                                                         $scope.reportRunJson.rangeAxisList[j].rangeYAxis = 
181                                                                 $scope.reportRunJson.rangeAxisList[j].rangeYAxis + "|"+ $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.value;
182                                                         
183                                                         //document.getElementById('yaxs').value = $scope.reportRunJson.rangeAxisList[j].rangeYAxis.substring(0,$scope.reportRunJson.rangeAxisList[j].rangeYAxis.indexOf('|'));
184                                                 }
185                                         } else {
186                                                 if ($scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON != "" && $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON != null)
187                                                         $scope.reportRunJson.rangeAxisList[j].rangeYAxis = "|"+ $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.value;
188                                         
189                                         }
190                                 }
191                                 
192                                 
193                 }*/     
194  
195                 if ($scope.reportRunJson.categoryAxisJSON == "") { 
196                         console.log('Inside categoryAxisJSON value'); 
197                         $scope.reportRunJson.categoryAxisJSON = {}; 
198                         $scope.reportRunJson.categoryAxisJSON.value = -1; 
199                         console.log('$scope.reportRunJson.categoryAxisJSON',$scope.reportRunJson.categoryAxisJSON);  
200                 }
201                 
202                         
203                 $http.post("save_chart", JSON.stringify($scope.reportRunJson)).success(function(data, status) {
204                   //  console.log(data);
205                   //  console.log(status);
206                          $scope.successSubmit=true;
207                         //  modalService.showSuccess("Success","Chart Wizard details have been successfully submitted.");
208                   //      saveProfile();
209                 
210                         })
211                         
212                         
213         /*      $http.post("/ecomp-sdk-app/testraptorchart", $scope.reportRunJson).then(function(response) {
214                         console.log(response.data);
215                         console.log(response.status);
216         
217                         });*/
218         }
219         
220         //$scope.samplearray = ["abc","test"];
221         
222         
223         $scope.addRangeAxisRow = function (rangeaxisitem) {
224                 
225                 
226                 
227                 
228                 $scope.reportRunJson.rangeAxisList.push({  
229                  
230           /*       "rangeColor":{  
231                     "index":0,
232                     "value":rangeaxisitem.rangeColor.value,
233                     "title":rangeaxisitem.rangeColor.title
234                     
235                  },
236                  "rangeLineType":{  
237                     "index":0,
238                     "value":rangeaxisitem.rangeLineType.value,
239                     "title":rangeaxisitem.rangeLineType.title
240                     
241                  },
242                  "rangeaxisLabel":{  
243                     "index":0,
244                     "value":rangeaxisitem.rangeaxisLabel.value,
245                     "title":rangeaxisitem.rangeaxisLabel.value
246                     
247                  },
248                  "YAxis":"",
249                  "chartTitle":""*/
250               });
251         //      alert($scope.reportRunJson.rangeAxisList.length);
252                 console.log($scope.reportRunJson.rangeAxisList);
253         
254         };
255
256         $scope.removeRangeAxisRow = function (index) {
257                 $scope.reportRunJson.rangeAxisList.splice(index, 1);
258                 //console.log($scope.hardCodeReport.rangeAxisList)
259         };
260         
261         
262         
263         /*$scope.saveProfile = function() {
264                   var uuu = "profile/saveProfile?profile_id=" + $scope.profileId;;
265                   var postData={profile: $scope.profile,
266                                         selectedCountry:$scope.selectedCountry!=null?$scope.selectedCountry.value:"",
267                                         selectedState:$scope.stateList.selected!=null?$scope.stateList.selected.value:"",
268                                         selectedTimeZone:$scope.selectedTimeZone!=null?$scope.selectedTimeZone.value:""
269                                };
270                   $.ajax({
271                          type : 'POST',
272                          url : uuu,
273                          dataType: 'json',
274                          contentType: 'application/json',
275                          data: JSON.stringify(postData),
276                          success : function(data){
277                                 modalService.showSuccess("Success","Update Successful.");
278                          },
279                          error : function(data){
280                                  modalService.showFailure("Fail","Error while saving.");
281                          }
282                   });
283         };*/
284         
285         
286  /*     $scope.actionClicked = function(){
287         
288                 if ($scope.chartType=="Bar Chart") {
289                 $scope.tt1=true;
290         } else if ($scope.chartType=="Time Series/Area Chart") {
291                 $scope.tt2=true;
292         }else 
293         //      $scope.tt3=true;
294     };*/
295         
296         $scope.init = function () {
297                 //      console.time("In init");
298                 if ($scope) { 
299                         $scope.populateChrtWzdFields();
300                 //      $scope.saveChartData();
301                 }
302                         
303         };
304         
305         
306         /*$scope.accgroups =  [
307                                  {
308                                      title: "Accordion Item #1",
309                                      content:"Unit test me bro! Proin eu quam malesuada, accumsan velit eu, tristique orci. Donec neque nisl, dignissim ut hendrerit sit amet, tempor id erat. Donec fermentum commodo semper. Sed lectus odio, egestas non volutpat eu, venenatis eu turpis. Donec eget fringilla lorem. Fusce sit amet semper velit. ",
310                                      open: false
311                                  },
312                                  {
313                                      title: "Accordion Item #2",
314                                      content: "Lint me too! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eleifend aliquam eros quis fringilla. Integer eu justo turpis. Nam mauris augue, posuere interdum dignissim sed, tempor sit amet neque. In nec tortor id nibh sollicitudin aliquam sit amet ac augue",
315                                      open: false
316                                  },
317                                  {
318                                      title: "Accordion Item #3",
319                                      content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eleifend aliquam eros quis fringilla. Integer eu justo turpis. Nam mauris augue, posuere interdum dignissim sed, tempor sit amet neque. In nec tortor id nibh sollicitudin aliquam sit amet ac augue",
320                                      open: false
321                                  }
322                              ];*/
323         
324         $scope.domainItems = [{title:"Domain Axis1", content:"Test1", open: false},{title:"Domain Axis2", content:"Test2", open: false}];
325         
326         $scope.chartTypes = [        
327                              {index: 0, value: 'BarChart3D', title: 'Bar Chart'},
328                              {index: 1, value: 'TimeSeriesChart', title: 'Time Series/Area Chart'},
329                              {index: 2, value: 'PieChart', title: 'Pie Chart'},
330                              {index: 3, value: 'AnnotationChart', title: 'Annotation Chart'},
331                              {index: 4, value: 'FlexTimeChart', title: 'Flexible Time Chart'}
332          ];
333          
334          /* $scope.domainAxes = [        
335                                      {index: 0, value: 'scenario_name', title: 'scenario_name'},
336                                      {index: 1, value: 'total_traffic_in_PB', title: 'Total Traffic in PB'},
337                                      {index: 2, value: 'Avg Utilization Day', title: 'Avg Utilization Day'}
338                                      
339                  ];*/
340          
341          $scope.categories = [        
342                                      {index: 0, value: 'scenario_name', title: 'scenario_name'},
343                                      {index: 1, value: 'total_traffic_in_PB', title: 'Total Traffic in PB'},
344                                      {index: 2, value: 'Avg Utilization Day', title: 'Avg Utilization Day'}
345                                      
346                  ];
347          
348          $scope.rangeColors = [        
349                                      
350                                      {index: 0, value: "#1f77b4",title: "Dodger Blue"},                                                 
351                                                          {index: 1, value: "#ff7f0e",title: "Vivid orange"},                                                    
352                                                          {index: 2, value: "#2ca02c",title: "Forest Green"},                                                    
353                                                          {index: 3, value: "#8c864b",title: "Greenish Red"},                                                    
354                                                          {index: 4, value: "#9467bd",title: "Desaturated violet"},                                      
355                                                          {index: 5, value: "#8c564b",title: "Dark moderate red"},                                       
356                                                          {index: 6, value: "#e377c2",title: "Soft pink"},                                                       
357                                                          {index: 7, value: "#7f7f7f",title: "Dark gray"},                                                       
358                                                          {index: 8, value: "#bcbd22",title: "Strong yellow"},                                           
359                                                          {index: 9, value: "#17becf",title: "Strong cyan"},                                                     
360                                                          {index: 10, value: "#dc143c",title: "Vivid red"},                                                      
361                                                          {index: 11, value: "#800080",title: "Dark magenta"},                                                   
362                                                          {index: 12, value: "#0000FF",title: "Blue"},                                                                   
363                                                          {index: 13, value: "#008000",title: "Dark lime green"},                                                
364                                                          {index: 14, value: "#D2691E",title: "Reddish Orange"},                                 
365                                                          {index: 15, value: "#FF0000",title: "Red"},                                                            
366                                                          {index: 16, value: "#000000",title: "Black"},                                                          
367                                                          {index: 17, value: "#DB7093",title: "Pink"},                                                           
368                                                          {index: 18, value: "#FF00FF",title: "Pure Magenta"},                                           
369                                                          {index: 19, value: "#7B68EE",title: "Soft blue"},                                                      
370                                                          {index: 20, value: "#1f77b6",title: "Strong blue"},                                            
371                                                          {index: 21, value: "#9edae5",title: "Very soft cyan"},                                         
372                                                          {index: 22, value: "#393b79",title: "Dark Blue"},                                                      
373                                                          {index: 23, value: "#5254a3",title: "Dark moderate Blue"},                                     
374                                                          {index: 24, value: "#6b6ecf",title: "Slightly desaturated blue"},                      
375                                                          {index: 25, value: "#9c9ede",title: "Very soft blue"},                 
376                                                          {index: 26, value: "#637939",title: "Dark Green"},                                                     
377                                                          {index: 27, value: "#8ca252",title: "Dark moderate green"},                            
378                                                          {index: 28, value: "#b5cf6b",title: "Slightly desaturated green"},                     
379                                                          {index: 29, value: "#cedb9c",title: "Desaturated Green"},      
380      
381                                                          /* Old Colors  */
382                                                          {index: 30, value: "#00FFFF",title: "Aqua"},
383                                                          {index: 31, value: "#000000",title: "Black"},
384                                                          {index: 32, value: "#0000FF",title: "Blue"},
385                                                          {index: 33, value: "#FF00FF",title: "Fuchsia"},
386                                                          {index: 34, value: "#808080",title: "Gray"},
387                                                          {index: 35, value: "#008000",title: "Green"},
388                                                          {index: 36, value: "#00FF00",title: "Lime"},
389                                                          {index: 37, value: "#800000",title: "Maroon"},
390                                                          {index: 38, value: "#000080",title: "Navy"},
391                                                          {index: 39, value: "#808000",title: "Olive"},
392                                                          {index: 40, value: "#FF9900",title: "Orange"},
393                                                          {index: 41, value: "#800080",title: "Purple"},
394                                                          {index: 42, value: "#FF0000",title: "Red"},
395                                                          {index: 43, value: "#C0C0C0",title: "Silver"},
396                                                          {index: 44, value: "#008080",title: "Teal"},
397                                                          {index: 45, value: "#FFFFFF",title: "White"},
398                                                          {index: 46, value: "#FFFF00",title: "Yellow"}
399                                                 ];      
400     
401     
402          $scope.lineTypes = [        
403                              {index: 0, value: 'default', title: 'Default'},
404                              {index: 1, value: 'dotted_lines', title: 'Dotted Lines'},
405                              {index: 2, value: 'dashed_lines', title: 'Dashed Lines'}
406                              
407          ]; 
408          
409          
410          $scope.hardCodeReport= {
411                    "reportID":"3356",
412                    "reportName":"Test: Line Chart",
413                    "reportDescr":"",
414                    "reportTitle":"",
415                    "reportSubTitle":"",
416                    "formFieldList":[
417
418                    ],
419                    "chartColumnJSONList":[
420                       {
421                          "index":0,
422                          "value":"tr0",
423                          "title":"traffic_date",
424                          "$$hashKey":"056"
425                       },
426                       {
427                          "index":1,
428                          "value":"ut1",
429                          "title":"util_perc",
430                          "$$hashKey":"057"
431                       }
432                    ],
433                    "formfield_comments":null,
434                    "totalRows":0,
435                    "chartSqlWhole":"SELECT traffic_date tr0, traffic_date tr0_1,util_perc ut1, 1 FROM portal.demo_util_chart   ORDER BY 1",
436                    "chartAvailable":true,
437                    "chartType":{"index": "", "value": "Bar Chart", "title": ""},
438                    "width":"700",
439                    "height":"420",
440                    "animation":false,
441                    "rotateLabels":"90",
442                    "staggerLabels":false,
443                    "showTitle":"false",
444                    "domainAxis":{
445                               "index":0,
446                               "value":"tr0",
447                               "title":"traffic_date",
448                               "$$hashKey":"11H"
449                            },
450
451                            "categoryAxis":{
452                                       "index":1,
453                                       "value":"ut1",
454                                       "title":"util_perc",
455                                       "$$hashKey":"11I"
456                                    },
457
458                    "hasCategoryAxis":false,
459                    "rangeAxisList":[
460                       {
461                          
462                          "rangeColor":{
463                                 "index":"",
464                             "value":"#bcbd22",
465                             "title":""
466                             
467                          },
468                          
469                          "rangeLineType":{
470                             "index":"",
471                             "value":"dotted_lines",
472                             "title":""
473                             
474                             
475                          },
476                          
477                          "rangeAxisLabel":{
478                             "index":0,
479                             "value":"tr0",
480                             "title":"traffic_date",
481                             "$$hashKey":"056"
482                          },
483                          "YAxis":"10",
484                          "chartTitle":"test"
485                       },
486                       {
487                                  
488                                  "rangeColor":{
489                                         "index":"",
490                                     "value":"#2ca02c",
491                                     "title":""
492                                     
493                                  },
494                                  
495                                  "rangeLineType":{
496                                     "index":"",
497                                     "value":"dashed_lines",
498                                     "title":""
499                                     
500                                     
501                                  },
502                                  
503                                  "rangeAxisLabel":{
504                                     "index":0,
505                                     "value":"tr0",
506                                     "title":"traffic_date",
507                                     "$$hashKey":"056"
508                                  },
509                                  "YAxis":"10",
510                                  "chartTitle":"test"
511                               }
512                       
513                      
514                    ],
515                   
516                    "primaryAxisLabel":"testlabel",
517                    "secondaryAxisLabel":"testseclabel",
518                    "minRange":"10",
519                    "maxRange":"20",
520                    "topMargin":"6",
521                    "bottomMargin":"5",
522                    "leftMargin":"4",
523                    "rightMargin":"3"
524                 };
525          
526          var colorValue = $scope.hardCodeReport.rangeAxisList[0].rangeColor.value;
527          
528          //console.log($scope.hardCodeReport.chartType);
529          
530          // prefill range color
531         /* for(var i = 0; i < $scope.rangeColors.length; i++) {
532                     var obj = $scope.rangeColors[i];
533                     //console.log(obj.id);
534                     if ($scope.rangeColors[i].value==colorValue) {
535                         $scope.hardCodeReport.rangeAxisList[0].rangeColor.index=$scope.rangeColors[i].index;
536                                 $scope.hardCodeReport.rangeAxisList[0].rangeColor.title=$scope.rangeColors[i].title;
537                     }
538
539                 }*/
540          
541          //prefill chart type
542          
543 //       console.log($scope.hardCodeReport.chartType);
544          
545 //       console.log($scope.hardCodeReport.chartType);
546          
547         // console.log($scope.hardCodeReport.rangeAxisList);
548          //prefill rangle line type
549         /* for(var j = 0; j < $scope.hardCodeReport.rangeAxisList.length; j++) { 
550          
551                  var lineTypeValue = $scope.hardCodeReport.rangeAxisList[j].rangeLineType.value;
552                  for(var i = 0; i < $scope.lineTypes.length; i++) {
553                             var obj = $scope.lineTypes[i];
554                             //console.log(obj.id);
555                             if ($scope.lineTypes[i].value==lineTypeValue) {
556                                 $scope.hardCodeReport.rangeAxisList[j].rangeLineType.index=$scope.lineTypes[i].index;
557                                 $scope.hardCodeReport.rangeAxisList[j].rangeLineType.title=$scope.lineTypes[i].title;
558                             }
559         
560                         }
561          }*/
562 //       console.log($scope.hardCodeReport.rangeAxisList);
563          
564         
565          
566          
567          // console.log($scope.hardCodeReport.rangeAxisList[0].rangeColor);
568         /* $scope.hardCodeReport.rangeAxisList[0].rangeColor.index=4;
569          $scope.hardCodeReport.rangeAxisList[0].rangeColor.title="Desaturated violet";*/
570          
571          
572          //console.log($scope.hardCodeReport);
573          
574
575          
576          
577          
578          /*$scope.reportRunJson = 
579                 {
580                            "reportID":"3356",
581                            "reportName":"Test: Line Chart",
582                            "reportDescr":"",
583                            "reportTitle":"",
584                            "reportSubTitle":"",
585                            "formFieldList":[
586
587                            ],
588                            "chartColumnJSONList":[
589                               {
590                                  "index":0,
591                                  "value":"tr0",
592                                  "title":"traffic_date"
593                               },
594                               {
595                                  "index":1,
596                                  "value":"ut1",
597                                  "title":"util_perc"
598                               }
599                            ],
600                            "formfield_comments":null,
601                            "totalRows":0,
602                            "chartSqlWhole":"SELECT traffic_date tr0, traffic_date tr0_1,util_perc ut1, 1 FROM portal.demo_util_chart   ORDER BY 1",
603                            "chartAvailable":true,
604                            "chartType":"TimeSeriesChart",
605                            "width":"700",
606                            "height":"420",
607                            "animation":false,
608                            "rotateLabels":"90",
609                            "staggerLabels":false,
610                            "showTitle":false,
611                            "domainAxis":"tr0",
612                            "categoryAxis":null,
613                            "hasCategoryAxis":false,
614                            "rangeAxisList":[
615                               {
616                                  "YAxis":"",
617                                  "chartTitle":""
618                               }
619                            ],
620                            "primaryAxisLabel":"",
621                            "secondaryAxisLabel":"",
622                            "minRange":"",
623                            "maxRange":"",
624                            "topMargin":"",
625                            "bottomMargin":"",
626                            "leftMargin":"",
627                            "rightMargin":"3"
628                         }; */
629                 $timeout(function() {
630                         $rootScope.isViewRendering = false;
631                         });
632
633
634 });
635
636 app.directive('onlyDigits', function () {
637
638     return {
639         restrict: 'A',
640         require: '?ngModel',
641         link: function (scope, element, attrs, ngModel) {
642             if (!ngModel) return;
643             ngModel.$parsers.unshift(function (inputValue) {
644                 var digits = inputValue.split('').filter(function (s) { return (!isNaN(s) && s != ' '); }).join('');
645                 ngModel.$viewValue = digits;
646                 ngModel.$render();
647                 return digits;
648             });
649         }
650     };
651 });
652
653 app.directive('onlyCharacters', function () {
654
655     return {
656         restrict: 'A',
657         require: '?ngModel',
658         link: function (scope, element, attrs, ngModel) {
659             if (!ngModel) return;
660             ngModel.$parsers.unshift(function (inputValue) {
661                 var digits = inputValue.split('').filter(function (s) { return (isNaN(s) && s != ' '); }).join('');
662                 ngModel.$viewValue = digits;
663                 ngModel.$render();
664                 return digits;
665             });
666         }
667     };
668 });
669
670
671