Skip to content

Commit

Permalink
Merge pull request #91 from abhishek-K-P/sprint-19-dev
Browse files Browse the repository at this point in the history
changed the OrgId to logged in user Org
  • Loading branch information
abhishek-K-P authored Nov 10, 2024
2 parents 82e89e8 + 9da0866 commit 07ae253
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'
import _ from 'lodash'
import { BlendedApporvalService } from '../../services/blended-approval.service'
import { TelemetryEvents } from '../../../../head/_services/telemetry.event.model'
import { EventService } from '@sunbird-cb/utils'
import { ConfigurationsService, EventService } from '@sunbird-cb/utils'
import { NominateUsersDialogComponent } from '../nominate-users-dialog/nominate-users-dialog.component'
import moment from 'moment'
import { NsContent } from '../../../../head/_services/widget-content.model'
Expand Down Expand Up @@ -39,8 +39,8 @@ export class BatchDetailsComponent implements OnInit {
userscount: any
showUserDetails = false
selectedUser: any
fetchStatus: boolean = true
checkSurveyLink: boolean = false
fetchStatus = true
checkSurveyLink = false
reportStatusList: any[] = []

tabledata: ITableData = {
Expand All @@ -58,16 +58,17 @@ export class BatchDetailsComponent implements OnInit {
sortState: 'asc',
needUserMenus: false,
}
userDetails: any

constructor(private router: Router, private activeRouter: ActivatedRoute,
// tslint:disable-next-line:align
constructor(
private router: Router,
private activeRouter: ActivatedRoute,
private bpService: BlendedApporvalService,
// tslint:disable-next-line:align
private snackBar: MatSnackBar,
// tslint:disable-next-line:align
private events: EventService,
// tslint:disable-next-line:align
private dialogue: MatDialog) {
private dialogue: MatDialog,
public configSvc: ConfigurationsService,
) {
const currentState = this.router.getCurrentNavigation()
if (currentState && currentState.extras.state) {
this.batchData = currentState.extras.state
Expand All @@ -82,7 +83,9 @@ export class BatchDetailsComponent implements OnInit {
}
}

ngOnInit() { }
async ngOnInit() {
this.userDetails = await this.bpService.getUserById('').toPromise().catch(_error => { })
}

filter(key: 'pending' | 'approved' | 'rejected' | 'sessions' | 'approvalStatus' | 'reportStatus') {
this.approvedUsers = []
Expand Down Expand Up @@ -551,33 +554,33 @@ export class BatchDetailsComponent implements OnInit {
this.getBpReportStatus()
}
if (evt.action === 'downloadReport') {
this.getBpReportStatus()
this.downloadReport()
}
}

async getBpReportStatus() {
const batchDetails = this.batchData
const req = {
request: {
orgId: this.programData.channel || '',
orgId: this.userDetails.rootOrgId || '',
courseId: this.programData.identifier || '',
batchId: batchDetails.batchId || ''
}
batchId: batchDetails.batchId || '',
},
}
const resData: any = await this.bpService.getBpReportStatusApi(req).toPromise().catch(_error => { })
if (!resData) {
this.fetchStatus = false
this.snackBar.open('Something went wrong while fetching the report status. Please try again after sometime.')
this.reportStatusList = []
} else if (!resData.result && Object.keys(resData.result).length <= 0) {
} else if (Object.keys(resData.result).length <= 0) {
this.reportStatusList = []
} else {
this.reportStatusList = resData.result.content
this.reportStatusList[0]['requestedon'] = this.reportStatusList[0]['lastReportGeneratedOn']
this.reportStatusList[0]['name'] = 'Enrollment Request Report'
this.reportStatusList[0]['SlNo'] = '1'
if (this.reportStatusList[0]['status'].toLowerCase() === 'completed') {
this.tabledata.actions = [{ icon: 'cloud_download', label: 'Download', name: 'download', type: 'link', disabled: false }]
this.tabledata.actions = [{ icon: 'cloud_download', label: 'Download', name: 'downloadReport', type: 'link', disabled: false }]
} else if (this.reportStatusList[0]['status'].toLowerCase() === 'in-progress' ||
this.reportStatusList[0]['status'].toLowerCase() === 'failed') {
this.tabledata.actions = [{ icon: 'refresh', label: 'Refresh', name: 'refreshStatus', type: 'link', disabled: false }]
Expand All @@ -588,11 +591,11 @@ export class BatchDetailsComponent implements OnInit {
const batchDetails = this.batchData
const reqBody = {
request: {
orgId: this.programData.channel || '',
orgId: this.userDetails.rootOrgId || '',
courseId: this.programData.identifier || '',
batchId: batchDetails.batchId || '',
surveyId: this.programData.wfSurveyLink.split('/')[this.programData.wfSurveyLink.split('/').length - 1] || '',
}
},
}
const resData: any = await this.bpService.generateBpReport(reqBody).toPromise().catch(_error => { })
if (resData && resData.params && resData.params.status.toLowerCase() === 'success') {
Expand All @@ -609,8 +612,10 @@ export class BatchDetailsComponent implements OnInit {
const downloadUrl = this.reportStatusList[0].downloadLink.split('gcpbpreports/')
[this.reportStatusList[0].downloadLink.split('gcpbpreports/').length - 1]
const fileExtension = downloadUrl.split('.').pop()?.toLowerCase()
const roleName = this.userDetails.roles.includes("MDO_LEADER") ? "MDO_LEADER" :
this.userDetails.roles.includes("MDO_LEADER") ? "MDO_ADMIN" : ''
// tslint:disable-next-line: max-line-length
const fileName = `Program_Coordinator_${batchDetails.name.split(' ').join('')}_Enrollment_Requests_Report_${this.formatDate(this.reportStatusList[0].lastReportGeneratedOn)}.${fileExtension}`
const fileName = `_Enrollment_Requests_Report_${roleName}_${batchDetails.name.split(' ').join('')}_Enrollment_Requests_Report_${this.formatDate(this.reportStatusList[0].lastReportGeneratedOn)}.${fileExtension}`
await this.bpService.downloadReport(downloadUrl, fileName)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const API_END_POINTS = {
BLENDED_USER_COUNT: `apis/proxies/v8/workflow/blendedprogram/enrol/status/count`,
BPREPORT_STATUS: 'apis/proxies/v8/bp/v1/bpreport/status',
GENERATE_REPORT: `apis/proxies/v8/bp/v1/generate/report`,
DOWNLOAD_REPORT: `apis/proxies/v8/bp/v1/bpreport/download/`
DOWNLOAD_REPORT: `apis/proxies/v8/bp/v1/bpreport/download/`,
}

@Injectable({
Expand Down

0 comments on commit 07ae253

Please sign in to comment.