Skip to content

Commit 9de2241

Browse files
Merge pull request #210 from venkykandagaddala/cbrelease-4.8.12
Shikshalokham reports
2 parents 78b20ea + a981932 commit 9de2241

File tree

8 files changed

+278
-11
lines changed

8 files changed

+278
-11
lines changed

project/ws/app/src/lib/routes/home/home.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import { PipeEmailPipe } from './pipes/pipe-email.pipe'
7373
import { EditEventComponent } from './routes/events/edit-event/edit-event.component'
7474
import { PipePublicURLModule } from './pipes/pipe-public-URL/pipe-public-URL.module'
7575
import { AcbpReportsComponent } from './routes/acbp-reports/acbp-reports.component'
76+
import { GeneralReportsComponent } from './routes/general-reports/general-reports.component'
7677
@NgModule({
7778
declarations: [
7879
HomeComponent,
@@ -94,6 +95,7 @@ import { AcbpReportsComponent } from './routes/acbp-reports/acbp-reports.compone
9495
ReportsComponent,
9596
CommsComponent,
9697
AcbpReportsComponent,
98+
GeneralReportsComponent,
9799
EventsListComponent,
98100
EventListViewComponent,
99101
EventThumbnailComponent,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="flex flex-4 flex-column cbp-reports">
2+
<ng-container *ngIf="reportSectionData && reportSectionData.length">
3+
<ws-widget-org-user-table [tableData]="tabledata" [data]='reportSectionData'
4+
(actionsClick)="downloadFile($event)"></ws-widget-org-user-table>
5+
</ng-container>
6+
<ng-container *ngIf="reportSectionData.length === 0">
7+
<div class="no-reports">No reports are avaible for the selected date.</div>
8+
</ng-container>
9+
</div>
10+
11+
<div *ngIf="displayLoader" class="mt-5 pr-4 flex items-center justify-center">
12+
<mat-spinner [diameter]="30"></mat-spinner>
13+
</div>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@import 'ws-common';
2+
@import 'ws-vars';
3+
@import 'ws-mixins';
4+
5+
::ng-deep .p1-btn {
6+
box-shadow: none !important;
7+
padding: 0 !important;
8+
text-align: left !important;
9+
span {
10+
text-decoration: underline !important;
11+
color: #0075B7 !important;
12+
}
13+
}
14+
15+
::ng-deep .cbp-reports .cdk-column-Actions {
16+
flex: 0 0 10%!important;
17+
}
18+
19+
::ng-deep .cbp-reports .cdk-column-reportName .textclass {
20+
cursor: default!important;
21+
}
22+
23+
::ng-deep .cbp-reports .cdk-column-reportType .textclass {
24+
cursor: default!important;
25+
}
26+
27+
::ng-deep .cbp-reports .cdk-column-lastUpdateOn .textclass {
28+
cursor: default!important;
29+
}
30+
31+
::ng-deep .mat-card-header-text {
32+
margin: 0!important;
33+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing'
2+
import { GeneralReportsComponent } from './general-reports.component'
3+
4+
5+
describe('GeneralReportsComponent', () => {
6+
let component: GeneralReportsComponent
7+
let fixture: ComponentFixture<GeneralReportsComponent>
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [GeneralReportsComponent],
12+
})
13+
.compileComponents()
14+
}))
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(GeneralReportsComponent)
18+
component = fixture.componentInstance
19+
fixture.detectChanges()
20+
})
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy()
24+
})
25+
})
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import { Component, OnInit, ViewChild } from '@angular/core'
2+
import { MatDialog } from '@angular/material/dialog'
3+
import { ConfigurationsService } from '@sunbird-cb/utils'
4+
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatSnackBar } from '@angular/material'
5+
import { environment } from '../../../../../../../../../src/environments/environment'
6+
/* tslint:disable */
7+
import _ from 'lodash'
8+
import { MatPaginator, MatTableDataSource } from '@angular/material'
9+
import { DatePipe } from '@angular/common'
10+
import { MomentDateAdapter } from '@angular/material-moment-adapter'
11+
import moment from 'moment'
12+
import { GeneralReportsService } from './general-reports.service'
13+
14+
export const MY_FORMATS = {
15+
parse: {
16+
dateInput: 'LL',
17+
},
18+
display: {
19+
dateInput: 'DD/MM/YYYY',
20+
monthYearLabel: 'YYYY',
21+
dateA11yLabel: 'LL',
22+
monthYearA11yLabel: 'YYYY',
23+
},
24+
}
25+
@Component({
26+
selector: 'ws-general-reports',
27+
templateUrl: './general-reports.component.html',
28+
styleUrls: ['./general-reports.component.scss'],
29+
providers: [DatePipe,
30+
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
31+
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
32+
]
33+
34+
})
35+
export class GeneralReportsComponent implements OnInit {
36+
37+
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator | null = null
38+
currentUser!: string | null
39+
tabledata: any = []
40+
dataSource: MatTableDataSource<any>
41+
reportSectionData: any = []
42+
todayDate: any
43+
maxDate: any
44+
reportData = []
45+
buckets: any
46+
displayLoader = false
47+
48+
constructor(
49+
public dialog: MatDialog,
50+
private configSvc: ConfigurationsService,
51+
private generalReportsService: GeneralReportsService,
52+
private datePipe: DatePipe,
53+
private snackBar: MatSnackBar,
54+
) {
55+
this.currentUser = this.configSvc.userProfile && this.configSvc.userProfile.userId
56+
this.dataSource = new MatTableDataSource(this.reportSectionData)
57+
this.dataSource.paginator = this.paginator
58+
59+
}
60+
61+
ngOnInit() {
62+
63+
this.todayDate = new Date(new Date())
64+
this.maxDate = new Date(new Date())
65+
66+
this.tabledata = {
67+
columns: [
68+
{ displayName: 'Report name', key: 'reportName' },
69+
{ displayName: 'Report type', key: 'reportType' },
70+
{ displayName: 'Last updated on', key: 'lastUpdateOn' },
71+
],
72+
needCheckBox: false,
73+
needHash: false,
74+
sortColumn: 'reportName',
75+
sortState: 'asc',
76+
needUserMenus: false,
77+
actionColumnName: 'Action',
78+
actions: [{ icon: '', label: 'Download', name: 'DownloadFile', type: 'Standard', disabled: false }],
79+
}
80+
81+
this.generalReportsService.getContent().subscribe((result: any) => {
82+
if (result && result.reports && result.reports.buckets) {
83+
this.buckets = result.reports.buckets
84+
this.getTableData(this.datePipe.transform(new Date(), 'yyyy-MM-dd'))
85+
}
86+
})
87+
setTimeout(() => this.dataSource.paginator = this.paginator)
88+
}
89+
90+
getTableData(rDate: any) {
91+
this.displayLoader = true
92+
this.reportSectionData = []
93+
this.generalReportsService.getReportContnet(rDate).subscribe((result: any) => {
94+
this.buckets.forEach((bucket: any) => {
95+
if (bucket.enable) {
96+
let lastUpdateOn: any = '-'
97+
let downloadUrl: any = ''
98+
const resp = result[bucket.key]
99+
if (resp && resp.lastModified) {
100+
lastUpdateOn = this.datePipe.transform(resp.lastModified, 'dd/MM/yyyy, h:mm a')
101+
downloadUrl = this.datePipe.transform(resp.lastModified, 'yyyy-MM-dd')
102+
}
103+
this.reportSectionData.push({
104+
reportName: bucket.name,
105+
reportType: "Detailed data report",
106+
lastUpdateOn: lastUpdateOn,
107+
downloadUrl: downloadUrl,
108+
bucketKey: bucket.key
109+
})
110+
}
111+
this.dataSource = new MatTableDataSource(this.reportSectionData)
112+
})
113+
this.displayLoader = false
114+
}, error => {
115+
this.displayLoader = false
116+
// tslint:disable-next-line: no-console
117+
console.log(error)
118+
})
119+
}
120+
121+
downloadFile(event: any) {
122+
if (event.row.downloadUrl && event.row.downloadUrl !== '') {
123+
this.downloadReport(event.row)
124+
} else {
125+
this.snackBar.open('Report is not available.', 'X', { duration: 2000 })
126+
}
127+
}
128+
129+
updateDate(event: any) {
130+
this.getTableData(moment(new Date(event.value)).format("YYYY-MM-DD"))
131+
}
132+
133+
async downloadReport(row: any) {
134+
const downloadUrl = `${environment.spvPath}/apis/proxies/v8/storage/v1/spvReport/${row.bucketKey.split(".zip")[0]}/${row.downloadUrl}/${row.bucketKey}`
135+
const xhr = new XMLHttpRequest()
136+
xhr.onreadystatechange = () => {
137+
if (xhr.readyState !== 4) {
138+
return
139+
}
140+
if (xhr.status === 200) {
141+
window.location.href = downloadUrl
142+
}
143+
}
144+
xhr.open('GET', downloadUrl)
145+
xhr.send()
146+
}
147+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Injectable } from '@angular/core'
2+
import { HttpClient } from '@angular/common/http'
3+
import { ConfigurationsService } from '@sunbird-cb/utils'
4+
5+
@Injectable({
6+
providedIn: 'root',
7+
})
8+
export class GeneralReportsService {
9+
10+
GENERAL_REPORTS = '/apis/proxies/v8/storage/v1/spvReportInfo'
11+
12+
constructor(private configSvc: ConfigurationsService,
13+
private http: HttpClient) { }
14+
15+
getContent() {
16+
return this.http.get<any>(`${this.configSvc.baseUrl}/feature/general-reports.json`)
17+
}
18+
19+
getReportContnet(rdate: any) {
20+
return this.http.get<any>(`${this.GENERAL_REPORTS}/${rdate}`)
21+
}
22+
23+
}

