mirror of https://github.com/portainer/portainer
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 userpull/5605/head
parent
d8b88d1004
commit
756ef060db
|
@ -22,6 +22,8 @@ type publicSettingsResponse struct {
|
|||
OAuthLogoutURI string `json:"OAuthLogoutURI" example:"https://gitlab.com/oauth/logout"`
|
||||
// Whether telemetry is enabled
|
||||
EnableTelemetry bool `json:"EnableTelemetry" example:"true"`
|
||||
// The expiry of a Kubeconfig
|
||||
KubeconfigExpiry string `example:"24h" default:"0"`
|
||||
}
|
||||
|
||||
// @id SettingsPublic
|
||||
|
@ -49,6 +51,7 @@ func generatePublicSettings(appSettings *portainer.Settings) *publicSettingsResp
|
|||
AuthenticationMethod: appSettings.AuthenticationMethod,
|
||||
EnableEdgeComputeFeatures: appSettings.EnableEdgeComputeFeatures,
|
||||
EnableTelemetry: appSettings.EnableTelemetry,
|
||||
KubeconfigExpiry: appSettings.KubeconfigExpiry,
|
||||
}
|
||||
//if OAuth authentication is on, compose the related fields from application settings
|
||||
if publicSettings.AuthenticationMethod == portainer.AuthenticationOAuth {
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -21,6 +21,7 @@ export function PublicSettingsViewModel(settings) {
|
|||
this.OAuthLoginURI = settings.OAuthLoginURI;
|
||||
this.EnableTelemetry = settings.EnableTelemetry;
|
||||
this.OAuthLogoutURI = settings.OAuthLogoutURI;
|
||||
this.KubeconfigExpiry = settings.KubeconfigExpiry;
|
||||
}
|
||||
|
||||
export function LDAPSettingsViewModel(data) {
|
||||
|
|
Loading…
Reference in New Issue