builder
This commit is contained in:
parent
7c1a487114
commit
4f75ecb3e0
@ -254,7 +254,7 @@ export class ReportbuildqueryComponent implements OnInit {
|
||||
name;
|
||||
databaseName;
|
||||
databasename(val) {
|
||||
console.log(val);
|
||||
console.log('connection ', val);
|
||||
this.databaseName = val.name;
|
||||
this.selecteddatabase = val.conn_string;
|
||||
console.log(this.selecteddatabase);
|
||||
|
||||
@ -23,6 +23,18 @@
|
||||
<label for="workflow_name">{{'ACTIVE'| translate}}</label>
|
||||
<input type="checkbox" formControlName="active" clrToggle value="billable" name="billable" />
|
||||
</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">
|
||||
<label for="url">Get URL</label>
|
||||
|
||||
@ -4,6 +4,8 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ToastrService } from 'ngx-toastr';
|
||||
import { ReportBuilderService } from 'src/app/services/api/report-builder.service';
|
||||
import { SureconnectService } from '../../dashboardnew/sureconnect/sureconnect.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-report-build2add',
|
||||
templateUrl: './report-build2add.component.html',
|
||||
@ -11,8 +13,12 @@ import { ReportBuilderService } from 'src/app/services/api/report-builder.servic
|
||||
})
|
||||
export class ReportBuild2addComponent implements OnInit {
|
||||
public entryForm: FormGroup;
|
||||
// Add sureconnect data property
|
||||
sureconnectData: any[] = [];
|
||||
|
||||
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 {
|
||||
this.entryForm = this._fb.group({
|
||||
@ -20,9 +26,23 @@ export class ReportBuild2addComponent implements OnInit {
|
||||
description:[null],
|
||||
active:[null],
|
||||
isSql:[false],
|
||||
// Add sureConnectId field to the form
|
||||
sureConnectId: [null],
|
||||
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() {
|
||||
|
||||
@ -26,20 +26,35 @@
|
||||
</div> -->
|
||||
<div class="clr-col-md-4 clr-col-sm-12">
|
||||
<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"
|
||||
[(ngModel)]="nodeEditProperties.url" placeholder="Enter Url" style="width: 76%"> <span><button
|
||||
class="btn btn-icon btn-primary" (click)="getkeys()">
|
||||
<clr-icon shape="view-list"></clr-icon>
|
||||
</button></span></div>
|
||||
</div>
|
||||
<div class="clr-col-md-4 clr-col-sm-12">
|
||||
<label for="workflow_name">Include Date filter</label>
|
||||
<input type="checkbox" formControlName="date_param_req" name="date_param_req" [(ngModel)]="nodeEditProperties.date_param_req" clrToggle />
|
||||
<input type="checkbox" formControlName="date_param_req" name="date_param_req"
|
||||
[(ngModel)]="nodeEditProperties.date_param_req" clrToggle />
|
||||
</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.name || conn.id}}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="clr-col-md-4 clr-col-sm-12">
|
||||
<label>Standard Parameters</label>
|
||||
<clr-combobox-container style="margin-top: 0; padding-top: 0;">
|
||||
<!-- <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"
|
||||
required>
|
||||
<clr-combobox formControlName="std_param_html" name="std_param_html"
|
||||
[(ngModel)]="nodeEditProperties.std_param_html" clrMulti="true" required>
|
||||
<ng-container *clrOptionSelected="let selected">
|
||||
{{selected}}
|
||||
</ng-container>
|
||||
@ -92,4 +107,3 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -3,6 +3,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ToastrService } from 'ngx-toastr';
|
||||
import { ReportBuilderService } from 'src/app/services/api/report-builder.service';
|
||||
import { SureconnectService } from '../../dashboardnew/sureconnect/sureconnect.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -23,11 +24,17 @@ export class ReportBuild2editComponent implements OnInit {
|
||||
date_param_req: '',
|
||||
// folderName:'',
|
||||
url: '',
|
||||
// Add sureConnectId property
|
||||
sureConnectId: null,
|
||||
|
||||
};
|
||||
// Add sureconnect data property
|
||||
sureconnectData: any[] = [];
|
||||
|
||||
constructor(private router: Router,
|
||||
private route: ActivatedRoute, private reportBuilderService: ReportBuilderService,
|
||||
private toastr: ToastrService, private _fb: FormBuilder) { }
|
||||
private toastr: ToastrService, private _fb: FormBuilder,
|
||||
private sureconnectService: SureconnectService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.id = this.route.snapshot.params["id"];
|
||||
@ -41,11 +48,26 @@ export class ReportBuild2editComponent implements OnInit {
|
||||
date_param_req: [null],
|
||||
// folderName:[null],
|
||||
url: [null],
|
||||
// Add sureConnectId to form
|
||||
sureConnectId: [null],
|
||||
});
|
||||
|
||||
// Load sureconnect data first, then load report data
|
||||
this.loadSureconnectData();
|
||||
this.getById(this.id);
|
||||
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;
|
||||
listoddatabase() {
|
||||
this.reportBuilderService.getdatabse().subscribe((data) => {
|
||||
@ -81,6 +103,11 @@ export class ReportBuild2editComponent implements OnInit {
|
||||
// this.nodeEditProperties.conn_name = this.builderLineData.conn_name;
|
||||
this.nodeEditProperties.date_param_req = this.builderLineData[0].date_param_req;
|
||||
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) => {
|
||||
@ -115,6 +142,8 @@ export class ReportBuild2editComponent implements OnInit {
|
||||
adhoc_param_html: this.nodeEditProperties.adhoc_param_html,
|
||||
date_param_req: this.nodeEditProperties.date_param_req,
|
||||
url: this.nodeEditProperties.url,
|
||||
// Add sureConnectId to the data
|
||||
sureConnectId: this.nodeEditProperties.sureConnectId,
|
||||
};
|
||||
|
||||
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[0].date_param_req = this.nodeEditProperties.date_param_req;
|
||||
this.builderLineData[0].url = this.nodeEditProperties.url;
|
||||
// Add sureConnectId to the data
|
||||
this.builderLineData[0].sureConnectId = this.nodeEditProperties.sureConnectId;
|
||||
|
||||
console.log(this.builderLineData);
|
||||
// this.builderLineData.splice(1);
|
||||
console.log(this.builderLineData);
|
||||
@ -148,6 +180,8 @@ export class ReportBuild2editComponent implements OnInit {
|
||||
|
||||
onSubmit() {
|
||||
this.updated = true;
|
||||
// Update nodeEditProperties with form values including sureConnectId
|
||||
Object.assign(this.nodeEditProperties, this.entryForm.value);
|
||||
this.update();
|
||||
}
|
||||
|
||||
|
||||
@ -15,12 +15,10 @@ import { ExcelService } from 'src/app/services/excel.service';
|
||||
export class Reportrunneredit2Component implements OnInit {
|
||||
dynamicForm: FormGroup;
|
||||
modalselect:boolean=false;
|
||||
serverData = [{
|
||||
"andor": "AND",
|
||||
serverData = [{"andor": "AND",
|
||||
"fields_name": "",
|
||||
"condition": "=",
|
||||
"value": ""
|
||||
}];
|
||||
"value": ""}];
|
||||
andor = ['AND', 'OR','NOT'];
|
||||
fieldname = ['name1', 'name2'];
|
||||
condition = ['=','!=','<','>','<=','>=','LIKE','BETWEEN','IN'];
|
||||
@ -79,7 +77,8 @@ export class Reportrunneredit2Component implements OnInit {
|
||||
selectedto;
|
||||
constructor(private router: Router,
|
||||
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({
|
||||
});
|
||||
}
|
||||
@ -105,8 +104,11 @@ export class Reportrunneredit2Component implements OnInit {
|
||||
adhocList:any[];
|
||||
SQLQuery;
|
||||
getUrl;
|
||||
// Add sureConnectId property
|
||||
sureConnectId: number | null = null;
|
||||
stdParamfields;
|
||||
DateParam;
|
||||
|
||||
getById(id: number) {
|
||||
this.reportBuilderService.getrbDetailsById(id).subscribe(
|
||||
(data) => {
|
||||
@ -121,6 +123,8 @@ export class Reportrunneredit2Component implements OnInit {
|
||||
// this.adhocList = JSON.parse(adhocList);
|
||||
this.DateParam = this.builderLineData.date_param_req;
|
||||
this.getUrl = this.builderLineData.url;
|
||||
// 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.featchData();
|
||||
@ -128,17 +132,28 @@ export class Reportrunneredit2Component implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
if(data.body){
|
||||
// Check if the response is XML (starts with <) or JSON
|
||||
if (typeof data.body === 'string' && data.body.trim().startsWith('<')) {
|
||||
// Handle XML response - for now we'll set rows to empty array
|
||||
// In a real implementation, you would parse the XML properly
|
||||
console.warn('Received XML response instead of JSON');
|
||||
// Handle XML response
|
||||
console.log('Received XML response, parsing to JSON');
|
||||
try {
|
||||
this.rows = this.parseXMLToJSON(data.body);
|
||||
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 {
|
||||
// Handle JSON response
|
||||
try {
|
||||
@ -858,4 +873,82 @@ export class Reportrunneredit2Component implements OnInit {
|
||||
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