diff --git a/portal-frontend/src/app/features/public/application/alc-review/alc-review.component.html b/portal-frontend/src/app/features/public/application/alc-review/alc-review.component.html index 936712c82c..58b4bc539e 100644 --- a/portal-frontend/src/app/features/public/application/alc-review/alc-review.component.html +++ b/portal-frontend/src/app/features/public/application/alc-review/alc-review.component.html @@ -4,6 +4,9 @@

ALC Review and Decision

- +
diff --git a/portal-frontend/src/app/features/public/application/alc-review/submission-documents/submission-documents.component.ts b/portal-frontend/src/app/features/public/application/alc-review/submission-documents/submission-documents.component.ts index 40166c6600..5364c65182 100644 --- a/portal-frontend/src/app/features/public/application/alc-review/submission-documents/submission-documents.component.ts +++ b/portal-frontend/src/app/features/public/application/alc-review/submission-documents/submission-documents.component.ts @@ -7,7 +7,7 @@ import { PublicDocumentDto } from '../../../../../services/public/public.dto'; import { PublicService } from '../../../../../services/public/public.service'; @Component({ - selector: 'app-submission-documents', + selector: 'app-submission-documents[applicationSubmission]', templateUrl: './submission-documents.component.html', styleUrls: ['./submission-documents.component.scss'], }) @@ -30,14 +30,14 @@ export class PublicSubmissionDocumentsComponent implements OnInit, OnDestroy { } async openFile(uuid: string) { - const res = await this.publicService.getApplicationOpenFileUrl(this.applicationSubmission.fileNumber, uuid); + const res = await this.publicService.getApplicationDownloadFileUrl(this.applicationSubmission.fileNumber, uuid); if (res) { window.open(res.url, '_blank'); } } async downloadFile(uuid: string) { - const res = await this.publicService.getApplicationOpenFileUrl(this.applicationSubmission.fileNumber, uuid); + const res = await this.publicService.getApplicationDownloadFileUrl(this.applicationSubmission.fileNumber, uuid); if (res) { const downloadLink = document.createElement('a'); downloadLink.href = res.url; diff --git a/portal-frontend/src/app/features/public/notice-of-intent/alc-review/alc-review.component.html b/portal-frontend/src/app/features/public/notice-of-intent/alc-review/alc-review.component.html index d9568d4860..56c175af02 100644 --- a/portal-frontend/src/app/features/public/notice-of-intent/alc-review/alc-review.component.html +++ b/portal-frontend/src/app/features/public/notice-of-intent/alc-review/alc-review.component.html @@ -4,6 +4,6 @@

ALC Review and Decision

- +
diff --git a/portal-frontend/src/app/features/public/notice-of-intent/alc-review/submission-documents/submission-documents.component.ts b/portal-frontend/src/app/features/public/notice-of-intent/alc-review/submission-documents/submission-documents.component.ts index 1fe9103978..321c2ab75b 100644 --- a/portal-frontend/src/app/features/public/notice-of-intent/alc-review/submission-documents/submission-documents.component.ts +++ b/portal-frontend/src/app/features/public/notice-of-intent/alc-review/submission-documents/submission-documents.component.ts @@ -35,7 +35,7 @@ export class PublicSubmissionDocumentsComponent implements OnInit, OnDestroy { } async downloadFile(uuid: string) { - const res = await this.publicService.getNoticeOfIntentOpenFileUrl(this.submission.fileNumber, uuid); + const res = await this.publicService.getNoticeOfIntentDownloadFileUrl(this.submission.fileNumber, uuid); if (res) { const downloadLink = document.createElement('a'); downloadLink.href = res.url; diff --git a/portal-frontend/src/app/features/public/notice-of-intent/public-notice-of-intent.module.ts b/portal-frontend/src/app/features/public/notice-of-intent/public-notice-of-intent.module.ts index 52e7ba7867..70db66eecc 100644 --- a/portal-frontend/src/app/features/public/notice-of-intent/public-notice-of-intent.module.ts +++ b/portal-frontend/src/app/features/public/notice-of-intent/public-notice-of-intent.module.ts @@ -46,5 +46,6 @@ const routes: Routes = [ MatAutocompleteModule, MatTreeModule, ], + exports: [PublicAlcReviewComponent], }) export class PublicNoticeOfIntentModule {} diff --git a/portal-frontend/src/app/features/public/notification/alc-review/alc-review.component.html b/portal-frontend/src/app/features/public/notification/alc-review/alc-review.component.html index 6e81d7ef34..3abb9f0a93 100644 --- a/portal-frontend/src/app/features/public/notification/alc-review/alc-review.component.html +++ b/portal-frontend/src/app/features/public/notification/alc-review/alc-review.component.html @@ -3,6 +3,6 @@

ALC Review and Decision

- +
diff --git a/portal-frontend/src/app/features/public/notification/alc-review/alc-review.component.ts b/portal-frontend/src/app/features/public/notification/alc-review/alc-review.component.ts index d822d4b3ed..143cc9d00d 100644 --- a/portal-frontend/src/app/features/public/notification/alc-review/alc-review.component.ts +++ b/portal-frontend/src/app/features/public/notification/alc-review/alc-review.component.ts @@ -10,6 +10,7 @@ import { PublicDocumentDto } from '../../../../services/public/public.dto'; styleUrls: ['./alc-review.component.scss'], }) export class PublicAlcReviewComponent { + @Input() submission!: PublicNotificationSubmissionDto; @Input() documents!: PublicDocumentDto[]; constructor() {} diff --git a/portal-frontend/src/app/features/public/notification/alc-review/submission-documents/submission-documents.component.ts b/portal-frontend/src/app/features/public/notification/alc-review/submission-documents/submission-documents.component.ts index 1fe9103978..0770fff841 100644 --- a/portal-frontend/src/app/features/public/notification/alc-review/submission-documents/submission-documents.component.ts +++ b/portal-frontend/src/app/features/public/notification/alc-review/submission-documents/submission-documents.component.ts @@ -2,7 +2,7 @@ import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { MatSort } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; import { Subject } from 'rxjs'; -import { PublicNoticeOfIntentSubmissionDto } from '../../../../../services/public/public-notice-of-intent.dto'; +import { PublicNotificationSubmissionDto } from '../../../../../services/public/public-notification.dto'; import { PublicDocumentDto } from '../../../../../services/public/public.dto'; import { PublicService } from '../../../../../services/public/public.service'; @@ -16,7 +16,7 @@ export class PublicSubmissionDocumentsComponent implements OnInit, OnDestroy { displayedColumns: string[] = ['type', 'fileName', 'source', 'uploadedAt', 'actions']; @Input() documents!: PublicDocumentDto[]; - @Input() submission!: PublicNoticeOfIntentSubmissionDto; + @Input() submission!: PublicNotificationSubmissionDto; @ViewChild(MatSort) sort!: MatSort; dataSource: MatTableDataSource = new MatTableDataSource(); @@ -28,14 +28,14 @@ export class PublicSubmissionDocumentsComponent implements OnInit, OnDestroy { } async openFile(uuid: string) { - const res = await this.publicService.getNoticeOfIntentOpenFileUrl(this.submission.fileNumber, uuid); + const res = await this.publicService.getNotificationOpenFileUrl(this.submission.fileNumber, uuid); if (res) { window.open(res.url, '_blank'); } } async downloadFile(uuid: string) { - const res = await this.publicService.getNoticeOfIntentOpenFileUrl(this.submission.fileNumber, uuid); + const res = await this.publicService.getNotificationDownloadFileUrl(this.submission.fileNumber, uuid); if (res) { const downloadLink = document.createElement('a'); downloadLink.href = res.url; diff --git a/portal-frontend/src/app/features/public/notification/public-notification.component.html b/portal-frontend/src/app/features/public/notification/public-notification.component.html index bd6c7ab639..48125cd3a2 100644 --- a/portal-frontend/src/app/features/public/notification/public-notification.component.html +++ b/portal-frontend/src/app/features/public/notification/public-notification.component.html @@ -48,7 +48,7 @@

Applicant Submission

- +
diff --git a/portal-frontend/src/app/services/public/public.service.spec.ts b/portal-frontend/src/app/services/public/public.service.spec.ts index f005ebfa28..574b4060d6 100644 --- a/portal-frontend/src/app/services/public/public.service.spec.ts +++ b/portal-frontend/src/app/services/public/public.service.spec.ts @@ -42,7 +42,7 @@ describe('PublicService', () => { expect(res).toBeDefined(); }); - it('should call get for loading application files', async () => { + it('should call get for opening application files', async () => { mockHttpClient.get.mockReturnValue(of({})); const res = await service.getApplicationOpenFileUrl('fileId', 'documentUuid'); @@ -50,4 +50,67 @@ describe('PublicService', () => { expect(mockHttpClient.get).toHaveBeenCalledTimes(1); expect(res).toBeDefined(); }); + + it('should call get for download application files', async () => { + mockHttpClient.get.mockReturnValue(of({})); + + const res = await service.getApplicationDownloadFileUrl('fileId', 'documentUuid'); + + expect(mockHttpClient.get).toHaveBeenCalledTimes(1); + expect(res).toBeDefined(); + }); + + it('should call get for loading Notice of Intent', async () => { + mockHttpClient.get.mockReturnValue(of({})); + + const res = await service.getNoticeOfIntent('fileId'); + + expect(mockHttpClient.get).toHaveBeenCalledTimes(1); + expect(res).toBeDefined(); + }); + + it('should call get for opening Notice of Intent files', async () => { + mockHttpClient.get.mockReturnValue(of({})); + + const res = await service.getNoticeOfIntentOpenFileUrl('fileId', 'documentUuid'); + + expect(mockHttpClient.get).toHaveBeenCalledTimes(1); + expect(res).toBeDefined(); + }); + + it('should call get for download Notice of Intent files', async () => { + mockHttpClient.get.mockReturnValue(of({})); + + const res = await service.getNoticeOfIntentDownloadFileUrl('fileId', 'documentUuid'); + + expect(mockHttpClient.get).toHaveBeenCalledTimes(1); + expect(res).toBeDefined(); + }); + + it('should call get for loading Notification', async () => { + mockHttpClient.get.mockReturnValue(of({})); + + const res = await service.getNotification('fileId'); + + expect(mockHttpClient.get).toHaveBeenCalledTimes(1); + expect(res).toBeDefined(); + }); + + it('should call get for opening Notification files', async () => { + mockHttpClient.get.mockReturnValue(of({})); + + const res = await service.getNotificationOpenFileUrl('fileId', 'documentUuid'); + + expect(mockHttpClient.get).toHaveBeenCalledTimes(1); + expect(res).toBeDefined(); + }); + + it('should call get for download Notification files', async () => { + mockHttpClient.get.mockReturnValue(of({})); + + const res = await service.getNotificationDownloadFileUrl('fileId', 'documentUuid'); + + expect(mockHttpClient.get).toHaveBeenCalledTimes(1); + expect(res).toBeDefined(); + }); }); diff --git a/portal-frontend/src/app/services/public/public.service.ts b/portal-frontend/src/app/services/public/public.service.ts index c8de0e6cbc..db6c7da137 100644 --- a/portal-frontend/src/app/services/public/public.service.ts +++ b/portal-frontend/src/app/services/public/public.service.ts @@ -39,6 +39,18 @@ export class PublicService { } } + async getApplicationDownloadFileUrl(fileId: string, uuid: string) { + try { + return await firstValueFrom( + this.httpClient.get<{ url: string }>(`${this.serviceUrl}/application/${fileId}/${uuid}/download`) + ); + } catch (e) { + console.error(e); + this.toastService.showErrorToast('Failed to load Application File, please try again later'); + return undefined; + } + } + async getNoticeOfIntent(fileId: string) { try { return await firstValueFrom( @@ -63,6 +75,18 @@ export class PublicService { } } + async getNoticeOfIntentDownloadFileUrl(fileId: string, uuid: string) { + try { + return await firstValueFrom( + this.httpClient.get<{ url: string }>(`${this.serviceUrl}/notice-of-intent/${fileId}/${uuid}/download`) + ); + } catch (e) { + console.error(e); + this.toastService.showErrorToast('Failed to load Notice of Intent File, please try again later'); + return undefined; + } + } + async getNotification(fileId: string) { try { return await firstValueFrom( @@ -86,4 +110,16 @@ export class PublicService { return undefined; } } + + async getNotificationDownloadFileUrl(fileId: string, uuid: string) { + try { + return await firstValueFrom( + this.httpClient.get<{ url: string }>(`${this.serviceUrl}/notification/${fileId}/${uuid}/download`) + ); + } catch (e) { + console.error(e); + this.toastService.showErrorToast('Failed to load Notification, please try again later'); + return undefined; + } + } } diff --git a/services/apps/alcs/src/portal/public/public.controller.ts b/services/apps/alcs/src/portal/public/public.controller.ts index 22d31c91d4..935b027760 100644 --- a/services/apps/alcs/src/portal/public/public.controller.ts +++ b/services/apps/alcs/src/portal/public/public.controller.ts @@ -23,11 +23,7 @@ export class PublicController { @Param('fileId') fileId: string, @Param('uuid') documentUuid: string, ) { - const url = await this.publicAppService.getDownloadUrl(documentUuid); - - return { - url, - }; + return await this.publicAppService.getDownloadUrl(documentUuid); } @Get('/application/:fileId/:uuid/open') @@ -35,11 +31,7 @@ export class PublicController { @Param('fileId') fileId: string, @Param('uuid') documentUuid: string, ) { - const url = await this.publicAppService.getInlineUrl(documentUuid); - - return { - url, - }; + return await this.publicAppService.getInlineUrl(documentUuid); } @Get('/notice-of-intent/:fileId') @@ -52,13 +44,7 @@ export class PublicController { @Param('fileId') fileId: string, @Param('uuid') documentUuid: string, ) { - const url = await this.publicNoticeOfIntentService.getDownloadUrl( - documentUuid, - ); - - return { - url, - }; + return await this.publicNoticeOfIntentService.getDownloadUrl(documentUuid); } @Get('/notice-of-intent/:fileId/:uuid/open') @@ -66,13 +52,7 @@ export class PublicController { @Param('fileId') fileId: string, @Param('uuid') documentUuid: string, ) { - const url = await this.publicNoticeOfIntentService.getInlineUrl( - documentUuid, - ); - - return { - url, - }; + return await this.publicNoticeOfIntentService.getInlineUrl(documentUuid); } @Get('/notification/:fileId') @@ -85,13 +65,7 @@ export class PublicController { @Param('fileId') fileId: string, @Param('uuid') documentUuid: string, ) { - const url = await this.publicNotificationService.getDownloadUrl( - documentUuid, - ); - - return { - url, - }; + return await this.publicNotificationService.getDownloadUrl(documentUuid); } @Get('/notification/:fileId/:uuid/open') @@ -99,10 +73,6 @@ export class PublicController { @Param('fileId') fileId: string, @Param('uuid') documentUuid: string, ) { - const url = await this.publicNotificationService.getInlineUrl(documentUuid); - - return { - url, - }; + return await this.publicNotificationService.getInlineUrl(documentUuid); } }