-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
FaizanMohammed326
committed
Jul 28, 2023
1 parent
1e0230c
commit 3478f6a
Showing
13 changed files
with
350 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...a/pages/potential-base-tab/reports/potential-base-nvsk/potential-base-nvsk.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div class="col-span-full"> | ||
<ng-container *ngIf="(reportData?.values && reportData?.values?.length > 0)"> | ||
<p class="text-center font-medium py-2 filename" >{{title}}</p><br> | ||
<!-- <sb-dashlet type="bar" [data]="reportData" [config]="config"></sb-dashlet> --> | ||
<app-sb-bar-chart type="horizontalBar" [data]="reportData" [config]="config" ></app-sb-bar-chart> | ||
</ng-container> | ||
<div class="noData" *ngIf="!(reportData?.values && reportData?.values?.length > 0)"> | ||
No Data Found | ||
</div> | ||
</div> |
Empty file.
23 changes: 23 additions & 0 deletions
23
...ages/potential-base-tab/reports/potential-base-nvsk/potential-base-nvsk.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PotentialBaseNvskComponent } from './potential-base-nvsk.component'; | ||
|
||
describe('PotentialBaseNvskComponent', () => { | ||
let component: PotentialBaseNvskComponent; | ||
let fixture: ComponentFixture<PotentialBaseNvskComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ PotentialBaseNvskComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PotentialBaseNvskComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
130 changes: 130 additions & 0 deletions
130
...tha/pages/potential-base-tab/reports/potential-base-nvsk/potential-base-nvsk.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import { Component, EventEmitter, OnInit, Output } from '@angular/core'; | ||
import { DataService } from 'src/app/core/services/data.service'; | ||
import { RbacService } from 'src/app/core/services/rbac-service.service'; | ||
import { WrapperService } from 'src/app/core/services/wrapper.service'; | ||
import { buildQuery, parseFilterToQuery, parseRbacFilter, parseTimeSeriesQuery } from 'src/app/utilities/QueryBuilder'; | ||
import { config } from 'src/app/views/nishtha/config/nishtha_config'; | ||
|
||
@Component({ | ||
selector: 'app-potential-base-nvsk', | ||
templateUrl: './potential-base-nvsk.component.html', | ||
styleUrls: ['./potential-base-nvsk.component.scss'] | ||
}) | ||
export class PotentialBaseNvskComponent implements OnInit { | ||
|
||
reportName: string = 'potential_base_nvsk'; | ||
filters: any = []; | ||
levels: any; | ||
reportData: any = { | ||
reportName: "% against Potential Base" | ||
}; | ||
title: string = '% against Potential Base' | ||
selectedYear: any; | ||
selectedMonth: any; | ||
startDate: any; | ||
endDate: any; | ||
config: any; | ||
compareDateRange: any = 30; | ||
filterIndex: any; | ||
rbacDetails: any; | ||
|
||
@Output() exportReportData = new EventEmitter<any>(); | ||
|
||
constructor(private readonly _dataService: DataService, private readonly _wrapperService: WrapperService, private _rbacService: RbacService) { | ||
this._rbacService.getRbacDetails().subscribe((rbacDetails: any) => { | ||
this.rbacDetails = rbacDetails; | ||
}) | ||
} | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
getReportData(values: any): void { | ||
let { filterValues, timeSeriesValues } = values ?? {}; | ||
this.startDate = timeSeriesValues?.startDate; | ||
this.endDate = timeSeriesValues?.endDate; | ||
let reportConfig = config | ||
|
||
let { timeSeriesQueries, queries, levels, defaultLevel, filters, options } = reportConfig[this.reportName]; | ||
let onLoadQuery; | ||
let currentLevel; | ||
|
||
if (this.rbacDetails?.role !== null && this.rbacDetails.role !== undefined) { | ||
filters.every((filter: any) => { | ||
if (Number(this.rbacDetails?.role) === Number(filter.hierarchyLevel)) { | ||
queries = { ...filter?.actions?.queries } | ||
currentLevel = filter?.actions?.level; | ||
this.reportData = { | ||
...this.reportData, | ||
reportName: `% ${currentLevel[0].toUpperCase() + currentLevel.substring(1)}s which conducted meeting` | ||
} | ||
Object.keys(queries).forEach((key) => { | ||
queries[key] = parseRbacFilter(queries[key], this.rbacDetails) | ||
}); | ||
return false | ||
} | ||
return true | ||
}) | ||
} | ||
|
||
Object.keys(queries).forEach(async (key: any) => { | ||
if (key.toLowerCase().includes('comparison')) { | ||
let endDate = new Date(); | ||
let days = endDate.getDate() - this.compareDateRange; | ||
let startDate = new Date(); | ||
startDate.setDate(days) | ||
onLoadQuery = parseTimeSeriesQuery(queries[key], startDate.toISOString().split('T')[0], endDate.toISOString().split('T')[0]) | ||
} | ||
else { | ||
onLoadQuery = queries[key] | ||
} | ||
let query = buildQuery(onLoadQuery, defaultLevel, this.levels, this.filters, this.startDate, this.endDate, key, this.compareDateRange); | ||
|
||
let metricFilter = [...filterValues].filter((filter: any) => { | ||
return filter.filterType === 'metric' | ||
}) | ||
|
||
filterValues = [...filterValues].filter((filter: any) => { | ||
return filter.filterType !== 'metric' | ||
}) | ||
|
||
filterValues.forEach((filterParams: any) => { | ||
query = parseFilterToQuery(query, filterParams) | ||
}); | ||
|
||
if (query && key === 'table') { | ||
this.reportData = await this._dataService.getTableReportData(query, options); | ||
if (this.reportData?.data?.length > 0) { | ||
let reportsData = { reportData: this.reportData.data, reportType: 'table', reportName: this.title } | ||
this.exportReportData.emit(reportsData) | ||
} | ||
} | ||
else if (query && key === 'bigNumber') { | ||
this.reportData = await this._dataService.getBigNumberReportData(query, options, 'averagePercentage', this.reportData); | ||
} | ||
else if (query && key === 'bigNumberComparison') { | ||
this.reportData = await this._dataService.getBigNumberReportData(query, options, 'differencePercentage', this.reportData); | ||
} | ||
else if (query && key === 'barChart') { | ||
let { reportData, config } = await this._dataService.getBarChartReportData(query, options, filters, defaultLevel); | ||
this.reportData = reportData | ||
this.config = config; | ||
if (this.reportData?.values?.length > 0) { | ||
let reportsData = { reportData: this.reportData.values, reportType: 'dashletBar', reportName: this.title, downloadConfig: options?.downloadConfig } | ||
this.exportReportData.emit(reportsData) | ||
} | ||
} | ||
else if (query && key === 'map') { | ||
console.log('quary', query); | ||
this.reportData = await this._dataService.getMapReportData(query, options, metricFilter) | ||
if (this.reportData?.data?.length > 0) { | ||
|
||
let reportsData = { reportData: this.reportData.data, reportType: 'map', reportName: this.title } | ||
this.exportReportData.emit(reportsData) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
} | ||
|