diff --git a/frontend/angular-clarity-master/src/app/modules/main/BuilderComponents/test.html b/frontend/angular-clarity-master/src/app/modules/main/BuilderComponents/test.html new file mode 100644 index 0000000..815da4a --- /dev/null +++ b/frontend/angular-clarity-master/src/app/modules/main/BuilderComponents/test.html @@ -0,0 +1,20 @@ + + + +
+Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ipsa fuga, asperiores mollitia iste vitae repellendus adipisci atque eum corrupti ad placeat unde voluptatum quia perferendis neque expedita, sequi iure quo. Ut error adipisci ex cum sint, suscipit, voluptatem repellat nemo dolorum unde dolores quasi aut. A earum quo mollitia voluptatibus!
+ + + + + + diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts index 8235097..7ae5c2e 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts @@ -453,7 +453,17 @@ export class EditnewdashComponent implements OnInit { onDrop(ev) { const componentType = ev.dataTransfer.getData("widgetIdentifier"); - let maxChartId = this.dashboardArray?.reduce((maxId, item) => Math.max(maxId, item.chartid), 0); + // Safely calculate maxChartId, handling cases where chartid might be NaN or missing + let maxChartId = 0; + if (this.dashboardArray && this.dashboardArray.length > 0) { + const validChartIds = this.dashboardArray + .map(item => item.chartid) + .filter(chartid => typeof chartid === 'number' && !isNaN(chartid)); + + if (validChartIds.length > 0) { + maxChartId = Math.max(...validChartIds); + } + } switch (componentType) { case "radar_chart": return this.dashboardArray.push({ @@ -758,15 +768,34 @@ export class EditnewdashComponent implements OnInit { this.refreshBaseDrilldownColumns(); } - if (item.datastore !== undefined || '' || null) { + // Check if we have either datastore or table to fetch columns + if ((item.datastore !== undefined && item.datastore !== '' && item.datastore !== null) || + (item.table !== undefined && item.table !== '' && item.table !== null)) { const datastore = item.datastore; - this.getTables(datastore); const table = item.table; - this.getColumns(datastore, table); + + // Fetch tables if datastore is available + if (datastore) { + this.getTables(datastore); + } + + // Fetch columns if table is available + if (table) { + this.getColumns(datastore, table); + } + console.log(item.yAxis); - if (isArray(item.yAxis)) { - this.selectedyAxis = item.yAxis; + // Set selectedyAxis regardless of whether it's an array or string + if (item.yAxis !== undefined && item.yAxis !== '' && item.yAxis !== null) { + if (isArray(item.yAxis)) { + this.selectedyAxis = item.yAxis; + } else { + // For single yAxis values, convert to array + this.selectedyAxis = [item.yAxis]; + } console.log(this.selectedyAxis); + } else { + this.selectedyAxis = []; } } else { this.selectedyAxis = []; @@ -840,12 +869,29 @@ export class EditnewdashComponent implements OnInit { // Update the onSubmit method to properly save filter data onSubmit(id) { console.log(id); - if (!isNullArray(this.selectedyAxis)) { - console.log("get y-axis array", this.selectedyAxis); + + // Check if ID is valid, including handling NaN + if (id === null || id === undefined || isNaN(id)) { + console.warn('Chart ID is null, undefined, or NaN, using modelid instead:', this.modelid); + id = this.modelid; + } + + // Ensure we have a valid numeric ID + const numId = typeof id === 'number' ? id : parseInt(id, 10); + if (isNaN(numId)) { + console.error('Unable to determine valid chart ID, aborting onSubmit'); + return; + } + + // Handle both array and string yAxis values + if (this.selectedyAxis !== undefined && this.selectedyAxis !== null && + ((Array.isArray(this.selectedyAxis) && this.selectedyAxis.length > 0) || + (typeof this.selectedyAxis === 'string' && this.selectedyAxis !== ''))) { + console.log("get y-axis", this.selectedyAxis); this.entryForm.patchValue({ yAxis: this.selectedyAxis }); } let formdata = this.entryForm.value; - let num = id; + let num = numId; console.log(this.entryForm.value); this.dashboardCollection.dashboard = this.dashboardCollection.dashboard.map(item => { if (item.chartid == num) { @@ -1052,15 +1098,25 @@ export class EditnewdashComponent implements OnInit { applyChanges(id) { console.log('Apply changes for chart ID:', id); - // Check if ID is valid - if (id === null || id === undefined) { - console.warn('Chart ID is null or undefined, using modelid instead:', this.modelid); + // Check if ID is valid, including handling NaN + if (id === null || id === undefined || isNaN(id)) { + console.warn('Chart ID is null, undefined, or NaN, using modelid instead:', this.modelid); id = this.modelid; } - // Update the form with selected Y-axis values if it's an array - if (!isNullArray(this.selectedyAxis)) { - console.log("get y-axis array", this.selectedyAxis); + // Ensure we have a valid numeric ID + const numId = typeof id === 'number' ? id : parseInt(id, 10); + if (isNaN(numId)) { + console.error('Unable to determine valid chart ID, aborting applyChanges'); + return; + } + + // Update the form with selected Y-axis values + // Handle both array and string yAxis values + if (this.selectedyAxis !== undefined && this.selectedyAxis !== null && + ((Array.isArray(this.selectedyAxis) && this.selectedyAxis.length > 0) || + (typeof this.selectedyAxis === 'string' && this.selectedyAxis !== ''))) { + console.log("get y-axis", this.selectedyAxis); this.entryForm.patchValue({ yAxis: this.selectedyAxis }); } 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 7fe97f8..73b6bb2 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 @@ -13,67 +13,66 @@ import { ReportBuilderService } from 'src/app/services/api/report-builder.servic export class ReportBuild2editComponent implements OnInit { public entryForm: FormGroup; updated = false; - ReportData:any = {}; + ReportData: any = {}; id: number; nodeEditProperties = { - std_param_html:'', - adhoc_param_html:'', + std_param_html: '', + adhoc_param_html: '', // column_str:'', // conn_name:'', - date_param_req:'', + date_param_req: '', // folderName:'', - url:'', + url: '', -}; + }; constructor(private router: Router, - private route: ActivatedRoute,private reportBuilderService: ReportBuilderService, - private toastr: ToastrService, private _fb: FormBuilder) { } + private route: ActivatedRoute, private reportBuilderService: ReportBuilderService, + private toastr: ToastrService, private _fb: FormBuilder) { } ngOnInit(): void { this.id = this.route.snapshot.params["id"]; console.log("update with id = ", this.id); this.entryForm = this._fb.group({ - std_param_html : [null], - adhoc_param_html:[null], + std_param_html: [null], + adhoc_param_html: [null], // column_str:[null], // conn_name:[null], - date_param_req:[null], + date_param_req: [null], // folderName:[null], - url:[null], - }); + url: [null], + }); this.getById(this.id); this.listoddatabase(); } databaselist; - listoddatabase(){ - this.reportBuilderService.getdatabse().subscribe((data)=>{ - this.databaselist=data; + listoddatabase() { + this.reportBuilderService.getdatabse().subscribe((data) => { + this.databaselist = data; console.log(this.databaselist) - },(error) => { + }, (error) => { console.log(error); - if(error){ - } + if (error) { + } }); - + } builderLine; lineId; - builderLineData:any[] = []; + builderLineData: any[] = []; getById(id: number) { this.reportBuilderService.getrbDetailsById(id).subscribe( (data) => { console.log(data); this.ReportData = data; - + this.builderLine = this.ReportData.rpt_builder2_lines; this.lineId = this.builderLine[0].id - console.log("line data ",this.lineId, this.builderLine); - if(this.builderLine[0].model != '') - { - this.builderLineData = JSON.parse(this.builderLine[0].model) ; + console.log("line data ", this.lineId, this.builderLine); + if (this.builderLine[0].model != '') { + this.builderLineData = JSON.parse(this.builderLine[0].model); console.log(this.builderLineData); this.nodeEditProperties.std_param_html = this.builderLineData[0].std_param_html; @@ -92,25 +91,25 @@ export class ReportBuild2editComponent implements OnInit { stdparams; keysfromurl; - getkeys(){ - if(this.nodeEditProperties.url !== null){ - this.reportBuilderService.getcolumnDetailsByurl(this.nodeEditProperties.url).subscribe(data =>{ - console.log(data); + getkeys() { + if (this.nodeEditProperties.url !== null) { + this.reportBuilderService.getcolumnDetailsByurl(this.nodeEditProperties.url).subscribe(data => { + console.log('coloum list data ', data); this.keysfromurl = data; - this.nodeEditProperties.adhoc_param_html = this.keysfromurl; + this.nodeEditProperties.adhoc_param_html = this.keysfromurl; }) - }else{ + } else { this.toastr.error("URL is required"); } } - + listBuilder_Lines = { - model:{} + model: {} } update() { - + this.builderLineData[0] = { std_param_html: this.nodeEditProperties.std_param_html, adhoc_param_html: this.nodeEditProperties.adhoc_param_html, @@ -119,7 +118,7 @@ export class ReportBuild2editComponent implements OnInit { }; this.builderLineData[0].std_param_html = this.nodeEditProperties.std_param_html; - this.builderLineData[0].adhoc_param_html = this.nodeEditProperties.adhoc_param_html; + this.builderLineData[0].adhoc_param_html = this.nodeEditProperties.adhoc_param_html; // this.builderLineData.column_str = this.nodeEditProperties.column_str; // this.builderLineData.conn_name = this.nodeEditProperties.conn_name ; this.builderLineData[0].date_param_req = this.nodeEditProperties.date_param_req; @@ -129,14 +128,14 @@ export class ReportBuild2editComponent implements OnInit { console.log(this.builderLineData); let tmp = JSON.stringify(this.builderLineData); //.replace(/\\/g, '') this.listBuilder_Lines.model = tmp; -console.log(this.listBuilder_Lines); + console.log(this.listBuilder_Lines); this.reportBuilderService.updaterbLineData(this.listBuilder_Lines, this.lineId).subscribe( (data) => { console.log(data); if (data) { this.toastr.success('Update successfully'); - } + } this.router.navigate(["../../all"], { relativeTo: this.route }); //this.router.navigate(["../../all"],{ relativeTo: this.route, queryParams: { p_id: this.projectId } }); }, 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 1f78b64..b2805f1 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,16 +14,18 @@ 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", @@ -76,13 +78,12 @@ 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"]; @@ -94,14 +95,14 @@ todayDate; setTimeout(() => { this.runtheQuery(); }, 2000); - - + + } reportName; builderLine; builderLineData; lineId; - adhocList:any[]; + adhocList: any[]; SQLQuery; getUrl; stdParamfields; @@ -113,36 +114,61 @@ todayDate; 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) + console.log(this.adhocList, this.DateParam, this.getUrl) this.getStdParam(this.header_id); this.featchData(); }); } - featchData(){ - this.reportBuilderService.getAllDetailsByurl(this.getUrl).subscribe(data =>{ + featchData() { + this.reportBuilderService.getAllDetailsByurl(this.getUrl).subscribe(data => { console.log(data); - if(data.body){ - console.log(JSON.parse(data.body)); - this.rows = JSON.parse(data.body); - this.filterRows = JSON.parse(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 = []; + } else { + // Handle JSON response + try { + console.log(JSON.parse(data.body)); + this.rows = JSON.parse(data.body); + this.filterRows = JSON.parse(data.body); + } catch (error) { + console.error('Error parsing JSON:', error); + this.rows = []; + this.filterRows = []; + } + } + } else { + // If no body, initialize with empty arrays + this.rows = []; + this.filterRows = []; } + }, error => { + // Handle HTTP errors + console.error('Error fetching data:', error); + this.rows = []; + this.filterRows = []; }); } - dynamicHtml:any = []; + dynamicHtml: any = []; dynamicHtmlFlag = false; stdParmas; stdParamFlag = false; - getStdParam(id: any){ + getStdParam(id: any) { console.log(this.builderLineData.std_param_html); this.dynamicHtml = this.builderLineData.std_param_html; // this.dynamicHtml = ['a.abc','b.abcde'] @@ -154,11 +180,11 @@ todayDate; } console.log(this.dynamicForm.value); } - if(this.dynamicHtml == undefined || this.dynamicHtml == ''){ - this.dynamicHtmlFlag = false; - }else{ - this.dynamicHtmlFlag = true; - } + if (this.dynamicHtml == undefined || this.dynamicHtml == '') { + this.dynamicHtmlFlag = false; + } else { + this.dynamicHtmlFlag = true; + } // this.reportBuilderService.getStdParamById(id).subscribe(data => { // console.log(data); @@ -174,37 +200,37 @@ todayDate; // } // }); } - modo2(val){ + modo2(val) { console.log(val); - this.selectedfrom=val; + this.selectedfrom = val; } - modo3(val){ + modo3(val) { console.log(val); -this.selectedto=val; + this.selectedto = val; } - duplicateArray=[]; + duplicateArray = []; myDateValue: Date; - toDate:Date; + toDate: Date; reverseAndTimeStamp(dateString) { const reverse = new Date(dateString.split("-").reverse().join("-")); return reverse.getTime(); - } + } filterDate() { - let fromdate=moment(this.myDateValue).format('DD-MM-YYYY'); -console.log(fromdate) -let todate=moment(this.toDate).format('DD-MM-YYYY'); -if(this.myDateValue && this.toDate){ -const selectedMembers = this.array.filter(m => { + let fromdate = moment(this.myDateValue).format('DD-MM-YYYY'); + console.log(fromdate) + let todate = moment(this.toDate).format('DD-MM-YYYY'); + if (this.myDateValue && this.toDate) { + const selectedMembers = this.array.filter(m => { return this.reverseAndTimeStamp(m.fromDate) >= this.reverseAndTimeStamp(fromdate) && this.reverseAndTimeStamp(m.fromDate) <= this.reverseAndTimeStamp(todate) + } + ); + this.duplicateArray = selectedMembers + } else { + this.duplicateArray = this.array } - ); - this.duplicateArray=selectedMembers -}else{ -this.duplicateArray=this.array -} console.log(this.duplicateArray); // the result objects - this.modalselect=false; -} + this.modalselect = false; + } dateParameter: string; from_date: Date; @@ -213,7 +239,7 @@ this.duplicateArray=this.array calculateThisWeek(): void { // Calculate the current date const currentDate = new Date(); - console.log(currentDate) + console.log(currentDate) // Get the day of the week (0-6, where 0 is Sunday) const currentDayOfWeek = currentDate.getDay(); @@ -228,10 +254,10 @@ this.duplicateArray=this.array this.to_date = new Date(this.from_date); this.to_date.setDate(this.from_date.getDate() + 6); console.log(this.from_date); - this.myDateValue=this.from_date; + this.myDateValue = this.from_date; console.log(this.to_date); console.log(this.myDateValue); - this.toDate=this.to_date; + this.toDate = this.to_date; this.FromDatequery = this.from_date.toISOString().substring(0, 10); this.ToDatequery = this.to_date.toISOString().substring(0, 10); @@ -254,10 +280,10 @@ this.duplicateArray=this.array // Calculate the date of Sunday of the previous week this.to_date = new Date(this.from_date); this.to_date.setDate(this.from_date.getDate() + 6); - this.myDateValue=this.from_date; + this.myDateValue = this.from_date; console.log(this.to_date); console.log(this.myDateValue); - this.toDate=this.to_date; + this.toDate = this.to_date; this.FromDatequery = this.from_date.toISOString().substring(0, 10); @@ -267,22 +293,22 @@ this.duplicateArray=this.array calculateThisMonth(): void { // Calculate the current date const currentDate = new Date(); - + // Calculate the date of the first day of the current month this.from_date = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1); - + // Calculate the date of the last day of the current month this.to_date = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0); - + // Set the 'to_date' to the last day of the current month at the end of the day this.to_date.setHours(23, 59, 59, 999); - + // Optionally, you can set 'myDateValue' to 'from_date' if needed this.myDateValue = this.from_date; - + // Optionally, you can set 'toDate' to 'to_date' if needed this.toDate = this.to_date; - + console.log(this.from_date); console.log(this.to_date); @@ -290,34 +316,34 @@ this.duplicateArray=this.array this.FromDatequery = this.from_date.toISOString().substring(0, 10); this.ToDatequery = this.to_date.toISOString().substring(0, 10); } - + calculateLastMonth(): void { // Calculate the current date const currentDate = new Date(); - + // Calculate the date of the first day of the previous month this.from_date = new Date(currentDate.getFullYear(), currentDate.getMonth() - 1, 1); - + // Calculate the date of the last day of the previous month this.to_date = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0); - + // Set the 'to_date' to the last day of the previous month at the end of the day this.to_date.setHours(23, 59, 59, 999); - + // Optionally, you can set 'myDateValue' to 'from_date' if needed this.myDateValue = this.from_date; - + // Optionally, you can set 'toDate' to 'to_date' if needed this.toDate = this.to_date; - + console.log(this.from_date); console.log(this.to_date); this.FromDatequery = this.from_date.toISOString().substring(0, 10); this.ToDatequery = this.to_date.toISOString().substring(0, 10); } - + calculateThisYear(): void { // Calculate the current date const currentDate = new Date(); @@ -328,10 +354,10 @@ this.duplicateArray=this.array // Calculate the date of the last day of the current year this.to_date = new Date(currentDate.getFullYear(), 11, 31); - this.myDateValue=this.from_date; + this.myDateValue = this.from_date; console.log(this.to_date); console.log(this.myDateValue); - this.toDate=this.to_date; + this.toDate = this.to_date; this.FromDatequery = this.from_date.toISOString().substring(0, 10); @@ -349,92 +375,92 @@ this.duplicateArray=this.array // Calculate the date of the last day of the previous year this.to_date = new Date(currentDate.getFullYear() - 1, 11, 31); - this.myDateValue=this.from_date; + this.myDateValue = this.from_date; console.log(this.to_date); console.log(this.myDateValue); - this.toDate=this.to_date; + this.toDate = this.to_date; this.FromDatequery = this.from_date.toISOString().substring(0, 10); this.ToDatequery = this.to_date.toISOString().substring(0, 10); // this.filterDate(); } SelectdateType; - select(val:any){ - console.log(val); - this.SelectdateType = val; - if(val === 'This Week'){ + select(val: any) { + console.log(val); + this.SelectdateType = val; + if (val === 'This Week') { this.FromDatequery = null; this.ToDatequery = null; this.calculateThisWeek() - }else if(val === 'Last Week'){ - this.FromDatequery = null; - this.ToDatequery = null; - this.calculateLastWeek() - }else if(val === 'This Month'){ - this.FromDatequery = null; - this.ToDatequery = null; - this.calculateThisMonth() - }else if(val === 'Last Month'){ - this.FromDatequery = null; - this.ToDatequery = null; - this.calculateLastMonth() + } else if (val === 'Last Week') { + this.FromDatequery = null; + this.ToDatequery = null; + this.calculateLastWeek() + } else if (val === 'This Month') { + this.FromDatequery = null; + this.ToDatequery = null; + this.calculateThisMonth() + } else if (val === 'Last Month') { + this.FromDatequery = null; + this.ToDatequery = null; + this.calculateLastMonth() // }else if(val === 'To Specific FromDate To To Date'){ // this.openmodel() - } - else if(val === 'This Year'){ - this.FromDatequery = null; - this.ToDatequery = null; - this.calculateThisYear() - }else if(val === 'Last Year'){ - this.FromDatequery = null; - this.ToDatequery = null; - this.calculateLastYear() - } - else if(val === 'Today'){ - this.FromDatequery = null; - this.ToDatequery = null; - this.myDateValue = this.todayDate; - this.toDate = this.todayDate; + } + else if (val === 'This Year') { + this.FromDatequery = null; + this.ToDatequery = null; + this.calculateThisYear() + } else if (val === 'Last Year') { + this.FromDatequery = null; + this.ToDatequery = null; + this.calculateLastYear() + } + else if (val === 'Today') { + this.FromDatequery = null; + this.ToDatequery = null; + this.myDateValue = this.todayDate; + this.toDate = this.todayDate; - this.FromDatequery = this.myDateValue; - this.ToDatequery = this.toDate; - } - else if(val === '--Select Particular--'){ - this.FromDatequery = null; - this.ToDatequery = null; - this.newfrom = null; - this.newto = null; - this.myDateValue = null; - this.toDate = null; - } + this.FromDatequery = this.myDateValue; + this.ToDatequery = this.toDate; + } + else if (val === '--Select Particular--') { + this.FromDatequery = null; + this.ToDatequery = null; + this.newfrom = null; + this.newto = null; + this.myDateValue = null; + this.toDate = null; + } } - openmodel(){ - this.modalselect=true; - } + openmodel() { + this.modalselect = true; + } - onExport() { - const reportNameWithUnderscore = this.reportName + '_'; - this.excel.exportAsExcelFile(this.rows, reportNameWithUnderscore, - moment().format('YYYYMMDD_HHmmss')) - } + onExport() { + const reportNameWithUnderscore = this.reportName + '_'; + this.excel.exportAsExcelFile(this.rows, reportNameWithUnderscore, + moment().format('YYYYMMDD_HHmmss')) + } downloadFile(format: string) { const date = moment().format('YYYYMMDD_HHmmss') const reportNameWithUnderscore = this.reportName + '_' + date; - this.reportBuilderService.downloadFile(format, this.filterRows,reportNameWithUnderscore) + this.reportBuilderService.downloadFile(format, this.filterRows, reportNameWithUnderscore) } - back(){ + back() { this.router.navigate(["../../all"], { relativeTo: this.route }); } -FormattedAdhocparameters; -adocdata; -// showPlusIconRow: number | null = 0; - onAddLines(){ - console.log(this.serverData); - const lastRow = this.serverData[this.serverData.length - 1]; - if (lastRow && lastRow.fields_name !== '') { + FormattedAdhocparameters; + adocdata; + // showPlusIconRow: number | null = 0; + onAddLines() { + console.log(this.serverData); + const lastRow = this.serverData[this.serverData.length - 1]; + if (lastRow && lastRow.fields_name !== '') { let formattedString = ''; for (const condition of this.serverData) { const { andor, fields_name, condition: cond, value } = condition; @@ -443,13 +469,13 @@ adocdata; this.FormattedAdhocparameters = formattedString // this.selectcolumn(this.serverData); } - this.serverData.push({ - andor: "AND", - fields_name: "", - condition: "=", - value: "" - }); - } + this.serverData.push({ + andor: "AND", + fields_name: "", + condition: "=", + value: "" + }); + } // this.showPlusIconRow = this.serverData.length - 1; } @@ -461,10 +487,10 @@ adocdata; if (this.serverData.length > 1) { // Get the item to be deleted const deletedItem = this.serverData[index]; - + // Remove the item from the serverData array this.serverData.splice(index, 1); - + // Remove the corresponding entries from selectedValues if (Array.isArray(deletedItem)) { for (const item of deletedItem) { @@ -488,14 +514,14 @@ adocdata; } } } - + console.log(this.selectedValues); - this.filterRowsBySelectedValues(); - } + this.filterRowsBySelectedValues(); + } - rows:any[]; - filterRows:any[]; + rows: any[]; + filterRows: any[]; columns: any[]; rowdata; FromDatequery; @@ -505,327 +531,331 @@ adocdata; newto; dateKey; -runtheQuery(){ - console.log(this.myDateValue , this.toDate); - let query = this.SQLQuery; -// let query - if(this.dynamicForm.value){ - // for(let i = 0; i < this.dynamicForm.value.length; i++){ - // // const query = this.SQLQuery + " AND " + this.dynamicForm.controls[i] + " = " + this.dynamicForm.value[i] - - // } + runtheQuery() { + console.log(this.myDateValue, this.toDate); + let query = this.SQLQuery; + // let query + if (this.dynamicForm.value) { + // for(let i = 0; i < this.dynamicForm.value.length; i++){ + // // const query = this.SQLQuery + " AND " + this.dynamicForm.controls[i] + " = " + this.dynamicForm.value[i] + + // } - // Iterate over the keys in dynamicForm.value - Object.keys(this.dynamicForm.value).forEach((key) => { - // Append the condition for each key to the query - if (this.dynamicForm.value[key] !== null ) { - this.selectcolumn(this.dynamicForm.value); - // query += ` AND ${key} = '${this.dynamicForm.value[key]}'`; - } - // const regex = /FROM/i; - // const match = query.match(regex); - // if (this.dynamicForm.value[key] !== null && this.dynamicForm.value[key] !== '') { - // // query += ` AND ${key} = '${this.dynamicForm.value[key]}'`; - // const columnName = key.split('.').pop(); - // let coalesceExpression = `, COALESCE(${key}, '${this.dynamicForm.value[key]}') as ${columnName}`; - // if (match) { - // // Insert the COALESCE expression before the FROM keyword - // query = query.slice(0, match.index) + coalesceExpression +' '+ query.slice(match.index); - // } - // } - }); - // if(this.FromDatequery && this.ToDatequery){ - // query += ` AND cretaedat BETWEEN '${this.FromDatequery}' AND '${this.ToDatequery}'`; + // Iterate over the keys in dynamicForm.value + Object.keys(this.dynamicForm.value).forEach((key) => { + // Append the condition for each key to the query + if (this.dynamicForm.value[key] !== null) { + this.selectcolumn(this.dynamicForm.value); + // query += ` AND ${key} = '${this.dynamicForm.value[key]}'`; + } + // const regex = /FROM/i; + // const match = query.match(regex); + // if (this.dynamicForm.value[key] !== null && this.dynamicForm.value[key] !== '') { + // // query += ` AND ${key} = '${this.dynamicForm.value[key]}'`; + // const columnName = key.split('.').pop(); + // let coalesceExpression = `, COALESCE(${key}, '${this.dynamicForm.value[key]}') as ${columnName}`; + // if (match) { + // // Insert the COALESCE expression before the FROM keyword + // query = query.slice(0, match.index) + coalesceExpression +' '+ query.slice(match.index); + // } + // } + }); + // if(this.FromDatequery && this.ToDatequery){ + // query += ` AND cretaedat BETWEEN '${this.FromDatequery}' AND '${this.ToDatequery}'`; - // }else - if(this.DateParam == true){ - this.dateKey = 'createdat'; - this.adhocList.forEach(key => { - if (key.includes("created_at")) { - this.dateKey ="created_at" ; + // }else + if (this.DateParam == true) { + this.dateKey = 'createdat'; + this.adhocList.forEach(key => { + if (key.includes("created_at")) { + this.dateKey = "created_at"; + } + }); + this.adhocList.forEach(key => { + if (key.includes("createdAt")) { + this.dateKey = "createdAt"; + } + }); + if (this.myDateValue && this.toDate) { + if (this.myDateValue) { + this.newfrom = new Date(this.myDateValue); + // const year = inputDate.getFullYear(); + // const month = String(inputDate.getMonth() + 1).padStart(2, "0"); // Months are zero-based, so add 1 + // const day = String(inputDate.getDate()).padStart(2, "0"); + // this.newfrom = `${year}-${month}-${day}`; + } + if (this.toDate) { + this.newto = new Date(this.toDate); + // const year = inputDate.getFullYear(); + // const month = String(inputDate.getMonth() + 1).padStart(2, "0"); // Months are zero-based, so add 1 + // const day = String(inputDate.getDate()).padStart(2, "0"); + // this.newto = `${year}-${month}-${day}`; + + } + query += ` AND ${this.dateKey} BETWEEN '${this.newfrom}' AND '${this.newto}'`; + + } } - }); - this.adhocList.forEach(key => { - if (key.includes("createdAt")) { - this.dateKey ="createdAt" ; + // if(this.myDateValue && this.toDate){ + // query += ` AND from_date = NVL(${this.myDateValue}from_date, 'from_date') AND to_date = NVL(${this.toDate}to_date, 'to_date')`; + // } + console.log(query); } -}); - if(this.myDateValue && this.toDate){ - if(this.myDateValue){ - this.newfrom = new Date(this.myDateValue); - // const year = inputDate.getFullYear(); - // const month = String(inputDate.getMonth() + 1).padStart(2, "0"); // Months are zero-based, so add 1 - // const day = String(inputDate.getDate()).padStart(2, "0"); - // this.newfrom = `${year}-${month}-${day}`; - } - if(this.toDate){ - this.newto = new Date(this.toDate); - // const year = inputDate.getFullYear(); - // const month = String(inputDate.getMonth() + 1).padStart(2, "0"); // Months are zero-based, so add 1 - // const day = String(inputDate.getDate()).padStart(2, "0"); - // this.newto = `${year}-${month}-${day}`; - - } - query += ` AND ${this.dateKey} BETWEEN '${this.newfrom}' AND '${this.newto}'`; + // if(this.FormattedAdhocparameters){ + // query += this.FormattedAdhocparameters + // } -} + this.selectcolumn(this.serverData); + // query = `SELECT a.name AS name, b.dob AS dob FROM abc a, abcde b WHERE a.name = 'gaurav' AND a.abc = NVL(b.abc, 'name') AND a.abcde = NVL(b.abcde, 'test');` + console.log(query); + this.reportBuilderService.getMasterData(query).subscribe((data) => { + // this.rows = data; + + console.log(this.rows); + this.rowdata = [this.rows]; + console.log(typeof this.rows); + if (data) { + this.toastr.success("Run Successfully") + } + var j; + var cart = []; + + for (var i = 0; i < data.length; i++) { + var columnsIn = data[i]; + if (i == 1) { + for (var key in columnsIn) { + j = { prop: key, name: key }; + cart.push(j) + + } + } + } + this.columns = cart; + + }); } - // if(this.myDateValue && this.toDate){ - // query += ` AND from_date = NVL(${this.myDateValue}from_date, 'from_date') AND to_date = NVL(${this.toDate}to_date, 'to_date')`; - // } - console.log(query); - } -// if(this.FormattedAdhocparameters){ -// query += this.FormattedAdhocparameters -// } + getHeaders() { + let headers: string[] = []; + if (this.rows) { + this.rows.forEach((value) => { + Object.keys(value).forEach((key) => { + if (!headers.find((header) => header == key)) { + headers.push(key) + } - this.selectcolumn(this.serverData); -// query = `SELECT a.name AS name, b.dob AS dob FROM abc a, abcde b WHERE a.name = 'gaurav' AND a.abc = NVL(b.abc, 'name') AND a.abcde = NVL(b.abcde, 'test');` - console.log(query); - this.reportBuilderService.getMasterData(query).subscribe((data) => { - // this.rows = data; - - console.log(this.rows); -this.rowdata= [this.rows]; - console.log(typeof this.rows); - if(data){ - this.toastr.success("Run Successfully") - } - var j; - var cart = []; + }) - for(var i = 0; i < data.length; i++) - { - var columnsIn = data[i]; - if(i==1) - { - for(var key in columnsIn) - { - j={prop:key , name: key}; - cart.push(j) - - } - } - } - this.columns = cart; - -}); -} -getHeaders() { -let headers: string[] = []; -if(this.rows) { - this.rows.forEach((value) => { - Object.keys(value).forEach((key) => { - if(!headers.find((header) => header == key)){ - headers.push(key) - } - - }) - - }) -} -return headers; -} - -getFilterHeaders() { - let headers: string[] = []; - if(this.filterRows) { - this.filterRows.forEach((value) => { - Object.keys(value).forEach((key) => { - if(!headers.find((header) => header == key)){ - headers.push(key) - } }) - }) - } - return headers; - } - - - -selectedValues: { [key: string]: any[] } = {}; -selectcolumn(data: any) { - if (Array.isArray(data)) { - for (const item of data) { - const columnName = item.fields_name; - const value = item.value; - - // Check if fields_name is not empty and value is not null or empty string - if (columnName.trim() !== '') { - if (!this.selectedValues[columnName]) { - this.selectedValues[columnName] = []; - } - - if (value !== null && value.trim() !== '') { - // Only add the value if it's not null and not an empty string - if (!this.selectedValues[columnName].includes(value)) { - this.selectedValues[columnName].push(value); - } - } else { - // Remove the property if the value is null or empty string - delete this.selectedValues[columnName]; - } - } - } - } else if (typeof data === 'object') { - // Handle the first JSON structure (object) - console.log(data); - for (const key in data) { - if (data.hasOwnProperty(key)) { - const columnName = key; - const value = data[key]; - - if (!this.selectedValues[columnName]) { - this.selectedValues[columnName] = []; - } - - if (value !== null && value.trim() !== '') { - // Only add the value if it's not null and not an empty string - if (!this.selectedValues[columnName].includes(value)) { - this.selectedValues[columnName].push(value); - } - } else { - // Remove the property if the value is null or empty string - delete this.selectedValues[columnName]; - } - } } + return headers; } - console.log(this.selectedValues); - this.filterRowsBySelectedValues(); -} + getFilterHeaders() { + let headers: string[] = []; + if (this.filterRows) { + this.filterRows.forEach((value) => { + Object.keys(value).forEach((key) => { + if (!headers.find((header) => header == key)) { + headers.push(key) + } + }) + }) + } + return headers; + } + selectedValues: { [key: string]: any[] } = {}; + selectcolumn(data: any) { + if (Array.isArray(data)) { + for (const item of data) { + const columnName = item.fields_name; + const value = item.value; -filtered = false; -filterRowsBySelectedValues() { - // Create a filteredRows array to store the filtered data - const filteredRows = []; - - // Iterate through each row in the rows array - for (const row of this.rows) { - let isMatch = true; - - // Iterate through each column in the selectedValues object - for (const columnName in this.selectedValues) { - if (this.selectedValues.hasOwnProperty(columnName) && row.hasOwnProperty(columnName)) { - // Get the selected values for the current column - const selectedValuesForColumn = this.selectedValues[columnName]; - - // Get the type of the row's value for the current column - const rowValue = row[columnName]; - const rowValueType = typeof rowValue; - - if (rowValueType === 'boolean') { - // Handle boolean values - if (selectedValuesForColumn.length === 0) { - // If no specific value selected for boolean, include the row - continue; + // Check if fields_name is not empty and value is not null or empty string + if (columnName.trim() !== '') { + if (!this.selectedValues[columnName]) { + this.selectedValues[columnName] = []; } - const selectedBooleanValue = selectedValuesForColumn[0] === 'true'; // Convert to boolean - if (selectedBooleanValue !== rowValue) { - isMatch = false; - break; // No need to check other columns if it's not a match - } - } else { - // Handle other data types, including numbers and strings - // Convert selected values to the appropriate type - const convertedValues = selectedValuesForColumn.map((value) => { - if (rowValueType === 'number') { - return parseFloat(value); // Convert to number - } else { - return value; // Keep the original value (string, etc.) + if (value !== null && value.trim() !== '') { + // Only add the value if it's not null and not an empty string + if (!this.selectedValues[columnName].includes(value)) { + this.selectedValues[columnName].push(value); } - }); + } else { + // Remove the property if the value is null or empty string + delete this.selectedValues[columnName]; + } + } + } + } else if (typeof data === 'object') { + // Handle the first JSON structure (object) + console.log(data); + for (const key in data) { + if (data.hasOwnProperty(key)) { + const columnName = key; + const value = data[key]; - // Check if the row's value for the current column matches any selected value - if (!convertedValues.includes(rowValue)) { - isMatch = false; - break; // No need to check other columns if it's not a match + if (!this.selectedValues[columnName]) { + this.selectedValues[columnName] = []; + } + + if (value !== null && value.trim() !== '') { + // Only add the value if it's not null and not an empty string + if (!this.selectedValues[columnName].includes(value)) { + this.selectedValues[columnName].push(value); + } + } else { + // Remove the property if the value is null or empty string + delete this.selectedValues[columnName]; } } } } - if(this.FromDatequery !== null && this.ToDatequery !== null){ + + console.log(this.selectedValues); + this.filterRowsBySelectedValues(); + } + + + + + filtered = false; + filterRowsBySelectedValues() { + // Check if rows is defined and iterable + if (!this.rows || !Array.isArray(this.rows)) { + console.warn('Rows is not defined or not an array'); + this.filterRows = []; + this.filtered = false; + return; + } + + // Create a filteredRows array to store the filtered data + const filteredRows = []; + + // Iterate through each row in the rows array + for (const row of this.rows) { + let isMatch = true; + + // Iterate through each column in the selectedValues object + for (const columnName in this.selectedValues) { + if (this.selectedValues.hasOwnProperty(columnName) && row.hasOwnProperty(columnName)) { + // Get the selected values for the current column + const selectedValuesForColumn = this.selectedValues[columnName]; + + // Get the type of the row's value for the current column + const rowValue = row[columnName]; + const rowValueType = typeof rowValue; + + if (rowValueType === 'boolean') { + // Handle boolean values + if (selectedValuesForColumn.length === 0) { + // If no specific value selected for boolean, include the row + continue; + } + + const selectedBooleanValue = selectedValuesForColumn[0] === 'true'; // Convert to boolean + if (selectedBooleanValue !== rowValue) { + isMatch = false; + break; // No need to check other columns if it's not a match + } + } else { + // Handle other data types, including numbers and strings + // Convert selected values to the appropriate type + const convertedValues = selectedValuesForColumn.map((value) => { + if (rowValueType === 'number') { + return parseFloat(value); // Convert to number + } else { + return value; // Keep the original value (string, etc.) + } + }); + + // Check if the row's value for the current column matches any selected value + if (!convertedValues.includes(rowValue)) { + isMatch = false; + break; // No need to check other columns if it's not a match + } + } + } + } + if (this.FromDatequery !== null && this.ToDatequery !== null) { this.newfrom = this.FromDatequery this.newto = this.ToDatequery - } + } - if (this.newfrom !== null && this.newto !== null) { - // Extract the year, month, and day from newfrom and newto - const from = new Date(this.newfrom); - const to = new Date(this.newto); - const newfromYear = from.getFullYear(); - const newfromMonth = from.getMonth(); - const newfromDay = from.getDate(); - const newtoYear = to.getFullYear(); - const newtoMonth = to.getMonth(); - const newtoDay = to.getDate(); - - // Extract the year, month, and day from createdAtDate - const dateKey = this.dateKey; - const createdAtDate = new Date(row[dateKey]); - const createdAtYear = createdAtDate.getFullYear(); - const createdAtMonth = createdAtDate.getMonth(); - const createdAtDay = createdAtDate.getDate(); - - // Create new Date objects using the extracted year, month, and day - const newfromDate = new Date(newfromYear, newfromMonth, newfromDay); - const newtoDate = new Date(newtoYear, newtoMonth, newtoDay); - const createdAtDateOnly = new Date(createdAtYear, createdAtMonth, createdAtDay); - - // Check if the createdAtDateOnly is within the specified date range - if (createdAtDateOnly < newfromDate || createdAtDateOnly > newtoDate) { - isMatch = false; + if (this.newfrom !== null && this.newto !== null) { + // Extract the year, month, and day from newfrom and newto + const from = new Date(this.newfrom); + const to = new Date(this.newto); + const newfromYear = from.getFullYear(); + const newfromMonth = from.getMonth(); + const newfromDay = from.getDate(); + const newtoYear = to.getFullYear(); + const newtoMonth = to.getMonth(); + const newtoDay = to.getDate(); + + // Extract the year, month, and day from createdAtDate + const dateKey = this.dateKey; + const createdAtDate = new Date(row[dateKey]); + const createdAtYear = createdAtDate.getFullYear(); + const createdAtMonth = createdAtDate.getMonth(); + const createdAtDay = createdAtDate.getDate(); + + // Create new Date objects using the extracted year, month, and day + const newfromDate = new Date(newfromYear, newfromMonth, newfromDay); + const newtoDate = new Date(newtoYear, newtoMonth, newtoDay); + const createdAtDateOnly = new Date(createdAtYear, createdAtMonth, createdAtDay); + + // Check if the createdAtDateOnly is within the specified date range + if (createdAtDateOnly < newfromDate || createdAtDateOnly > newtoDate) { + isMatch = false; + } + } + + + // If the row matches all selected values, add it to the filteredRows array + if (isMatch) { + filteredRows.push(row); } } - - // If the row matches all selected values, add it to the filteredRows array - if (isMatch) { - filteredRows.push(row); - } + // Assign the filtered data to the rows + console.log(filteredRows); + this.filterRows = filteredRows; + + // Check if all arrays in selectedValues are empty + const allArraysEmpty = Object.values(this.selectedValues).every(arr => arr.length === 0); + + // Check if the date range is not selected + const dateRangeNotSelected = !this.newfrom || !this.newto; + + // Set this.filtered based on allArraysEmpty and dateRangeNotSelected + this.filtered = !allArraysEmpty || !dateRangeNotSelected; } - // Assign the filtered data to the rows - console.log(filteredRows); - this.filterRows = filteredRows; - // Check if all arrays in selectedValues are empty - const allArraysEmpty = Object.values(this.selectedValues).every(arr => arr.length === 0); - // Check if the date range is not selected - const dateRangeNotSelected = !this.newfrom || !this.newto; - - // Set this.filtered based on allArraysEmpty and dateRangeNotSelected - this.filtered = !allArraysEmpty || !dateRangeNotSelected; -} - - - -formatDate(dateObj: any): string { - // Extract individual date properties - const { year, monthValue, dayOfMonth, hour, minute, second } = dateObj; - - // Create a JavaScript Date object using the extracted properties - const formattedDate = new Date(year, monthValue - 1, dayOfMonth, hour, minute, second); - - // Format the date as needed (e.g., using built-in JavaScript date formatting) - return formattedDate.toLocaleString(); // Or any other desired formatting -} - -isDate(value: any): boolean { - return ( - value instanceof Date || - (value && - value.year !== undefined && - value.monthValue !== undefined && - value.dayOfMonth !== undefined) - ); -} + formatDate(dateObj: any): string { + // Extract individual date properties + const { year, monthValue, dayOfMonth, hour, minute, second } = dateObj; + // Create a JavaScript Date object using the extracted properties + const formattedDate = new Date(year, monthValue - 1, dayOfMonth, hour, minute, second); + + // Format the date as needed (e.g., using built-in JavaScript date formatting) + return formattedDate.toLocaleString(); // Or any other desired formatting + } + + isDate(value: any): boolean { + return ( + value instanceof Date || + (value && + value.year !== undefined && + value.monthValue !== undefined && + value.dayOfMonth !== undefined) + ); + } } diff --git a/frontend/angular-clarity-master/src/app/modules/main/layout/layout.component.html b/frontend/angular-clarity-master/src/app/modules/main/layout/layout.component.html index f12d961..9a2e3ff 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/layout/layout.component.html +++ b/frontend/angular-clarity-master/src/app/modules/main/layout/layout.component.html @@ -39,6 +39,14 @@ + + + +