diff --git a/osc_tui/popup.py b/osc_tui/popup.py index 3aa4f6f..81c1ea9 100644 --- a/osc_tui/popup.py +++ b/osc_tui/popup.py @@ -287,6 +287,44 @@ def add_to_lbu(): F.edit() +def selectRouteTable(form, rt, form_color='STANDOUT'): + id = rt[0] + F = displayPopup(id, color=form_color) + F.preserve_selected_widget = True + + def exit(): + F.editing = False + + F.on_ok = exit + info = F.add_widget( + oscscreen.ButtonPress, + name="INFO", + ) + + def info_rt(): + exit() + F = displayPopupWide(name = "Route Table Info id: " + id) + F.preserve_selected_widget = True + + ft = F.add_widget( + oscscreen.Pager, + ) + sg = main.GATEWAY.ReadRouteTables(form=form, Filters={"RouteTableIds": [id]}) + sg = sg["RouteTables"][0] + + ft.values = json.dumps(sg, indent=2).split("\n") + + def ok(): + exit() + + F.on_ok = ok + F.edit() + + info.whenPressed = info_rt + F.edit() + form.current_grid.display() + + def editSecurityGroup(form, sg, form_color='STANDOUT'): name = sg[1] id = sg[0] diff --git a/osc_tui/routeTables.py b/osc_tui/routeTables.py index 53d06a8..7fb3a7a 100644 --- a/osc_tui/routeTables.py +++ b/osc_tui/routeTables.py @@ -5,15 +5,20 @@ class routeTablesGrid(selectableGrid.SelectableGrid): def __init__(self, screen, *args, **keywords): super().__init__(screen, *args, **keywords) - self.col_titles = ["Id"] + self.col_titles = ["Id", "NetId"] + + def on_selection(line): + popup.selectRouteTable(self.form, line) + + self.on_selection = on_selection def refresh_call(self, name_filter=None): groups = main.GATEWAY.ReadRouteTables(form=self.form)['RouteTables'] return groups def refresh(self): - groups = main.do_search(self.data.copy(), ["RouteTableId"]) + groups = main.do_search(self.data.copy(), ["RouteTableId", "NetId"]) values = list() for g in groups: - values.append([g['RouteTableId']]) + values.append([g['RouteTableId'], g["NetId"] if "NetId" in g else "No Net"]) self.values = values