Refactor and update to new API types
Signed-off-by: trivernis <trivernis@protonmail.com>pull/4/head
parent
ef0ba80917
commit
66fe9432fd
@ -0,0 +1,163 @@
|
|||||||
|
import {FileBasicData, FileMetadata, FileOsMetadata} from "./api-types/files";
|
||||||
|
import {invoke} from "@tauri-apps/api/tauri";
|
||||||
|
import {ApiFunction} from "./api-types/functions";
|
||||||
|
import {
|
||||||
|
AddLocalFileREquest,
|
||||||
|
AddRepositoryRequest,
|
||||||
|
ChangeFileTagsRequest,
|
||||||
|
CheckDaemonRunningRequest,
|
||||||
|
CheckLocalRepositoryExistsRequest,
|
||||||
|
CreateTagsRequest,
|
||||||
|
DeleteRepositoryRequest,
|
||||||
|
DeleteThumbnailsRequest,
|
||||||
|
FindFilesRequest,
|
||||||
|
GetFileMetadataRequest,
|
||||||
|
GetSizeRequest,
|
||||||
|
GetTagsForFilesRequest,
|
||||||
|
InitRepositoryRequest,
|
||||||
|
ReadFileRequest,
|
||||||
|
RemoveRepositoryRequest,
|
||||||
|
ResolvePathsToFilesRequest,
|
||||||
|
SaveFileRequest,
|
||||||
|
SelectRepositoryRequest,
|
||||||
|
SetFrontendStateRequest,
|
||||||
|
StartDaemonRequest,
|
||||||
|
UpdateFileNameRequest
|
||||||
|
} from "./api-types/requests";
|
||||||
|
import {
|
||||||
|
RepositoryData,
|
||||||
|
RepositoryMetadata,
|
||||||
|
SizeMetadata
|
||||||
|
} from "./api-types/repo";
|
||||||
|
import {NamespaceData, TagData} from "./api-types/tags";
|
||||||
|
|
||||||
|
export class MediarepApi {
|
||||||
|
|
||||||
|
public static async hasExecutable(): Promise<boolean> {
|
||||||
|
return this.invokePlugin(ApiFunction.HasExecutable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getRepositories(): Promise<RepositoryData[]> {
|
||||||
|
return this.invokePlugin(ApiFunction.GetRepositories);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async selectRepository(request: SelectRepositoryRequest): Promise<void> {
|
||||||
|
return this.invokePlugin(ApiFunction.SelectRepository, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async disconnectRepository(): Promise<void> {
|
||||||
|
return this.invokePlugin(ApiFunction.DisconnectRepository);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async closeLocalRepository(): Promise<void> {
|
||||||
|
return this.invokePlugin(ApiFunction.CloseLocalRepository);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async addRepository(request: AddRepositoryRequest): Promise<RepositoryData[]> {
|
||||||
|
return this.invokePlugin(ApiFunction.AddRepository, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async checkDaemonRunning(request: CheckDaemonRunningRequest): Promise<boolean> {
|
||||||
|
return this.invokePlugin(ApiFunction.CheckDaemonRunning, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async checkLocalRepositoryExists(request: CheckLocalRepositoryExistsRequest): Promise<boolean> {
|
||||||
|
return this.invokePlugin(ApiFunction.CheckLocalRepositoryExists, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async removeRepository(request: RemoveRepositoryRequest): Promise<void> {
|
||||||
|
return this.invokePlugin(ApiFunction.RemoveRepository, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async deleteRepository(request: DeleteRepositoryRequest): Promise<void> {
|
||||||
|
return this.invokePlugin(ApiFunction.DeleteRepository, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async startDaemon(request: StartDaemonRequest): Promise<void> {
|
||||||
|
return this.invokePlugin(ApiFunction.StartDaemon, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async initRepository(request: InitRepositoryRequest): Promise<void> {
|
||||||
|
return this.invokePlugin(ApiFunction.InitRepository, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getRepositoryMetadata(): Promise<RepositoryMetadata> {
|
||||||
|
return this.invokePlugin(ApiFunction.GetRepoMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getSize(request: GetSizeRequest): Promise<SizeMetadata> {
|
||||||
|
return this.invokePlugin(ApiFunction.GetSize, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getActiveRepository(): Promise<RepositoryData | undefined> {
|
||||||
|
return this.invokePlugin(ApiFunction.GetActiveRepository);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getAllFiles(): Promise<FileBasicData[]> {
|
||||||
|
return this.invokePlugin(ApiFunction.GetAllFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async findFiles(request: FindFilesRequest): Promise<FileBasicData[]> {
|
||||||
|
return this.invokePlugin(ApiFunction.FindFiles, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getFileMetadata(request: GetFileMetadataRequest): Promise<FileMetadata> {
|
||||||
|
return this.invokePlugin(ApiFunction.GetFileMetadata, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async updateFileName(request: UpdateFileNameRequest): Promise<FileMetadata> {
|
||||||
|
return this.invokePlugin(ApiFunction.UpdateFileName, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async saveFileLocally(request: SaveFileRequest): Promise<void> {
|
||||||
|
return this.invokePlugin(ApiFunction.SaveFileLocally, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async deleteThumbnails(request: DeleteThumbnailsRequest): Promise<void> {
|
||||||
|
return this.invokePlugin(ApiFunction.DeleteThumbnails, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async readFile(request: ReadFileRequest): Promise<number[]> {
|
||||||
|
return this.invokePlugin(ApiFunction.ReadFile, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getAllTags(): Promise<TagData[]> {
|
||||||
|
return this.invokePlugin(ApiFunction.GetAllTags);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getAllNamespaces(): Promise<NamespaceData[]> {
|
||||||
|
return this.invokePlugin(ApiFunction.GetAllNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getTagsForFiles(request: GetTagsForFilesRequest): Promise<TagData[]> {
|
||||||
|
return this.invokePlugin(ApiFunction.GetTagsForFiles, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async createTags(request: CreateTagsRequest): Promise<TagData[]> {
|
||||||
|
return this.invokePlugin(ApiFunction.CreateTags, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async changeFileTags(request: ChangeFileTagsRequest): Promise<TagData[]> {
|
||||||
|
return this.invokePlugin(ApiFunction.ChangeFileTags, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async resolvePathsToFiles(request: ResolvePathsToFilesRequest): Promise<FileOsMetadata[]> {
|
||||||
|
return this.invokePlugin(ApiFunction.ResolvePathsToFiles, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async addLocalFile(request: AddLocalFileREquest): Promise<FileBasicData> {
|
||||||
|
return this.invokePlugin(ApiFunction.AddLocalFile, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getFrontendState(): Promise<string> {
|
||||||
|
return this.invokePlugin(ApiFunction.GetFrontendState);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async setFrontendState(request: SetFrontendStateRequest): Promise<void> {
|
||||||
|
return this.invokePlugin(ApiFunction.SetFrontendState, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async invokePlugin<T>(fn: ApiFunction, args?: any): Promise<T> {
|
||||||
|
return invoke<T>(`plugin:mediarepo|${fn}`, args);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
export type FilterExpression =
|
||||||
|
{ OrExpression: TagQuery[] }
|
||||||
|
| { Query: TagQuery };
|
||||||
|
|
||||||
|
export type TagQuery = {
|
||||||
|
negate: boolean,
|
||||||
|
tag: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SortKey = { Namespace: SortNamespace }
|
||||||
|
| { FileName: SortDirection }
|
||||||
|
| { FileSize: SortDirection }
|
||||||
|
| { FileImportedTime: SortDirection }
|
||||||
|
| { FileChangeTime: SortDirection }
|
||||||
|
| { FileType: SortDirection };
|
||||||
|
|
||||||
|
export type SortNamespace = {
|
||||||
|
name: string,
|
||||||
|
direction: SortDirection,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SortDirection = "Ascending" | "Descending";
|
||||||
|
|
||||||
|
export type FileBasicData = {
|
||||||
|
id: number,
|
||||||
|
status: FileStatus,
|
||||||
|
cd: string,
|
||||||
|
mime_type: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FileStatus = "Imported" | "Archived" | "Deleted";
|
||||||
|
|
||||||
|
export type FileMetadata = {
|
||||||
|
file_id: number,
|
||||||
|
name?: string,
|
||||||
|
comment?: string,
|
||||||
|
creation_time: Date,
|
||||||
|
change_time: Date,
|
||||||
|
import_time: Date,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FileOsMetadata = {
|
||||||
|
name: string,
|
||||||
|
path: string,
|
||||||
|
mime_type: string,
|
||||||
|
created_at: Date,
|
||||||
|
modified_at: Date,
|
||||||
|
};
|
@ -0,0 +1,38 @@
|
|||||||
|
export enum ApiFunction {
|
||||||
|
// repository
|
||||||
|
HasExecutable = "has_executable",
|
||||||
|
GetRepositories = "get_repositories",
|
||||||
|
SelectRepository = "select_repository",
|
||||||
|
DisconnectRepository = "disconnect_repository",
|
||||||
|
CloseLocalRepository = "close_local_repository",
|
||||||
|
AddRepository = "add_repository",
|
||||||
|
CheckDaemonRunning = "check_daemon_running",
|
||||||
|
CheckLocalRepositoryExists = "check_local_repository_exists",
|
||||||
|
RemoveRepository = "remove_repository",
|
||||||
|
DeleteRepository = "delete_repository",
|
||||||
|
StartDaemon = "start_daemon",
|
||||||
|
InitRepository = "init_repository",
|
||||||
|
GetRepoMetadata = "get_repo_metadata",
|
||||||
|
GetSize = "get_size",
|
||||||
|
GetActiveRepository = "get_active_repository",
|
||||||
|
// files
|
||||||
|
GetAllFiles = "get_all_files",
|
||||||
|
FindFiles = "find_files",
|
||||||
|
GetFileMetadata = "get_file_metadata",
|
||||||
|
UpdateFileName = "update_file_name",
|
||||||
|
SaveFileLocally = "save_file_locally",
|
||||||
|
DeleteThumbnails = "delete_thumbnails",
|
||||||
|
ReadFile = "read_file",
|
||||||
|
// tags
|
||||||
|
GetAllTags = "get_all_tags",
|
||||||
|
GetAllNamespace = "get_all_namespaces",
|
||||||
|
GetTagsForFiles = "get_tags_for_files",
|
||||||
|
CreateTags = "create_tags",
|
||||||
|
ChangeFileTags = "change_file_tags",
|
||||||
|
// import
|
||||||
|
ResolvePathsToFiles = "resolve_paths_to_files",
|
||||||
|
AddLocalFile = "add_local_file",
|
||||||
|
// state
|
||||||
|
GetFrontendState = "get_frontend_state",
|
||||||
|
SetFrontendState = "set_frontend_state",
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
export type RepositoryMetadata = {
|
||||||
|
version: string,
|
||||||
|
file_count: number,
|
||||||
|
tag_count: number,
|
||||||
|
namespace_count: number,
|
||||||
|
mapping_count: number,
|
||||||
|
hash_count: number,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SizeMetadata = {
|
||||||
|
size_type: SizeType,
|
||||||
|
size: number,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SizeType = "Total" | "FileFolder" | "ThumbFolder" | "DatabaseFile";
|
||||||
|
|
||||||
|
export type RepositoryData = {
|
||||||
|
name: string,
|
||||||
|
address?: string,
|
||||||
|
path?: string,
|
||||||
|
local: boolean,
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
import {FileOsMetadata, FilterExpression, SortKey} from "./files";
|
||||||
|
import {RepositoryData, SizeType} from "./repo";
|
||||||
|
|
||||||
|
type NameIdentifierRequest = {
|
||||||
|
name: string
|
||||||
|
};
|
||||||
|
|
||||||
|
type IdIdentifierRequest = {
|
||||||
|
id: number
|
||||||
|
};
|
||||||
|
|
||||||
|
type RepoPathIdentifier = {
|
||||||
|
repoPath: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SelectRepositoryRequest = NameIdentifierRequest;
|
||||||
|
|
||||||
|
export type AddRepositoryRequest = RepositoryData;
|
||||||
|
|
||||||
|
export type CheckLocalRepositoryExistsRequest = {
|
||||||
|
path: string
|
||||||
|
};
|
||||||
|
|
||||||
|
export type RemoveRepositoryRequest = NameIdentifierRequest;
|
||||||
|
|
||||||
|
export type DeleteRepositoryRequest = NameIdentifierRequest;
|
||||||
|
|
||||||
|
export type CheckDaemonRunningRequest = {
|
||||||
|
address: string
|
||||||
|
};
|
||||||
|
|
||||||
|
export type StartDaemonRequest = RepoPathIdentifier;
|
||||||
|
|
||||||
|
export type InitRepositoryRequest = RepoPathIdentifier;
|
||||||
|
|
||||||
|
export type GetSizeRequest = {
|
||||||
|
sizeType: SizeType
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FindFilesRequest = {
|
||||||
|
filters: FilterExpression[],
|
||||||
|
sortBy: SortKey[]
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UpdateFileNameRequest = {
|
||||||
|
id: number,
|
||||||
|
name: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SaveFileRequest = {
|
||||||
|
id: number,
|
||||||
|
path: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DeleteThumbnailsRequest = IdIdentifierRequest;
|
||||||
|
|
||||||
|
export type ReadFileRequest = {
|
||||||
|
hash: string,
|
||||||
|
mimeType: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetFileMetadataRequest = IdIdentifierRequest;
|
||||||
|
|
||||||
|
export type GetTagsForFilesRequest = {
|
||||||
|
cds: string[]
|
||||||
|
};
|
||||||
|
|
||||||
|
export type CreateTagsRequest = {
|
||||||
|
tags: string[]
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ChangeFileTagsRequest = {
|
||||||
|
id: number,
|
||||||
|
addedTags: number[],
|
||||||
|
removedTags: number[],
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ResolvePathsToFilesRequest = {
|
||||||
|
paths: string[],
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AddLocalFileREquest = {
|
||||||
|
metadata: FileOsMetadata,
|
||||||
|
options: AddFileOptions,
|
||||||
|
}
|
||||||
|
|
||||||
|
type AddFileOptions = {
|
||||||
|
read_tags_from_txt: boolean,
|
||||||
|
delete_after_import: boolean,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SetFrontendStateRequest = {
|
||||||
|
state: string
|
||||||
|
};
|
@ -0,0 +1,10 @@
|
|||||||
|
export type TagData = {
|
||||||
|
id: number,
|
||||||
|
namespace?: string,
|
||||||
|
name: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type NamespaceData = {
|
||||||
|
id: number,
|
||||||
|
name: string,
|
||||||
|
};
|
@ -0,0 +1,32 @@
|
|||||||
|
import {FileBasicData, FileStatus} from "../api-types/files";
|
||||||
|
|
||||||
|
export class File {
|
||||||
|
constructor(
|
||||||
|
private basicData: FileBasicData,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public get rawData(): FileBasicData {
|
||||||
|
return this.basicData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get id(): number {
|
||||||
|
return this.basicData.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get cd(): string {
|
||||||
|
return this.basicData.cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get status(): FileStatus {
|
||||||
|
return this.basicData.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get mimeType(): string {
|
||||||
|
return this.basicData.mime_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public set status(value: FileStatus) {
|
||||||
|
this.basicData.status = value;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
import {NamespaceData} from "../api-types/tags";
|
||||||
|
|
||||||
|
export class Namespace {
|
||||||
|
constructor(private data: NamespaceData) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public get id(): number {
|
||||||
|
return this.data.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get name(): string {
|
||||||
|
return this.data.name;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
import {RepositoryData} from "../api-types/repo";
|
||||||
|
|
||||||
|
export class Repository {
|
||||||
|
constructor(
|
||||||
|
private repoData: RepositoryData,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public get name(): string {
|
||||||
|
return this.repoData.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get address(): string | undefined {
|
||||||
|
return this.repoData.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get path(): string | undefined {
|
||||||
|
return this.repoData.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get local(): boolean {
|
||||||
|
return this.repoData.local;
|
||||||
|
}
|
||||||
|
|
||||||
|
public update(data: {name?: string, address?: string, path?: string, local?: boolean}) {
|
||||||
|
this.repoData = Object.assign(this.repoData, data);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
import {TagData} from "../api-types/tags";
|
||||||
|
|
||||||
|
export class Tag {
|
||||||
|
|
||||||
|
private normalizedTag?: string = undefined;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private tagData: TagData,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public get id(): number {
|
||||||
|
return this.tagData.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get name(): string {
|
||||||
|
return this.tagData.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get namespace(): string | undefined {
|
||||||
|
return this.tagData.namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getNormalizedOutput(): string {
|
||||||
|
if (!this.normalizedTag) {
|
||||||
|
this.normalizedTag = this.namespace ? this.namespace + ":" + this.name : this.name;
|
||||||
|
}
|
||||||
|
return this.normalizedTag;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
export function mapOptional<I, O>(mapFn: (value: I) => O): (value: I | undefined) => O | undefined {
|
||||||
|
return (value: I | undefined) => value ? mapFn(value) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mapMany<I, O>(mapFn: (value: I) => O): (value: I[]) => O[] {
|
||||||
|
return (value: I[]) => value.map(mapFn);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mapNew<T, V>(classType: new (value: V) => T): (value: V) => T {
|
||||||
|
return (value: V) => new classType(value);
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<app-file-grid #fileGrid (fileOpenEvent)="this.onFileOpen($event)" (fileSelectEvent)="this.onFileSelect($event)"
|
<app-file-grid (fileOpenEvent)="this.onFileOpen($event)" (fileSelectEvent)="this.onFileSelect($event)"
|
||||||
*ngIf="this.mode === 'grid'"
|
*ngIf="this.mode === 'grid'"
|
||||||
[files]="this.files" [preselectedFile]="this.preselectedFile"></app-file-grid>
|
[files]="this.files" [preselectedFile]="this.preselectedFile"></app-file-grid>
|
||||||
<app-file-gallery #fileGallery (closeEvent)="this.setMode('grid')" (fileSelectEvent)="this.onSingleFileSelect($event)"
|
<app-file-gallery (closeEvent)="this.setMode('grid')" (fileSelectEvent)="this.onSingleFileSelect($event)"
|
||||||
*ngIf="this.mode === 'gallery'"
|
*ngIf="this.mode === 'gallery'"
|
||||||
[files]="this.files"
|
[files]="this.files"
|
||||||
[preselectedFile]="this.preselectedFile"></app-file-gallery>
|
[preselectedFile]="this.preselectedFile"></app-file-gallery>
|
||||||
|
@ -1,21 +1,41 @@
|
|||||||
import {Component, Input} from "@angular/core";
|
import {
|
||||||
import {File} from "../../../../models/File";
|
Component,
|
||||||
|
Input,
|
||||||
|
OnChanges,
|
||||||
|
OnInit,
|
||||||
|
SimpleChanges
|
||||||
|
} from "@angular/core";
|
||||||
|
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";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-file-metadata",
|
selector: "app-file-metadata",
|
||||||
templateUrl: "./file-metadata.component.html",
|
templateUrl: "./file-metadata.component.html",
|
||||||
styleUrls: ["./file-metadata.component.scss"]
|
styleUrls: ["./file-metadata.component.scss"]
|
||||||
})
|
})
|
||||||
export class FileMetadataComponent {
|
export class FileMetadataComponent implements OnInit, OnChanges {
|
||||||
|
|
||||||
@Input() file!: File;
|
@Input() file!: File;
|
||||||
|
public fileMetadata: FileMetadata | undefined;
|
||||||
|
|
||||||
constructor(private fileService: FileService) {
|
constructor(private fileService: FileService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async ngOnInit() {
|
||||||
|
this.fileMetadata = await this.fileService.getFileMetadata(this.file.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ngOnChanges(changes:SimpleChanges) {
|
||||||
|
if (changes["file"] && (!this.fileMetadata || this.fileMetadata.file_id != this.file.id)) {
|
||||||
|
this.fileMetadata = await this.fileService.getFileMetadata(this.file.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async saveFileName(name: string) {
|
public async saveFileName(name: string) {
|
||||||
const newFile = await this.fileService.updateFileName(this.file, name);
|
const newFile = await this.fileService.updateFileName(this.file.id, name);
|
||||||
this.file.name = newFile.name;
|
if (this.fileMetadata) {
|
||||||
|
this.fileMetadata.name = newFile.name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
export class File {
|
|
||||||
constructor(
|
|
||||||
public id: number,
|
|
||||||
public name: string | undefined,
|
|
||||||
public comment: string | undefined,
|
|
||||||
public hash: string,
|
|
||||||
public file_type: number,
|
|
||||||
public mime_type: string | undefined,
|
|
||||||
public creation_time: Date,
|
|
||||||
public change_time: Date,
|
|
||||||
public import_time: Date,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
export type FileOsMetadata = {
|
|
||||||
name: string,
|
|
||||||
path: string,
|
|
||||||
mime_type: string,
|
|
||||||
created_at: Date,
|
|
||||||
modified_at: Date,
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
export class Namespace {
|
|
||||||
constructor(public id: number, public name: string) {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
export class Repository {
|
|
||||||
constructor(
|
|
||||||
public name: string,
|
|
||||||
public address: string | undefined,
|
|
||||||
public path: string | undefined,
|
|
||||||
public local: boolean,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
export enum SizeType {
|
|
||||||
Total = "Total",
|
|
||||||
FileFolder = "FileFolder",
|
|
||||||
ThumbFolder = "ThumbFolder",
|
|
||||||
DatabaseFile = "DatabaseFile",
|
|
||||||
}
|
|
||||||
|
|
||||||
export type SizeMetadata = {
|
|
||||||
size_type: SizeType,
|
|
||||||
size: number,
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
export class Tag {
|
|
||||||
|
|
||||||
private normalizedTag?: string = undefined;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
public id: number,
|
|
||||||
public name: string,
|
|
||||||
public namespace: string | undefined
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public getNormalizedOutput(): string {
|
|
||||||
if (!this.normalizedTag) {
|
|
||||||
this.normalizedTag = this.namespace ? this.namespace + ":" + this.name : this.name
|
|
||||||
}
|
|
||||||
return this.normalizedTag;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
export type Thumbnail = {
|
|
||||||
file_hash: string,
|
|
||||||
height: number,
|
|
||||||
width: number,
|
|
||||||
mime_type: string | undefined
|
|
||||||
}
|
|
Loading…
Reference in New Issue