probe detail modify bug fix

This commit is contained in:
insanity 2018-06-01 12:59:38 +09:00
parent f26e14bad3
commit 28b5e819fa

View File

@ -6,6 +6,7 @@ import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
import { AuthContainerSelector } from '@overflow/shared/auth/store'; import { AuthContainerSelector } from '@overflow/shared/auth/store';
import { DomainMember } from '@overflow/commons-typescript/model/domain'; import { DomainMember } from '@overflow/commons-typescript/model/domain';
import { ProbeHostService } from '../service/probe-host.service'; import { ProbeHostService } from '../service/probe-host.service';
import { ProbeService } from '../service/probe.service';
@Component({ @Component({
selector: 'of-probe-detail', selector: 'of-probe-detail',
@ -18,10 +19,8 @@ export class ProbeDetailComponent implements OnInit {
probeHost: ProbeHost; probeHost: ProbeHost;
error$: Observable<any>; error$: Observable<any>;
@Output() modify = new EventEmitter<ProbeHost>();
@Output() discovery = new EventEmitter<number>(); @Output() discovery = new EventEmitter<number>();
editMode = false; editMode = false;
displayNameErrMsg: string; displayNameErrMsg: string;
descriptionErrMsg: string; descriptionErrMsg: string;
@ -30,7 +29,8 @@ export class ProbeDetailComponent implements OnInit {
constructor( constructor(
private store: Store<any>, private store: Store<any>,
private probeHostService: ProbeHostService private probeHostService: ProbeHostService,
private probeService: ProbeService,
) { ) {
} }
@ -60,7 +60,7 @@ export class ProbeDetailComponent implements OnInit {
this.displayNameErrMsg = msg; this.displayNameErrMsg = msg;
} else { } else {
this.displayNameErrMsg = null; this.displayNameErrMsg = null;
this.displayName = value; this.displayName = value.trim();
} }
} }
@ -70,15 +70,31 @@ export class ProbeDetailComponent implements OnInit {
this.descriptionErrMsg = msg; this.descriptionErrMsg = msg;
} else { } else {
this.descriptionErrMsg = null; this.descriptionErrMsg = null;
this.description = value; this.description = value.trim();
} }
} }
onEditSave() { onEditSave() {
this.probeHost.probe.displayName = this.displayName ? this.displayName : this.probeHost.probe.displayName; 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.probeHost.probe.description = this.description ? this.description : this.probeHost.probe.description;
this.modify.emit(this.probeHost);
this.probeService.modify(this.probeHost.probe)
.pipe(
tap(() => {
this.pending$ = of(true);
}),
map((probe: Probe) => {
this.editMode = false; 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 { checkValidDisplayName(value: string): string | null {