Skip to content

Commit

Permalink
add colors to a lot of stuffs
Browse files Browse the repository at this point in the history
Signed-off-by: matthias.gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Feb 13, 2024
1 parent 3b6a9e1 commit 3fdee0e
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
14 changes: 14 additions & 0 deletions osc_tui/netPeering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 13 additions & 0 deletions osc_tui/nicsGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 11 additions & 0 deletions osc_tui/publicIps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions osc_tui/volumesGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 28 additions & 0 deletions osc_tui/vpcsGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand All @@ -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)
Expand Down

0 comments on commit 3fdee0e

Please sign in to comment.