Skip to content

Commit

Permalink
add UserGroups grid
Browse files Browse the repository at this point in the history
Signed-off-by: matthias.gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Nov 29, 2024
1 parent 4feb516 commit 973d48c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions osc_tui/mainForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def swicthToVolumeLink(self, id, volume):

# update draw_line_at when adding a new resource
class mainMenu(osc_npyscreen.MultiLineAction):
def __init__(self, screen, form=None, draw_line_at=19, *args, **keywords):
def __init__(self, screen, form=None, draw_line_at=20, *args, **keywords):
super().__init__(screen, *args, **keywords)
self.form = form
self.cursor_line = SELECTED_BUTTON
Expand Down Expand Up @@ -262,7 +262,7 @@ def build_line(size):
out = out + '‎'
return out
menu_desc = (
"Vms Security Volumes Snapshots Keypairs Images LoadBalancers Nets Subnets PublicIps Nics NetAccessPoints NetPeering InternetServices NatServices RouteTables DhcpOptions GPUs Users " + build_line(15) + " Refresh Quit").split()
"Vms Security Volumes Snapshots Keypairs Images LoadBalancers Nets Subnets PublicIps Nics NetAccessPoints NetPeering InternetServices NatServices RouteTables DhcpOptions GPUs Users UserGroups " + build_line(15) + " Refresh Quit").split()
global CURRENT_GRID_CLASS
y, _ = self.useable_space()
self.rowOffset = MENU_WIDTH
Expand Down Expand Up @@ -326,6 +326,8 @@ def build_line(size):
CURRENT_GRID_CLASS = natServices.natServicesGrid
elif MODE == 'Users':
CURRENT_GRID_CLASS = userGrid.userGrid
elif MODE == 'UserGroups':
CURRENT_GRID_CLASS = userGrid.userGroupGrid
elif MODE == 'PublicIps':
CURRENT_GRID_CLASS = publicIps.publicIpsGrid
elif MODE == 'Keypairs':
Expand Down
18 changes: 18 additions & 0 deletions osc_tui/userGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,21 @@ def refresh(self):
values.append([g['UserId'], g['UserName'], g['UserEmail'],
g["CreationDate"]])
self.values = values

class userGroupGrid(selectableGrid.SelectableGrid):
def __init__(self, screen, *args, **keywords):
super().__init__(screen, *args, **keywords)
self.col_titles = ["Id", "Name", "Path", "Orn", "CreationDate"]

def refresh_call(self, name_filter=None):
groups = main.GATEWAY.ReadUserGroups(form=self.form)['UserGroups']
return groups

def refresh(self):
groups = main.do_search(self.data.copy(), ["UserGroupId", "Name",
"Path", "Orn", "CreationDate"])
values = list()
for g in groups:
values.append([g['UserGroupId'], g['Name'], g['Path'], g["Orn"],
g["CreationDate"]])
self.values = values

0 comments on commit 973d48c

Please sign in to comment.