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

confirm button ok

parent 61dab4c7
...@@ -3,6 +3,7 @@ import { Observable } from 'rxjs/internal/Observable'; ...@@ -3,6 +3,7 @@ import { Observable } from 'rxjs/internal/Observable';
import { of } from 'rxjs/internal/observable/of'; import { of } from 'rxjs/internal/observable/of';
import { map } from 'rxjs/internal/operators/map'; import { map } from 'rxjs/internal/operators/map';
import { mergeMap } from 'rxjs/internal/operators/mergeMap'; import { mergeMap } from 'rxjs/internal/operators/mergeMap';
import { filter } from 'rxjs/operators';
import { CommandsApi, IArgType, IColumn } from 'src/app/api/commands.api'; import { CommandsApi, IArgType, IColumn } from 'src/app/api/commands.api';
import { CmdCtrl } from 'src/app/controls/cmd.control'; import { CmdCtrl } from 'src/app/controls/cmd.control';
import { EntryFC } from 'src/app/controls/entry.control'; import { EntryFC } from 'src/app/controls/entry.control';
...@@ -90,12 +91,12 @@ export class CommandsComponent { ...@@ -90,12 +91,12 @@ export class CommandsComponent {
onCmdSubmit(control: CmdCtrl) { onCmdSubmit(control: CmdCtrl) {
// const obs = control.confirm ? this.dialogService.openConfirmDialog(control.confirm) : of(null) const obs = control.confirm
? this.dialogService.openConfirmDialog(control.confirm).pipe(filter(confirmed => confirmed))
: of(null)
// this.rows$ = obs.pipe( this.rows$ = obs.pipe(
// mergeMap(() => this.commandsApi.runCommand$(control.api(), `${this.selectedModule!.nameFC.value}`)), mergeMap(() => this.commandsApi.runCommand$(control.api(), `${this.selectedModule!.nameFC.value}`)),
this.rows$ = this.commandsApi.runCommand$(control.api(), `${this.selectedModule!.nameFC.value}`).pipe(
mergeMap(resp => { mergeMap(resp => {
if (resp.display[0]) return this.dialogService.openRespDialog(resp, 'cmd ' + control.nameFC.value + ' response:') if (resp.display[0]) return this.dialogService.openRespDialog(resp, 'cmd ' + control.nameFC.value + ' response:')
else return of(resp) else return of(resp)
......
<h1>Really ?</h1> <h3>{{ data.title }}</h3>
<div fxLayoutGap="10px" mat-dialog-actions fxLayout="row" fxLayoutAlign="center start"> <div fxLayoutGap="10px" mat-dialog-actions fxLayout="row" fxLayoutAlign="center start">
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>Ok</button> <button mat-button [mat-dialog-close]="true" cdkFocusInitial>Ok</button>
<button mat-button (click)="onNoClick()">Cancel</button> <button mat-button (click)="onNoClick()">Cancel</button>
......
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import { Component } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({ @Component({
selector: 'app-confirm', selector: 'app-confirm',
...@@ -10,8 +10,9 @@ import { MatDialogRef } from '@angular/material/dialog'; ...@@ -10,8 +10,9 @@ import { MatDialogRef } from '@angular/material/dialog';
export class ConfirmDialogComponent { export class ConfirmDialogComponent {
constructor( constructor(
public dialogRef: MatDialogRef<void> public dialogRef: MatDialogRef<void>,
) { } @Inject(MAT_DIALOG_DATA) public data: any) {
}
onNoClick() { onNoClick() {
this.dialogRef.close(); this.dialogRef.close();
......
...@@ -3,14 +3,18 @@ import { ICommand } from '../api/commands.api'; ...@@ -3,14 +3,18 @@ import { ICommand } from '../api/commands.api';
const enum CmdFCN { const enum CmdFCN {
name = 'name', name = 'name',
confirm = 'confirm'
} }
export class CmdCtrl extends FormGroup { export class CmdCtrl extends FormGroup {
confirm?: string
constructor(cmd: ICommand) { constructor(cmd: ICommand) {
super({}); super({});
this.addControl(CmdFCN.name, new FormControl(cmd.name)); this.addControl(CmdFCN.name, new FormControl(cmd.name));
this.confirm = cmd.confirm
} }
api() { api() {
......
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