diff --git a/src/main/webapp/app/lecture/pdf-preview/pdf-preview-enlarged-canvas/pdf-preview-enlarged-canvas.component.ts b/src/main/webapp/app/lecture/pdf-preview/pdf-preview-enlarged-canvas/pdf-preview-enlarged-canvas.component.ts index 36e955f1a97f..725c45ab4094 100644 --- a/src/main/webapp/app/lecture/pdf-preview/pdf-preview-enlarged-canvas/pdf-preview-enlarged-canvas.component.ts +++ b/src/main/webapp/app/lecture/pdf-preview/pdf-preview-enlarged-canvas/pdf-preview-enlarged-canvas.component.ts @@ -14,20 +14,23 @@ type NavigationDirection = 'next' | 'prev'; export class PdfPreviewEnlargedCanvasComponent { enlargedCanvas = viewChild.required>('enlargedCanvas'); - readonly DEFAULT_SLIDE_HEIGHT = 800; + readonly DEFAULT_ENLARGED_SLIDE_HEIGHT = 800; + // Inputs pdfContainer = input.required(); originalCanvas = input(); totalPages = input(0); - isEnlargedViewOutput = output(); - + // Signals currentPage = signal(1); + //Outputs + isEnlargedViewOutput = output(); + constructor() { effect( () => { - this.displayEnlargedCanvas(this.originalCanvas()!, false); + this.displayEnlargedCanvas(this.originalCanvas()!); }, { allowSignalWrites: true }, ); @@ -65,8 +68,7 @@ export class PdfPreviewEnlargedCanvasComponent { } }; - displayEnlargedCanvas(originalCanvas: HTMLCanvasElement, isVertical: boolean) { - this.adjustPdfContainerSize(isVertical); + displayEnlargedCanvas(originalCanvas: HTMLCanvasElement) { this.currentPage.set(Number(originalCanvas.id)); this.toggleBodyScroll(true); setTimeout(() => { @@ -109,7 +111,7 @@ export class PdfPreviewEnlargedCanvasComponent { if (originalCanvas.height > originalCanvas.width) { // Vertical slide - const fixedHeight = this.DEFAULT_SLIDE_HEIGHT; + const fixedHeight = this.DEFAULT_ENLARGED_SLIDE_HEIGHT; scaleY = fixedHeight / originalCanvas.height; scaleX = containerWidth / originalCanvas.width; } else { @@ -174,7 +176,7 @@ export class PdfPreviewEnlargedCanvasComponent { adjustPdfContainerSize(isVertical: boolean): void { const pdfContainer = this.pdfContainer(); if (isVertical) { - pdfContainer.style.height = `${this.DEFAULT_SLIDE_HEIGHT}px`; + pdfContainer.style.height = `${this.DEFAULT_ENLARGED_SLIDE_HEIGHT}px`; } else { pdfContainer.style.height = '60vh'; } diff --git a/src/main/webapp/app/lecture/pdf-preview/pdf-preview-thumbnail-grid/pdf-preview-thumbnail-grid.component.html b/src/main/webapp/app/lecture/pdf-preview/pdf-preview-thumbnail-grid/pdf-preview-thumbnail-grid.component.html index f3293aa1cf83..24b713acb796 100644 --- a/src/main/webapp/app/lecture/pdf-preview/pdf-preview-thumbnail-grid/pdf-preview-thumbnail-grid.component.html +++ b/src/main/webapp/app/lecture/pdf-preview/pdf-preview-thumbnail-grid/pdf-preview-thumbnail-grid.component.html @@ -1,6 +1,7 @@
@if (isEnlargedView()) { >('pdfContainer'); readonly DEFAULT_SLIDE_WIDTH = 250; - readonly DEFAULT_SLIDE_HEIGHT = 800; + // Inputs currentPdfUrl = input(); appendFile = input(); - isPdfLoading = output(); - + // Signals isEnlargedView = signal(false); totalPages = signal(0); selectedPages = signal>(new Set()); originalCanvas = signal(undefined); + // Outputs + isPdfLoading = output(); totalPagesOutput = output(); selectedPagesOutput = output>(); + // Injected services private readonly alertService = inject(AlertService); constructor() { effect( () => { - this.loadOrAppendPdf(this.currentPdfUrl()!, false); + this.loadOrAppendPdf(this.currentPdfUrl()!, this.appendFile()); }, { allowSignalWrites: true }, ); @@ -186,7 +188,6 @@ export class PdfPreviewThumbnailGridComponent { * @param originalCanvas - The original canvas element of the PDF page to be enlarged. * */ displayEnlargedCanvas(originalCanvas: HTMLCanvasElement) { - //const isVertical = originalCanvas.height > originalCanvas.width; this.originalCanvas.set(originalCanvas); this.isEnlargedView.set(true); } diff --git a/src/main/webapp/app/lecture/pdf-preview/pdf-preview.component.ts b/src/main/webapp/app/lecture/pdf-preview/pdf-preview.component.ts index 74ed6f618b1c..c61848cc5768 100644 --- a/src/main/webapp/app/lecture/pdf-preview/pdf-preview.component.ts +++ b/src/main/webapp/app/lecture/pdf-preview/pdf-preview.component.ts @@ -32,6 +32,7 @@ export class PdfPreviewComponent implements OnInit, OnDestroy { attachmentSub: Subscription; attachmentUnitSub: Subscription; + // Signals course = signal(undefined); attachment = signal(undefined); attachmentUnit = signal(undefined); @@ -202,6 +203,8 @@ export class PdfPreviewComponent implements OnInit, OnDestroy { const objectUrl = URL.createObjectURL(this.currentPdfBlob()!); this.currentPdfUrl.set(objectUrl); + this.appendFile.set(false); + this.dialogErrorSource.next(''); } catch (error) { this.alertService.error('artemisApp.attachment.pdfPreview.pageDeleteError', { error: error.message }); } finally { @@ -233,13 +236,12 @@ export class PdfPreviewComponent implements OnInit, OnDestroy { this.selectedPages()!.clear(); const objectUrl = URL.createObjectURL(this.currentPdfBlob()!); - this.appendFile.set(true); this.currentPdfUrl.set(objectUrl); + this.appendFile.set(true); } catch (error) { this.alertService.error('artemisApp.attachment.pdfPreview.mergeFailedError', { error: error.message }); } finally { this.isPdfLoading.set(false); - this.appendFile.set(false); this.fileInput()!.nativeElement.value = ''; } }