From 3fdee0ef2b5a055f366a85901949ec23ba4f890e Mon Sep 17 00:00:00 2001 From: "matthias.gatto" Date: Tue, 13 Feb 2024 19:02:24 +0100 Subject: [PATCH] add colors to a lot of stuffs Signed-off-by: matthias.gatto --- osc_tui/netPeering.py | 14 ++++++++++++++ osc_tui/nicsGrid.py | 13 +++++++++++++ osc_tui/publicIps.py | 11 +++++++++++ osc_tui/volumesGrid.py | 12 ++++++++++++ osc_tui/vpcsGrid.py | 28 ++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+) diff --git a/osc_tui/netPeering.py b/osc_tui/netPeering.py index 63dff7f..334f815 100644 --- a/osc_tui/netPeering.py +++ b/osc_tui/netPeering.py @@ -9,6 +9,20 @@ def __init__(self, screen, *args, **keywords): def refresh_call(self, name_filter=None): return main.GATEWAY.ReadNetPeerings(form=self.form)['NetPeerings'] + def custom_print_cell(self, cell, cell_value): + # Checking if we are in the table and not in the title's row. + if not isinstance(cell.grid_current_value_index, int): + y, _ = cell.grid_current_value_index + state = self.values[y][2] + cell.highlight_whole_widget = True + # states: pending-acceptance | active | rejected | failed | expired | deleted + if state == "active": + cell.color = "GOODHL" + elif state == "pending-acceptance": + cell.color = "CURSOR" + else: + cell.color = "DANGER" + def refresh(self): groups = main.do_search(self.data.copy(), ['NetPeeringId'], state_msg=True, accepted_net=True) diff --git a/osc_tui/nicsGrid.py b/osc_tui/nicsGrid.py index a56e496..b99fc95 100644 --- a/osc_tui/nicsGrid.py +++ b/osc_tui/nicsGrid.py @@ -10,6 +10,19 @@ def refresh_call(self, name_filter=None): groups = main.GATEWAY.ReadNics(form=self.form)['Nics'] return groups + def custom_print_cell(self, cell, cell_value): + # Checking if we are in the table and not in the title's row. + if not isinstance(cell.grid_current_value_index, int): + y, _ = cell.grid_current_value_index + state = self.values[y][1] + cell.highlight_whole_widget = True + if state == "in-use": + cell.color = "GOODHL" + elif state == "available": + cell.color = "CURSOR" + else: + cell.color = "RED_BLACK" + def refresh(self): nics = main.do_search(self.data.copy(), ["NicId", "State", "SubnetId", "NetId", "Description", "MacAddress"]) values = list() diff --git a/osc_tui/publicIps.py b/osc_tui/publicIps.py index ee3038f..341092f 100644 --- a/osc_tui/publicIps.py +++ b/osc_tui/publicIps.py @@ -10,6 +10,17 @@ def refresh_call(self, name_filter=None): groups = main.GATEWAY.ReadPublicIps(form=self.form)['PublicIps'] return groups + def custom_print_cell(self, cell, cell_value): + # Checking if we are in the table and not in the title's row. + if not isinstance(cell.grid_current_value_index, int): + y, _ = cell.grid_current_value_index + linkto = self.values[y][2] + cell.highlight_whole_widget = True + if linkto == "unattached": + cell.color = "CURSOR" + else: + cell.color = "GOODHL" + def refresh(self): groups = main.do_search(self.data.copy(), ["PublicIpId", "PublicIp", "VmId"]) values = list() diff --git a/osc_tui/volumesGrid.py b/osc_tui/volumesGrid.py index b1535a1..52124f8 100644 --- a/osc_tui/volumesGrid.py +++ b/osc_tui/volumesGrid.py @@ -22,6 +22,18 @@ def on_selection(line): self.on_selection = on_selection + def custom_print_cell(self, cell, cell_value): + # Checking if we are in the table and not in the title's row. + if not isinstance(cell.grid_current_value_index, int): + y, _ = cell.grid_current_value_index + linkto = self.values[y][5] + cell.highlight_whole_widget = True + if linkto == "Unlinked": + cell.color = "CURSOR" + else: + cell.color = "GOODHL" + + def refresh_call(self, name_filter=None): groups = main.GATEWAY.ReadVolumes(form=self.form) if groups is None: diff --git a/osc_tui/vpcsGrid.py b/osc_tui/vpcsGrid.py index 5853644..f4ec04a 100644 --- a/osc_tui/vpcsGrid.py +++ b/osc_tui/vpcsGrid.py @@ -17,6 +17,20 @@ def refresh_call(self, name_filter=None): groups = main.GATEWAY.ReadNets(form=self.form)['Nets'] return groups + def custom_print_cell(self, cell, cell_value): + # Checking if we are in the table and not in the title's row. + if not isinstance(cell.grid_current_value_index, int): + y, _ = cell.grid_current_value_index + state = self.values[y][3] + # states: pending | available | deleted + cell.highlight_whole_widget = True + if state == "available": + cell.color = "GOODHL" + elif state == "deleted": + cell.color = "DANGER" + else: + cell.color = "RED_BLACK" + def refresh(self): groups = main.do_search(self.data.copy(), ["NetId", "IpRange", "DhcpOptionsSetId", "State"]) @@ -42,6 +56,20 @@ def refresh_call(self, name_filter=None): Filters={"NetIds": [popup.SUBNETID]})['Subnets'] return groups + def custom_print_cell(self, cell, cell_value): + # Checking if we are in the table and not in the title's row. + if not isinstance(cell.grid_current_value_index, int): + y, _ = cell.grid_current_value_index + state = self.values[y][4] + # states: pending | available | deleted + cell.highlight_whole_widget = True + if state == "available": + cell.color = "GOODHL" + elif state == "deleted": + cell.color = "DANGER" + else: + cell.color = "RED_BLACK" + def refresh(self): groups = main.do_search(self.data.copy(), ["SubnetId", "IpRange", "NetId", "State"], name_as_tag=True)