|
|
@ -1,8 +1,15 @@
|
|
|
|
import {ChangeDetectionStrategy, Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from "@angular/core";
|
|
|
|
import {
|
|
|
|
|
|
|
|
ChangeDetectionStrategy,
|
|
|
|
|
|
|
|
ChangeDetectorRef,
|
|
|
|
|
|
|
|
Component,
|
|
|
|
|
|
|
|
Input,
|
|
|
|
|
|
|
|
OnChanges,
|
|
|
|
|
|
|
|
OnInit,
|
|
|
|
|
|
|
|
SimpleChanges
|
|
|
|
|
|
|
|
} from "@angular/core";
|
|
|
|
import {File} from "../../../../../api/models/File";
|
|
|
|
import {File} from "../../../../../api/models/File";
|
|
|
|
import {FileService} from "../../../../services/file/file.service";
|
|
|
|
import {FileService} from "../../../../services/file/file.service";
|
|
|
|
import {FileMetadata} from "../../../../../api/api-types/files";
|
|
|
|
import {FileMetadata} from "../../../../../api/api-types/files";
|
|
|
|
import {BusyIndicatorComponent} from "../../app-common/busy-indicator/busy-indicator.component";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: "app-file-metadata",
|
|
|
|
selector: "app-file-metadata",
|
|
|
@ -14,32 +21,34 @@ export class FileMetadataComponent implements OnInit, OnChanges {
|
|
|
|
|
|
|
|
|
|
|
|
@Input() file!: File;
|
|
|
|
@Input() file!: File;
|
|
|
|
public fileMetadata: FileMetadata | undefined;
|
|
|
|
public fileMetadata: FileMetadata | undefined;
|
|
|
|
|
|
|
|
public loading: boolean = false;
|
|
|
|
|
|
|
|
|
|
|
|
@ViewChild(BusyIndicatorComponent) busyIndicator!: BusyIndicatorComponent;
|
|
|
|
constructor(private changeDetector: ChangeDetectorRef, private fileService: FileService) {
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private fileService: FileService) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async ngOnInit() {
|
|
|
|
public async ngOnInit() {
|
|
|
|
await this.busyIndicator.wrapAsyncOperation(async () => {
|
|
|
|
this.loading = true;
|
|
|
|
this.fileMetadata = await this.fileService.getFileMetadata(this.file.id);
|
|
|
|
this.fileMetadata = await this.fileService.getFileMetadata(this.file.id);
|
|
|
|
});
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async ngOnChanges(changes: SimpleChanges) {
|
|
|
|
public async ngOnChanges(changes: SimpleChanges) {
|
|
|
|
if (changes["file"] && (!this.fileMetadata || this.fileMetadata.file_id != this.file.id)) {
|
|
|
|
if (changes["file"] && (!this.fileMetadata || this.fileMetadata.file_id != this.file.id)) {
|
|
|
|
await this.busyIndicator.wrapAsyncOperation(async () => {
|
|
|
|
this.loading = true;
|
|
|
|
this.fileMetadata = await this.fileService.getFileMetadata(this.file.id);
|
|
|
|
this.fileMetadata = await this.fileService.getFileMetadata(this.file.id);
|
|
|
|
});
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async saveFileName(name: string) {
|
|
|
|
public async saveFileName(name: string) {
|
|
|
|
await this.busyIndicator.wrapAsyncOperation(async () => {
|
|
|
|
this.loading = true;
|
|
|
|
const newFile = await this.fileService.updateFileName(this.file.id, name);
|
|
|
|
const newFile = await this.fileService.updateFileName(this.file.id, name);
|
|
|
|
if (this.fileMetadata) {
|
|
|
|
if (this.fileMetadata) {
|
|
|
|
this.fileMetadata.name = newFile.name;
|
|
|
|
this.fileMetadata.name = newFile.name;
|
|
|
|
}
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|