Skip to content

Commit

Permalink
fix(jans-cli-tui): working branch 11 (#3980)
Browse files Browse the repository at this point in the history
* fix(jans-cli-tui): status for saving fido configuration

* fix(jans-cli-tui): customObjectClasses is jansPerson for creating user

* feat(jans-cli-tui): enhance presentation of agama deployments (ref: #3854)

* feat(jans-cli-tui): save default ACR (ref: #4031)

* feat(jans-cli-tui): attributes (ref: #4035)

* fix(jans-cli-tui): code smell

* fix(jans-cli-tui): warning message before deleting attribute

* feat(jans-cli-tui): show configuration for projet (ref: #4041)

* fix(jans-cli-tui): dropdown changes value with up/down even if not activated

* fix(jans-cli-tui): code smell

* fix(jans-cli-tui): drop down widget selected value

* fix(jans-cli-tui): code smell
  • Loading branch information
devrimyatar authored Mar 13, 2023
1 parent 092989b commit fdba800
Show file tree
Hide file tree
Showing 11 changed files with 588 additions and 124 deletions.
3 changes: 3 additions & 0 deletions jans-cli-tui/cli_tui/jans_cli_tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def __init__(self):
self.progressing_text = ""
self.mouse_float=True
self.browse_path = '/'
self.app_configuration = {}

self.not_implemented = Frame(
body=HSplit([Label(text=_("Not imlemented yet")), Button(text=_("MyButton"))], width=D()),
Expand Down Expand Up @@ -353,6 +354,8 @@ def check_available_plugins(self) -> None:
for pp in self._plugins:
if getattr(pp, 'server_side_plugin', False) and pp.pid not in self.available_plugins:
self.disable_plugin(pp.pid)
if hasattr(pp, 'on_cli_object_ready'):
pp.on_cli_object_ready()

self.init_plugins()

Expand Down
63 changes: 52 additions & 11 deletions jans-cli-tui/cli_tui/plugins/010_auth_server/agama.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ def __init__(
self.data = []
self.working_container = JansVerticalNav(
myparent=app,
headers=[_("Project Name"), _("Type"), _("Author"), _("Updated")],
preferred_size= self.app.get_column_sizes(.25, .25 , .3, .1, .1),
headers=[_("Project Name"), _("Type"), _("Author"), _("Updated"), _("Status"), _("Errors")],
preferred_size= self.app.get_column_sizes(.2, .2 , .2, .1, .1, .1, .1),
on_display=self.app.data_display_dialog,
on_delete=self.delete_agama_project,
selectes=0,
headerColor=cli_style.navbar_headcolor,
entriesColor=cli_style.navbar_entriescolor,
hide_headers = True
hide_headers = True,
custom_key_bindings=([('c', self.display_config)]),
jans_help=_("Press c to display configuration for project")
)

self.main_container = HSplit([
Expand All @@ -54,29 +56,68 @@ def __init__(
], style=cli_style.container)


def display_config(self, event):

project_data = self.working_container.all_data[self.working_container.selectes]
project_name = project_data['details']['projectMetadata']['projectName']

async def coroutine():
cli_args = {'operation_id': 'get-agama-dev-prj-configs', 'endpoint_args':'name:{}'.format(project_name)}
self.app.start_progressing(_("Retreiving project configuration..."))
response = await get_event_loop().run_in_executor(self.app.executor, self.app.cli_requests, cli_args)
self.app.stop_progressing()

try:
result = response.json()
except Exception:
result = result.text

if result:
self.app.data_display_dialog(title=_("Configuration for") + " " + project_name, data=response.json())
else:
self.app.show_message(_(common_strings.error), "Server did not return configuration for {}".format(project_name), tobefocused=self.working_container)


asyncio.ensure_future(coroutine())


def update_agama_container(self, start_index=0, search_str=''):

self.working_container.clear()
data_display = []

for agama in self.data.get('entries', []):
project_details = agama['details']
project_metadata = project_details['projectMetadata']

if search_str.lower():
project_str = ' '.join((
agama['details']['projectMetadata'].get('projectName'),
agama['details']['projectMetadata'].get('author', ''),
agama['details']['projectMetadata'].get('type', ''),
agama['details']['projectMetadata'].get('description', '')
project_metadata.get('projectName'),
project_metadata.get('author', ''),
project_metadata.get('type', ''),
project_metadata.get('description', '')
)).lower()
if search_str not in project_str:
continue

dt_object = datetime.fromisoformat(agama['createdAt'])
if agama.get('finishedAt'):
status = _("Pending")
error = ''
else:
status = _("Processed")
if not project_details.get('error'):
error = 'No'
else:
error = project_details['error'][:5] + '...'

data_display.append((
agama['details']['projectMetadata'].get('projectName'),
agama['details']['projectMetadata'].get('type', '??'),
agama['details']['projectMetadata'].get('author', '??'),
'{:02d}/{:02d}/{}'.format(dt_object.day, dt_object.month, str(dt_object.year)[2:])
project_metadata.get('projectName'),
project_metadata.get('type', '??'),
project_metadata.get('author', '??'),
'{:02d}/{:02d}/{}'.format(dt_object.day, dt_object.month, str(dt_object.year)[2:]),
status,
error
))

if not data_display:
Expand Down
Loading

0 comments on commit fdba800

Please sign in to comment.