probe detail modify bug fix
This commit is contained in:
parent
f26e14bad3
commit
28b5e819fa
|
@ -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<any>;
|
||||
|
||||
@Output() modify = new EventEmitter<ProbeHost>();
|
||||
@Output() discovery = new EventEmitter<number>();
|
||||
|
||||
|
||||
editMode = false;
|
||||
displayNameErrMsg: string;
|
||||
descriptionErrMsg: string;
|
||||
|
@ -30,27 +29,28 @@ export class ProbeDetailComponent implements OnInit {
|
|||
|
||||
constructor(
|
||||
private store: Store<any>,
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user