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

APIv2.2

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