mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
feat(k8s):add kubeconfig expiry days on mouse hover EE-1300 (#5589)
* add kubeconfig expiry days on mouse hover * replace settings with publicSettings for non-admin user
This commit is contained in:
parent
d8b88d1004
commit
756ef060db
4 changed files with 39 additions and 3 deletions
|
@ -1,15 +1,45 @@
|
|||
export default class KubeConfigController {
|
||||
/* @ngInject */
|
||||
constructor($window, KubernetesConfigService) {
|
||||
constructor($async, $window, KubernetesConfigService, SettingsService) {
|
||||
this.$async = $async;
|
||||
this.$window = $window;
|
||||
this.KubernetesConfigService = KubernetesConfigService;
|
||||
this.SettingsService = SettingsService;
|
||||
}
|
||||
|
||||
async downloadKubeconfig() {
|
||||
await this.KubernetesConfigService.downloadConfig();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
this.state = { isHTTPS: this.$window.location.protocol === 'https:' };
|
||||
return this.$async(async () => {
|
||||
this.state = {
|
||||
isHTTPS: this.$window.location.protocol === 'https:',
|
||||
expiryDays: '',
|
||||
};
|
||||
await this.expiryHoverMessage();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<button
|
||||
<span class="interactive" tooltip-append-to-body="true" tooltip-placement="bottom" tooltip-class="portainer-tooltip" uib-tooltip="Kubeconfig file will {{ $ctrl.state.expiryDays }}">
|
||||
<button
|
||||
ng-if="$ctrl.state.isHTTPS"
|
||||
type="button"
|
||||
class="btn btn-xs btn-primary"
|
||||
|
@ -9,3 +10,4 @@
|
|||
>
|
||||
Kubeconfig <i class="fas fa-download space-right"></i>
|
||||
</button>
|
||||
</span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue