mirror of
https://github.com/jwetzell/showbridge-webui.git
synced 2026-09-08 23:08:59 +00:00
clean out template and patch stuff
This commit is contained in:
@@ -46,11 +46,6 @@ export class ParamsFormComponent implements OnInit {
|
|||||||
}[] = [];
|
}[] = [];
|
||||||
paramsOptionsSelectedIndex: number = 0;
|
paramsOptionsSelectedIndex: number = 0;
|
||||||
|
|
||||||
keysToTemplate: Set<string> = new Set<string>();
|
|
||||||
|
|
||||||
patchType: 'midi' | 'network' | undefined;
|
|
||||||
patchIndex: number = -1;
|
|
||||||
|
|
||||||
private schemaService = inject(SchemaService);
|
private schemaService = inject(SchemaService);
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
@@ -110,39 +105,9 @@ export class ParamsFormComponent implements OnInit {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (paramKey === '_port' || paramKey === '_host') {
|
|
||||||
//NOTE(jwetzell): determine what patch to load for dropdown
|
|
||||||
const valueIsPatch = dataToPatch[paramKey].match(
|
|
||||||
/^\${vars.patches.(midi|network)\[(\d+)\].(port|host)}$/,
|
|
||||||
);
|
|
||||||
if (valueIsPatch) {
|
|
||||||
this.patchType = valueIsPatch[1];
|
|
||||||
try {
|
|
||||||
this.patchIndex = parseInt(valueIsPatch[2]);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('params-form: error decoding patch info');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//NOTE(jwetzell): initialize keysToTemplate
|
|
||||||
Object.entries(dataToPatch).forEach(([key, value]) => {
|
|
||||||
if (key.startsWith('_') && value !== undefined) {
|
|
||||||
this.keysToTemplate.add(key.substring(1));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (has(this.paramsFormInfo.paramsInfo, 'port')) {
|
|
||||||
this.patchable = true;
|
|
||||||
if (has(this.paramsFormInfo.paramsInfo, 'host')) {
|
|
||||||
this.patchType = 'network';
|
|
||||||
} else {
|
|
||||||
this.patchType = 'midi';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.paramsFormInfo.formGroup.patchValue(dataToPatch);
|
this.paramsFormInfo.formGroup.patchValue(dataToPatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +162,6 @@ export class ParamsFormComponent implements OnInit {
|
|||||||
const params = this.schemaService.cleanParams(
|
const params = this.schemaService.cleanParams(
|
||||||
this.paramsSchema,
|
this.paramsSchema,
|
||||||
this.paramsFormInfo?.formGroup.value,
|
this.paramsFormInfo?.formGroup.value,
|
||||||
this.keysToTemplate,
|
|
||||||
);
|
);
|
||||||
this.updated.emit(params);
|
this.updated.emit(params);
|
||||||
} else {
|
} else {
|
||||||
@@ -207,17 +171,7 @@ export class ParamsFormComponent implements OnInit {
|
|||||||
|
|
||||||
paramKeys() {
|
paramKeys() {
|
||||||
if (this.paramsFormInfo) {
|
if (this.paramsFormInfo) {
|
||||||
return Object.keys(this.paramsFormInfo?.formGroup.controls).filter((key) => {
|
return Object.keys(this.paramsFormInfo?.formGroup.controls);
|
||||||
if (this.keysToTemplate.has(key)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE(jwezell): exclude template keys that aren't supposed to be
|
|
||||||
if (key.startsWith('_') && !this.keysToTemplate.has(key.substring(1))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -241,7 +195,6 @@ export class ParamsFormComponent implements OnInit {
|
|||||||
const params = this.schemaService.cleanParams(
|
const params = this.schemaService.cleanParams(
|
||||||
this.paramsSchema,
|
this.paramsSchema,
|
||||||
this.paramsFormInfo?.formGroup.value,
|
this.paramsFormInfo?.formGroup.value,
|
||||||
this.keysToTemplate,
|
|
||||||
);
|
);
|
||||||
return params[key];
|
return params[key];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ export class SchemaService {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanParams(paramsSchema: SomeJSONSchema, params: any, keysToTemplate: Set<string>): any {
|
cleanParams(paramsSchema: SomeJSONSchema, params: any): any {
|
||||||
Object.keys(params).forEach((paramKey) => {
|
Object.keys(params).forEach((paramKey) => {
|
||||||
if (paramsSchema.properties[paramKey]) {
|
if (paramsSchema.properties[paramKey]) {
|
||||||
const paramSchema = paramsSchema.properties[paramKey];
|
const paramSchema = paramsSchema.properties[paramKey];
|
||||||
|
|||||||
Reference in New Issue
Block a user