Skip to content

Commit

Permalink
bug fix for cios
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek-K-P committed Jul 26, 2024
1 parent 0f001ed commit f2b4bd7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class AppTocAboutComponent implements OnInit, OnChanges, AfterViewInit, O
@Input() fromViewer = false
@Input() selectedBatchData: any
@Input() selectedTabValue = 0
@Input() fromMarketPlace? = false
@Input() fromMarketPlace ? = false
@ViewChild('summaryElem', { static: false }) summaryElem !: ElementRef
@ViewChild('objectivesElem', { static: false }) objectivesElem !: ElementRef
@ViewChild('descElem', { static: false }) descElem !: ElementRef
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@project-sunbird/sb-styles": "0.0.7",
"@project-sunbird/sunbird-quml-player": "0.0.6",
"@project-sunbird/telemetry-sdk": "0.0.26",
"@sunbird-cb/consumption": "0.0.66",
"@sunbird-cb/consumption": "0.0.67",
"@sunbird-cb/design-system": "0.0.2",
"@sunbird-cb/discussions-ui-v8": "2.1.3",
"@sunbird-cb/micro-surveys": "^2.0.17",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@
</ng-container>
</a>
</ng-container>
<ng-container *ngIf="(userExtCourseEnroll | json) !== '{}' && userExtCourseEnroll.issued_certificates?.length > 0
<!-- <ng-container *ngIf="(userExtCourseEnroll | json) !== '{}' && userExtCourseEnroll.issued_certificates?.length > 0
&& userExtCourseEnroll.progress === 100">
<button class="flex action-button justify-center flex-middle resume" type="button" (click)="downloadCert()">
<!-- <img src="fusion-assets/images/certificate-ico.svg" width="24" height="24"> -->
<!-- <img src="fusion-assets/images/certificate-ico.svg" width="24" height="24">
<span>Certificate</span>
<mat-icon *ngIf="!downloadCertificateLoading" class="ml-2">arrow_downward</mat-icon>
<div class="center flex flex-middle certificate-loader margin-left-s" *ngIf="downloadCertificateLoading">
<mat-spinner strokeWidth="2" stroke="'white'" class="white-spinner" [diameter]="24"></mat-spinner>
</div>
</button>
</ng-container>
</ng-container> -->
</div>
<div>
<div class="flex flex-col px-8 py-4 gap-2" *ngIf="extContentReadData?.duration > 0">
Expand All @@ -139,7 +139,7 @@
</div>
</ng-container>
<ng-container *ngIf="!skeletonLoader">
<ws-widget-app-toc-about [content]="extContentReadData" [fromMarketPlace]="true"></ws-widget-app-toc-about>
<ws-widget-app-toc-about [content]="extContentReadData" [fromMarketPlace]="true" [skeletonLoader]="skeletonLoader"></ws-widget-app-toc-about>
</ng-container>

</div>
Expand Down Expand Up @@ -199,17 +199,17 @@
</ng-container>
</a>
</ng-container>
<ng-container *ngIf="(userExtCourseEnroll | json) !== '{}' && userExtCourseEnroll.issued_certificates?.length > 0
<!-- <ng-container *ngIf="(userExtCourseEnroll | json) !== '{}' && userExtCourseEnroll.issued_certificates?.length > 0
&& userExtCourseEnroll.progress === 100">
<button class="flex action-button justify-center flex-middle resume" type="button" (click)="downloadCert()">
<!-- <img src="fusion-assets/images/certificate-ico.svg" width="24" height="24"> -->
<!-- <img src="fusion-assets/images/certificate-ico.svg" width="24" height="24">
<span>Certificate</span>
<mat-icon *ngIf="!downloadCertificateLoading" class="ml-2">arrow_downward</mat-icon>
<div class="center flex flex-middle certificate-loader margin-left-s" *ngIf="downloadCertificateLoading">
<mat-spinner strokeWidth="2" stroke="'white'" class="white-spinner" [diameter]="24"></mat-spinner>
</div>
</button>
</ng-container>
</ng-container> -->
</div>
<div>
<div class="flex flex-col kpi-values items-center gap-2" *ngIf="extContentReadData?.duration > 0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { TranslateService } from '@ngx-translate/core'
import { CommonMethodsService } from '@sunbird-cb/consumption'
import { ConfigurationsService, MultilingualTranslationsService, WidgetContentService } from '@sunbird-cb/utils-v2'
import { LoaderService } from '@ws/author/src/public-api'
import { MatDialog, MatSnackBar } from '@angular/material'
import { MatSnackBar } from '@angular/material'
import { CertificateService } from '../../../certificate/services/certificate.service'
import { CertificateDialogComponent } from '@sunbird-cb/collection/src/lib/_common/certificate-dialog/certificate-dialog.component'

@Component({
selector: 'ws-app-app-toc-cios-home',
Expand Down Expand Up @@ -52,17 +51,25 @@ export class AppTocCiosHomeComponent implements OnInit, AfterViewInit {
private langtranslations: MultilingualTranslationsService,
private contentSvc: WidgetContentService,
private certSvc: CertificateService,
private dialog: MatDialog,
public loader: LoaderService,
public snackBar: MatSnackBar
) {
this.route.data.subscribe((data: any) => {
if (data && data.extContent && data.extContent.data && data.extContent.data.content) {
this.extContentReadData = data.extContent.data.content
this.extContentReadData['certificateObj'] = {
data: {},
}
this.skeletonLoader = false
}
if (data && data.userEnrollContent && data.userEnrollContent.data && data.userEnrollContent.data.result) {
if (data && data.userEnrollContent && data.userEnrollContent.data && data.userEnrollContent.data.result &&
Object.keys(data.userEnrollContent.data.result).length > 0
) {
this.userExtCourseEnroll = data.userEnrollContent.data.result
if (this.userExtCourseEnroll.completionpercentage === 100) {
this.extContentReadData['completionStatus'] = 2
this.downloadCert()
}
}
})

Expand Down Expand Up @@ -132,17 +139,17 @@ export class AppTocCiosHomeComponent implements OnInit, AfterViewInit {

async downloadCert() {
this.downloadCertificateLoading = true
const certData = this.userExtCourseEnroll.issued_certificates
const certRes: any = await this.certSvc.downloadCertificate_v2(certData[0].identifier).toPromise().catch(_error => {})
const certRes: any = await
this.certSvc.downloadCertificate_v2(this.userExtCourseEnroll.issued_certificates[0].identifier).toPromise().catch(_error => {})
if (certRes && Object.keys(certRes.result).length > 0) {
this.downloadCertificateLoading = false
this.dialog.open(CertificateDialogComponent, {
width: '1300px',
data: { cet: certRes.result.printUri , certId: certData[0].identifier },
})
this.extContentReadData['certificateObj'] = {
data: this.userExtCourseEnroll.issued_certificates[0],
certData: certRes.result.printUri,
certId: this.userExtCourseEnroll.issued_certificates[0].identifier,
}
} else {
this.downloadCertificateLoading = false
this.snackBar.open('Unable to get the certificate. Try again after sometime.')
}
}
}

0 comments on commit f2b4bd7

Please sign in to comment.