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

fixed API variables calls

parent fa03569f
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<input input matInput [formControl]="variable.valueFC" /> <input input matInput [formControl]="variable.valueFC" />
</mat-form-field> </mat-form-field>
<button mat-raised-button color="primary" [disabled]="!variable.modifiableFC.value" <button mat-raised-button color="primary" [disabled]="!variable.modifiableFC.value"
(click)="onVarSubmit(variable)"> (click)="onSubVarSubmit(variable)">
set set
</button> </button>
</div> </div>
...@@ -44,24 +44,24 @@ ...@@ -44,24 +44,24 @@
<mat-label>Command</mat-label> <mat-label>Command</mat-label>
<mat-select [formControl]="selectedSubCmd!.nameFC" [value]="selectedSubCmd!.nameFC.value" <mat-select [formControl]="selectedSubCmd!.nameFC" [value]="selectedSubCmd!.nameFC.value"
(selectionChange)="onSubCmdSelect()"> (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-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div>
<div *ngIf="args$ | async as args" fxLaypout="column"> <div *ngIf="args$ | async as args" fxLaypout="column">
<div *ngIf="args.length"> <div *ngIf="args.length">
<h1 mat-dialog-title>Sub-Variables</h1> <h1 mat-dialog-title>{{ selectedSubCmd!.nameFC.value }} Sub-Variables</h1>
<div *ngFor="let variable of args"> <div *ngFor="let variable of args">
<mat-form-field> <mat-form-field>
<mat-label>{{ variable.nameFC.value }}</mat-label> <mat-label>{{ variable.nameFC.value }}</mat-label>
<input input matInput [formControl]="variable.valueFC" /> <input input matInput [formControl]="variable.valueFC" />
</mat-form-field> </mat-form-field>
<button mat-raised-button color="primary" [disabled]="!variable.modifiableFC.value" <button mat-raised-button color="primary" [disabled]="!variable.modifiableFC.value"
(click)="onSubVarSubmit(variable)"> (click)="onSubVarSubmit(variable)">
submit submit
</button> </button>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -39,7 +39,7 @@ export class CommandsComponent { ...@@ -39,7 +39,7 @@ export class CommandsComponent {
); );
this.cmds$ = this.commandsApi.readCommands$().pipe( 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) tap(controls => [this.selectedCmd] = controls)
); );
} }
...@@ -47,19 +47,20 @@ export class CommandsComponent { ...@@ -47,19 +47,20 @@ export class CommandsComponent {
onCmdSelect() { onCmdSelect() {
this.subcmds$ = this.commandsApi.readCommands$(`${this.selectedCmd!.nameFC.value}`).pipe( 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) 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) tap(controls => [this.selectedSubVar] = controls)
) )
} }
onSubCmdSelect() { onSubCmdSelect() {
this.args$ = this.commandsApi.readVariables$(`${this.selectedCmd!.nameFC.value}/${this.selectedSubCmd!.nameFC.value}`).pipe( this.args$ = this.commandsApi.readVariables$(`${this.selectedCmd!.nameFC.value}/${this.selectedSubCmd!.nameFC.value}`).pipe(
map(vars => vars.map(v => new VarCtrl(v))), map(ivars => ivars.map(ivar => new VarCtrl(ivar))),
tap(vars => [this.selectedArg] = vars) tap(controls => [this.selectedArg] = controls)
) )
} }
...@@ -68,6 +69,7 @@ export class CommandsComponent { ...@@ -68,6 +69,7 @@ export class CommandsComponent {
} }
onSubVarSubmit(control: VarCtrl) { 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