Commit a3b64c4a authored by El Mghazli Yacine's avatar El Mghazli Yacine

APIv2.2

parent 564bcde6
......@@ -37,8 +37,6 @@ export class CommandsApi {
public readModuleCommands$ = (moduleName: string) => this.httpClient.get<ICommand[]>(environment.backend + route + '/commands/' + moduleName);
public runCommand$ = (command: ICommand) => this.httpClient.post<string>(environment.backend + route + '/run/', command);
public setVariable$ = (variable: IVariable) => this.httpClient.post<string>(environment.backend + route + '/set/', variable);
public runCommand$ = (moduleName: string, variable: IVariable) => this.httpClient.post<string>(environment.backend + route + '/commands/' + moduleName, variable);
}
......@@ -16,7 +16,7 @@
<mat-form-field>
<mat-label>Command</mat-label>
<mat-select [formControl]="selectedCmd!.nameFC" [value]="selectedCmd!.nameFC.value"
(selectionChange)="onCmdSelect(selectedCmd!)">
(selectionChange)="onCmdSelect()">
<mat-option *ngFor="let cmd of cmds" [value]="cmd">{{ cmd.nameFC.value }}
</mat-option>
</mat-select>
......@@ -41,7 +41,7 @@
<mat-form-field>
<mat-label>Command</mat-label>
<mat-select [formControl]="selectedSubCmd!.nameFC" [value]="selectedSubCmd!.nameFC.value"
(selectionChange)="onSubCmdSelect(selectedSubCmd!)">
(selectionChange)="onSubCmdSelect()">
<mat-option *ngFor="let cmd of subcmds" [value]="cmd">{{ cmd.nameFC.value }}
</mat-option>
</mat-select>
......@@ -55,7 +55,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)">
submit
</button>
</div>
......
......@@ -43,31 +43,30 @@ export class CommandsComponent {
);
}
onCmdSubmit(control: CmdCtrl) {
this.commandsApi.runCommand$(control.api()).subscribe();
}
onCmdSelect(control: CmdCtrl) {
this.subcmds$ = this.commandsApi.readModuleCommands$(control.nameFC.value).pipe(
onCmdSelect() {
this.subcmds$ = this.commandsApi.readModuleCommands$(`${this.selectedCmd?.nameFC.value}`).pipe(
map(cmds => cmds.map(cmd => new CmdCtrl(cmd))),
// tap(cmds => [this.selectedSubCmd] = cmds)
)
this.subvars$ = this.commandsApi.readModuleVariables$(control.nameFC.value).pipe(
this.subvars$ = this.commandsApi.readModuleVariables$(`${this.selectedCmd?.nameFC.value}`).pipe(
map(vars => vars.map(v => new VarCtrl(v))),
// tap(vars => [this.selectedSubVar] = vars)
)
}
onSubCmdSelect(control: CmdCtrl) {
this.args$ = this.commandsApi.readModuleVariables$(control.nameFC.value).pipe(
onSubCmdSelect() {
this.args$ = this.commandsApi.readModuleVariables$(`${this.selectedCmd?.nameFC.value}/${this.selectedSubCmd?.nameFC.value}`).pipe(
map(vars => vars.map(v => new VarCtrl(v))),
// tap(vars => [this.selectedSubVar] = vars)
)
}
onVarSubmit(control: VarCtrl) {
control.nameFC = new FormControl(`${this.selectedCmd?.nameFC.value} ${this.selectedSubCmd?.nameFC.value} ${control.nameFC.value}`.trim())
this.commandsApi.setVariable$(control.api()).subscribe();
this.commandsApi.runCommand$(`${this.selectedCmd?.nameFC.value}/${control.nameFC.value}`, control.valueFC.value).subscribe();
}
onSubVarSubmit(control: VarCtrl) {
this.commandsApi.runCommand$(`${this.selectedCmd?.nameFC.value}/${this.selectedSubCmd?.nameFC.value}/${control.nameFC.value}`, control.valueFC.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