diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/report-build/reportbuildquery/reportbuildquery.component.ts b/frontend/angular-clarity-master/src/app/modules/main/builder/report-build/reportbuildquery/reportbuildquery.component.ts index 3c23b53..c25b688 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/report-build/reportbuildquery/reportbuildquery.component.ts +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/report-build/reportbuildquery/reportbuildquery.component.ts @@ -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); diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/report-build2/report-build2add/report-build2add.component.html b/frontend/angular-clarity-master/src/app/modules/main/builder/report-build2/report-build2add/report-build2add.component.html index 587e702..502e454 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/report-build2/report-build2add/report-build2add.component.html +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/report-build2/report-build2add/report-build2add.component.html @@ -23,6 +23,18 @@ + + +
+ + +
+ -
- -
 
-
-
- - -
-
- - - - - - {{selected}} - - - - {{state}} - - - - - -
-
- - - -
- +
+ + +
+ +
+ + + + + + {{selected}} + + + + {{state}} + + + + + +
+
+ + + +
+ - - - + -
- -
-
- - -
- - - \ No newline at end of file +
+
+ + +
+ + \ No newline at end of file diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/report-build2/report-build2edit/report-build2edit.component.ts b/frontend/angular-clarity-master/src/app/modules/main/builder/report-build2/report-build2edit/report-build2edit.component.ts index 73b6bb2..56c99ec 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/report-build2/report-build2edit/report-build2edit.component.ts +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/report-build2/report-build2edit/report-build2edit.component.ts @@ -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(); } @@ -155,4 +189,4 @@ export class ReportBuild2editComponent implements OnInit { this.router.navigate(["../../all"], { relativeTo: this.route }); } -} +} \ No newline at end of file diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/report-runner/reportrunneredit2/reportrunneredit2.component.ts b/frontend/angular-clarity-master/src/app/modules/main/builder/report-runner/reportrunneredit2/reportrunneredit2.component.ts index b2805f1..4f83668 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/report-runner/reportrunneredit2/reportrunneredit2.component.ts +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/report-runner/reportrunneredit2/reportrunneredit2.component.ts @@ -14,18 +14,16 @@ import { ExcelService } from 'src/app/services/excel.service'; }) export class Reportrunneredit2Component implements OnInit { dynamicForm: FormGroup; - modalselect: boolean = false; - serverData = [{ - "andor": "AND", - "fields_name": "", - "condition": "=", - "value": "" - }]; - andor = ['AND', 'OR', 'NOT']; + modalselect:boolean=false; + serverData = [{"andor": "AND", + "fields_name": "", + "condition": "=", + "value": ""}]; + andor = ['AND', 'OR','NOT']; fieldname = ['name1', 'name2']; - condition = ['=', '!=', '<', '>', '<=', '>=', 'LIKE', 'BETWEEN', 'IN']; + condition = ['=','!=','<','>','<=','>=','LIKE','BETWEEN','IN']; header_id; - public array = [ + public array=[ { "id": 1, "name": "Jack", @@ -78,12 +76,13 @@ export class Reportrunneredit2Component implements OnInit { selectedfrom; selectedto; constructor(private router: Router, - private route: ActivatedRoute, private _fb: FormBuilder, - private reportBuilderService: ReportBuilderService, private toastr: ToastrService, private sanitizer: DomSanitizer, private excel: ExcelService) { - this.dynamicForm = this._fb.group({ - }); - } - todayDate; + private route: ActivatedRoute,private _fb: FormBuilder, + private reportBuilderService: ReportBuilderService,private toastr:ToastrService,private sanitizer: DomSanitizer,private excel: ExcelService) + { + this.dynamicForm = this._fb.group({ + }); + } +todayDate; ngOnInit(): void { this.todayDate = new Date().toISOString().slice(0, 10); this.header_id = this.route.snapshot.params["id"]; @@ -95,18 +94,21 @@ export class Reportrunneredit2Component implements OnInit { setTimeout(() => { this.runtheQuery(); }, 2000); - - + + } reportName; builderLine; builderLineData; lineId; - adhocList: any[]; + adhocList:any[]; SQLQuery; getUrl; + // Add sureConnectId property + sureConnectId: number | null = null; stdParamfields; DateParam; + getById(id: number) { this.reportBuilderService.getrbDetailsById(id).subscribe( (data) => { @@ -114,31 +116,44 @@ export class Reportrunneredit2Component implements OnInit { this.reportName = data.reportName; this.builderLine = data.rpt_builder2_lines; this.lineId = this.builderLine[0].id - this.builderLineData = JSON.parse(this.builderLine[0].model); - console.log(this.lineId, this.builderLineData); + this.builderLineData = JSON.parse(this.builderLine[0].model) ; + console.log(this.lineId,this.builderLineData); this.builderLineData = this.builderLineData[0]; this.adhocList = this.builderLineData.adhoc_param_html; // this.adhocList = JSON.parse(adhocList); this.DateParam = this.builderLineData.date_param_req; 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.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); - if (data.body) { + 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'); - this.rows = []; - this.filterRows = []; + // 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: 101John Doejohn.doe@example.com + * @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 ...) + 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; + } +} \ No newline at end of file