Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(document): add default document viewer if document is not a pdf * fix(document): call correct function for downloading document file * chore(document): remove console log
- Loading branch information
Showing
6 changed files
with
269 additions
and
75 deletions.
There are no files selected for viewing
123 changes: 80 additions & 43 deletions
123
src/app/workspace/resource/representation/document/document.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,100 @@ | ||
<div class="pdf-container"> | ||
<div *ngIf="fileType === 'pdf'" class="pdf-container"> | ||
<!-- in case of an error --> | ||
<app-status [status]="404" [url]="src.fileValue.fileUrl" [representation]="'document'" *ngIf="failedToLoad"> | ||
</app-status> | ||
|
||
<pdf-viewer class="pdf-viewer" [src]="src.fileValue.fileUrl" [original-size]="false" [autoresize]="true" | ||
[show-all]="true" [show-borders]="true" [zoom]="zoomFactor" [zoom-scale]="'page-width'"> | ||
</pdf-viewer> | ||
|
||
<div class="toolbar"> | ||
<div class="action horizontal bottom"> | ||
<!-- caption --> | ||
<span> | ||
<button mat-icon-button [matMenuTriggerFor]="more"> | ||
<mat-icon>more_vert</mat-icon> | ||
</button> | ||
<mat-menu #more="matMenu" class="mat-menu-custom-black"> | ||
<button class="menu-content" mat-menu-item (click)="downloadDocument(src.fileValue.fileUrl)"> | ||
Download file | ||
</button> | ||
<button class="menu-content" mat-menu-item (click)="openReplaceFileDialog()"> | ||
Replace file | ||
</button> | ||
</mat-menu> | ||
</span> | ||
|
||
<!-- input field for searching through document --> | ||
<input matInput #queryInp type="text" id="searchbox" name="searchbox" | ||
class="pdf-searchbox fill-remaining-space" placeholder="Search in pdf..." [value]="pdfQuery" | ||
[disabled]="failedToLoad" (input)="searchQueryChanged($event.target.value)" | ||
(keyup.enter)="searchQueryChanged(queryInp.value)" /> | ||
|
||
<!-- image action tools e.g. zoom, rotate and flip --> | ||
<span> | ||
<!-- zoom buttons --> | ||
<button mat-icon-button id="DSP_PDF_ZOOM_OUT" matTooltip="Zoom out" | ||
(click)="zoomFactor = zoomFactor - 0.2" [disabled]="failedToLoad"> | ||
<mat-icon>remove_circle_outline</mat-icon> | ||
</button> | ||
<button mat-icon-button id="DSP_PDF_HOME" matTooltip="Reset zoom" (click)="zoomFactor = 1.0" | ||
[disabled]="failedToLoad"> | ||
<mat-icon>adjust</mat-icon> | ||
</button> | ||
<button mat-icon-button id="DSP_PDF_ZOOM_IN" matTooltip="Zoom in" | ||
(click)="zoomFactor = zoomFactor + 0.2" [disabled]="failedToLoad"> | ||
<mat-icon>add_circle_outline</mat-icon> | ||
</button> | ||
</span> | ||
|
||
<!-- empty placeholders to center the zoom buttons --> | ||
<span class="fill-remaining-space"></span> | ||
<span class="empty-space"></span> | ||
<span class="empty-space"></span> | ||
<span class="empty-space"></span> | ||
|
||
<!-- full screen button --> | ||
<span> | ||
<button mat-icon-button id="DSP_PDF_FULL_SCREEN" matTooltip="Fullscreen" (click)="openFullscreen()" | ||
[disabled]="failedToLoad"> | ||
<mat-icon>fullscreen</mat-icon> | ||
</button> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="toolbar"> | ||
<div class="action horizontal bottom"> | ||
<!-- caption --> | ||
<span> | ||
<!-- default document viewer --> | ||
<div *ngIf="fileType !== 'pdf'"> | ||
<div class="file-representation"> | ||
<div class="container"> | ||
<div class="contents"> | ||
<div class="icon"> | ||
<mat-icon> | ||
text_snippet | ||
</mat-icon> | ||
</div> | ||
<div class="file"> | ||
<p>{{originalFilename}}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="toolbar"> | ||
<!-- toolbar --> | ||
<div class="action horizontal bottom"> | ||
<!-- three dot menu to download and replace file --> | ||
<button mat-icon-button [matMenuTriggerFor]="more"> | ||
<mat-icon>more_vert</mat-icon> | ||
</button> | ||
<mat-menu #more="matMenu" class="mat-menu-custom-black"> | ||
<button class="menu-content" mat-menu-item (click)="downloadDocument(src.fileValue.fileUrl)"> | ||
<button class="menu-content" mat-menu-item (click)="downloadDocument(src.fileValue.fileUrl)" | ||
[disabled]="failedToLoad"> | ||
Download file | ||
</button> | ||
<button class="menu-content" mat-menu-item (click)="openReplaceFileDialog()"> | ||
Replace file | ||
</button> | ||
</mat-menu> | ||
</span> | ||
|
||
<!-- input field for searching through document --> | ||
<input matInput #queryInp type="text" id="searchbox" name="searchbox" class="pdf-searchbox fill-remaining-space" | ||
placeholder="Search in pdf..." [value]="pdfQuery" [disabled]="failedToLoad" | ||
(input)="searchQueryChanged($event.target.value)" (keyup.enter)="searchQueryChanged(queryInp.value)" /> | ||
|
||
<!-- image action tools e.g. zoom, rotate and flip --> | ||
<span> | ||
<!-- zoom buttons --> | ||
<button mat-icon-button id="DSP_PDF_ZOOM_OUT" matTooltip="Zoom out" (click)="zoomFactor = zoomFactor - 0.2" | ||
[disabled]="failedToLoad"> | ||
<mat-icon>remove_circle_outline</mat-icon> | ||
</button> | ||
<button mat-icon-button id="DSP_PDF_HOME" matTooltip="Reset zoom" (click)="zoomFactor = 1.0" | ||
[disabled]="failedToLoad"> | ||
<mat-icon>adjust</mat-icon> | ||
</button> | ||
<button mat-icon-button id="DSP_PDF_ZOOM_IN" matTooltip="Zoom in" (click)="zoomFactor = zoomFactor + 0.2" | ||
[disabled]="failedToLoad"> | ||
<mat-icon>add_circle_outline</mat-icon> | ||
</button> | ||
</span> | ||
|
||
<!-- empty placeholders to center the zoom buttons --> | ||
<span class="fill-remaining-space"></span> | ||
<span class="empty-space"></span> | ||
<span class="empty-space"></span> | ||
<span class="empty-space"></span> | ||
|
||
<!-- full screen button --> | ||
<span> | ||
<button mat-icon-button id="DSP_PDF_FULL_SCREEN" matTooltip="Fullscreen" (click)="openFullscreen()" | ||
[disabled]="failedToLoad"> | ||
<mat-icon>fullscreen</mat-icon> | ||
</button> | ||
</span> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.