pygui: small cleanup for removing service configuration when they are removed/toggled
This commit is contained in:
parent
54ac807a4f
commit
4879d6e297
2 changed files with 6 additions and 17 deletions
|
@ -103,6 +103,7 @@ class NodeConfigServiceDialog(Dialog):
|
||||||
self.current_services.add(name)
|
self.current_services.add(name)
|
||||||
elif not var.get() and name in self.current_services:
|
elif not var.get() and name in self.current_services:
|
||||||
self.current_services.remove(name)
|
self.current_services.remove(name)
|
||||||
|
self.node.config_service_configs.pop(name, None)
|
||||||
self.draw_current_services()
|
self.draw_current_services()
|
||||||
self.node.config_services = self.current_services.copy()
|
self.node.config_services = self.current_services.copy()
|
||||||
|
|
||||||
|
@ -132,20 +133,13 @@ class NodeConfigServiceDialog(Dialog):
|
||||||
if self.is_custom_service(name):
|
if self.is_custom_service(name):
|
||||||
self.current.listbox.itemconfig(tk.END, bg="green")
|
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:
|
def click_save(self) -> None:
|
||||||
self.node.config_services = self.current_services.copy()
|
self.node.config_services = self.current_services.copy()
|
||||||
self.cleanup_custom_services()
|
|
||||||
logger.info("saved node config services: %s", self.node.config_services)
|
logger.info("saved node config services: %s", self.node.config_services)
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def click_cancel(self) -> None:
|
def click_cancel(self) -> None:
|
||||||
self.current_services = None
|
self.current_services = None
|
||||||
self.cleanup_custom_services()
|
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def click_remove(self) -> None:
|
def click_remove(self) -> None:
|
||||||
|
@ -154,6 +148,7 @@ class NodeConfigServiceDialog(Dialog):
|
||||||
service = self.current.listbox.get(cur[0])
|
service = self.current.listbox.get(cur[0])
|
||||||
self.current.listbox.delete(cur[0])
|
self.current.listbox.delete(cur[0])
|
||||||
self.current_services.remove(service)
|
self.current_services.remove(service)
|
||||||
|
self.node.config_service_configs.pop(service, None)
|
||||||
for checkbutton in self.services.frame.winfo_children():
|
for checkbutton in self.services.frame.winfo_children():
|
||||||
if checkbutton["text"] == service:
|
if checkbutton["text"] == service:
|
||||||
checkbutton.invoke()
|
checkbutton.invoke()
|
||||||
|
|
|
@ -99,6 +99,8 @@ class NodeServiceDialog(Dialog):
|
||||||
self.current_services.add(name)
|
self.current_services.add(name)
|
||||||
elif not var.get() and name in self.current_services:
|
elif not var.get() and name in self.current_services:
|
||||||
self.current_services.remove(name)
|
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)
|
self.current.listbox.delete(0, tk.END)
|
||||||
for name in sorted(self.current_services):
|
for name in sorted(self.current_services):
|
||||||
self.current.listbox.insert(tk.END, name)
|
self.current.listbox.insert(tk.END, name)
|
||||||
|
@ -126,21 +128,11 @@ class NodeServiceDialog(Dialog):
|
||||||
"Service Configuration", "Select a service to configure", parent=self
|
"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:
|
def click_cancel(self) -> None:
|
||||||
self.cleanup_custom_services()
|
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def click_save(self) -> None:
|
def click_save(self) -> None:
|
||||||
self.node.services = self.current_services.copy()
|
self.node.services = self.current_services.copy()
|
||||||
self.cleanup_custom_services()
|
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def click_remove(self) -> None:
|
def click_remove(self) -> None:
|
||||||
|
@ -149,6 +141,8 @@ class NodeServiceDialog(Dialog):
|
||||||
service = self.current.listbox.get(cur[0])
|
service = self.current.listbox.get(cur[0])
|
||||||
self.current.listbox.delete(cur[0])
|
self.current.listbox.delete(cur[0])
|
||||||
self.current_services.remove(service)
|
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():
|
for checkbutton in self.services.frame.winfo_children():
|
||||||
if checkbutton["text"] == service:
|
if checkbutton["text"] == service:
|
||||||
checkbutton.invoke()
|
checkbutton.invoke()
|
||||||
|
|
Loading…
Reference in a new issue