styleUrls: ['./config-xds.component.scss'],
templateUrl: './config-xds.component.html',
})
-export class ConfigXdsComponent implements OnInit {
+export class ConfigXdsComponent {
// TODO: cleanup agentStatus$: Observable<IAgentStatus>;
- connecting = false;
+ applying = false;
xdsServerUrl = '';
- server: IXDServerCfg;
+ server: IXDServerCfg = { id: '', url: 'http://localhost:8000', connRetry: 10, connected: false };
configFormChanged = false;
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);
});
}