From 323ab51762b16b3973cd49322cb5b6e8b062b511 Mon Sep 17 00:00:00 2001 From: Ece Eren Date: Mon, 4 Nov 2024 08:30:11 +0100 Subject: [PATCH 01/11] Add hide icon to slide pages --- .../pdf-preview-thumbnail-grid.component.html | 1 + .../pdf-preview-thumbnail-grid.component.ts | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) 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 01ca1b9617a2..07d67be26971 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,3 +1,4 @@ +
@if (isEnlargedView()) { { overlay.style.opacity = '1'; + hideShowIcon.style.opacity = '1'; }); container.addEventListener('mouseleave', () => { overlay.style.opacity = '0'; + hideShowIcon.style.opacity = '0'; }); overlay.addEventListener('click', () => this.displayEnlargedCanvas(canvas)); @@ -165,6 +169,11 @@ export class PdfPreviewThumbnailGridComponent { return overlay; } + /** + * Generates a checkbox for each PDF page to allow for selection of pages. + * @param pageIndex The index of the page. + * @returns An input element styled as a checkbox. + */ private createCheckbox(pageIndex: number): HTMLDivElement { const checkbox = document.createElement('input'); checkbox.type = 'checkbox'; @@ -183,9 +192,19 @@ export class PdfPreviewThumbnailGridComponent { return checkbox; } + private createHideShowIcon(pageIndex: number): HTMLAnchorElement { + const icon = document.createElement('a'); + icon.type = 'button'; + icon.id = `hide-icon-${String(pageIndex)}`; + icon.className = 'btn btn-secondary'; + icon.innerHTML = ``; + icon.style.cssText = `opacity: 0; position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); color: gray; cursor: pointer; z-index: 4;`; + return icon; + } + /** * Displays the selected PDF page in an enlarged view for detailed examination. - * @param originalCanvas - The original canvas element of the PDF page to be enlarged. + * @param originalCanvas - The originala canvas element of the PDF page to be enlarged. * */ displayEnlargedCanvas(originalCanvas: HTMLCanvasElement) { this.originalCanvas.set(originalCanvas); From a14fe4fa4748032fff9e2fd911c969d52a274f3f Mon Sep 17 00:00:00 2001 From: Ece Eren Date: Tue, 5 Nov 2024 00:46:47 +0100 Subject: [PATCH 02/11] Add functionality to hide-show buttons --- .../pdf-preview-thumbnail-grid.component.ts | 51 ++++++++++++++----- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/src/main/webapp/app/lecture/pdf-preview/pdf-preview-thumbnail-grid/pdf-preview-thumbnail-grid.component.ts b/src/main/webapp/app/lecture/pdf-preview/pdf-preview-thumbnail-grid/pdf-preview-thumbnail-grid.component.ts index c4173bf84db1..4d4503aaf2bc 100644 --- a/src/main/webapp/app/lecture/pdf-preview/pdf-preview-thumbnail-grid/pdf-preview-thumbnail-grid.component.ts +++ b/src/main/webapp/app/lecture/pdf-preview/pdf-preview-thumbnail-grid/pdf-preview-thumbnail-grid.component.ts @@ -135,20 +135,22 @@ export class PdfPreviewThumbnailGridComponent { const overlay = this.createOverlay(pageIndex); const checkbox = this.createCheckbox(pageIndex); - const hideShowIcon = this.createHideShowIcon(pageIndex); + const hideButton = this.createHideButton(pageIndex); container.appendChild(canvas); container.appendChild(overlay); container.appendChild(checkbox); - container.appendChild(hideShowIcon); + container.appendChild(hideButton); container.addEventListener('mouseenter', () => { overlay.style.opacity = '1'; - hideShowIcon.style.opacity = '1'; + hideButton.style.opacity = '1'; }); container.addEventListener('mouseleave', () => { overlay.style.opacity = '0'; - hideShowIcon.style.opacity = '0'; + hideButton.style.opacity = '0'; }); + + hideButton.addEventListener('click', () => this.toggleVisibility(container, hideButton)); overlay.addEventListener('click', () => this.displayEnlargedCanvas(canvas)); return container; @@ -165,7 +167,7 @@ export class PdfPreviewThumbnailGridComponent { /* Dynamically created elements are not detected by DOM, that is why we need to set the styles manually. * See: https://stackoverflow.com/a/70911189 */ - overlay.style.cssText = `position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; font-size: 24px; color: white; z-index: 1; transition: opacity 0.3s ease; opacity: 0; cursor: pointer; background-color: var(--pdf-preview-container-overlay)`; + overlay.style.cssText = `position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; font-size: 24px; color: white; z-index: 2; transition: opacity 0.3s ease; opacity: 0; cursor: pointer; background-color: var(--pdf-preview-container-overlay)`; return overlay; } @@ -192,19 +194,40 @@ export class PdfPreviewThumbnailGridComponent { return checkbox; } - private createHideShowIcon(pageIndex: number): HTMLAnchorElement { - const icon = document.createElement('a'); - icon.type = 'button'; - icon.id = `hide-icon-${String(pageIndex)}`; - icon.className = 'btn btn-secondary'; - icon.innerHTML = ``; - icon.style.cssText = `opacity: 0; position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); color: gray; cursor: pointer; z-index: 4;`; - return icon; + private createHideButton(pageIndex: number): HTMLAnchorElement { + const hideButton = document.createElement('a'); + hideButton.type = 'button'; + hideButton.id = `hide-icon-${pageIndex}`; + hideButton.className = 'btn btn-secondary'; + hideButton.style.cssText = `opacity: 0; position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); cursor: pointer; z-index: 4;`; + hideButton.innerHTML = ``; + + return hideButton; + } + + private toggleVisibility(container: HTMLDivElement, hideButton: HTMLAnchorElement): void { + const overlay = document.createElement('div'); + overlay.id = 'pdf-page-overlay'; + overlay.style.cssText = `position: absolute; top: 0; width: 100%; height: 100%; z-index: 1; transition: opacity 0.3s ease; background-color: var(--pdf-preview-container-overlay)`; + + const diagonalLine = document.createElement('div'); + diagonalLine.style.cssText = `position: absolute; top: 0; left: 0; width: 115%; height: 2px; background-color: white; transform: rotate(29deg); transform-origin: top left;`; + overlay.appendChild(diagonalLine); + + if (hideButton.className === 'btn btn-secondary') { + container.appendChild(overlay); + hideButton.className = 'btn btn-success'; + hideButton.children[0].className = 'fa fa-eye'; + } else { + container.removeChild(container.querySelector(`#pdf-page-overlay`)!); + hideButton.className = 'btn btn-secondary'; + hideButton.children[0].className = 'fa fa-eye-slash'; + } } /** * Displays the selected PDF page in an enlarged view for detailed examination. - * @param originalCanvas - The originala canvas element of the PDF page to be enlarged. + * @param originalCanvas - The original canvas element of the PDF page to be enlarged. * */ displayEnlargedCanvas(originalCanvas: HTMLCanvasElement) { this.originalCanvas.set(originalCanvas); From e9a4ace13c895db6c1a77334e2733cfbbe3c3537 Mon Sep 17 00:00:00 2001 From: Ece Eren Date: Sun, 10 Nov 2024 18:12:27 +0100 Subject: [PATCH 03/11] Add slide hiding capability & creating a hidden version of the file --- .../artemis/lecture/domain/Attachment.java | 26 +++- .../repository/AttachmentRepository.java | 7 + .../lecture/web/AttachmentResource.java | 13 ++ .../changelog/20241110173144_changelog.xml | 22 +++ .../resources/config/liquibase/master.xml | 1 + .../webapp/app/entities/attachment.model.ts | 2 + .../webapp/app/lecture/attachment.service.ts | 12 ++ .../pdf-preview-thumbnail-grid.component.ts | 56 +++++--- .../pdf-preview/pdf-preview.component.html | 9 +- .../pdf-preview/pdf-preview.component.ts | 126 +++++++++++++++++- 10 files changed, 250 insertions(+), 24 deletions(-) create mode 100644 src/main/resources/config/liquibase/changelog/20241110173144_changelog.xml diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/domain/Attachment.java b/src/main/java/de/tum/cit/aet/artemis/lecture/domain/Attachment.java index 6806850fd86b..ca2bb2104d85 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/domain/Attachment.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/domain/Attachment.java @@ -61,6 +61,13 @@ public class Attachment extends DomainObject implements Serializable { @JoinColumn(name = "attachment_unit_id") private AttachmentUnit attachmentUnit; + @Column(name = "hidden_pages") + private String hiddenPages; + + @OneToOne + @JoinColumn(name = "parent_attachment_id") + private Attachment parentAttachment; + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove public String getName() { @@ -135,6 +142,22 @@ public void setAttachmentUnit(AttachmentUnit attachmentUnit) { this.attachmentUnit = attachmentUnit; } + public String getHiddenPages() { + return hiddenPages; + } + + public void setHiddenPages(String hiddenPages) { + this.hiddenPages = hiddenPages; + } + + public Attachment getParentAttachment() { + return parentAttachment; + } + + public void setParentAttachment(Attachment parentAttachment) { + this.parentAttachment = parentAttachment; + } + public Boolean isVisibleToStudents() { if (releaseDate == null) { // no release date means the attachment is visible to students return Boolean.TRUE; @@ -145,6 +168,7 @@ public Boolean isVisibleToStudents() { @Override public String toString() { return "Attachment{" + "id=" + getId() + ", name='" + getName() + "'" + ", link='" + getLink() + "'" + ", version='" + getVersion() + "'" + ", uploadDate='" - + getUploadDate() + "'" + ", releaseDate='" + getReleaseDate() + "'" + ", attachmentType='" + getAttachmentType() + "'" + "}"; + + getUploadDate() + "'" + ", releaseDate='" + getReleaseDate() + "'" + ", attachmentType='" + getAttachmentType() + "'" + ", hiddenPages='" + getHiddenPages() + "'" + + ", parentAttachment='" + getParentAttachment() + "'" + "}"; } } diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentRepository.java index 30b1068ed687..fc7a355223bc 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentRepository.java @@ -29,4 +29,11 @@ public interface AttachmentRepository extends ArtemisJpaRepository