2021-08-30 22:07:50 +00:00
|
|
|
export default class KubeConfigController {
|
|
|
|
/* @ngInject */
|
2021-09-10 10:42:25 +00:00
|
|
|
constructor($async, $window, KubernetesConfigService, SettingsService) {
|
|
|
|
this.$async = $async;
|
2021-08-30 22:07:50 +00:00
|
|
|
this.$window = $window;
|
|
|
|
this.KubernetesConfigService = KubernetesConfigService;
|
2021-09-10 10:42:25 +00:00
|
|
|
this.SettingsService = SettingsService;
|
2021-08-30 22:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async downloadKubeconfig() {
|
|
|
|
await this.KubernetesConfigService.downloadConfig();
|
|
|
|
}
|
|
|
|
|
2021-09-10 10:42:25 +00:00
|
|
|
async expiryHoverMessage() {
|
|
|
|
const settings = await this.SettingsService.publicSettings();
|
|
|
|
const expiryDays = settings.KubeconfigExpiry;
|
|
|
|
switch (expiryDays) {
|
|
|
|
case '0':
|
|
|
|
this.state.expiryDays = 'not expire';
|
|
|
|
break;
|
|
|
|
case '24h':
|
|
|
|
this.state.expiryDays = 'expire in 1 day';
|
|
|
|
break;
|
|
|
|
case '168h':
|
|
|
|
this.state.expiryDays = 'expire in 7 days';
|
|
|
|
break;
|
|
|
|
case '720h':
|
|
|
|
this.state.expiryDays = 'expire in 30 days';
|
|
|
|
break;
|
|
|
|
case '8640h':
|
|
|
|
this.state.expiryDays = 'expire in 1 year';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-30 22:07:50 +00:00
|
|
|
$onInit() {
|
2021-09-10 10:42:25 +00:00
|
|
|
return this.$async(async () => {
|
|
|
|
this.state = {
|
|
|
|
isHTTPS: this.$window.location.protocol === 'https:',
|
|
|
|
expiryDays: '',
|
|
|
|
};
|
|
|
|
await this.expiryHoverMessage();
|
|
|
|
});
|
2021-08-30 22:07:50 +00:00
|
|
|
}
|
|
|
|
}
|