Commit 2afae815 authored by El Mghazli Yacine's avatar El Mghazli Yacine

fixed API variables calls

parent fa03569f
......@@ -30,7 +30,7 @@
<input input matInput [formControl]="variable.valueFC" />
</mat-form-field>
<button mat-raised-button color="primary" [disabled]="!variable.modifiableFC.value"
(click)="onVarSubmit(variable)">
(click)="onSubVarSubmit(variable)">
set
</button>
</div>
......@@ -44,24 +44,24 @@
<mat-label>Command</mat-label>
<mat-select [formControl]="selectedSubCmd!.nameFC" [value]="selectedSubCmd!.nameFC.value"
(selectionChange)="onSubCmdSelect()">
<mat-option *ngFor="let cmd of subcmds" [value]="cmd.nameFC.value">{{ cmd.nameFC.value }}
<mat-option *ngFor="let subcmd of subcmds" [value]="subcmd.nameFC.value">{{ subcmd.nameFC.value }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div *ngIf="args$ | async as args" fxLaypout="column">
<div *ngIf="args.length">
<h1 mat-dialog-title>Sub-Variables</h1>
<div *ngFor="let variable of args">
<mat-form-field>
<mat-label>{{ variable.nameFC.value }}</mat-label>
<input input matInput [formControl]="variable.valueFC" />
</mat-form-field>
<button mat-raised-button color="primary" [disabled]="!variable.modifiableFC.value"
(click)="onSubVarSubmit(variable)">
submit
</button>
<div *ngIf="args$ | async as args" fxLaypout="column">
<div *ngIf="args.length">
<h1 mat-dialog-title>{{ selectedSubCmd!.nameFC.value }} Sub-Variables</h1>
<div *ngFor="let variable of args">
<mat-form-field>
<mat-label>{{ variable.nameFC.value }}</mat-label>
<input input matInput [formControl]="variable.valueFC" />
</mat-form-field>
<button mat-raised-button color="primary" [disabled]="!variable.modifiableFC.value"
(click)="onSubVarSubmit(variable)">
submit
</button>
</div>
</div>
</div>
</div>
......
......@@ -39,7 +39,7 @@ export class CommandsComponent {
);
this.cmds$ = this.commandsApi.readCommands$().pipe(
map((cmds) => cmds.map(ivar => new CmdCtrl(ivar))),
map((cmds) => cmds.map(icmd => new CmdCtrl(icmd))),
tap(controls => [this.selectedCmd] = controls)
);
}
......@@ -47,19 +47,20 @@ export class CommandsComponent {
onCmdSelect() {
this.subcmds$ = this.commandsApi.readCommands$(`${this.selectedCmd!.nameFC.value}`).pipe(
map(cmds => cmds.map(cmd => new CmdCtrl(cmd))),
map(icmds => icmds.map(icmd => new CmdCtrl(icmd))),
tap(controls => [this.selectedSubCmd] = controls)
)
this.subvars$ = this.commandsApi.readVariables$(`${this.selectedCmd!.nameFC.value}`).pipe(map(vars => vars.map(v => new VarCtrl(v))),
this.subvars$ = this.commandsApi.readVariables$(`${this.selectedCmd!.nameFC.value}`).pipe(
map(ivars => ivars.map(ivar => new VarCtrl(ivar))),
tap(controls => [this.selectedSubVar] = controls)
)
}
onSubCmdSelect() {
this.args$ = this.commandsApi.readVariables$(`${this.selectedCmd!.nameFC.value}/${this.selectedSubCmd!.nameFC.value}`).pipe(
map(vars => vars.map(v => new VarCtrl(v))),
tap(vars => [this.selectedArg] = vars)
map(ivars => ivars.map(ivar => new VarCtrl(ivar))),
tap(controls => [this.selectedArg] = controls)
)
}
......@@ -68,6 +69,7 @@ export class CommandsComponent {
}
onSubVarSubmit(control: VarCtrl) {
this.commandsApi.setVariable$(control.api(), `${this.selectedCmd?.nameFC.value}/${this.selectedSubCmd?.nameFC.value}/${control.nameFC.value}`).subscribe();
this.commandsApi.setVariable$(control.api(), `${this.selectedCmd?.nameFC.value}`).subscribe();
// this.commandsApi.setVariable$(control.api(), `${this.selectedCmd?.nameFC.value} / ${this.selectedSubCmd?.nameFC.value} / ${control.nameFC.value}`).subscribe();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment