mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
remove file uploads from config
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
<ng-container [ngSwitch]="spec.type">
|
<ng-container [ngSwitch]="spec.type">
|
||||||
<form-color *ngSwitchCase="'color'"></form-color>
|
<form-color *ngSwitchCase="'color'"></form-color>
|
||||||
<form-datetime *ngSwitchCase="'datetime'"></form-datetime>
|
<form-datetime *ngSwitchCase="'datetime'"></form-datetime>
|
||||||
<form-file *ngSwitchCase="'file'"></form-file>
|
|
||||||
<form-multiselect *ngSwitchCase="'multiselect'"></form-multiselect>
|
<form-multiselect *ngSwitchCase="'multiselect'"></form-multiselect>
|
||||||
<form-number *ngSwitchCase="'number'"></form-number>
|
<form-number *ngSwitchCase="'number'"></form-number>
|
||||||
<form-select *ngSwitchCase="'select'"></form-select>
|
<form-select *ngSwitchCase="'select'"></form-select>
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
<tui-input-files
|
|
||||||
[pseudoInvalid]="invalid"
|
|
||||||
[(ngModel)]="value"
|
|
||||||
(focusedChange)="onFocus($event)"
|
|
||||||
>
|
|
||||||
<input tuiInputFiles [accept]="spec.extensions.join(',')" />
|
|
||||||
<ng-template let-drop>
|
|
||||||
<div class="template" [class.template_hidden]="drop">
|
|
||||||
<div class="label">
|
|
||||||
{{ spec.name }}
|
|
||||||
<span *ngIf="spec.required">*</span>
|
|
||||||
<tui-tooltip
|
|
||||||
*ngIf="spec.description"
|
|
||||||
[content]="spec.description"
|
|
||||||
></tui-tooltip>
|
|
||||||
</div>
|
|
||||||
<tui-tag
|
|
||||||
*ngIf="value; else label"
|
|
||||||
class="file"
|
|
||||||
size="l"
|
|
||||||
[value]="value.name"
|
|
||||||
[removable]="true"
|
|
||||||
(edited)="value = null"
|
|
||||||
></tui-tag>
|
|
||||||
<ng-template #label>
|
|
||||||
<small>Click or drop file here</small>
|
|
||||||
</ng-template>
|
|
||||||
</div>
|
|
||||||
<div class="drop" [class.drop_hidden]="!drop">Drop file here</div>
|
|
||||||
</ng-template>
|
|
||||||
</tui-input-files>
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
@@ -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<CT.ValueSpecFile, TuiFileLike> {}
|
|
||||||
@@ -40,7 +40,6 @@ import { FormToggleComponent } from './form-toggle/form-toggle.component'
|
|||||||
import { FormTextareaComponent } from './form-textarea/form-textarea.component'
|
import { FormTextareaComponent } from './form-textarea/form-textarea.component'
|
||||||
import { FormNumberComponent } from './form-number/form-number.component'
|
import { FormNumberComponent } from './form-number/form-number.component'
|
||||||
import { FormSelectComponent } from './form-select/form-select.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 { FormMultiselectComponent } from './form-multiselect/form-multiselect.component'
|
||||||
import { FormUnionComponent } from './form-union/form-union.component'
|
import { FormUnionComponent } from './form-union/form-union.component'
|
||||||
import { FormObjectComponent } from './form-object/form-object.component'
|
import { FormObjectComponent } from './form-object/form-object.component'
|
||||||
@@ -96,7 +95,6 @@ import { HintPipe } from './hint.pipe'
|
|||||||
FormNumberComponent,
|
FormNumberComponent,
|
||||||
FormSelectComponent,
|
FormSelectComponent,
|
||||||
FormMultiselectComponent,
|
FormMultiselectComponent,
|
||||||
FormFileComponent,
|
|
||||||
FormUnionComponent,
|
FormUnionComponent,
|
||||||
FormObjectComponent,
|
FormObjectComponent,
|
||||||
FormArrayComponent,
|
FormArrayComponent,
|
||||||
|
|||||||
@@ -203,8 +203,6 @@ export class ConfigModal {
|
|||||||
const loader = new Subscription()
|
const loader = new Subscription()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.uploadFiles(config, loader)
|
|
||||||
|
|
||||||
if (hasCurrentDeps(this.pkgId, await getAllPackages(this.patchDb))) {
|
if (hasCurrentDeps(this.pkgId, await getAllPackages(this.patchDb))) {
|
||||||
await this.configureDeps(config, loader)
|
await this.configureDeps(config, loader)
|
||||||
} else {
|
} else {
|
||||||
@@ -217,24 +215,6 @@ export class ConfigModal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async uploadFiles(config: Record<string, any>, 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(
|
private async configureDeps(
|
||||||
config: Record<string, any>,
|
config: Record<string, any>,
|
||||||
loader: Subscription,
|
loader: Subscription,
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ export abstract class ApiService {
|
|||||||
// for sideloading packages
|
// for sideloading packages
|
||||||
abstract uploadPackage(guid: string, body: Blob): Promise<string>
|
abstract uploadPackage(guid: string, body: Blob): Promise<string>
|
||||||
|
|
||||||
abstract uploadFile(body: Blob): Promise<string>
|
|
||||||
|
|
||||||
// for getting static files: ex icons, instructions, licenses
|
// for getting static files: ex icons, instructions, licenses
|
||||||
abstract getStaticProxy(
|
abstract getStaticProxy(
|
||||||
pkg: MarketplacePkg,
|
pkg: MarketplacePkg,
|
||||||
|
|||||||
@@ -52,15 +52,6 @@ export class LiveApiService extends ApiService {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadFile(body: Blob): Promise<string> {
|
|
||||||
return this.httpRequest({
|
|
||||||
method: Method.POST,
|
|
||||||
body,
|
|
||||||
url: `/rest/upload`,
|
|
||||||
responseType: 'text',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// for getting static files: ex. instructions, licenses
|
// for getting static files: ex. instructions, licenses
|
||||||
|
|
||||||
async getStaticProxy(
|
async getStaticProxy(
|
||||||
|
|||||||
@@ -1084,11 +1084,6 @@ export class MockApiService extends ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadFile(body: Blob): Promise<string> {
|
|
||||||
await pauseFor(2000)
|
|
||||||
return 'returnedhash'
|
|
||||||
}
|
|
||||||
|
|
||||||
private async initProgress(): Promise<T.FullProgress> {
|
private async initProgress(): Promise<T.FullProgress> {
|
||||||
const progress = JSON.parse(JSON.stringify(PROGRESS))
|
const progress = JSON.parse(JSON.stringify(PROGRESS))
|
||||||
|
|
||||||
|
|||||||
@@ -122,11 +122,6 @@ export class FormService {
|
|||||||
return this.getListItem(spec, entry)
|
return this.getListItem(spec, entry)
|
||||||
})
|
})
|
||||||
return this.formBuilder.array(mapped, listValidators(spec))
|
return this.formBuilder.array(mapped, listValidators(spec))
|
||||||
case 'file':
|
|
||||||
return this.formBuilder.control(
|
|
||||||
currentValue || null,
|
|
||||||
fileValidators(spec),
|
|
||||||
)
|
|
||||||
case 'union':
|
case 'union':
|
||||||
const currentSelection = currentValue?.selection
|
const currentSelection = currentValue?.selection
|
||||||
const isValid = !!spec.variants[currentSelection]
|
const isValid = !!spec.variants[currentSelection]
|
||||||
@@ -259,16 +254,6 @@ function listValidators(spec: CT.ValueSpecList): ValidatorFn[] {
|
|||||||
return validators
|
return validators
|
||||||
}
|
}
|
||||||
|
|
||||||
function fileValidators(spec: CT.ValueSpecFile): ValidatorFn[] {
|
|
||||||
const validators: ValidatorFn[] = []
|
|
||||||
|
|
||||||
if (spec.required) {
|
|
||||||
validators.push(Validators.required)
|
|
||||||
}
|
|
||||||
|
|
||||||
return validators
|
|
||||||
}
|
|
||||||
|
|
||||||
export function numberInRange(
|
export function numberInRange(
|
||||||
min: number | null,
|
min: number | null,
|
||||||
max: number | null,
|
max: number | null,
|
||||||
|
|||||||
Reference in New Issue
Block a user