Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(upload): fix thumbnail preview (DEV-268) #619

Merged
merged 2 commits into from Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,10 +22,7 @@

<ng-container *ngIf="!isLoading && file">
<div *ngIf="thumbnailUrl" class="thumbnail">
<img src="{{ thumbnailUrl }}" alt="thumbnail" />
<button mat-button class="delete-file" title="delete file" (click)="deleteAttachment()">
<mat-icon>close</mat-icon>
</button>
<img [src]="thumbnailUrl" alt="thumbnail" />
</div>

<div class="files-list">
Expand Down
@@ -1,5 +1,6 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import {
CreateArchiveFileValue,
CreateAudioFileValue,
Expand Down Expand Up @@ -38,7 +39,7 @@ export class UploadComponent implements OnInit {
form: FormGroup;
fileControl: FormControl;
isLoading = false;
thumbnailUrl: string;
thumbnailUrl: string | SafeUrl;

allowedFileTypes: string[];
// todo: maybe we can use this list to display which file format is allowed to
Expand All @@ -47,13 +48,10 @@ export class UploadComponent implements OnInit {
supportedAudioTypes = ['audio/mpeg'];
supportedArchiveTypes = ['application/zip', 'application/x-tar', 'application/gzip'];

// readonly fromLabels = {
// upload: 'Upload file',
// drag_drop: 'Drag and drop or click to upload'
// };
constructor(
private _fb: FormBuilder,
private _notification: NotificationService,
private _sanitizer: DomSanitizer,
private _upload: UploadFileService
) { }

Expand Down Expand Up @@ -97,7 +95,7 @@ export class UploadComponent implements OnInit {
case 'stillImage':
const temporaryUrl = res.uploadedFiles[0].temporaryUrl;
const thumbnailUri = '/full/256,/0/default.jpg';
this.thumbnailUrl = `${temporaryUrl}${thumbnailUri}`;
this.thumbnailUrl = this._sanitizer.bypassSecurityTrustUrl(temporaryUrl + thumbnailUri);
break;

case 'document':
Expand Down