From 4879d6e2974e14005058446767a4fa16977ce273 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Mon, 12 Jul 2021 11:01:36 -0700 Subject: [PATCH] pygui: small cleanup for removing service configuration when they are removed/toggled --- daemon/core/gui/dialogs/nodeconfigservice.py | 9 ++------- daemon/core/gui/dialogs/nodeservice.py | 14 ++++---------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/daemon/core/gui/dialogs/nodeconfigservice.py b/daemon/core/gui/dialogs/nodeconfigservice.py index 7b55fba4..cddbdb03 100644 --- a/daemon/core/gui/dialogs/nodeconfigservice.py +++ b/daemon/core/gui/dialogs/nodeconfigservice.py @@ -103,6 +103,7 @@ class NodeConfigServiceDialog(Dialog): self.current_services.add(name) elif not var.get() and name in self.current_services: self.current_services.remove(name) + self.node.config_service_configs.pop(name, None) self.draw_current_services() self.node.config_services = self.current_services.copy() @@ -132,20 +133,13 @@ class NodeConfigServiceDialog(Dialog): if self.is_custom_service(name): self.current.listbox.itemconfig(tk.END, bg="green") - def cleanup_custom_services(self) -> None: - for service in list(self.node.config_service_configs): - if service not in self.node.config_services: - self.node.config_service_configs.pop(service) - def click_save(self) -> None: self.node.config_services = self.current_services.copy() - self.cleanup_custom_services() logger.info("saved node config services: %s", self.node.config_services) self.destroy() def click_cancel(self) -> None: self.current_services = None - self.cleanup_custom_services() self.destroy() def click_remove(self) -> None: @@ -154,6 +148,7 @@ class NodeConfigServiceDialog(Dialog): service = self.current.listbox.get(cur[0]) self.current.listbox.delete(cur[0]) self.current_services.remove(service) + self.node.config_service_configs.pop(service, None) for checkbutton in self.services.frame.winfo_children(): if checkbutton["text"] == service: checkbutton.invoke() diff --git a/daemon/core/gui/dialogs/nodeservice.py b/daemon/core/gui/dialogs/nodeservice.py index dd9b4419..431d5c3d 100644 --- a/daemon/core/gui/dialogs/nodeservice.py +++ b/daemon/core/gui/dialogs/nodeservice.py @@ -99,6 +99,8 @@ class NodeServiceDialog(Dialog): self.current_services.add(name) elif not var.get() and name in self.current_services: self.current_services.remove(name) + self.node.service_configs.pop(name, None) + self.node.service_file_configs.pop(name, None) self.current.listbox.delete(0, tk.END) for name in sorted(self.current_services): self.current.listbox.insert(tk.END, name) @@ -126,21 +128,11 @@ class NodeServiceDialog(Dialog): "Service Configuration", "Select a service to configure", parent=self ) - def cleanup_custom_services(self) -> None: - for service in list(self.node.service_configs): - if service not in self.node.services: - self.node.service_configs.pop(service) - for service in list(self.node.service_file_configs): - if service not in self.node.services: - self.node.service_file_configs.pop(service) - def click_cancel(self) -> None: - self.cleanup_custom_services() self.destroy() def click_save(self) -> None: self.node.services = self.current_services.copy() - self.cleanup_custom_services() self.destroy() def click_remove(self) -> None: @@ -149,6 +141,8 @@ class NodeServiceDialog(Dialog): service = self.current.listbox.get(cur[0]) self.current.listbox.delete(cur[0]) self.current_services.remove(service) + self.node.service_configs.pop(service, None) + self.node.service_file_configs.pop(service, None) for checkbutton in self.services.frame.winfo_children(): if checkbutton["text"] == service: checkbutton.invoke()