From 7aee22bdfe0c9539998557b2845d9441ffc38aab Mon Sep 17 00:00:00 2001 From: suvarnakale Date: Fri, 27 Oct 2023 13:50:44 +0530 Subject: [PATCH 1/2] #846 - Redirection of certicificate icons to preview - Done --- .../add-template/add-template.component.html | 6 +- .../add-template/add-template.component.ts | 86 +++++++++++-------- .../configurations.component.html | 4 +- .../configurations.component.ts | 15 +++- 4 files changed, 66 insertions(+), 45 deletions(-) diff --git a/src/app/admin/add-template/add-template.component.html b/src/app/admin/add-template/add-template.component.html index 06c6eb6..5f4e385 100644 --- a/src/app/admin/add-template/add-template.component.html +++ b/src/app/admin/add-template/add-template.component.html @@ -16,7 +16,7 @@ -->
-
+
@@ -90,11 +90,11 @@
-
+
{{'PREVIEW' | translate}}
-
+
  diff --git a/src/app/admin/add-template/add-template.component.ts b/src/app/admin/add-template/add-template.component.ts index c8f061c..ff700b5 100644 --- a/src/app/admin/add-template/add-template.component.ts +++ b/src/app/admin/add-template/add-template.component.ts @@ -62,6 +62,10 @@ export class AddTemplateComponent implements OnInit { certificateTitle: any; schemaOsid: any; vcStep: string; + fromPreview: boolean; + credTemp: any[]; + flag: boolean; + certificateName: any; constructor(public schemaService: SchemaService, public toastMsg: ToastMessageService, private route: ActivatedRoute, @@ -72,21 +76,18 @@ export class AddTemplateComponent implements OnInit { public translate: TranslateService, public router: Router) { } - ngOnInit(): void { + async ngOnInit() { this.getDocument(); this.route.queryParams.subscribe(params => { this.fromEdit = params['fromEdit'] === 'true'; this.certificateIndex = +params['certificateIndex']; - + this.fromPreview = params['fromPreview'] === 'true'; + this.certificateName = params['certificateName']; }); if (this.fromEdit) { this.previewScreen(); } - // this.generalService.getData('/Issuer').subscribe((res) => { - // console.log(res); - // this.issuerOsid = res[0].osid; - // }); this.activeRoute.params.subscribe(params => { this.params = params; @@ -98,16 +99,45 @@ export class AddTemplateComponent implements OnInit { } this.schemaService.getEntitySchemaJSON().subscribe((data) => { let allSteps = data['usecase'][this.usecase]['steps']; - for(let i=0; i response.text()) - // .then(data => { - // this.schemaContent = data; - // this.userJson = data; - // // Do something with your data - // console.log(this.userJson); - // }); - - // fetch(doc.certificateUrl) - // .then(response => response.text()) - // .then(data => { - // this.certificateContent = data; - // this.userHtml = data; - // this.injectHTML(); - // }); - - // this.isPreview = true; - // localStorage.setItem('isPreview', 'yes'); - - if (this.fromEdit && this.certificateIndex !== undefined) { + if (this.fromEdit || this.fromPreview && this.certificateIndex !== undefined) { const credTemp = this.generalService.getCertificateData(); - const certificateData = credTemp[this.certificateIndex]['html']; - this.certificateTitle = credTemp[this.certificateIndex]['title']; + if(this.certificateName){ + for(let i=0; i < this.credTemp.length; i++){ + if(this.credTemp[i].title == this.certificateName){ + this.certificateIndex = i; + break; + } + } + } + const certificateData = credTemp ? credTemp[this.certificateIndex]['html'] : this.credTemp[this.certificateIndex]['html']; + this.certificateTitle = credTemp ? credTemp[this.certificateIndex]['title'] : this.credTemp[this.certificateIndex]['title']; this.userHtml = certificateData; } - if (!this.fromEdit) { + if (!this.fromEdit && !this.fromPreview) { this.userHtml = `