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;
databaseName;
databasename(val) {
console.log(val);
console.log('connection ', val);
this.databaseName = val.name;
this.selecteddatabase = val.conn_string;
console.log(this.selecteddatabase);

View File

@ -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>
@ -76,4 +88,4 @@
<button type="submit" class="btn btn-primary" [disabled]="!entryForm.valid" (click)="onSubmit()">{{'SUBMIT' | translate}}</button>
</div>
</form>
</div>
</div>

View File

@ -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() {
@ -68,4 +88,4 @@ export class ReportBuild2addComponent implements OnInit {
this.router.navigate(["../all"], { relativeTo: this.route });
}
}
}

View File

@ -1,13 +1,13 @@
<div class="container">
<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>
<hr />
<form [formGroup]="entryForm">
<div class="clr-row">
<div class="clr-col-lg-12 clr-col-md-12 clr-col-sm-12">
<div>
<div class="clr-row">
<!-- <div class="clr-col-md-4 clr-col-sm-12">
<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>
<hr />
<form [formGroup]="entryForm">
<div class="clr-row">
<div class="clr-col-lg-12 clr-col-md-12 clr-col-sm-12">
<div>
<div class="clr-row">
<!-- <div class="clr-col-md-4 clr-col-sm-12">
<div class="clr-col-sm-12">
<label for="projectName">Connection Name</label>
<select formControlName="conn_name" name="conn_name" [(ngModel)]="nodeEditProperties.conn_name" id="service" class="clr-dropdown">
@ -24,55 +24,70 @@
</select>
</div>
</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%">&nbsp;<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 />
</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>
<ng-container *clrOptionSelected="let selected">
{{selected}}
</ng-container>
<clr-options>
<clr-option *clrOptionItems="let state of keysfromurl" [clrValue]="state">
{{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-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%">&nbsp;<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 />
</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>
<ng-container *clrOptionSelected="let selected">
{{selected}}
</ng-container>
<clr-options>
<clr-option *clrOptionItems="let state of keysfromurl" [clrValue]="state">
{{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">
<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>
</div>
</div> -->
</div>
</div>
</div>
</div>
</div>
<br>
<!-- <div class="clr-row" style="padding-left:10px;">
</div>
</div>
<br>
<!-- <div class="clr-row" style="padding-left:10px;">
<div class="clr-col-md-4 clr-col-sm-12">
<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%">
@ -85,11 +100,10 @@
</textarea>
</div>
</div> -->
<br>
<div class="center">
<button type="button" class="btn btn-outline" (click)="back()">BACK</button>
<button type="submit" form-control class="btn btn-primary" (click)="onSubmit()">UPDATE</button>
</div>
</form>
</div>
<br>
<div class="center">
<button type="button" class="btn btn-outline" (click)="back()">BACK</button>
<button type="submit" form-control class="btn btn-primary" (click)="onSubmit()">UPDATE</button>
</div>
</form>
</div>

View File

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

View File

@ -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: <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;
}
}