From 66fe9432fd248f53810529b7b6002ce4b4ac9ad9 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 8 Jan 2022 16:48:38 +0100 Subject: [PATCH] Refactor and update to new API types Signed-off-by: trivernis --- mediarepo-ui/.eslintrc.json | 114 ++++++------ mediarepo-ui/src-tauri/Cargo.lock | 4 +- mediarepo-ui/src-tauri/Cargo.toml | 2 +- mediarepo-ui/src/api/Api.ts | 163 ++++++++++++++++++ mediarepo-ui/src/api/api-types/files.ts | 48 ++++++ mediarepo-ui/src/api/api-types/functions.ts | 38 ++++ mediarepo-ui/src/api/api-types/repo.ts | 22 +++ mediarepo-ui/src/api/api-types/requests.ts | 94 ++++++++++ mediarepo-ui/src/api/api-types/tags.ts | 10 ++ mediarepo-ui/src/api/models/File.ts | 32 ++++ mediarepo-ui/src/api/models/Namespace.ts | 14 ++ mediarepo-ui/src/api/models/Repository.ts | 28 +++ mediarepo-ui/src/api/models/Tag.ts | 30 ++++ mediarepo-ui/src/api/models/adaptors.ts | 11 ++ .../app/components/core/core.component.html | 2 +- .../app/components/core/core.component.scss | 5 +- .../src/app/components/core/core.component.ts | 4 +- .../src/app/components/core/core.module.ts | 4 +- .../files-tab-sidebar.component.ts | 10 +- .../core/files-tab/files-tab.component.ts | 12 +- .../import-tab-sidebar.component.ts | 2 +- .../core/import-tab/import-tab.component.ts | 10 +- .../download-daemon-dialog.component.ts | 2 +- .../repositories-tab.component.ts | 2 +- .../repository-card.component.ts | 8 +- .../repository-details-view.component.spec.ts | 40 +++-- .../repository-details-view.component.ts | 13 +- .../shared/app-common/app-common.module.ts | 4 +- .../busy-indicator.component.ts | 4 +- .../input-receiver.directive.spec.ts | 12 +- .../content-viewer.component.html | 2 +- .../content-viewer.component.ts | 9 +- .../image-viewer/image-viewer.component.ts | 4 +- .../file/file-card/file-card.component.ts | 4 +- .../file-context-menu.component.ts | 6 +- .../file-gallery/file-gallery.component.ts | 24 +-- .../file-grid/file-grid.component.ts | 15 +- .../file-multiview.component.html | 4 +- .../file-multiview.component.ts | 9 +- .../file-thumbnail.component.html | 2 +- .../file-thumbnail.component.ts | 9 +- .../input/tag-input/tag-input.component.ts | 16 +- .../edit-repository-dialog.component.ts | 7 +- .../repository-form.component.ts | 6 +- .../repository/repository.module.ts | 2 +- .../file-import/file-import.component.ts | 2 +- .../filesystem-import.component.ts | 4 +- .../editable-metadata-entry.component.html | 2 +- .../editable-metadata-entry.component.ts | 18 +- .../file-metadata.component.html | 12 +- .../file-metadata/file-metadata.component.ts | 30 +++- .../file-search/file-search.component.ts | 12 +- .../filter-dialog/filter-dialog.component.ts | 22 +-- .../tag-filter-list-item.component.ts | 6 +- .../sort-dialog/sort-dialog.component.ts | 15 +- .../shared/sidebar/sidebar.module.ts | 3 - .../sidebar/tag-edit/tag-edit.component.ts | 25 +-- .../shared/tag/tag-item/tag-item.component.ts | 2 +- mediarepo-ui/src/app/models/AppState.ts | 4 +- mediarepo-ui/src/app/models/File.ts | 14 -- mediarepo-ui/src/app/models/FileOsMetadata.ts | 7 - .../{FilterExpression.ts => GenericFilter.ts} | 31 ++-- mediarepo-ui/src/app/models/Namespace.ts | 4 - mediarepo-ui/src/app/models/Repository.ts | 9 - mediarepo-ui/src/app/models/SizeMetadata.ts | 11 -- mediarepo-ui/src/app/models/SortKey.ts | 6 +- mediarepo-ui/src/app/models/TabState.ts | 29 ++-- mediarepo-ui/src/app/models/Tag.ts | 18 -- mediarepo-ui/src/app/models/Thumbnail.ts | 6 - .../error-broker/error-broker.service.ts | 8 +- .../src/app/services/file/file.helper.ts | 13 +- .../src/app/services/file/file.service.ts | 42 ++--- .../src/app/services/import/import.service.ts | 13 +- .../services/repository/repository.service.ts | 52 +++--- .../scheduling/scheduling.service.spec.ts | 22 +-- .../services/scheduling/scheduling.service.ts | 10 +- .../src/app/services/state/state.service.ts | 18 +- .../src/app/services/tag/tag.service.ts | 34 ++-- 78 files changed, 908 insertions(+), 459 deletions(-) create mode 100644 mediarepo-ui/src/api/Api.ts create mode 100644 mediarepo-ui/src/api/api-types/files.ts create mode 100644 mediarepo-ui/src/api/api-types/functions.ts create mode 100644 mediarepo-ui/src/api/api-types/repo.ts create mode 100644 mediarepo-ui/src/api/api-types/requests.ts create mode 100644 mediarepo-ui/src/api/api-types/tags.ts create mode 100644 mediarepo-ui/src/api/models/File.ts create mode 100644 mediarepo-ui/src/api/models/Namespace.ts create mode 100644 mediarepo-ui/src/api/models/Repository.ts create mode 100644 mediarepo-ui/src/api/models/Tag.ts create mode 100644 mediarepo-ui/src/api/models/adaptors.ts delete mode 100644 mediarepo-ui/src/app/models/File.ts delete mode 100644 mediarepo-ui/src/app/models/FileOsMetadata.ts rename mediarepo-ui/src/app/models/{FilterExpression.ts => GenericFilter.ts} (70%) delete mode 100644 mediarepo-ui/src/app/models/Namespace.ts delete mode 100644 mediarepo-ui/src/app/models/Repository.ts delete mode 100644 mediarepo-ui/src/app/models/SizeMetadata.ts delete mode 100644 mediarepo-ui/src/app/models/Tag.ts delete mode 100644 mediarepo-ui/src/app/models/Thumbnail.ts diff --git a/mediarepo-ui/.eslintrc.json b/mediarepo-ui/.eslintrc.json index 5c694cf..a82c42c 100644 --- a/mediarepo-ui/.eslintrc.json +++ b/mediarepo-ui/.eslintrc.json @@ -1,52 +1,66 @@ { - "root": true, - "ignorePatterns": [ - "projects/**/*" - ], - "overrides": [ - { - "files": [ - "*.ts" - ], - "parserOptions": { - "project": [ - "tsconfig.json" - ], - "createDefaultProgram": true - }, - "extends": [ - "plugin:@angular-eslint/recommended", - "plugin:@angular-eslint/template/process-inline-templates" - ], - "rules": { - "@angular-eslint/directive-selector": [ - "error", - { - "type": "attribute", - "prefix": "app", - "style": "camelCase" - } - ], - "@angular-eslint/component-selector": [ - "error", - { - "type": "element", - "prefix": "app", - "style": "kebab-case" - } - ], - "quotes": ["warn", "double", {"avoidEscape": true}], - "indent": ["error", 4, {"SwitchCase": 1}] - } - }, - { - "files": [ - "*.html" - ], - "extends": [ - "plugin:@angular-eslint/template/recommended" - ], - "rules": {} - } - ] + "root": true, + "ignorePatterns": [ + "projects/**/*" + ], + "overrides": [ + { + "files": [ + "*.ts" + ], + "parserOptions": { + "project": [ + "tsconfig.json" + ], + "createDefaultProgram": true + }, + "extends": [ + "plugin:@angular-eslint/recommended", + "plugin:@angular-eslint/template/process-inline-templates" + ], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "app", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "app", + "style": "kebab-case" + } + ], + "quotes": [ + "warn", + "double", + { + "avoidEscape": true + } + ], + "indent": [ + "error", + 4, + { + "SwitchCase": 1 + } + ], + "no-unused-expressions": "warn", + "semi": "error" + } + }, + { + "files": [ + "*.html" + ], + "extends": [ + "plugin:@angular-eslint/template/recommended" + ], + "rules": {} + } + ] } diff --git a/mediarepo-ui/src-tauri/Cargo.lock b/mediarepo-ui/src-tauri/Cargo.lock index 633f381..af2b101 100644 --- a/mediarepo-ui/src-tauri/Cargo.lock +++ b/mediarepo-ui/src-tauri/Cargo.lock @@ -1489,8 +1489,8 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "mediarepo-api" -version = "0.20.0" -source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=0c897acfd959c776fc10bd8fabdd2eb22b437be3#0c897acfd959c776fc10bd8fabdd2eb22b437be3" +version = "0.24.1" +source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=91d8182548bfdb19f2de9afd8c29d5c8ebd48993#91d8182548bfdb19f2de9afd8c29d5c8ebd48993" dependencies = [ "async-trait", "bromine", diff --git a/mediarepo-ui/src-tauri/Cargo.toml b/mediarepo-ui/src-tauri/Cargo.toml index 2b90f94..7ebae95 100644 --- a/mediarepo-ui/src-tauri/Cargo.toml +++ b/mediarepo-ui/src-tauri/Cargo.toml @@ -25,7 +25,7 @@ features = [ "env-filter" ] [dependencies.mediarepo-api] git = "https://github.com/Trivernis/mediarepo-api.git" -rev = "0c897acfd959c776fc10bd8fabdd2eb22b437be3" +rev = "91d8182548bfdb19f2de9afd8c29d5c8ebd48993" features = [ "tauri-plugin" ] [features] diff --git a/mediarepo-ui/src/api/Api.ts b/mediarepo-ui/src/api/Api.ts new file mode 100644 index 0000000..d0e6456 --- /dev/null +++ b/mediarepo-ui/src/api/Api.ts @@ -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 { + return this.invokePlugin(ApiFunction.HasExecutable); + } + + public static async getRepositories(): Promise { + return this.invokePlugin(ApiFunction.GetRepositories); + } + + public static async selectRepository(request: SelectRepositoryRequest): Promise { + return this.invokePlugin(ApiFunction.SelectRepository, request); + } + + public static async disconnectRepository(): Promise { + return this.invokePlugin(ApiFunction.DisconnectRepository); + } + + public static async closeLocalRepository(): Promise { + return this.invokePlugin(ApiFunction.CloseLocalRepository); + } + + public static async addRepository(request: AddRepositoryRequest): Promise { + return this.invokePlugin(ApiFunction.AddRepository, request); + } + + public static async checkDaemonRunning(request: CheckDaemonRunningRequest): Promise { + return this.invokePlugin(ApiFunction.CheckDaemonRunning, request); + } + + public static async checkLocalRepositoryExists(request: CheckLocalRepositoryExistsRequest): Promise { + return this.invokePlugin(ApiFunction.CheckLocalRepositoryExists, request); + } + + public static async removeRepository(request: RemoveRepositoryRequest): Promise { + return this.invokePlugin(ApiFunction.RemoveRepository, request); + } + + public static async deleteRepository(request: DeleteRepositoryRequest): Promise { + return this.invokePlugin(ApiFunction.DeleteRepository, request); + } + + public static async startDaemon(request: StartDaemonRequest): Promise { + return this.invokePlugin(ApiFunction.StartDaemon, request); + } + + public static async initRepository(request: InitRepositoryRequest): Promise { + return this.invokePlugin(ApiFunction.InitRepository, request); + } + + public static async getRepositoryMetadata(): Promise { + return this.invokePlugin(ApiFunction.GetRepoMetadata); + } + + public static async getSize(request: GetSizeRequest): Promise { + return this.invokePlugin(ApiFunction.GetSize, request); + } + + public static async getActiveRepository(): Promise { + return this.invokePlugin(ApiFunction.GetActiveRepository); + } + + public static async getAllFiles(): Promise { + return this.invokePlugin(ApiFunction.GetAllFiles); + } + + public static async findFiles(request: FindFilesRequest): Promise { + return this.invokePlugin(ApiFunction.FindFiles, request); + } + + public static async getFileMetadata(request: GetFileMetadataRequest): Promise { + return this.invokePlugin(ApiFunction.GetFileMetadata, request); + } + + public static async updateFileName(request: UpdateFileNameRequest): Promise { + return this.invokePlugin(ApiFunction.UpdateFileName, request); + } + + public static async saveFileLocally(request: SaveFileRequest): Promise { + return this.invokePlugin(ApiFunction.SaveFileLocally, request); + } + + public static async deleteThumbnails(request: DeleteThumbnailsRequest): Promise { + return this.invokePlugin(ApiFunction.DeleteThumbnails, request); + } + + public static async readFile(request: ReadFileRequest): Promise { + return this.invokePlugin(ApiFunction.ReadFile, request); + } + + public static async getAllTags(): Promise { + return this.invokePlugin(ApiFunction.GetAllTags); + } + + public static async getAllNamespaces(): Promise { + return this.invokePlugin(ApiFunction.GetAllNamespace); + } + + public static async getTagsForFiles(request: GetTagsForFilesRequest): Promise { + return this.invokePlugin(ApiFunction.GetTagsForFiles, request); + } + + public static async createTags(request: CreateTagsRequest): Promise { + return this.invokePlugin(ApiFunction.CreateTags, request); + } + + public static async changeFileTags(request: ChangeFileTagsRequest): Promise { + return this.invokePlugin(ApiFunction.ChangeFileTags, request); + } + + public static async resolvePathsToFiles(request: ResolvePathsToFilesRequest): Promise { + return this.invokePlugin(ApiFunction.ResolvePathsToFiles, request); + } + + public static async addLocalFile(request: AddLocalFileREquest): Promise { + return this.invokePlugin(ApiFunction.AddLocalFile, request); + } + + public static async getFrontendState(): Promise { + return this.invokePlugin(ApiFunction.GetFrontendState); + } + + public static async setFrontendState(request: SetFrontendStateRequest): Promise { + return this.invokePlugin(ApiFunction.SetFrontendState, request); + } + + private static async invokePlugin(fn: ApiFunction, args?: any): Promise { + return invoke(`plugin:mediarepo|${fn}`, args); + } +} diff --git a/mediarepo-ui/src/api/api-types/files.ts b/mediarepo-ui/src/api/api-types/files.ts new file mode 100644 index 0000000..0c58eb7 --- /dev/null +++ b/mediarepo-ui/src/api/api-types/files.ts @@ -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, +}; diff --git a/mediarepo-ui/src/api/api-types/functions.ts b/mediarepo-ui/src/api/api-types/functions.ts new file mode 100644 index 0000000..f26d9bf --- /dev/null +++ b/mediarepo-ui/src/api/api-types/functions.ts @@ -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", +} diff --git a/mediarepo-ui/src/api/api-types/repo.ts b/mediarepo-ui/src/api/api-types/repo.ts new file mode 100644 index 0000000..2487ac0 --- /dev/null +++ b/mediarepo-ui/src/api/api-types/repo.ts @@ -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, +} diff --git a/mediarepo-ui/src/api/api-types/requests.ts b/mediarepo-ui/src/api/api-types/requests.ts new file mode 100644 index 0000000..3015171 --- /dev/null +++ b/mediarepo-ui/src/api/api-types/requests.ts @@ -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 +}; diff --git a/mediarepo-ui/src/api/api-types/tags.ts b/mediarepo-ui/src/api/api-types/tags.ts new file mode 100644 index 0000000..6b81aba --- /dev/null +++ b/mediarepo-ui/src/api/api-types/tags.ts @@ -0,0 +1,10 @@ +export type TagData = { + id: number, + namespace?: string, + name: string, +}; + +export type NamespaceData = { + id: number, + name: string, +}; diff --git a/mediarepo-ui/src/api/models/File.ts b/mediarepo-ui/src/api/models/File.ts new file mode 100644 index 0000000..84c5a8f --- /dev/null +++ b/mediarepo-ui/src/api/models/File.ts @@ -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; + } +} diff --git a/mediarepo-ui/src/api/models/Namespace.ts b/mediarepo-ui/src/api/models/Namespace.ts new file mode 100644 index 0000000..c211ccf --- /dev/null +++ b/mediarepo-ui/src/api/models/Namespace.ts @@ -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; + } +} diff --git a/mediarepo-ui/src/api/models/Repository.ts b/mediarepo-ui/src/api/models/Repository.ts new file mode 100644 index 0000000..9eb5ed6 --- /dev/null +++ b/mediarepo-ui/src/api/models/Repository.ts @@ -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); + } +} diff --git a/mediarepo-ui/src/api/models/Tag.ts b/mediarepo-ui/src/api/models/Tag.ts new file mode 100644 index 0000000..3fc9640 --- /dev/null +++ b/mediarepo-ui/src/api/models/Tag.ts @@ -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; + } +} diff --git a/mediarepo-ui/src/api/models/adaptors.ts b/mediarepo-ui/src/api/models/adaptors.ts new file mode 100644 index 0000000..05adcd2 --- /dev/null +++ b/mediarepo-ui/src/api/models/adaptors.ts @@ -0,0 +1,11 @@ +export function mapOptional(mapFn: (value: I) => O): (value: I | undefined) => O | undefined { + return (value: I | undefined) => value ? mapFn(value) : undefined; +} + +export function mapMany(mapFn: (value: I) => O): (value: I[]) => O[] { + return (value: I[]) => value.map(mapFn); +} + +export function mapNew(classType: new (value: V) => T): (value: V) => T { + return (value: V) => new classType(value); +} diff --git a/mediarepo-ui/src/app/components/core/core.component.html b/mediarepo-ui/src/app/components/core/core.component.html index d7229de..0637827 100644 --- a/mediarepo-ui/src/app/components/core/core.component.html +++ b/mediarepo-ui/src/app/components/core/core.component.html @@ -1,7 +1,7 @@
- + diff --git a/mediarepo-ui/src/app/components/core/core.component.scss b/mediarepo-ui/src/app/components/core/core.component.scss index bf897f0..e4f50ca 100644 --- a/mediarepo-ui/src/app/components/core/core.component.scss +++ b/mediarepo-ui/src/app/components/core/core.component.scss @@ -34,10 +34,11 @@ mat-tab-group { float: right; position: absolute; right: 0; - top: 4px; + top: 0; + height: 100%; ng-icon { font-size: 1.5em; - margin-top: calc(-50% + 0.2em); + margin-top: calc(-50%); --ng-icon__size: 0.4em; } } diff --git a/mediarepo-ui/src/app/components/core/core.component.ts b/mediarepo-ui/src/app/components/core/core.component.ts index 716cb12..79d3b93 100644 --- a/mediarepo-ui/src/app/components/core/core.component.ts +++ b/mediarepo-ui/src/app/components/core/core.component.ts @@ -1,5 +1,5 @@ import {Component, ViewChild} from "@angular/core"; -import {Repository} from "../../models/Repository"; +import {Repository} from "../../../api/models/Repository"; import {RepositoryService} from "../../services/repository/repository.service"; import {MatTabChangeEvent, MatTabGroup} from "@angular/material/tabs"; import {TagService} from "../../services/tag/tag.service"; @@ -60,7 +60,7 @@ export class CoreComponent { this.addTab(); } }); - }) + }); } async loadRepoData() { diff --git a/mediarepo-ui/src/app/components/core/core.module.ts b/mediarepo-ui/src/app/components/core/core.module.ts index f771cbb..d3ffbc9 100644 --- a/mediarepo-ui/src/app/components/core/core.module.ts +++ b/mediarepo-ui/src/app/components/core/core.module.ts @@ -46,7 +46,9 @@ import { RepositoryModule } from "../shared/repository/repository/repository.module"; import {MatToolbarModule} from "@angular/material/toolbar"; -import { RepositoryDetailsViewComponent } from './repositories-tab/repository-details-view/repository-details-view.component'; +import { + RepositoryDetailsViewComponent +} from "./repositories-tab/repository-details-view/repository-details-view.component"; @NgModule({ diff --git a/mediarepo-ui/src/app/components/core/files-tab/files-tab-sidebar/files-tab-sidebar.component.ts b/mediarepo-ui/src/app/components/core/files-tab/files-tab-sidebar/files-tab-sidebar.component.ts index 10ca564..ff3a8d9 100644 --- a/mediarepo-ui/src/app/components/core/files-tab/files-tab-sidebar/files-tab-sidebar.component.ts +++ b/mediarepo-ui/src/app/components/core/files-tab/files-tab-sidebar/files-tab-sidebar.component.ts @@ -8,9 +8,9 @@ import { SimpleChanges, ViewChild } from "@angular/core"; -import {Tag} from "../../../../models/Tag"; +import {Tag} from "../../../../../api/models/Tag"; import {TagService} from "../../../../services/tag/tag.service"; -import {File} from "../../../../models/File"; +import {File} from "../../../../../api/models/File"; import { FileSearchComponent } from "../../../shared/sidebar/file-search/file-search.component"; @@ -53,7 +53,7 @@ export class FilesTabSidebarComponent implements OnInit, OnChanges { this.state.files.subscribe(async (files) => { this.files = files; await this.onDisplayedFilesChange(); - }) + }); if (this.fileSearch) { await this.fileSearch.searchForFiles(); } @@ -76,13 +76,13 @@ export class FilesTabSidebarComponent implements OnInit, OnChanges { async loadTagsForDisplayedFiles() { this.tagsOfFiles = await this.tagService.getTagsForFiles( - this.files.map(f => f.hash)); + this.files.map(f => f.cd)); this.showAllTagsFallback(); } async showFileDetails(files: File[]) { this.tagsOfSelection = await this.tagService.getTagsForFiles( - files.map(f => f.hash)) + files.map(f => f.cd)); this.tagsOfSelection = this.tagsOfSelection.sort( (a, b) => a.getNormalizedOutput() .localeCompare(b.getNormalizedOutput())); diff --git a/mediarepo-ui/src/app/components/core/files-tab/files-tab.component.ts b/mediarepo-ui/src/app/components/core/files-tab/files-tab.component.ts index 73e3e34..a64a857 100644 --- a/mediarepo-ui/src/app/components/core/files-tab/files-tab.component.ts +++ b/mediarepo-ui/src/app/components/core/files-tab/files-tab.component.ts @@ -1,5 +1,5 @@ import {Component, Input, OnInit} from "@angular/core"; -import {File} from "../../../models/File"; +import {File} from "../../../../api/models/File"; import {TabState} from "../../../models/TabState"; @Component({ @@ -26,17 +26,17 @@ export class FilesTabComponent implements OnInit { async onFileSelect(files: File[]) { this.selectedFiles = files; if (files.length === 1) { - this.state.selectedFileHash.next(files[0].hash); + this.state.selectedCD.next(files[0].cd); } else { - this.state.selectedFileHash.next(undefined); + this.state.selectedCD.next(undefined); } } public getStateSelectedFile(): File | undefined { - const hash = this.state.selectedFileHash.value; + const hash = this.state.selectedCD.value; if (hash) { - return this.files.find(f => f.hash === hash); + return this.files.find(f => f.cd === hash); } else { return undefined; } @@ -45,7 +45,7 @@ export class FilesTabComponent implements OnInit { public async onKeydown(event: KeyboardEvent) { switch (event.key) { case "F5": - await this.state.findFiles() + await this.state.findFiles(); break; } } diff --git a/mediarepo-ui/src/app/components/core/import-tab/import-tab-sidebar/import-tab-sidebar.component.ts b/mediarepo-ui/src/app/components/core/import-tab/import-tab-sidebar/import-tab-sidebar.component.ts index af49e8f..a9b6b32 100644 --- a/mediarepo-ui/src/app/components/core/import-tab/import-tab-sidebar/import-tab-sidebar.component.ts +++ b/mediarepo-ui/src/app/components/core/import-tab/import-tab-sidebar/import-tab-sidebar.component.ts @@ -1,5 +1,5 @@ import {Component, EventEmitter, Input, Output} from "@angular/core"; -import {File} from "../../../../models/File"; +import {File} from "../../../../../api/models/File"; @Component({ selector: "app-import-tab-sidebar", diff --git a/mediarepo-ui/src/app/components/core/import-tab/import-tab.component.ts b/mediarepo-ui/src/app/components/core/import-tab/import-tab.component.ts index 1f74164..1cee62d 100644 --- a/mediarepo-ui/src/app/components/core/import-tab/import-tab.component.ts +++ b/mediarepo-ui/src/app/components/core/import-tab/import-tab.component.ts @@ -1,5 +1,5 @@ import {Component, Input, OnInit} from "@angular/core"; -import {File} from "../../../models/File"; +import {File} from "../../../../api/models/File"; import {TabState} from "../../../models/TabState"; @Component({ @@ -47,17 +47,17 @@ export class ImportTabComponent implements OnInit { public onFileSelect(files: File[]) { this.selectedFiles = files; if (files.length === 1) { - this.state.selectedFileHash.next(files[0].hash); + this.state.selectedCD.next(files[0].cd); } else { - this.state.selectedFileHash.next(undefined); + this.state.selectedCD.next(undefined); } } public getSelectedFileFromState(): File | undefined { - const selectedHash = this.state.selectedFileHash.value; + const selectedHash = this.state.selectedCD.value; if (selectedHash && this.files) { - return this.files.find(f => f.hash === selectedHash); + return this.files.find(f => f.cd === selectedHash); } else { return undefined; } diff --git a/mediarepo-ui/src/app/components/core/repositories-tab/download-daemon-dialog/download-daemon-dialog.component.ts b/mediarepo-ui/src/app/components/core/repositories-tab/download-daemon-dialog/download-daemon-dialog.component.ts index 957a8f8..a66d319 100644 --- a/mediarepo-ui/src/app/components/core/repositories-tab/download-daemon-dialog/download-daemon-dialog.component.ts +++ b/mediarepo-ui/src/app/components/core/repositories-tab/download-daemon-dialog/download-daemon-dialog.component.ts @@ -20,6 +20,6 @@ export class DownloadDaemonDialogComponent { } closeDialog(result: boolean) { - this.dialogRef.close(result) + this.dialogRef.close(result); } } diff --git a/mediarepo-ui/src/app/components/core/repositories-tab/repositories-tab.component.ts b/mediarepo-ui/src/app/components/core/repositories-tab/repositories-tab.component.ts index d377166..7fc543c 100644 --- a/mediarepo-ui/src/app/components/core/repositories-tab/repositories-tab.component.ts +++ b/mediarepo-ui/src/app/components/core/repositories-tab/repositories-tab.component.ts @@ -1,5 +1,5 @@ import {AfterViewInit, Component, OnInit} from "@angular/core"; -import {Repository} from "../../../models/Repository"; +import {Repository} from "../../../../api/models/Repository"; import { RepositoryService } from "../../../services/repository/repository.service"; diff --git a/mediarepo-ui/src/app/components/core/repositories-tab/repository-card/repository-card.component.ts b/mediarepo-ui/src/app/components/core/repositories-tab/repository-card/repository-card.component.ts index 0c70358..d364753 100644 --- a/mediarepo-ui/src/app/components/core/repositories-tab/repository-card/repository-card.component.ts +++ b/mediarepo-ui/src/app/components/core/repositories-tab/repository-card/repository-card.component.ts @@ -1,5 +1,5 @@ import {Component, Input, OnDestroy, OnInit, ViewChild} from "@angular/core"; -import {Repository} from "../../../../models/Repository"; +import {Repository} from "../../../../../api/models/Repository"; import { RepositoryService } from "../../../../services/repository/repository.service"; @@ -52,7 +52,7 @@ export class RepositoryCardComponent implements OnInit, OnDestroy { } public isSelectedRepository(): boolean { - return this.repoService.selectedRepository.getValue()?.name === this.repository.name + return this.repoService.selectedRepository.getValue()?.name === this.repository.name; } public async removeRepository() { @@ -124,7 +124,7 @@ export class RepositoryCardComponent implements OnInit, OnDestroy { await this.repoService.startDaemon(this.repository.path!); this.daemonRunning = true; await new Promise((res, _) => { - setTimeout(res, 2000) // wait for the daemon to start + setTimeout(res, 2000); // wait for the daemon to start }); } await this.selectRepository(); @@ -156,6 +156,6 @@ export class RepositoryCardComponent implements OnInit, OnDestroy { data: { repository: this.repository } - }) + }); } } diff --git a/mediarepo-ui/src/app/components/core/repositories-tab/repository-details-view/repository-details-view.component.spec.ts b/mediarepo-ui/src/app/components/core/repositories-tab/repository-details-view/repository-details-view.component.spec.ts index 2b105dc..7791c6f 100644 --- a/mediarepo-ui/src/app/components/core/repositories-tab/repository-details-view/repository-details-view.component.spec.ts +++ b/mediarepo-ui/src/app/components/core/repositories-tab/repository-details-view/repository-details-view.component.spec.ts @@ -1,25 +1,27 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import {ComponentFixture, TestBed} from "@angular/core/testing"; -import { RepositoryDetailsViewComponent } from './repository-details-view.component'; +import { + RepositoryDetailsViewComponent +} from "./repository-details-view.component"; -describe('RepositoryDetailsViewComponent', () => { - let component: RepositoryDetailsViewComponent; - let fixture: ComponentFixture; +describe("RepositoryDetailsViewComponent", () => { + let component: RepositoryDetailsViewComponent; + let fixture: ComponentFixture; - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ RepositoryDetailsViewComponent ] - }) - .compileComponents(); - }); + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ RepositoryDetailsViewComponent ] + }) + .compileComponents(); + }); - beforeEach(() => { - fixture = TestBed.createComponent(RepositoryDetailsViewComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + beforeEach(() => { + fixture = TestBed.createComponent(RepositoryDetailsViewComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); - it('should create', () => { - expect(component).toBeTruthy(); - }); + it("should create", () => { + expect(component).toBeTruthy(); + }); }); diff --git a/mediarepo-ui/src/app/components/core/repositories-tab/repository-details-view/repository-details-view.component.ts b/mediarepo-ui/src/app/components/core/repositories-tab/repository-details-view/repository-details-view.component.ts index 23a861e..2ae64da 100644 --- a/mediarepo-ui/src/app/components/core/repositories-tab/repository-details-view/repository-details-view.component.ts +++ b/mediarepo-ui/src/app/components/core/repositories-tab/repository-details-view/repository-details-view.component.ts @@ -6,13 +6,12 @@ import { OnInit, SimpleChanges } from "@angular/core"; -import {Repository} from "../../../../models/Repository"; +import {Repository} from "../../../../../api/models/Repository"; import { RepositoryService } from "../../../../services/repository/repository.service"; import {RepositoryMetadata} from "../../../../models/RepositoryMetadata"; import {BehaviorSubject} from "rxjs"; -import {SizeType} from "../../../../models/SizeMetadata"; @Component({ selector: "app-repository-details-view", @@ -57,13 +56,13 @@ export class RepositoryDetailsViewComponent implements OnInit, OnChanges, OnDest } public async getSizes() { - const totalSize = await this.repoService.getSize(SizeType.Total) + const totalSize = await this.repoService.getSize("Total"); this.totalSize.next(this.formatByteSize(totalSize.size)); - const fileSize = await this.repoService.getSize(SizeType.FileFolder); + const fileSize = await this.repoService.getSize("FileFolder"); this.fileFolderSize.next(this.formatByteSize(fileSize.size)); - const thumbSize = await this.repoService.getSize(SizeType.ThumbFolder); + const thumbSize = await this.repoService.getSize("ThumbFolder"); this.thumbFolderSize.next(this.formatByteSize(thumbSize.size)); - const databaseSize = await this.repoService.getSize(SizeType.DatabaseFile); + const databaseSize = await this.repoService.getSize("DatabaseFile"); this.databaseFileSize.next(this.formatByteSize(databaseSize.size)); } @@ -82,7 +81,7 @@ export class RepositoryDetailsViewComponent implements OnInit, OnChanges, OnDest } else if (size >= kib) { return (size / kib).toFixed(2) + " KiB"; } else { - return size + " B" + return size + " B"; } } diff --git a/mediarepo-ui/src/app/components/shared/app-common/app-common.module.ts b/mediarepo-ui/src/app/components/shared/app-common/app-common.module.ts index 413538c..e05c03d 100644 --- a/mediarepo-ui/src/app/components/shared/app-common/app-common.module.ts +++ b/mediarepo-ui/src/app/components/shared/app-common/app-common.module.ts @@ -15,7 +15,9 @@ import {MatMenuModule} from "@angular/material/menu"; import { ContentAwareImageComponent } from "./content-aware-image/content-aware-image.component"; -import { InputReceiverDirective } from "./input-receiver/input-receiver.directive"; +import { + InputReceiverDirective +} from "./input-receiver/input-receiver.directive"; import { MetadataEntryComponent } from "./metadata-entry/metadata-entry.component"; diff --git a/mediarepo-ui/src/app/components/shared/app-common/busy-indicator/busy-indicator.component.ts b/mediarepo-ui/src/app/components/shared/app-common/busy-indicator/busy-indicator.component.ts index 2926520..89e9f09 100644 --- a/mediarepo-ui/src/app/components/shared/app-common/busy-indicator/busy-indicator.component.ts +++ b/mediarepo-ui/src/app/components/shared/app-common/busy-indicator/busy-indicator.component.ts @@ -22,7 +22,7 @@ export class BusyIndicatorComponent { } public wrapOperation(operation: Function): T | undefined { - this.setBusy(true) + this.setBusy(true); try { const result = operation(); this.setBusy(false); @@ -35,7 +35,7 @@ export class BusyIndicatorComponent { } public async wrapAsyncOperation(operation: Function): Promise { - this.setBusy(true) + this.setBusy(true); try { const result = await operation(); this.setBusy(false); diff --git a/mediarepo-ui/src/app/components/shared/app-common/input-receiver/input-receiver.directive.spec.ts b/mediarepo-ui/src/app/components/shared/app-common/input-receiver/input-receiver.directive.spec.ts index 37946f5..d40b81f 100644 --- a/mediarepo-ui/src/app/components/shared/app-common/input-receiver/input-receiver.directive.spec.ts +++ b/mediarepo-ui/src/app/components/shared/app-common/input-receiver/input-receiver.directive.spec.ts @@ -1,8 +1,8 @@ -import { InputReceiverDirective } from './input-receiver.directive'; +import {InputReceiverDirective} from "./input-receiver.directive"; -describe('InputReceiverDirective', () => { - it('should create an instance', () => { - const directive = new InputReceiverDirective(); - expect(directive).toBeTruthy(); - }); +describe("InputReceiverDirective", () => { + it("should create an instance", () => { + const directive = new InputReceiverDirective(); + expect(directive).toBeTruthy(); + }); }); 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 09dca58..8077d88 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 @@ -3,7 +3,7 @@
- Unsupported content type {{this.file.mime_type}} + 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 d99acc3..e6400cb 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 @@ -8,7 +8,7 @@ import { ViewChild } from "@angular/core"; import {SafeResourceUrl} from "@angular/platform-browser"; -import {File} from "../../../../models/File"; +import {File} from "../../../../../api/models/File"; import {FileService} from "../../../../services/file/file.service"; import {FileHelper} from "../../../../services/file/file.helper"; import { @@ -64,10 +64,7 @@ export class ContentViewerComponent implements AfterViewInit, OnChanges, OnDestr } public getContentType(): ContentType { - if (!this.file.mime_type) { - return "other"; - } - let mimeParts = this.file.mime_type.split("/"); + let mimeParts = this.file.mimeType.split("/"); const type = mimeParts.shift() ?? "other"; const subtype = mimeParts.shift() ?? "*"; @@ -84,7 +81,7 @@ export class ContentViewerComponent implements AfterViewInit, OnChanges, OnDestr } public async downloadContent() { - const path = await FileHelper.getFileDownloadLocation(this.file) + const path = await FileHelper.getFileDownloadLocation(this.file); if (path) { try { diff --git a/mediarepo-ui/src/app/components/shared/file/content-viewer/image-viewer/image-viewer.component.ts b/mediarepo-ui/src/app/components/shared/file/content-viewer/image-viewer/image-viewer.component.ts index a0a008e..539b8a4 100644 --- a/mediarepo-ui/src/app/components/shared/file/content-viewer/image-viewer/image-viewer.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/content-viewer/image-viewer/image-viewer.component.ts @@ -54,12 +54,12 @@ export class ImageViewerComponent implements OnChanges { const delta = event.wheelDelta ?? event.detail; if (delta > 0) { - this.imageZoom += 0.2 + this.imageZoom += 0.2; if (this.imageZoom > 4) { this.imageZoom = 4; } } else if (delta < 0) { - this.imageZoom -= 0.2 + this.imageZoom -= 0.2; if (this.imageZoom < 0.5) { this.imageZoom = 0.5; } diff --git a/mediarepo-ui/src/app/components/shared/file/file-card/file-card.component.ts b/mediarepo-ui/src/app/components/shared/file/file-card/file-card.component.ts index f48a30e..e8064c8 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-card/file-card.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/file-card/file-card.component.ts @@ -10,7 +10,7 @@ import { SimpleChanges, ViewChild } from "@angular/core"; -import {File} from "../../../../models/File"; +import {File} from "../../../../../api/models/File"; import {Selectable} from "../../../../models/Selectable"; import { SchedulingService @@ -62,7 +62,7 @@ export class FileCardComponent implements OnInit, OnChanges, OnDestroy { this.workId = this.schedulingService.addWork(LOADING_WORK_KEY, async () => { await this.schedulingService.delay(1); - this.loading = false + this.loading = false; }); } } diff --git a/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.ts b/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.ts index b790239..b35ac01 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.ts @@ -1,5 +1,5 @@ import {Component, ViewChild} from "@angular/core"; -import {File} from "../../../../models/File"; +import {File} from "../../../../../api/models/File"; import { ContextMenuComponent } from "../../app-common/context-menu/context-menu.component"; @@ -30,11 +30,11 @@ export class FileContextMenuComponent { } public async copyFileHash(): Promise { - await clipboard.writeText(this.file.hash); + await clipboard.writeText(this.file.cd); } public async exportFile(): Promise { - const path = await FileHelper.getFileDownloadLocation(this.file) + const path = await FileHelper.getFileDownloadLocation(this.file); if (path) { try { diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts index d5dadb2..3fd2d13 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts @@ -1,8 +1,8 @@ import { - AfterContentInit, AfterViewInit, - Component, ElementRef, + AfterViewInit, + Component, + ElementRef, EventEmitter, - HostListener, Input, OnChanges, OnInit, @@ -10,7 +10,7 @@ import { SimpleChanges, ViewChild } from "@angular/core"; -import {File} from "../../../../../models/File"; +import {File} from "../../../../../../api/models/File"; import {FileService} from "../../../../../services/file/file.service"; import {SafeResourceUrl} from "@angular/platform-browser"; import {Selectable} from "../../../../../models/Selectable"; @@ -48,7 +48,7 @@ export class FileGalleryComponent implements OnChanges, OnInit, AfterViewInit { if (!this.selectedFile || this.files.indexOf( this.selectedFile.data) < 0) { await this.onEntrySelect( - this.getPreselectedEntry() ?? this.entries[0]) + this.getPreselectedEntry() ?? this.entries[0]); } } @@ -59,15 +59,15 @@ export class FileGalleryComponent implements OnChanges, OnInit, AfterViewInit { public async ngOnChanges(changes: SimpleChanges): Promise { if (changes["files"]) { this.entries = this.files.map( - f => new Selectable(f, f.hash == this.selectedFile?.data.hash)); + f => new Selectable(f, f.id == this.selectedFile?.data.id)); const selectedIndex = this.files.findIndex( - f => f.hash === this.selectedFile?.data.hash); + f => f.id === this.selectedFile?.data.id); if (!this.selectedFile || selectedIndex < 0) { await this.onEntrySelect( - this.getPreselectedEntry() ?? this.entries[0]) + this.getPreselectedEntry() ?? this.entries[0]); } else { - await this.onEntrySelect(this.entries[selectedIndex]) + await this.onEntrySelect(this.entries[selectedIndex]); } } } @@ -101,7 +101,7 @@ export class FileGalleryComponent implements OnChanges, OnInit, AfterViewInit { async loadSelectedFile() { if (this.selectedFile) { this.fileContentUrl = this.fileService.buildContentUrl( - this.selectedFile.data) + this.selectedFile.data); } } @@ -117,7 +117,7 @@ export class FileGalleryComponent implements OnChanges, OnInit, AfterViewInit { } await this.onEntrySelect(this.entries[index]); } else { - await this.onEntrySelect(this.entries[0]) + await this.onEntrySelect(this.entries[0]); } } @@ -133,7 +133,7 @@ export class FileGalleryComponent implements OnChanges, OnInit, AfterViewInit { } await this.onEntrySelect(this.entries[index]); } else { - await this.onEntrySelect(this.entries[0]) + await this.onEntrySelect(this.entries[0]); } } diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts index 52d1286..971dd1f 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts @@ -1,9 +1,8 @@ import { - AfterContentInit, AfterViewInit, + AfterViewInit, Component, ElementRef, EventEmitter, - HostListener, Input, OnChanges, OnInit, @@ -11,7 +10,7 @@ import { SimpleChanges, ViewChild } from "@angular/core"; -import {File} from "../../../../../models/File"; +import {File} from "../../../../../../api/models/File"; import {FileCardComponent} from "../../file-card/file-card.component"; import {CdkVirtualScrollViewport} from "@angular/cdk/scrolling"; import {TabService} from "../../../../../services/tab/tab.service"; @@ -73,7 +72,7 @@ export class FileGridComponent implements OnChanges, OnInit, AfterViewInit { setSelectedFile(clickedEntry: Selectable) { if (!(this.shiftClicked || this.ctrlClicked) && this.selectedEntries.length > 0) { this.selectedEntries.forEach(entry => { - if (entry !== clickedEntry) entry.selected = false + if (entry !== clickedEntry) entry.selected = false; }); this.selectedEntries = []; } @@ -199,11 +198,11 @@ export class FileGridComponent implements OnChanges, OnInit, AfterViewInit { selectedIndex --; break; case "right": - selectedIndex++ + selectedIndex++; break; } while (selectedIndex < 0) { - selectedIndex = this.gridEntries.length + selectedIndex + selectedIndex = this.gridEntries.length + selectedIndex; } if (selectedIndex > this.gridEntries.length) { selectedIndex %= this.gridEntries.length; @@ -222,7 +221,7 @@ export class FileGridComponent implements OnChanges, OnInit, AfterViewInit { offsetTop = this.virtualScroll.measureScrollOffset("top"); if (contentOffset < offsetTop + (viewportSize / 2)) { - this.virtualScroll.scrollToOffset((offsetTop + 130) - viewportSize/ 2) + this.virtualScroll.scrollToOffset((offsetTop + 130) - viewportSize/ 2); } } } @@ -266,7 +265,7 @@ export class FileGridComponent implements OnChanges, OnInit, AfterViewInit { break; case "Enter": if (this.selectedEntries.length === 1) { - this.fileOpenEvent.emit(this.selectedEntries[0].data) + this.fileOpenEvent.emit(this.selectedEntries[0].data); } break; } diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-multiview.component.html b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-multiview.component.html index 031048b..fb61522 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-multiview.component.html +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-multiview.component.html @@ -1,7 +1,7 @@ - - diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-multiview.component.ts b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-multiview.component.ts index 908391b..93d54ea 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-multiview.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-multiview.component.ts @@ -1,13 +1,12 @@ import { - AfterViewChecked, AfterViewInit, + AfterViewInit, Component, - ElementRef, EventEmitter, Input, Output, ViewChild } from "@angular/core"; -import {File} from "../../../../models/File"; +import {File} from "../../../../../api/models/File"; import {FileGalleryComponent} from "./file-gallery/file-gallery.component"; import {FileGridComponent} from "./file-grid/file-grid.component"; @@ -36,7 +35,7 @@ export class FileMultiviewComponent implements AfterViewInit { public ngAfterViewInit(): void { if (this.preselectedFile) { - this.fileSelectEvent.emit([this.preselectedFile]) + this.fileSelectEvent.emit([this.preselectedFile]); this.selectedFiles = [this.preselectedFile]; } } @@ -59,7 +58,7 @@ export class FileMultiviewComponent implements AfterViewInit { public onFileOpen(file: File): void { this.preselectedFile = file; - this.setMode("gallery") + this.setMode("gallery"); this.fileOpenEvent.emit(file); } diff --git a/mediarepo-ui/src/app/components/shared/file/file-thumbnail/file-thumbnail.component.html b/mediarepo-ui/src/app/components/shared/file/file-thumbnail/file-thumbnail.component.html index e238923..f62b67a 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-thumbnail/file-thumbnail.component.html +++ b/mediarepo-ui/src/app/components/shared/file/file-thumbnail/file-thumbnail.component.html @@ -2,7 +2,7 @@ borderRadius="0.25em">
- +
diff --git a/mediarepo-ui/src/app/components/shared/file/file-thumbnail/file-thumbnail.component.ts b/mediarepo-ui/src/app/components/shared/file/file-thumbnail/file-thumbnail.component.ts index e17da1e..8979313 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-thumbnail/file-thumbnail.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/file-thumbnail/file-thumbnail.component.ts @@ -5,13 +5,10 @@ import { OnChanges, SimpleChanges } from "@angular/core"; -import {File} from "../../../../models/File"; +import {File} from "../../../../../api/models/File"; import {FileService} from "../../../../services/file/file.service"; import {FileHelper} from "../../../../services/file/file.helper"; import {SafeResourceUrl} from "@angular/platform-browser"; -import { - SchedulingService -} from "../../../../services/scheduling/scheduling.service"; @Component({ selector: "app-file-thumbnail", @@ -41,14 +38,14 @@ export class FileThumbnailComponent implements OnChanges, AfterViewInit { } public getThumbnailSupported(): boolean { - const mimeParts = FileHelper.parseMime(this.file.mime_type); + const mimeParts = FileHelper.parseMime(this.file.mimeType); return !!mimeParts && this.supportedThumbnailTypes.includes( mimeParts[0]); } public getFileType(): string { - const mimeParts = FileHelper.parseMime(this.file.mime_type); + const mimeParts = FileHelper.parseMime(this.file.mimeType); return (mimeParts && mimeParts[0]) ?? "other"; } } diff --git a/mediarepo-ui/src/app/components/shared/input/tag-input/tag-input.component.ts b/mediarepo-ui/src/app/components/shared/input/tag-input/tag-input.component.ts index 91fe6da..2f12ee7 100644 --- a/mediarepo-ui/src/app/components/shared/input/tag-input/tag-input.component.ts +++ b/mediarepo-ui/src/app/components/shared/input/tag-input/tag-input.component.ts @@ -8,7 +8,7 @@ import { SimpleChanges, ViewChild } from "@angular/core"; -import {Tag} from "../../../../models/Tag"; +import {Tag} from "../../../../../api/models/Tag"; import {FormControl} from "@angular/forms"; import {MatAutocompleteSelectedEvent} from "@angular/material/autocomplete"; import {Observable} from "rxjs"; @@ -60,7 +60,7 @@ export class TagInputComponent implements OnChanges { } private addTag(value: string) { - const tag = this.normalizeTag(value); + const tag = TagInputComponent.normalizeTag(value); if (tag.length > 0 && (this.allowInvalid || this.checkTagValid(tag))) { this.tagAdded.emit(tag); this.formControl.setValue(""); @@ -69,7 +69,7 @@ export class TagInputComponent implements OnChanges { } private filterSuggestionTag(tag: string) { - let normalizedTag = this.normalizeTag(tag); + let normalizedTag = TagInputComponent.normalizeTag(tag); const negated = normalizedTag.startsWith("-") && this.allowNegation; normalizedTag = this.allowNegation ? normalizedTag.replace(/^-/, "") : normalizedTag; @@ -80,11 +80,11 @@ export class TagInputComponent implements OnChanges { const autocompleteTags = this.tagsForAutocomplete.filter( t => t.includes(normalizedTag)) .map(t => negated ? "-" + t : t) - .sort((l, r) => this.compareSuggestionTags(normalizedTag, l, r)) + .sort((l, r) => TagInputComponent.compareSuggestionTags(normalizedTag, l, r)) .slice(0, 50); if (containsWildcard) { - autocompleteTags.unshift(this.normalizeTag(tag)); + autocompleteTags.unshift(TagInputComponent.normalizeTag(tag)); } return autocompleteTags; @@ -111,7 +111,7 @@ export class TagInputComponent implements OnChanges { * @returns {string} * @private */ - private normalizeTag(tag: string): string { + private static normalizeTag(tag: string): string { let normalizedTag = tag.trim(); let parts = normalizedTag.split(":"); @@ -124,7 +124,7 @@ export class TagInputComponent implements OnChanges { } } - private compareSuggestionTags(query: string, l: string, r: string): number { + private static compareSuggestionTags(query: string, l: string, r: string): number { if (l.startsWith(query) && !r.startsWith(query)) { return -1; } else if (!l.startsWith(query) && r.startsWith(query)) { @@ -134,7 +134,7 @@ export class TagInputComponent implements OnChanges { } else if (l.length > r.length) { return 1; } else { - return l.localeCompare(r) + return l.localeCompare(r); } } } diff --git a/mediarepo-ui/src/app/components/shared/repository/repository/edit-repository-dialog/edit-repository-dialog.component.ts b/mediarepo-ui/src/app/components/shared/repository/repository/edit-repository-dialog/edit-repository-dialog.component.ts index 857c32f..406115b 100644 --- a/mediarepo-ui/src/app/components/shared/repository/repository/edit-repository-dialog/edit-repository-dialog.component.ts +++ b/mediarepo-ui/src/app/components/shared/repository/repository/edit-repository-dialog/edit-repository-dialog.component.ts @@ -9,7 +9,7 @@ import { ErrorBrokerService } from "../../../../../services/error-broker/error-broker.service"; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; -import {Repository} from "../../../../../models/Repository"; +import {Repository} from "../../../../../../api/models/Repository"; @Component({ selector: "app-edit-repository-dialog", @@ -62,10 +62,7 @@ export class EditRepositoryDialogComponent { } await this.repoService.addRepository(name, path, address, repositoryType === "local"); - this.selectedRepository.name = name; - this.selectedRepository.local = repositoryType === "local"; - this.selectedRepository.path = path; - this.selectedRepository.address = address; + this.selectedRepository.update({name, local: repositoryType === "local", path, address}); this.dialogRef.close(); } catch (err) { diff --git a/mediarepo-ui/src/app/components/shared/repository/repository/repository-form/repository-form.component.ts b/mediarepo-ui/src/app/components/shared/repository/repository/repository-form/repository-form.component.ts index 2a4ba02..161a73f 100644 --- a/mediarepo-ui/src/app/components/shared/repository/repository/repository-form/repository-form.component.ts +++ b/mediarepo-ui/src/app/components/shared/repository/repository/repository-form/repository-form.component.ts @@ -6,7 +6,7 @@ import { ValidationErrors, Validators } from "@angular/forms"; -import {Repository} from "../../../../../models/Repository"; +import {Repository} from "../../../../../../api/models/Repository"; import { RepositoryService } from "../../../../../services/repository/repository.service"; @@ -20,7 +20,7 @@ import {MatDialog} from "@angular/material/dialog"; }) export class RepositoryFormComponent implements OnInit { - @Input() name: string = "My Repository"; + @Input() name: string = "My RepositoryData"; @Input() repositoryType: "local" | "remote" = "local"; @Input() path: string = ""; @Input() address: string = ""; @@ -120,7 +120,7 @@ export class RepositoryFormComponent implements OnInit { "repositoryType")?.value ?? "remote"; if (repositoryType === "remote") { - const match = /(\d+\.){3}\d+:\d+|\S+:\d+/.test(control.value) + const match = /(\d+\.){3}\d+:\d+|\S+:\d+/.test(control.value); return match ? null : {invalidAddress: control.value}; } diff --git a/mediarepo-ui/src/app/components/shared/repository/repository/repository.module.ts b/mediarepo-ui/src/app/components/shared/repository/repository/repository.module.ts index 3f84742..dc53773 100644 --- a/mediarepo-ui/src/app/components/shared/repository/repository/repository.module.ts +++ b/mediarepo-ui/src/app/components/shared/repository/repository/repository.module.ts @@ -16,7 +16,7 @@ import {MatSelectModule} from "@angular/material/select"; import {MatInputModule} from "@angular/material/input"; import {ReactiveFormsModule} from "@angular/forms"; import {NgIconsModule} from "@ng-icons/core"; -import {MatFolder} from "@ng-icons/material-icons" +import {MatFolder} from "@ng-icons/material-icons"; @NgModule({ diff --git a/mediarepo-ui/src/app/components/shared/sidebar/file-import/file-import.component.ts b/mediarepo-ui/src/app/components/shared/sidebar/file-import/file-import.component.ts index bb9a5a0..7fb1c49 100644 --- a/mediarepo-ui/src/app/components/shared/sidebar/file-import/file-import.component.ts +++ b/mediarepo-ui/src/app/components/shared/sidebar/file-import/file-import.component.ts @@ -1,5 +1,5 @@ import {Component, EventEmitter, Output} from "@angular/core"; -import {File} from "../../../../models/File"; +import {File} from "../../../../../api/models/File"; @Component({ selector: "app-file-import", diff --git a/mediarepo-ui/src/app/components/shared/sidebar/file-import/filesystem-import/filesystem-import.component.ts b/mediarepo-ui/src/app/components/shared/sidebar/file-import/filesystem-import/filesystem-import.component.ts index f2bc725..9959a37 100644 --- a/mediarepo-ui/src/app/components/shared/sidebar/file-import/filesystem-import/filesystem-import.component.ts +++ b/mediarepo-ui/src/app/components/shared/sidebar/file-import/filesystem-import/filesystem-import.component.ts @@ -1,12 +1,12 @@ import {Component, EventEmitter, Output} from "@angular/core"; -import {FileOsMetadata} from "../../../../../models/FileOsMetadata"; import {ImportService} from "../../../../../services/import/import.service"; import { ErrorBrokerService } from "../../../../../services/error-broker/error-broker.service"; import {AddFileOptions} from "../../../../../models/AddFileOptions"; -import {File} from "../../../../../models/File"; +import {File} from "../../../../../../api/models/File"; import {DialogFilter} from "@tauri-apps/api/dialog"; +import {FileOsMetadata} from "../../../../../../api/api-types/files"; @Component({ selector: "app-filesystem-import", diff --git a/mediarepo-ui/src/app/components/shared/sidebar/file-metadata/editable-metadata-entry/editable-metadata-entry.component.html b/mediarepo-ui/src/app/components/shared/sidebar/file-metadata/editable-metadata-entry/editable-metadata-entry.component.html index 83356c9..32ad696 100644 --- a/mediarepo-ui/src/app/components/shared/sidebar/file-metadata/editable-metadata-entry/editable-metadata-entry.component.html +++ b/mediarepo-ui/src/app/components/shared/sidebar/file-metadata/editable-metadata-entry/editable-metadata-entry.component.html @@ -2,7 +2,7 @@ {{value}} {{attributeName}} - +