2018-06-28 17:45:26 +00:00
|
|
|
import { Component, Inject } from 'ng-metadata/core';
|
2018-06-12 15:28:58 +00:00
|
|
|
const templateUrl = require('./config-setup-app.component.html');
|
|
|
|
|
2018-08-06 14:52:56 +00:00
|
|
|
declare var window: any;
|
|
|
|
|
2018-06-12 15:28:58 +00:00
|
|
|
/**
|
|
|
|
* Initial Screen and Choice in the Config App
|
|
|
|
*/
|
|
|
|
@Component({
|
|
|
|
selector: 'config-setup-app',
|
|
|
|
templateUrl: templateUrl,
|
|
|
|
})
|
|
|
|
export class ConfigSetupAppComponent {
|
2018-06-27 17:49:54 +00:00
|
|
|
private state
|
|
|
|
: 'choice'
|
|
|
|
| 'setup'
|
|
|
|
| 'load'
|
2018-08-06 14:52:56 +00:00
|
|
|
| 'download'
|
|
|
|
| 'deploy';
|
2018-06-27 17:49:54 +00:00
|
|
|
|
|
|
|
private loadedConfig = false;
|
2018-08-09 20:43:11 +00:00
|
|
|
private kubeNamespace: string | boolean = false;
|
2018-06-12 15:28:58 +00:00
|
|
|
|
2018-06-28 17:45:26 +00:00
|
|
|
constructor(@Inject('ApiService') private apiService) {
|
2018-06-12 15:28:58 +00:00
|
|
|
this.state = 'choice';
|
2018-08-09 20:43:11 +00:00
|
|
|
if (window.__kubernetes_namespace) {
|
|
|
|
this.kubeNamespace = window.__kubernetes_namespace;
|
2018-08-06 14:52:56 +00:00
|
|
|
}
|
2018-06-12 15:28:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private chooseSetup(): void {
|
2018-06-28 17:45:26 +00:00
|
|
|
this.apiService.scStartNewConfig()
|
|
|
|
.then(() => {
|
|
|
|
this.state = 'setup';
|
|
|
|
})
|
|
|
|
.catch(this.apiService.errorDisplay(
|
|
|
|
'Could not initialize new setup. Please report this error'
|
|
|
|
));
|
2018-06-12 15:28:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private chooseLoad(): void {
|
|
|
|
this.state = 'load';
|
2018-06-27 17:49:54 +00:00
|
|
|
this.loadedConfig = true;
|
2018-06-12 15:28:58 +00:00
|
|
|
}
|
2018-06-19 17:46:34 +00:00
|
|
|
|
2018-08-06 14:52:56 +00:00
|
|
|
private choosePopulate(): void {
|
2018-08-20 17:47:10 +00:00
|
|
|
this.apiService.scKubePopulateConfig()
|
|
|
|
.then(() => {
|
|
|
|
this.state = 'setup';
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
this.apiService.errorDisplay(
|
|
|
|
`Could not populate the configuration from your cluster. Please report this error: ${JSON.stringify(err)}`
|
|
|
|
)()
|
|
|
|
})
|
2018-08-06 14:52:56 +00:00
|
|
|
}
|
|
|
|
|
2018-06-19 17:46:34 +00:00
|
|
|
private configLoaded(): void {
|
|
|
|
this.state = 'setup';
|
|
|
|
}
|
2018-06-27 17:49:54 +00:00
|
|
|
|
|
|
|
private setupCompleted(): void {
|
|
|
|
this.state = 'download';
|
|
|
|
}
|
2018-08-06 14:52:56 +00:00
|
|
|
|
|
|
|
private chooseDeploy(): void {
|
|
|
|
this.state = 'deploy';
|
|
|
|
}
|
2018-06-12 15:28:58 +00:00
|
|
|
}
|