From 2e1f124689c06f0fb77b860a2ba1248af38f3b3c Mon Sep 17 00:00:00 2001 From: Sandra To Date: Mon, 11 Mar 2024 13:40:54 -0700 Subject: [PATCH 1/2] Create utils and add filename to backend requests --- .../application-document.service.ts | 5 ++++- .../notice-of-intent-document.service.ts | 5 ++++- .../parcel-owners/parcel-owners.component.ts | 4 +++- portal-frontend/src/app/shared/utils/file.ts | 20 +++++++++++++++++++ .../application-document.controller.ts | 4 +++- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/portal-frontend/src/app/services/application-document/application-document.service.ts b/portal-frontend/src/app/services/application-document/application-document.service.ts index b7b69eab01..d908451237 100644 --- a/portal-frontend/src/app/services/application-document/application-document.service.ts +++ b/portal-frontend/src/app/services/application-document/application-document.service.ts @@ -51,7 +51,10 @@ export class ApplicationDocumentService { async openFile(fileUuid: string) { try { - return await firstValueFrom(this.httpClient.get<{ url: string }>(`${this.serviceUrl}/${fileUuid}/open`)); + return await firstValueFrom( + // TODO: Make fileName mandatory when ready to update all other usage + this.httpClient.get<{ url: string; fileName?: string }>(`${this.serviceUrl}/${fileUuid}/open`) + ); } catch (e) { console.error(e); this.toastService.showErrorToast('Failed to open the document, please try again'); diff --git a/portal-frontend/src/app/services/notice-of-intent-document/notice-of-intent-document.service.ts b/portal-frontend/src/app/services/notice-of-intent-document/notice-of-intent-document.service.ts index 40461754d6..a4e466f5ed 100644 --- a/portal-frontend/src/app/services/notice-of-intent-document/notice-of-intent-document.service.ts +++ b/portal-frontend/src/app/services/notice-of-intent-document/notice-of-intent-document.service.ts @@ -51,7 +51,10 @@ export class NoticeOfIntentDocumentService { async openFile(fileUuid: string) { try { - return await firstValueFrom(this.httpClient.get<{ url: string }>(`${this.serviceUrl}/${fileUuid}/open`)); + return await firstValueFrom( + // TODO: Make fileName mandatory when ready to update all other usage + this.httpClient.get<{ url: string; fileName?: string }>(`${this.serviceUrl}/${fileUuid}/open`) + ); } catch (e) { console.error(e); this.toastService.showErrorToast('Failed to open the document, please try again'); diff --git a/portal-frontend/src/app/shared/owner-dialogs/parcel-owners/parcel-owners.component.ts b/portal-frontend/src/app/shared/owner-dialogs/parcel-owners/parcel-owners.component.ts index 8cadb3bc21..890a56c3eb 100644 --- a/portal-frontend/src/app/shared/owner-dialogs/parcel-owners/parcel-owners.component.ts +++ b/portal-frontend/src/app/shared/owner-dialogs/parcel-owners/parcel-owners.component.ts @@ -11,6 +11,7 @@ import { NoticeOfIntentOwnerService } from '../../../services/notice-of-intent-o import { OWNER_TYPE } from '../../dto/owner.dto'; import { CrownOwnerDialogComponent } from '../crown-owner-dialog/crown-owner-dialog.component'; import { OwnerDialogComponent } from '../owner-dialog/owner-dialog.component'; +import { openFileIframe } from '../../utils/file'; @Component({ selector: 'app-parcel-owners[owners][fileId][submissionUuid][ownerService]', @@ -107,7 +108,8 @@ export class ParcelOwnersComponent { async onOpenFile(uuid: string) { const res = await this.documentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + const { fileName, url } = res; + openFileIframe(fileName || 'browser title', url); } } } diff --git a/portal-frontend/src/app/shared/utils/file.ts b/portal-frontend/src/app/shared/utils/file.ts index e13fc14fcc..a6b0debf77 100644 --- a/portal-frontend/src/app/shared/utils/file.ts +++ b/portal-frontend/src/app/shared/utils/file.ts @@ -11,3 +11,23 @@ export const openPdfFile = (fileName: string, data: any) => { } downloadLink.click(); }; + +export const openFileIframe = (fileName: string, url: string) => { + const newWindow = window.open('', '_blank'); + if (newWindow) { + newWindow.document.title = fileName; + + const iframe = newWindow.document.createElement('iframe'); + iframe.src = url; + iframe.style.borderWidth = '0'; + iframe.style.width = '100%'; + iframe.style.height = '100%'; + + newWindow.document.body.appendChild(iframe); + newWindow.document.body.style.backgroundColor = 'rgb(82, 86, 89)'; + newWindow.document.body.style.height = '100%'; + newWindow.document.body.style.width = '100%'; + newWindow.document.body.style.margin = '0'; + newWindow.document.body.style.overflow = 'hidden'; + } +}; diff --git a/services/apps/alcs/src/portal/application-document/application-document.controller.ts b/services/apps/alcs/src/portal/application-document/application-document.controller.ts index 09394a6491..fc771e6723 100644 --- a/services/apps/alcs/src/portal/application-document/application-document.controller.ts +++ b/services/apps/alcs/src/portal/application-document/application-document.controller.ts @@ -75,7 +75,9 @@ export class ApplicationDocumentController { if (canAccessDocument) { const url = await this.applicationDocumentService.getInlineUrl(document); - return { url }; + // TODO: Same thing for other document controllers + const { fileName } = document.document; + return { url, fileName }; } throw new NotFoundException('Failed to find document'); From 4ed225da495818871809b5e36f2ffa99db55ed1d Mon Sep 17 00:00:00 2001 From: Sandra To Date: Mon, 11 Mar 2024 15:15:32 -0700 Subject: [PATCH 2/2] Open all portal non-decision documents in new browser tab iframe with file name --- .../application-details.component.ts | 6 ++++-- .../cove-details/cove-details.component.ts | 5 ++++- .../excl-details/excl-details.component.ts | 5 ++++- .../incl-details/incl-details.component.ts | 5 ++++- .../naru-details/naru-details.component.ts | 5 ++++- .../nfu-details/nfu-details.component.ts | 5 ++++- .../application-details/parcel/parcel.component.ts | 4 ++-- .../pfrs-details/pfrs-details.component.ts | 5 ++++- .../pofo-details/pofo-details.component.ts | 5 ++++- .../roso-details/roso-details.component.ts | 5 ++++- .../subd-details/subd-details.component.ts | 5 ++++- .../tur-details/tur-details.component.ts | 5 ++++- .../edit-submission/files-step.partial.ts | 3 ++- .../parcel-entry/parcel-entry.component.ts | 3 ++- .../review-attachments.component.ts | 4 ++-- .../review-submit-fng/review-submit-fng.component.ts | 3 ++- .../review-submit/review-submit.component.ts | 3 ++- .../submission-documents.component.ts | 3 ++- .../lfng-review/lfng-review.component.ts | 11 ++++++----- .../view-application-submission.component.ts | 3 ++- .../edit-submission/files-step.partial.ts | 3 ++- .../parcels/parcel-entry/parcel-entry.component.ts | 3 ++- .../additional-information.component.ts | 5 ++++- .../notice-of-intent-details.component.ts | 5 ++++- .../parcel/parcel.component.ts | 3 ++- .../pfrs-details/pfrs-details.component.ts | 5 ++++- .../pofo-details/pofo-details.component.ts | 5 ++++- .../roso-details/roso-details.component.ts | 5 ++++- .../submission-documents.component.ts | 3 ++- .../edit-submission/files-step.partial.ts | 3 ++- .../notification-details.component.ts | 5 ++++- .../proposal-details/proposal-details.component.ts | 5 ++++- .../submission-documents.component.ts | 3 ++- .../alc-review/decisions/decisions.component.ts | 2 +- .../alc-review/decisions/decisions.component.ts | 4 +--- .../application-document.service.ts | 3 +-- .../notice-of-intent-document.service.ts | 3 +-- .../notification-document.service.ts | 4 +++- .../parcel-owners/parcel-owners.component.ts | 3 +-- portal-frontend/src/app/shared/utils/file.ts | 6 +++--- .../application-document.controller.spec.ts | 2 ++ .../application-document.controller.ts | 1 - .../notice-of-intent-document.controller.spec.ts | 3 ++- .../notice-of-intent-document.controller.ts | 3 ++- .../notification-document.controller.spec.ts | 5 ++++- .../notification-document.controller.ts | 3 ++- 46 files changed, 129 insertions(+), 59 deletions(-) diff --git a/portal-frontend/src/app/features/applications/application-details/application-details.component.ts b/portal-frontend/src/app/features/applications/application-details/application-details.component.ts index fb44fa59bf..5d832e1e89 100644 --- a/portal-frontend/src/app/features/applications/application-details/application-details.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/application-details.component.ts @@ -7,13 +7,13 @@ import { ApplicationOwnerDetailedDto, ApplicationOwnerDto, } from '../../../services/application-owner/application-owner.dto'; -import { PARCEL_OWNERSHIP_TYPE } from '../../../services/application-parcel/application-parcel.dto'; import { ApplicationParcelService } from '../../../services/application-parcel/application-parcel.service'; import { ApplicationSubmissionDetailedDto } from '../../../services/application-submission/application-submission.dto'; import { LocalGovernmentDto } from '../../../services/code/code.dto'; import { CodeService } from '../../../services/code/code.service'; import { DOCUMENT_SOURCE, DOCUMENT_TYPE } from '../../../shared/dto/document.dto'; import { OWNER_TYPE } from '../../../shared/dto/owner.dto'; +import { openFileIframe } from '../../../shared/utils/file'; @Component({ selector: 'app-application-details', @@ -85,7 +85,9 @@ export class ApplicationDetailsComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } async onNavigateToStep(step: number) { diff --git a/portal-frontend/src/app/features/applications/application-details/cove-details/cove-details.component.ts b/portal-frontend/src/app/features/applications/application-details/cove-details/cove-details.component.ts index c53b94252c..26eb309cfc 100644 --- a/portal-frontend/src/app/features/applications/application-details/cove-details/cove-details.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/cove-details/cove-details.component.ts @@ -6,6 +6,7 @@ import { ApplicationSubmissionDetailedDto } from '../../../../services/applicati import { CovenantTransfereeDto } from '../../../../services/covenant-transferee/covenant-transferee.dto'; import { CovenantTransfereeService } from '../../../../services/covenant-transferee/covenant-transferee.service'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-cove-details', @@ -53,7 +54,9 @@ export class CoveDetailsComponent { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } private async loadTransferees(uuid: string) { diff --git a/portal-frontend/src/app/features/applications/application-details/excl-details/excl-details.component.ts b/portal-frontend/src/app/features/applications/application-details/excl-details/excl-details.component.ts index 3ca125515e..ccae72c74b 100644 --- a/portal-frontend/src/app/features/applications/application-details/excl-details/excl-details.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/excl-details/excl-details.component.ts @@ -4,6 +4,7 @@ import { ApplicationDocumentService } from '../../../../services/application-doc import { ApplicationSubmissionDetailedDto } from '../../../../services/application-submission/application-submission.dto'; import { ApplicationDocumentDto } from '../../../../services/application-document/application-document.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-excl-details', @@ -53,6 +54,8 @@ export class ExclDetailsComponent { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/applications/application-details/incl-details/incl-details.component.ts b/portal-frontend/src/app/features/applications/application-details/incl-details/incl-details.component.ts index b303ec6af8..cda17dbd0d 100644 --- a/portal-frontend/src/app/features/applications/application-details/incl-details/incl-details.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/incl-details/incl-details.component.ts @@ -6,6 +6,7 @@ import { ApplicationSubmissionDetailedDto } from '../../../../services/applicati import { ApplicationDocumentDto } from '../../../../services/application-document/application-document.dto'; import { AuthenticationService } from '../../../../services/authentication/authentication.service'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-incl-details', @@ -73,7 +74,9 @@ export class InclDetailsComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } ngOnDestroy(): void { diff --git a/portal-frontend/src/app/features/applications/application-details/naru-details/naru-details.component.ts b/portal-frontend/src/app/features/applications/application-details/naru-details/naru-details.component.ts index 104949081f..fc5e952eb0 100644 --- a/portal-frontend/src/app/features/applications/application-details/naru-details/naru-details.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/naru-details/naru-details.component.ts @@ -4,6 +4,7 @@ import { ApplicationDocumentDto } from '../../../../services/application-documen import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service'; import { ApplicationSubmissionDetailedDto } from '../../../../services/application-submission/application-submission.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-naru-details[applicationSubmission]', @@ -43,6 +44,8 @@ export class NaruDetailsComponent { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/applications/application-details/nfu-details/nfu-details.component.ts b/portal-frontend/src/app/features/applications/application-details/nfu-details/nfu-details.component.ts index 8284bf74e9..4e9fdd0233 100644 --- a/portal-frontend/src/app/features/applications/application-details/nfu-details/nfu-details.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/nfu-details/nfu-details.component.ts @@ -4,6 +4,7 @@ import { ApplicationDocumentDto } from '../../../../services/application-documen import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service'; import { ApplicationSubmissionDetailedDto } from '../../../../services/application-submission/application-submission.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-nfu-details[applicationSubmission]', @@ -35,6 +36,8 @@ export class NfuDetailsComponent { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/applications/application-details/parcel/parcel.component.ts b/portal-frontend/src/app/features/applications/application-details/parcel/parcel.component.ts index af04c7693d..a588acd793 100644 --- a/portal-frontend/src/app/features/applications/application-details/parcel/parcel.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/parcel/parcel.component.ts @@ -4,7 +4,6 @@ import { BehaviorSubject, Subject, takeUntil } from 'rxjs'; import { ApplicationDocumentDto } from '../../../../services/application-document/application-document.dto'; import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service'; import { ApplicationOwnerDto } from '../../../../services/application-owner/application-owner.dto'; -import { ApplicationOwnerService } from '../../../../services/application-owner/application-owner.service'; import { ApplicationParcelDto, ApplicationParcelUpdateDto, @@ -14,6 +13,7 @@ import { ApplicationParcelService } from '../../../../services/application-parce import { ApplicationSubmissionDetailedDto } from '../../../../services/application-submission/application-submission.dto'; import { BaseCodeDto } from '../../../../shared/dto/base.dto'; import { formatBooleanToYesNoString } from '../../../../shared/utils/boolean-helper'; +import { openFileIframe } from '../../../../shared/utils/file'; export class ApplicationParcelBasicValidation { // indicates general validity check state, including owner related information @@ -101,7 +101,7 @@ export class ParcelComponent { async onOpenFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/applications/application-details/pfrs-details/pfrs-details.component.ts b/portal-frontend/src/app/features/applications/application-details/pfrs-details/pfrs-details.component.ts index f60af81230..9cc2770c6d 100644 --- a/portal-frontend/src/app/features/applications/application-details/pfrs-details/pfrs-details.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/pfrs-details/pfrs-details.component.ts @@ -4,6 +4,7 @@ import { ApplicationDocumentDto } from '../../../../services/application-documen import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service'; import { ApplicationSubmissionDetailedDto } from '../../../../services/application-submission/application-submission.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-pfrs-details[applicationSubmission]', @@ -49,6 +50,8 @@ export class PfrsDetailsComponent { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/applications/application-details/pofo-details/pofo-details.component.ts b/portal-frontend/src/app/features/applications/application-details/pofo-details/pofo-details.component.ts index 9e2c20112c..274f2ad0fe 100644 --- a/portal-frontend/src/app/features/applications/application-details/pofo-details/pofo-details.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/pofo-details/pofo-details.component.ts @@ -4,6 +4,7 @@ import { ApplicationDocumentDto } from '../../../../services/application-documen import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service'; import { ApplicationSubmissionDetailedDto } from '../../../../services/application-submission/application-submission.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-pofo-details[applicationSubmission]', @@ -47,6 +48,8 @@ export class PofoDetailsComponent { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/applications/application-details/roso-details/roso-details.component.ts b/portal-frontend/src/app/features/applications/application-details/roso-details/roso-details.component.ts index f543cfddf2..209bf3f994 100644 --- a/portal-frontend/src/app/features/applications/application-details/roso-details/roso-details.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/roso-details/roso-details.component.ts @@ -4,6 +4,7 @@ import { ApplicationDocumentDto } from '../../../../services/application-documen import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service'; import { ApplicationSubmissionDetailedDto } from '../../../../services/application-submission/application-submission.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-roso-details[applicationSubmission]', @@ -47,6 +48,8 @@ export class RosoDetailsComponent { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/applications/application-details/subd-details/subd-details.component.ts b/portal-frontend/src/app/features/applications/application-details/subd-details/subd-details.component.ts index 62703a504e..9718f187ff 100644 --- a/portal-frontend/src/app/features/applications/application-details/subd-details/subd-details.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/subd-details/subd-details.component.ts @@ -5,6 +5,7 @@ import { ApplicationDocumentService } from '../../../../services/application-doc import { ApplicationParcelService } from '../../../../services/application-parcel/application-parcel.service'; import { ApplicationSubmissionDetailedDto } from '../../../../services/application-submission/application-submission.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-subd-details[applicationSubmission]', @@ -57,7 +58,9 @@ export class SubdDetailsComponent { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } private async loadParcels(fileNumber: string) { diff --git a/portal-frontend/src/app/features/applications/application-details/tur-details/tur-details.component.ts b/portal-frontend/src/app/features/applications/application-details/tur-details/tur-details.component.ts index 229dab9f16..5f96e46a8e 100644 --- a/portal-frontend/src/app/features/applications/application-details/tur-details/tur-details.component.ts +++ b/portal-frontend/src/app/features/applications/application-details/tur-details/tur-details.component.ts @@ -4,6 +4,7 @@ import { ApplicationDocumentDto } from '../../../../services/application-documen import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service'; import { ApplicationSubmissionDetailedDto } from '../../../../services/application-submission/application-submission.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-tur-details[applicationSubmission]', @@ -44,6 +45,8 @@ export class TurDetailsComponent { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/applications/edit-submission/files-step.partial.ts b/portal-frontend/src/app/features/applications/edit-submission/files-step.partial.ts index 47f65a2227..6f26e899ba 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/files-step.partial.ts +++ b/portal-frontend/src/app/features/applications/edit-submission/files-step.partial.ts @@ -9,6 +9,7 @@ import { DOCUMENT_TYPE } from '../../../shared/dto/document.dto'; import { FileHandle } from '../../../shared/file-drag-drop/drag-drop.directive'; import { RemoveFileConfirmationDialogComponent } from '../alcs-edit-submission/remove-file-confirmation-dialog/remove-file-confirmation-dialog.component'; import { StepComponent } from './step.partial'; +import { openFileIframe } from '../../../shared/utils/file'; @Component({ selector: 'app-file-step', @@ -85,7 +86,7 @@ export abstract class FilesStepComponent extends StepComponent { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } } diff --git a/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.ts b/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.ts index 3620251972..0842b8d691 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.ts +++ b/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.ts @@ -21,6 +21,7 @@ import { OwnerDialogComponent } from '../../../../../shared/owner-dialogs/owner- import { formatBooleanToString } from '../../../../../shared/utils/boolean-helper'; import { RemoveFileConfirmationDialogComponent } from '../../../alcs-edit-submission/remove-file-confirmation-dialog/remove-file-confirmation-dialog.component'; import { ParcelEntryConfirmationDialogComponent } from './parcel-entry-confirmation-dialog/parcel-entry-confirmation-dialog.component'; +import { openFileIframe } from '../../../../../shared/utils/file'; export interface ParcelEntryFormData { uuid: string; @@ -345,7 +346,7 @@ export class ParcelEntryComponent implements OnInit { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/applications/review-submission/review-attachments/review-attachments.component.ts b/portal-frontend/src/app/features/applications/review-submission/review-attachments/review-attachments.component.ts index 86777d905d..9738bc07bd 100644 --- a/portal-frontend/src/app/features/applications/review-submission/review-attachments/review-attachments.component.ts +++ b/portal-frontend/src/app/features/applications/review-submission/review-attachments/review-attachments.component.ts @@ -1,5 +1,4 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; -import { Router } from '@angular/router'; import { BehaviorSubject, Subject, takeUntil } from 'rxjs'; import { ApplicationDocumentDto } from '../../../../services/application-document/application-document.dto'; import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service'; @@ -8,6 +7,7 @@ import { ToastService } from '../../../../services/toast/toast.service'; import { DOCUMENT_SOURCE, DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; import { FileHandle } from '../../../../shared/file-drag-drop/drag-drop.directive'; import { ReviewApplicationFngSteps, ReviewApplicationSteps } from '../review-submission.component'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-review-attachments', @@ -128,7 +128,7 @@ export class ReviewAttachmentsComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/applications/review-submission/review-submit-fng/review-submit-fng.component.ts b/portal-frontend/src/app/features/applications/review-submission/review-submit-fng/review-submit-fng.component.ts index 43544526ec..d151847d50 100644 --- a/portal-frontend/src/app/features/applications/review-submission/review-submit-fng/review-submit-fng.component.ts +++ b/portal-frontend/src/app/features/applications/review-submission/review-submit-fng/review-submit-fng.component.ts @@ -16,6 +16,7 @@ import { MOBILE_BREAKPOINT } from '../../../../shared/utils/breakpoints'; import { ReviewApplicationFngSteps } from '../review-submission.component'; import { ToastService } from '../../../../services/toast/toast.service'; import { SubmitConfirmationDialogComponent } from '../submit-confirmation-dialog/submit-confirmation-dialog.component'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-review-submit-fng[stepper]', @@ -123,7 +124,7 @@ export class ReviewSubmitFngComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/applications/review-submission/review-submit/review-submit.component.ts b/portal-frontend/src/app/features/applications/review-submission/review-submit/review-submit.component.ts index 971eeb4943..36cb5a6718 100644 --- a/portal-frontend/src/app/features/applications/review-submission/review-submit/review-submit.component.ts +++ b/portal-frontend/src/app/features/applications/review-submission/review-submit/review-submit.component.ts @@ -15,6 +15,7 @@ import { DOCUMENT_SOURCE, DOCUMENT_TYPE } from '../../../../shared/dto/document. import { MOBILE_BREAKPOINT } from '../../../../shared/utils/breakpoints'; import { ReviewApplicationSteps } from '../review-submission.component'; import { SubmitConfirmationDialogComponent } from '../submit-confirmation-dialog/submit-confirmation-dialog.component'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-review-submit[stepper]', @@ -131,7 +132,7 @@ export class ReviewSubmitComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/applications/view-submission/alc-review/submission-documents/submission-documents.component.ts b/portal-frontend/src/app/features/applications/view-submission/alc-review/submission-documents/submission-documents.component.ts index 787f560c25..679fb8aa43 100644 --- a/portal-frontend/src/app/features/applications/view-submission/alc-review/submission-documents/submission-documents.component.ts +++ b/portal-frontend/src/app/features/applications/view-submission/alc-review/submission-documents/submission-documents.component.ts @@ -4,6 +4,7 @@ import { MatTableDataSource } from '@angular/material/table'; import { BehaviorSubject, Subject, takeUntil } from 'rxjs'; import { ApplicationDocumentDto } from '../../../../../services/application-document/application-document.dto'; import { ApplicationDocumentService } from '../../../../../services/application-document/application-document.service'; +import { openFileIframe } from '../../../../../shared/utils/file'; @Component({ selector: 'app-submission-documents', @@ -32,7 +33,7 @@ export class SubmissionDocumentsComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/applications/view-submission/lfng-review/lfng-review.component.ts b/portal-frontend/src/app/features/applications/view-submission/lfng-review/lfng-review.component.ts index a7b09050cb..ac6a36d33f 100644 --- a/portal-frontend/src/app/features/applications/view-submission/lfng-review/lfng-review.component.ts +++ b/portal-frontend/src/app/features/applications/view-submission/lfng-review/lfng-review.component.ts @@ -11,6 +11,7 @@ import { } from '../../../../services/application-submission/application-submission.dto'; import { PdfGenerationService } from '../../../../services/pdf-generation/pdf-generation.service'; import { DOCUMENT_SOURCE, DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-lfng-review', @@ -40,7 +41,7 @@ export class LfngReviewComponent implements OnInit, OnDestroy { private applicationReviewService: ApplicationSubmissionReviewService, private pdfGenerationService: PdfGenerationService, private applicationDocumentService: ApplicationDocumentService, - private router: Router, + private router: Router ) {} ngOnInit(): void { @@ -69,7 +70,7 @@ export class LfngReviewComponent implements OnInit, OnDestroy { this.$application.pipe(takeUntil(this.$destroy)).subscribe((application) => { this.application = application; this.submittedToAlcStatus = !!this.application?.submissionStatuses.find( - (s) => s.statusTypeCode === SUBMISSION_STATUS.SUBMITTED_TO_ALC && !!s.effectiveDate, + (s) => s.statusTypeCode === SUBMISSION_STATUS.SUBMITTED_TO_ALC && !!s.effectiveDate ); this.isTurOrCov = this.application?.typeCode === 'COVE' || this.application?.typeCode === 'TURP'; this.loadReview(); @@ -78,10 +79,10 @@ export class LfngReviewComponent implements OnInit, OnDestroy { this.$applicationDocuments.subscribe((documents) => { this.staffReport = documents.filter((document) => document.type?.code === DOCUMENT_TYPE.STAFF_REPORT); this.resolutionDocument = documents.filter( - (document) => document.type?.code === DOCUMENT_TYPE.RESOLUTION_DOCUMENT, + (document) => document.type?.code === DOCUMENT_TYPE.RESOLUTION_DOCUMENT ); this.governmentOtherAttachments = documents.filter( - (document) => document.type?.code === DOCUMENT_TYPE.OTHER && document.source === DOCUMENT_SOURCE.LFNG, + (document) => document.type?.code === DOCUMENT_TYPE.OTHER && document.source === DOCUMENT_SOURCE.LFNG ); }); } @@ -109,7 +110,7 @@ export class LfngReviewComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/applications/view-submission/view-application-submission.component.ts b/portal-frontend/src/app/features/applications/view-submission/view-application-submission.component.ts index 0d214beaf0..a08e1fcaf1 100644 --- a/portal-frontend/src/app/features/applications/view-submission/view-application-submission.component.ts +++ b/portal-frontend/src/app/features/applications/view-submission/view-application-submission.component.ts @@ -12,6 +12,7 @@ import { import { ApplicationSubmissionService } from '../../../services/application-submission/application-submission.service'; import { PdfGenerationService } from '../../../services/pdf-generation/pdf-generation.service'; import { ConfirmationDialogService } from '../../../shared/confirmation-dialog/confirmation-dialog.service'; +import { openFileIframe } from '../../../shared/utils/file'; @Component({ selector: 'app-view-application-submission', @@ -96,7 +97,7 @@ export class ViewApplicationSubmissionComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.applicationDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/notice-of-intents/edit-submission/files-step.partial.ts b/portal-frontend/src/app/features/notice-of-intents/edit-submission/files-step.partial.ts index e177bdf537..a407e19b5a 100644 --- a/portal-frontend/src/app/features/notice-of-intents/edit-submission/files-step.partial.ts +++ b/portal-frontend/src/app/features/notice-of-intents/edit-submission/files-step.partial.ts @@ -9,6 +9,7 @@ import { DOCUMENT_TYPE } from '../../../shared/dto/document.dto'; import { FileHandle } from '../../../shared/file-drag-drop/drag-drop.directive'; import { RemoveFileConfirmationDialogComponent } from '../../applications/alcs-edit-submission/remove-file-confirmation-dialog/remove-file-confirmation-dialog.component'; import { StepComponent } from './step.partial'; +import { openFileIframe } from '../../../shared/utils/file'; @Component({ selector: 'app-file-step', @@ -85,7 +86,7 @@ export abstract class FilesStepComponent extends StepComponent { async openFile(uuid: string) { const res = await this.noticeOfIntentDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } } diff --git a/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.ts b/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.ts index ad45e840e0..bcbbe6636d 100644 --- a/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.ts +++ b/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.ts @@ -20,6 +20,7 @@ import { formatBooleanToString } from '../../../../../shared/utils/boolean-helpe import { RemoveFileConfirmationDialogComponent } from '../../../../applications/alcs-edit-submission/remove-file-confirmation-dialog/remove-file-confirmation-dialog.component'; import { ParcelEntryConfirmationDialogComponent } from './parcel-entry-confirmation-dialog/parcel-entry-confirmation-dialog.component'; import { scrollToElement } from '../../../../../shared/utils/scroll-helper'; +import { openFileIframe } from '../../../../../shared/utils/file'; export interface ParcelEntryFormData { uuid: string; @@ -343,7 +344,7 @@ export class ParcelEntryComponent implements OnInit { async openFile(uuid: string) { const res = await this.noticeOfIntentDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/additional-information/additional-information.component.ts b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/additional-information/additional-information.component.ts index 680cd87210..f0f313b4b6 100644 --- a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/additional-information/additional-information.component.ts +++ b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/additional-information/additional-information.component.ts @@ -8,6 +8,7 @@ import { RESIDENTIAL_STRUCTURE_TYPES, STRUCTURE_TYPES, } from '../../edit-submission/additional-information/additional-information.component'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-additional-information', @@ -101,6 +102,8 @@ export class AdditionalInformationComponent { async openFile(uuid: string) { const res = await this.noticeOfIntentDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/notice-of-intent-details.component.ts b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/notice-of-intent-details.component.ts index dc207c8289..ccf3768864 100644 --- a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/notice-of-intent-details.component.ts +++ b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/notice-of-intent-details.component.ts @@ -10,6 +10,7 @@ import { NoticeOfIntentParcelService } from '../../../services/notice-of-intent- import { NoticeOfIntentSubmissionDetailedDto } from '../../../services/notice-of-intent-submission/notice-of-intent-submission.dto'; import { DOCUMENT_SOURCE, DOCUMENT_TYPE } from '../../../shared/dto/document.dto'; import { OWNER_TYPE } from '../../../shared/dto/owner.dto'; +import { openFileIframe } from '../../../shared/utils/file'; @Component({ selector: 'app-noi-details', @@ -83,7 +84,9 @@ export class NoticeOfIntentDetailsComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.noticeOfIntentDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } async onNavigateToStep(step: number) { diff --git a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/parcel/parcel.component.ts b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/parcel/parcel.component.ts index accce22e7d..aa4fa84fd4 100644 --- a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/parcel/parcel.component.ts +++ b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/parcel/parcel.component.ts @@ -14,6 +14,7 @@ import { NoticeOfIntentParcelService } from '../../../../services/notice-of-inte import { NoticeOfIntentSubmissionDetailedDto } from '../../../../services/notice-of-intent-submission/notice-of-intent-submission.dto'; import { BaseCodeDto } from '../../../../shared/dto/base.dto'; import { formatBooleanToYesNoString } from '../../../../shared/utils/boolean-helper'; +import { openFileIframe } from '../../../../shared/utils/file'; export class NoticeOfIntentParcelBasicValidation { // indicates general validity check state, including owner related information @@ -99,7 +100,7 @@ export class ParcelComponent { async onOpenFile(uuid: string) { const res = await this.noticeOfIntentDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/pfrs-details/pfrs-details.component.ts b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/pfrs-details/pfrs-details.component.ts index d4bf554748..1729791499 100644 --- a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/pfrs-details/pfrs-details.component.ts +++ b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/pfrs-details/pfrs-details.component.ts @@ -4,6 +4,7 @@ import { NoticeOfIntentDocumentDto } from '../../../../services/notice-of-intent import { NoticeOfIntentDocumentService } from '../../../../services/notice-of-intent-document/notice-of-intent-document.service'; import { NoticeOfIntentSubmissionDetailedDto } from '../../../../services/notice-of-intent-submission/notice-of-intent-submission.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-pfrs-details[noiSubmission]', @@ -49,6 +50,8 @@ export class PfrsDetailsComponent { async openFile(uuid: string) { const res = await this.noticeOfIntentDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/pofo-details/pofo-details.component.ts b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/pofo-details/pofo-details.component.ts index 115a9bcaeb..bda8999026 100644 --- a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/pofo-details/pofo-details.component.ts +++ b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/pofo-details/pofo-details.component.ts @@ -4,6 +4,7 @@ import { NoticeOfIntentDocumentDto } from '../../../../services/notice-of-intent import { NoticeOfIntentDocumentService } from '../../../../services/notice-of-intent-document/notice-of-intent-document.service'; import { NoticeOfIntentSubmissionDetailedDto } from '../../../../services/notice-of-intent-submission/notice-of-intent-submission.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-pofo-details[noiSubmission]', @@ -49,6 +50,8 @@ export class PofoDetailsComponent { async openFile(uuid: string) { const res = await this.noticeOfIntentDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/roso-details/roso-details.component.ts b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/roso-details/roso-details.component.ts index 4b352feab2..4edd97841c 100644 --- a/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/roso-details/roso-details.component.ts +++ b/portal-frontend/src/app/features/notice-of-intents/notice-of-intent-details/roso-details/roso-details.component.ts @@ -4,6 +4,7 @@ import { NoticeOfIntentDocumentDto } from '../../../../services/notice-of-intent import { NoticeOfIntentDocumentService } from '../../../../services/notice-of-intent-document/notice-of-intent-document.service'; import { NoticeOfIntentSubmissionDetailedDto } from '../../../../services/notice-of-intent-submission/notice-of-intent-submission.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-roso-details[noiSubmission]', @@ -49,6 +50,8 @@ export class RosoDetailsComponent { async openFile(uuid: string) { const res = await this.noticeOfIntentDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/notice-of-intents/view-submission/alc-review/submission-documents/submission-documents.component.ts b/portal-frontend/src/app/features/notice-of-intents/view-submission/alc-review/submission-documents/submission-documents.component.ts index 382a65b85a..0fb70ef5e1 100644 --- a/portal-frontend/src/app/features/notice-of-intents/view-submission/alc-review/submission-documents/submission-documents.component.ts +++ b/portal-frontend/src/app/features/notice-of-intents/view-submission/alc-review/submission-documents/submission-documents.component.ts @@ -4,6 +4,7 @@ import { MatTableDataSource } from '@angular/material/table'; import { BehaviorSubject, Subject, takeUntil } from 'rxjs'; import { NoticeOfIntentDocumentDto } from '../../../../../services/notice-of-intent-document/notice-of-intent-document.dto'; import { NoticeOfIntentDocumentService } from '../../../../../services/notice-of-intent-document/notice-of-intent-document.service'; +import { openFileIframe } from '../../../../../shared/utils/file'; @Component({ selector: 'app-submission-documents', @@ -32,7 +33,7 @@ export class SubmissionDocumentsComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.noticeOfIntentDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/notifications/edit-submission/files-step.partial.ts b/portal-frontend/src/app/features/notifications/edit-submission/files-step.partial.ts index 2a1fcd1328..817b3a513f 100644 --- a/portal-frontend/src/app/features/notifications/edit-submission/files-step.partial.ts +++ b/portal-frontend/src/app/features/notifications/edit-submission/files-step.partial.ts @@ -9,6 +9,7 @@ import { ToastService } from '../../../services/toast/toast.service'; import { DOCUMENT_TYPE } from '../../../shared/dto/document.dto'; import { FileHandle } from '../../../shared/file-drag-drop/drag-drop.directive'; import { StepComponent } from './step.partial'; +import { openFileIframe } from '../../../shared/utils/file'; @Component({ selector: 'app-file-step', @@ -71,7 +72,7 @@ export abstract class FilesStepComponent extends StepComponent { async openFile(uuid: string) { const res = await this.notificationDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } } diff --git a/portal-frontend/src/app/features/notifications/notification-details/notification-details.component.ts b/portal-frontend/src/app/features/notifications/notification-details/notification-details.component.ts index f21c0a467d..75155e4402 100644 --- a/portal-frontend/src/app/features/notifications/notification-details/notification-details.component.ts +++ b/portal-frontend/src/app/features/notifications/notification-details/notification-details.component.ts @@ -8,6 +8,7 @@ import { NotificationDocumentService } from '../../../services/notification-docu import { NotificationSubmissionDetailedDto } from '../../../services/notification-submission/notification-submission.dto'; import { DOCUMENT_SOURCE, DOCUMENT_TYPE } from '../../../shared/dto/document.dto'; import { OWNER_TYPE } from '../../../shared/dto/owner.dto'; +import { openFileIframe } from '../../../shared/utils/file'; @Component({ selector: 'app-notification-details', @@ -65,7 +66,9 @@ export class NotificationDetailsComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.notificationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } async onNavigateToStep(step: number) { diff --git a/portal-frontend/src/app/features/notifications/notification-details/proposal-details/proposal-details.component.ts b/portal-frontend/src/app/features/notifications/notification-details/proposal-details/proposal-details.component.ts index 457e1cf731..348c6a7024 100644 --- a/portal-frontend/src/app/features/notifications/notification-details/proposal-details/proposal-details.component.ts +++ b/portal-frontend/src/app/features/notifications/notification-details/proposal-details/proposal-details.component.ts @@ -4,6 +4,7 @@ import { NotificationDocumentDto } from '../../../../services/notification-docum import { NotificationDocumentService } from '../../../../services/notification-document/notification-document.service'; import { NotificationSubmissionDetailedDto } from '../../../../services/notification-submission/notification-submission.dto'; import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto'; +import { openFileIframe } from '../../../../shared/utils/file'; @Component({ selector: 'app-proposal-details[notificationSubmission]', @@ -38,6 +39,8 @@ export class ProposalDetailsComponent { async openFile(uuid: string) { const res = await this.notificationDocumentService.openFile(uuid); - window.open(res?.url, '_blank'); + if (res) { + openFileIframe(res); + } } } diff --git a/portal-frontend/src/app/features/notifications/view-submission/alc-review/submission-documents/submission-documents.component.ts b/portal-frontend/src/app/features/notifications/view-submission/alc-review/submission-documents/submission-documents.component.ts index 2088483b40..505cf75369 100644 --- a/portal-frontend/src/app/features/notifications/view-submission/alc-review/submission-documents/submission-documents.component.ts +++ b/portal-frontend/src/app/features/notifications/view-submission/alc-review/submission-documents/submission-documents.component.ts @@ -4,6 +4,7 @@ import { MatTableDataSource } from '@angular/material/table'; import { BehaviorSubject, Subject, takeUntil } from 'rxjs'; import { NotificationDocumentDto } from '../../../../../services/notification-document/notification-document.dto'; import { NotificationDocumentService } from '../../../../../services/notification-document/notification-document.service'; +import { openFileIframe } from '../../../../../shared/utils/file'; @Component({ selector: 'app-submission-documents', @@ -32,7 +33,7 @@ export class SubmissionDocumentsComponent implements OnInit, OnDestroy { async openFile(uuid: string) { const res = await this.notificationDocumentService.openFile(uuid); if (res) { - window.open(res.url, '_blank'); + openFileIframe(res); } } diff --git a/portal-frontend/src/app/features/public/application/alc-review/decisions/decisions.component.ts b/portal-frontend/src/app/features/public/application/alc-review/decisions/decisions.component.ts index ebf506417a..2210cea9c3 100644 --- a/portal-frontend/src/app/features/public/application/alc-review/decisions/decisions.component.ts +++ b/portal-frontend/src/app/features/public/application/alc-review/decisions/decisions.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { ApplicationPortalDecisionDto } from '../../../../../services/application-decision/application-decision.dto'; import { ApplicationDecisionService } from '../../../../../services/application-decision/application-decision.service'; diff --git a/portal-frontend/src/app/features/public/notice-of-intent/alc-review/decisions/decisions.component.ts b/portal-frontend/src/app/features/public/notice-of-intent/alc-review/decisions/decisions.component.ts index a8b190adcd..32abf6af5e 100644 --- a/portal-frontend/src/app/features/public/notice-of-intent/alc-review/decisions/decisions.component.ts +++ b/portal-frontend/src/app/features/public/notice-of-intent/alc-review/decisions/decisions.component.ts @@ -1,6 +1,4 @@ -import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; -import { ApplicationPortalDecisionDto } from '../../../../../services/application-decision/application-decision.dto'; -import { ApplicationDecisionService } from '../../../../../services/application-decision/application-decision.service'; +import { Component, Input } from '@angular/core'; import { NoticeOfIntentPortalDecisionDto } from '../../../../../services/notice-of-intent-decision/notice-of-intent-decision.dto'; import { NoticeOfIntentDecisionService } from '../../../../../services/notice-of-intent-decision/notice-of-intent-decision.service'; diff --git a/portal-frontend/src/app/services/application-document/application-document.service.ts b/portal-frontend/src/app/services/application-document/application-document.service.ts index d908451237..e5dd88c9ae 100644 --- a/portal-frontend/src/app/services/application-document/application-document.service.ts +++ b/portal-frontend/src/app/services/application-document/application-document.service.ts @@ -52,8 +52,7 @@ export class ApplicationDocumentService { async openFile(fileUuid: string) { try { return await firstValueFrom( - // TODO: Make fileName mandatory when ready to update all other usage - this.httpClient.get<{ url: string; fileName?: string }>(`${this.serviceUrl}/${fileUuid}/open`) + this.httpClient.get<{ url: string; fileName: string }>(`${this.serviceUrl}/${fileUuid}/open`) ); } catch (e) { console.error(e); diff --git a/portal-frontend/src/app/services/notice-of-intent-document/notice-of-intent-document.service.ts b/portal-frontend/src/app/services/notice-of-intent-document/notice-of-intent-document.service.ts index a4e466f5ed..1860044eb3 100644 --- a/portal-frontend/src/app/services/notice-of-intent-document/notice-of-intent-document.service.ts +++ b/portal-frontend/src/app/services/notice-of-intent-document/notice-of-intent-document.service.ts @@ -52,8 +52,7 @@ export class NoticeOfIntentDocumentService { async openFile(fileUuid: string) { try { return await firstValueFrom( - // TODO: Make fileName mandatory when ready to update all other usage - this.httpClient.get<{ url: string; fileName?: string }>(`${this.serviceUrl}/${fileUuid}/open`) + this.httpClient.get<{ url: string; fileName: string }>(`${this.serviceUrl}/${fileUuid}/open`) ); } catch (e) { console.error(e); diff --git a/portal-frontend/src/app/services/notification-document/notification-document.service.ts b/portal-frontend/src/app/services/notification-document/notification-document.service.ts index 698ecbae19..e94af3b6d5 100644 --- a/portal-frontend/src/app/services/notification-document/notification-document.service.ts +++ b/portal-frontend/src/app/services/notification-document/notification-document.service.ts @@ -51,7 +51,9 @@ export class NotificationDocumentService { async openFile(fileUuid: string) { try { - return await firstValueFrom(this.httpClient.get<{ url: string }>(`${this.serviceUrl}/${fileUuid}/open`)); + return await firstValueFrom( + this.httpClient.get<{ url: string; fileName: string }>(`${this.serviceUrl}/${fileUuid}/open`) + ); } catch (e) { console.error(e); this.toastService.showErrorToast('Failed to open the document, please try again'); diff --git a/portal-frontend/src/app/shared/owner-dialogs/parcel-owners/parcel-owners.component.ts b/portal-frontend/src/app/shared/owner-dialogs/parcel-owners/parcel-owners.component.ts index 890a56c3eb..bddf22ec3c 100644 --- a/portal-frontend/src/app/shared/owner-dialogs/parcel-owners/parcel-owners.component.ts +++ b/portal-frontend/src/app/shared/owner-dialogs/parcel-owners/parcel-owners.component.ts @@ -108,8 +108,7 @@ export class ParcelOwnersComponent { async onOpenFile(uuid: string) { const res = await this.documentService.openFile(uuid); if (res) { - const { fileName, url } = res; - openFileIframe(fileName || 'browser title', url); + openFileIframe(res); } } } diff --git a/portal-frontend/src/app/shared/utils/file.ts b/portal-frontend/src/app/shared/utils/file.ts index a6b0debf77..45754c0265 100644 --- a/portal-frontend/src/app/shared/utils/file.ts +++ b/portal-frontend/src/app/shared/utils/file.ts @@ -12,13 +12,13 @@ export const openPdfFile = (fileName: string, data: any) => { downloadLink.click(); }; -export const openFileIframe = (fileName: string, url: string) => { +export const openFileIframe = (data: { url: string; fileName: string }) => { const newWindow = window.open('', '_blank'); if (newWindow) { - newWindow.document.title = fileName; + newWindow.document.title = data.fileName; const iframe = newWindow.document.createElement('iframe'); - iframe.src = url; + iframe.src = data.url; iframe.style.borderWidth = '0'; iframe.style.width = '100%'; iframe.style.height = '100%'; diff --git a/services/apps/alcs/src/portal/application-document/application-document.controller.spec.ts b/services/apps/alcs/src/portal/application-document/application-document.controller.spec.ts index e197636f0d..420e84cfda 100644 --- a/services/apps/alcs/src/portal/application-document/application-document.controller.spec.ts +++ b/services/apps/alcs/src/portal/application-document/application-document.controller.spec.ts @@ -136,7 +136,9 @@ describe('ApplicationDocumentController', () => { }, }); + expect(appDocumentService.getInlineUrl).toHaveBeenCalledTimes(1); expect(res.url).toEqual(fakeUrl); + expect(res.fileName).toEqual(mockDocument.document.fileName); }); it('should call through for download', async () => { diff --git a/services/apps/alcs/src/portal/application-document/application-document.controller.ts b/services/apps/alcs/src/portal/application-document/application-document.controller.ts index fc771e6723..821fde6f82 100644 --- a/services/apps/alcs/src/portal/application-document/application-document.controller.ts +++ b/services/apps/alcs/src/portal/application-document/application-document.controller.ts @@ -75,7 +75,6 @@ export class ApplicationDocumentController { if (canAccessDocument) { const url = await this.applicationDocumentService.getInlineUrl(document); - // TODO: Same thing for other document controllers const { fileName } = document.document; return { url, fileName }; } diff --git a/services/apps/alcs/src/portal/notice-of-intent-document/notice-of-intent-document.controller.spec.ts b/services/apps/alcs/src/portal/notice-of-intent-document/notice-of-intent-document.controller.spec.ts index c3efe743c9..73c73b9c39 100644 --- a/services/apps/alcs/src/portal/notice-of-intent-document/notice-of-intent-document.controller.spec.ts +++ b/services/apps/alcs/src/portal/notice-of-intent-document/notice-of-intent-document.controller.spec.ts @@ -120,8 +120,9 @@ describe('NoticeOfIntentDocumentController', () => { const res = await controller.open('fake-uuid', mockRequest); - expect(res.url).toEqual(fakeUrl); expect(noiDocumentService.getInlineUrl).toHaveBeenCalledTimes(1); + expect(res.url).toEqual(fakeUrl); + expect(res.fileName).toEqual(mockDocument.document.fileName); }); it('should call through for download', async () => { diff --git a/services/apps/alcs/src/portal/notice-of-intent-document/notice-of-intent-document.controller.ts b/services/apps/alcs/src/portal/notice-of-intent-document/notice-of-intent-document.controller.ts index 4c287b96a2..5ccfe49ff8 100644 --- a/services/apps/alcs/src/portal/notice-of-intent-document/notice-of-intent-document.controller.ts +++ b/services/apps/alcs/src/portal/notice-of-intent-document/notice-of-intent-document.controller.ts @@ -80,7 +80,8 @@ export class NoticeOfIntentDocumentController { if (canAccessDocument) { const url = await this.noticeOfIntentDocumentService.getInlineUrl(document); - return { url }; + const { fileName } = document.document; + return { url, fileName }; } throw new NotFoundException('Failed to find document'); diff --git a/services/apps/alcs/src/portal/notification-document/notification-document.controller.spec.ts b/services/apps/alcs/src/portal/notification-document/notification-document.controller.spec.ts index 2afbe33066..88891e0ae8 100644 --- a/services/apps/alcs/src/portal/notification-document/notification-document.controller.spec.ts +++ b/services/apps/alcs/src/portal/notification-document/notification-document.controller.spec.ts @@ -5,7 +5,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { ClsService } from 'nestjs-cls'; import { mockKeyCloakProviders } from '../../../test/mocks/mockTypes'; import { VISIBILITY_FLAG } from '../../alcs/application/application-document/application-document.entity'; -import { NoticeOfIntentDocument } from '../../alcs/notice-of-intent/notice-of-intent-document/notice-of-intent-document.entity'; import { NotificationDocument } from '../../alcs/notification/notification-document/notification-document.entity'; import { NotificationDocumentService } from '../../alcs/notification/notification-document/notification-document.service'; import { NotificationService } from '../../alcs/notification/notification.service'; @@ -137,7 +136,11 @@ describe('NotificationDocumentController', () => { }, }); + expect(mockNotificationDocumentService.getInlineUrl).toHaveBeenCalledTimes( + 1, + ); expect(res.url).toEqual(fakeUrl); + expect(res.fileName).toEqual(mockDocument.document.fileName); }); it('should call through for download', async () => { diff --git a/services/apps/alcs/src/portal/notification-document/notification-document.controller.ts b/services/apps/alcs/src/portal/notification-document/notification-document.controller.ts index 54c990bb0a..555cde8cd6 100644 --- a/services/apps/alcs/src/portal/notification-document/notification-document.controller.ts +++ b/services/apps/alcs/src/portal/notification-document/notification-document.controller.ts @@ -78,7 +78,8 @@ export class NotificationDocumentController { if (canAccessDocument) { const url = await this.notificationDocumentService.getInlineUrl(document); - return { url }; + const { fileName } = document.document; + return { url, fileName }; } throw new NotFoundException('Failed to find document');