mirror of
https://github.com/jwetzell/showbridge-webui.git
synced 2026-08-16 03:43:24 +00:00
add config upload and viewing returned errors for modules and routes
This commit is contained in:
@@ -43,5 +43,20 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
@if (moduleConfigErrors().length > 0) {
|
||||
<div class="m-2 p-2 border-2 border-red-500">
|
||||
<div class="flex items-center mb-2 text-red-500">
|
||||
<mat-icon>error</mat-icon>
|
||||
<span class="ml-1">Module Errors</span>
|
||||
</div>
|
||||
@for (error of moduleConfigErrors(); track error) {
|
||||
<div class="ml-4 mb-1 text-white">
|
||||
{{ error.error }}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -3,13 +3,14 @@ import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angula
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { ModuleConfiguration } from '../../models/config.models';
|
||||
import { ModuleConfig } from '../../models/config.models';
|
||||
import { SchemaService } from '../../services/schema.service';
|
||||
import { ParamsFormComponent } from '../params-form/params-form.component';
|
||||
import { JsonPipe } from '@angular/common';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { EventsService } from '../../services/events.service';
|
||||
import { tap, debounceTime } from 'rxjs';
|
||||
import { ConfigService } from '../../services/config.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-module',
|
||||
@@ -27,7 +28,17 @@ import { tap, debounceTime } from 'rxjs';
|
||||
})
|
||||
export class ModuleComponent {
|
||||
path = input<string>('');
|
||||
module = model<ModuleConfiguration>();
|
||||
index = computed(() => {
|
||||
const path = this.path();
|
||||
if (path) {
|
||||
const parts = path.split('/');
|
||||
const lastPart = parts[parts.length - 1];
|
||||
return parseInt(lastPart, 10);
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
|
||||
module = model<ModuleConfig>();
|
||||
delete = output<void>();
|
||||
|
||||
params = computed(() => this.module()!.params);
|
||||
@@ -39,6 +50,15 @@ export class ModuleComponent {
|
||||
: undefined;
|
||||
});
|
||||
|
||||
moduleConfigErrors = computed(() => {
|
||||
const index = this.index();
|
||||
const moduleErrors = this.configService.moduleErrors();
|
||||
if (index !== undefined) {
|
||||
return moduleErrors.filter((error) => error.index === index);
|
||||
}
|
||||
return [];
|
||||
});
|
||||
|
||||
formGroup: FormGroup = new FormGroup({
|
||||
id: new FormControl('', [Validators.required]),
|
||||
type: new FormControl(''),
|
||||
@@ -49,6 +69,7 @@ export class ModuleComponent {
|
||||
|
||||
private schemaService = inject(SchemaService);
|
||||
private eventsService = inject(EventsService);
|
||||
private configService = inject(ConfigService);
|
||||
ngOnInit(): void {
|
||||
this.formGroup.patchValue({
|
||||
id: this.module()?.id,
|
||||
|
||||
Reference in New Issue
Block a user