X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=webapp%2Fsrc%2Fapp%2Fpages%2Fconfig%2Fconfig-xds%2Fconfig-xds.component.ts;h=bd461459907d055b991eb5135026d7d012c14489;hb=cd8d64e86de540aea78a253c5fcc7826e8f15456;hp=ffd236daaa1f3d686c4494c3034dc5585d7bff29;hpb=38c0c21a969e621c725245ce91c78e77076c5ce7;p=src%2Fxds%2Fxds-agent.git diff --git a/webapp/src/app/pages/config/config-xds/config-xds.component.ts b/webapp/src/app/pages/config/config-xds/config-xds.component.ts index ffd236d..bd46145 100644 --- a/webapp/src/app/pages/config/config-xds/config-xds.component.ts +++ b/webapp/src/app/pages/config/config-xds/config-xds.component.ts @@ -15,12 +15,12 @@ import 'rxjs/add/operator/catch'; styleUrls: ['./config-xds.component.scss'], templateUrl: './config-xds.component.html', }) -export class ConfigXdsComponent implements OnInit { +export class ConfigXdsComponent { // TODO: cleanup agentStatus$: Observable; - connecting = false; + applying = false; xdsServerUrl = ''; - server: IXDServerCfg; + server: IXDServerCfg = { id: '', url: 'http://localhost:8000', connRetry: 10, connected: false }; configFormChanged = false; @@ -28,33 +28,32 @@ export class ConfigXdsComponent implements OnInit { private XdsConfigSvr: XDSConfigService, private alert: AlertService, ) { - } - - ngOnInit() { // FIXME support multiple servers - - this.server = this.XdsConfigSvr.getCurServer(); - this.xdsServerUrl = this.server.url; - this.XdsConfigSvr.onCurServer().subscribe(svr => { this.xdsServerUrl = svr.url; - this.server = svr; + this.server = Object.assign({}, svr); }); } + isApplyBtnEnable(): boolean { + return this.xdsServerUrl !== '' && (!this.server.connected || this.configFormChanged); + } + onSubmit() { if (!this.configFormChanged && this.server.connected) { return; } this.configFormChanged = false; - this.connecting = true; + this.applying = true; this.server.url = this.xdsServerUrl; this.XdsConfigSvr.setCurServer(this.server) .subscribe(cfg => { - this.connecting = false; - }, + this.alert.info('XDS Server successfully connected (' + cfg.url + ')'); + this.server = Object.assign({}, cfg); + this.applying = false; + }, err => { - this.connecting = false; + this.applying = false; this.alert.error(err); }); }