project/ws/app/src/lib/routes/home/routes/reports/reports.component.html

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,36 @@
1313
<div class="flex flex-1 flex-column margin-fix">
1414
<div class="flex flex-1 filter max-height-60">
1515
<div *ngFor="let department of departmentHearders">
16+
<a *ngIf="department==='STATE'" class="filter-option"
17+
[ngClass]="{'ws-mat-accent-border-active' : currentFilter === 'state',
18+
'ws-mat-accent-border font-medium':currentFilter !== 'state'}" mat-button
19+
[routerLink]="'/app/home/reports/state'" (click)="filter(department.toLowerCase())" role="button">
20+
STATE</a>
1621
<a *ngIf="department ==='MINISTRY'" class="filter-option"
1722
[ngClass]="{'ws-mat-accent-border-active' : currentFilter === 'ministry',
1823
'ws-mat-accent-border font-medium':currentFilter !== 'ministry'}" mat-button
1924
[routerLink]="'/app/home/reports/ministry'" (click)="filter(department.toLowerCase())" role="button">
2025
MINISTRY</a>
21-
<a *ngIf="department==='STATE'" class="filter-option"
22-
[ngClass]="{'ws-mat-accent-border-active' : currentFilter === 'state',
23-
'ws-mat-accent-border font-medium':currentFilter !== 'state'}" mat-button
24-
[routerLink]="'/app/home/reports/state'" (click)="filter(department.toLowerCase())" role="button">
25-
STATE</a>
26+
27+
<a *ngIf="department ==='survey'" class="filter-option"
28+
[ngClass]="{'ws-mat-accent-border-active' : currentFilter === 'survey',
29+
'ws-mat-accent-border font-medium':currentFilter !== 'survey'}" mat-button
30+
[routerLink]="'/app/home/reports/survey'" (click)="renderSurvey()" role="button">
31+
SURVEY</a>
32+
2633
</div>
34+
2735
</div>
2836
</div>
29-
<ng-container>
37+
<ng-container *ngIf="currentFilter !== 'survey'">
3038
<ws-widget-directory-table [selectedDepartment]='currentDepartment' [tableData]='tabledata' [data]='data'
3139
[needCreate]="false" (eOnRowClick)="onRoleClick($event)" (actionsClick)="actionClick($event)"
3240
(searchByEnterKey)="onEnterkySearch($event)">
3341
</ws-widget-directory-table>
3442
</ng-container>
43+
<ng-container *ngIf="currentFilter === 'survey'">
44+
<ws-general-reports></ws-general-reports>
45+
</ng-container>
3546
</mat-card-content>
3647
</mat-card>
3748
</div>

