1 import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2 import { HttpClient, HttpHeaders } from '@angular/common/http';
3 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
4 import { DefinitionSaveDialogComponent } from './definition-save-dialog/definition-save-dialog.component';
5 import {ActivatedRoute} from "@angular/router";
6 import { environment } from '../../../../../../environments/environment';
7 import { DefinitionService } from './definition.service';
10 selector: 'app-definition',
11 templateUrl: './definition.component.html',
12 styleUrls: ['./definition.component.css'],
13 providers: [ NgbModal]
15 export class DefinitionComponent implements OnInit {
17 showSpinner : boolean;
19 @Input() closable = true;
21 @Input("reportId") reportId1 : string;
22 @Input ("reportMode") reportMode : string;
31 reportDescription : string;
35 reportDefinition : string;
37 HideFormFields : boolean;
41 emptyMessage : string;
42 heightContainer : number;
43 widthContainer : number;
44 allowScheduler : boolean;
45 sizedByContent : boolean;
46 hideFormFields1 : boolean;
48 HideReportData : boolean;
51 disableColumnSort : boolean;
52 runTimeFormNum : number;
54 reportSubTitle : string;
70 definitionPostResponse1 : any;
72 definitionPostResponse : any;
78 pilotModalComponent : DefinitionSaveDialogComponent;
80 IncomingReportId : number;
82 constructor(private _http : HttpClient, private _route : ActivatedRoute, private _definitionService : DefinitionService) {
83 this.showSpinner = true;
84 this.IncomingReportId = -1;
90 this.showDialog = false;
91 this.showSpinner = true;
92 this._route.params.subscribe(params => {
94 if(params["reportId"] !== undefined)
96 this.IncomingReportId = params["reportId"];
97 this.reportId1 = params["reportId"];
101 console.log(this.IncomingReportId, this.reportMode);
103 if(this.IncomingReportId == -1 && this.reportMode == "Create")
105 this._definitionService.getDefinitionPageDetails(this.IncomingReportId, this.reportMode)
106 .subscribe((response) => {
107 this.finalGetObj = response;
109 console.log(this.finalGetObj);
110 this.reportId = response["reportId"];
111 this.reportName = response["reportName"];
112 this.reportDescription = response["reportDescr"];
113 this.reportType = response["reportType"];
114 this.dataSrc = response["dbInfo"];
115 this.helpText = response["formHelpText"];
116 this.reportDefinition = response["repDefType"];
117 this.pageSize = response["pageSize"];
118 this.hideFormFields1 = response["hideFormFieldsAfterRun"];
119 this.maxRows = response["maxRowsInExcelCSVDownload"];
120 this.colsFrozen = response["frozenColumns"];
121 this.gridAlign = response["dataGridAlign"];
122 this.emptyMessage = response["emptyMessage"];
124 for(let i=0; i<response["displayArea"].length; i++)
126 if(response["displayArea"][i]["selected"] === true)
128 this.displayArea = response["displayArea"][i]["name"];
134 this.heightContainer = response["dataContainerHeight"];
135 this.widthContainer = response["dataContainerWidth"];
136 this.allowScheduler = (response["allowScheduler"] == "Y" ? true : false);
137 this.sizedByContent = (response["sizedByContent"] == "Y" ? true : false);
139 eval("this." + eval("response[" + '"displayOptions"' + "][0]['name']") +"=" + "response[" +'"displayOptions"'+"][0]["+'"selected"'+"];");
140 eval("this." + eval("response[" + '"displayOptions"' + "][1]['name']") +"=" + "response[" +'"displayOptions"'+"][1]["+'"selected"'+"];");
141 eval("this." + eval("response[" + '"displayOptions"' + "][2]['name']") +"=" + "response[" +'"displayOptions"'+"][2]["+'"selected"'+"];");
142 eval("this." + eval("response[" + '"displayOptions"' + "][3]['name']") +"=" + "response[" +'"displayOptions"'+"][3]["+'"selected"'+"];");
143 eval("this." + eval("response[" + '"displayOptions"' + "][4]['name']") +"=" + "response[" +'"displayOptions"'+"][4]["+'"selected"'+"];");
145 this.disableColumnSort = response["runtimeColSortDisabled"];
146 this.runTimeFormNum = 100;
147 this.reportTitle = response["reportTitle"];
148 this.reportSubTitle = response["reportSubTitle"];
149 this.oneTime = (response["oneTimeRec"] == "Y" ? true : false );
150 this.hourly = (response["hourlyRec"] == "Y" ? true : false );
151 this.daily = (response["dailyRec"] == "Y" ? true : false );
152 this.MonFri = (response["dailyMFRec"] == "Y" ? true : false );
153 this.Weekly = (response["weeklyRec"] == "Y" ? true : false );
154 this.Monthly = (response["monthlyRec"] == "Y" ? true : false );
156 this.showSpinner = false;
161 if(this.IncomingReportId !== -1 && this.reportMode == "Edit")
163 this._definitionService.getDefinitionPageDetails(this.IncomingReportId, this.reportMode)
164 .subscribe((response) => {
165 this.finalGetObj = response;
167 console.log(this.finalGetObj);
168 this.reportId = response["reportId"];
169 this.reportName = response["reportName"];
170 this.reportDescription = response["reportDescr"];
171 this.reportType = response["reportType"];
172 this.dataSrc = response["dbInfo"];
173 this.helpText = response["formHelpText"];
174 this.reportDefinition = response["repDefType"];
175 this.pageSize = response["pageSize"];
176 this.hideFormFields1 = response["hideFormFieldsAfterRun"];
177 this.maxRows = response["maxRowsInExcelCSVDownload"];
178 this.colsFrozen = response["frozenColumns"];
179 this.gridAlign = response["dataGridAlign"];
180 this.emptyMessage = response["emptyMessage"];
182 for(let i=0; i<response["displayArea"].length; i++)
184 if(response["displayArea"][i]["selected"] === true)
186 this.displayArea = response["displayArea"][i]["name"];
192 this.heightContainer = response["dataContainerHeight"];
193 this.widthContainer = response["dataContainerWidth"];
194 this.allowScheduler = (response["allowScheduler"] == "Y" ? true : false);
195 this.sizedByContent = (response["sizedByContent"] == "Y" ? true : false);
197 eval("this." + eval("response[" + '"displayOptions"' + "][0]['name']") +"=" + "response[" +'"displayOptions"'+"][0]["+'"selected"'+"];");
198 eval("this." + eval("response[" + '"displayOptions"' + "][1]['name']") +"=" + "response[" +'"displayOptions"'+"][1]["+'"selected"'+"];");
199 eval("this." + eval("response[" + '"displayOptions"' + "][2]['name']") +"=" + "response[" +'"displayOptions"'+"][2]["+'"selected"'+"];");
200 eval("this." + eval("response[" + '"displayOptions"' + "][3]['name']") +"=" + "response[" +'"displayOptions"'+"][3]["+'"selected"'+"];");
201 eval("this." + eval("response[" + '"displayOptions"' + "][4]['name']") +"=" + "response[" +'"displayOptions"'+"][4]["+'"selected"'+"];");
203 this.disableColumnSort = response["runtimeColSortDisabled"];
204 this.runTimeFormNum = 100;
205 this.reportTitle = response["reportTitle"];
206 this.reportSubTitle = response["reportSubTitle"];
207 this.oneTime = (response["oneTimeRec"] == "Y" ? true : false );
208 this.hourly = (response["hourlyRec"] == "Y" ? true : false );
209 this.daily = (response["dailyRec"] == "Y" ? true : false );
210 this.MonFri = (response["dailyMFRec"] == "Y" ? true : false );
211 this.Weekly = (response["weeklyRec"] == "Y" ? true : false );
212 this.Monthly = (response["monthlyRec"] == "Y" ? true : false );
214 this.showSpinner = false;
223 this.showDialog = false;
224 this.showSpinner = true;
225 this._route.params.subscribe(params => {
227 if(params["reportId"] !== undefined)
229 this.IncomingReportId = params["reportId"];
230 this.reportId1 = params["reportId"];
234 console.log(this.IncomingReportId, this.reportMode);
236 if(this.IncomingReportId == -1 && this.reportMode == "Create")
238 this._definitionService.getDefinitionPageDetails(this.IncomingReportId, this.reportMode)
239 .subscribe((response) => {
240 this.finalGetObj = response;
242 console.log(this.finalGetObj);
243 this.reportId = response["reportId"];
244 this.reportName = response["reportName"];
245 this.reportDescription = response["reportDescr"];
246 this.reportType = response["reportType"];
247 this.dataSrc = response["dbInfo"];
248 this.helpText = response["formHelpText"];
249 this.reportDefinition = response["repDefType"];
250 this.pageSize = response["pageSize"];
251 this.hideFormFields1 = response["hideFormFieldsAfterRun"];
252 this.maxRows = response["maxRowsInExcelCSVDownload"];
253 this.colsFrozen = response["frozenColumns"];
254 this.gridAlign = response["dataGridAlign"];
255 this.emptyMessage = response["emptyMessage"];
257 for(let i=0; i<response["displayArea"].length; i++)
259 if(response["displayArea"][i]["selected"] === true)
261 this.displayArea = response["displayArea"][i]["name"];
267 this.heightContainer = response["dataContainerHeight"];
268 this.widthContainer = response["dataContainerWidth"];
269 this.allowScheduler = (response["allowScheduler"] == "Y" ? true : false);
270 this.sizedByContent = (response["sizedByContent"] == "Y" ? true : false);
272 eval("this." + eval("response[" + '"displayOptions"' + "][0]['name']") +"=" + "response[" +'"displayOptions"'+"][0]["+'"selected"'+"];");
273 eval("this." + eval("response[" + '"displayOptions"' + "][1]['name']") +"=" + "response[" +'"displayOptions"'+"][1]["+'"selected"'+"];");
274 eval("this." + eval("response[" + '"displayOptions"' + "][2]['name']") +"=" + "response[" +'"displayOptions"'+"][2]["+'"selected"'+"];");
275 eval("this." + eval("response[" + '"displayOptions"' + "][3]['name']") +"=" + "response[" +'"displayOptions"'+"][3]["+'"selected"'+"];");
276 eval("this." + eval("response[" + '"displayOptions"' + "][4]['name']") +"=" + "response[" +'"displayOptions"'+"][4]["+'"selected"'+"];");
278 this.disableColumnSort = response["runtimeColSortDisabled"];
279 this.runTimeFormNum = 100;
280 this.reportTitle = response["reportTitle"];
281 this.reportSubTitle = response["reportSubTitle"];
282 this.oneTime = (response["oneTimeRec"] == "Y" ? true : false );
283 this.hourly = (response["hourlyRec"] == "Y" ? true : false );
284 this.daily = (response["dailyRec"] == "Y" ? true : false );
285 this.MonFri = (response["dailyMFRec"] == "Y" ? true : false );
286 this.Weekly = (response["weeklyRec"] == "Y" ? true : false );
287 this.Monthly = (response["monthlyRec"] == "Y" ? true : false );
289 this.showSpinner = false;
294 if(this.IncomingReportId !== -1 && this.reportMode == "Edit")
296 this._definitionService.getDefinitionPageDetails(this.IncomingReportId, this.reportMode)
297 .subscribe((response) => {
298 this.finalGetObj = response;
300 console.log(this.finalGetObj);
301 this.reportId = response["reportId"];
302 this.reportName = response["reportName"];
303 this.reportDescription = response["reportDescr"];
304 this.reportType = response["reportType"];
305 this.dataSrc = response["dbInfo"];
306 this.helpText = response["formHelpText"];
307 this.reportDefinition = response["repDefType"];
308 this.pageSize = response["pageSize"];
309 this.hideFormFields1 = response["hideFormFieldsAfterRun"];
310 this.maxRows = response["maxRowsInExcelCSVDownload"];
311 this.colsFrozen = response["frozenColumns"];
312 this.gridAlign = response["dataGridAlign"];
313 this.emptyMessage = response["emptyMessage"];
315 for(let i=0; i<response["displayArea"].length; i++)
317 if(response["displayArea"][i]["selected"] === true)
319 this.displayArea = response["displayArea"][i]["name"];
325 this.heightContainer = response["dataContainerHeight"];
326 this.widthContainer = response["dataContainerWidth"];
327 this.allowScheduler = (response["allowScheduler"] == "Y" ? true : false);
328 this.sizedByContent = (response["sizedByContent"] == "Y" ? true : false);
330 eval("this." + eval("response[" + '"displayOptions"' + "][0]['name']") +"=" + "response[" +'"displayOptions"'+"][0]["+'"selected"'+"];");
331 eval("this." + eval("response[" + '"displayOptions"' + "][1]['name']") +"=" + "response[" +'"displayOptions"'+"][1]["+'"selected"'+"];");
332 eval("this." + eval("response[" + '"displayOptions"' + "][2]['name']") +"=" + "response[" +'"displayOptions"'+"][2]["+'"selected"'+"];");
333 eval("this." + eval("response[" + '"displayOptions"' + "][3]['name']") +"=" + "response[" +'"displayOptions"'+"][3]["+'"selected"'+"];");
334 eval("this." + eval("response[" + '"displayOptions"' + "][4]['name']") +"=" + "response[" +'"displayOptions"'+"][4]["+'"selected"'+"];");
336 this.disableColumnSort = response["runtimeColSortDisabled"];
337 this.runTimeFormNum = 100;
338 this.reportTitle = response["reportTitle"];
339 this.reportSubTitle = response["reportSubTitle"];
340 this.oneTime = (response["oneTimeRec"] == "Y" ? true : false );
341 this.hourly = (response["hourlyRec"] == "Y" ? true : false );
342 this.daily = (response["dailyRec"] == "Y" ? true : false );
343 this.MonFri = (response["dailyMFRec"] == "Y" ? true : false );
344 this.Weekly = (response["weeklyRec"] == "Y" ? true : false );
345 this.Monthly = (response["monthlyRec"] == "Y" ? true : false );
347 this.showSpinner = false;
354 saveDefinitionInfo(){
356 if(this.IncomingReportId == -1 && this.reportMode == "Create")
358 this.finalPostObj["tabName"] = "Definition";
359 this.finalPostObj["tabId"] = "Def";
360 this.finalPostObj["reportId"] = this.reportId;
361 this.finalPostObj["reportName"] = this.reportName;
362 this.finalPostObj["reportDescr"] = this.reportDescription;
363 this.finalPostObj["reportType"] = this.reportType;
364 this.finalPostObj["reportTypeList"] = null;
365 this.finalPostObj["dbInfo"] = this.dataSrc;
366 this.finalPostObj["formHelpText"] = this.helpText;
367 this.finalPostObj["pageSize"] = this.pageSize;
369 this.finalPostObj["dbInfoList"] = [
376 this.finalPostObj["displayArea"] = [
380 "selected": (this.displayArea == "HOME" ? true : false)
385 "selected": (this.displayArea == "CUSTOMER" ? true : false)
390 "selected": (this.displayArea == "REPORTS" ? true : false)
393 this.finalPostObj["hideFormFieldsAfterRun"] = this.hideFormFields1;
394 this.finalPostObj["maxRowsInExcelCSVDownload"] = this.maxRows;
395 this.finalPostObj["frozenColumns"] = this.colsFrozen;
396 this.finalPostObj["dataGridAlign"] = this.gridAlign;
397 this.finalPostObj["emptyMessage"] = this.emptyMessage;
398 this.finalPostObj["dataContainerHeight"] = this.heightContainer;
399 this.finalPostObj["dataContainerWidth"] = this.widthContainer;
400 this.finalPostObj["displayOptions"] = [
402 "name": "HideFormFields",
403 "selected": (this.HideFormFields == undefined ? false : this.HideFormFields )
407 "selected": (this.HideChart == undefined ? false : this.HideChart )
410 "name": "HideReportData",
411 "selected": (this.HideReportData == undefined ? false : this.HideReportData )
415 "selected": (this.HideExcel == undefined ? false : this.HideExcel )
419 "selected": (this.HidePDF == undefined ? false : this.HidePDF )
422 this.finalPostObj["runtimeColSortDisabled"] = this.disableColumnSort;
423 this.finalPostObj["numFormCols"] = this.runTimeFormNum;
424 this.finalPostObj["reportTitle"] = this.reportTitle;
425 this.finalPostObj["reportSubTitle"] = this.reportSubTitle;
426 this.finalPostObj["oneTimeRec"] = this.oneTime;
427 this.finalPostObj["hourlyRec"] = this.hourly;
428 this.finalPostObj["dailyRec"] = this.daily;
429 this.finalPostObj["dailyMFRec"] = this.MonFri;
430 this.finalPostObj["weeklyRec"] = this.Weekly;
431 this.finalPostObj["monthlyRec"] = this.Monthly;
432 this.finalPostObj["allowScheduler"] = (this.allowScheduler == true ? "Y" : "N" );
433 this.finalPostObj["sizedByContent"] = (this.sizedByContent == true ? "Y" : "N" );
434 this.finalPostObj["repDefType"] = this.reportDefinition;
436 this._http.post(environment.baseUrl + "report/wizard/save_def_tab_data/Create", this.finalPostObj, { headers: new HttpHeaders({'Content-Type': 'application/json'})})
437 .subscribe((response) => {
439 //console.log(response);
441 if(response["message"] === "Success Definition of given report is saved in session.")
443 this.status = "Success!";
444 this.message = "Your change has been saved! Definition is updated.";
445 this.showDialog = !this.showDialog;
446 this.closable = true;
450 this.status = "Failure!";
451 this.message = "Definition could not be updated.";
452 this.showDialog = !this.showDialog;
453 this.closable = true;
458 if(this.IncomingReportId !== -1 && this.reportMode == "Edit")
461 console.log("Reached Here!!!");
462 this.finalPostObj["tabName"] = "Definition";
463 this.finalPostObj["tabId"] = "Def";
464 this.finalPostObj["reportId"] = this.reportId;
465 this.finalPostObj["reportName"] = this.reportName;
466 this.finalPostObj["reportDescr"] = this.reportDescription;
467 this.finalPostObj["reportType"] = this.reportType;
468 this.finalPostObj["reportTypeList"] = null;
469 this.finalPostObj["dbInfo"] = this.dataSrc;
470 this.finalPostObj["formHelpText"] = this.helpText;
471 this.finalPostObj["pageSize"] = this.pageSize;
473 this.finalPostObj["dbInfoList"] = [
480 this.finalPostObj["displayArea"] = [
484 "selected": (this.displayArea == "HOME" ? true : false)
489 "selected": (this.displayArea == "CUSTOMER" ? true : false)
494 "selected": (this.displayArea == "REPORTS" ? true : false)
497 this.finalPostObj["hideFormFieldsAfterRun"] = this.hideFormFields1;
498 this.finalPostObj["maxRowsInExcelCSVDownload"] = this.maxRows;
499 this.finalPostObj["frozenColumns"] = this.colsFrozen;
500 this.finalPostObj["dataGridAlign"] = this.gridAlign;
501 this.finalPostObj["emptyMessage"] = this.emptyMessage;
502 this.finalPostObj["dataContainerHeight"] = this.heightContainer;
503 this.finalPostObj["dataContainerWidth"] = this.widthContainer;
504 this.finalPostObj["displayOptions"] = [
506 "name": "HideFormFields",
507 "selected": (this.HideFormFields == undefined ? false : this.HideFormFields )
511 "selected": (this.HideChart == undefined ? false : this.HideChart )
514 "name": "HideReportData",
515 "selected": (this.HideReportData == undefined ? false : this.HideReportData )
519 "selected": (this.HideExcel == undefined ? false : this.HideExcel )
523 "selected": (this.HidePDF == undefined ? false : this.HidePDF )
526 this.finalPostObj["runtimeColSortDisabled"] = this.disableColumnSort;
527 this.finalPostObj["numFormCols"] = this.runTimeFormNum;
528 this.finalPostObj["reportTitle"] = this.reportTitle;
529 this.finalPostObj["reportSubTitle"] = this.reportSubTitle;
530 this.finalPostObj["oneTimeRec"] = this.oneTime;
531 this.finalPostObj["hourlyRec"] = this.hourly;
532 this.finalPostObj["dailyRec"] = this.daily;
533 this.finalPostObj["dailyMFRec"] = this.MonFri;
534 this.finalPostObj["weeklyRec"] = this.Weekly;
535 this.finalPostObj["monthlyRec"] = this.Monthly;
536 this.finalPostObj["allowScheduler"] = (this.allowScheduler == true ? "Y" : "N" );
537 this.finalPostObj["sizedByContent"] = (this.sizedByContent == true ? "Y" : "N" );
538 this.finalPostObj["repDefType"] = this.reportDefinition;
540 this._definitionService.portDefinitionPageDetails(this.IncomingReportId, this.finalPostObj)
541 .subscribe((response) => {
543 //console.log(response);
545 if(response["message"] === "Success Definition of given report is saved in session.")
547 this.status = "Success!";
548 this.message = "Your change has been saved! Definition is updated.";
549 this.showDialog = !this.showDialog;
550 this.closable = true;
554 this.status = "Failure!";
555 this.message = "Definition could not be updated.";
556 this.showDialog = !this.showDialog;
557 this.closable = true;
566 this.showDialog = !this.showDialog;
567 this.closable = false;