From c85b66a74864385e2221d90c8f8e8d309f016413 Mon Sep 17 00:00:00 2001 From: MAL Date: Mon, 21 Aug 2023 13:19:37 +0200 Subject: [PATCH] add shortcuts --- osc_tui/mainForm.py | 55 +++++++++++++++++++++++++++++++++++++++++++++ osc_tui/popup.py | 20 +++++++++++------ 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/osc_tui/mainForm.py b/osc_tui/mainForm.py index d8e5a21..daba94d 100644 --- a/osc_tui/mainForm.py +++ b/osc_tui/mainForm.py @@ -331,6 +331,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() @@ -352,12 +382,37 @@ def quit_key(self, key_val): def key_reload(self, _): self.reload() + def switch_to_volumes(form, _): + global MODE + MODE = "Volumes" + form.reload() + + def switch_to_instances(form, _): + global MODE + MODE = "Vms" + form.reload() + + def switch_to_images(form, _): + global MODE + MODE = "Images" + form.reload() + + def switch_to_security_grid(form, _): + global MODE + MODE = "Security" + form.reload() + def set_up_handlers(self): super().set_up_handlers() self.add_handlers({"q": self.quit_key}) 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}) 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 a15d30d..2598043 100644 --- a/osc_tui/popup.py +++ b/osc_tui/popup.py @@ -819,7 +819,7 @@ def capsule(): " |/\n" + " +\n", - r" \| \n" + + " \| \n" + " +\n", " \\ \n" + @@ -1062,12 +1062,18 @@ def showHelp(arg): oscscreen.Pager, ) ft.values = [ - "Return to profile : q", - "Exit : Ctrl+Q", - "Refresh : F5 or r", - "Search in Fields : /", - "search in Menu : l", - "Help : h\n", + "Return to profile : q", + "Exit : Ctrl+Q", + "Refresh : F5 or r", + "Search in Fields : /", + "search in Menu : l", + "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():