34 lines
969 B
Python
34 lines
969 B
Python
from asciimatics.widgets import Layout, Text
|
|
|
|
from ...utils import http_get
|
|
from ..CeoFrame import CeoFrame
|
|
|
|
|
|
class GetGroupView(CeoFrame):
|
|
def __init__(self, screen, width, height, model):
|
|
super().__init__(
|
|
screen, height, width, model, 'GetGroup',
|
|
)
|
|
layout = Layout([100], fill_frame=True)
|
|
self.add_layout(layout)
|
|
self._cn = Text("Group name", "cn")
|
|
layout.add_widget(self._cn)
|
|
|
|
self.add_flash_message_layout()
|
|
self.add_buttons(
|
|
back_btn=True,
|
|
next_scene='GetGroupResult', on_next=self._next)
|
|
self.fix()
|
|
|
|
def _ceoframe_on_reset(self):
|
|
super()._ceoframe_on_reset()
|
|
self._cn.value = None
|
|
|
|
def _next(self):
|
|
cn = self._cn.value
|
|
self.flash_message('Looking up group...', force_update=True)
|
|
try:
|
|
self._model.resp = http_get(f'/api/groups/{cn}')
|
|
finally:
|
|
self.clear_flash_message()
|