From 32afe7b3af1c2b8825115dc00c58ad25153b0f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20P=C3=B6mp?= Date: Mon, 5 Aug 2024 16:05:10 +0200 Subject: [PATCH] feat(octra): gear icon next to file name allows to change import options --- .../octra-dropzone.component.html | 29 +- .../octra-dropzone.component.scss | 17 +- .../octra-dropzone.component.ts | 40 +-- apps/octra/src/app/core/obj/objects.ts | 5 + .../tool-configurator.component.ts | 248 +++++++++--------- 5 files changed, 182 insertions(+), 157 deletions(-) diff --git a/apps/octra/src/app/core/component/octra-dropzone/octra-dropzone.component.html b/apps/octra/src/app/core/component/octra-dropzone/octra-dropzone.component.html index 38d0dd9e0..0ae61a8c4 100644 --- a/apps/octra/src/app/core/component/octra-dropzone/octra-dropzone.component.html +++ b/apps/octra/src/app/core/component/octra-dropzone/octra-dropzone.component.html @@ -1,14 +1,6 @@ - - + + +
- - {{ getDropzoneFileString(file) }} {{ getDropzoneFileString(file) }} + + + +
{{ - 'dropzone.drag&drop here' | transloco - }} + 'dropzone.drag&drop here' | transloco + }}
{ + const setAnnotation = async () => { if ( this._oaudiofile !== undefined && importResult !== undefined && @@ -181,6 +177,7 @@ export class OctraDropzoneComponent extends DefaultComponent { !importResult.error ) { fileProgress.status = 'valid'; + if ( fileProgress.name !== audioName + AppInfo.converters[i].extension && @@ -278,7 +275,7 @@ export class OctraDropzoneComponent extends DefaultComponent { }; this._files.push(audioProcess); } else { - setAnnotation(); + await setAnnotation(); } fileProgress.checked_converters++; @@ -442,23 +439,26 @@ export class OctraDropzoneComponent extends DefaultComponent { }); } - private async openImportOptionsModal( - needsOptions: any, - value: any, - converter: Converter - ): Promise { + protected async openImportOptionsModal( + fileProgress: FileProgress + ): Promise { + this.dropzone.clicklocked = true; + // make sure, that event click does not trigger + + this.subscribe(timer(300), () => { + this.dropzone.clicklocked = false; + }); const result = await this.modService.openModal< typeof ImportOptionsModalComponent, any >(ImportOptionsModalComponent, ImportOptionsModalComponent.options, { - schema: needsOptions, - value, - converter, + schema: fileProgress.needsOptions, + value: fileProgress.options, + converter: fileProgress.converter, }); if (result.action === 'apply') { - return result.result; + fileProgress.options = result.result; } - return value; } } diff --git a/apps/octra/src/app/core/obj/objects.ts b/apps/octra/src/app/core/obj/objects.ts index 28635b926..3bf843b5d 100644 --- a/apps/octra/src/app/core/obj/objects.ts +++ b/apps/octra/src/app/core/obj/objects.ts @@ -1,9 +1,14 @@ +import { Converter } from '@octra/annotation'; + export interface FileProgress { status: 'progress' | 'valid' | 'invalid'; name: string; type: string; size: number; file: File; + needsOptions?: any; + options?: any; + converter?: Converter; content?: string | ArrayBuffer; checked_converters: number; progress: number; diff --git a/libs/ngx-components/src/lib/components/form-generator/tool-configurator.component.ts b/libs/ngx-components/src/lib/components/form-generator/tool-configurator.component.ts index 4276981d0..03309f013 100644 --- a/libs/ngx-components/src/lib/components/form-generator/tool-configurator.component.ts +++ b/libs/ngx-components/src/lib/components/form-generator/tool-configurator.component.ts @@ -40,59 +40,63 @@ export class ToolConfiguratorComponent const defaultValue = schema['default']; if (typeof items === 'object') { if (items['type'] === 'string') { - result.push( - new ConfigurationArrayControl( - name!, - { - title: schema['title'] ?? name, - type: 'text', - value: jsonValue ?? defaultValue, - defaultValue, - description: schema['description'], - ignore: false, - context: items['enum'], - dependsOn: schema['dependsOn'], - toggleable: schema['toggleable'], - }, - this.form - ) + const control = new ConfigurationArrayControl( + name!, + { + title: schema['title'] ?? name, + type: 'text', + value: jsonValue ?? defaultValue, + defaultValue, + description: schema['description'], + ignore: false, + context: items['enum'], + dependsOn: schema['dependsOn'], + toggleable: schema['toggleable'], + }, + this.form ); + + control.toggled = + json && name !== undefined && Object.keys(json).includes(name); + result.push(control); } else if (items['type'] === 'number') { - result.push( - new ConfigurationArrayControl( - name!, - { - title: schema['title'] ?? name, - type: 'number', - value: jsonValue ?? defaultValue, - defaultValue, - description: schema['description'], - ignore: false, - context: items['enum'], - dependsOn: schema['dependsOn'], - toggleable: schema['toggleable'], - }, - this.form - ) + const control = new ConfigurationArrayControl( + name!, + { + title: schema['title'] ?? name, + type: 'number', + value: jsonValue ?? defaultValue, + defaultValue, + description: schema['description'], + ignore: false, + context: items['enum'], + dependsOn: schema['dependsOn'], + toggleable: schema['toggleable'], + }, + this.form ); + control.toggled = + json && name !== undefined && Object.keys(json).includes(name); + result.push(control); } else if (items['type'] === 'integer') { - result.push( - new ConfigurationArrayControl( - name!, - { - title: schema['title'] ?? name, - toggleable: schema['toggleable'], - type: 'integer', - value: jsonValue ?? defaultValue, - defaultValue, - description: schema['description'], - dependsOn: schema['dependsOn'], - ignore: false, - context: items['enum'], - }, - this.form - ) + const control = new ConfigurationArrayControl( + name!, + { + title: schema['title'] ?? name, + toggleable: schema['toggleable'], + type: 'integer', + value: jsonValue ?? defaultValue, + defaultValue, + description: schema['description'], + dependsOn: schema['dependsOn'], + ignore: false, + context: items['enum'], + }, + this.form ); + control.toggled = + json && name !== undefined && Object.keys(json).includes(name); + result.push(control); } } else { // TODO add @@ -124,45 +128,87 @@ export class ToolConfiguratorComponent const ignore = ['version', '$schema'].includes(name); if (schema['type'] === 'boolean') { - result.push( - new ConfigurationSwitchControl( - name, - { - title: title ?? name, - value: jsonValue ?? defaultValue, - defaultValue, - description, - ignore, - dependsOn, - toggleable, - }, - this.form - ) + const control = new ConfigurationSwitchControl( + name, + { + title: title ?? name, + value: jsonValue ?? defaultValue, + defaultValue, + description, + ignore, + dependsOn, + toggleable, + }, + this.form ); + control.toggled = + json && name !== undefined && Object.keys(json).includes(name); + result.push(control); } else if (schema['type'] === 'number') { - result.push( - new ConfigurationNumberControl( - name, - { - title: title ?? name, - type: 'number', - value: jsonValue ?? defaultValue, - defaultValue, - description, - dependsOn, - toggleable, - ignore, - }, - this.form - ) + const control = new ConfigurationNumberControl( + name, + { + title: title ?? name, + type: 'number', + value: jsonValue ?? defaultValue, + defaultValue, + description, + dependsOn, + toggleable, + ignore, + }, + this.form ); + control.toggled = + json && name !== undefined && Object.keys(json).includes(name); + result.push(control); } else if (schema['type'] === 'integer') { - result.push( - new ConfigurationNumberControl( + const control = new ConfigurationNumberControl( + name, + { + title: title ?? name, + type: 'integer', + value: jsonValue ?? defaultValue, + defaultValue, + description, + ignore, + toggleable, + dependsOn, + }, + this.form + ); + control.toggled = + json && name !== undefined && Object.keys(json).includes(name); + result.push(control); + } else if (schema['type'] === 'string') { + let control: ConfigurationControl = new ConfigurationSelectControl( + name, + { + title: title ?? name, + value: jsonValue ?? defaultValue, + defaultValue, + description, + ignore, + toggleable, + dependsOn, + context: enumValues?.map((a) => ({ + label: a, + value: a, + })), + }, + this.form + ); + control.toggled = + json && name !== undefined && Object.keys(json).includes(name); + + if (enumValues) { + // select + result.push(control); + } else { + control = new ConfigurationTextControl( name, { title: title ?? name, - type: 'integer', value: jsonValue ?? defaultValue, defaultValue, description, @@ -171,46 +217,10 @@ export class ToolConfiguratorComponent dependsOn, }, this.form - ) - ); - } else if (schema['type'] === 'string') { - if (enumValues) { - // select - result.push( - new ConfigurationSelectControl( - name, - { - title: title ?? name, - value: jsonValue ?? defaultValue, - defaultValue, - description, - ignore, - toggleable, - dependsOn, - context: enumValues.map((a) => ({ - label: a, - value: a, - })), - }, - this.form - ) - ); - } else { - result.push( - new ConfigurationTextControl( - name, - { - title: title ?? name, - value: jsonValue ?? defaultValue, - defaultValue, - description, - ignore, - toggleable, - dependsOn, - }, - this.form - ) ); + control.toggled = + json && name !== undefined && Object.keys(json).includes(name); + result.push(control); } } }