From 7f90c63b69f570f60e20ada5dad19a56d6baf43e Mon Sep 17 00:00:00 2001 From: Jan Wiebe Date: Tue, 31 Mar 2026 11:41:07 +0200 Subject: [PATCH 01/14] fix(frontend:files): remove pdf-to-onlyoffice redirect in viewerHook --- .../src/app/applications/files/services/files.service.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/applications/files/services/files.service.ts b/frontend/src/app/applications/files/services/files.service.ts index caa17218..041c1853 100644 --- a/frontend/src/app/applications/files/services/files.service.ts +++ b/frontend/src/app/applications/files/services/files.service.ts @@ -295,7 +295,7 @@ export class FilesService { let hookedShortMime: string try { - hookedShortMime = await this.viewerHook(file, isWriteable) + hookedShortMime = await this.viewerHook(file) if (file?.lock?.isExclusive) { this.layout.sendNotification('info', 'The file is locked', fileLockPropsToString(file.lock)) } @@ -351,10 +351,7 @@ export class FilesService { }) } - private async viewerHook(file: FileModel, isWriteable = false): Promise { - if (isWriteable && file.shortMime === SHORT_MIME.PDF && file.isEditable) { - return SHORT_MIME.DOCUMENT - } + private async viewerHook(file: FileModel): Promise { if (file.shortMime === SHORT_MIME.TEXT) { if (file.size < MAX_TEXT_FILE_SIZE) { return SHORT_MIME.TEXT From 7c38299cc47968865818a13e4e55cd02f4ea9a63 Mon Sep 17 00:00:00 2001 From: Jan Wiebe Date: Tue, 31 Mar 2026 11:44:48 +0200 Subject: [PATCH 02/14] feat(frontend:files): add activeViewer signal and toggleViewer to pdf dialog Co-Authored-By: Claude Sonnet 4.6 --- .../dialogs/files-viewer-dialog.component.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts index 4c4e28d0..59a093b3 100644 --- a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts +++ b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts @@ -37,12 +37,16 @@ export class FilesViewerDialogComponent implements OnInit, OnDestroy { @Input({ required: true }) isWriteable: boolean @Input({ required: true }) hookedShortMime: string @Input({ required: true }) editorProvider: FileEditorProviders + protected activeViewer = signal('') modalClosing = signal(false) protected isReadonly = model(true) protected currentHeight: number protected readonly SHORT_MIME = SHORT_MIME protected readonly icons = { faEye, faPen } protected directoryImages = computed(() => this.directoryFiles.filter((file) => file.isImage)) + protected canToggleViewer = computed( + () => this.isWriteable && this.currentFile?.isEditable && this.currentFile?.shortMime === SHORT_MIME.PDF + ) private openedFile: { id: string | number; name: string; mimeUrl: string } protected readonly store = inject(StoreService) private readonly layout = inject(LayoutService) @@ -50,17 +54,29 @@ export class FilesViewerDialogComponent implements OnInit, OnDestroy { private readonly offsetTop = 42 ngOnInit() { + this.activeViewer.set(this.hookedShortMime) this.isReadonly.set(this.mode === FILE_MODE.VIEW) this.openedFile = { id: this.currentFile.id, name: this.currentFile.name, mimeUrl: this.currentFile.mimeUrl } this.onResize() } + protected toggleViewer(): void { + if (this.activeViewer() === SHORT_MIME.PDF) { + this.editorProvider.onlyoffice = true + this.activeViewer.set(SHORT_MIME.DOCUMENT) + this.isReadonly.set(false) + } else { + this.activeViewer.set(SHORT_MIME.PDF) + this.isReadonly.set(true) + } + } + ngOnDestroy() { this.subscription.unsubscribe() } onClose() { - if (this.currentFile.isEditable && this.hookedShortMime === SHORT_MIME.TEXT) { + if (this.currentFile.isEditable && this.activeViewer() === SHORT_MIME.TEXT) { // Prevent closing the modal without saving when using the text editor this.modalClosing.set(true) // Force the next state change From d8bbf9ef141d8429979743612495980a49b9038c Mon Sep 17 00:00:00 2001 From: Jan Wiebe Date: Tue, 31 Mar 2026 11:47:40 +0200 Subject: [PATCH 03/14] fix(frontend:files): use local signal instead of mutating editorProvider in toggleViewer --- .../files/components/dialogs/files-viewer-dialog.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts index 59a093b3..ca8c9255 100644 --- a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts +++ b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts @@ -47,6 +47,7 @@ export class FilesViewerDialogComponent implements OnInit, OnDestroy { protected canToggleViewer = computed( () => this.isWriteable && this.currentFile?.isEditable && this.currentFile?.shortMime === SHORT_MIME.PDF ) + protected onlyOfficeForPdf = signal(false) private openedFile: { id: string | number; name: string; mimeUrl: string } protected readonly store = inject(StoreService) private readonly layout = inject(LayoutService) @@ -62,10 +63,11 @@ export class FilesViewerDialogComponent implements OnInit, OnDestroy { protected toggleViewer(): void { if (this.activeViewer() === SHORT_MIME.PDF) { - this.editorProvider.onlyoffice = true + this.onlyOfficeForPdf.set(true) this.activeViewer.set(SHORT_MIME.DOCUMENT) this.isReadonly.set(false) } else { + this.onlyOfficeForPdf.set(false) this.activeViewer.set(SHORT_MIME.PDF) this.isReadonly.set(true) } From d5695b4af604b7567bbcf03e1d99750fcbb2db49 Mon Sep 17 00:00:00 2001 From: Jan Wiebe Date: Tue, 31 Mar 2026 12:03:31 +0200 Subject: [PATCH 04/14] feat(frontend:files): update pdf viewer template to use activeViewer and toggle button --- .../dialogs/files-viewer-dialog.component.html | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.html b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.html index 2b489a99..c9795079 100644 --- a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.html +++ b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.html @@ -1,6 +1,12 @@ @if (currentFile) {