diff --git a/@overflow/probe/component/probe-detail.component.ts b/@overflow/probe/component/probe-detail.component.ts index 3748b38..d945e94 100644 --- a/@overflow/probe/component/probe-detail.component.ts +++ b/@overflow/probe/component/probe-detail.component.ts @@ -6,6 +6,7 @@ import { catchError, exhaustMap, map, tap } from 'rxjs/operators'; import { AuthContainerSelector } from '@overflow/shared/auth/store'; import { DomainMember } from '@overflow/commons-typescript/model/domain'; import { ProbeHostService } from '../service/probe-host.service'; +import { ProbeService } from '../service/probe.service'; @Component({ selector: 'of-probe-detail', @@ -18,10 +19,8 @@ export class ProbeDetailComponent implements OnInit { probeHost: ProbeHost; error$: Observable; - @Output() modify = new EventEmitter(); @Output() discovery = new EventEmitter(); - editMode = false; displayNameErrMsg: string; descriptionErrMsg: string; @@ -30,27 +29,28 @@ export class ProbeDetailComponent implements OnInit { constructor( private store: Store, - private probeHostService: ProbeHostService + private probeHostService: ProbeHostService, + private probeService: ProbeService, ) { } ngOnInit() { this.probeHostService.read(this.probeHostID) - .pipe( - tap(() => { - this.pending$ = of(true); - }), - map((probeHost: ProbeHost) => { - this.probeHost = probeHost; - }), - catchError(error => { - this.error$ = of(error); - return of(); - }), - tap(() => { - this.pending$ = of(false); - }), - ).take(1).subscribe(); + .pipe( + tap(() => { + this.pending$ = of(true); + }), + map((probeHost: ProbeHost) => { + this.probeHost = probeHost; + }), + catchError(error => { + this.error$ = of(error); + return of(); + }), + tap(() => { + this.pending$ = of(false); + }), + ).take(1).subscribe(); } @@ -60,7 +60,7 @@ export class ProbeDetailComponent implements OnInit { this.displayNameErrMsg = msg; } else { this.displayNameErrMsg = null; - this.displayName = value; + this.displayName = value.trim(); } } @@ -70,15 +70,31 @@ export class ProbeDetailComponent implements OnInit { this.descriptionErrMsg = msg; } else { this.descriptionErrMsg = null; - this.description = value; + this.description = value.trim(); } } onEditSave() { this.probeHost.probe.displayName = this.displayName ? this.displayName : this.probeHost.probe.displayName; this.probeHost.probe.description = this.description ? this.description : this.probeHost.probe.description; - this.modify.emit(this.probeHost); - this.editMode = false; + + this.probeService.modify(this.probeHost.probe) + .pipe( + tap(() => { + this.pending$ = of(true); + }), + map((probe: Probe) => { + this.editMode = false; + this.probeHost.probe = probe; + }), + catchError(error => { + this.error$ = of(error); + return of(); + }), + tap(() => { + this.pending$ = of(false); + }), + ).take(1).subscribe(); } checkValidDisplayName(value: string): string | null {