|
|
@ -1,4 +1,7 @@
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
|
|
|
|
AfterViewChecked,
|
|
|
|
|
|
|
|
ChangeDetectionStrategy,
|
|
|
|
|
|
|
|
ChangeDetectorRef,
|
|
|
|
Component,
|
|
|
|
Component,
|
|
|
|
ElementRef,
|
|
|
|
ElementRef,
|
|
|
|
EventEmitter,
|
|
|
|
EventEmitter,
|
|
|
@ -12,42 +15,49 @@ import {
|
|
|
|
} from "@angular/core";
|
|
|
|
} from "@angular/core";
|
|
|
|
import {File} from "../../../../../api/models/File";
|
|
|
|
import {File} from "../../../../../api/models/File";
|
|
|
|
import {Selectable} from "../../../../models/Selectable";
|
|
|
|
import {Selectable} from "../../../../models/Selectable";
|
|
|
|
import {
|
|
|
|
import {SchedulingService} from "../../../../services/scheduling/scheduling.service";
|
|
|
|
SchedulingService
|
|
|
|
|
|
|
|
} from "../../../../services/scheduling/scheduling.service";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const LOADING_WORK_KEY = "FILE_THUMBNAIL_LOADING";
|
|
|
|
const LOADING_WORK_KEY = "FILE_THUMBNAIL_LOADING";
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: "app-file-card",
|
|
|
|
selector: "app-file-card",
|
|
|
|
templateUrl: "./file-card.component.html",
|
|
|
|
templateUrl: "./file-card.component.html",
|
|
|
|
styleUrls: ["./file-card.component.scss"]
|
|
|
|
styleUrls: ["./file-card.component.scss"],
|
|
|
|
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class FileCardComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
|
export class FileCardComponent implements OnInit, OnChanges, OnDestroy, AfterViewChecked {
|
|
|
|
@ViewChild("card") card!: ElementRef;
|
|
|
|
@ViewChild("card") card!: ElementRef;
|
|
|
|
@Input() public entry!: Selectable<File>;
|
|
|
|
@Input() public entry!: Selectable<File>;
|
|
|
|
@Output() clickEvent = new EventEmitter<FileCardComponent>();
|
|
|
|
@Output() clickEvent = new EventEmitter<FileCardComponent>();
|
|
|
|
@Output() dblClickEvent = new EventEmitter<FileCardComponent>();
|
|
|
|
@Output() dblClickEvent = new EventEmitter<FileCardComponent>();
|
|
|
|
|
|
|
|
public loading = false;
|
|
|
|
private cachedId: number | undefined;
|
|
|
|
private cachedId: number | undefined;
|
|
|
|
private workId: number | undefined;
|
|
|
|
private workId: number | undefined;
|
|
|
|
public loading = false;
|
|
|
|
private selectedPrevious = false;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private schedulingService: SchedulingService) {
|
|
|
|
constructor(private changeDetector: ChangeDetectorRef, private schedulingService: SchedulingService) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async ngOnInit() {
|
|
|
|
async ngOnInit() {
|
|
|
|
this.cachedId = this.entry.data.id;
|
|
|
|
this.cachedId = this.entry.data.id;
|
|
|
|
|
|
|
|
this.selectedPrevious = this.entry.selected;
|
|
|
|
this.setImageDelayed();
|
|
|
|
this.setImageDelayed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async ngOnChanges(changes: SimpleChanges) {
|
|
|
|
async ngOnChanges(changes: SimpleChanges) {
|
|
|
|
if (changes["file"] && (this.cachedId === undefined || this.entry.data.id !== this.cachedId)) {
|
|
|
|
if (changes["entry"] && (this.cachedId === undefined || this.entry.data.id !== this.cachedId)) {
|
|
|
|
this.cachedId = this.entry.data.id;
|
|
|
|
this.cachedId = this.entry.data.id;
|
|
|
|
this.setImageDelayed();
|
|
|
|
this.setImageDelayed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ngAfterViewChecked(): void {
|
|
|
|
|
|
|
|
if (this.entry.selected != this.selectedPrevious) {
|
|
|
|
|
|
|
|
this.selectedPrevious = this.entry.selected;
|
|
|
|
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ngOnDestroy(): void {
|
|
|
|
public ngOnDestroy(): void {
|
|
|
|
if (this.workId) {
|
|
|
|
if (this.workId) {
|
|
|
|
this.schedulingService.cancelWork(LOADING_WORK_KEY, this.workId);
|
|
|
|
this.schedulingService.cancelWork(LOADING_WORK_KEY, this.workId);
|
|
|
@ -59,10 +69,13 @@ export class FileCardComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
|
this.schedulingService.cancelWork(LOADING_WORK_KEY, this.workId);
|
|
|
|
this.schedulingService.cancelWork(LOADING_WORK_KEY, this.workId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.loading = true;
|
|
|
|
this.loading = true;
|
|
|
|
this.workId = this.schedulingService.addWork(LOADING_WORK_KEY,
|
|
|
|
this.workId = this.schedulingService.addWork(
|
|
|
|
|
|
|
|
LOADING_WORK_KEY,
|
|
|
|
async () => {
|
|
|
|
async () => {
|
|
|
|
await this.schedulingService.delay(1);
|
|
|
|
await this.schedulingService.delay(1);
|
|
|
|
this.loading = false;
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|