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';
8 import {CdkDragDrop, moveItemInArray, transferArrayItem} from '@angular/cdk/drag-drop';
11 selector: 'app-definition',
12 templateUrl: './definition.component.html',
13 styleUrls: ['./definition.component.css'],
14 providers: [ NgbModal]
16 export class DefinitionComponent implements OnInit {
21 showSpinner : boolean;
23 @Input() closable = true;
25 @Input("reportId") reportId1 : string;
26 @Input ("reportMode") reportMode : string;
35 reportDescription : string;
39 reportDefinition : string;
41 hideFormFields : boolean;
45 emptyMessage : string;
46 heightContainer : number;
47 widthContainer : number;
48 allowScheduler : boolean;
49 sizedByContent : boolean;
50 hideFormFields1 : boolean;
52 hideReportData : boolean;
55 disableColumnSort : boolean;
56 runTimeFormNum : number;
58 reportSubTitle : string;
74 definitionPostResponse1 : any;
76 definitionPostResponse : any;
82 dashboardLayoutHTML : any;
84 pilotModalComponent : DefinitionSaveDialogComponent;
86 IncomingReportId : number;
87 displayOptionsArr : {}[] = [];
89 constructor(private _http : HttpClient, private _route : ActivatedRoute, private _definitionService : DefinitionService) {
90 this.showSpinner = true;
91 this.IncomingReportId = -1;
92 this.dashboardObj = [];
93 this.dashboardLayoutHTML = "";
99 this.showDialog = false;
100 this.showSpinner = true;
101 this._route.params.subscribe(params => {
103 if(params["reportId"] !== undefined)
105 this.IncomingReportId = params["reportId"];
106 this.reportId1 = params["reportId"];
109 if(this.IncomingReportId == -1 && this.reportMode == "Create")
111 this._definitionService.getDefinitionPageDetails(this.IncomingReportId, this.reportMode)
112 .subscribe((response) => {
113 this.finalGetObj = response;
115 this.reportId = response["reportId"];
116 this.reportName = response["reportName"];
117 this.reportDescription = response["reportDescr"];
118 this.reportType = response["reportType"];
119 this.dataSrc = response["dbInfo"];
120 this.helpText = response["formHelpText"];
121 this.reportDefinition = response["repDefType"];
122 this.pageSize = response["pageSize"];
123 this.hideFormFields1 = response["hideFormFieldsAfterRun"];
124 this.maxRows = response["maxRowsInExcelCSVDownload"];
125 this.colsFrozen = response["frozenColumns"];
126 this.gridAlign = response["dataGridAlign"];
127 this.emptyMessage = response["emptyMessage"];
129 if(response["dashboardLayoutJSON"])
131 this.dashboardObj = JSON.parse(response["dashboardLayoutJSON"]);
132 this.dashboardLayoutHTML = response["dashboardLayoutHTML"];
135 if(response["displayArea"])
137 for(let i=0; i<response["displayArea"].length; i++)
139 if(response["displayArea"][i]["selected"] === true)
141 this.displayArea = response["displayArea"][i]["name"];
146 this.heightContainer = response["dataContainerHeight"];
147 this.widthContainer = response["dataContainerWidth"];
148 this.allowScheduler = (response["allowScheduler"] == "Y" ? true : false);
149 this.sizedByContent = (response["sizedByContent"] == "Y" ? true : false);
151 this.displayOptionsArr = response["displayOptions"];
154 for(let cont of this.displayOptionsArr)
156 if(cont["name"] == "HideFormFields")
158 this.hideFormFields = cont["selected"];
160 if(cont["name"] == "HideChart")
162 this.hideChart = cont["selected"];
164 if(cont["name"] == "HideReportData")
166 this.hideReportData = cont["selected"];
168 if(cont["name"] == "HideExcel")
170 this.hideExcel = cont["selected"];
172 if(cont["name"] == "HidePdf")
174 this.hidePDF = cont["selected"];
178 this.disableColumnSort = response["runtimeColSortDisabled"];
179 this.runTimeFormNum = response["numFormCols"];
180 this.reportTitle = response["reportTitle"];
181 this.reportSubTitle = response["reportSubTitle"];
182 this.oneTime = (response["oneTimeRec"] == "Y" ? true : false );
183 this.hourly = (response["hourlyRec"] == "Y" ? true : false );
184 this.daily = (response["dailyRec"] == "Y" ? true : false );
185 this.MonFri = (response["dailyMFRec"] == "Y" ? true : false );
186 this.Weekly = (response["weeklyRec"] == "Y" ? true : false );
187 this.Monthly = (response["monthlyRec"] == "Y" ? true : false );
189 this.showSpinner = false;
194 if(this.IncomingReportId !== -1 && this.reportMode == "Edit")
196 this._definitionService.getDefinitionPageDetails(this.IncomingReportId, this.reportMode)
197 .subscribe((response) => {
198 this.finalGetObj = response;
200 this.reportId = response["reportId"];
201 this.reportName = response["reportName"];
202 this.reportDescription = response["reportDescr"];
203 this.reportType = response["reportType"];
205 if(this.reportType === "Linear")
207 this.dataSrc = response["dbInfo"];
208 this.helpText = response["formHelpText"];
209 this.reportDefinition = response["repDefType"];
210 this.pageSize = response["pageSize"];
211 this.hideFormFields1 = response["hideFormFieldsAfterRun"];
212 this.maxRows = response["maxRowsInExcelCSVDownload"];
213 this.colsFrozen = response["frozenColumns"];
214 this.gridAlign = response["dataGridAlign"];
215 this.emptyMessage = response["emptyMessage"];
217 if(response["displayArea"])
219 for(let i=0; i<response["displayArea"].length; i++)
221 if(response["displayArea"][i]["selected"] === true)
223 this.displayArea = response["displayArea"][i]["name"];
230 this.heightContainer = response["dataContainerHeight"];
231 this.widthContainer = response["dataContainerWidth"];
232 this.allowScheduler = (response["allowScheduler"] == "Y" ? true : false);
233 this.sizedByContent = (response["sizedByContent"] == "Y" ? true : false);
235 this.displayOptionsArr = response["displayOptions"];
237 for(let cont of this.displayOptionsArr)
239 if(cont["name"] == "HideFormFields")
241 this.hideFormFields = cont["selected"];
243 if(cont["name"] == "HideChart")
245 this.hideChart = cont["selected"];
247 if(cont["name"] == "HideReportData")
249 this.hideReportData = cont["selected"];
251 if(cont["name"] == "HideExcel")
253 this.hideExcel = cont["selected"];
255 if(cont["name"] == "HidePdf")
257 this.hidePDF = cont["selected"];
261 this.disableColumnSort = response["runtimeColSortDisabled"];
262 this.runTimeFormNum = response["numFormCols"];;
263 this.reportTitle = response["reportTitle"];
264 this.reportSubTitle = response["reportSubTitle"];
265 this.oneTime = (response["oneTimeRec"] == "Y" ? true : false );
266 this.hourly = (response["hourlyRec"] == "Y" ? true : false );
267 this.daily = (response["dailyRec"] == "Y" ? true : false );
268 this.MonFri = (response["dailyMFRec"] == "Y" ? true : false );
269 this.Weekly = (response["weeklyRec"] == "Y" ? true : false );
270 this.Monthly = (response["monthlyRec"] == "Y" ? true : false );
274 if(response["dashboardLayoutJSON"])
276 this.dashboardObj = JSON.parse(response["dashboardLayoutJSON"]);
280 if(response["dashboardLayoutHTML"])
282 this.dashboardLayoutHTML = response["dashboardLayoutHTML"];
288 this.showSpinner = false;
297 saveDefinitionInfo(){
299 if(this.IncomingReportId == -1 && this.reportMode == "Create")
301 this.finalPostObj["tabName"] = "Definition";
302 this.finalPostObj["tabId"] = "Def";
303 this.finalPostObj["reportId"] = this.reportId;
304 this.finalPostObj["reportName"] = this.reportName;
305 this.finalPostObj["reportDescr"] = this.reportDescription;
306 this.finalPostObj["reportType"] = this.reportType;
307 this.finalPostObj["reportTypeList"] = null;
308 this.finalPostObj["dbInfo"] = this.dataSrc;
309 this.finalPostObj["formHelpText"] = this.helpText;
310 this.finalPostObj["pageSize"] = this.pageSize;
312 this.finalPostObj["dbInfoList"] = [
319 this.finalPostObj["displayArea"] = [
323 "selected": (this.displayArea == "HOME" ? true : false)
328 "selected": (this.displayArea == "CUSTOMER" ? true : false)
333 "selected": (this.displayArea == "REPORTS" ? true : false)
336 this.finalPostObj["hideFormFieldsAfterRun"] = this.hideFormFields1;
337 this.finalPostObj["maxRowsInExcelCSVDownload"] = this.maxRows;
338 this.finalPostObj["frozenColumns"] = this.colsFrozen;
339 this.finalPostObj["dataGridAlign"] = this.gridAlign;
340 this.finalPostObj["emptyMessage"] = this.emptyMessage;
341 this.finalPostObj["dataContainerHeight"] = this.heightContainer;
342 this.finalPostObj["dataContainerWidth"] = this.widthContainer;
343 this.finalPostObj["displayOptions"] = [
345 "name": "HideFormFields",
346 "selected": (this.hideFormFields == undefined ? false : this.hideFormFields )
350 "selected": (this.hideChart == undefined ? false : this.hideChart )
353 "name": "HideReportData",
354 "selected": (this.hideReportData == undefined ? false : this.hideReportData )
358 "selected": (this.hideExcel == undefined ? false : this.hideExcel )
362 "selected": (this.hidePDF == undefined ? false : this.hidePDF )
365 this.finalPostObj["runtimeColSortDisabled"] = this.disableColumnSort;
366 this.finalPostObj["numFormCols"] = this.runTimeFormNum;
367 this.finalPostObj["reportTitle"] = this.reportTitle;
368 this.finalPostObj["reportSubTitle"] = this.reportSubTitle;
369 this.finalPostObj["oneTimeRec"] = this.oneTime;
370 this.finalPostObj["hourlyRec"] = this.hourly;
371 this.finalPostObj["dailyRec"] = this.daily;
372 this.finalPostObj["dailyMFRec"] = this.MonFri;
373 this.finalPostObj["weeklyRec"] = this.Weekly;
374 this.finalPostObj["monthlyRec"] = this.Monthly;
375 this.finalPostObj["allowScheduler"] = (this.allowScheduler == true ? "Y" : "N" );
376 this.finalPostObj["sizedByContent"] = (this.sizedByContent == true ? "Y" : "N" );
377 this.finalPostObj["repDefType"] = this.reportDefinition;
379 this._http.post(environment.baseUrl + "report/wizard/save_def_tab_data/Create", this.finalPostObj, { headers: new HttpHeaders({'Content-Type': 'application/json'})})
380 .subscribe((response) => {
381 if(response["message"] === "Success Definition of given report is saved in session.")
383 this.status = "Success!";
384 this.message = "Your change has been saved! Definition is updated.";
385 this.showDialog = !this.showDialog;
386 this.closable = true;
390 this.status = "Failure!";
391 this.message = "Definition could not be updated.";
392 this.showDialog = !this.showDialog;
393 this.closable = true;
398 if(this.IncomingReportId !== -1 && this.reportMode == "Edit")
401 this.finalPostObj["tabName"] = "Definition";
402 this.finalPostObj["tabId"] = "Def";
403 this.finalPostObj["reportId"] = this.reportId;
404 this.finalPostObj["reportName"] = this.reportName;
405 this.finalPostObj["reportDescr"] = this.reportDescription;
406 this.finalPostObj["reportType"] = this.reportType;
408 if(this.reportType === "Dashboard")
410 this.finalPostObj["dashboardLayoutJSON"] = JSON.stringify(this.dashboardObj);
411 this.finalPostObj["dashboardLayoutHTML"] = this.dashboardLayoutHTML;
417 this.finalPostObj["reportTypeList"] = null;
418 this.finalPostObj["dbInfo"] = this.dataSrc;
419 this.finalPostObj["formHelpText"] = this.helpText;
420 this.finalPostObj["pageSize"] = this.pageSize;
422 this.finalPostObj["dbInfoList"] = [
429 this.finalPostObj["displayArea"] = [
433 "selected": (this.displayArea == "HOME" ? true : false)
438 "selected": (this.displayArea == "CUSTOMER" ? true : false)
443 "selected": (this.displayArea == "REPORTS" ? true : false)
446 this.finalPostObj["hideFormFieldsAfterRun"] = this.hideFormFields1;
447 this.finalPostObj["maxRowsInExcelCSVDownload"] = this.maxRows;
448 this.finalPostObj["frozenColumns"] = this.colsFrozen;
449 this.finalPostObj["dataGridAlign"] = this.gridAlign;
450 this.finalPostObj["emptyMessage"] = this.emptyMessage;
451 this.finalPostObj["dataContainerHeight"] = this.heightContainer;
452 this.finalPostObj["dataContainerWidth"] = this.widthContainer;
453 this.finalPostObj["displayOptions"] = [
455 "name": "HideFormFields",
456 "selected": (this.hideFormFields == undefined ? false : this.hideFormFields )
460 "selected": (this.hideChart == undefined ? false : this.hideChart )
463 "name": "HideReportData",
464 "selected": (this.hideReportData == undefined ? false : this.hideReportData )
468 "selected": (this.hideExcel == undefined ? false : this.hideExcel )
472 "selected": (this.hidePDF == undefined ? false : this.hidePDF )
475 this.finalPostObj["runtimeColSortDisabled"] = this.disableColumnSort;
476 this.finalPostObj["numFormCols"] = this.runTimeFormNum;
477 this.finalPostObj["reportTitle"] = this.reportTitle;
478 this.finalPostObj["reportSubTitle"] = this.reportSubTitle;
479 this.finalPostObj["oneTimeRec"] = this.oneTime;
480 this.finalPostObj["hourlyRec"] = this.hourly;
481 this.finalPostObj["dailyRec"] = this.daily;
482 this.finalPostObj["dailyMFRec"] = this.MonFri;
483 this.finalPostObj["weeklyRec"] = this.Weekly;
484 this.finalPostObj["monthlyRec"] = this.Monthly;
485 this.finalPostObj["allowScheduler"] = (this.allowScheduler == true ? "Y" : "N" );
486 this.finalPostObj["sizedByContent"] = (this.sizedByContent == true ? "Y" : "N" );
487 this.finalPostObj["repDefType"] = this.reportDefinition;
491 this._definitionService.portDefinitionPageDetails(this.IncomingReportId, this.finalPostObj)
492 .subscribe((response) => {
494 if(response["message"] === "Success Definition of given report is saved in session.")
496 this.status = "Success!";
497 this.message = "Your change has been saved! Definition is updated.";
498 this.showDialog = !this.showDialog;
499 this.closable = true;
503 this.status = "Failure!";
504 this.message = "Definition could not be updated.";
505 this.showDialog = !this.showDialog;
506 this.closable = true;
515 this.showDialog = !this.showDialog;
516 this.closable = false;
519 onTransferDashboardObj(transferredDashboardObj : any)
521 this.dashboardObj = transferredDashboardObj;