From 89e327383ee5745dbabc13efc365fd8bcc31b08d Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 30 Jul 2024 09:09:35 -0600 Subject: [PATCH] remove file uploads from config --- .../form-control/form-control.component.html | 1 - .../form/form-file/form-file.component.html | 31 ------------- .../form/form-file/form-file.component.scss | 46 ------------------- .../form/form-file/form-file.component.ts | 11 ----- .../ui/src/app/components/form/form.module.ts | 2 - .../ui/src/app/modals/config.component.ts | 20 -------- .../app/services/api/embassy-api.service.ts | 2 - .../services/api/embassy-live-api.service.ts | 9 ---- .../services/api/embassy-mock-api.service.ts | 5 -- .../ui/src/app/services/form.service.ts | 15 ------ 10 files changed, 142 deletions(-) delete mode 100644 web/projects/ui/src/app/components/form/form-file/form-file.component.html delete mode 100644 web/projects/ui/src/app/components/form/form-file/form-file.component.scss delete mode 100644 web/projects/ui/src/app/components/form/form-file/form-file.component.ts diff --git a/web/projects/ui/src/app/components/form/form-control/form-control.component.html b/web/projects/ui/src/app/components/form/form-control/form-control.component.html index 614aae05c..731d64a63 100644 --- a/web/projects/ui/src/app/components/form/form-control/form-control.component.html +++ b/web/projects/ui/src/app/components/form/form-control/form-control.component.html @@ -1,7 +1,6 @@ - diff --git a/web/projects/ui/src/app/components/form/form-file/form-file.component.html b/web/projects/ui/src/app/components/form/form-file/form-file.component.html deleted file mode 100644 index 9e9c16613..000000000 --- a/web/projects/ui/src/app/components/form/form-file/form-file.component.html +++ /dev/null @@ -1,31 +0,0 @@ - - - -
-
- {{ spec.name }} - * - -
- - - Click or drop file here - -
-
Drop file here
-
-
diff --git a/web/projects/ui/src/app/components/form/form-file/form-file.component.scss b/web/projects/ui/src/app/components/form/form-file/form-file.component.scss deleted file mode 100644 index 2e314972d..000000000 --- a/web/projects/ui/src/app/components/form/form-file/form-file.component.scss +++ /dev/null @@ -1,46 +0,0 @@ -@import '@taiga-ui/core/styles/taiga-ui-local'; - -.template { - @include transition(opacity); - - width: 100%; - display: flex; - align-items: center; - padding: 0 0.5rem; - font: var(--tui-font-text-m); - font-weight: bold; - - &_hidden { - opacity: 0; - } -} - -.drop { - @include fullsize(); - @include transition(opacity); - display: flex; - align-items: center; - justify-content: space-around; - - &_hidden { - opacity: 0; - } -} - -.label { - display: flex; - align-items: center; - max-width: 50%; -} - -small { - max-width: 50%; - font-weight: normal; - color: var(--tui-text-02); - margin-left: auto; -} - -tui-tag { - z-index: 1; - margin: -0.25rem -0.25rem -0.25rem auto; -} diff --git a/web/projects/ui/src/app/components/form/form-file/form-file.component.ts b/web/projects/ui/src/app/components/form/form-file/form-file.component.ts deleted file mode 100644 index 52d340fa6..000000000 --- a/web/projects/ui/src/app/components/form/form-file/form-file.component.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Component } from '@angular/core' -import { TuiFileLike } from '@taiga-ui/kit' -import { CT } from '@start9labs/start-sdk' -import { Control } from '../control' - -@Component({ - selector: 'form-file', - templateUrl: './form-file.component.html', - styleUrls: ['./form-file.component.scss'], -}) -export class FormFileComponent extends Control {} diff --git a/web/projects/ui/src/app/components/form/form.module.ts b/web/projects/ui/src/app/components/form/form.module.ts index b7a36cd1f..5417309a9 100644 --- a/web/projects/ui/src/app/components/form/form.module.ts +++ b/web/projects/ui/src/app/components/form/form.module.ts @@ -40,7 +40,6 @@ import { FormToggleComponent } from './form-toggle/form-toggle.component' import { FormTextareaComponent } from './form-textarea/form-textarea.component' import { FormNumberComponent } from './form-number/form-number.component' import { FormSelectComponent } from './form-select/form-select.component' -import { FormFileComponent } from './form-file/form-file.component' import { FormMultiselectComponent } from './form-multiselect/form-multiselect.component' import { FormUnionComponent } from './form-union/form-union.component' import { FormObjectComponent } from './form-object/form-object.component' @@ -96,7 +95,6 @@ import { HintPipe } from './hint.pipe' FormNumberComponent, FormSelectComponent, FormMultiselectComponent, - FormFileComponent, FormUnionComponent, FormObjectComponent, FormArrayComponent, diff --git a/web/projects/ui/src/app/modals/config.component.ts b/web/projects/ui/src/app/modals/config.component.ts index 194302f5f..60cef3141 100644 --- a/web/projects/ui/src/app/modals/config.component.ts +++ b/web/projects/ui/src/app/modals/config.component.ts @@ -203,8 +203,6 @@ export class ConfigModal { const loader = new Subscription() try { - await this.uploadFiles(config, loader) - if (hasCurrentDeps(this.pkgId, await getAllPackages(this.patchDb))) { await this.configureDeps(config, loader) } else { @@ -217,24 +215,6 @@ export class ConfigModal { } } - private async uploadFiles(config: Record, loader: Subscription) { - loader.unsubscribe() - loader.closed = false - - // TODO: Could be nested files - const keys = Object.keys(config).filter(key => config[key] instanceof File) - const message = `Uploading File${keys.length > 1 ? 's' : ''}...` - - if (!keys.length) return - - loader.add(this.loader.open(message).subscribe()) - - const hashes = await Promise.all( - keys.map(key => this.embassyApi.uploadFile(config[key])), - ) - keys.forEach((key, i) => (config[key] = hashes[i])) - } - private async configureDeps( config: Record, loader: Subscription, diff --git a/web/projects/ui/src/app/services/api/embassy-api.service.ts b/web/projects/ui/src/app/services/api/embassy-api.service.ts index 579292300..acd6780d1 100644 --- a/web/projects/ui/src/app/services/api/embassy-api.service.ts +++ b/web/projects/ui/src/app/services/api/embassy-api.service.ts @@ -14,8 +14,6 @@ export abstract class ApiService { // for sideloading packages abstract uploadPackage(guid: string, body: Blob): Promise - abstract uploadFile(body: Blob): Promise - // for getting static files: ex icons, instructions, licenses abstract getStaticProxy( pkg: MarketplacePkg, diff --git a/web/projects/ui/src/app/services/api/embassy-live-api.service.ts b/web/projects/ui/src/app/services/api/embassy-live-api.service.ts index 7780670c0..324936e8d 100644 --- a/web/projects/ui/src/app/services/api/embassy-live-api.service.ts +++ b/web/projects/ui/src/app/services/api/embassy-live-api.service.ts @@ -52,15 +52,6 @@ export class LiveApiService extends ApiService { }) } - async uploadFile(body: Blob): Promise { - return this.httpRequest({ - method: Method.POST, - body, - url: `/rest/upload`, - responseType: 'text', - }) - } - // for getting static files: ex. instructions, licenses async getStaticProxy( diff --git a/web/projects/ui/src/app/services/api/embassy-mock-api.service.ts b/web/projects/ui/src/app/services/api/embassy-mock-api.service.ts index e063fb6e4..f716a1863 100644 --- a/web/projects/ui/src/app/services/api/embassy-mock-api.service.ts +++ b/web/projects/ui/src/app/services/api/embassy-mock-api.service.ts @@ -1084,11 +1084,6 @@ export class MockApiService extends ApiService { } } - async uploadFile(body: Blob): Promise { - await pauseFor(2000) - return 'returnedhash' - } - private async initProgress(): Promise { const progress = JSON.parse(JSON.stringify(PROGRESS)) diff --git a/web/projects/ui/src/app/services/form.service.ts b/web/projects/ui/src/app/services/form.service.ts index 3cd0ee591..779fb1f53 100644 --- a/web/projects/ui/src/app/services/form.service.ts +++ b/web/projects/ui/src/app/services/form.service.ts @@ -122,11 +122,6 @@ export class FormService { return this.getListItem(spec, entry) }) return this.formBuilder.array(mapped, listValidators(spec)) - case 'file': - return this.formBuilder.control( - currentValue || null, - fileValidators(spec), - ) case 'union': const currentSelection = currentValue?.selection const isValid = !!spec.variants[currentSelection] @@ -259,16 +254,6 @@ function listValidators(spec: CT.ValueSpecList): ValidatorFn[] { return validators } -function fileValidators(spec: CT.ValueSpecFile): ValidatorFn[] { - const validators: ValidatorFn[] = [] - - if (spec.required) { - validators.push(Validators.required) - } - - return validators -} - export function numberInRange( min: number | null, max: number | null,