From f6b2c879bc7daa58358ab572ee8114e667e00178 Mon Sep 17 00:00:00 2001 From: Matt Hook Date: Tue, 27 Feb 2024 11:18:28 +1300 Subject: [PATCH] fix(kube): make app autorefresh and show system settings stay [EE-6771] (#11256) --- .../applicationsDatatableController.js | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/kubernetes/components/datatables/applications-datatable/applicationsDatatableController.js b/app/kubernetes/components/datatables/applications-datatable/applicationsDatatableController.js index 527a2d6e2..099ee534d 100644 --- a/app/kubernetes/components/datatables/applications-datatable/applicationsDatatableController.js +++ b/app/kubernetes/components/datatables/applications-datatable/applicationsDatatableController.js @@ -169,20 +169,22 @@ angular.module('portainer.kubernetes').controller('KubernetesApplicationsDatatab }; this.$onChanges = function (changes) { - // when the table is visible, sync the show system setting with the stack show system setting - if (changes.isVisible && changes.isVisible.currentValue) { - const storedStacksSettings = DatatableService.getDataTableSettings('kubernetes.applications.stacks'); - if (storedStacksSettings && storedStacksSettings.state) { - this.settings.showSystem = storedStacksSettings.state.showSystemResources; + if (this.settingsLoaded) { + // when the table is visible, sync the show system setting with the stack show system setting + if (changes.isVisible && changes.isVisible.currentValue) { + const storedStacksSettings = DatatableService.getDataTableSettings('kubernetes.applications.stacks'); + if (storedStacksSettings && storedStacksSettings.state) { + this.settings.showSystem = storedStacksSettings.state.showSystemResources; + DatatableService.setDataTableSettings(this.settingsKey, this.settings); + } + } else if (typeof this.isSystemResources !== 'undefined') { + this.settings.showSystem = this.isSystemResources; DatatableService.setDataTableSettings(this.settingsKey, this.settings); } - } else if (typeof this.isSystemResources !== 'undefined') { - this.settings.showSystem = this.isSystemResources; - DatatableService.setDataTableSettings(this.settingsKey, this.settings); + this.state.namespace = this.namespace; + this.updateNamespace(); + this.prepareTableFromDataset(); } - this.state.namespace = this.namespace; - this.updateNamespace(); - this.prepareTableFromDataset(); }; this.$onInit = function () { @@ -226,7 +228,7 @@ angular.module('portainer.kubernetes').controller('KubernetesApplicationsDatatab // make show system in sync with the stack show system settings const storedStacksSettings = DatatableService.getDataTableSettings('kubernetes.applications.stacks'); if (storedStacksSettings && storedStacksSettings.state) { - this.settings.showSystem = storedStacksSettings.state.showSystemResources; + this.settings.showSystem = storedStacksSettings.state.showSystemResources || this.settings.showSystem; } this.setSystemResources && this.setSystemResources(this.settings.showSystem);