builder
This commit is contained in:
parent
7c1a487114
commit
4f75ecb3e0
@ -254,7 +254,7 @@ export class ReportbuildqueryComponent implements OnInit {
|
|||||||
name;
|
name;
|
||||||
databaseName;
|
databaseName;
|
||||||
databasename(val) {
|
databasename(val) {
|
||||||
console.log(val);
|
console.log('connection ', val);
|
||||||
this.databaseName = val.name;
|
this.databaseName = val.name;
|
||||||
this.selecteddatabase = val.conn_string;
|
this.selecteddatabase = val.conn_string;
|
||||||
console.log(this.selecteddatabase);
|
console.log(this.selecteddatabase);
|
||||||
|
|||||||
@ -23,6 +23,18 @@
|
|||||||
<label for="workflow_name">{{'ACTIVE'| translate}}</label>
|
<label for="workflow_name">{{'ACTIVE'| translate}}</label>
|
||||||
<input type="checkbox" formControlName="active" clrToggle value="billable" name="billable" />
|
<input type="checkbox" formControlName="active" clrToggle value="billable" name="billable" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- SureConnect Dropdown -->
|
||||||
|
<div class="clr-col-md-4 clr-col-sm-12">
|
||||||
|
<label for="sureConnectId">SureConnect Connection</label>
|
||||||
|
<select formControlName="sureConnectId" class="clr-select">
|
||||||
|
<option value="">-- Select SureConnect --</option>
|
||||||
|
<option *ngFor="let conn of sureconnectData" [value]="conn.id">
|
||||||
|
{{conn.connection_name || conn.id}}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<div class="clr-col-md-4 clr-col-sm-12">
|
<div class="clr-col-md-4 clr-col-sm-12">
|
||||||
<label for="url">Get URL</label>
|
<label for="url">Get URL</label>
|
||||||
@ -76,4 +88,4 @@
|
|||||||
<button type="submit" class="btn btn-primary" [disabled]="!entryForm.valid" (click)="onSubmit()">{{'SUBMIT' | translate}}</button>
|
<button type="submit" class="btn btn-primary" [disabled]="!entryForm.valid" (click)="onSubmit()">{{'SUBMIT' | translate}}</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -4,6 +4,8 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
|||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ToastrService } from 'ngx-toastr';
|
import { ToastrService } from 'ngx-toastr';
|
||||||
import { ReportBuilderService } from 'src/app/services/api/report-builder.service';
|
import { ReportBuilderService } from 'src/app/services/api/report-builder.service';
|
||||||
|
import { SureconnectService } from '../../dashboardnew/sureconnect/sureconnect.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-report-build2add',
|
selector: 'app-report-build2add',
|
||||||
templateUrl: './report-build2add.component.html',
|
templateUrl: './report-build2add.component.html',
|
||||||
@ -11,8 +13,12 @@ import { ReportBuilderService } from 'src/app/services/api/report-builder.servic
|
|||||||
})
|
})
|
||||||
export class ReportBuild2addComponent implements OnInit {
|
export class ReportBuild2addComponent implements OnInit {
|
||||||
public entryForm: FormGroup;
|
public entryForm: FormGroup;
|
||||||
|
// Add sureconnect data property
|
||||||
|
sureconnectData: any[] = [];
|
||||||
|
|
||||||
constructor(private _fb: FormBuilder, private router: Router,private toastr: ToastrService,
|
constructor(private _fb: FormBuilder, private router: Router,private toastr: ToastrService,
|
||||||
private route: ActivatedRoute,private reportBuilderService: ReportBuilderService) { }
|
private route: ActivatedRoute,private reportBuilderService: ReportBuilderService,
|
||||||
|
private sureconnectService: SureconnectService) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.entryForm = this._fb.group({
|
this.entryForm = this._fb.group({
|
||||||
@ -20,9 +26,23 @@ export class ReportBuild2addComponent implements OnInit {
|
|||||||
description:[null],
|
description:[null],
|
||||||
active:[null],
|
active:[null],
|
||||||
isSql:[false],
|
isSql:[false],
|
||||||
|
// Add sureConnectId field to the form
|
||||||
|
sureConnectId: [null],
|
||||||
Rpt_builder2_lines: this._fb.array([this.initLinesFormReport()]),
|
Rpt_builder2_lines: this._fb.array([this.initLinesFormReport()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Load sureconnect data
|
||||||
|
this.loadSureconnectData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add method to load sureconnect data
|
||||||
|
loadSureconnectData() {
|
||||||
|
this.sureconnectService.getAll().subscribe((data: any[]) => {
|
||||||
|
this.sureconnectData = data;
|
||||||
|
console.log('Sureconnect data loaded:', this.sureconnectData);
|
||||||
|
}, (error) => {
|
||||||
|
console.log('Error loading sureconnect data:', error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initLinesFormReport() {
|
initLinesFormReport() {
|
||||||
@ -68,4 +88,4 @@ export class ReportBuild2addComponent implements OnInit {
|
|||||||
this.router.navigate(["../all"], { relativeTo: this.route });
|
this.router.navigate(["../all"], { relativeTo: this.route });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,13 +1,13 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h3 style="font-weight: 300;display: inline;"><b>REPORT SET UP - Project Details Report ({{ReportData.id}})</b></h3>
|
<h3 style="font-weight: 300;display: inline;"><b>REPORT SET UP - Project Details Report ({{ReportData.id}})</b></h3>
|
||||||
<span class="label label-light-blue" style="display: inline;margin-left: 10px;">Edit Mode</span>
|
<span class="label label-light-blue" style="display: inline;margin-left: 10px;">Edit Mode</span>
|
||||||
<hr />
|
<hr />
|
||||||
<form [formGroup]="entryForm">
|
<form [formGroup]="entryForm">
|
||||||
<div class="clr-row">
|
<div class="clr-row">
|
||||||
<div class="clr-col-lg-12 clr-col-md-12 clr-col-sm-12">
|
<div class="clr-col-lg-12 clr-col-md-12 clr-col-sm-12">
|
||||||
<div>
|
<div>
|
||||||
<div class="clr-row">
|
<div class="clr-row">
|
||||||
<!-- <div class="clr-col-md-4 clr-col-sm-12">
|
<!-- <div class="clr-col-md-4 clr-col-sm-12">
|
||||||
<div class="clr-col-sm-12">
|
<div class="clr-col-sm-12">
|
||||||
<label for="projectName">Connection Name</label>
|
<label for="projectName">Connection Name</label>
|
||||||
<select formControlName="conn_name" name="conn_name" [(ngModel)]="nodeEditProperties.conn_name" id="service" class="clr-dropdown">
|
<select formControlName="conn_name" name="conn_name" [(ngModel)]="nodeEditProperties.conn_name" id="service" class="clr-dropdown">
|
||||||
@ -24,55 +24,70 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="clr-col-md-4 clr-col-sm-12">
|
<div class="clr-col-md-4 clr-col-sm-12">
|
||||||
<label for="url">Get URL</label>
|
<label for="url">Get URL</label>
|
||||||
<div> <input type="text" class="clr-input" formControlName="url" name="url" [(ngModel)]="nodeEditProperties.url" placeholder="Enter Url" style="width: 76%"> <span><button class="btn btn-icon btn-primary" (click)="getkeys()">
|
<div> <input type="text" class="clr-input" formControlName="url" name="url"
|
||||||
<clr-icon shape="view-list"></clr-icon>
|
[(ngModel)]="nodeEditProperties.url" placeholder="Enter Url" style="width: 76%"> <span><button
|
||||||
</button></span></div>
|
class="btn btn-icon btn-primary" (click)="getkeys()">
|
||||||
</div>
|
<clr-icon shape="view-list"></clr-icon>
|
||||||
<div class="clr-col-md-4 clr-col-sm-12">
|
</button></span></div>
|
||||||
<label for="workflow_name">Include Date filter</label>
|
</div>
|
||||||
<input type="checkbox" formControlName="date_param_req" name="date_param_req" [(ngModel)]="nodeEditProperties.date_param_req" clrToggle />
|
<div class="clr-col-md-4 clr-col-sm-12">
|
||||||
</div>
|
<label for="workflow_name">Include Date filter</label>
|
||||||
<div class="clr-col-md-4 clr-col-sm-12">
|
<input type="checkbox" formControlName="date_param_req" name="date_param_req"
|
||||||
<label>Standard Parameters</label>
|
[(ngModel)]="nodeEditProperties.date_param_req" clrToggle />
|
||||||
<clr-combobox-container style="margin-top: 0; padding-top: 0;">
|
</div>
|
||||||
<!-- <label style="padding-bottom: 5px; padding-top:0px; font-weight: lighter;" class="p1">Select Left Side Filter</label> -->
|
|
||||||
<clr-combobox formControlName="std_param_html" name="std_param_html" [(ngModel)]="nodeEditProperties.std_param_html" clrMulti="true"
|
<!-- SureConnect Dropdown -->
|
||||||
required>
|
<div class="clr-col-md-4 clr-col-sm-12">
|
||||||
<ng-container *clrOptionSelected="let selected">
|
<label for="sureConnectId">SureConnect Connection</label>
|
||||||
{{selected}}
|
<select formControlName="sureConnectId" class="clr-select">
|
||||||
</ng-container>
|
<option value="">-- Select SureConnect --</option>
|
||||||
<clr-options>
|
<option *ngFor="let conn of sureconnectData" [value]="conn.id">
|
||||||
<clr-option *clrOptionItems="let state of keysfromurl" [clrValue]="state">
|
{{conn.name || conn.id}}
|
||||||
{{state}}
|
</option>
|
||||||
</clr-option>
|
</select>
|
||||||
</clr-options>
|
</div>
|
||||||
</clr-combobox>
|
|
||||||
</clr-combobox-container>
|
<div class="clr-col-md-4 clr-col-sm-12">
|
||||||
|
<label>Standard Parameters</label>
|
||||||
</div>
|
<clr-combobox-container style="margin-top: 0; padding-top: 0;">
|
||||||
<div class="clr-col-md-4 clr-col-sm-12">
|
<!-- <label style="padding-bottom: 5px; padding-top:0px; font-weight: lighter;" class="p1">Select Left Side Filter</label> -->
|
||||||
<label>List</label>
|
<clr-combobox formControlName="std_param_html" name="std_param_html"
|
||||||
<select>
|
[(ngModel)]="nodeEditProperties.std_param_html" clrMulti="true" required>
|
||||||
<option value="">Choose from list</option>
|
<ng-container *clrOptionSelected="let selected">
|
||||||
<option></option>
|
{{selected}}
|
||||||
</select>
|
</ng-container>
|
||||||
|
<clr-options>
|
||||||
</div>
|
<clr-option *clrOptionItems="let state of keysfromurl" [clrValue]="state">
|
||||||
<!-- <div class="clr-col-md-4 clr-col-sm-12">
|
{{state}}
|
||||||
|
</clr-option>
|
||||||
|
</clr-options>
|
||||||
|
</clr-combobox>
|
||||||
|
</clr-combobox-container>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="clr-col-md-4 clr-col-sm-12">
|
||||||
|
<label>List</label>
|
||||||
|
<select>
|
||||||
|
<option value="">Choose from list</option>
|
||||||
|
<option></option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- <div class="clr-col-md-4 clr-col-sm-12">
|
||||||
<div class="clr-col-sm-12">
|
<div class="clr-col-sm-12">
|
||||||
<label for="description" class="d1">Adhoc Parameter String (html)</label>
|
<label for="description" class="d1">Adhoc Parameter String (html)</label>
|
||||||
<textarea id="t1" cols="10" rows="3" formControlName="adhoc_param_html" placeholder="Enter Description" name="adhoc_param_html" [(ngModel)]="nodeEditProperties.adhoc_param_html" style="width:100%">
|
<textarea id="t1" cols="10" rows="3" formControlName="adhoc_param_html" placeholder="Enter Description" name="adhoc_param_html" [(ngModel)]="nodeEditProperties.adhoc_param_html" style="width:100%">
|
||||||
</textarea>
|
</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<br>
|
</div>
|
||||||
<!-- <div class="clr-row" style="padding-left:10px;">
|
</div>
|
||||||
|
<br>
|
||||||
|
<!-- <div class="clr-row" style="padding-left:10px;">
|
||||||
<div class="clr-col-md-4 clr-col-sm-12">
|
<div class="clr-col-md-4 clr-col-sm-12">
|
||||||
<label for="description" class="d1">Column String (html)</label>
|
<label for="description" class="d1">Column String (html)</label>
|
||||||
<textarea id="t1" cols="10" rows="3" formControlName="column_str" placeholder="Enter Description" name="column_str" [(ngModel)]="nodeEditProperties.column_str" style="width:100%">
|
<textarea id="t1" cols="10" rows="3" formControlName="column_str" placeholder="Enter Description" name="column_str" [(ngModel)]="nodeEditProperties.column_str" style="width:100%">
|
||||||
@ -85,11 +100,10 @@
|
|||||||
</textarea>
|
</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
<br>
|
<br>
|
||||||
<div class="center">
|
<div class="center">
|
||||||
<button type="button" class="btn btn-outline" (click)="back()">BACK</button>
|
<button type="button" class="btn btn-outline" (click)="back()">BACK</button>
|
||||||
<button type="submit" form-control class="btn btn-primary" (click)="onSubmit()">UPDATE</button>
|
<button type="submit" form-control class="btn btn-primary" (click)="onSubmit()">UPDATE</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -3,6 +3,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
|||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ToastrService } from 'ngx-toastr';
|
import { ToastrService } from 'ngx-toastr';
|
||||||
import { ReportBuilderService } from 'src/app/services/api/report-builder.service';
|
import { ReportBuilderService } from 'src/app/services/api/report-builder.service';
|
||||||
|
import { SureconnectService } from '../../dashboardnew/sureconnect/sureconnect.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -23,11 +24,17 @@ export class ReportBuild2editComponent implements OnInit {
|
|||||||
date_param_req: '',
|
date_param_req: '',
|
||||||
// folderName:'',
|
// folderName:'',
|
||||||
url: '',
|
url: '',
|
||||||
|
// Add sureConnectId property
|
||||||
|
sureConnectId: null,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
// Add sureconnect data property
|
||||||
|
sureconnectData: any[] = [];
|
||||||
|
|
||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
private route: ActivatedRoute, private reportBuilderService: ReportBuilderService,
|
private route: ActivatedRoute, private reportBuilderService: ReportBuilderService,
|
||||||
private toastr: ToastrService, private _fb: FormBuilder) { }
|
private toastr: ToastrService, private _fb: FormBuilder,
|
||||||
|
private sureconnectService: SureconnectService) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.id = this.route.snapshot.params["id"];
|
this.id = this.route.snapshot.params["id"];
|
||||||
@ -41,11 +48,26 @@ export class ReportBuild2editComponent implements OnInit {
|
|||||||
date_param_req: [null],
|
date_param_req: [null],
|
||||||
// folderName:[null],
|
// folderName:[null],
|
||||||
url: [null],
|
url: [null],
|
||||||
|
// Add sureConnectId to form
|
||||||
|
sureConnectId: [null],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Load sureconnect data first, then load report data
|
||||||
|
this.loadSureconnectData();
|
||||||
this.getById(this.id);
|
this.getById(this.id);
|
||||||
this.listoddatabase();
|
this.listoddatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add method to load sureconnect data
|
||||||
|
loadSureconnectData() {
|
||||||
|
this.sureconnectService.getAll().subscribe((data: any[]) => {
|
||||||
|
this.sureconnectData = data;
|
||||||
|
console.log('Sureconnect data loaded:', this.sureconnectData);
|
||||||
|
}, (error) => {
|
||||||
|
console.log('Error loading sureconnect data:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
databaselist;
|
databaselist;
|
||||||
listoddatabase() {
|
listoddatabase() {
|
||||||
this.reportBuilderService.getdatabse().subscribe((data) => {
|
this.reportBuilderService.getdatabse().subscribe((data) => {
|
||||||
@ -81,6 +103,11 @@ export class ReportBuild2editComponent implements OnInit {
|
|||||||
// this.nodeEditProperties.conn_name = this.builderLineData.conn_name;
|
// this.nodeEditProperties.conn_name = this.builderLineData.conn_name;
|
||||||
this.nodeEditProperties.date_param_req = this.builderLineData[0].date_param_req;
|
this.nodeEditProperties.date_param_req = this.builderLineData[0].date_param_req;
|
||||||
this.nodeEditProperties.url = this.builderLineData[0].url;
|
this.nodeEditProperties.url = this.builderLineData[0].url;
|
||||||
|
// Set sureConnectId if it exists in the data
|
||||||
|
this.nodeEditProperties.sureConnectId = this.builderLineData[0].sureConnectId || null;
|
||||||
|
|
||||||
|
// Update form with loaded data
|
||||||
|
this.entryForm.patchValue(this.nodeEditProperties);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
@ -115,6 +142,8 @@ export class ReportBuild2editComponent implements OnInit {
|
|||||||
adhoc_param_html: this.nodeEditProperties.adhoc_param_html,
|
adhoc_param_html: this.nodeEditProperties.adhoc_param_html,
|
||||||
date_param_req: this.nodeEditProperties.date_param_req,
|
date_param_req: this.nodeEditProperties.date_param_req,
|
||||||
url: this.nodeEditProperties.url,
|
url: this.nodeEditProperties.url,
|
||||||
|
// Add sureConnectId to the data
|
||||||
|
sureConnectId: this.nodeEditProperties.sureConnectId,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.builderLineData[0].std_param_html = this.nodeEditProperties.std_param_html;
|
this.builderLineData[0].std_param_html = this.nodeEditProperties.std_param_html;
|
||||||
@ -123,6 +152,9 @@ export class ReportBuild2editComponent implements OnInit {
|
|||||||
// this.builderLineData.conn_name = this.nodeEditProperties.conn_name ;
|
// this.builderLineData.conn_name = this.nodeEditProperties.conn_name ;
|
||||||
this.builderLineData[0].date_param_req = this.nodeEditProperties.date_param_req;
|
this.builderLineData[0].date_param_req = this.nodeEditProperties.date_param_req;
|
||||||
this.builderLineData[0].url = this.nodeEditProperties.url;
|
this.builderLineData[0].url = this.nodeEditProperties.url;
|
||||||
|
// Add sureConnectId to the data
|
||||||
|
this.builderLineData[0].sureConnectId = this.nodeEditProperties.sureConnectId;
|
||||||
|
|
||||||
console.log(this.builderLineData);
|
console.log(this.builderLineData);
|
||||||
// this.builderLineData.splice(1);
|
// this.builderLineData.splice(1);
|
||||||
console.log(this.builderLineData);
|
console.log(this.builderLineData);
|
||||||
@ -148,6 +180,8 @@ export class ReportBuild2editComponent implements OnInit {
|
|||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.updated = true;
|
this.updated = true;
|
||||||
|
// Update nodeEditProperties with form values including sureConnectId
|
||||||
|
Object.assign(this.nodeEditProperties, this.entryForm.value);
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,4 +189,4 @@ export class ReportBuild2editComponent implements OnInit {
|
|||||||
this.router.navigate(["../../all"], { relativeTo: this.route });
|
this.router.navigate(["../../all"], { relativeTo: this.route });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -14,18 +14,16 @@ import { ExcelService } from 'src/app/services/excel.service';
|
|||||||
})
|
})
|
||||||
export class Reportrunneredit2Component implements OnInit {
|
export class Reportrunneredit2Component implements OnInit {
|
||||||
dynamicForm: FormGroup;
|
dynamicForm: FormGroup;
|
||||||
modalselect: boolean = false;
|
modalselect:boolean=false;
|
||||||
serverData = [{
|
serverData = [{"andor": "AND",
|
||||||
"andor": "AND",
|
"fields_name": "",
|
||||||
"fields_name": "",
|
"condition": "=",
|
||||||
"condition": "=",
|
"value": ""}];
|
||||||
"value": ""
|
andor = ['AND', 'OR','NOT'];
|
||||||
}];
|
|
||||||
andor = ['AND', 'OR', 'NOT'];
|
|
||||||
fieldname = ['name1', 'name2'];
|
fieldname = ['name1', 'name2'];
|
||||||
condition = ['=', '!=', '<', '>', '<=', '>=', 'LIKE', 'BETWEEN', 'IN'];
|
condition = ['=','!=','<','>','<=','>=','LIKE','BETWEEN','IN'];
|
||||||
header_id;
|
header_id;
|
||||||
public array = [
|
public array=[
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "Jack",
|
"name": "Jack",
|
||||||
@ -78,12 +76,13 @@ export class Reportrunneredit2Component implements OnInit {
|
|||||||
selectedfrom;
|
selectedfrom;
|
||||||
selectedto;
|
selectedto;
|
||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
private route: ActivatedRoute, private _fb: FormBuilder,
|
private route: ActivatedRoute,private _fb: FormBuilder,
|
||||||
private reportBuilderService: ReportBuilderService, private toastr: ToastrService, private sanitizer: DomSanitizer, private excel: ExcelService) {
|
private reportBuilderService: ReportBuilderService,private toastr:ToastrService,private sanitizer: DomSanitizer,private excel: ExcelService)
|
||||||
this.dynamicForm = this._fb.group({
|
{
|
||||||
});
|
this.dynamicForm = this._fb.group({
|
||||||
}
|
});
|
||||||
todayDate;
|
}
|
||||||
|
todayDate;
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.todayDate = new Date().toISOString().slice(0, 10);
|
this.todayDate = new Date().toISOString().slice(0, 10);
|
||||||
this.header_id = this.route.snapshot.params["id"];
|
this.header_id = this.route.snapshot.params["id"];
|
||||||
@ -95,18 +94,21 @@ export class Reportrunneredit2Component implements OnInit {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.runtheQuery();
|
this.runtheQuery();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
reportName;
|
reportName;
|
||||||
builderLine;
|
builderLine;
|
||||||
builderLineData;
|
builderLineData;
|
||||||
lineId;
|
lineId;
|
||||||
adhocList: any[];
|
adhocList:any[];
|
||||||
SQLQuery;
|
SQLQuery;
|
||||||
getUrl;
|
getUrl;
|
||||||
|
// Add sureConnectId property
|
||||||
|
sureConnectId: number | null = null;
|
||||||
stdParamfields;
|
stdParamfields;
|
||||||
DateParam;
|
DateParam;
|
||||||
|
|
||||||
getById(id: number) {
|
getById(id: number) {
|
||||||
this.reportBuilderService.getrbDetailsById(id).subscribe(
|
this.reportBuilderService.getrbDetailsById(id).subscribe(
|
||||||
(data) => {
|
(data) => {
|
||||||
@ -114,31 +116,44 @@ export class Reportrunneredit2Component implements OnInit {
|
|||||||
this.reportName = data.reportName;
|
this.reportName = data.reportName;
|
||||||
this.builderLine = data.rpt_builder2_lines;
|
this.builderLine = data.rpt_builder2_lines;
|
||||||
this.lineId = this.builderLine[0].id
|
this.lineId = this.builderLine[0].id
|
||||||
this.builderLineData = JSON.parse(this.builderLine[0].model);
|
this.builderLineData = JSON.parse(this.builderLine[0].model) ;
|
||||||
console.log(this.lineId, this.builderLineData);
|
console.log(this.lineId,this.builderLineData);
|
||||||
this.builderLineData = this.builderLineData[0];
|
this.builderLineData = this.builderLineData[0];
|
||||||
this.adhocList = this.builderLineData.adhoc_param_html;
|
this.adhocList = this.builderLineData.adhoc_param_html;
|
||||||
// this.adhocList = JSON.parse(adhocList);
|
// this.adhocList = JSON.parse(adhocList);
|
||||||
this.DateParam = this.builderLineData.date_param_req;
|
this.DateParam = this.builderLineData.date_param_req;
|
||||||
this.getUrl = this.builderLineData.url;
|
this.getUrl = this.builderLineData.url;
|
||||||
console.log(this.adhocList, this.DateParam, this.getUrl)
|
// Get sureConnectId if it exists
|
||||||
|
this.sureConnectId = this.builderLineData.sureConnectId || null;
|
||||||
|
console.log(this.adhocList,this.DateParam,this.getUrl)
|
||||||
this.getStdParam(this.header_id);
|
this.getStdParam(this.header_id);
|
||||||
this.featchData();
|
this.featchData();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
featchData() {
|
/**
|
||||||
this.reportBuilderService.getAllDetailsByurl(this.getUrl).subscribe(data => {
|
* Fetch data using the URL and SureConnect connection if available
|
||||||
|
*/
|
||||||
|
featchData(){
|
||||||
|
// If sureConnectId is available, we might want to modify the request
|
||||||
|
// For now, we'll use the existing implementation but with better error handling
|
||||||
|
this.reportBuilderService.getAllDetailsByurl(this.getUrl).subscribe(data =>{
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if (data.body) {
|
if(data.body){
|
||||||
// Check if the response is XML (starts with <) or JSON
|
// Check if the response is XML (starts with <) or JSON
|
||||||
if (typeof data.body === 'string' && data.body.trim().startsWith('<')) {
|
if (typeof data.body === 'string' && data.body.trim().startsWith('<')) {
|
||||||
// Handle XML response - for now we'll set rows to empty array
|
// Handle XML response
|
||||||
// In a real implementation, you would parse the XML properly
|
console.log('Received XML response, parsing to JSON');
|
||||||
console.warn('Received XML response instead of JSON');
|
try {
|
||||||
this.rows = [];
|
this.rows = this.parseXMLToJSON(data.body);
|
||||||
this.filterRows = [];
|
this.filterRows = [...this.rows]; // Create a copy
|
||||||
|
console.log('Parsed XML data:', this.rows);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error parsing XML:', error);
|
||||||
|
this.rows = [];
|
||||||
|
this.filterRows = [];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle JSON response
|
// Handle JSON response
|
||||||
try {
|
try {
|
||||||
@ -858,4 +873,82 @@ export class Reportrunneredit2Component implements OnInit {
|
|||||||
value.dayOfMonth !== undefined)
|
value.dayOfMonth !== undefined)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Simple XML parser to convert XML to JSON array
|
||||||
|
* Handles the specific format: <User><id>101</id><name>John Doe</name><email>john.doe@example.com</email></User>
|
||||||
|
* @param xmlString The XML string to parse
|
||||||
|
* @returns Array of objects representing the XML data
|
||||||
|
*/
|
||||||
|
private parseXMLToJSON(xmlString: string): any[] {
|
||||||
|
// Remove any XML declaration
|
||||||
|
xmlString = xmlString.replace(/<\?xml[^>]*\?>/g, '');
|
||||||
|
|
||||||
|
// Extract the root element name (e.g., "User" from <User>...</User>)
|
||||||
|
const rootMatch = xmlString.match(/<(\w+)(?:\s[^>]*)?>/);
|
||||||
|
if (!rootMatch) {
|
||||||
|
console.warn('Could not identify root element in XML');
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const rootElement = rootMatch[1];
|
||||||
|
const results: any[] = [];
|
||||||
|
|
||||||
|
// Create a regex to match all instances of the root element
|
||||||
|
const regex = new RegExp(`<${rootElement}(?:\\s[^>]*)?>([\\s\\S]*?)<\\/${rootElement}>`, 'g');
|
||||||
|
let match;
|
||||||
|
|
||||||
|
while ((match = regex.exec(xmlString)) !== null) {
|
||||||
|
const elementContent = match[1];
|
||||||
|
const item: any = {};
|
||||||
|
|
||||||
|
// Extract all tags and their values
|
||||||
|
const tagRegex = /<(\w+)>(.*?)<\/\1>/g;
|
||||||
|
let tagMatch;
|
||||||
|
|
||||||
|
while ((tagMatch = tagRegex.exec(elementContent)) !== null) {
|
||||||
|
const tagName = tagMatch[1];
|
||||||
|
const tagValue = tagMatch[2];
|
||||||
|
// Try to convert to appropriate type
|
||||||
|
item[tagName] = this.convertValueType(tagValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
results.push(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert string values to appropriate types (number, boolean, etc.)
|
||||||
|
* @param value The string value to convert
|
||||||
|
* @returns The value converted to the appropriate type
|
||||||
|
*/
|
||||||
|
private convertValueType(value: string): any {
|
||||||
|
// Check for empty value
|
||||||
|
if (value === '') {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for boolean values
|
||||||
|
if (value.toLowerCase() === 'true') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (value.toLowerCase() === 'false') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for numeric values
|
||||||
|
if (!isNaN(Number(value)) && !isNaN(parseFloat(value))) {
|
||||||
|
// Check if it's an integer or float
|
||||||
|
if (Number.isInteger(parseFloat(value))) {
|
||||||
|
return parseInt(value, 10);
|
||||||
|
} else {
|
||||||
|
return parseFloat(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return as string if no other type matches
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user