Skip to content

Commit

Permalink
Nishtha new changes for NVSK
Browse files Browse the repository at this point in the history
  • Loading branch information
FaizanMohammed326 committed Jul 28, 2023
1 parent 1e0230c commit 3478f6a
Show file tree
Hide file tree
Showing 13 changed files with 350 additions and 97 deletions.
2 changes: 1 addition & 1 deletion src/app/core/services/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class DataService {
datasets: this.getDatasets(options.barChart, filters),

options: {
height: ((defaultPageSize ? defaultPageSize : 30) * 15 + 150).toString(),
height: ((rows.length > defaultPageSize ? defaultPageSize : rows.length) * 15 + 150).toString(),
tooltips: {
callbacks: {
label: (tooltipItem, data) => {
Expand Down
183 changes: 124 additions & 59 deletions src/app/views/nishtha/config/nishtha_config.ts

Large diffs are not rendered by default.

57 changes: 29 additions & 28 deletions src/app/views/nishtha/nishtha.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,46 @@ export class NishthaComponent implements OnInit {
selectedTabLabel;
tabs: any = [];
programName: any = 'nishtha'

constructor(private route: ActivatedRoute, private _rbacService: RbacService, private _commonService: CommonService) {
this.route.queryParams.subscribe((param: any) => {
this.tabIndex = param.tab ? Number(param.tab) : 0;
})
this._rbacService.getRbacDetails().subscribe((rbacDetails: any) => {
this.rbacDetails = rbacDetails;
})
let allTabs = [...Object.keys(config)]
allTabs.forEach((tab: any) => {
config?.[tab]?.filters?.every((filter) => {
if((Number(filter?.hierarchyLevel) === this.rbacDetails?.role) || this.rbacDetails?.role === 0){
if(!(this.tabs.includes(config?.[tab]?.label))){
this.tabs.push(config?.[tab]?.label)
}
return false
}
return true

constructor(private route: ActivatedRoute, private _rbacService: RbacService, private _commonService: CommonService) {
this.route.queryParams.subscribe((param: any) => {
this.tabIndex = param.tab ? Number(param.tab) : 0;
})
this._rbacService.getRbacDetails().subscribe((rbacDetails: any) => {
this.rbacDetails = rbacDetails;
})
let allTabs = [...Object.keys(config)]
allTabs.forEach((tab: any) => {
config?.[tab]?.filters?.every((filter) => {
if ((Number(filter?.hierarchyLevel) === this.rbacDetails?.role)) {
if (!(this.tabs.includes(config?.[tab]?.label))) {
this.tabs.push(config?.[tab]?.label)
}
return false
}
return true
})
})
})
console.log(this.tabs)
}

ngOnInit(): void {
this._commonService.getMetaData(this.programName).subscribe()
}

ngAfterViewInit(): void {
setTimeout(() => {
this.selectedTabLabel = this.tabs.length > 0 ? this.tabs[0] : undefined
});
setTimeout(() => {
this.selectedTabLabel = this.tabs.length > 0 ? this.tabs[0] : undefined
});
}

onTabChanged($event: any): void {
this.selectedTabLabel = $event?.tab?.textLabel;
this.tabIndex = $event.index;
setTimeout(() => {
window.dispatchEvent(new Event('resize'));
console.log('resize');
}, 100);
this.selectedTabLabel = $event?.tab?.textLabel;
this.tabIndex = $event.index;
setTimeout(() => {
window.dispatchEvent(new Event('resize'));
console.log('resize');
}, 100);
}

}
3 changes: 2 additions & 1 deletion src/app/views/nishtha/nishtha.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import { CourseWiseStatusComponent } from './pages/course-wise-status-tab/report
import { PotentialBaseCertificatesComponent } from './pages/potential-base-tab/reports/potential-base-certificates/potential-base-certificates.component';
import { DashletModule, DataService } from '@project-sunbird/sb-dashlet';
import { NishthaBignumberMetricsComponent } from './pages/implementation-status-tab/reports/nishtha-bignumber-metrics/nishtha-bignumber-metrics.component';
import { PotentialBaseNvskComponent } from './pages/potential-base-tab/reports/potential-base-nvsk/potential-base-nvsk.component';

@NgModule({
declarations: [
NishthaComponent,
ImplementationStatusTabComponent,CourseAndMediumStatusTabComponent,CourseWiseStatusTabComponent,PotentialBaseTabComponent,DistrictWiseStatusTabComponent,
ImplementationStatusComponent,CourseAndMediumStatusComponent,PotentialBaseComponent,DistrictWiseStatusComponent,CourseWiseStatusComponent, PotentialBaseCertificatesComponent, NishthaBignumberMetricsComponent
ImplementationStatusComponent,CourseAndMediumStatusComponent,PotentialBaseComponent,DistrictWiseStatusComponent,CourseWiseStatusComponent, PotentialBaseCertificatesComponent, NishthaBignumberMetricsComponent, PotentialBaseNvskComponent
],
imports: [
DashletModule.forRoot({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<div class="col-span-2 xmd:col-span-2 div-shadow" *ngIf="checkReport('course_wise_status', 'table', 'barChart')"
id="table">
<app-course-wise-status #courseWiseStatus></app-course-wise-status>
<app-course-wise-status #courseWiseStatus (exportReportData)="csvDownload($event)"></app-course-wise-status>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
<app-nishtha-bignumber-metrics (exportReportData)="importBigNumberMetrics($event)"></app-nishtha-bignumber-metrics>
</div>
<div class="row-wrapper grid grid-cols-5 gap-4">
<h2 *ngIf="NVSK" class="col-span-5 ml-3"><b>NISHTHA Coverage (No. of participants):</b></h2>
<div class="col-span-2 xmd:col-span-1 bignumber-container" id="bignumber2"
*ngFor="let bigNumberData of bigNumberMetrics; let index = index">
*ngFor="let bigNumberData of getMetricsArray(); let index = index">
<div *ngIf="checkReport('nishtha_metrics', 'bigNumber'+(index+1))">
<app-big-number [bigNumberReportData]="bigNumberData"></app-big-number>
</div>
Expand All @@ -25,7 +26,7 @@
<div class="row-wrapper grid ">
<div class="col-span-1 xmd:col-span-1 div-shadow" *ngIf="checkReport('implementation_status', 'table') || checkReport('implementation_status', 'map')"
id="table">
<app-implementation-status #implementationStatus></app-implementation-status>
<app-implementation-status #implementationStatus (exportReportData)="csvDownload($event)"></app-implementation-status>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { RbacService } from 'src/app/core/services/rbac-service.service';
import { WrapperService } from 'src/app/core/services/wrapper.service';
import { config } from '../../config/nishtha_config';
import { ImplementationStatusComponent } from './reports/implementation-status/implementation-status.component';
import { environment } from 'src/environments/environment';

@Component({
selector: 'app-implementation-status-tab',
Expand All @@ -29,13 +30,17 @@ export class ImplementationStatusTabComponent implements OnInit, AfterViewInit {
hasCommonFilters: boolean = true;
bigNumberMetrics: any = [];
tabLabel:any = 'Implementation Status'
NVSK: boolean = true;

@ViewChild('implementationStatus') implementationStatus: ImplementationStatusComponent;

constructor(private _wrapperService: WrapperService, private _rbacService: RbacService) {
this._rbacService.getRbacDetails().subscribe((rbacDetails: any) => {
this.rbacDetails = rbacDetails;
})
if(environment.config === 'VSK') {
this.NVSK = false;
}
}

async ngOnInit(): Promise<void> {
Expand Down Expand Up @@ -90,4 +95,10 @@ constructor(private _wrapperService: WrapperService, private _rbacService: RbacS
importBigNumberMetrics(bigNumberMetric: any) {
this.bigNumberMetrics[bigNumberMetric.ind] = bigNumberMetric.data
}

getMetricsArray() {
return this.bigNumberMetrics.filter((data) => {
return data.averagePercentage !== null || data.averagePercentage !== undefined
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
</div>
</div>
<div class="reports-row" >
<div class="row-wrapper grid grid-cols-2 gap-4">
<div class="row-wrapper grid grid-cols-2 gap-4" *ngIf="!NVSK">
<div class="col-span-2 xmd:col-span-1 div-shadow" *ngIf="checkReport('potential_base', 'barChart') || checkReport('potential_base', 'stackedBarChart')" id="chart1">
<app-potential-base #potentialBase></app-potential-base>
</div>
<div class="col-span-2 xmd:col-span-1 div-shadow" *ngIf="checkReport('potential_base', 'barChart') || checkReport('potential_base', 'stackedBarChart')" id="chart2">
<app-potential-base-certificates #potentialBaseCertificates></app-potential-base-certificates>
</div>
</div>
<div class="row-wrapper grid grid-cols-1 gap-4" *ngIf="NVSK">
<div class="col-span-1 div-shadow" *ngIf="checkReport('potential_base_nvsk', 'barChart')" id="chart1">
<app-potential-base-nvsk #potentialBaseNVSK (exportReportData)="csvDownload($event)"></app-potential-base-nvsk>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { config } from '../../config/nishtha_config';
import { PotentialBaseCertificatesComponent } from './reports/potential-base-certificates/potential-base-certificates.component';
import { PotentialBaseComponent } from './reports/potential-base/potential-base.component';
import { environment } from 'src/environments/environment';
import { PotentialBaseNvskComponent } from './reports/potential-base-nvsk/potential-base-nvsk.component';

@Component({
selector: 'app-potential-base-tab',
Expand Down Expand Up @@ -34,6 +35,7 @@ export class PotentialBaseTabComponent implements OnInit, AfterViewInit {

@ViewChild('potentialBase') potentialBase: PotentialBaseComponent;
@ViewChild('potentialBaseCertificates') potentialBaseCertificates: PotentialBaseCertificatesComponent;
@ViewChild('potentialBaseNVSK') potentialBaseNVSK: PotentialBaseNvskComponent;

constructor(private _wrapperService: WrapperService, private _rbacService: RbacService) {
this._rbacService.getRbacDetails().subscribe((rbacDetails: any) => {
Expand All @@ -52,8 +54,7 @@ constructor(private _wrapperService: WrapperService, private _rbacService: RbacS
async ngAfterViewInit(): Promise<void> {
if (this.NVSK) {
this.filters = await this._wrapperService.constructCommonFilters(config.filters, this.matLabel);
this.potentialBase?.getReportData({ filterValues: this.filters.map((filter) => { return { ...filter, columnName: filter.valueProp, filterType: filter.id } }) });
this.potentialBaseCertificates?.getReportData({ filterValues: this.filters.map((filter) => { return { ...filter, columnName: filter.valueProp, filterType: filter.id } }) });
this.potentialBaseNVSK?.getReportData({ filterValues: this.filters.map((filter) => { return { ...filter, columnName: filter.valueProp, filterType: filter.id } }) });
} else {
this.potentialBase?.getReportData({ filterValues: [] });
this.potentialBaseCertificates?.getReportData({ filterValues: [] });
Expand Down Expand Up @@ -88,8 +89,13 @@ constructor(private _wrapperService: WrapperService, private _rbacService: RbacS

filtersUpdated(filters: any) {
this.reportsData = [];
this.potentialBase?.getReportData({ filterValues: filters.map((filter) => { return { ...filter, columnName: filter.valueProp, filterType: filter.id } }) });
this.potentialBaseCertificates?.getReportData({ filterValues: filters.map((filter) => { return { ...filter, columnName: filter.valueProp, filterType: filter.id } }) });
if(this.NVSK) {
this.potentialBaseNVSK?.getReportData({ filterValues: this.filters.map((filter) => { return { ...filter, columnName: filter.valueProp, filterType: filter.id } }) });
}
else {
this.potentialBaseCertificates?.getReportData({ filterValues: filters.map((filter) => { return { ...filter, columnName: filter.valueProp, filterType: filter.id } }) });
this.potentialBase?.getReportData({ filterValues: filters.map((filter) => { return { ...filter, columnName: filter.valueProp, filterType: filter.id } }) });
}
}

timeSeriesUpdated(event: any): void {
Expand Down
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>
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();
});
});
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)
}
}
})
}

}

0 comments on commit 3478f6a

Please sign in to comment.