|
|
@ -5,7 +5,8 @@ import {
|
|
|
|
Input,
|
|
|
|
Input,
|
|
|
|
OnChanges,
|
|
|
|
OnChanges,
|
|
|
|
OnInit,
|
|
|
|
OnInit,
|
|
|
|
Output, SimpleChanges,
|
|
|
|
Output,
|
|
|
|
|
|
|
|
SimpleChanges,
|
|
|
|
ViewChild
|
|
|
|
ViewChild
|
|
|
|
} from '@angular/core';
|
|
|
|
} from '@angular/core';
|
|
|
|
import {File} from "../../../models/File";
|
|
|
|
import {File} from "../../../models/File";
|
|
|
@ -15,45 +16,34 @@ import {SafeResourceUrl} from "@angular/platform-browser";
|
|
|
|
import {GridEntry} from "./GridEntry";
|
|
|
|
import {GridEntry} from "./GridEntry";
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: 'app-file-grid-entry',
|
|
|
|
selector: 'app-file-grid-entry',
|
|
|
|
templateUrl: './file-grid-entry.component.html',
|
|
|
|
templateUrl: './file-grid-entry.component.html',
|
|
|
|
styleUrls: ['./file-grid-entry.component.scss']
|
|
|
|
styleUrls: ['./file-grid-entry.component.scss']
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class FileGridEntryComponent implements OnInit, OnChanges {
|
|
|
|
export class FileGridEntryComponent implements OnInit, OnChanges {
|
|
|
|
|
|
|
|
|
|
|
|
@ViewChild("card") card!: ElementRef;
|
|
|
|
@ViewChild("card") card!: ElementRef;
|
|
|
|
@Input() public gridEntry!: GridEntry;
|
|
|
|
@Input() public gridEntry!: GridEntry;
|
|
|
|
@Output() clickEvent = new EventEmitter<FileGridEntryComponent>();
|
|
|
|
@Output() clickEvent = new EventEmitter<FileGridEntryComponent>();
|
|
|
|
@Output() dblClickEvent = new EventEmitter<FileGridEntryComponent>();
|
|
|
|
@Output() dblClickEvent = new EventEmitter<FileGridEntryComponent>();
|
|
|
|
|
|
|
|
|
|
|
|
contentUrl: SafeResourceUrl | undefined;
|
|
|
|
contentUrl: SafeResourceUrl | undefined;
|
|
|
|
private cachedFile: File | undefined;
|
|
|
|
private cachedFile: File | undefined;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private fileService: FileService, private errorBroker: ErrorBrokerService) {
|
|
|
|
constructor(private fileService: FileService, private errorBroker: ErrorBrokerService) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async ngOnInit() {
|
|
|
|
|
|
|
|
this.cachedFile = this.gridEntry.file;
|
|
|
|
|
|
|
|
await this.loadImage();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async ngOnChanges(changes: SimpleChanges) {
|
|
|
|
|
|
|
|
if (changes["file"] && (!this.cachedFile || this.gridEntry.file.hash !== this.cachedFile.hash)) {
|
|
|
|
|
|
|
|
this.cachedFile = this.gridEntry.file;
|
|
|
|
|
|
|
|
await this.loadImage();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async loadImage() {
|
|
|
|
async ngOnInit() {
|
|
|
|
try {
|
|
|
|
this.cachedFile = this.gridEntry.file;
|
|
|
|
const hash = this.gridEntry.file.hash;
|
|
|
|
this.contentUrl = this.fileService.buildThumbnailUrl(this.gridEntry.file,
|
|
|
|
const contentUrl = await this.fileService.getFileThumbnail(this.gridEntry.file, 250, 250);
|
|
|
|
250, 250);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.gridEntry.file.hash === hash) { // avoid issues with changed files
|
|
|
|
async ngOnChanges(changes: SimpleChanges) {
|
|
|
|
this.contentUrl = contentUrl;
|
|
|
|
if (changes["file"] && (!this.cachedFile || this.gridEntry.file.hash !== this.cachedFile.hash)) {
|
|
|
|
}
|
|
|
|
this.cachedFile = this.gridEntry.file;
|
|
|
|
} catch (err) {
|
|
|
|
this.contentUrl = this.fileService.buildThumbnailUrl(this.gridEntry.file,
|
|
|
|
this.errorBroker.showError(err);
|
|
|
|
250, 250);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|