diff --git a/mediarepo-ui/src/app/components/shared/file/content-viewer/content-viewer.component.html b/mediarepo-ui/src/app/components/shared/file/content-viewer/content-viewer.component.html
index 8077d88..c74112c 100644
--- a/mediarepo-ui/src/app/components/shared/file/content-viewer/content-viewer.component.html
+++ b/mediarepo-ui/src/app/components/shared/file/content-viewer/content-viewer.component.html
@@ -1,8 +1,8 @@
-
-
-
+
+
+
-
+
Unsupported content type {{this.file.mimeType}}
diff --git a/mediarepo-ui/src/app/components/shared/file/content-viewer/content-viewer.component.ts b/mediarepo-ui/src/app/components/shared/file/content-viewer/content-viewer.component.ts
index e6400cb..2f52ce5 100644
--- a/mediarepo-ui/src/app/components/shared/file/content-viewer/content-viewer.component.ts
+++ b/mediarepo-ui/src/app/components/shared/file/content-viewer/content-viewer.component.ts
@@ -1,5 +1,6 @@
import {
AfterViewInit,
+ ChangeDetectionStrategy,
Component,
Input,
OnChanges,
@@ -11,25 +12,23 @@ import {SafeResourceUrl} from "@angular/platform-browser";
import {File} from "../../../../../api/models/File";
import {FileService} from "../../../../services/file/file.service";
import {FileHelper} from "../../../../services/file/file.helper";
-import {
- ErrorBrokerService
-} from "../../../../services/error-broker/error-broker.service";
-import {
- BusyIndicatorComponent
-} from "../../app-common/busy-indicator/busy-indicator.component";
+import {ErrorBrokerService} from "../../../../services/error-broker/error-broker.service";
+import {BusyIndicatorComponent} from "../../app-common/busy-indicator/busy-indicator.component";
type ContentType = "image" | "video" | "audio" | "other";
@Component({
selector: "app-content-viewer",
templateUrl: "./content-viewer.component.html",
- styleUrls: ["./content-viewer.component.scss"]
+ styleUrls: ["./content-viewer.component.scss"],
+ changeDetection: ChangeDetectionStrategy.OnPush
})
export class ContentViewerComponent implements AfterViewInit, OnChanges, OnDestroy {
@Input() file!: File;
public contentUrl: SafeResourceUrl | undefined;
public blobUrl: SafeResourceUrl | undefined;
+ public contentType: ContentType = "other";
@ViewChild(BusyIndicatorComponent) busyIndicator!: BusyIndicatorComponent;
@@ -40,7 +39,8 @@ export class ContentViewerComponent implements AfterViewInit, OnChanges, OnDestr
}
public async ngAfterViewInit() {
- if (["audio", "video"].includes(this.getContentType())) {
+ this.contentType = this.getContentType();
+ if (["audio", "video"].includes(this.contentType)) {
await this.loadBlobUrl();
} else {
this.contentUrl = this.fileService.buildContentUrl(this.file);
@@ -49,8 +49,9 @@ export class ContentViewerComponent implements AfterViewInit, OnChanges, OnDestr
public async ngOnChanges(changes: SimpleChanges) {
if (changes["file"]) {
- if (["audio", "video"].includes(
- this.getContentType()) && this.busyIndicator) {
+ this.contentType = this.getContentType();
+
+ if (["audio", "video"].includes(this.contentType) && this.busyIndicator) {
await this.loadBlobUrl();
} else {
this.contentUrl = this.fileService.buildContentUrl(this.file);
@@ -63,23 +64,6 @@ export class ContentViewerComponent implements AfterViewInit, OnChanges, OnDestr
this.unloadBlobUrl();
}
- public getContentType(): ContentType {
- let mimeParts = this.file.mimeType.split("/");
- const type = mimeParts.shift() ?? "other";
- const subtype = mimeParts.shift() ?? "*";
-
- switch (type) {
- case "image":
- return "image";
- case "video":
- return "video";
- case "audio":
- return "audio";
- default:
- return "other";
- }
- }
-
public async downloadContent() {
const path = await FileHelper.getFileDownloadLocation(this.file);
@@ -103,6 +87,22 @@ export class ContentViewerComponent implements AfterViewInit, OnChanges, OnDestr
});
}
+ private getContentType(): ContentType {
+ let mimeParts = this.file.mimeType.split("/");
+ const type = mimeParts.shift() ?? "other";
+
+ switch (type) {
+ case "image":
+ return "image";
+ case "video":
+ return "video";
+ case "audio":
+ return "audio";
+ default:
+ return "other";
+ }
+ }
+
private unloadBlobUrl() {
if (this.blobUrl) {
URL?.revokeObjectURL(this.blobUrl as string);
diff --git a/mediarepo-ui/src/app/components/shared/sidebar/file-metadata/file-metadata.component.html b/mediarepo-ui/src/app/components/shared/sidebar/file-metadata/file-metadata.component.html
index 0644be9..ed8b0b1 100644
--- a/mediarepo-ui/src/app/components/shared/sidebar/file-metadata/file-metadata.component.html
+++ b/mediarepo-ui/src/app/components/shared/sidebar/file-metadata/file-metadata.component.html
@@ -3,15 +3,21 @@
File Metadata
-