2b59c57844d5cb00ef3a0cceafcb5fdeb4bd6e9f
[portal/sdk.git] /
1 var ModalInstanceCtrl = function ($scope, $modalInstance, msg,$rootScope) {
2         $scope.msg=msg;
3 }
4
5 var testRunSqlController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, queriedData) {
6         var init = function() {
7                 $scope.isError = false;
8                 if (queriedData.errormessage) {
9                         $scope.isError = true;
10                         $scope.errormessage = queriedData.errormessage;
11                         $scope.stacktrace = queriedData.stacktrace;
12                 } else {
13                         $scope.queryData = queriedData;
14                 }
15         }
16         init();                 
17         $scope.close = function() {
18                 $modalInstance.dismiss();
19         };
20 }
21
22 var openColumnPopupController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, colData, $routeParams) {
23         $scope.processingData=true;
24         $scope.colInfo={};
25         $scope.drilldownReports={};
26         $scope.isEditCol = true;
27         var init = function() {         
28                 $scope.displayAlignmentOptions = [
29                         {value:"null", text:""},                                                         
30                         {value:"Left", text:"Left"},
31                         {value:"Center", text:"Center"},
32                         {value:"Right", text:"Right"}
33                 ];
34                 $scope.dataTypeOptions = [
35                         {value:"Number", text:"Number"},                                                         
36                         {value:"Date", text:"Date"},
37                         {value:"VARCHAR2", text:"Character"},
38                         {value:"Hyperlink", text:"Hyperlink"}
39                 ];
40                 
41                 $scope.multiGroupColLevel = [
42                         {value:"1", text:"1"},
43                         {value:"2", text:"2"},
44                         {value:"3", text:"3"},
45                         {value:"4", text:"4"}
46                 ];
47                 $scope.indentValues = [
48                         {value:"1", text:"1"},
49                         {value:"2", text:"2"},
50                         {value:"3", text:"3"},
51                 ];
52         }
53         
54         $scope.totalForTheColList= [];
55         raptorReportFactory.getTotalForTheColList().then(function(data){
56                 $scope.totalForTheColList = data;
57         },function(error){
58                 $scope.errorPopUp(error);
59                 $log.error("raptorReportFactory: retrieveTotalForTheColList failed.");
60         });     
61         
62         raptorReportFactory.getDrillDownReportList().then(function(data2){
63                 $scope.drilldownReports = data2;
64                 raptorReportFactory.getColumnEditInfoById(colData.id).then(function(data){
65                         $scope.colInfo = data;
66                         if($scope.colInfo.noWrap!=null && ($scope.colInfo.noWrap=='Y' || $scope.colInfo.noWrap==true))
67                                 $scope.colInfo.noWrap=true;
68                         else
69                                 $scope.colInfo.noWrap=false;
70                         $scope.processingData=false;
71                         init();
72                 },function(error){
73                         $scope.errorPopUp(error);
74                         $log.error("raptorReportFactory: getColumnEditInfoById failed.");
75                 });     
76         },function(error){
77                 $scope.errorPopUp(error);
78                 $log.error("raptorReportFactory: getDrillDownReportList failed.");
79         });
80         
81         $scope.massageData = function(){
82                 if(!Number.isInteger($scope.colInfo.level))
83                         $scope.colInfo.level = null;
84                 if(!Number.isInteger($scope.colInfo.indentation))
85                         $scope.colInfo.indentation = null;
86         }
87                                                  
88         $scope.save = function() {
89                 $scope.processingData=true;
90                 $scope.colInfo.noWrap=($scope.colInfo.noWrap==true)?'Y':'N';    
91                 if($scope.colInfo.level && $scope.colInfo.level.startsWith("Select"))
92                         $scope.colInfo.level = null;
93                 if($scope.colInfo.displayTotal && $scope.colInfo.displayTotal.startsWith("Select"))
94                         $scope.colInfo.displayTotal = null;
95                         
96                 if($scope.colInfo.indentation && $scope.colInfo.indentation.startsWith("Select"))
97                         $scope.colInfo.indentation = null;
98                 raptorReportFactory.saveColumnEditInfo($scope.colInfo).then(function(data){
99                         $scope.successPopUp('');
100                         $scope.processingData=false;
101                         $modalInstance.close();                                                                                                                                 
102                 },function(error){
103                         $scope.errorPopUp(error);
104                         $log.error("raptorReportFactory: save failed.");
105                         $scope.processingData=false;
106                 });                                              
107         };                                      
108
109         $scope.cancel = function() {
110                 $modalInstance.dismiss();
111         };
112         
113         
114         /****Drill***/
115         $scope.drilDownValues=[];                       
116         $scope.childReportFF =[];
117         $scope.childReportCol = [];
118         $scope.complete = function() {          
119                 var drillDownParams='';
120                 var ampStr = "&";
121                 var count =0;
122                 for(var i in $scope.selectedDrillReportFormField){      
123                         var selectedRadio = $scope.selectedDrillReportFormField[i];
124                         if( selectedRadio != (i+'-0')){// if it's not 'No Value' 
125                                 if (typeof($scope.drillDownParams[i].fieldName) == "undefined"){        
126                                         if(i>=($scope.drilDownFormField.length-1)){
127                                                 var id = $scope.drilDownFormField[i].id;
128                                                 drillDownParams+= id+"=";
129                                         }               
130                                 }else
131                                         drillDownParams+=$scope.drillDownParams[i].fieldName+"=";
132                                 if( selectedRadio == (i+'-1')){//'Fixed Value'  
133                                         drillDownParams+= $scope.drillDownParams[i].valValue+ampStr;
134                                 }else if( selectedRadio == (i+'-2')){//'Value of Column'
135                                         drillDownParams+= ('['+$scope.drillDownParams[i].valColId+']'+ampStr);
136                                 }else if( selectedRadio == (i+'-3')){//'Value of form field'
137                                         drillDownParams+= ('[!'+$scope.drillDownParams[i].valFieldId+']'+ampStr);
138                                 }else if( selectedRadio == (i+'-4')){//'Value set'
139                                         if($scope.drillDownParams[i].valColId!='' && $scope.drillDownParams[i].valFieldId!='' && $scope.drillDownParams[i].valColId!='Select' && $scope.drillDownParams[i].valFieldId!='Select')        
140                                                 drillDownParams+= ('['+$scope.drillDownParams[i].valColId+'!'+$scope.drillDownParams[i].valFieldId+']'+ampStr);                                         
141                                 }
142                         }
143                 }
144                 drillDownParams = drillDownParams.substring(0, drillDownParams.length - 1);
145                 $scope.colInfo.drilldownParams = drillDownParams;
146                 $scope.isEditCol=true;
147         };
148         $scope.selectedDrillReportFormField = [];
149         $scope.drillDownParams = {};
150         $scope.getDrillReportFormField = function(ddReportId,param){
151                 $scope.isEditCol = false;
152                 $scope.processingData = true;
153                 
154                 raptorReportFactory.getChildReportFormField(ddReportId).then(function(data){                                            
155                         $scope.drilDownFormField = data;
156                         for(var i in data){
157                                 var array = [
158                                         {selection: 'No Value', value:'Accept Default', radioGroup :i+'-'+'0'},
159                                         {selection: 'Fixed Value', value:'Accept Default' , radioGroup :i+'-'+'1'},
160                                         {selection: 'Value of Column', value:'Accept Default', radioGroup :i+'-'+'2'},
161                                         {selection: 'Value of form field', value:'Accept Default', radioGroup :i+'-'+'3'},
162                                         {selection: 'Value set', value:'Pass the value of the selected column if not empty, otherwise pass the value of the selected form field', radioGroup :i+'-'+'4'}
163                                 ]
164                                 $scope.drilDownValues.push(array);
165                         }
166                         
167                         if(param!=''){
168                                 raptorReportFactory.getDrillDownParamDef(param).then(function(dataDD){                          
169                                         var temp = $scope.drilDownFormField;
170                                         $scope.drillDownParams = [];
171                                         for(var i in $scope.drilDownFormField){
172                                                 $scope.selectedDrillReportFormField[i] = i+'-0';
173                                                 var tmp = {
174                                                                 fieldName: $scope.drilDownFormField[i].id,
175                                                                 valColId:'',
176                                                                 ValFieldId:'',
177                                                                 valType:'',
178                                                                 valValue:''
179                                                 };
180                                                 $scope.drillDownParams.push(tmp);
181                                         }
182                                         for(var i in $scope.drilDownFormField){
183                                                 for(var j in dataDD){
184                                                         if($scope.drilDownFormField[i].id == dataDD[j].fieldName){
185                                                                 $scope.selectedDrillReportFormField[i] = i+'-'+dataDD[j].valType;       
186                                                                 $scope.drillDownParams[i] = dataDD[j];
187                                                         }               
188                                                 }
189                                         }
190                                 },function(error){
191                                         $scope.errorPopUp(error);
192                                         $log.error("raptorReportFactory: getChildReportFormField failed.");  
193                                 }).finally(function() {
194                                         $scope.processingData=false;
195                                 });     
196                         }else{
197                                 $scope.processingData = false;
198                         }
199                 },function(error){
200                         $scope.errorPopUp(error);
201                         $log.error("raptorReportFactory: getChildReportFormField failed.");  
202                 });
203
204                 raptorReportFactory.getChildReportFormField($scope.colInfo.drilldownURL).then(function(data){
205                         $scope.childReportFF =data;
206                 },function(error){
207                         $scope.errorPopUp(error);
208                         $log.error("raptorReportFactory: getChildReportFormField failed.");  
209                 });     
210                 
211                 raptorReportFactory.getChildReportColumn($routeParams.reportId).then(function(data){
212                         $scope.childReportCol =data;
213                 },function(error){
214                         $scope.errorPopUp(error);
215                         $log.error("raptorReportFactory: getChildReportFormField failed.");  
216                 });
217         }                               
218 }
219
220
221 var openFormFieldPopupController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, fieldData) {
222         $scope.formFieldEditData = {};
223         $scope.sqlAsDefaultValue ={
224                         value:false
225         };
226         $scope.predefinedValues ={
227                         value:''
228         };
229         var init = function() {
230                 if($scope.type=='edit'){
231                         $scope.dataProcessing = true;
232                         raptorReportFactory.getFormFieldEditInfoById(fieldData.id).then(function(data){
233                                 $scope.dataProcessing = false;
234                                 $scope.formFieldEditData = data;
235                                 if($scope.formFieldEditData.fieldDefaultSQL)
236                                         $scope.sqlAsDefaultValue.value = true;
237                         },function(error){
238                                 $scope.errorPopUp(error);
239                                 $log.error("raptorReportFactory: getColumnEditInfoById failed.");
240                         }).finally(function() {
241                                 $scope.dataProcessing=false; 
242                         });                     
243                 }else{
244                         $scope.formFieldEditData ={
245                                 groupFormField: false,
246                                 visible:"true"
247                         };
248                 }                                                               
249                 $scope.ynOptions = [
250                         {value:"true", text:"Yes"},
251                         {value:"false", text:"No"}                                                       
252                         ];
253                 $scope.verifyFieldValueOptions = [
254                         {value:null, text:"--- Do Not Perform Validation ---"},
255                         {value:"DATE", text:"Date"},
256                         {value:"TIMESTAMP_HR", text:"TimeStamp (Hour)"},
257                         {value:"TIMESTAMP_MIN", text:"TimeStamp (Hour,Min)"},
258                         {value:"TIMESTAMP_SEC", text:"TimeStamp (Hour,Min,Sec)"},
259                         {value:"INTEGER", text:"Integer"},
260                         {value:"POSITIVE_INTEGER", text:"Positive Integer"},
261                         {value:"NON_NEGATIVE_INTEGER", text:"Positive Integer. Cannot Be Zero"},
262                         {value:"FLOAT", text:"Any Number"},
263                         {value:"NON_NEGATIVE_FLOAT", text:"Positive Number"},
264                         {value:"POSITIVE_FLOAT", text:"Positive Number. Cannot Be Zero"}
265                         ]
266                 $scope.fieldTypeOptions = [
267                         {value:"TEXT", text:"Text Box"},
268                         {value:"LIST_BOX", text:"List Box"},
269                         {value:"LIST_MULTI_SELECT", text:"Multi-select List Box"},
270                         {value:"HIDDEN", text:"Hidden"}                                                                                                                                                  
271                         ];
272         }
273         init();
274         $scope.save = function() {
275                 if($scope.sqlAsDefaultValue.value && ($scope.formFieldEditData.fieldDefaultSQL==null || $scope.formFieldEditData.fieldDefaultSQL=='')){
276                         $scope.errorPopUp("if SQL as Default Value is checked, 'Default SQL' and 'SQL Generating Custom List of Values' fields cannot be empty");
277                         return;
278                 }else if(!$scope.sqlAsDefaultValue.value){
279                         $scope.formFieldEditData.fieldDefaultSQL=null;
280                 }
281                 $scope.dataProcessing = true;
282                 console.log($scope.formFieldEditData.validationType);
283                 if($scope.formFieldEditData.validationType=='Select')
284                         $scope.formFieldEditData.validationType = '';
285                 raptorReportFactory.saveFormFieldEditInfo($scope.formFieldEditData).then(function(data){
286                         $scope.dataProcessing = false;
287                         $scope.successPopUp('');
288                         $modalInstance.close(); 
289                 },function(error){
290                         $scope.errorPopUp(error);
291                         $log.error("raptorReportFactory: saveFormFieldEditInfo failed.");
292                 }).finally(function() {
293                         $scope.dataProcessing=false; 
294                 });                       
295         };
296         
297         $scope.add = function() {
298                 $scope.dataProcessing = true;
299                 $scope.formFieldEditData.visible==
300                 raptorReportFactory.addFormFieldEditInfo($scope.formFieldEditData).then(function(data){
301                         $scope.dataProcessing = false;
302                         $modalInstance.close(); 
303                 },function(error){
304                         $scope.errorPopUp(error);
305                         $log.error("raptorReportFactory: add FormFieldEditInfo failed.");
306                 }).finally(function() {
307                         $scope.dataProcessing=false; 
308                 });
309         };
310         
311         $scope.addPredefinedValueList = function() {
312                 if($scope.formFieldEditData.predefinedValueList==null)
313                         $scope.formFieldEditData.predefinedValueList=[];
314                 var item ={
315                                 id:$scope.predefinedValues.value,
316                                 name:$scope.predefinedValues.value,
317                                 selected:false
318                 };
319                 if($scope.predefinedValues.value!=null && $scope.predefinedValues.value!='')
320                         $scope.formFieldEditData.predefinedValueList.push(item);
321         };
322         
323         $scope.removePredefinedValueList = function(removeVal) {
324                 var removeIndex = null;
325                 for(i in $scope.formFieldEditData.predefinedValueList){
326                         if($scope.formFieldEditData.predefinedValueList[i].id == removeVal){
327                                 removeIndex= i;
328                                 break;
329                         }
330                 }
331                 $scope.formFieldEditData.predefinedValueList.splice(removeIndex, 1)
332         };
333
334         $scope.cancel = function() {
335                 $modalInstance.dismiss();
336         };
337 }
338
339
340 var deleteFormFieldController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) {
341         $scope.tempFieldId = rowData.id;
342         $scope.ok = function() {
343                 raptorReportFactory.deleteFormFieldById(rowData.id).then(function(data){
344                         $modalInstance.close();                                                                                                                                                                                                 
345                 },function(error){
346                         $scope.errorPopUp(error);
347                         $log.error("raptorReportFactory: deleteFormFieldById failed.");
348                 });                                                                              
349         }                                        
350         $scope.cancel = function() {
351                 $modalInstance.dismiss();
352         };
353 }
354
355 var removeReportSecurityUserController = function ($scope, $modalInstance, $http, $log, raptorReportFactory,securityUser) {                                      
356         $scope.securityUserName = securityUser.name;
357         $scope.ok = function() {
358                 raptorReportFactory.removeReportSecurityUser(securityUser.id).then(function(data){
359                         $modalInstance.close();         
360                 },function(error){
361                         $scope.errorPopUp(error);
362                         $log.error("raptorReportFactory: removeReportSecurityUser failed.");
363                 });                                                      
364         }                                        
365         $scope.cancel = function() {
366                 $modalInstance.dismiss();
367         };
368 }
369
370 var removeReportSecurityRoleController = function ($scope, $modalInstance, $http, $log, raptorReportFactory,securityRole) {                                      
371         $scope.securityRoleName = securityRole.name;
372         $scope.ok = function() {
373                 raptorReportFactory.removeReportSecurityRole(securityRole.id).then(function(data){
374                         $modalInstance.close();         
375                 },function(error){
376                         $scope.errorPopUp(error);
377                         $log.error("raptorReportFactory: removeReportSecurityRole failed.");
378                 });     
379         }                                        
380         $scope.cancel = function() {
381                 $modalInstance.dismiss();
382         };
383 }
384
385 var formFieldVerifySQLController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, queriedData) {
386         var init = function() {
387                 $scope.isError = false;
388                 if (queriedData.errormessage) {
389                         $scope.isError = true;
390                         $scope.errormessage = queriedData.errormessage;
391                         $scope.stacktrace = queriedData.stacktrace;
392                 } else {
393                         $scope.queryData = queriedData;
394                 }
395         }
396         init();                 
397         $scope.close = function() {
398                 $modalInstance.dismiss();
399         };
400 }
401 var toggleUserEditAccessActiveController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) {
402         $scope.rowData = rowData;
403         $scope.toggleEditAccessStatus = function(rowData) {
404                 raptorReportFactory.toggleUserEditAccess(rowData);
405                 $modalInstance.close();
406         };
407
408         $scope.cancelEditAccessToggle = function(rowData) {
409                 rowData.accessAllowed = ! rowData.accessAllowed;
410                 $modalInstance.dismiss('cancel');}
411 }
412
413 var toggleRoleEditAccessActiveController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) {
414         $scope.rowData = rowData;
415         $scope.toggleEditAccessStatus = function(rowData) {
416                 raptorReportFactory.toggleRoleEditAccess(rowData); 
417                 $modalInstance.close();
418         };
419
420         $scope.cancelEditAccessToggle = function(rowData) {
421                 rowData.accessAllowed = ! rowData.accessAllowed;
422                 $modalInstance.dismiss('cancel');}
423 }