This commit is contained in:
string 2025-10-31 15:51:28 +05:30
parent 7c1a487114
commit 4f75ecb3e0
6 changed files with 270 additions and 97 deletions

View File

@ -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);

View File

@ -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>

View File

@ -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() {

View File

@ -26,20 +26,35 @@
</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%">&nbsp;<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%">&nbsp;<span><button
class="btn btn-icon btn-primary" (click)="getkeys()">
<clr-icon shape="view-list"></clr-icon> <clr-icon shape="view-list"></clr-icon>
</button></span></div> </button></span></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="workflow_name">Include Date filter</label> <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> </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"> <div class="clr-col-md-4 clr-col-sm-12">
<label>Standard Parameters</label> <label>Standard Parameters</label>
<clr-combobox-container style="margin-top: 0; padding-top: 0;"> <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> --> <!-- <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" <clr-combobox formControlName="std_param_html" name="std_param_html"
required> [(ngModel)]="nodeEditProperties.std_param_html" clrMulti="true" required>
<ng-container *clrOptionSelected="let selected"> <ng-container *clrOptionSelected="let selected">
{{selected}} {{selected}}
</ng-container> </ng-container>
@ -92,4 +107,3 @@
</div> </div>
</form> </form>
</div> </div>

View File

@ -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();
} }

View File

@ -15,12 +15,10 @@ 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'];
@ -79,7 +77,8 @@ export class Reportrunneredit2Component implements OnInit {
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({
}); });
} }
@ -105,8 +104,11 @@ export class Reportrunneredit2Component implements OnInit {
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) => {
@ -121,6 +123,8 @@ export class Reportrunneredit2Component implements OnInit {
// 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;
// Get sureConnectId if it exists
this.sureConnectId = this.builderLineData.sureConnectId || null;
console.log(this.adhocList,this.DateParam,this.getUrl) console.log(this.adhocList,this.DateParam,this.getUrl)
this.getStdParam(this.header_id); this.getStdParam(this.header_id);
this.featchData(); this.featchData();
@ -128,17 +132,28 @@ export class Reportrunneredit2Component implements OnInit {
} }
/**
* Fetch data using the URL and SureConnect connection if available
*/
featchData(){ 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 =>{ 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.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.rows = [];
this.filterRows = []; 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;
}
} }