add Databases and Positions menus

pull/20/head
Max Erenberg 1 year ago
parent df7148940a
commit 4aaf10b687
  1. 3
      ceo/tui/CeoFrame.py
  2. 63
      ceo/tui/WelcomeView.py

@ -30,6 +30,9 @@ class CeoFrame(Frame):
self._name = name
self._loaded = False
self._has_dynamic_layouts = has_dynamic_layouts
# sanity check
if save_data:
assert name in model.viewdata
def _ceoframe_on_load(self):
# We usually don't want _on_load() to be called multiple times

@ -23,40 +23,40 @@ class WelcomeView(Frame):
('Change login shell', 'ChangeLoginShell'),
('Set forwarding addresses', 'SetForwardingAddresses'),
]
members_menu = ListBox(
len(members_menu_items),
[
(desc, i) for i, (desc, view) in
enumerate(members_menu_items)
],
name='members',
label='Members',
on_select=self._members_menu_select,
)
members_menu = self._create_menu(
members_menu_items, 'members', self._members_menu_select)
groups_menu_items = [
('Add group', 'AddGroup'),
('Get group members', 'GetGroup'),
('Add member to group', 'AddMemberToGroup'),
('Remove member from group', 'RemoveMemberFromGroup'),
]
groups_menu = ListBox(
len(groups_menu_items),
[
(desc, i) for i, (desc, view) in
enumerate(groups_menu_items)
],
name='groups',
label='Groups',
on_select=functools.partial(self._generic_menu_select, 'groups'),
)
groups_menu = self._create_menu(groups_menu_items, 'groups')
db_menu_items = [
('Create MySQL database', 'CreateMySQL'),
('Reset MySQL password', 'ResetMySQLPassword'),
('Create PostgreSQL database', 'CreatePostgreSQL'),
('Reset PostgreSQL password', 'ResetPostgreSQLPassword'),
]
db_menu = self._create_menu(
db_menu_items, 'databases', self._db_menu_select)
positions_menu_items = [
('Get positions', 'GetPositions'),
('Set positions', 'SetPositions'),
]
positions_menu = self._create_menu(positions_menu_items, 'positions')
self._menu_groups = {
'members': members_menu_items,
'groups': groups_menu_items,
'databases': db_menu_items,
'positions': positions_menu_items,
}
layout = Layout([100], fill_frame=True)
layout = Layout([1, 4, 1], fill_frame=True)
self.add_layout(layout)
layout.add_widget(members_menu)
layout.add_widget(groups_menu)
layout.add_widget(members_menu, 1)
layout.add_widget(groups_menu, 1)
layout.add_widget(db_menu, 1)
layout.add_widget(positions_menu, 1)
layout = Layout([100])
self.add_layout(layout)
@ -68,6 +68,20 @@ class WelcomeView(Frame):
layout.add_widget(Button("Quit", self._quit), 2)
self.fix()
def _create_menu(self, menu_items, name, on_select=None):
if on_select is None:
on_select = functools.partial(self._generic_menu_select, name)
return ListBox(
len(menu_items),
[
(desc, i) for i, (desc, view) in
enumerate(menu_items)
],
name=name,
label=name.capitalize(),
on_select=on_select,
)
def _get_menu_item_desc_view(self, menu_name: str):
self.save()
item_id = self.data[menu_name]
@ -80,6 +94,9 @@ class WelcomeView(Frame):
self._model.is_club_rep = True
self._welcomeview_go_to_next_scene(desc, view)
def _db_menu_select(self):
pass
def _generic_menu_select(self, menu_name):
desc, view = self._get_menu_item_desc_view('groups')
self._welcomeview_go_to_next_scene(desc, view)

Loading…
Cancel
Save