-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #836 from jwetzell/feat/webui-add-export-import-mi…
…di-list add export import midi list to patch editor
- Loading branch information
Showing
10 changed files
with
116 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
webui/src/app/components/import-config/import-config.component.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
...mport-config/import-config.component.html → ...ts/import-json/import-json.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
<div class="flex flex-col h-full"> | ||
<h1 mat-dialog-title>Import Config</h1> | ||
<h1 mat-dialog-title>{{ this.data.title }}</h1> | ||
<ng-container *ngIf="formGroup"> | ||
<div class="flex-auto w-full h-full"> | ||
<form [formGroup]="formGroup" class="w-full h-full p-2"> | ||
<textarea formControlName="config" placeholder="Paste Config Here" class="w-full h-full pt-1 pl-1"></textarea> | ||
<textarea formControlName="json" placeholder="Paste Config Here" class="w-full h-full pt-1 pl-1"></textarea> | ||
</form> | ||
</div> | ||
<div mat-dialog-actions> | ||
<button mat-button mat-dialog-close>Cancel</button> | ||
<span class="flex-auto"></span> | ||
<button mat-button (click)="importConfig()" [disabled]="!formGroup.valid">Import</button> | ||
<button mat-button (click)="importJson()" [disabled]="!formGroup.valid">Import</button> | ||
</div> | ||
</ng-container> | ||
</div> |
59 changes: 59 additions & 0 deletions
59
webui/src/app/components/import-json/import-json.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Component, inject } from '@angular/core'; | ||
import { AbstractControl, FormControl, FormGroup, ValidationErrors, Validators } from '@angular/forms'; | ||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; | ||
import { SomeJSONSchema } from 'ajv/dist/types/json-schema'; | ||
import { SchemaService } from 'src/app/services/schema.service'; | ||
|
||
type ImportJSONComponentData = { | ||
schema?: SomeJSONSchema; | ||
title: string; | ||
}; | ||
|
||
@Component({ | ||
selector: 'app-import-json', | ||
templateUrl: './import-json.component.html', | ||
styleUrls: ['./import-json.component.css'], | ||
}) | ||
export class ImportJSONComponent { | ||
readonly data = inject<ImportJSONComponentData>(MAT_DIALOG_DATA); | ||
|
||
formGroup?: FormGroup; | ||
|
||
constructor( | ||
private schemaService: SchemaService, | ||
public dialogRef: MatDialogRef<ImportJSONComponent> | ||
) { | ||
if (this.data.schema !== undefined) { | ||
console.log(this.data.schema); | ||
this.formGroup = new FormGroup({ | ||
json: new FormControl(null, [ | ||
Validators.required, | ||
this.isJSON, | ||
this.schemaService.jsonValidator(this.data.schema), | ||
]), | ||
}); | ||
} else { | ||
this.formGroup = new FormGroup({ | ||
json: new FormControl(null, [Validators.required, this.isJSON]), | ||
}); | ||
} | ||
|
||
this.formGroup.valueChanges.subscribe(console.log); | ||
} | ||
|
||
isJSON(control: AbstractControl): ValidationErrors | null { | ||
console.log(control); | ||
try { | ||
JSON.parse(control.value); | ||
return null; | ||
} catch (error) { | ||
return { json: error }; | ||
} | ||
} | ||
|
||
importJson() { | ||
if (this.formGroup?.valid) { | ||
this.dialogRef.close(JSON.parse(this.formGroup.controls['json'].value)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters