Skip to content

Commit

Permalink
Merge pull request #328 from Sunbird-cQube/dev
Browse files Browse the repository at this point in the history
merge dev to staging for nishtha changes
  • Loading branch information
htvenkatesh authored Aug 1, 2023
2 parents 2f82030 + 94c4d1e commit 58791fc
Show file tree
Hide file tree
Showing 13 changed files with 389 additions and 21 deletions.
67 changes: 57 additions & 10 deletions src/app/views/nishtha/config/nishtha_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const config = {
"name": "Program",
"labelProp": "program_name",
"valueProp": "program_name",
"id": "program_name",
"id": "metric",
"query": "select program_name from dimensions.programnishtha order by program_name"
},
{
Expand Down Expand Up @@ -52,6 +52,14 @@ export const config = {
// "id": "metric",
// "query": "select category_name from dimensions.categorypgi"
// },
{
"label": "Medium of instruction",
"name": "Program",
"labelProp": "program_name",
"valueProp": "program_name",
"id": "program_name",
"query": "select program_name from dimensions.programnishtha order by program_name"
},
],
implementation_status: {
"label": "Implementation Status",
Expand All @@ -61,7 +69,7 @@ export const config = {
"hierarchyLevel": "0",
"actions": {
"queries": {
"map": "select d.latitude, d.longitude, t.state_id,state_name ,t.status from dimensions.state as d join (select state_id, program_name, case when sum > 0 then 'YES' else 'NO' end as status from datasets.nishtha_programstarted_state0programnishtha) as t on d.state_id = t.state_id order by d.state_name asc"
"map": "select d.latitude, d.longitude, t.state_id, t.program_name, state_name ,t.status from dimensions.state as d join (select state_id, program_name, case when sum > 0 then 'YES' else 'NO' end as status from datasets.nishtha_programstarted_state0programnishtha) as t on d.state_id = t.state_id order by d.state_name asc"
},
"level": "state",
"nextLevel": "district"
Expand All @@ -72,7 +80,7 @@ export const config = {
"hierarchyLevel": "1",
"actions": {
"queries": {
"table": "select program_name , case when sum > 0 then 'YES' else 'NO' end as status from datasets.nishtha_started_programnishtha group by program_name,status order by program_name",
"table": "select program_name , case when sum > 0 then 'YES' else 'NO' end as status from datasets.nishtha_started_programnishtha group by program_name,status order by program_name",
},
"level": "district",
"nextLevel": "block"
Expand Down Expand Up @@ -110,13 +118,15 @@ export const config = {
},
"downloadConfig": {
"fileName": "Implementation Status",
"excludeColumns": ['indicator', 'tooltip', 'Latitude', 'Longitude']
"excludeColumns": ['indicator', 'tooltip', 'Latitude', 'Longitude', 'status']
},
"map": {
"metricFilterNeeded": false,
"indicator": "status",
"metricLabelProp": "program_name",
"metricValueProp": "status",
"groupByColumn": "state_id",
"metricFilterNeeded": true,
"legend": {
"title": "Implemented PGI"
"title": "Implemented Nishtha"
},
"tooltipMetrics": [
{
Expand All @@ -125,8 +135,8 @@ export const config = {
"valueSuffix": "\n"
},
{
"valuePrefix": "Implemented PGI: ",
"value": "status",
"valuePrefix": "",
"value": "program_name",
"valueSuffix": "\n"
}
]
Expand Down Expand Up @@ -186,6 +196,43 @@ export const config = {
}
}
},
medium_of_instruction: {
"label": "Medium of instruction",
"filters": [
{
"name": "National",
"hierarchyLevel": "0",
"actions": {
"queries": {
"table": "SELECT st.state_name, SUM(count) as no_of_languages, string_agg(language, ',' order by language) as list_of_languages FROM datasets.nishtha_totalmedium_dqamdiwbdiicaxv9f2xl as ntm JOIN dimensions.state as st ON st.state_id = ntm.state_id GROUP BY ntm.state_id, st.state_name ORDER BY st.state_name"
},
"level": "state",
"nextLevel": "district"
}
}
],
"options": {
"table": {
"columns": [
{
name: "Name of State/ UT/ Autonomous Organisation",
property: "state_name",
class: "text-center"
},
{
name: "No.of Languages",
property: "no_of_languages",
class: "text-center"
},
{
name: "List of Languages",
property: "list_of_languages",
class: "text-center"
}
],
}
}
},
potential_base: {
"label": "% against Potential Base",
"defaultLevel": "state",
Expand Down Expand Up @@ -526,7 +573,7 @@ export const config = {
"actions": {
"queries": {
"bigNumber1": "select count(program_id) as programs from dimensions.programnishtha",
"bigNumber2": "select sum(sum) as beneficiaries from datasets.nishtha_started_programnishtha"
"bigNumber2": "select sum(sum) as beneficiaries from datasets.nishtha_total_participants_programnishtha"
},
"level": "state"
}
Expand Down
28 changes: 21 additions & 7 deletions src/app/views/nishtha/nishtha.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@
*ngIf="selectedTabLabel === 'Implementation Status'"></app-implementation-status-tab>
</mat-tab>

<mat-tab label='Courses and Medium Status' *ngIf="tabs.includes('Courses and Medium Status')">
<app-course-and-medium-status-tab
*ngIf="selectedTabLabel === 'Courses and Medium Status'"></app-course-and-medium-status-tab>
</mat-tab>
<ng-container *ngIf="!NVSK">
<mat-tab label='Courses and Medium Status' *ngIf="tabs.includes('Courses and Medium Status')">
<app-course-and-medium-status-tab
*ngIf="selectedTabLabel === 'Courses and Medium Status'"></app-course-and-medium-status-tab>
</mat-tab>
</ng-container>

<ng-container *ngIf="NVSK">
<mat-tab label='Medium of instruction' *ngIf="tabs.includes('Medium of instruction')">
<app-medium-of-instruction-tab
*ngIf="selectedTabLabel === 'Medium of instruction'"></app-medium-of-instruction-tab>
</mat-tab>
<mat-tab label='Course Wise Status' *ngIf="tabs.includes('Course Wise Status')">
<app-course-wise-status-tab *ngIf="selectedTabLabel === 'Course Wise Status'"></app-course-wise-status-tab>
</mat-tab>
</ng-container>

<mat-tab label='% against Potential Base' *ngIf="tabs.includes('% against Potential Base')">
<app-potential-base-tab *ngIf="selectedTabLabel === '% against Potential Base'"></app-potential-base-tab>
Expand All @@ -32,9 +44,11 @@
*ngIf="selectedTabLabel === 'District Wise Status'"></app-district-wise-status-tab>
</mat-tab>

<mat-tab label='Course Wise Status' *ngIf="tabs.includes('Course Wise Status')">
<app-course-wise-status-tab *ngIf="selectedTabLabel === 'Course Wise Status'"></app-course-wise-status-tab>
</mat-tab>
<ng-container *ngIf="!NVSK">
<mat-tab label='Course Wise Status' *ngIf="tabs.includes('Course Wise Status')">
<app-course-wise-status-tab *ngIf="selectedTabLabel === 'Course Wise Status'"></app-course-wise-status-tab>
</mat-tab>
</ng-container>

</mat-tab-group>
</div>
12 changes: 9 additions & 3 deletions src/app/views/nishtha/nishtha.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ActivatedRoute } from '@angular/router';
import { CommonService } from 'src/app/core/services/common/common.service';
import { RbacService } from 'src/app/core/services/rbac-service.service';
import { config } from './config/nishtha_config';
import { environment } from 'src/environments/environment';

@Component({
selector: 'app-nishtha',
Expand All @@ -16,15 +17,21 @@ export class NishthaComponent implements OnInit {
tabIndex;
selectedTabLabel;
tabs: any = [];
programName: any = 'nishtha'
programName: any = 'nishtha';
NVSK = 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;
})
});

if(environment.config === 'VSK') {
this.NVSK = false;
}

let allTabs = [...Object.keys(config)]
allTabs.forEach((tab: any) => {
config?.[tab]?.filters?.every((filter) => {
Expand All @@ -37,7 +44,6 @@ export class NishthaComponent implements OnInit {
return true
})
})
console.log(this.tabs)
}

ngOnInit(): void {
Expand Down
4 changes: 3 additions & 1 deletion src/app/views/nishtha/nishtha.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ import { PotentialBaseCertificatesComponent } from './pages/potential-base-tab/r
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';
import { MediumOfInstructionTabComponent } from './pages/medium-of-instruction-tab/medium-of-instruction-tab.component';
import { MediumOfInstructionComponent } from './pages/medium-of-instruction-tab/reports/medium-of-instruction/medium-of-instruction.component';

@NgModule({
declarations: [
NishthaComponent,
ImplementationStatusTabComponent,CourseAndMediumStatusTabComponent,CourseWiseStatusTabComponent,PotentialBaseTabComponent,DistrictWiseStatusTabComponent,
ImplementationStatusComponent,CourseAndMediumStatusComponent,PotentialBaseComponent,DistrictWiseStatusComponent,CourseWiseStatusComponent, PotentialBaseCertificatesComponent, NishthaBignumberMetricsComponent, PotentialBaseNvskComponent
ImplementationStatusComponent,CourseAndMediumStatusComponent,PotentialBaseComponent,DistrictWiseStatusComponent,CourseWiseStatusComponent, PotentialBaseCertificatesComponent, NishthaBignumberMetricsComponent, PotentialBaseNvskComponent, MediumOfInstructionTabComponent, MediumOfInstructionComponent
],
imports: [
DashletModule.forRoot({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export class ImplementationStatusComponent implements OnInit {
return filter.filterType === 'metric'
});

filterValues = [...filterValues].filter((filter: any) => {
return filter.filterType !== 'metric'
})

filterValues.forEach((filterParams: any) => {
query = parseFilterToQuery(query, filterParams)
});
Expand All @@ -108,6 +112,7 @@ export class ImplementationStatusComponent implements OnInit {
} else if (query && key === 'map') {
this.spinner.show();
this.reportData = await this._dataService.getMapReportData(query, options, metricFilter);
console.log(this.reportData)
this.spinner.hide();
if (this.reportData?.data?.length > 0) {
let reportsData = { reportData: this.reportData.data, reportType: 'map', reportName: this.title, downloadConfig: options?.downloadConfig }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="col-span-full tab-wrapper">
<div class="filter-row grid grid-cols-4">
<div class="col-span-2">
<app-filter-panel [filters]="filters" (filtersUpdated)="filtersUpdated($event)"
colSize="col-span-6" *ngIf="NVSK"></app-filter-panel>
</div>
<div class="col-start-4 col-end-5 download-button">
<!-- <app-popup-options [data]="reportsData" [reportName]="'nishtha_courses&medium_status'" ></app-popup-options> -->
<app-download-button [data]="reportsData"></app-download-button>
</div>
</div>
<div class="reports-row" >
<div class="row-wrapper grid grid-cols-2 gap-4">

<div class="col-span-2 xmd:col-span-2 div-shadow" *ngIf="checkReport('medium_of_instruction', 'table')"
id="table">
<app-medium-of-instruction #mediumOfInstruction></app-medium-of-instruction>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MediumOfInstructionTabComponent } from './medium-of-instruction-tab.component';

describe('MediumOfInstructionTabComponent', () => {
let component: MediumOfInstructionTabComponent;
let fixture: ComponentFixture<MediumOfInstructionTabComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ MediumOfInstructionTabComponent ]
})
.compileComponents();

fixture = TestBed.createComponent(MediumOfInstructionTabComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
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 { environment } from 'src/environments/environment';
import { MediumOfInstructionComponent } from './reports/medium-of-instruction/medium-of-instruction.component';

@Component({
selector: 'app-medium-of-instruction-tab',
templateUrl: './medium-of-instruction-tab.component.html',
styleUrls: ['./medium-of-instruction-tab.component.scss']
})
export class MediumOfInstructionTabComponent implements OnInit, AfterViewInit {

bigNumberReports: any = {};
minYear: any;
maxYear: any;
minMonth: any;
maxMonth: any;
academicYear: any = [];
months: any = [];
filters: any;
reportsToBeShown: any = [];
rbacDetails: any;
reportsData: any = [];
startDate: any;
endDate: any;
defaultSelectedDays: any;
hasTimeSeriesFilters: boolean = false;
hasCommonFilters: boolean = true;
matLavel = 'Medium of instruction'
NVSK: boolean = true;
@ViewChild('mediumOfInstruction') mediumOfInstruction: MediumOfInstructionComponent;

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> {
// this.renderReports();
}

async ngAfterViewInit(): Promise<void> {
if (this.hasCommonFilters && this.NVSK) {
this.filters = await this._wrapperService.constructCommonFilters(config.filters, this.matLavel);
this.mediumOfInstruction?.getReportData({ filterValues: this.filters.map((filter) => { return { ...filter, columnName: filter.valueProp, filterType: filter.id } }) });
}

if (this.startDate === undefined && this.endDate === undefined && this.hasTimeSeriesFilters) {
let endDate = new Date();
let days = endDate.getDate() - this.defaultSelectedDays;
let startDate = new Date();
startDate.setDate(days);
this.mediumOfInstruction?.getReportData({ timeSeriesValues: { startDate: startDate?.toISOString().split('T')[0], endDate: endDate?.toISOString().split('T')[0] } });
}
}

checkReport(key: string, reportType: string, alterReportType?: string): Boolean {
let reportConfig = config;
let flag = false;
reportConfig[key]?.filters?.forEach((filter: any) => {
if (Number(filter.hierarchyLevel) === Number(this.rbacDetails?.role) && (Object.keys(filter?.actions?.queries).includes(reportType) || Object.keys(filter?.actions?.queries).includes(alterReportType))) {
flag = true
}
})
return flag
}

csvDownload(csvData: any) {
if (csvData) {
this.reportsData.push(csvData)
}
}

filtersUpdated(filters: any) {
this.reportsData = [];
this.mediumOfInstruction?.getReportData({ filterValues: filters.map((filter) => { return { ...filter, columnName: filter.valueProp, filterType: filter.id } }) });
}

timeSeriesUpdated(event: any): void {
this.startDate = event?.startDate?.toDate().toISOString().split('T')[0]
this.endDate = event?.endDate?.toDate().toISOString().split('T')[0]
if (event?.startDate !== null && event?.endDate !== null) {
this.reportsData = [];
this.mediumOfInstruction?.getReportData({ timeSeriesValues: { startDate: this.startDate, endDate: this.endDate } });
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="grid grid-cols-12" *ngIf="reportData?.data?.length > 0">
<div class="xs:col-span-full">
<app-material-heat-chart-table [tableData]="reportData" [title]="title"></app-material-heat-chart-table>
</div>
</div>
<div class="noData" *ngIf="reportData?.data?.length <= 0">
No Data Found
</div>
Loading

0 comments on commit 58791fc

Please sign in to comment.