From 1c3b2ab922848409d5d4d6e6b1b085e837cccb80 Mon Sep 17 00:00:00 2001 From: MAL Date: Tue, 22 Aug 2023 15:25:50 +0200 Subject: [PATCH 1/2] add shortcuts for navigation : Create / Keypairs --- osc_tui/mainForm.py | 56 ++++++++++++++++++++++++++++++++++++++++++--- osc_tui/popup.py | 21 +++++++++++++++-- 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/osc_tui/mainForm.py b/osc_tui/mainForm.py index 2924693..e40e776 100644 --- a/osc_tui/mainForm.py +++ b/osc_tui/mainForm.py @@ -181,10 +181,10 @@ def actionHighlighted(self, act_on_this, key_press): elif MODE == 'Nets': if act_on_this == 'Create new': self.form.parentApp.addForm( - "CREATE_VPCs", - createVpcs.createVpcs, + "CREATE_VPCS", + createVpcs.CreateVpcs, name="osc-tui") - self.form.parentApp.switchForm("CREATE_VPCs") + self.form.parentApp.switchForm("CREATE_VPCS") return elif MODE == 'Images': if act_on_this == 'Filter': @@ -334,6 +334,36 @@ def build_line(size): rely=2, ) + def create_new(self, _): + global MODE + if MODE == "Vms": + self.parentApp.addForm("CREATE_VM", createVm.CreateVm, name="osc-tui") + self.parentApp.switchForm("CREATE_VM") + elif MODE == "Security": + popup.newSecurityGroup(self) + elif MODE == "Volumes": + self.parentApp.addForm("CREATE_VOLUME", createVolume.CreateVolume, name="osc-tui") + self.parentApp.switchForm("CREATE_VOLUME") + elif MODE == "Snapshots": + self.parentApp.addForm("CREATE_SNAPSHOT", createSnapshot.CreateSnapshot, name="osc-tui") + self.parentApp.switchForm("CREATE_SNAPSHOT") + elif MODE == "Keypairs": + self.parentApp.addForm("CREATE_KEYPAIR", createKeyPair.CreateKeyPair, name="osc-tui") + self.parentApp.switchForm("CREATE_KEYPAIR") + elif MODE == "Images": + self.parentApp.addForm("CREATE_Images", createImage.CreateImage, name="osc-tui") + self.parentApp.switchForm("CREATE_Images") + elif MODE == "LoadBalancers": + self.parentApp.addForm("CREATE_LOADBALANCER", createLoadbalancer.CreateLoadbalancer, name="osc-tui") + self.parentApp.switchForm("CREATE_LOADBALANCER") + elif MODE == "Nets": + self.parentApp.addForm("CREATE_VPCS", createVpcs.CreateVpcs, name="osc-tui") + self.parentApp.switchForm("CREATE_VPCS") + elif MODE == "NetAccessPoints": + self.parentApp.addForm("CREATE_NET-ACCESS-POINT", createNetAccessPoint.CreateNetAccessPoint, name="osc-tui") + self.parentApp.switchForm("CREATE_NET-ACCESS-POINT") + + def on_screen(self): super().on_screen() @@ -373,7 +403,21 @@ def switch_to_images(form, _): def switch_to_security_grid(form, _): global MODE MODE = "Security" +<<<<<<< HEAD form.reload() +======= + self.reload() + + def switch_to_nets(self, _): + global MODE + MODE = "Nets" + self.reload() + + def switch_to_keypairs(self, _): + global MODE + MODE = "Keypairs" + self.reload() +>>>>>>> 78b59da (add shortcuts for navigation : Create / Keypairs) def set_up_handlers(self): super().set_up_handlers() @@ -381,10 +425,16 @@ def set_up_handlers(self): self.add_handlers({"^Q": quit}) self.add_handlers({"h": popup.showHelp}) self.add_handlers({"/": popup.slashSearch}) + self.add_handlers({"C": self.create_new}) self.add_handlers({"V": self.switch_to_volumes}) self.add_handlers({"I": self.switch_to_instances}) self.add_handlers({"M": self.switch_to_images}) self.add_handlers({"S": self.switch_to_security_grid}) +<<<<<<< HEAD +======= + self.add_handlers({"T": self.switch_to_nets}) + self.add_handlers({"K": self.switch_to_keypairs}) +>>>>>>> 78b59da (add shortcuts for navigation : Create / Keypairs) self.add_handlers({ "r" : self.key_reload, curses.KEY_F5 : self.key_reload diff --git a/osc_tui/popup.py b/osc_tui/popup.py index 973e0e2..b2aaaf3 100644 --- a/osc_tui/popup.py +++ b/osc_tui/popup.py @@ -822,7 +822,7 @@ def capsule(): " |/\n" + " +\n", - r" \| \n" + + " \| \n" + " +\n", " \\ \n" + @@ -1070,11 +1070,13 @@ def showHelp(arg): "Refresh : F5 or r", "Search in Fields : /", "search in Menu : l", - "Help : h\n", + "Help : h", "Switch to Vms : I", "Switch to Volumes : V", "Switch to Images : M", "Switch to Security : S", + "Switch to Nets : T", + "Switch to Keypairs : K\n", ] def ok(): @@ -1082,3 +1084,18 @@ def ok(): F.on_ok = ok F.edit() + +def errorPopup(message): + F = displayPopup(name = "Error") + F.preserve_selected_widget = True + + ft = F.add_widget( + oscscreen.Pager, + ) + ft.values = [message] + + def ok(): + exit() + + F.on_ok = ok + F.edit() From b915f25edff1c91dcd3de1110a17e6d845a78147 Mon Sep 17 00:00:00 2001 From: MAL Date: Thu, 14 Sep 2023 11:17:05 +0200 Subject: [PATCH 2/2] add shortcuts --- osc_tui/mainForm.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/osc_tui/mainForm.py b/osc_tui/mainForm.py index e40e776..111c874 100644 --- a/osc_tui/mainForm.py +++ b/osc_tui/mainForm.py @@ -403,10 +403,7 @@ def switch_to_images(form, _): def switch_to_security_grid(form, _): global MODE MODE = "Security" -<<<<<<< HEAD form.reload() -======= - self.reload() def switch_to_nets(self, _): global MODE @@ -417,7 +414,6 @@ def switch_to_keypairs(self, _): global MODE MODE = "Keypairs" self.reload() ->>>>>>> 78b59da (add shortcuts for navigation : Create / Keypairs) def set_up_handlers(self): super().set_up_handlers() @@ -430,11 +426,8 @@ def set_up_handlers(self): self.add_handlers({"I": self.switch_to_instances}) self.add_handlers({"M": self.switch_to_images}) self.add_handlers({"S": self.switch_to_security_grid}) -<<<<<<< HEAD -======= self.add_handlers({"T": self.switch_to_nets}) self.add_handlers({"K": self.switch_to_keypairs}) ->>>>>>> 78b59da (add shortcuts for navigation : Create / Keypairs) self.add_handlers({ "r" : self.key_reload, curses.KEY_F5 : self.key_reload