project/ws/app/src/lib/routes/home/routes/reports/reports.component.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export class ReportsComponent implements OnInit {
7575
this.getDepartDataByKey(this.currentFilter)
7676
this.createTableHeader()
7777
}
78+
this.departmentHearders.push('survey')
7879
})
7980
}
8081
createTableHeader() {
@@ -107,7 +108,9 @@ export class ReportsComponent implements OnInit {
107108
}
108109

109110
filter(value: string) {
110-
this.searchInputvalue.searchInput.nativeElement.value = ''
111+
if (value !== 'survey') {
112+
this.searchInputvalue && this.searchInputvalue.searchInput ? this.searchInputvalue.searchInput.nativeElement.value = '' : ''
113+
}
111114
let key = ''
112115
let index = 1
113116
if (value === 'cbc') {
@@ -122,6 +125,8 @@ export class ReportsComponent implements OnInit {
122125
key = 'state'
123126
} else if (value === 'ministry') {
124127
key = 'ministry'
128+
} else if (value === 'survey') {
129+
key = 'survey'
125130
}
126131
if (key === 'cbc') {
127132
index = 1
@@ -134,11 +139,18 @@ export class ReportsComponent implements OnInit {
134139
index,
135140
label: key,
136141
}
137-
this.searchInputvalue.applyFilter('')
138-
this.getAllDepartments('')
139-
this.raiseTabTelemetry(key, data)
140-
this.getDepartDataByKey(key)
142+
if (value !== 'survey') {
143+
this.searchInputvalue ? this.searchInputvalue.applyFilter('') : ''
144+
this.getAllDepartments('')
145+
this.getDepartDataByKey(key)
146+
this.raiseTabTelemetry(key, data)
147+
}
141148
}
149+
150+
renderSurvey() {
151+
this.currentFilter = 'survey'
152+
}
153+
142154
getDepartDataByKey(key: string) {
143155
if (key) {
144156
this.currentFilter = key
@@ -234,6 +246,7 @@ export class ReportsComponent implements OnInit {
234246
filteredData2.push(obj)
235247
}
236248
})
249+
break
237250
}
238251
this.data = filteredData2.map((dept: any) => {
239252
return {

0 commit comments

Comments
 (0)