From 341d97589b10df05a0da9dd6c6a67498b6e51359 Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Sun, 11 Dec 2022 22:49:27 -0800 Subject: [PATCH 01/30] fix(jans-cli-tui) fix Empty spaces in multi tab properties ref:(#3286) --- jans-cli-tui/cli_tui/jans_cli_tui.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jans-cli-tui/cli_tui/jans_cli_tui.py b/jans-cli-tui/cli_tui/jans_cli_tui.py index 4a16c018e8c..e9e548993d3 100755 --- a/jans-cli-tui/cli_tui/jans_cli_tui.py +++ b/jans-cli-tui/cli_tui/jans_cli_tui.py @@ -548,7 +548,8 @@ def custom_handler(): if on_selection_changed: rl._handle_enter = custom_handler - v = VSplit([Label(text=title, width=len(title), style=style), rl]) + v = VSplit([Window(FormattedTextControl(title), width=len(title)+1, style=style,), rl], padding=1) + v.me = rl return v From 94c7d42e70a318884d4de189b3c5dfeb9cae944c Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Mon, 12 Dec 2022 10:21:14 +0300 Subject: [PATCH 02/30] fix: jans-cli-tui save script location --- .../plugins/060_scripts/edit_script_dialog.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/060_scripts/edit_script_dialog.py b/jans-cli-tui/cli_tui/plugins/060_scripts/edit_script_dialog.py index e55b9a35e5b..7d6dee4acd2 100755 --- a/jans-cli-tui/cli_tui/plugins/060_scripts/edit_script_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/060_scripts/edit_script_dialog.py @@ -89,17 +89,14 @@ def save(self) -> None: prop['hide'] = prop_[2] data[prop_container.jans_name].append(prop) - - data['locationType'] = 'ldap' if data['location'] == 'db' else 'file' + data['locationType'] = data.get('locationType') data['internal'] = self.data.get('internal', False) data['modified'] = self.data.get('modified', False) data['revision'] = self.data.get('revision', 0) + 1 data['script'] = self.script - del data['location'] - - if not data['inum']: - del data['inum'] + if data['locationType'] != 'file': + data.pop('locationPath', None) if self.data.get('baseDn'): data['baseDn'] = self.data['baseDn'] @@ -154,12 +151,12 @@ def create_window(self) -> None: self.location_widget = self.myparent.getTitledText( _(" Path"), name='locationPath', - value=self.data.get('locationPath',''), + value=self.data.get('locationPath',''), style='class:script-titledtext', jans_help="locationPath" ) - self.set_location_widget_state(self.data.get('locationPath') == 'file') + self.set_location_widget_state(self.data.get('locationType') == 'file') config_properties_title = _("Conf. Properties: ") add_property_title = _("Add Property") @@ -233,9 +230,9 @@ def create_window(self) -> None: self.myparent.getTitledRadioButton( _("Location"), - name='location', - values=[('db', _("Database")), ('file', _("File System"))], - current_value= 'file' if self.data.get('locationPath') else 'db', + name='locationType', + values=[('ldap', _("Database")), ('file', _("File System"))], + current_value= 'file' if self.data.get('locationType') == 'file' else 'ldap', jans_help=_("Where to save script"), style='class:outh-client-radiobutton', on_selection_changed=self.script_location_changed, From a5c51ef06da3fe175f0b899cf4ecdc526286a85d Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Tue, 13 Dec 2022 20:29:10 +0300 Subject: [PATCH 03/30] fix: jans-linux-tui remove updatedAt from user edit --- jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py b/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py index e16c82fa843..337ead93634 100644 --- a/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py @@ -242,7 +242,7 @@ def add_claim(self) -> None: for claim in common_data.users.claims: if not claim['oxMultiValuedAttribute'] and claim['name'] in cur_claims: continue - if claim['name'] in ('memberOf', 'userPassword', 'uid', 'jansStatus', 'jansActive'): + if claim['name'] in ('memberOf', 'userPassword', 'uid', 'jansStatus', 'jansActive', 'updatedAt'): continue claims_list.append((claim['name'], claim['displayName'])) From b31307b76c015d27620555bfddb3fbff88e54dec Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Tue, 13 Dec 2022 20:51:00 +0300 Subject: [PATCH 04/30] fix: jans-cli-tui user-edit None value --- jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py b/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py index 337ead93634..e1b9f06ec4f 100644 --- a/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py @@ -93,6 +93,8 @@ def get_custom_attribute(attribute, multi=False): return val if multi: return values + while None in values: + values.remove(None) ret_val = ', '.join(values) return ret_val return [] if multi else '' From d945c9e332e214aa894ec8c481146003c6bf5a69 Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Tue, 13 Dec 2022 17:08:28 -0800 Subject: [PATCH 05/30] fix:jans-cli-tui rename jans_date_picker --- jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py | 2 +- jans-cli-tui/cli_tui/plugins/010_oxauth/edit_scope_dialog.py | 1 - jans-cli-tui/cli_tui/utils/utils.py | 2 +- .../wui_components/{jans_data_picker.py => jans_date_picker.py} | 0 4 files changed, 2 insertions(+), 3 deletions(-) rename jans-cli-tui/cli_tui/wui_components/{jans_data_picker.py => jans_date_picker.py} (100%) diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py index 0ede9d2d20f..26ac561f1f0 100755 --- a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py @@ -21,7 +21,7 @@ from wui_components.jans_side_nav_bar import JansSideNavBar from wui_components.jans_cli_dialog import JansGDialog from wui_components.jans_drop_down import DropDownWidget -from wui_components.jans_data_picker import DateSelectWidget +from cli_tui.wui_components.jans_date_picker import DateSelectWidget from utils.utils import DialogUtils from wui_components.jans_vetrical_nav import JansVerticalNav from view_uma_dialog import ViewUMADialog diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_scope_dialog.py b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_scope_dialog.py index 1d983e7308a..69f8ef2d753 100755 --- a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_scope_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_scope_dialog.py @@ -37,7 +37,6 @@ from wui_components.jans_side_nav_bar import JansSideNavBar from wui_components.jans_cli_dialog import JansGDialog from wui_components.jans_drop_down import DropDownWidget -from wui_components.jans_data_picker import DateSelectWidget from wui_components.jans_vetrical_nav import JansVerticalNav from view_uma_dialog import ViewUMADialog diff --git a/jans-cli-tui/cli_tui/utils/utils.py b/jans-cli-tui/cli_tui/utils/utils.py index 2d28644fd93..6d5c12fbb2d 100755 --- a/jans-cli-tui/cli_tui/utils/utils.py +++ b/jans-cli-tui/cli_tui/utils/utils.py @@ -5,7 +5,7 @@ from cli_style import style from wui_components.jans_drop_down import DropDownWidget -from wui_components.jans_data_picker import DateSelectWidget +from cli_tui.wui_components.jans_date_picker import DateSelectWidget from wui_components.jans_spinner import Spinner diff --git a/jans-cli-tui/cli_tui/wui_components/jans_data_picker.py b/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py similarity index 100% rename from jans-cli-tui/cli_tui/wui_components/jans_data_picker.py rename to jans-cli-tui/cli_tui/wui_components/jans_date_picker.py From cdc8ad68d6f202e8412b4cf8717b012ea47c5e30 Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Tue, 13 Dec 2022 17:10:06 -0800 Subject: [PATCH 06/30] fix:jans-cli-tui refactor test files for renaming jans_date_picker --- jans-cli-tui/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jans-cli-tui/test.py b/jans-cli-tui/test.py index b5c8f8ae9f4..cbae2496cf0 100644 --- a/jans-cli-tui/test.py +++ b/jans-cli-tui/test.py @@ -7,7 +7,7 @@ jans_main = importlib.import_module("jans-cli-tui") from cli_tui.wui_components.jans_drop_down import DropDownWidget -from cli_tui.wui_components.jans_data_picker import DateSelectWidget +from cli_tui.wui_components.jans_date_picker import DateSelectWidget from prompt_toolkit import prompt From 3e29868ddac32aff368f723f7bb16740c4a5a570 Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Sat, 17 Dec 2022 00:13:17 -0800 Subject: [PATCH 07/30] fix:jans-cli-tui fix import error --- jans-cli-tui/cli_tui/utils/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jans-cli-tui/cli_tui/utils/utils.py b/jans-cli-tui/cli_tui/utils/utils.py index 6d5c12fbb2d..427cf0d09b5 100755 --- a/jans-cli-tui/cli_tui/utils/utils.py +++ b/jans-cli-tui/cli_tui/utils/utils.py @@ -5,9 +5,11 @@ from cli_style import style from wui_components.jans_drop_down import DropDownWidget -from cli_tui.wui_components.jans_date_picker import DateSelectWidget from wui_components.jans_spinner import Spinner +import sys +sys.path.append("./") +from cli_tui.wui_components.jans_date_picker import DateSelectWidget common_data = SimpleNamespace() From e599ea26ac703a8aca2062ce3c104bd651eaa6fb Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Mon, 19 Dec 2022 04:04:06 -0800 Subject: [PATCH 08/30] feat:jans-cli-tui add mouse menu for cut, paste, copy (ref: #2712) --- jans-cli-tui/cli_tui/jans_cli_tui.py | 170 ++++++++++++++++++++++++++- 1 file changed, 164 insertions(+), 6 deletions(-) diff --git a/jans-cli-tui/cli_tui/jans_cli_tui.py b/jans-cli-tui/cli_tui/jans_cli_tui.py index e9e548993d3..ec7bce653e3 100755 --- a/jans-cli-tui/cli_tui/jans_cli_tui.py +++ b/jans-cli-tui/cli_tui/jans_cli_tui.py @@ -62,20 +62,17 @@ from prompt_toolkit.formatted_text import AnyFormattedText from typing import TypeVar, Callable from prompt_toolkit.widgets import Button, Dialog, Label - -# -------------------------------------------------------------------------- # from cli import config_cli from utils.validators import IntegerValidator from wui_components.jans_cli_dialog import JansGDialog from wui_components.jans_nav_bar import JansNavBar from wui_components.jans_message_dialog import JansMessageDialog - from cli_style import style - import cli_style - from utils.multi_lang import _ -# -------------------------------------------------------------------------- # +from prompt_toolkit.mouse_events import MouseEvent, MouseEventType +from prompt_toolkit.keys import Keys + home_dir = Path.home() config_dir = home_dir.joinpath('.config') @@ -109,6 +106,7 @@ def __init__(self): self.cli_object_ok = False self.pbar_text = "" self.progressing_text = "" + self.mouse_float=True self.not_implemented = Frame( body=HSplit([Label(text=_("Not imlemented yet")), Button(text=_("MyButton"))], width=D()), @@ -380,6 +378,166 @@ def set_keybindings(self) -> None: self.bindings.add('f1')(self.help) self.bindings.add('escape')(self.escape) self.bindings.add('s-up')(self.up) + self.bindings.add(Keys.Vt100MouseEvent)(self.mouse) + + + + def mouse(self,event): ### mouse: [<35;108;20M + + pieces = event.data.split(";") ##['LEFT', 'MOUSE_DOWN', '146', '10'] + mouse_click=int(pieces[0][3:]) + mouse_state=str(pieces[2][-1:]) + x = int(pieces[1]) + y = int(pieces[2][:-1]) + + mouse_event, x, y = map(int, [mouse_click,x,y]) + m = mouse_state + + mouse_event = { + (0, 'M'): MouseEventType.MOUSE_DOWN, + (0, 'm'): MouseEventType.MOUSE_UP, + (2, 'M'): MouseEventType.MOUSE_DOWN, + (2, 'm'): MouseEventType.MOUSE_UP, + (64, 'M'): MouseEventType.SCROLL_UP, + (65, 'M'): MouseEventType.SCROLL_DOWN, + }.get((mouse_event, m)) + + mouse_click = { + 0: "LEFT", + 2: "RIGHT" + }.get(mouse_click) + + + # ------------------------------------------------------------------------------------ # + # ------------------------------------------------------------------------------------ # + # ------------------------------------------------------------------------------------ # + res=[] + res.append(HTML(''.format("Copy"))) + res.append("\n") + res.append(HTML(''.format("Cut"))) + res.append("\n") + res.append(HTML(''.format("Paste"))) + res.append("\n") + + content= Window( + content=FormattedTextControl( + text=merge_formatted_text(res), + focusable=True, + ), height=D()) + floa=Float(content=content, left=x,top=y) + floa.name='mouse' + + # ------------------------------------------------------------------------------------ # + # ------------------------------------------------------------------------------------ # + # ------------------------------------------------------------------------------------ # + + if mouse_click == "RIGHT" and mouse_event == MouseEventType.MOUSE_DOWN : + if self.mouse_float == True : + self.root_layout.floats.append(floa) + self.mouse_cord=(x,y) + self.mouse_float = False + else: + try: + if get_app().layout.container.floats: + if get_app().layout.container.floats[-1].name =='mouse': + get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) + self.root_layout.floats.append(floa) + self.mouse_cord=(x,y) + self.mouse_float = False + else: + self.root_layout.floats.append(floa) + self.mouse_cord=(x,y) + self.mouse_float = False + else: + self.root_layout.floats.append(floa) + self.mouse_cord=(x,y) + self.mouse_float = False + except Exception as e: + pass + + elif mouse_click == "LEFT" and mouse_event == MouseEventType.MOUSE_DOWN and self.mouse_float == False: + try: + if get_app().layout.container.floats: + if get_app().layout.container.floats[-1].name =='mouse': + + if self.mouse_select =='Copy': + data = get_app().current_buffer.copy_selection(False) + get_app().clipboard.set_data(data) + get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) + self.mouse_float = True + + elif self.mouse_select =='Paste': + data = get_app().clipboard.get_data() + get_app().current_buffer.paste_clipboard_data(data) + get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) + self.mouse_float = True + + elif self.mouse_select =='Cut': + data = get_app().current_buffer.copy_selection(True) + get_app().clipboard.set_data(data) + get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) + self.mouse_float = True + + else: + get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) + self.mouse_float = True + + except Exception as e: + pass + + + if get_app().layout.container.floats: + try : + get_float_name = get_app().layout.container.floats[-1].name + except: + get_float_name = '' + + if get_float_name =='mouse': + if self.mouse_cord[0] <= x and self.mouse_cord[0] >= x-5: + if self.mouse_cord[1] == y-1: + res = [] + res.append(HTML(''.format('#00FF00', "Copy "))) + res.append("\n") + res.append(HTML(''.format("Cut"))) + res.append("\n") + res.append(HTML(''.format("Paste"))) + res.append("\n") + get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) + self.mouse_select = 'Copy' + + elif self.mouse_cord[1] == y-2: + res = [] + res.append(HTML(''.format("Copy"))) + res.append("\n") + res.append(HTML(''.format('#00FF00', "Cut "))) + res.append("\n") + res.append(HTML(''.format("Paste"))) + res.append("\n") + get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) + self.mouse_select = 'Cut' + + elif self.mouse_cord[1] == y-3: + res = [] + res.append(HTML(''.format("Copy"))) + res.append("\n") + res.append(HTML(''.format("Cut"))) + res.append("\n") + res.append(HTML(''.format('#00FF00', "Paste"))) + res.append("\n") + get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) + self.mouse_select = 'Paste' + else: + self.mouse_select = 'None' + else: + res = [] + res.append(HTML(''.format("Copy"))) + res.append("\n") + res.append(HTML(''.format("Cut"))) + res.append("\n") + res.append(HTML(''.format("Paste"))) + res.append("\n") + get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) + self.mouse_select = 'None' def up(self, ev: KeyPressEvent) -> None: get_app().layout.focus(Frame(self.nav_bar.nav_window)) From d5e60dc8213dd9446f059a1ddbd77385a37799bd Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Mon, 19 Dec 2022 06:36:32 -0800 Subject: [PATCH 09/30] fix:jans-cli-tui remove unused imports --- .../cli_tui/wui_components/jans_date_picker.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py b/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py index 9123faa82d6..aa11053984e 100755 --- a/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py +++ b/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py @@ -1,29 +1,20 @@ from prompt_toolkit.application.current import get_app from prompt_toolkit.key_binding import KeyBindings -from prompt_toolkit.layout.containers import Float, HSplit, Window from prompt_toolkit.layout.controls import FormattedTextControl from prompt_toolkit.formatted_text import HTML, merge_formatted_text from prompt_toolkit.layout.margins import ScrollbarMargin from prompt_toolkit.key_binding.bindings.focus import focus_next, focus_previous from prompt_toolkit.layout.dimension import D -from prompt_toolkit.layout.containers import Float, FloatContainer, HSplit, Window, VSplit -from prompt_toolkit.widgets import Button, Label, TextArea +from prompt_toolkit.widgets import Button, Label from prompt_toolkit.layout.containers import ( - ConditionalContainer, Float, HSplit, VSplit, - VerticalAlign, - HorizontalAlign, DynamicContainer, - FloatContainer, Window ) -from prompt_toolkit.layout.containers import ( - AnyContainer, -) -from typing import Optional, Sequence, Union +from typing import Optional from prompt_toolkit.formatted_text import AnyFormattedText from prompt_toolkit.widgets import Button, Dialog from prompt_toolkit.key_binding.key_bindings import KeyBindings, KeyBindingsBase From 5c8e03dea642d824f2221ddd343f6d57d4608351 Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Tue, 20 Dec 2022 02:31:46 -0800 Subject: [PATCH 10/30] fix:jans-cli-tui change user password (ref: #3360) --- jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py | 4 ++++ jans-cli-tui/cli_tui/plugins/070_users/main.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py b/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py index e1b9f06ec4f..62fbdf436d6 100644 --- a/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py @@ -156,6 +156,10 @@ def get_custom_attribute(attribute, multi=False): self.edit_user_content.insert(2, self.app.getTitledText(_("Password *"), name='userPassword', value='', style='class:script-titledtext', jans_help=self.app.get_help_from_schema(self.schema, 'userPassword')) ) + else : + self.edit_user_content.insert(2, + self.app.getTitledText(_("Change Password"), name='userPassword', value='', style='class:script-titledtext', jans_help="Enter New Password") + ) for ca in self.data.get('customAttributes', []): diff --git a/jans-cli-tui/cli_tui/plugins/070_users/main.py b/jans-cli-tui/cli_tui/plugins/070_users/main.py index 64d227c5ead..e80b2cb557b 100755 --- a/jans-cli-tui/cli_tui/plugins/070_users/main.py +++ b/jans-cli-tui/cli_tui/plugins/070_users/main.py @@ -196,6 +196,9 @@ def save_user(self, dialog: Dialog) -> None: if 'baseDn' not in dialog.data: user_info['userPassword'] = raw_data['userPassword'] + else: + if raw_data['userPassword']: + user_info['userPassword'] = raw_data['userPassword'] for key_ in ('inum', 'baseDn', 'dn'): if key_ in raw_data: From 99784791b97caa339a4c5614104fda7a1665f772 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Wed, 21 Dec 2022 21:46:05 +0300 Subject: [PATCH 11/30] fix: jans-cli-tui imports --- jans-cli-tui/cli_tui/jans_cli_tui.py | 170 +----------------- .../plugins/010_oxauth/edit_client_dialog.py | 2 +- jans-cli-tui/cli_tui/utils/utils.py | 3 +- 3 files changed, 8 insertions(+), 167 deletions(-) diff --git a/jans-cli-tui/cli_tui/jans_cli_tui.py b/jans-cli-tui/cli_tui/jans_cli_tui.py index ec7bce653e3..e9e548993d3 100755 --- a/jans-cli-tui/cli_tui/jans_cli_tui.py +++ b/jans-cli-tui/cli_tui/jans_cli_tui.py @@ -62,17 +62,20 @@ from prompt_toolkit.formatted_text import AnyFormattedText from typing import TypeVar, Callable from prompt_toolkit.widgets import Button, Dialog, Label + +# -------------------------------------------------------------------------- # from cli import config_cli from utils.validators import IntegerValidator from wui_components.jans_cli_dialog import JansGDialog from wui_components.jans_nav_bar import JansNavBar from wui_components.jans_message_dialog import JansMessageDialog + from cli_style import style + import cli_style -from utils.multi_lang import _ -from prompt_toolkit.mouse_events import MouseEvent, MouseEventType -from prompt_toolkit.keys import Keys +from utils.multi_lang import _ +# -------------------------------------------------------------------------- # home_dir = Path.home() config_dir = home_dir.joinpath('.config') @@ -106,7 +109,6 @@ def __init__(self): self.cli_object_ok = False self.pbar_text = "" self.progressing_text = "" - self.mouse_float=True self.not_implemented = Frame( body=HSplit([Label(text=_("Not imlemented yet")), Button(text=_("MyButton"))], width=D()), @@ -378,166 +380,6 @@ def set_keybindings(self) -> None: self.bindings.add('f1')(self.help) self.bindings.add('escape')(self.escape) self.bindings.add('s-up')(self.up) - self.bindings.add(Keys.Vt100MouseEvent)(self.mouse) - - - - def mouse(self,event): ### mouse: [<35;108;20M - - pieces = event.data.split(";") ##['LEFT', 'MOUSE_DOWN', '146', '10'] - mouse_click=int(pieces[0][3:]) - mouse_state=str(pieces[2][-1:]) - x = int(pieces[1]) - y = int(pieces[2][:-1]) - - mouse_event, x, y = map(int, [mouse_click,x,y]) - m = mouse_state - - mouse_event = { - (0, 'M'): MouseEventType.MOUSE_DOWN, - (0, 'm'): MouseEventType.MOUSE_UP, - (2, 'M'): MouseEventType.MOUSE_DOWN, - (2, 'm'): MouseEventType.MOUSE_UP, - (64, 'M'): MouseEventType.SCROLL_UP, - (65, 'M'): MouseEventType.SCROLL_DOWN, - }.get((mouse_event, m)) - - mouse_click = { - 0: "LEFT", - 2: "RIGHT" - }.get(mouse_click) - - - # ------------------------------------------------------------------------------------ # - # ------------------------------------------------------------------------------------ # - # ------------------------------------------------------------------------------------ # - res=[] - res.append(HTML(''.format("Copy"))) - res.append("\n") - res.append(HTML(''.format("Cut"))) - res.append("\n") - res.append(HTML(''.format("Paste"))) - res.append("\n") - - content= Window( - content=FormattedTextControl( - text=merge_formatted_text(res), - focusable=True, - ), height=D()) - floa=Float(content=content, left=x,top=y) - floa.name='mouse' - - # ------------------------------------------------------------------------------------ # - # ------------------------------------------------------------------------------------ # - # ------------------------------------------------------------------------------------ # - - if mouse_click == "RIGHT" and mouse_event == MouseEventType.MOUSE_DOWN : - if self.mouse_float == True : - self.root_layout.floats.append(floa) - self.mouse_cord=(x,y) - self.mouse_float = False - else: - try: - if get_app().layout.container.floats: - if get_app().layout.container.floats[-1].name =='mouse': - get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) - self.root_layout.floats.append(floa) - self.mouse_cord=(x,y) - self.mouse_float = False - else: - self.root_layout.floats.append(floa) - self.mouse_cord=(x,y) - self.mouse_float = False - else: - self.root_layout.floats.append(floa) - self.mouse_cord=(x,y) - self.mouse_float = False - except Exception as e: - pass - - elif mouse_click == "LEFT" and mouse_event == MouseEventType.MOUSE_DOWN and self.mouse_float == False: - try: - if get_app().layout.container.floats: - if get_app().layout.container.floats[-1].name =='mouse': - - if self.mouse_select =='Copy': - data = get_app().current_buffer.copy_selection(False) - get_app().clipboard.set_data(data) - get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) - self.mouse_float = True - - elif self.mouse_select =='Paste': - data = get_app().clipboard.get_data() - get_app().current_buffer.paste_clipboard_data(data) - get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) - self.mouse_float = True - - elif self.mouse_select =='Cut': - data = get_app().current_buffer.copy_selection(True) - get_app().clipboard.set_data(data) - get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) - self.mouse_float = True - - else: - get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) - self.mouse_float = True - - except Exception as e: - pass - - - if get_app().layout.container.floats: - try : - get_float_name = get_app().layout.container.floats[-1].name - except: - get_float_name = '' - - if get_float_name =='mouse': - if self.mouse_cord[0] <= x and self.mouse_cord[0] >= x-5: - if self.mouse_cord[1] == y-1: - res = [] - res.append(HTML(''.format('#00FF00', "Copy "))) - res.append("\n") - res.append(HTML(''.format("Cut"))) - res.append("\n") - res.append(HTML(''.format("Paste"))) - res.append("\n") - get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) - self.mouse_select = 'Copy' - - elif self.mouse_cord[1] == y-2: - res = [] - res.append(HTML(''.format("Copy"))) - res.append("\n") - res.append(HTML(''.format('#00FF00', "Cut "))) - res.append("\n") - res.append(HTML(''.format("Paste"))) - res.append("\n") - get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) - self.mouse_select = 'Cut' - - elif self.mouse_cord[1] == y-3: - res = [] - res.append(HTML(''.format("Copy"))) - res.append("\n") - res.append(HTML(''.format("Cut"))) - res.append("\n") - res.append(HTML(''.format('#00FF00', "Paste"))) - res.append("\n") - get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) - self.mouse_select = 'Paste' - else: - self.mouse_select = 'None' - else: - res = [] - res.append(HTML(''.format("Copy"))) - res.append("\n") - res.append(HTML(''.format("Cut"))) - res.append("\n") - res.append(HTML(''.format("Paste"))) - res.append("\n") - get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) - self.mouse_select = 'None' def up(self, ev: KeyPressEvent) -> None: get_app().layout.focus(Frame(self.nav_bar.nav_window)) diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py index 26ac561f1f0..9c0e545831a 100755 --- a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py @@ -21,7 +21,7 @@ from wui_components.jans_side_nav_bar import JansSideNavBar from wui_components.jans_cli_dialog import JansGDialog from wui_components.jans_drop_down import DropDownWidget -from cli_tui.wui_components.jans_date_picker import DateSelectWidget +from wui_components.jans_date_picker import DateSelectWidget from utils.utils import DialogUtils from wui_components.jans_vetrical_nav import JansVerticalNav from view_uma_dialog import ViewUMADialog diff --git a/jans-cli-tui/cli_tui/utils/utils.py b/jans-cli-tui/cli_tui/utils/utils.py index 427cf0d09b5..f5dd69c1506 100755 --- a/jans-cli-tui/cli_tui/utils/utils.py +++ b/jans-cli-tui/cli_tui/utils/utils.py @@ -8,8 +8,7 @@ from wui_components.jans_spinner import Spinner import sys -sys.path.append("./") -from cli_tui.wui_components.jans_date_picker import DateSelectWidget +from wui_components.jans_date_picker import DateSelectWidget common_data = SimpleNamespace() From 86eedd6f4533777a1527743bc44ddef6b67efded Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Wed, 21 Dec 2022 21:49:29 +0300 Subject: [PATCH 12/30] Revert "fix: jans-cli-tui imports" This reverts commit 99784791b97caa339a4c5614104fda7a1665f772. --- jans-cli-tui/cli_tui/jans_cli_tui.py | 170 +++++++++++++++++- .../plugins/010_oxauth/edit_client_dialog.py | 2 +- jans-cli-tui/cli_tui/utils/utils.py | 3 +- 3 files changed, 167 insertions(+), 8 deletions(-) diff --git a/jans-cli-tui/cli_tui/jans_cli_tui.py b/jans-cli-tui/cli_tui/jans_cli_tui.py index e9e548993d3..ec7bce653e3 100755 --- a/jans-cli-tui/cli_tui/jans_cli_tui.py +++ b/jans-cli-tui/cli_tui/jans_cli_tui.py @@ -62,20 +62,17 @@ from prompt_toolkit.formatted_text import AnyFormattedText from typing import TypeVar, Callable from prompt_toolkit.widgets import Button, Dialog, Label - -# -------------------------------------------------------------------------- # from cli import config_cli from utils.validators import IntegerValidator from wui_components.jans_cli_dialog import JansGDialog from wui_components.jans_nav_bar import JansNavBar from wui_components.jans_message_dialog import JansMessageDialog - from cli_style import style - import cli_style - from utils.multi_lang import _ -# -------------------------------------------------------------------------- # +from prompt_toolkit.mouse_events import MouseEvent, MouseEventType +from prompt_toolkit.keys import Keys + home_dir = Path.home() config_dir = home_dir.joinpath('.config') @@ -109,6 +106,7 @@ def __init__(self): self.cli_object_ok = False self.pbar_text = "" self.progressing_text = "" + self.mouse_float=True self.not_implemented = Frame( body=HSplit([Label(text=_("Not imlemented yet")), Button(text=_("MyButton"))], width=D()), @@ -380,6 +378,166 @@ def set_keybindings(self) -> None: self.bindings.add('f1')(self.help) self.bindings.add('escape')(self.escape) self.bindings.add('s-up')(self.up) + self.bindings.add(Keys.Vt100MouseEvent)(self.mouse) + + + + def mouse(self,event): ### mouse: [<35;108;20M + + pieces = event.data.split(";") ##['LEFT', 'MOUSE_DOWN', '146', '10'] + mouse_click=int(pieces[0][3:]) + mouse_state=str(pieces[2][-1:]) + x = int(pieces[1]) + y = int(pieces[2][:-1]) + + mouse_event, x, y = map(int, [mouse_click,x,y]) + m = mouse_state + + mouse_event = { + (0, 'M'): MouseEventType.MOUSE_DOWN, + (0, 'm'): MouseEventType.MOUSE_UP, + (2, 'M'): MouseEventType.MOUSE_DOWN, + (2, 'm'): MouseEventType.MOUSE_UP, + (64, 'M'): MouseEventType.SCROLL_UP, + (65, 'M'): MouseEventType.SCROLL_DOWN, + }.get((mouse_event, m)) + + mouse_click = { + 0: "LEFT", + 2: "RIGHT" + }.get(mouse_click) + + + # ------------------------------------------------------------------------------------ # + # ------------------------------------------------------------------------------------ # + # ------------------------------------------------------------------------------------ # + res=[] + res.append(HTML(''.format("Copy"))) + res.append("\n") + res.append(HTML(''.format("Cut"))) + res.append("\n") + res.append(HTML(''.format("Paste"))) + res.append("\n") + + content= Window( + content=FormattedTextControl( + text=merge_formatted_text(res), + focusable=True, + ), height=D()) + floa=Float(content=content, left=x,top=y) + floa.name='mouse' + + # ------------------------------------------------------------------------------------ # + # ------------------------------------------------------------------------------------ # + # ------------------------------------------------------------------------------------ # + + if mouse_click == "RIGHT" and mouse_event == MouseEventType.MOUSE_DOWN : + if self.mouse_float == True : + self.root_layout.floats.append(floa) + self.mouse_cord=(x,y) + self.mouse_float = False + else: + try: + if get_app().layout.container.floats: + if get_app().layout.container.floats[-1].name =='mouse': + get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) + self.root_layout.floats.append(floa) + self.mouse_cord=(x,y) + self.mouse_float = False + else: + self.root_layout.floats.append(floa) + self.mouse_cord=(x,y) + self.mouse_float = False + else: + self.root_layout.floats.append(floa) + self.mouse_cord=(x,y) + self.mouse_float = False + except Exception as e: + pass + + elif mouse_click == "LEFT" and mouse_event == MouseEventType.MOUSE_DOWN and self.mouse_float == False: + try: + if get_app().layout.container.floats: + if get_app().layout.container.floats[-1].name =='mouse': + + if self.mouse_select =='Copy': + data = get_app().current_buffer.copy_selection(False) + get_app().clipboard.set_data(data) + get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) + self.mouse_float = True + + elif self.mouse_select =='Paste': + data = get_app().clipboard.get_data() + get_app().current_buffer.paste_clipboard_data(data) + get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) + self.mouse_float = True + + elif self.mouse_select =='Cut': + data = get_app().current_buffer.copy_selection(True) + get_app().clipboard.set_data(data) + get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) + self.mouse_float = True + + else: + get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) + self.mouse_float = True + + except Exception as e: + pass + + + if get_app().layout.container.floats: + try : + get_float_name = get_app().layout.container.floats[-1].name + except: + get_float_name = '' + + if get_float_name =='mouse': + if self.mouse_cord[0] <= x and self.mouse_cord[0] >= x-5: + if self.mouse_cord[1] == y-1: + res = [] + res.append(HTML(''.format('#00FF00', "Copy "))) + res.append("\n") + res.append(HTML(''.format("Cut"))) + res.append("\n") + res.append(HTML(''.format("Paste"))) + res.append("\n") + get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) + self.mouse_select = 'Copy' + + elif self.mouse_cord[1] == y-2: + res = [] + res.append(HTML(''.format("Copy"))) + res.append("\n") + res.append(HTML(''.format('#00FF00', "Cut "))) + res.append("\n") + res.append(HTML(''.format("Paste"))) + res.append("\n") + get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) + self.mouse_select = 'Cut' + + elif self.mouse_cord[1] == y-3: + res = [] + res.append(HTML(''.format("Copy"))) + res.append("\n") + res.append(HTML(''.format("Cut"))) + res.append("\n") + res.append(HTML(''.format('#00FF00', "Paste"))) + res.append("\n") + get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) + self.mouse_select = 'Paste' + else: + self.mouse_select = 'None' + else: + res = [] + res.append(HTML(''.format("Copy"))) + res.append("\n") + res.append(HTML(''.format("Cut"))) + res.append("\n") + res.append(HTML(''.format("Paste"))) + res.append("\n") + get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) + self.mouse_select = 'None' def up(self, ev: KeyPressEvent) -> None: get_app().layout.focus(Frame(self.nav_bar.nav_window)) diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py index 9c0e545831a..26ac561f1f0 100755 --- a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py @@ -21,7 +21,7 @@ from wui_components.jans_side_nav_bar import JansSideNavBar from wui_components.jans_cli_dialog import JansGDialog from wui_components.jans_drop_down import DropDownWidget -from wui_components.jans_date_picker import DateSelectWidget +from cli_tui.wui_components.jans_date_picker import DateSelectWidget from utils.utils import DialogUtils from wui_components.jans_vetrical_nav import JansVerticalNav from view_uma_dialog import ViewUMADialog diff --git a/jans-cli-tui/cli_tui/utils/utils.py b/jans-cli-tui/cli_tui/utils/utils.py index f5dd69c1506..427cf0d09b5 100755 --- a/jans-cli-tui/cli_tui/utils/utils.py +++ b/jans-cli-tui/cli_tui/utils/utils.py @@ -8,7 +8,8 @@ from wui_components.jans_spinner import Spinner import sys -from wui_components.jans_date_picker import DateSelectWidget +sys.path.append("./") +from cli_tui.wui_components.jans_date_picker import DateSelectWidget common_data = SimpleNamespace() From ecf15b2f66384f70255d0a6fc95c785f183f815b Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Wed, 21 Dec 2022 21:55:43 +0300 Subject: [PATCH 13/30] fix: jans-cli-tui imports --- jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py | 2 +- jans-cli-tui/cli_tui/utils/utils.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py index 26ac561f1f0..9c0e545831a 100755 --- a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py @@ -21,7 +21,7 @@ from wui_components.jans_side_nav_bar import JansSideNavBar from wui_components.jans_cli_dialog import JansGDialog from wui_components.jans_drop_down import DropDownWidget -from cli_tui.wui_components.jans_date_picker import DateSelectWidget +from wui_components.jans_date_picker import DateSelectWidget from utils.utils import DialogUtils from wui_components.jans_vetrical_nav import JansVerticalNav from view_uma_dialog import ViewUMADialog diff --git a/jans-cli-tui/cli_tui/utils/utils.py b/jans-cli-tui/cli_tui/utils/utils.py index 427cf0d09b5..f5dd69c1506 100755 --- a/jans-cli-tui/cli_tui/utils/utils.py +++ b/jans-cli-tui/cli_tui/utils/utils.py @@ -8,8 +8,7 @@ from wui_components.jans_spinner import Spinner import sys -sys.path.append("./") -from cli_tui.wui_components.jans_date_picker import DateSelectWidget +from wui_components.jans_date_picker import DateSelectWidget common_data = SimpleNamespace() From d143b0102f6d373e8f3e2661061be245d456e412 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Wed, 21 Dec 2022 22:02:23 +0300 Subject: [PATCH 14/30] feat: jans-cli-tui option --no-tui --- jans-cli-tui/cli_tui/jans_cli_tui.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/jans-cli-tui/cli_tui/jans_cli_tui.py b/jans-cli-tui/cli_tui/jans_cli_tui.py index ec7bce653e3..11332499cd1 100755 --- a/jans-cli-tui/cli_tui/jans_cli_tui.py +++ b/jans-cli-tui/cli_tui/jans_cli_tui.py @@ -22,6 +22,17 @@ if os.path.exists(pylib_dir): sys.path.insert(0, pylib_dir) +no_tui = False +if '--no-tui' in sys.argv: + sys.argv.remove('--no-tui') + no_tui = True + +from cli import config_cli + +if no_tui: + config_cli.main() + sys.exit() + import prompt_toolkit from prompt_toolkit.application import Application from prompt_toolkit.application.current import get_app @@ -62,7 +73,7 @@ from prompt_toolkit.formatted_text import AnyFormattedText from typing import TypeVar, Callable from prompt_toolkit.widgets import Button, Dialog, Label -from cli import config_cli + from utils.validators import IntegerValidator from wui_components.jans_cli_dialog import JansGDialog from wui_components.jans_nav_bar import JansNavBar From e8bb14fb7ecec2ff8ca843e3aff1f72a8622e467 Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Wed, 21 Dec 2022 11:32:42 -0800 Subject: [PATCH 15/30] fix:jans-cli-tui unable to search user in search box (ref: #3353) --- jans-cli-tui/cli_tui/plugins/060_scripts/main.py | 2 +- jans-cli-tui/cli_tui/plugins/070_users/main.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/060_scripts/main.py b/jans-cli-tui/cli_tui/plugins/060_scripts/main.py index 196d0a1e99e..aab867b8dbb 100755 --- a/jans-cli-tui/cli_tui/plugins/060_scripts/main.py +++ b/jans-cli-tui/cli_tui/plugins/060_scripts/main.py @@ -66,7 +66,7 @@ def scripts_prepare_containers(self) -> None: def get_scripts( self, - start_index: Optional[int]= 1, + start_index: Optional[int]= 0, pattern: Optional[str]= '', ) -> None: """Get the current Scripts from server diff --git a/jans-cli-tui/cli_tui/plugins/070_users/main.py b/jans-cli-tui/cli_tui/plugins/070_users/main.py index e80b2cb557b..287ddc6bb5e 100755 --- a/jans-cli-tui/cli_tui/plugins/070_users/main.py +++ b/jans-cli-tui/cli_tui/plugins/070_users/main.py @@ -103,7 +103,7 @@ def update_user_list_container(self, pattern: Optional[str]='') -> None: self.app.invalidate() - def get_users(self, start_index: int=1, pattern: Optional[str]='') -> None: + def get_users(self, start_index: int=0, pattern: Optional[str]='') -> None: """Gets Users from server. """ From d68a13b4c5cf84c31827b3f74eb1be73fe9d77cc Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Wed, 21 Dec 2022 11:52:36 -0800 Subject: [PATCH 16/30] fix: jans-cli-tui searches should call if no search string entered (ref: #3379) --- jans-cli-tui/cli_tui/plugins/010_oxauth/main.py | 10 ---------- jans-cli-tui/cli_tui/plugins/040_config_api/main.py | 6 ------ jans-cli-tui/cli_tui/plugins/060_scripts/main.py | 5 +---- jans-cli-tui/cli_tui/plugins/070_users/main.py | 3 --- 4 files changed, 1 insertion(+), 23 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/main.py b/jans-cli-tui/cli_tui/plugins/010_oxauth/main.py index e9bd5f3864c..89159e4be55 100755 --- a/jans-cli-tui/cli_tui/plugins/010_oxauth/main.py +++ b/jans-cli-tui/cli_tui/plugins/010_oxauth/main.py @@ -527,10 +527,6 @@ def search_properties(self, tbuffer:Buffer) -> None: self.app.logger.debug("type tbuffer="+str(type(tbuffer))) self.search_text=tbuffer.text - if not len(tbuffer.text) > 2: - self.app.show_message(_("Error!"), _("Search string should be at least three characters"),tobefocused=self.oauth_containers['properties']) - return - self.oauth_update_properties(0, tbuffer.text) def oauth_update_keys(self) -> None: @@ -660,9 +656,6 @@ def search_scope(self, tbuffer:Buffer,) -> None: Args: tbuffer (Buffer): Buffer returned from the TextArea widget > GetTitleText """ - if not len(tbuffer.text) > 2: - self.app.show_message(_("Error!"), _("Search string should be at least three characters"),tobefocused=self.oauth_containers['scopes']) - return self.oauth_get_scopes(pattern=tbuffer.text) @@ -672,9 +665,6 @@ def search_clients(self, tbuffer:Buffer,) -> None: Args: tbuffer (Buffer): Buffer returned from the TextArea widget > GetTitleText """ - if not len(tbuffer.text) > 2: - self.app.show_message(_("Error!"), _("Search string should be at least three characters"),tobefocused=self.oauth_containers['clients']) - return self.oauth_update_clients(pattern=tbuffer.text) diff --git a/jans-cli-tui/cli_tui/plugins/040_config_api/main.py b/jans-cli-tui/cli_tui/plugins/040_config_api/main.py index 238ae2a4c27..397c626ff76 100755 --- a/jans-cli-tui/cli_tui/plugins/040_config_api/main.py +++ b/jans-cli-tui/cli_tui/plugins/040_config_api/main.py @@ -476,9 +476,6 @@ def search_adminui_permissions(self, tbuffer:Buffer) -> None: Args: tbuffer (Buffer): Buffer returned from the TextArea widget > GetTitleText """ - if not len(tbuffer.text) > 2: - self.app.show_message(_("Error!"), _("Search string should be at least three characters"), tobefocused=self.app.center_container) - return self.adminui_update_permissions(0, tbuffer.text) @@ -632,9 +629,6 @@ def search_adminui_mapping(self, tbuffer:Buffer,) -> None: Args: tbuffer (Buffer): Buffer returned from the TextArea widget > GetTitleText """ - if not len(tbuffer.text) > 2: - self.app.show_message(_("Error!"), _("Search string should be at least three characters"),tobefocused=self.containers['mapping']) - return self.adminui_update_mapping(tbuffer.text) diff --git a/jans-cli-tui/cli_tui/plugins/060_scripts/main.py b/jans-cli-tui/cli_tui/plugins/060_scripts/main.py index aab867b8dbb..1f250038e9b 100755 --- a/jans-cli-tui/cli_tui/plugins/060_scripts/main.py +++ b/jans-cli-tui/cli_tui/plugins/060_scripts/main.py @@ -170,10 +170,7 @@ def search_scripts(self, tbuffer:Buffer) -> None: Args: tbuffer (Buffer): Buffer returned from the TextArea widget > GetTitleText """ - if not len(tbuffer.text) > 2: - self.app.show_message(_("Error!"), _("Search string should be at least three characters"), tobefocused=self.scripts_main_area) - return - + self.get_scripts(pattern=tbuffer.text) def add_script_dialog(self, **kwargs: Any): diff --git a/jans-cli-tui/cli_tui/plugins/070_users/main.py b/jans-cli-tui/cli_tui/plugins/070_users/main.py index 287ddc6bb5e..747217813fd 100755 --- a/jans-cli-tui/cli_tui/plugins/070_users/main.py +++ b/jans-cli-tui/cli_tui/plugins/070_users/main.py @@ -266,8 +266,5 @@ def search_user(self, tbuffer:Buffer) -> None: Args: tbuffer (Buffer): Buffer returned from the TextArea widget > GetTitleText """ - if not len(tbuffer.text) > 2: - self.app.show_message(_("Error!"), _("Search string should be at least three characters"), tobefocused=self.app.center_container) - return self.get_users(pattern=tbuffer.text) From 1bf0aff0365372469ffc97c1b323b5b3f4a4e7e3 Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Wed, 21 Dec 2022 12:01:45 -0800 Subject: [PATCH 17/30] fix:jans-cli-tui reverting changes for worng user password implementation (ref: #3360) --- jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py | 4 ---- jans-cli-tui/cli_tui/plugins/070_users/main.py | 3 --- 2 files changed, 7 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py b/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py index 62fbdf436d6..e1b9f06ec4f 100644 --- a/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py @@ -156,10 +156,6 @@ def get_custom_attribute(attribute, multi=False): self.edit_user_content.insert(2, self.app.getTitledText(_("Password *"), name='userPassword', value='', style='class:script-titledtext', jans_help=self.app.get_help_from_schema(self.schema, 'userPassword')) ) - else : - self.edit_user_content.insert(2, - self.app.getTitledText(_("Change Password"), name='userPassword', value='', style='class:script-titledtext', jans_help="Enter New Password") - ) for ca in self.data.get('customAttributes', []): diff --git a/jans-cli-tui/cli_tui/plugins/070_users/main.py b/jans-cli-tui/cli_tui/plugins/070_users/main.py index 747217813fd..ead042a5973 100755 --- a/jans-cli-tui/cli_tui/plugins/070_users/main.py +++ b/jans-cli-tui/cli_tui/plugins/070_users/main.py @@ -196,9 +196,6 @@ def save_user(self, dialog: Dialog) -> None: if 'baseDn' not in dialog.data: user_info['userPassword'] = raw_data['userPassword'] - else: - if raw_data['userPassword']: - user_info['userPassword'] = raw_data['userPassword'] for key_ in ('inum', 'baseDn', 'dn'): if key_ in raw_data: From 456ae85d4a51827fd230ee1c83103eb613f39a47 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Fri, 23 Dec 2022 11:04:49 +0300 Subject: [PATCH 18/30] fix: jans-cli-tui user patch operation --- jans-cli-tui/cli_tui/cli/config_cli.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/jans-cli-tui/cli_tui/cli/config_cli.py b/jans-cli-tui/cli_tui/cli/config_cli.py index c8ed11eff01..aa115cd01fc 100755 --- a/jans-cli-tui/cli_tui/cli/config_cli.py +++ b/jans-cli-tui/cli_tui/cli/config_cli.py @@ -1126,7 +1126,11 @@ def patch_requests(self, endpoint, url_param_dict, data): security = self.get_scope_for_endpoint(endpoint) self.get_access_token(security) - headers = self.get_request_header({'Accept': 'application/json', 'Content-Type': 'application/json-patch+json'}) + content_key = 'application/json-patch+json' + for content_key in endpoint.info.get('requestBody', {}).get('content', {}): + break + + headers = self.get_request_header({'Accept': 'application/json', 'Content-Type': content_key}) data = data response = requests.patch( url=url, @@ -1361,17 +1365,18 @@ def process_command_patch(self, path, suffix_param, endpoint_params, data_fn, da except ValueError as ve: self.exit_with_error(str(ve)) - if not isinstance(data, list): + if ('configuser' not in endpoint.path) and (not isinstance(data, list)): self.exit_with_error("{} must be array of /components/schemas/PatchRequest".format(data_fn)) - op_modes = ('add', 'remove', 'replace', 'move', 'copy', 'test') + if 'configuser' not in endpoint.path: + op_modes = ('add', 'remove', 'replace', 'move', 'copy', 'test') - for item in data: - if not item['op'] in op_modes: - print("op must be one of {}".format(', '.join(op_modes))) - sys.exit() - if not item['path'].startswith('/'): - item['path'] = '/' + item['path'] + for item in data: + if not item['op'] in op_modes: + print("op must be one of {}".format(', '.join(op_modes))) + sys.exit() + if not item['path'].startswith('/'): + item['path'] = '/' + item['path'] response = self.patch_requests(endpoint, suffix_param, data) From d5716c22495687b020589d91df1b160cd5fc7f4b Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Fri, 23 Dec 2022 11:19:59 +0300 Subject: [PATCH 19/30] fix: rename 010_oxauth as 010_auth_server --- .../cli_tui/plugins/{010_oxauth => 010_auth_server}/.enabled | 0 .../cli_tui/plugins/{010_oxauth => 010_auth_server}/__init__.py | 0 .../plugins/{010_oxauth => 010_auth_server}/edit_client_dialog.py | 0 .../plugins/{010_oxauth => 010_auth_server}/edit_scope_dialog.py | 0 .../cli_tui/plugins/{010_oxauth => 010_auth_server}/main.py | 0 .../plugins/{010_oxauth => 010_auth_server}/view_property.py | 0 .../plugins/{010_oxauth => 010_auth_server}/view_uma_dialog.py | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename jans-cli-tui/cli_tui/plugins/{010_oxauth => 010_auth_server}/.enabled (100%) rename jans-cli-tui/cli_tui/plugins/{010_oxauth => 010_auth_server}/__init__.py (100%) rename jans-cli-tui/cli_tui/plugins/{010_oxauth => 010_auth_server}/edit_client_dialog.py (100%) rename jans-cli-tui/cli_tui/plugins/{010_oxauth => 010_auth_server}/edit_scope_dialog.py (100%) rename jans-cli-tui/cli_tui/plugins/{010_oxauth => 010_auth_server}/main.py (100%) rename jans-cli-tui/cli_tui/plugins/{010_oxauth => 010_auth_server}/view_property.py (100%) rename jans-cli-tui/cli_tui/plugins/{010_oxauth => 010_auth_server}/view_uma_dialog.py (100%) diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/.enabled b/jans-cli-tui/cli_tui/plugins/010_auth_server/.enabled similarity index 100% rename from jans-cli-tui/cli_tui/plugins/010_oxauth/.enabled rename to jans-cli-tui/cli_tui/plugins/010_auth_server/.enabled diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/__init__.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/__init__.py similarity index 100% rename from jans-cli-tui/cli_tui/plugins/010_oxauth/__init__.py rename to jans-cli-tui/cli_tui/plugins/010_auth_server/__init__.py diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py similarity index 100% rename from jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py rename to jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_scope_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py similarity index 100% rename from jans-cli-tui/cli_tui/plugins/010_oxauth/edit_scope_dialog.py rename to jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/main.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py similarity index 100% rename from jans-cli-tui/cli_tui/plugins/010_oxauth/main.py rename to jans-cli-tui/cli_tui/plugins/010_auth_server/main.py diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/view_property.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_property.py similarity index 100% rename from jans-cli-tui/cli_tui/plugins/010_oxauth/view_property.py rename to jans-cli-tui/cli_tui/plugins/010_auth_server/view_property.py diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/view_uma_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_uma_dialog.py similarity index 100% rename from jans-cli-tui/cli_tui/plugins/010_oxauth/view_uma_dialog.py rename to jans-cli-tui/cli_tui/plugins/010_auth_server/view_uma_dialog.py From 4c2775c51e0aedc0ace2d4cc8c914b4892f28fc6 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Fri, 23 Dec 2022 11:24:27 +0300 Subject: [PATCH 20/30] fix: rename oxauth to_oauth --- jans-cli-tui/cli_tui/plugins/010_auth_server/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py index 89159e4be55..84fde741b2d 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py @@ -41,13 +41,13 @@ def __init__( self, app: Application ) -> None: - """init for Plugin class "oxauth" + """init for Plugin class "oauth" Args: app (Generic): The main Application class """ self.app = app - self.pid = 'oxauth' + self.pid = 'oauth' self.name = '[A]uth Server' self.search_text= None self.oauth_update_properties_start_index = 0 From 7bd8d26bb2343acb171417cf87f7b28520c4fc8e Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Thu, 29 Dec 2022 19:19:23 +0300 Subject: [PATCH 21/30] fix: jans-cli-tui parse escaped colon for patch (ref: #3448) --- jans-cli-tui/cli_tui/cli/config_cli.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jans-cli-tui/cli_tui/cli/config_cli.py b/jans-cli-tui/cli_tui/cli/config_cli.py index aa115cd01fc..e2db383ee48 100755 --- a/jans-cli-tui/cli_tui/cli/config_cli.py +++ b/jans-cli-tui/cli_tui/cli/config_cli.py @@ -1424,11 +1424,13 @@ def process_command_by_id(self, operation_id, url_suffix, endpoint_args, data_fn pdata = args.patch_replace if pop: - if pop != 'remove' and pdata.count(':') != 1: - self.exit_with_error("Please provide --patch-data as colon delimited key:value pair") + if pop != 'remove': + try: + ppath, pval = self.unescaped_split(pdata, ':') + except Exception as e: + self.exit_with_error("Please provide --patch-data as colon delimited key:value pair.\nUse escape if you need colon in value or key, i.e. mtlsUserInfoEndpoint:https\\:example.jans.io/userinfo") if pop != 'remove': - ppath, pval = pdata.split(':') data = [{'op': pop, 'path': '/'+ ppath.lstrip('/'), 'value': pval}] else: data = [{'op': pop, 'path': '/'+ pdata.lstrip('/')}] From 75d2e1cb25c3a77aa30dbf7971beb34168683dfa Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Fri, 30 Dec 2022 22:56:22 -0800 Subject: [PATCH 22/30] fix: jans-cli-tui fix typo (ref: #3475) --- .../cli_tui/plugins/010_auth_server/edit_client_dialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py index 9c0e545831a..da5c79bead2 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py @@ -307,7 +307,7 @@ def prepare_tabs(self) -> None: style='class:outh-client-radiobutton'), self.myparent.getTitledCheckBox( - _("Incliude Claims in id_token"), + _("Include Claims in id_token"), name='includeClaimsInIdToken', checked=self.data.get('includeClaimsInIdToken'), jans_help=self.myparent.get_help_from_schema(schema, 'includeClaimsInIdToken'), From c4e5ddf61c53b7385fdef793b438078be7115122 Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Fri, 30 Dec 2022 23:20:22 -0800 Subject: [PATCH 23/30] fix:jans-cli-tui fix script search (ref #3468) --- jans-cli-tui/cli_tui/plugins/060_scripts/main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jans-cli-tui/cli_tui/plugins/060_scripts/main.py b/jans-cli-tui/cli_tui/plugins/060_scripts/main.py index 1f250038e9b..6d058e0ef25 100755 --- a/jans-cli-tui/cli_tui/plugins/060_scripts/main.py +++ b/jans-cli-tui/cli_tui/plugins/060_scripts/main.py @@ -136,8 +136,17 @@ def scripts_update_list( buttons = [] + f = open("hopa.dev", "a") + f.write('start: '+str(self.data['start'])+'\n') + f.write('totalEntriesCount: '+str(self.data['totalEntriesCount'])+'\n') + f.write('entriesCount: '+str(self.data['entriesCount'])+'\n') + f.write('Prev: '+str(self.data['start']-self.app.entries_per_page-1)+'\n') + f.write('**************************'+'\n') + f.close() + + if self.data['start'] > 1: - handler_partial = partial(self.get_scripts, self.data['start']-self.app.entries_per_page+1, pattern) + handler_partial = partial(self.get_scripts, self.data['start']-self.app.entries_per_page-1, pattern) prev_button = Button(_("Prev"), handler=handler_partial) prev_button.window.jans_help = _("Retreives previous %d entries") % self.app.entries_per_page buttons.append(prev_button) From 5439c070e55b1f8cfd838b72d34eee4be278552e Mon Sep 17 00:00:00 2001 From: AbdelwahabAdam Date: Fri, 30 Dec 2022 23:22:57 -0800 Subject: [PATCH 24/30] fix:jans-cli-tui fix script search (ref #3468) --- jans-cli-tui/cli_tui/plugins/060_scripts/main.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/060_scripts/main.py b/jans-cli-tui/cli_tui/plugins/060_scripts/main.py index 6d058e0ef25..e90cf9f689d 100755 --- a/jans-cli-tui/cli_tui/plugins/060_scripts/main.py +++ b/jans-cli-tui/cli_tui/plugins/060_scripts/main.py @@ -136,15 +136,6 @@ def scripts_update_list( buttons = [] - f = open("hopa.dev", "a") - f.write('start: '+str(self.data['start'])+'\n') - f.write('totalEntriesCount: '+str(self.data['totalEntriesCount'])+'\n') - f.write('entriesCount: '+str(self.data['entriesCount'])+'\n') - f.write('Prev: '+str(self.data['start']-self.app.entries_per_page-1)+'\n') - f.write('**************************'+'\n') - f.close() - - if self.data['start'] > 1: handler_partial = partial(self.get_scripts, self.data['start']-self.app.entries_per_page-1, pattern) prev_button = Button(_("Prev"), handler=handler_partial) From 5b0ecffa6723813e1e172d806ee078f024f088a3 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Sat, 31 Dec 2022 18:46:03 +0300 Subject: [PATCH 25/30] fix: jan-cli-tui add none option to tokenEndpointAuthMethod (ref: #3463) --- .../cli_tui/plugins/010_auth_server/edit_client_dialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py index da5c79bead2..d7ddf0bbd4e 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py @@ -217,7 +217,7 @@ def prepare_tabs(self) -> None: self.myparent.getTitledRadioButton( _("Authn Method token endpoint"), name='tokenEndpointAuthMethod', - values=[('client_secret_basic', 'client_secret_basic'), ('client_secret_post', 'client_secret_post'), ('client_secret_jwt', 'client_secret_jwt'), ('private_key_jwt', 'private_key_jwt')], + values=[('none', 'none'), ('client_secret_basic', 'client_secret_basic'), ('client_secret_post', 'client_secret_post'), ('client_secret_jwt', 'client_secret_jwt'), ('private_key_jwt', 'private_key_jwt')], current_value=self.data.get('tokenEndpointAuthMethod'), jans_help=self.myparent.get_help_from_schema(schema, 'tokenEndpointAuthMethod'), style='class:outh-client-radiobutton'), From fbaa22746a1d0063d0fd7d455bae58b427da0ff5 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Mon, 2 Jan 2023 11:03:50 +0300 Subject: [PATCH 26/30] fix: jans-cli-tui code smells --- jans-cli-tui/cli_tui/cli/config_cli.py | 2 +- jans-cli-tui/cli_tui/cli_style.py | 17 +++ jans-cli-tui/cli_tui/jans_cli_tui.py | 47 +++--- .../010_auth_server/edit_client_dialog.py | 137 +++++++++--------- .../010_auth_server/edit_scope_dialog.py | 98 ++++++------- jans-cli-tui/cli_tui/utils/static.py | 7 + 6 files changed, 164 insertions(+), 144 deletions(-) diff --git a/jans-cli-tui/cli_tui/cli/config_cli.py b/jans-cli-tui/cli_tui/cli/config_cli.py index e2db383ee48..bbc25ed4262 100755 --- a/jans-cli-tui/cli_tui/cli/config_cli.py +++ b/jans-cli-tui/cli_tui/cli/config_cli.py @@ -1427,7 +1427,7 @@ def process_command_by_id(self, operation_id, url_suffix, endpoint_args, data_fn if pop != 'remove': try: ppath, pval = self.unescaped_split(pdata, ':') - except Exception as e: + except Exception: self.exit_with_error("Please provide --patch-data as colon delimited key:value pair.\nUse escape if you need colon in value or key, i.e. mtlsUserInfoEndpoint:https\\:example.jans.io/userinfo") if pop != 'remove': diff --git a/jans-cli-tui/cli_tui/cli_style.py b/jans-cli-tui/cli_tui/cli_style.py index ac940f37f25..ad5309edc3d 100755 --- a/jans-cli-tui/cli_tui/cli_style.py +++ b/jans-cli-tui/cli_tui/cli_style.py @@ -59,6 +59,23 @@ "outh-titledtext":"green", "outh-label":"blue", + + # PLUGINS + "plugin-navbar":"#2600ff", + "plugin-navbar-headcolor":"green", + "plugin-navbar-entriescolor":"blue", + "plugin-tabs":"", + "plugin-text":"green", + "plugin-textsearch":"", + "plugin-label":"bold", + "plugin-textrequired":"#8b000a", + "plugin-checkbox":"green", + "plugin-checkboxlist":"green", + "plugin-radiobutton":"green", + "plugin-dropdown":"green", + "plugin-widget":"green", + + ## edit_client_dialog "outh-client-navbar":"#2600ff", "outh-client-navbar-headcolor":"green", diff --git a/jans-cli-tui/cli_tui/jans_cli_tui.py b/jans-cli-tui/cli_tui/jans_cli_tui.py index 11332499cd1..78cb7914735 100755 --- a/jans-cli-tui/cli_tui/jans_cli_tui.py +++ b/jans-cli-tui/cli_tui/jans_cli_tui.py @@ -422,12 +422,15 @@ def mouse(self,event): ### mouse: [<35;108;20M # ------------------------------------------------------------------------------------ # # ------------------------------------------------------------------------------------ # # ------------------------------------------------------------------------------------ # + style_tmp = '' + style_tmp_red = '' + res=[] - res.append(HTML(''.format("Copy"))) - res.append("\n") - res.append(HTML(''.format("Cut"))) + res.append(HTML(style_tmp.format("Copy"))) + res.append("\n") + res.append(HTML(style_tmp.format("Cut"))) res.append("\n") - res.append(HTML(''.format("Paste"))) + res.append(HTML(style_tmp.format("Paste"))) res.append("\n") content= Window( @@ -437,7 +440,7 @@ def mouse(self,event): ### mouse: [<35;108;20M ), height=D()) floa=Float(content=content, left=x,top=y) floa.name='mouse' - + # ------------------------------------------------------------------------------------ # # ------------------------------------------------------------------------------------ # # ------------------------------------------------------------------------------------ # @@ -463,7 +466,7 @@ def mouse(self,event): ### mouse: [<35;108;20M self.root_layout.floats.append(floa) self.mouse_cord=(x,y) self.mouse_float = False - except Exception as e: + except Exception: pass elif mouse_click == "LEFT" and mouse_event == MouseEventType.MOUSE_DOWN and self.mouse_float == False: @@ -493,7 +496,7 @@ def mouse(self,event): ### mouse: [<35;108;20M get_app().layout.container.floats.remove(get_app().layout.container.floats[-1]) self.mouse_float = True - except Exception as e: + except Exception: pass @@ -507,33 +510,31 @@ def mouse(self,event): ### mouse: [<35;108;20M if self.mouse_cord[0] <= x and self.mouse_cord[0] >= x-5: if self.mouse_cord[1] == y-1: res = [] - res.append(HTML(''.format('#00FF00', "Copy "))) + res.append(HTML(style_tmp_red.format("Copy "))) res.append("\n") - res.append(HTML(''.format("Cut"))) + res.append(HTML(style_tmp.format("Cut"))) res.append("\n") - res.append(HTML(''.format("Paste"))) + res.append(HTML(style_tmp.format("Paste"))) res.append("\n") get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) - self.mouse_select = 'Copy' - + self.mouse_select = 'Copy' elif self.mouse_cord[1] == y-2: res = [] - res.append(HTML(''.format("Copy"))) + res.append(HTML(style_tmp.format("Copy"))) res.append("\n") - res.append(HTML(''.format('#00FF00', "Cut "))) + res.append(HTML(style_tmp_red.format("Cut "))) res.append("\n") - res.append(HTML(''.format("Paste"))) + res.append(HTML(style_tmp.format("Paste"))) res.append("\n") get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) - self.mouse_select = 'Cut' - + self.mouse_select = 'Cut' elif self.mouse_cord[1] == y-3: res = [] - res.append(HTML(''.format("Copy"))) + res.append(HTML(style_tmp.format("Copy"))) res.append("\n") - res.append(HTML(''.format("Cut"))) + res.append(HTML(style_tmp.format("Cut"))) res.append("\n") - res.append(HTML(''.format('#00FF00', "Paste"))) + res.append(HTML(style_tmp_red.format(style_tmp_red, "Paste"))) res.append("\n") get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) self.mouse_select = 'Paste' @@ -541,11 +542,11 @@ def mouse(self,event): ### mouse: [<35;108;20M self.mouse_select = 'None' else: res = [] - res.append(HTML(''.format("Copy"))) + res.append(HTML(style_tmp.format("Copy"))) res.append("\n") - res.append(HTML(''.format("Cut"))) + res.append(HTML(style_tmp.format("Cut"))) res.append("\n") - res.append(HTML(''.format("Paste"))) + res.append(HTML(style_tmp.format("Paste"))) res.append("\n") get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) self.mouse_select = 'None' diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py index d7ddf0bbd4e..9e3294f9677 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py @@ -15,7 +15,7 @@ from prompt_toolkit.lexers import PygmentsLexer, DynamicLexer from prompt_toolkit.application.current import get_app from asyncio import Future, ensure_future -from utils.static import DialogResult +from utils.static import DialogResult, CLI_STYLE from utils.multi_lang import _ from wui_components.jans_dialog_with_nav import JansDialogWithNav from wui_components.jans_side_nav_bar import JansSideNavBar @@ -33,6 +33,7 @@ import json +ERROR_GETTING_CLIENTS = _("Error getting clients") class EditClientDialog(JansGDialog, DialogUtils): """The Main Client Dialog that contain every thing related to The Client @@ -184,35 +185,35 @@ def prepare_tabs(self) -> None: value=self.data.get('inum',''), jans_help=self.myparent.get_help_from_schema(schema, 'inum'), read_only=True, - style='class:outh-client-text'), + style=CLI_STYLE.edit_text), self.myparent.getTitledCheckBox( _("Active"), name='disabled', checked= not self.data.get('disabled'), jans_help=self.myparent.get_help_from_schema(schema, 'disabled'), - style='class:outh-client-checkbox'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( _("Client Name"), name='clientName', value=self.data.get('clientName',''), jans_help=self.myparent.get_help_from_schema(schema, 'clientName'), - style='class:outh-client-text'), + style=CLI_STYLE.edit_text), self.myparent.getTitledText( _("Client Secret"), name='clientSecret', value=self.data.get('clientSecret',''), jans_help=self.myparent.get_help_from_schema(schema, 'clientSecret'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( _("Description"), name='description', value=self.data.get('description',''), jans_help=self.myparent.get_help_from_schema(schema, 'description'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledRadioButton( _("Authn Method token endpoint"), @@ -220,7 +221,7 @@ def prepare_tabs(self) -> None: values=[('none', 'none'), ('client_secret_basic', 'client_secret_basic'), ('client_secret_post', 'client_secret_post'), ('client_secret_jwt', 'client_secret_jwt'), ('private_key_jwt', 'private_key_jwt')], current_value=self.data.get('tokenEndpointAuthMethod'), jans_help=self.myparent.get_help_from_schema(schema, 'tokenEndpointAuthMethod'), - style='class:outh-client-radiobutton'), + style=CLI_STYLE.radio_button), self.myparent.getTitledRadioButton( _("Subject Type"), @@ -228,14 +229,14 @@ def prepare_tabs(self) -> None: values=[('public', 'Public'),('pairwise', 'Pairwise')], current_value=self.data.get('subjectType'), jans_help=self.myparent.get_help_from_schema(schema, 'subjectType'), - style='class:outh-client-radiobutton'), + style=CLI_STYLE.radio_button), self.myparent.getTitledText( _("Sector Identifier URI"), name='sectorIdentifierUri', value=self.data.get('sectorIdentifierUri',''), jans_help=self.myparent.get_help_from_schema(schema, 'sectorIdentifierUri'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledCheckBoxList( _("Grant"), @@ -259,7 +260,7 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/AppConfiguration'), 'tokenEndpointAuthMethodsSupported'), - style='class:outh-client-checkbox'), + style=CLI_STYLE.check_box), self.myparent.getTitledRadioButton( _("Application Type"), @@ -267,7 +268,7 @@ def prepare_tabs(self) -> None: values=['native','web'], current_value=self.data.get('applicationType'), jans_help=self.myparent.get_help_from_schema(schema, 'applicationType'), - style='class:outh-client-radiobutton'), + style=CLI_STYLE.radio_button), self.myparent.getTitledText( _("Redirect Uris"), @@ -284,14 +285,14 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'redirectUrisRegex'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText(_("Scopes"), name='scopes', value='\n'.join(self.data.get('scopes', [])), height=3, jans_help=self.myparent.get_help_from_schema(schema, 'scopes'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), ],width=D(), style='class:outh-client-tabs' @@ -304,14 +305,14 @@ def prepare_tabs(self) -> None: values=[('jwt', 'JWT'), ('reference', 'Reference')], current_value= 'jwt' if self.data.get('accessTokenAsJwt') else 'reference', jans_help=self.myparent.get_help_from_schema(schema, 'accessTokenAsJwt'), - style='class:outh-client-radiobutton'), + style=CLI_STYLE.radio_button), self.myparent.getTitledCheckBox( _("Include Claims in id_token"), name='includeClaimsInIdToken', checked=self.data.get('includeClaimsInIdToken'), jans_help=self.myparent.get_help_from_schema(schema, 'includeClaimsInIdToken'), - style='class:outh-client-checkbox'), + style=CLI_STYLE.check_box), self.myparent.getTitledCheckBox( _("Run introspection script before JWT access token creation"), @@ -320,14 +321,14 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'runIntrospectionScriptBeforeJwtCreation'), - style='class:outh-client-checkbox'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( title=_("Token binding confirmation method for id_token"), name='idTokenTokenBindingCnf', value=self.data.get('idTokenTokenBindingCnf',''), jans_help=self.myparent.get_help_from_schema(schema, 'idTokenTokenBindingCnf'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( title=_("Access token additional audiences"), @@ -336,7 +337,7 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'additionalAudience'), - style='class:outh-client-text', + style=CLI_STYLE.check_box, height = 3), self.myparent.getTitledText( @@ -345,7 +346,7 @@ def prepare_tabs(self) -> None: value=self.data.get('accessTokenLifetime',''), jans_help=self.myparent.get_help_from_schema(schema, 'accessTokenLifetime'), text_type='integer', - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( _("Refresh token lifetime"), @@ -353,7 +354,7 @@ def prepare_tabs(self) -> None: value=self.data.get('refreshTokenLifetime',''), jans_help=self.myparent.get_help_from_schema(schema, 'refreshTokenLifetime'), text_type='integer', - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( _("Defult max authn age"), @@ -361,7 +362,7 @@ def prepare_tabs(self) -> None: value=self.data.get('defaultMaxAge',''), jans_help=self.myparent.get_help_from_schema(schema, 'defaultMaxAge'), text_type='integer', - style='class:outh-client-text'), + style=CLI_STYLE.check_box), ],width=D(),style='class:outh-client-tabs') @@ -372,14 +373,14 @@ def prepare_tabs(self) -> None: name='frontChannelLogoutUri', value=self.data.get('frontChannelLogoutUri',''), jans_help=self.myparent.get_help_from_schema(schema, 'frontChannelLogoutUri'), ## No Descritption - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( _("Post logout redirect URIs"), name='postLogoutRedirectUris', value='\n'.join(self.data.get('postLogoutRedirectUris',[])), jans_help=self.myparent.get_help_from_schema(schema, 'postLogoutRedirectUris'), - height=3, style='class:outh-client-text'), + height=3, style=CLI_STYLE.check_box), self.myparent.getTitledText( _("Back channel logout URI"), @@ -388,7 +389,7 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'backchannelLogoutUri'), - height=3, style='class:outh-client-text' + height=3, style=CLI_STYLE.check_box ), self.myparent.getTitledCheckBox( @@ -398,7 +399,7 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'backchannelLogoutSessionRequired'), - style='class:outh-client-checkbox' + style=CLI_STYLE.check_box ), self.myparent.getTitledCheckBox( @@ -406,7 +407,7 @@ def prepare_tabs(self) -> None: name='frontChannelLogoutSessionRequired', checked=self.data.get('frontChannelLogoutSessionRequired'), jans_help=self.myparent.get_help_from_schema(schema, 'frontChannelLogoutSessionRequired'),## No Descritption - style='class:outh-client-checkbox'), + style=CLI_STYLE.check_box), ],width=D(),style='class:outh-client-tabs' ) @@ -418,35 +419,35 @@ def prepare_tabs(self) -> None: value='\n'.join(self.data.get('contacts', [])), height=3, jans_help=self.myparent.get_help_from_schema(schema, 'contacts'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText(_("Authorized JS origins"), ### height =3 insted of the <+> button name='authorizedOrigins', value='\n'.join(self.data.get('authorizedOrigins', [])), height=3, jans_help=self.myparent.get_help_from_schema(schema, 'authorizedOrigins'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( title =_("Software id"), name='softwareId', value=self.data.get('softwareId',''), jans_help=self.myparent.get_help_from_schema(schema, 'softwareId'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( title =_("Software version"), name='softwareVersion', value=self.data.get('softwareVersion',''), jans_help=self.myparent.get_help_from_schema(schema, 'softwareVersion'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( title =_("Software statement"), name='softwareStatement', value=self.data.get('softwareStatement',''), jans_help=self.myparent.get_help_from_schema(schema, 'softwareStatement'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), ],width=D(),style='class:outh-client-tabs') @@ -472,20 +473,20 @@ def prepare_tabs(self) -> None: current_value=self.data.get('backchannelTokenDeliveryMode'), values=['poll','push', 'ping'], jans_help=self.myparent.get_help_from_schema(schema, 'backchannelTokenDeliveryMode'), - style='class:outh-client-radiobutton'), + style=CLI_STYLE.radio_button), self.myparent.getTitledText( title =_("Client notification endpoint"), name='backchannelClientNotificationEndpoint', value=self.data.get('backchannelClientNotificationEndpoint',''), jans_help=self.myparent.get_help_from_schema(schema, 'backchannelClientNotificationEndpoint'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledCheckBox( _("Require user code param"), name='backchannelUserCodeParameter', checked=self.data.get('backchannelUserCodeParameter', ''), - style='class:outh-client-checkbox', + style=CLI_STYLE.check_box, jans_help=self.myparent.get_help_from_schema(schema, 'backchannelUserCodeParameter'), ), @@ -493,20 +494,20 @@ def prepare_tabs(self) -> None: Label(text=_("PAR"),style='class:outh-client-label'), self.myparent.getTitledText( - title =_("Request lifetime"), + title =_("Request lifetime"), name='parLifetime', value=self.data.get('attributes', {}).get('parLifetime',0), jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'parLifetime'), - text_type='integer', - style='class:outh-client-text'), + text_type='integer', + style=CLI_STYLE.check_box), self.myparent.getTitledCheckBox( _("Request PAR"), name='requirePar', checked=self.data.get('attributes', {}).get('requirePar',''), - style='class:outh-client-checkbox', + style=CLI_STYLE.check_box, jans_help=self.myparent.get_help_from_schema(schema, 'requirePar'), ), @@ -518,7 +519,7 @@ def prepare_tabs(self) -> None: values=[('jwt', 'JWT'), ('reference', 'Reference')], current_value='jwt' if self.data.get('rptAsJwt') else 'reference', jans_help=self.myparent.get_help_from_schema(schema, 'rptAsJwt'), - style='class:outh-client-radiobutton'), + style=CLI_STYLE.radio_button), self.myparent.getTitledText( title =_("Claims redirect URI"), @@ -526,13 +527,13 @@ def prepare_tabs(self) -> None: value='\n'.join(self.data.get('claimRedirectUris','')), jans_help=self.myparent.get_help_from_schema(schema, 'claimRedirectUris'), height=3, - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText(_("RPT Modification Script"), name='rptClaimsScripts', value='\n'.join(self.data.get('attributes', {}).get('rptClaimsScripts',[]) ), height=3, - style='class:outh-client-text', + style=CLI_STYLE.check_box, jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/Scope'), 'rptClaimsScripts'), @@ -550,14 +551,14 @@ def prepare_tabs(self) -> None: name='jwksUri', value=self.data.get('jwksUri',''), jans_help=self.myparent.get_help_from_schema(schema, 'jwksUri'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( title =_("Client JWKS"), name='jwks', value=self.data.get('jwks',''), jans_help=self.myparent.get_help_from_schema(schema, 'jwks'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), ] @@ -615,7 +616,7 @@ def allow_spontaneous_changed(cb): self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'spontaneousScopeScriptDns'), height=3, - style='class:outh-client-text') + style=CLI_STYLE.check_box) self.tabs['Advanced Client Properties'] = HSplit([ @@ -628,7 +629,7 @@ def allow_spontaneous_changed(cb): self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'jansDefaultPromptLogin'), - style='class:outh-client-checkbox' + style=CLI_STYLE.check_box ), self.myparent.getTitledCheckBox( @@ -636,7 +637,7 @@ def allow_spontaneous_changed(cb): name='persistClientAuthorizations', checked=self.data.get('persistClientAuthorizations'), jans_help=self.myparent.get_help_from_schema(schema, 'persistClientAuthorizations'), - style='class:outh-client-checkbox'), + style=CLI_STYLE.check_box), self.myparent.getTitledCheckBox( _("Allow spontaneos scopes"), @@ -646,7 +647,7 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'allowSpontaneousScopes'), - style='class:outh-client-checkbox' + style=CLI_STYLE.check_box ), self.spontaneous_scopes, @@ -668,21 +669,21 @@ def allow_spontaneous_changed(cb): name='initiateLoginUri', value=self.data.get('initiateLoginUri',''), jans_help=self.myparent.get_help_from_schema(schema, 'initiateLoginUri'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText(_("Request URIs"), ### height =3 insted of the <+> button name='requestUris', value='\n'.join(self.data.get('requestUris', [])), height=3, jans_help=self.myparent.get_help_from_schema(schema, 'requestUris'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText(_("Default ACR"), ### height =3 >> "the type is array" cant be dropdown name='defaultAcrValues', value='\n'.join(self.data.get('defaultAcrValues', [])), height=3, jans_help=self.myparent.get_help_from_schema(schema, 'defaultAcrValues'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText(_("Allowed ACR"), ### height =3 insted of the <+> button name='jansAuthorizedAcr', @@ -691,13 +692,13 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'jansAuthorizedAcr'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText( _("TLS Subject DN"), name='tlsClientAuthSubjectDn', value='\n'.join(self.data.get('attributes', {}).get('tlsClientAuthSubjectDn',[])), - height=3, style='class:outh-client-text', + height=3, style=CLI_STYLE.check_box, jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'tlsClientAuthSubjectDn'), @@ -726,7 +727,7 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'spontaneousScopes'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText(_("Update Token"), name='updateTokenScriptDns', @@ -734,8 +735,8 @@ def allow_spontaneous_changed(cb): height=3, jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), - 'updateTokenScriptDns'), - style='class:outh-client-text'), + 'updateTokenScriptDns'), + style=CLI_STYLE.check_box), self.myparent.getTitledText(_("Post Authn"), name='postAuthnScripts', @@ -744,7 +745,7 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'postAuthnScripts'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText(_("Introspection"), name='introspectionScripts', @@ -753,13 +754,13 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'introspectionScripts'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), self.myparent.getTitledText(_("Password Grant"), name='ropcScripts', value='\n'.join(self.data.get('attributes', {}).get('ropcScripts',[])), height=3, - style='class:outh-client-text', + style=CLI_STYLE.check_box, jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'ropcScripts'), @@ -772,14 +773,14 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'consentGatheringScripts'), - style='class:outh-client-text'), + style=CLI_STYLE.check_box), ],width=D(),style='class:outh-client-tabs' ) self.left_nav = list(self.tabs.keys())[0] def show_client_scopes(self) -> None: - client_scopes = self.data.get('scopes') + client_scopes = self.data.get('scopes') self.myparent.logger.debug('client_scopes: '+str(client_scopes)) data = [] for i in client_scopes : @@ -793,12 +794,12 @@ def show_client_scopes(self) -> None: data={} ) - except Exception as e: - # self.myparent.show_message(_("Error getting clients"), str(e)) + except Exception: + # self.myparent.show_message(ERROR_GETTING_CLIENTS, str(e)) pass if rsponse.status_code not in (200, 201): - # self.myparent.show_message(_("Error getting clients"), str(rsponse.text)) + # self.myparent.show_message(ERROR_GETTING_CLIENTS, str(rsponse.text)) pass if rsponse.json().get('scopeType','') == 'spontaneous': data.append(rsponse.json()) @@ -871,18 +872,18 @@ def oauth_update_uma_resources ( ) except Exception as e: - self.myparent.show_message(_("Error getting clients"), str(e)) + self.myparent.show_message(ERROR_GETTING_CLIENTS, str(e)) return if rsponse.status_code not in (200, 201): - self.myparent.show_message(_("Error getting clients"), str(rsponse.text)) + self.myparent.show_message(ERROR_GETTING_CLIENTS, str(rsponse.text)) return result = {} try: result = rsponse.json() except Exception: - self.myparent.show_message(_("Error getting clients"), str(rsponse.text)) + self.myparent.show_message(ERROR_GETTING_CLIENTS, str(rsponse.text)) return data =[] @@ -901,9 +902,9 @@ def oauth_update_uma_resources ( data={} ) scope_result = scope_response.json() - except Exception as e: + except Exception: display_name = 'None' - pass + display_name = scope_result.get('displayName') or scope_result.get('inum') if display_name: diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py index 69f8ef2d753..97f37e9a912 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py @@ -143,22 +143,21 @@ def create_window(self) -> None: values=scope_types, on_selection_changed=self.scope_selection_changed, jans_help=self.myparent.get_help_from_schema(self.schema, 'scopeType'), - - style='class:outh-scope-radiobutton'), + style=CLI_STYLE.radio_button), self.myparent.getTitledText( _("id"), name='id', value=self.data.get('id',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'id'), - style='class:outh-client-textrequired'), + style=CLI_STYLE.edit_text_required), self.myparent.getTitledText( _("inum"), name='inum', value=self.data.get('inum',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'inum'), - style='class:outh-scope-text', + style=CLI_STYLE.edit_text, read_only=True,), self.myparent.getTitledText( @@ -166,14 +165,14 @@ def create_window(self) -> None: name='displayName', value=self.data.get('displayName',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'displayName'), - style='class:outh-scope-text'), + style=CLI_STYLE.edit_text), self.myparent.getTitledText( _("Description"), name='description', value=self.data.get('description',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'description'), - style='class:outh-scope-text'), + style=CLI_STYLE.edit_text), DynamicContainer(lambda: self.alt_tabs[self.sope_type]), ], style='class:outh-scope-tabs'), @@ -195,7 +194,7 @@ def scope_selection_changed( self.sope_type = cb.current_value def get_named_claims( - self, + self, claims_list:list ) -> list: """This method for getting claim name @@ -207,8 +206,10 @@ def get_named_claims( list: List with Names retlated to that claims """ + calims_names = [] + try : - responce = self.myparent.cli_object.process_command_by_id( + response = self.myparent.cli_object.process_command_by_id( operation_id='get-attributes', url_suffix='', endpoint_args='', @@ -216,17 +217,15 @@ def get_named_claims( data={} ) except Exception as e: - self.myparent.show_message(_("Error getting claims"), str(e)) - return - - if responce.status_code not in (200, 201): - self.myparent.show_message(_("Error getting clients"), str(responce.text)) - return + self.myparent.show_message(_("Error getting claims"), str(e)) + return calims_names + if response.status_code not in (200, 201): + self.myparent.show_message(_("Error getting claims"), str(response.text)) + return calims_names - result = responce.json() + result = response.json() - calims_names=[] for entry in result["entries"] : for claim in claims_list: if claim == entry['dn']: @@ -249,7 +248,7 @@ async def coroutine(): result = await self.myparent.show_dialog_as_float(dialog) try: self.myparent.layout.focus(focused_before) - except: + except Exception: self.myparent.layout.focus(self.myparent.center_frame) ## if result.lower() == 'yes': @@ -272,7 +271,7 @@ def prepare_tabs(self) -> None: name='defaultScope', checked=self.data.get('defaultScope'), jans_help=self.myparent.get_help_from_schema(self.schema, 'defaultScope'), - style='class:outh-scope-checkbox', + style=CLI_STYLE.check_box, ), self.myparent.getTitledCheckBox( @@ -280,7 +279,7 @@ def prepare_tabs(self) -> None: name='showInConfigurationEndpoint', checked=self.data.get('attributes',{}).get('showInConfigurationEndpoint',''), jans_help='Configuration Endpoint', - style='class:outh-scope-checkbox', + style=CLI_STYLE.check_box, ), ],width=D(),) @@ -292,7 +291,7 @@ def prepare_tabs(self) -> None: name='defaultScope', checked=self.data.get('defaultScope'), jans_help=self.myparent.get_help_from_schema(self.schema, 'defaultScope'), - style='class:outh-scope-checkbox', + style=CLI_STYLE.check_box, ), self.myparent.getTitledCheckBox( @@ -300,7 +299,7 @@ def prepare_tabs(self) -> None: name='showInConfigurationEndpoint', checked=self.data.get('attributes',{}).get('showInConfigurationEndpoint',''), jans_help='Configuration Endpoint', - style='class:outh-scope-checkbox', + style=CLI_STYLE.check_box, ), # Window(char='-', height=1), @@ -315,23 +314,22 @@ def prepare_tabs(self) -> None: ), ] calims_data = self.get_named_claims(self.data.get('claims', [])) - - if True : - self.claims_container = JansVerticalNav( - myparent=self.myparent, - headers=['dn', 'Display Name'], - preferred_size= [0,0], - data=calims_data, - on_display=self.myparent.data_display_dialog, - on_delete=self.delete_claim, - selectes=0, - headerColor='class:outh-client-navbar-headcolor', - entriesColor='class:outh-client-navbar-entriescolor', - all_data=calims_data - ) - open_id_widgets.append(self.claims_container) - + + self.claims_container = JansVerticalNav( + myparent=self.myparent, + headers=['dn', 'Display Name'], + preferred_size= [0,0], + data=calims_data, + on_display=self.myparent.data_display_dialog, + on_delete=self.delete_claim, + selectes=0, + headerColor='class:outh-client-navbar-headcolor', + entriesColor='class:outh-client-navbar-entriescolor', + all_data=calims_data + ) + + open_id_widgets.append(self.claims_container) self.alt_tabs['openid'] = HSplit(open_id_widgets, width=D()) @@ -342,9 +340,8 @@ def prepare_tabs(self) -> None: value='\n'.join(self.data.get('dynamicScopeScripts', [])), jans_help=self.myparent.get_help_from_schema(self.schema, 'dynamicScopeScripts'), height=3, - style='class:outh-scope-text'), + style=CLI_STYLE.edit_text), - # Window(char='-', height=1), self.myparent.getTitledText( _("Search"), name='__search_claims__', @@ -357,9 +354,7 @@ def prepare_tabs(self) -> None: value='\n'.join(self.data.get('claims', [])), height=3, jans_help=self.myparent.get_help_from_schema(self.schema, 'claims'), - style='class:outh-scope-text'), - - # Label(text=_("Claims"),style='red'), ## name = claims TODO + style=CLI_STYLE.edit_text), ],width=D(), ) @@ -369,7 +364,7 @@ def prepare_tabs(self) -> None: _("Associated Client"), name='none', value=self.data.get('none',''), - style='class:outh-scope-text', + style=CLI_STYLE.edit_text, read_only=True, jans_help=self.myparent.get_help_from_schema(self.schema, 'none'), height=3,),## Not fount @@ -379,7 +374,7 @@ def prepare_tabs(self) -> None: name='creationDate', value=self.data.get('creationDate',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'creationDate'), - style='class:outh-scope-text', + style=CLI_STYLE.edit_text, read_only=True,), ],width=D(), @@ -394,7 +389,7 @@ def prepare_tabs(self) -> None: name='iconUrl', value=self.data.get('iconUrl',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'iconUrl'), - style='class:outh-scope-text'), + style=CLI_STYLE.edit_text), self.myparent.getTitledText(_("Authorization Policies"), @@ -402,14 +397,14 @@ def prepare_tabs(self) -> None: value='\n'.join(self.data.get('umaAuthorizationPolicies', [])), height=3, jans_help=self.myparent.get_help_from_schema(self.schema, 'umaAuthorizationPolicies'), - style='class:outh-scope-text'), + style=CLI_STYLE.edit_text), self.myparent.getTitledText( _("Associated Client"), name='none', value=self.data.get('none',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'none'), - style='class:outh-scope-text', + style=CLI_STYLE.edit_text, read_only=True, height=3,), ## Not fount @@ -418,13 +413,13 @@ def prepare_tabs(self) -> None: name='description', value=self.data.get('description',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'description'), - style='class:outh-scope-text', + style=CLI_STYLE.edit_text, read_only=True,), self.myparent.getTitledText( _("Creator"), name='Creator', - style='class:outh-scope-text', + style=CLI_STYLE.edit_text, jans_help=self.myparent.get_help_from_schema(self.schema, 'Creator'), read_only=True, value=uma_creator @@ -444,7 +439,7 @@ def search_claims( """ try : - responce = self.myparent.cli_object.process_command_by_id( + response = self.myparent.cli_object.process_command_by_id( operation_id='get-attributes', url_suffix='', endpoint_args='pattern:{}'.format(textbuffer.text), @@ -455,7 +450,7 @@ def search_claims( self.myparent.show_message(_("Error searching claims"), str(e)) return - result = responce.json() + result = response.json() if not result.get('entries'): self.myparent.show_message(_("Ooops"), _("Can't find any claim for ʹ%sʹ.") % textbuffer.text) @@ -480,7 +475,6 @@ def add_selected_claims(dialog): for k in values: if k[0][0] in current_data: - pass else: values_uniqe.append(k) diff --git a/jans-cli-tui/cli_tui/utils/static.py b/jans-cli-tui/cli_tui/utils/static.py index e331702ef8d..fc18c0ace9e 100755 --- a/jans-cli-tui/cli_tui/utils/static.py +++ b/jans-cli-tui/cli_tui/utils/static.py @@ -4,3 +4,10 @@ class DialogResult(Enum): CANCEL = 0 ACCEPT = 1 OK = 2 + +class CLI_STYLE: + edit_text = 'class:plugin-text' + edit_text_required = 'class:plugin-textrequired' + check_box = 'class:plugin-checkbox' + radio_button = 'class:plugin-radiobutton' + From 90fe169dc276a82db11a1ce0708fcb10798d16f1 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Mon, 2 Jan 2023 11:06:25 +0300 Subject: [PATCH 27/30] fix: jans-cli-tui code smells --- .../cli_tui/plugins/010_auth_server/edit_scope_dialog.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py index 97f37e9a912..c7cbc9dbf9f 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py @@ -30,7 +30,7 @@ from prompt_toolkit.layout.dimension import AnyDimension from cli import config_cli -from utils.static import DialogResult +from utils.static import DialogResult, CLI_STYLE from utils.utils import DialogUtils from utils.multi_lang import _ from wui_components.jans_dialog_with_nav import JansDialogWithNav @@ -41,8 +41,6 @@ from view_uma_dialog import ViewUMADialog - - class EditScopeDialog(JansGDialog, DialogUtils): """The Main Scope Dialog that contain every thing related to The Scope """ @@ -474,8 +472,7 @@ def add_selected_claims(dialog): values_uniqe = [] for k in values: - if k[0][0] in current_data: - else: + if k[0][0] not in current_data: values_uniqe.append(k) if not values_uniqe: From 456f6cf3eb4b44eeedef209161822005182eb829 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Mon, 2 Jan 2023 12:09:24 +0300 Subject: [PATCH 28/30] fix: jans-cli-tui code smells --- jans-cli-tui/cli_tui/cli_style.py | 5 +- jans-cli-tui/cli_tui/jans_cli_tui.py | 10 +-- .../010_auth_server/edit_client_dialog.py | 69 ++++++++++--------- .../cli_tui/plugins/010_auth_server/main.py | 67 +++++++++--------- .../plugins/010_auth_server/view_property.py | 53 +++++++------- .../010_auth_server/view_uma_dialog.py | 16 ++--- jans-cli-tui/cli_tui/utils/static.py | 10 ++- .../wui_components/jans_date_picker.py | 27 +++----- 8 files changed, 132 insertions(+), 125 deletions(-) diff --git a/jans-cli-tui/cli_tui/cli_style.py b/jans-cli-tui/cli_tui/cli_style.py index ad5309edc3d..2daa3d1e190 100755 --- a/jans-cli-tui/cli_tui/cli_style.py +++ b/jans-cli-tui/cli_tui/cli_style.py @@ -74,8 +74,9 @@ "plugin-radiobutton":"green", "plugin-dropdown":"green", "plugin-widget":"green", - - + "plugin-container":"", + "plugin-container.text":"green", + ## edit_client_dialog "outh-client-navbar":"#2600ff", "outh-client-navbar-headcolor":"green", diff --git a/jans-cli-tui/cli_tui/jans_cli_tui.py b/jans-cli-tui/cli_tui/jans_cli_tui.py index 78cb7914735..5ac14ab8027 100755 --- a/jans-cli-tui/cli_tui/jans_cli_tui.py +++ b/jans-cli-tui/cli_tui/jans_cli_tui.py @@ -299,7 +299,7 @@ async def coroutine(): await self.show_dialog_as_float(dialog) try: app.layout.focus(focused_before) - except: + except Exception: app.layout.focus(self.center_frame) self.start_progressing() @@ -373,7 +373,7 @@ async def coroutine(): result = await self.show_dialog_as_float(dialog) try: app.layout.focus(focused_before) - except: + except Exception: app.layout.focus(self.center_frame) self.create_cli() @@ -503,7 +503,7 @@ def mouse(self,event): ### mouse: [<35;108;20M if get_app().layout.container.floats: try : get_float_name = get_app().layout.container.floats[-1].name - except: + except Exception: get_float_name = '' if get_float_name =='mouse': @@ -534,7 +534,7 @@ def mouse(self,event): ### mouse: [<35;108;20M res.append("\n") res.append(HTML(style_tmp.format("Cut"))) res.append("\n") - res.append(HTML(style_tmp_red.format(style_tmp_red, "Paste"))) + res.append(HTML(style_tmp_red.format("Paste"))) res.append("\n") get_app().layout.container.floats[-1].content.content.text=merge_formatted_text(res) self.mouse_select = 'Paste' @@ -804,7 +804,7 @@ async def coroutine(): result = await self.show_dialog_as_float(dialog) try: self.layout.focus(focused_before) - except: + except Exception: self.layout.focus(self.center_frame) return result diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py index 9e3294f9677..713cec743ac 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py @@ -34,6 +34,7 @@ import json ERROR_GETTING_CLIENTS = _("Error getting clients") +ATTRIBUTE_SCHEMA_PATH = '#/components/schemas/ClientAttributes' class EditClientDialog(JansGDialog, DialogUtils): """The Main Client Dialog that contain every thing related to The Client @@ -45,7 +46,7 @@ def __init__( title: AnyFormattedText= "", buttons: Optional[Sequence[Button]]= [], save_handler: Callable= None, - delete_UMAresource: Callable= None, + delete_uma_resource: Callable= None, )-> Dialog: """init for `EditClientDialog`, inherits from two diffrent classes `JansGDialog` and `DialogUtils` @@ -58,11 +59,11 @@ def __init__( data (list): selected line data button_functions (list, optional): Dialog main buttons with their handlers. Defaults to []. save_handler (method, optional): handler invoked when closing the dialog. Defaults to None. - delete_UMAresource (method, optional): handler invoked when deleting UMA-resources + delete_uma_resource (method, optional): handler invoked when deleting UMA-resources """ super().__init__(parent, title, buttons) self.save_handler = save_handler - self.delete_UMAresource=delete_UMAresource + self.delete_uma_resource=delete_uma_resource self.data = data self.title=title self.myparent.logger.debug('self.data in init: '+str(self.data)) @@ -283,7 +284,7 @@ def prepare_tabs(self) -> None: name='redirectUrisRegex', value=self.data.get('attributes', {}).get('redirectUrisRegex',''), jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'redirectUrisRegex'), style=CLI_STYLE.check_box), @@ -295,7 +296,7 @@ def prepare_tabs(self) -> None: style=CLI_STYLE.check_box), ],width=D(), - style='class:outh-client-tabs' + style=CLI_STYLE.tabs ) self.tabs['Tokens'] = HSplit([ @@ -319,7 +320,7 @@ def prepare_tabs(self) -> None: name='runIntrospectionScriptBeforeJwtCreation', checked=self.data.get('attributes', {}).get('runIntrospectionScriptBeforeJwtCreation'), jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'runIntrospectionScriptBeforeJwtCreation'), style=CLI_STYLE.check_box), @@ -335,7 +336,7 @@ def prepare_tabs(self) -> None: name='additionalAudience', value='\n'.join(self.data.get('attributes', {}).get('additionalAudience',[])), jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'additionalAudience'), style=CLI_STYLE.check_box, height = 3), @@ -364,7 +365,7 @@ def prepare_tabs(self) -> None: text_type='integer', style=CLI_STYLE.check_box), - ],width=D(),style='class:outh-client-tabs') + ],width=D(),style=CLI_STYLE.tabs) self.tabs['Logout'] = HSplit([ @@ -387,7 +388,7 @@ def prepare_tabs(self) -> None: name='backchannelLogoutUri', value='\n'.join(self.data.get('attributes', {}).get('backchannelLogoutUri',[]) ), jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'backchannelLogoutUri'), height=3, style=CLI_STYLE.check_box ), @@ -397,7 +398,7 @@ def prepare_tabs(self) -> None: name='backchannelLogoutSessionRequired', checked=self.data.get('attributes', {}).get('backchannelLogoutSessionRequired'), jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'backchannelLogoutSessionRequired'), style=CLI_STYLE.check_box ), @@ -409,7 +410,7 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema(schema, 'frontChannelLogoutSessionRequired'),## No Descritption style=CLI_STYLE.check_box), - ],width=D(),style='class:outh-client-tabs' + ],width=D(),style=CLI_STYLE.tabs ) self.tabs['SoftwareInfo'] = HSplit([ @@ -449,7 +450,7 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema(schema, 'softwareStatement'), style=CLI_STYLE.check_box), - ],width=D(),style='class:outh-client-tabs') + ],width=D(),style=CLI_STYLE.tabs) self.uma_resources = HSplit([],width=D()) @@ -463,10 +464,10 @@ def prepare_tabs(self) -> None: width=D(), ), DynamicContainer(lambda: self.uma_resources) - ],style='class:outh-client-tabs') + ],style=CLI_STYLE.tabs) self.tabs['CIBA/PAR/UMA'] = HSplit([ - Label(text=_("CIBA"),style='class:outh-client-label'), + Label(text=_("CIBA"),style=CLI_STYLE.label), self.myparent.getTitledRadioButton( _("Token delivery method"), name='backchannelTokenDeliveryMode', @@ -491,14 +492,14 @@ def prepare_tabs(self) -> None: ), - Label(text=_("PAR"),style='class:outh-client-label'), + Label(text=_("PAR"),style=CLI_STYLE.label), self.myparent.getTitledText( title =_("Request lifetime"), name='parLifetime', value=self.data.get('attributes', {}).get('parLifetime',0), jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'parLifetime'), text_type='integer', style=CLI_STYLE.check_box), @@ -511,7 +512,7 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema(schema, 'requirePar'), ), - Label(_("UMA"), style='class:outh-client-label'), + Label(_("UMA"), style=CLI_STYLE.label), self.myparent.getTitledRadioButton( _("PRT token type"), @@ -541,7 +542,7 @@ def prepare_tabs(self) -> None: self.resources if self.data.get('inum','') else HSplit([],width=D()) - ],width=D(),style='class:outh-client-tabs' + ],width=D(),style=CLI_STYLE.tabs ) @@ -613,7 +614,7 @@ def allow_spontaneous_changed(cb): read_only=False if 'allowSpontaneousScopes' in self.data and self.data.get('attributes', {}).get('allowSpontaneousScopes') else True, focusable=True, jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'spontaneousScopeScriptDns'), height=3, style=CLI_STYLE.check_box) @@ -626,7 +627,7 @@ def allow_spontaneous_changed(cb): name='jansDefaultPromptLogin', checked=self.data.get('attributes', {}).get('jansDefaultPromptLogin'), jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'jansDefaultPromptLogin'), style=CLI_STYLE.check_box @@ -645,7 +646,7 @@ def allow_spontaneous_changed(cb): checked=self.data.get('attributes', {}).get('allowSpontaneousScopes'), on_selection_changed=allow_spontaneous_changed, jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'allowSpontaneousScopes'), style=CLI_STYLE.check_box ), @@ -654,7 +655,7 @@ def allow_spontaneous_changed(cb): VSplit([ - Label(text=_("Spontaneous scopes"),style='class:outh-client-label',width=len(_("Spontaneous scopes")*2)), ## TODO + Label(text=_("Spontaneous scopes"),style=CLI_STYLE.label,width=len(_("Spontaneous scopes")*2)), ## TODO Button( _("View current"), handler=self.show_client_scopes, @@ -690,7 +691,7 @@ def allow_spontaneous_changed(cb): value='\n'.join(self.data.get('attributes', {}).get('jansAuthorizedAcr',[])), height=3, jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'jansAuthorizedAcr'), style=CLI_STYLE.check_box), @@ -700,7 +701,7 @@ def allow_spontaneous_changed(cb): value='\n'.join(self.data.get('attributes', {}).get('tlsClientAuthSubjectDn',[])), height=3, style=CLI_STYLE.check_box, jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'tlsClientAuthSubjectDn'), ), @@ -714,7 +715,7 @@ def allow_spontaneous_changed(cb): style='class:outh-client-widget' ), - ],width=D(),style='class:outh-client-tabs' + ],width=D(),style=CLI_STYLE.tabs ) self.tabs['Client Scripts'] = HSplit([ @@ -725,7 +726,7 @@ def allow_spontaneous_changed(cb): value='\n'.join(self.data.get('attributes', {}).get('spontaneousScopes',[])), height=3, jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'spontaneousScopes'), style=CLI_STYLE.check_box), @@ -734,7 +735,7 @@ def allow_spontaneous_changed(cb): value='\n'.join(self.data.get('attributes', {}).get('updateTokenScriptDns',[])), height=3, jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'updateTokenScriptDns'), style=CLI_STYLE.check_box), @@ -743,7 +744,7 @@ def allow_spontaneous_changed(cb): value='\n'.join(self.data.get('attributes', {}).get('postAuthnScripts',[])), height=3, jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'postAuthnScripts'), style=CLI_STYLE.check_box), @@ -752,7 +753,7 @@ def allow_spontaneous_changed(cb): value='\n'.join(self.data.get('attributes', {}).get('introspectionScripts',[])), height=3, jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'introspectionScripts'), style=CLI_STYLE.check_box), @@ -762,7 +763,7 @@ def allow_spontaneous_changed(cb): height=3, style=CLI_STYLE.check_box, jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'ropcScripts'), ), @@ -771,10 +772,10 @@ def allow_spontaneous_changed(cb): value='\n'.join(self.data.get('attributes', {}).get('consentGatheringScripts',[]) ), height=3, jans_help=self.myparent.get_help_from_schema( - self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), + self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'consentGatheringScripts'), style=CLI_STYLE.check_box), - ],width=D(),style='class:outh-client-tabs' + ],width=D(),style=CLI_STYLE.tabs ) self.left_nav = list(self.tabs.keys())[0] @@ -928,7 +929,7 @@ def oauth_update_uma_resources ( data=data, on_enter=self.view_uma_resources, on_display=self.myparent.data_display_dialog, - on_delete=self.delete_UMAresource, + on_delete=self.delete_uma_resource, # selection_changed=self.data_selection_changed, selectes=0, headerColor='class:outh-client-navbar-headcolor', @@ -964,7 +965,7 @@ def view_uma_resources(self, **params: Any) -> None: selected_line_data = params['data'] ##self.uma_result title = _("Edit user Data (Clients)") - dialog = ViewUMADialog(self.myparent, title=title, data=selected_line_data, deleted_uma=self.delete_UMAresource) + dialog = ViewUMADialog(self.myparent, title=title, data=selected_line_data, deleted_uma=self.delete_uma_resource) self.myparent.show_jans_dialog(dialog) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py index 84fde741b2d..f08e86801d8 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py @@ -21,7 +21,7 @@ TextArea ) from prompt_toolkit.lexers import PygmentsLexer, DynamicLexer -from utils.static import DialogResult +from utils.static import DialogResult, CLI_STYLE, COMMON_STRINGS from utils.utils import DialogUtils from wui_components.jans_nav_bar import JansNavBar from wui_components.jans_vetrical_nav import JansVerticalNav @@ -34,6 +34,8 @@ from prompt_toolkit.application import Application from utils.multi_lang import _ +QUESTION_TEMP = "\n {} ?" + class Plugin(DialogUtils): """This is a general class for plugins """ @@ -78,7 +80,8 @@ async def get_appconfiguration(self) -> None: self.oauth_logging() def process(self): - pass + """No pre-processing for this plugin. + """ def set_center_frame(self) -> None: """center frame content @@ -102,7 +105,7 @@ def oauth_prepare_containers(self) -> None: self.oauth_containers['scopes'] = HSplit([ VSplit([ self.app.getButton(text=_("Get Scopes"), name='oauth:scopes:get', jans_help=_("Retreive first {} Scopes").format(self.app.entries_per_page), handler=self.oauth_get_scopes), - self.app.getTitledText(_("Search"), name='oauth:scopes:search', jans_help=_("Press enter to perform search"), accept_handler=self.search_scope,style='class:outh_containers_scopes.text'), + self.app.getTitledText(_("Search"), name='oauth:scopes:search', jans_help=_(COMMON_STRINGS.enter_to_search), accept_handler=self.search_scope,style='class:outh_containers_scopes.text'), self.app.getButton(text=_("Add Scope"), name='oauth:scopes:add', jans_help=_("To add a new scope press this button"), handler=self.add_scope), ], padding=3, @@ -114,7 +117,7 @@ def oauth_prepare_containers(self) -> None: self.oauth_containers['clients'] = HSplit([ VSplit([ self.app.getButton(text=_("Get Clients"), name='oauth:clients:get', jans_help=_("Retreive first {} OpenID Connect clients").format(self.app.entries_per_page), handler=self.oauth_update_clients), - self.app.getTitledText(_("Search"), name='oauth:clients:search', jans_help=_("Press enter to perform search"), accept_handler=self.search_clients,style='class:outh_containers_clients.text'), + self.app.getTitledText(_("Search"), name='oauth:clients:search', jans_help=_(COMMON_STRINGS.enter_to_search), accept_handler=self.search_clients,style='class:outh_containers_clients.text'), self.app.getButton(text=_("Add Client"), name='oauth:clients:add', jans_help=_("To add a new client press this button"), handler=self.add_client), ], @@ -122,7 +125,7 @@ def oauth_prepare_containers(self) -> None: width=D(), ), DynamicContainer(lambda: self.oauth_data_container['clients']) - ],style='class:outh_containers_clients') + ],style=CLI_STYLE.container) self.oauth_containers['keys'] = HSplit([ @@ -133,14 +136,14 @@ def oauth_prepare_containers(self) -> None: width=D(), ), DynamicContainer(lambda: self.oauth_data_container['keys']) - ], style='class:outh_containers_clients') + ], style=CLI_STYLE.container) self.oauth_containers['properties'] = HSplit([ VSplit([ self.app.getTitledText( _("Search"), name='oauth:properties:search', - jans_help=_("Press enter to perform search"), + jans_help=_(COMMON_STRINGS.enter_to_search), accept_handler=self.search_properties, style='class:outh_containers_scopes.text') ], @@ -157,7 +160,7 @@ def oauth_prepare_containers(self) -> None: DynamicContainer(lambda: self.oauth_main_area), ], height=D(), - style='class:outh_maincontainer' + style=CLI_STYLE.container ) def oauth_prepare_navbar(self) -> None: @@ -241,8 +244,8 @@ async def coroutine(): on_delete=self.delete_client, get_help=(self.get_help,'Client'), selectes=0, - headerColor='class:outh-verticalnav-headcolor', - entriesColor='class:outh-verticalnav-entriescolor', + headerColor=CLI_STYLE.navbar_headcolor, + entriesColor=CLI_STYLE.navbar_entriescolor, all_data=result['entries'] ) buttons = [] @@ -267,7 +270,7 @@ async def coroutine(): self.app.layout.focus(clients) ### it fix focuse on the last item deletion >> try on UMA-res >> edit_client_dialog >> oauth_update_uma_resources else: - self.app.show_message(_("Oops"), _("No matching result"),tobefocused = self.oauth_containers['clients']) + self.app.show_message(_("Oops"), _(COMMON_STRINGS.no_matching_result),tobefocused = self.oauth_containers['clients']) asyncio.ensure_future(coroutine()) @@ -282,14 +285,14 @@ def delete_client(self, **kwargs: Any) -> None: str: The server response """ - dialog = self.app.get_confirm_dialog(_("Are you sure want to delete client inum:")+"\n {} ?".format(kwargs ['selected'][0])) + dialog = self.app.get_confirm_dialog(_("Are you sure want to delete client inum:")+QUESTION_TEMP.format(kwargs ['selected'][0])) async def coroutine(): focused_before = self.app.layout.current_window result = await self.app.show_dialog_as_float(dialog) try: self.app.layout.focus(focused_before) - except: + except Exception: self.app.stop_progressing() self.app.layout.focus(self.app.center_frame) @@ -362,8 +365,8 @@ async def coroutine(): on_delete=self.delete_scope, get_help=(self.get_help,'Scope'), selectes=0, - headerColor='class:outh-verticalnav-headcolor', - entriesColor='class:outh-verticalnav-entriescolor', + headerColor=CLI_STYLE.navbar_headcolor, + entriesColor=CLI_STYLE.navbar_entriescolor, all_data=result['entries'] ) @@ -389,7 +392,7 @@ async def coroutine(): self.app.layout.focus(scopes) ### it fix focuse on the last item deletion >> try on UMA-res >> edit_client_dialog >> oauth_update_uma_resources else: - self.app.show_message(_("Oops"), _("No matching result"),tobefocused = self.oauth_containers['scopes']) + self.app.show_message(_("Oops"), _(COMMON_STRINGS.no_matching_result),tobefocused = self.oauth_containers['scopes']) asyncio.ensure_future(coroutine()) @@ -470,8 +473,8 @@ def oauth_update_properties( get_help=(self.get_help,'AppConfiguration'), # selection_changed=self.data_selection_changed, selectes=0, - headerColor='class:outh-verticalnav-headcolor', - entriesColor='class:outh-verticalnav-entriescolor', + headerColor=CLI_STYLE.navbar_headcolor, + entriesColor=CLI_STYLE.navbar_entriescolor, all_data=list(self.app_configuration.values()) ) @@ -483,7 +486,7 @@ def oauth_update_properties( if tofocus: self.app.layout.focus(properties) else: - self.app.show_message(_("Oops"), _("No matching result"),tobefocused = self.oauth_containers['properties']) + self.app.show_message(_("Oops"), _(COMMON_STRINGS.no_matching_result),tobefocused = self.oauth_containers['properties']) def properties_display_dialog(self, **params: Any) -> None: """Display the properties as Text @@ -557,8 +560,8 @@ def oauth_update_keys(self) -> None: preferred_size=[0,0], on_display=self.app.data_display_dialog, selectes=0, - headerColor='class:outh-verticalnav-headcolor', - entriesColor='class:outh-verticalnav-entriescolor', + headerColor=CLI_STYLE.navbar_headcolor, + entriesColor=CLI_STYLE.navbar_entriescolor, all_data=self.jwks_keys['keys'] ) @@ -597,7 +600,7 @@ def edit_client_dialog(self, **params: Any) -> None: selected_line_data = params['data'] title = _("Edit user Data (Clients)") - self.EditClientDialog = EditClientDialog(self.app, title=title, data=selected_line_data,save_handler=self.save_client,delete_UMAresource=self.delete_UMAresource) + self.EditClientDialog = EditClientDialog(self.app, title=title, data=selected_line_data, save_handler=self.save_client, delete_uma_resource=self.delete_uma_resource) self.app.show_jans_dialog(self.EditClientDialog) def save_client(self, dialog: Dialog) -> None: @@ -706,13 +709,13 @@ def delete_scope(self, **kwargs: Any): str: The server response """ - dialog = self.app.get_confirm_dialog(_("Are you sure want to delete scope inum:")+"\n {} ?".format(kwargs ['selected'][3])) + dialog = self.app.get_confirm_dialog(_("Are you sure want to delete scope inum:")+QUESTION_TEMP.format(kwargs ['selected'][3])) async def coroutine(): focused_before = self.app.layout.current_window result = await self.app.show_dialog_as_float(dialog) try: self.app.layout.focus(focused_before) - except: + except Exception: self.app.layout.focus(self.app.center_frame) if result.lower() == 'yes': @@ -734,13 +737,13 @@ def delete_UMAresource(self, **kwargs: Any): Returns: str: The server response """ - dialog = self.app.get_confirm_dialog(_("Are you sure want to delete UMA resoucres with id:")+"\n {} ?".format(kwargs ['selected'][0])) + dialog = self.app.get_confirm_dialog(_("Are you sure want to delete UMA resoucres with id:")+QUESTION_TEMP.format(kwargs ['selected'][0])) async def coroutine(): focused_before = self.app.layout.current_window result = await self.app.show_dialog_as_float(dialog) try: self.app.layout.focus(focused_before) - except: + except Exception: self.app.layout.focus(self.EditClientDialog) if result.lower() == 'yes': @@ -784,28 +787,28 @@ def oauth_logging(self) -> None: name='httpLoggingEnabled', checked=self.app_configuration.get('httpLoggingEnabled'), jans_help=self.app.get_help_from_schema(self.schema, 'httpLoggingEnabled'), - style='class:outh-client-checkbox' + style=CLI_STYLE.check_box ), self.app.getTitledCheckBox( _("Disable JDK Logger"), name='disableJdkLogger', checked=self.app_configuration.get('disableJdkLogger'), jans_help=self.app.get_help_from_schema(self.schema, 'disableJdkLogger'), - style='class:outh-client-checkbox' + style=CLI_STYLE.check_box ), self.app.getTitledCheckBox( _("Enable Oauth Audit Logging"), name='enabledOAuthAuditLogging', checked=self.app_configuration.get('enabledOAuthAuditLogging'), jans_help=self.app.get_help_from_schema(self.schema, 'enabledOAuthAuditLogging'), - style='class:outh-client-checkbox' + style=CLI_STYLE.check_box ), Window(height=1), HSplit([ self.app.getButton(text=_("Save Logging"), name='oauth:logging:save', jans_help=_("Save Auth Server logging configuration"), handler=self.save_logging), Window(width=100), ]) - ], style='class:outh_containers_clients', width=D()) + ], style=CLI_STYLE.container, width=D()) def save_logging(self) -> None: """This method to Save the Auth Login to server @@ -831,10 +834,10 @@ def save_logging(self) -> None: dialog = JansGDialog(self.app, title=_("Confirmation"), body=body, buttons=buttons) async def coroutine(): focused_before = self.app.layout.current_window - result = await self.app.show_dialog_as_float(dialog) + await self.app.show_dialog_as_float(dialog) try: self.app.layout.focus(focused_before) - except: + except Exception: self.app.layout.focus(self.app.center_frame) asyncio.ensure_future(coroutine()) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/view_property.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_property.py index a9f35d83d0f..5ad23fc2cee 100644 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/view_property.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_property.py @@ -11,7 +11,7 @@ RadioList, Dialog, ) -from utils.static import DialogResult +from utils.static import DialogResult, CLI_STYLE from utils.utils import DialogUtils from wui_components.jans_cli_dialog import JansGDialog from typing import Optional, Sequence @@ -151,7 +151,7 @@ def get_type(self,prop): prop_type= 'list-list' else: prop_type= 'long-TitledText' - except: + except Exception: prop_type = None return prop_type @@ -172,7 +172,7 @@ def get_listValues(self,prop,type=None): else: list_values= self.schema.get('properties', {})[prop]['items']['items']['enum'] - except: + except Exception: list_values = [] return list_values @@ -181,6 +181,7 @@ def prepare_properties(self): """This method build the main value_content to edit the properties """ + tab_temp = 'tab{}' prop_type = self.get_type(self.property) if prop_type == 'TitledText': @@ -188,7 +189,7 @@ def prepare_properties(self): self.property, name=self.property, value=self.value, - style='class:outh-scope-text' + style=CLI_STYLE.edit_text ), ],width=D()) @@ -198,7 +199,7 @@ def prepare_properties(self): name=self.property, value=self.value, text_type='integer', - style='class:outh-scope-text' + style=CLI_STYLE.edit_text ), ],width=D()) @@ -208,9 +209,9 @@ def prepare_properties(self): name=self.property, height=3, value='\n'.join(self.value), - style='class:outh-scope-text' + style=CLI_STYLE.edit_text ), - ],width=D()) + ],width=D()) elif prop_type == 'list-list': self.value_content= HSplit([ @@ -219,7 +220,7 @@ def prepare_properties(self): name=self.property, values=self.get_listValues(self.property,'nasted'), style='class:outh-client-checkboxlist'), - ],width=D()) + ],width=D()) elif prop_type == 'checkboxlist': self.value_content= HSplit([ @@ -228,14 +229,14 @@ def prepare_properties(self): name=self.property, values=self.get_listValues(self.property), style='class:outh-client-checkboxlist'), - ],width=D()) + ],width=D()) - elif prop_type == 'list-dict': + elif prop_type == 'list-dict': tab_num = len(self.value) tabs = [] for i in range(tab_num) : - tabs.append(('tab{}'.format(i),'tab{}'.format(i))) - + tabs.append((tab_temp.format(i), tab_temp.format(i))) + for tab in self.value: tab_list=[] @@ -245,7 +246,7 @@ def prepare_properties(self): item , name=item, value=tab[item], - style='class:outh-scope-text' + style=CLI_STYLE.edit_text ), ],width=D())) @@ -255,7 +256,7 @@ def prepare_properties(self): name=item, value=tab[item], text_type='integer', - style='class:outh-scope-text' + style=CLI_STYLE.edit_text ), ],width=D())) @@ -265,20 +266,20 @@ def prepare_properties(self): name=item, height=3, value='\n'.join(tab[item]), - style='class:outh-scope-text' + style=CLI_STYLE.edit_text ), ],width=D())) elif type(tab[item]) == bool: tab_list.append(HSplit([ self.app.getTitledCheckBox( - item, - name=item, - checked= tab[item], - style='class:outh-client-checkbox'), + item, + name=item, + checked= tab[item], + style=CLI_STYLE.checkbox), ],width=D())) - self.tabs['tab{}'.format(self.value.index(tab))] = HSplit(tab_list,width=D()) + self.tabs[tab_temp.format(self.value.index(tab))] = HSplit(tab_list,width=D()) self.value_content=HSplit([ self.app.getTitledRadioButton( @@ -299,7 +300,7 @@ def prepare_properties(self): self.property, name=self.property, checked= self.value, - style='class:outh-client-checkbox'), + style=CLI_STYLE.checkbox), ],width=D()) elif prop_type == 'dict': @@ -310,7 +311,7 @@ def prepare_properties(self): item , name=item, value=self.value[item], - style='class:outh-scope-text' + style=CLI_STYLE.edit_text ), ],width=D())) @@ -320,7 +321,7 @@ def prepare_properties(self): name=item, value=self.value[item], text_type='integer', - style='class:outh-scope-text' + style=CLI_STYLE.edit_text ), ],width=D())) @@ -330,7 +331,7 @@ def prepare_properties(self): name=item, height=3, value='\n'.join(self.value[item]), - style='class:outh-scope-text' + style=CLI_STYLE.edit_text ), ],width=D())) @@ -340,7 +341,7 @@ def prepare_properties(self): item, name=item, checked= self.value[item], - style='class:outh-client-checkbox'), + style=CLI_STYLE.checkbox), ],width=D())) else : @@ -348,7 +349,7 @@ def prepare_properties(self): item, name=item, value="No Items Here", - style='class:outh-scope-text', + style=CLI_STYLE.edit_text, read_only=True, ), ],width=D())) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/view_uma_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_uma_dialog.py index d6c551df023..71cbc1b9c20 100644 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/view_uma_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_uma_dialog.py @@ -17,7 +17,7 @@ import cli_style from utils.multi_lang import _ from utils.utils import DialogUtils -from utils.static import DialogResult +from utils.static import DialogResult, CLI_STYLE from wui_components.jans_nav_bar import JansNavBar from wui_components.jans_cli_dialog import JansGDialog @@ -80,7 +80,7 @@ def cancel() -> None: name='id', value=self.data.get('id',''), read_only=True, - style='class:outh-uma-text', + style=CLI_STYLE.edit_text, ), self.myparent.getTitledText( @@ -88,14 +88,14 @@ def cancel() -> None: name='name', value=self.data.get('name',''), read_only=True, - style='class:outh-uma-text'), + style=CLI_STYLE.edit_text), self.myparent.getTitledText( _("IconURL"), name='iconUri', value=self.data.get('iconUri',''), read_only=True, - style='class:outh-uma-text'), + style=CLI_STYLE.edit_text), VSplit([ @@ -112,14 +112,14 @@ def cancel() -> None: name='clients', value=self.data.get('clients',''), read_only=True, - style='class:outh-uma-text'), + style=CLI_STYLE.edit_text), self.myparent.getTitledText( _("Creation time"), name='creationDate', value=self.data.get('creationDate',''), read_only=True, - style='class:outh-uma-text'), + style=CLI_STYLE.edit_text), ], padding=1,width=100,style='class:outh-uma-tabs' # key_bindings=self.get_uma_dialog_key_bindings() @@ -147,7 +147,7 @@ def UMA_prepare_containers(self) -> None: name='scopes', value='\n'.join(self.data.get('scopes',[])), read_only=True, - style='class:outh-uma-text', + style=CLI_STYLE.edit_text, height=3, ) ],width=D()) @@ -158,7 +158,7 @@ def UMA_prepare_containers(self) -> None: name='scopeExpression', value='\n'.join(self.data.get('scopeExpression',[])), read_only=True, - style='class:outh-uma-text', + style=CLI_STYLE.edit_text, height=3, ), ],width=D()) diff --git a/jans-cli-tui/cli_tui/utils/static.py b/jans-cli-tui/cli_tui/utils/static.py index fc18c0ace9e..e1c6de4d8bc 100755 --- a/jans-cli-tui/cli_tui/utils/static.py +++ b/jans-cli-tui/cli_tui/utils/static.py @@ -10,4 +10,12 @@ class CLI_STYLE: edit_text_required = 'class:plugin-textrequired' check_box = 'class:plugin-checkbox' radio_button = 'class:plugin-radiobutton' - + tabs = 'class:plugin-tabs' + label = 'class:plugin-label' + container = 'class:plugin-container' + navbar_headcolor = "class:plugin-navbar-headcolor" + navbar_entriescolor = "class:plugin-navbar-entriescolor" + +class COMMON_STRINGS: + enter_to_search = "Press enter to perform search" + no_matching_result = "No matching result" diff --git a/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py b/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py index aa11053984e..5680206f952 100755 --- a/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py +++ b/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py @@ -24,6 +24,8 @@ import datetime import cli_style +DATE_TIME_TEMP = '%Y-%m-%dT%H:%M:%S' + class JansSelectDate: """_summary_ """ @@ -86,7 +88,6 @@ def __init__( ), height=5, cursorline=False, - # width=D(), #15, style="class:date-picker-day", ### days window style right_margins=[ScrollbarMargin(display_arrows=True),], wrap_lines=True, @@ -99,7 +100,6 @@ def __init__( ), height=2, cursorline=False, - # width=D(), #15, style="class:date-picker-time", ### time window style right_margins=[ScrollbarMargin(display_arrows=True),], wrap_lines=True @@ -167,7 +167,7 @@ def extract_date( try : day_index = week.index(day) break - except: + except Exception: day_index = 0 week_index = self.entries.index(dum_week) self.cord_y = week_index @@ -279,7 +279,6 @@ def up(self)-> None: self.dec_month(day=1) else: self.cord_y = (self.cord_y - 1)# % 5 - #self.depug=Label(text="entries = "+str(self.entries[self.cord_y][self.cord_x])+':',) self.selected_cord = (self.cord_x, self.cord_y) else: self.adjust_time(1) @@ -290,7 +289,6 @@ def down(self)-> None: self.inc_month(day=28) else: self.cord_y = (self.cord_y + 1)# % 5 - #self.depug=Label(text="entries = "+str(self.entries[self.cord_y][self.cord_x])+':',) self.selected_cord = (self.cord_x, self.cord_y) else: self.adjust_time(-1) @@ -303,9 +301,7 @@ def right(self)-> None: self.cord_x = (self.cord_x + 1) #% 7 self.selected_cord = (self.cord_x, self.cord_y) else: - if self.cord_x >= 2 : - pass - else : + if not self.cord_x >= 2 : self.cord_x = (self.cord_x + 1) #% 7 def left(self)-> None: @@ -318,9 +314,7 @@ def left(self)-> None: self.selected_cord = (self.cord_x, self.cord_y) self.date_changed = True else: - if self.cord_x <=0 : - pass - else : + if not self.cord_x <=0 : self.cord_x = (self.cord_x - 1) #% 7 def next(self)-> None: @@ -356,7 +350,7 @@ def __init__( if value: self.text = value - ts = time.strptime(value[:19], "%Y-%m-%dT%H:%M:%S") # "2023-11-27" + ts = time.strptime(value[:19], DATE_TIME_TEMP) # "2023-11-27" self.date = time.strftime("%m/%d/%Y", ts) # "11/27/2023" self.hours = int(time.strftime("%H",ts)) self.minuts =int(time.strftime("%M",ts)) @@ -398,8 +392,7 @@ def value( self, value:str, )-> None: - #passed_value = self.value - self._value = self.value + self._value = self.value def make_time( self, @@ -410,7 +403,7 @@ def make_time( Args: text (str): the text that appear on the wigdet """ - ts = time.strptime(text[:19], "%Y-%m-%dT%H:%M:%S") # "2023-11-27" + ts = time.strptime(text[:19], DATE_TIME_TEMP) # "2023-11-27" years =int(time.strftime("%Y",ts)) months = int(time.strftime("%m",ts)) days = int(time.strftime("%d",ts)) @@ -420,7 +413,7 @@ def make_time( t = (years, months,days,self.hours,self.minuts,self.seconds,0,0,0) ## the up increment t = time.mktime(t) - self.text= (time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(t))) + self.text= (time.strftime(DATE_TIME_TEMP, time.gmtime(t))) def _get_text(self)-> AnyFormattedText: """To get The selected value @@ -459,7 +452,7 @@ def _enter(event) -> None: t = (years, months,days,(self.select_box.hours-8),self.select_box.minuts,self.select_box.seconds,0,0,0) ## the up increment t = time.mktime(t) - self.text= (time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(t))) + self.text= (time.strftime(DATE_TIME_TEMP, time.gmtime(t))) get_app().layout.container.floats.remove(self.select_box_float) @kb.add("up") From 76f24535a4ca8d23d0445093141777f2de5ac504 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Mon, 2 Jan 2023 14:17:27 +0300 Subject: [PATCH 29/30] fix: jans-cli-tui code smells --- .../010_auth_server/edit_client_dialog.py | 136 +++++++++--------- .../010_auth_server/edit_scope_dialog.py | 41 +++--- .../cli_tui/plugins/010_auth_server/main.py | 53 ++++--- .../plugins/010_auth_server/view_property.py | 28 ++-- .../010_auth_server/view_uma_dialog.py | 20 +-- jans-cli-tui/cli_tui/utils/static.py | 4 +- .../wui_components/jans_date_picker.py | 30 ++-- 7 files changed, 151 insertions(+), 161 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py index 713cec743ac..402dd3fb459 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py @@ -15,7 +15,7 @@ from prompt_toolkit.lexers import PygmentsLexer, DynamicLexer from prompt_toolkit.application.current import get_app from asyncio import Future, ensure_future -from utils.static import DialogResult, CLI_STYLE +from utils.static import DialogResult, cli_style from utils.multi_lang import _ from wui_components.jans_dialog_with_nav import JansDialogWithNav from wui_components.jans_side_nav_bar import JansSideNavBar @@ -186,35 +186,35 @@ def prepare_tabs(self) -> None: value=self.data.get('inum',''), jans_help=self.myparent.get_help_from_schema(schema, 'inum'), read_only=True, - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), self.myparent.getTitledCheckBox( _("Active"), name='disabled', checked= not self.data.get('disabled'), jans_help=self.myparent.get_help_from_schema(schema, 'disabled'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( _("Client Name"), name='clientName', value=self.data.get('clientName',''), jans_help=self.myparent.get_help_from_schema(schema, 'clientName'), - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), self.myparent.getTitledText( _("Client Secret"), name='clientSecret', value=self.data.get('clientSecret',''), jans_help=self.myparent.get_help_from_schema(schema, 'clientSecret'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( _("Description"), name='description', value=self.data.get('description',''), jans_help=self.myparent.get_help_from_schema(schema, 'description'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledRadioButton( _("Authn Method token endpoint"), @@ -222,7 +222,7 @@ def prepare_tabs(self) -> None: values=[('none', 'none'), ('client_secret_basic', 'client_secret_basic'), ('client_secret_post', 'client_secret_post'), ('client_secret_jwt', 'client_secret_jwt'), ('private_key_jwt', 'private_key_jwt')], current_value=self.data.get('tokenEndpointAuthMethod'), jans_help=self.myparent.get_help_from_schema(schema, 'tokenEndpointAuthMethod'), - style=CLI_STYLE.radio_button), + style=cli_style.radio_button), self.myparent.getTitledRadioButton( _("Subject Type"), @@ -230,14 +230,14 @@ def prepare_tabs(self) -> None: values=[('public', 'Public'),('pairwise', 'Pairwise')], current_value=self.data.get('subjectType'), jans_help=self.myparent.get_help_from_schema(schema, 'subjectType'), - style=CLI_STYLE.radio_button), + style=cli_style.radio_button), self.myparent.getTitledText( _("Sector Identifier URI"), name='sectorIdentifierUri', value=self.data.get('sectorIdentifierUri',''), jans_help=self.myparent.get_help_from_schema(schema, 'sectorIdentifierUri'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledCheckBoxList( _("Grant"), @@ -261,7 +261,7 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/AppConfiguration'), 'tokenEndpointAuthMethodsSupported'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledRadioButton( _("Application Type"), @@ -269,7 +269,7 @@ def prepare_tabs(self) -> None: values=['native','web'], current_value=self.data.get('applicationType'), jans_help=self.myparent.get_help_from_schema(schema, 'applicationType'), - style=CLI_STYLE.radio_button), + style=cli_style.radio_button), self.myparent.getTitledText( _("Redirect Uris"), @@ -286,17 +286,17 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'redirectUrisRegex'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText(_("Scopes"), name='scopes', value='\n'.join(self.data.get('scopes', [])), height=3, jans_help=self.myparent.get_help_from_schema(schema, 'scopes'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), ],width=D(), - style=CLI_STYLE.tabs + style=cli_style.tabs ) self.tabs['Tokens'] = HSplit([ @@ -306,14 +306,14 @@ def prepare_tabs(self) -> None: values=[('jwt', 'JWT'), ('reference', 'Reference')], current_value= 'jwt' if self.data.get('accessTokenAsJwt') else 'reference', jans_help=self.myparent.get_help_from_schema(schema, 'accessTokenAsJwt'), - style=CLI_STYLE.radio_button), + style=cli_style.radio_button), self.myparent.getTitledCheckBox( _("Include Claims in id_token"), name='includeClaimsInIdToken', checked=self.data.get('includeClaimsInIdToken'), jans_help=self.myparent.get_help_from_schema(schema, 'includeClaimsInIdToken'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledCheckBox( _("Run introspection script before JWT access token creation"), @@ -322,14 +322,14 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'runIntrospectionScriptBeforeJwtCreation'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( title=_("Token binding confirmation method for id_token"), name='idTokenTokenBindingCnf', value=self.data.get('idTokenTokenBindingCnf',''), jans_help=self.myparent.get_help_from_schema(schema, 'idTokenTokenBindingCnf'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( title=_("Access token additional audiences"), @@ -338,7 +338,7 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'additionalAudience'), - style=CLI_STYLE.check_box, + style=cli_style.check_box, height = 3), self.myparent.getTitledText( @@ -347,7 +347,7 @@ def prepare_tabs(self) -> None: value=self.data.get('accessTokenLifetime',''), jans_help=self.myparent.get_help_from_schema(schema, 'accessTokenLifetime'), text_type='integer', - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( _("Refresh token lifetime"), @@ -355,7 +355,7 @@ def prepare_tabs(self) -> None: value=self.data.get('refreshTokenLifetime',''), jans_help=self.myparent.get_help_from_schema(schema, 'refreshTokenLifetime'), text_type='integer', - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( _("Defult max authn age"), @@ -363,9 +363,9 @@ def prepare_tabs(self) -> None: value=self.data.get('defaultMaxAge',''), jans_help=self.myparent.get_help_from_schema(schema, 'defaultMaxAge'), text_type='integer', - style=CLI_STYLE.check_box), + style=cli_style.check_box), - ],width=D(),style=CLI_STYLE.tabs) + ],width=D(),style=cli_style.tabs) self.tabs['Logout'] = HSplit([ @@ -374,14 +374,14 @@ def prepare_tabs(self) -> None: name='frontChannelLogoutUri', value=self.data.get('frontChannelLogoutUri',''), jans_help=self.myparent.get_help_from_schema(schema, 'frontChannelLogoutUri'), ## No Descritption - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( _("Post logout redirect URIs"), name='postLogoutRedirectUris', value='\n'.join(self.data.get('postLogoutRedirectUris',[])), jans_help=self.myparent.get_help_from_schema(schema, 'postLogoutRedirectUris'), - height=3, style=CLI_STYLE.check_box), + height=3, style=cli_style.check_box), self.myparent.getTitledText( _("Back channel logout URI"), @@ -390,7 +390,7 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'backchannelLogoutUri'), - height=3, style=CLI_STYLE.check_box + height=3, style=cli_style.check_box ), self.myparent.getTitledCheckBox( @@ -400,7 +400,7 @@ def prepare_tabs(self) -> None: jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'backchannelLogoutSessionRequired'), - style=CLI_STYLE.check_box + style=cli_style.check_box ), self.myparent.getTitledCheckBox( @@ -408,9 +408,9 @@ def prepare_tabs(self) -> None: name='frontChannelLogoutSessionRequired', checked=self.data.get('frontChannelLogoutSessionRequired'), jans_help=self.myparent.get_help_from_schema(schema, 'frontChannelLogoutSessionRequired'),## No Descritption - style=CLI_STYLE.check_box), + style=cli_style.check_box), - ],width=D(),style=CLI_STYLE.tabs + ],width=D(),style=cli_style.tabs ) self.tabs['SoftwareInfo'] = HSplit([ @@ -420,37 +420,37 @@ def prepare_tabs(self) -> None: value='\n'.join(self.data.get('contacts', [])), height=3, jans_help=self.myparent.get_help_from_schema(schema, 'contacts'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText(_("Authorized JS origins"), ### height =3 insted of the <+> button name='authorizedOrigins', value='\n'.join(self.data.get('authorizedOrigins', [])), height=3, jans_help=self.myparent.get_help_from_schema(schema, 'authorizedOrigins'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( title =_("Software id"), name='softwareId', value=self.data.get('softwareId',''), jans_help=self.myparent.get_help_from_schema(schema, 'softwareId'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( title =_("Software version"), name='softwareVersion', value=self.data.get('softwareVersion',''), jans_help=self.myparent.get_help_from_schema(schema, 'softwareVersion'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( title =_("Software statement"), name='softwareStatement', value=self.data.get('softwareStatement',''), jans_help=self.myparent.get_help_from_schema(schema, 'softwareStatement'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), - ],width=D(),style=CLI_STYLE.tabs) + ],width=D(),style=cli_style.tabs) self.uma_resources = HSplit([],width=D()) @@ -464,35 +464,35 @@ def prepare_tabs(self) -> None: width=D(), ), DynamicContainer(lambda: self.uma_resources) - ],style=CLI_STYLE.tabs) + ],style=cli_style.tabs) self.tabs['CIBA/PAR/UMA'] = HSplit([ - Label(text=_("CIBA"),style=CLI_STYLE.label), + Label(text=_("CIBA"),style=cli_style.label), self.myparent.getTitledRadioButton( _("Token delivery method"), name='backchannelTokenDeliveryMode', current_value=self.data.get('backchannelTokenDeliveryMode'), values=['poll','push', 'ping'], jans_help=self.myparent.get_help_from_schema(schema, 'backchannelTokenDeliveryMode'), - style=CLI_STYLE.radio_button), + style=cli_style.radio_button), self.myparent.getTitledText( title =_("Client notification endpoint"), name='backchannelClientNotificationEndpoint', value=self.data.get('backchannelClientNotificationEndpoint',''), jans_help=self.myparent.get_help_from_schema(schema, 'backchannelClientNotificationEndpoint'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledCheckBox( _("Require user code param"), name='backchannelUserCodeParameter', checked=self.data.get('backchannelUserCodeParameter', ''), - style=CLI_STYLE.check_box, + style=cli_style.check_box, jans_help=self.myparent.get_help_from_schema(schema, 'backchannelUserCodeParameter'), ), - Label(text=_("PAR"),style=CLI_STYLE.label), + Label(text=_("PAR"),style=cli_style.label), self.myparent.getTitledText( title =_("Request lifetime"), @@ -502,17 +502,17 @@ def prepare_tabs(self) -> None: self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'parLifetime'), text_type='integer', - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledCheckBox( _("Request PAR"), name='requirePar', checked=self.data.get('attributes', {}).get('requirePar',''), - style=CLI_STYLE.check_box, + style=cli_style.check_box, jans_help=self.myparent.get_help_from_schema(schema, 'requirePar'), ), - Label(_("UMA"), style=CLI_STYLE.label), + Label(_("UMA"), style=cli_style.label), self.myparent.getTitledRadioButton( _("PRT token type"), @@ -520,7 +520,7 @@ def prepare_tabs(self) -> None: values=[('jwt', 'JWT'), ('reference', 'Reference')], current_value='jwt' if self.data.get('rptAsJwt') else 'reference', jans_help=self.myparent.get_help_from_schema(schema, 'rptAsJwt'), - style=CLI_STYLE.radio_button), + style=cli_style.radio_button), self.myparent.getTitledText( title =_("Claims redirect URI"), @@ -528,13 +528,13 @@ def prepare_tabs(self) -> None: value='\n'.join(self.data.get('claimRedirectUris','')), jans_help=self.myparent.get_help_from_schema(schema, 'claimRedirectUris'), height=3, - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText(_("RPT Modification Script"), name='rptClaimsScripts', value='\n'.join(self.data.get('attributes', {}).get('rptClaimsScripts',[]) ), height=3, - style=CLI_STYLE.check_box, + style=cli_style.check_box, jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/Scope'), 'rptClaimsScripts'), @@ -542,7 +542,7 @@ def prepare_tabs(self) -> None: self.resources if self.data.get('inum','') else HSplit([],width=D()) - ],width=D(),style=CLI_STYLE.tabs + ],width=D(),style=cli_style.tabs ) @@ -552,14 +552,14 @@ def prepare_tabs(self) -> None: name='jwksUri', value=self.data.get('jwksUri',''), jans_help=self.myparent.get_help_from_schema(schema, 'jwksUri'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( title =_("Client JWKS"), name='jwks', value=self.data.get('jwks',''), jans_help=self.myparent.get_help_from_schema(schema, 'jwks'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), ] @@ -617,7 +617,7 @@ def allow_spontaneous_changed(cb): self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'spontaneousScopeScriptDns'), height=3, - style=CLI_STYLE.check_box) + style=cli_style.check_box) self.tabs['Advanced Client Properties'] = HSplit([ @@ -630,7 +630,7 @@ def allow_spontaneous_changed(cb): self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'jansDefaultPromptLogin'), - style=CLI_STYLE.check_box + style=cli_style.check_box ), self.myparent.getTitledCheckBox( @@ -638,7 +638,7 @@ def allow_spontaneous_changed(cb): name='persistClientAuthorizations', checked=self.data.get('persistClientAuthorizations'), jans_help=self.myparent.get_help_from_schema(schema, 'persistClientAuthorizations'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledCheckBox( _("Allow spontaneos scopes"), @@ -648,14 +648,14 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'allowSpontaneousScopes'), - style=CLI_STYLE.check_box + style=cli_style.check_box ), self.spontaneous_scopes, VSplit([ - Label(text=_("Spontaneous scopes"),style=CLI_STYLE.label,width=len(_("Spontaneous scopes")*2)), ## TODO + Label(text=_("Spontaneous scopes"),style=cli_style.label,width=len(_("Spontaneous scopes")*2)), ## TODO Button( _("View current"), handler=self.show_client_scopes, @@ -670,21 +670,21 @@ def allow_spontaneous_changed(cb): name='initiateLoginUri', value=self.data.get('initiateLoginUri',''), jans_help=self.myparent.get_help_from_schema(schema, 'initiateLoginUri'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText(_("Request URIs"), ### height =3 insted of the <+> button name='requestUris', value='\n'.join(self.data.get('requestUris', [])), height=3, jans_help=self.myparent.get_help_from_schema(schema, 'requestUris'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText(_("Default ACR"), ### height =3 >> "the type is array" cant be dropdown name='defaultAcrValues', value='\n'.join(self.data.get('defaultAcrValues', [])), height=3, jans_help=self.myparent.get_help_from_schema(schema, 'defaultAcrValues'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText(_("Allowed ACR"), ### height =3 insted of the <+> button name='jansAuthorizedAcr', @@ -693,13 +693,13 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'jansAuthorizedAcr'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText( _("TLS Subject DN"), name='tlsClientAuthSubjectDn', value='\n'.join(self.data.get('attributes', {}).get('tlsClientAuthSubjectDn',[])), - height=3, style=CLI_STYLE.check_box, + height=3, style=cli_style.check_box, jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'tlsClientAuthSubjectDn'), @@ -715,7 +715,7 @@ def allow_spontaneous_changed(cb): style='class:outh-client-widget' ), - ],width=D(),style=CLI_STYLE.tabs + ],width=D(),style=cli_style.tabs ) self.tabs['Client Scripts'] = HSplit([ @@ -728,7 +728,7 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'spontaneousScopes'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText(_("Update Token"), name='updateTokenScriptDns', @@ -737,7 +737,7 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'updateTokenScriptDns'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText(_("Post Authn"), name='postAuthnScripts', @@ -746,7 +746,7 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'postAuthnScripts'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText(_("Introspection"), name='introspectionScripts', @@ -755,13 +755,13 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'introspectionScripts'), - style=CLI_STYLE.check_box), + style=cli_style.check_box), self.myparent.getTitledText(_("Password Grant"), name='ropcScripts', value='\n'.join(self.data.get('attributes', {}).get('ropcScripts',[])), height=3, - style=CLI_STYLE.check_box, + style=cli_style.check_box, jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'ropcScripts'), @@ -774,8 +774,8 @@ def allow_spontaneous_changed(cb): jans_help=self.myparent.get_help_from_schema( self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH), 'consentGatheringScripts'), - style=CLI_STYLE.check_box), - ],width=D(),style=CLI_STYLE.tabs + style=cli_style.check_box), + ],width=D(),style=cli_style.tabs ) self.left_nav = list(self.tabs.keys())[0] diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py index c7cbc9dbf9f..d059b823573 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py @@ -30,7 +30,7 @@ from prompt_toolkit.layout.dimension import AnyDimension from cli import config_cli -from utils.static import DialogResult, CLI_STYLE +from utils.static import DialogResult, cli_style from utils.utils import DialogUtils from utils.multi_lang import _ from wui_components.jans_dialog_with_nav import JansDialogWithNav @@ -141,21 +141,21 @@ def create_window(self) -> None: values=scope_types, on_selection_changed=self.scope_selection_changed, jans_help=self.myparent.get_help_from_schema(self.schema, 'scopeType'), - style=CLI_STYLE.radio_button), + style=cli_style.radio_button), self.myparent.getTitledText( _("id"), name='id', value=self.data.get('id',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'id'), - style=CLI_STYLE.edit_text_required), + style=cli_style.edit_text_required), self.myparent.getTitledText( _("inum"), name='inum', value=self.data.get('inum',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'inum'), - style=CLI_STYLE.edit_text, + style=cli_style.edit_text, read_only=True,), self.myparent.getTitledText( @@ -163,14 +163,14 @@ def create_window(self) -> None: name='displayName', value=self.data.get('displayName',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'displayName'), - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), self.myparent.getTitledText( _("Description"), name='description', value=self.data.get('description',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'description'), - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), DynamicContainer(lambda: self.alt_tabs[self.sope_type]), ], style='class:outh-scope-tabs'), @@ -269,7 +269,7 @@ def prepare_tabs(self) -> None: name='defaultScope', checked=self.data.get('defaultScope'), jans_help=self.myparent.get_help_from_schema(self.schema, 'defaultScope'), - style=CLI_STYLE.check_box, + style=cli_style.check_box, ), self.myparent.getTitledCheckBox( @@ -277,7 +277,7 @@ def prepare_tabs(self) -> None: name='showInConfigurationEndpoint', checked=self.data.get('attributes',{}).get('showInConfigurationEndpoint',''), jans_help='Configuration Endpoint', - style=CLI_STYLE.check_box, + style=cli_style.check_box, ), ],width=D(),) @@ -289,7 +289,7 @@ def prepare_tabs(self) -> None: name='defaultScope', checked=self.data.get('defaultScope'), jans_help=self.myparent.get_help_from_schema(self.schema, 'defaultScope'), - style=CLI_STYLE.check_box, + style=cli_style.check_box, ), self.myparent.getTitledCheckBox( @@ -297,7 +297,7 @@ def prepare_tabs(self) -> None: name='showInConfigurationEndpoint', checked=self.data.get('attributes',{}).get('showInConfigurationEndpoint',''), jans_help='Configuration Endpoint', - style=CLI_STYLE.check_box, + style=cli_style.check_box, ), # Window(char='-', height=1), @@ -338,13 +338,14 @@ def prepare_tabs(self) -> None: value='\n'.join(self.data.get('dynamicScopeScripts', [])), jans_help=self.myparent.get_help_from_schema(self.schema, 'dynamicScopeScripts'), height=3, - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), self.myparent.getTitledText( _("Search"), name='__search_claims__', style='class:outh-scope-textsearch',width=10, - jans_help=_("Press enter to perform search"), ),#accept_handler=self.search_scopes + jans_help=_("Press enter to perform search"), + ) self.myparent.getTitledText( _("Claims"), @@ -352,7 +353,7 @@ def prepare_tabs(self) -> None: value='\n'.join(self.data.get('claims', [])), height=3, jans_help=self.myparent.get_help_from_schema(self.schema, 'claims'), - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), ],width=D(), ) @@ -362,7 +363,7 @@ def prepare_tabs(self) -> None: _("Associated Client"), name='none', value=self.data.get('none',''), - style=CLI_STYLE.edit_text, + style=cli_style.edit_text, read_only=True, jans_help=self.myparent.get_help_from_schema(self.schema, 'none'), height=3,),## Not fount @@ -372,7 +373,7 @@ def prepare_tabs(self) -> None: name='creationDate', value=self.data.get('creationDate',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'creationDate'), - style=CLI_STYLE.edit_text, + style=cli_style.edit_text, read_only=True,), ],width=D(), @@ -387,7 +388,7 @@ def prepare_tabs(self) -> None: name='iconUrl', value=self.data.get('iconUrl',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'iconUrl'), - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), self.myparent.getTitledText(_("Authorization Policies"), @@ -395,14 +396,14 @@ def prepare_tabs(self) -> None: value='\n'.join(self.data.get('umaAuthorizationPolicies', [])), height=3, jans_help=self.myparent.get_help_from_schema(self.schema, 'umaAuthorizationPolicies'), - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), self.myparent.getTitledText( _("Associated Client"), name='none', value=self.data.get('none',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'none'), - style=CLI_STYLE.edit_text, + style=cli_style.edit_text, read_only=True, height=3,), ## Not fount @@ -411,13 +412,13 @@ def prepare_tabs(self) -> None: name='description', value=self.data.get('description',''), jans_help=self.myparent.get_help_from_schema(self.schema, 'description'), - style=CLI_STYLE.edit_text, + style=cli_style.edit_text, read_only=True,), self.myparent.getTitledText( _("Creator"), name='Creator', - style=CLI_STYLE.edit_text, + style=cli_style.edit_text, jans_help=self.myparent.get_help_from_schema(self.schema, 'Creator'), read_only=True, value=uma_creator diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py index f08e86801d8..6990ff5a6a3 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py @@ -21,7 +21,7 @@ TextArea ) from prompt_toolkit.lexers import PygmentsLexer, DynamicLexer -from utils.static import DialogResult, CLI_STYLE, COMMON_STRINGS +from utils.static import DialogResult, cli_style, common_strings from utils.utils import DialogUtils from wui_components.jans_nav_bar import JansNavBar from wui_components.jans_vetrical_nav import JansVerticalNav @@ -105,7 +105,7 @@ def oauth_prepare_containers(self) -> None: self.oauth_containers['scopes'] = HSplit([ VSplit([ self.app.getButton(text=_("Get Scopes"), name='oauth:scopes:get', jans_help=_("Retreive first {} Scopes").format(self.app.entries_per_page), handler=self.oauth_get_scopes), - self.app.getTitledText(_("Search"), name='oauth:scopes:search', jans_help=_(COMMON_STRINGS.enter_to_search), accept_handler=self.search_scope,style='class:outh_containers_scopes.text'), + self.app.getTitledText(_("Search"), name='oauth:scopes:search', jans_help=_(common_strings.enter_to_search), accept_handler=self.search_scope,style='class:outh_containers_scopes.text'), self.app.getButton(text=_("Add Scope"), name='oauth:scopes:add', jans_help=_("To add a new scope press this button"), handler=self.add_scope), ], padding=3, @@ -117,7 +117,7 @@ def oauth_prepare_containers(self) -> None: self.oauth_containers['clients'] = HSplit([ VSplit([ self.app.getButton(text=_("Get Clients"), name='oauth:clients:get', jans_help=_("Retreive first {} OpenID Connect clients").format(self.app.entries_per_page), handler=self.oauth_update_clients), - self.app.getTitledText(_("Search"), name='oauth:clients:search', jans_help=_(COMMON_STRINGS.enter_to_search), accept_handler=self.search_clients,style='class:outh_containers_clients.text'), + self.app.getTitledText(_("Search"), name='oauth:clients:search', jans_help=_(common_strings.enter_to_search), accept_handler=self.search_clients,style='class:outh_containers_clients.text'), self.app.getButton(text=_("Add Client"), name='oauth:clients:add', jans_help=_("To add a new client press this button"), handler=self.add_client), ], @@ -125,7 +125,7 @@ def oauth_prepare_containers(self) -> None: width=D(), ), DynamicContainer(lambda: self.oauth_data_container['clients']) - ],style=CLI_STYLE.container) + ],style=cli_style.container) self.oauth_containers['keys'] = HSplit([ @@ -136,14 +136,14 @@ def oauth_prepare_containers(self) -> None: width=D(), ), DynamicContainer(lambda: self.oauth_data_container['keys']) - ], style=CLI_STYLE.container) + ], style=cli_style.container) self.oauth_containers['properties'] = HSplit([ VSplit([ self.app.getTitledText( _("Search"), name='oauth:properties:search', - jans_help=_(COMMON_STRINGS.enter_to_search), + jans_help=_(common_strings.enter_to_search), accept_handler=self.search_properties, style='class:outh_containers_scopes.text') ], @@ -160,7 +160,7 @@ def oauth_prepare_containers(self) -> None: DynamicContainer(lambda: self.oauth_main_area), ], height=D(), - style=CLI_STYLE.container + style=cli_style.container ) def oauth_prepare_navbar(self) -> None: @@ -244,8 +244,8 @@ async def coroutine(): on_delete=self.delete_client, get_help=(self.get_help,'Client'), selectes=0, - headerColor=CLI_STYLE.navbar_headcolor, - entriesColor=CLI_STYLE.navbar_entriescolor, + headerColor=cli_style.navbar_headcolor, + entriesColor=cli_style.navbar_entriescolor, all_data=result['entries'] ) buttons = [] @@ -270,7 +270,7 @@ async def coroutine(): self.app.layout.focus(clients) ### it fix focuse on the last item deletion >> try on UMA-res >> edit_client_dialog >> oauth_update_uma_resources else: - self.app.show_message(_("Oops"), _(COMMON_STRINGS.no_matching_result),tobefocused = self.oauth_containers['clients']) + self.app.show_message(_("Oops"), _(common_strings.no_matching_result),tobefocused = self.oauth_containers['clients']) asyncio.ensure_future(coroutine()) @@ -337,7 +337,7 @@ async def coroutine(): try: result = response.json() - except Exception as e: + except Exception: self.app.show_message(_("Error getting response"), str(response)) return @@ -365,8 +365,8 @@ async def coroutine(): on_delete=self.delete_scope, get_help=(self.get_help,'Scope'), selectes=0, - headerColor=CLI_STYLE.navbar_headcolor, - entriesColor=CLI_STYLE.navbar_entriescolor, + headerColor=cli_style.navbar_headcolor, + entriesColor=cli_style.navbar_entriescolor, all_data=result['entries'] ) @@ -392,7 +392,7 @@ async def coroutine(): self.app.layout.focus(scopes) ### it fix focuse on the last item deletion >> try on UMA-res >> edit_client_dialog >> oauth_update_uma_resources else: - self.app.show_message(_("Oops"), _(COMMON_STRINGS.no_matching_result),tobefocused = self.oauth_containers['scopes']) + self.app.show_message(_("Oops"), _(common_strings.no_matching_result),tobefocused = self.oauth_containers['scopes']) asyncio.ensure_future(coroutine()) @@ -471,10 +471,9 @@ def oauth_update_properties( on_enter=self.view_property, on_display=self.properties_display_dialog, get_help=(self.get_help,'AppConfiguration'), - # selection_changed=self.data_selection_changed, selectes=0, - headerColor=CLI_STYLE.navbar_headcolor, - entriesColor=CLI_STYLE.navbar_entriescolor, + headerColor=cli_style.navbar_headcolor, + entriesColor=cli_style.navbar_entriescolor, all_data=list(self.app_configuration.values()) ) @@ -486,7 +485,7 @@ def oauth_update_properties( if tofocus: self.app.layout.focus(properties) else: - self.app.show_message(_("Oops"), _(COMMON_STRINGS.no_matching_result),tobefocused = self.oauth_containers['properties']) + self.app.show_message(_("Oops"), _(common_strings.no_matching_result),tobefocused = self.oauth_containers['properties']) def properties_display_dialog(self, **params: Any) -> None: """Display the properties as Text @@ -560,8 +559,8 @@ def oauth_update_keys(self) -> None: preferred_size=[0,0], on_display=self.app.data_display_dialog, selectes=0, - headerColor=CLI_STYLE.navbar_headcolor, - entriesColor=CLI_STYLE.navbar_entriescolor, + headerColor=cli_style.navbar_headcolor, + entriesColor=cli_style.navbar_entriescolor, all_data=self.jwks_keys['keys'] ) @@ -625,7 +624,7 @@ def save_client(self, dialog: Dialog) -> None: self.app.stop_progressing() if response.status_code in (200, 201): self.oauth_update_clients() - return True + return None self.app.show_message(_("Error!"), _("An error ocurred while saving client:\n") + str(response.text)) @@ -675,13 +674,13 @@ def add_scope(self) -> None: """Method to display the dialog of Scopes (Add New) """ dialog = EditScopeDialog(self.app, title=_("Add New Scope"), data={}, save_handler=self.save_scope) - result = self.app.show_jans_dialog(dialog) + self.app.show_jans_dialog(dialog) def add_client(self) -> None: """Method to display the dialog of clients (Add New) """ dialog = EditClientDialog(self.app, title=_("Add Client"), data={}, save_handler=self.save_client) - result = self.app.show_jans_dialog(dialog) + self.app.show_jans_dialog(dialog) def get_help(self, **kwargs: Any): """This method get focused field Description to display on statusbar @@ -787,28 +786,28 @@ def oauth_logging(self) -> None: name='httpLoggingEnabled', checked=self.app_configuration.get('httpLoggingEnabled'), jans_help=self.app.get_help_from_schema(self.schema, 'httpLoggingEnabled'), - style=CLI_STYLE.check_box + style=cli_style.check_box ), self.app.getTitledCheckBox( _("Disable JDK Logger"), name='disableJdkLogger', checked=self.app_configuration.get('disableJdkLogger'), jans_help=self.app.get_help_from_schema(self.schema, 'disableJdkLogger'), - style=CLI_STYLE.check_box + style=cli_style.check_box ), self.app.getTitledCheckBox( _("Enable Oauth Audit Logging"), name='enabledOAuthAuditLogging', checked=self.app_configuration.get('enabledOAuthAuditLogging'), jans_help=self.app.get_help_from_schema(self.schema, 'enabledOAuthAuditLogging'), - style=CLI_STYLE.check_box + style=cli_style.check_box ), Window(height=1), HSplit([ self.app.getButton(text=_("Save Logging"), name='oauth:logging:save', jans_help=_("Save Auth Server logging configuration"), handler=self.save_logging), Window(width=100), ]) - ], style=CLI_STYLE.container, width=D()) + ], style=cli_style.container, width=D()) def save_logging(self) -> None: """This method to Save the Auth Login to server diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/view_property.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_property.py index 5ad23fc2cee..67ee4d7f09f 100644 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/view_property.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_property.py @@ -11,7 +11,7 @@ RadioList, Dialog, ) -from utils.static import DialogResult, CLI_STYLE +from utils.static import DialogResult, cli_style from utils.utils import DialogUtils from wui_components.jans_cli_dialog import JansGDialog from typing import Optional, Sequence @@ -189,7 +189,7 @@ def prepare_properties(self): self.property, name=self.property, value=self.value, - style=CLI_STYLE.edit_text + style=cli_style.edit_text ), ],width=D()) @@ -199,7 +199,7 @@ def prepare_properties(self): name=self.property, value=self.value, text_type='integer', - style=CLI_STYLE.edit_text + style=cli_style.edit_text ), ],width=D()) @@ -209,7 +209,7 @@ def prepare_properties(self): name=self.property, height=3, value='\n'.join(self.value), - style=CLI_STYLE.edit_text + style=cli_style.edit_text ), ],width=D()) @@ -246,7 +246,7 @@ def prepare_properties(self): item , name=item, value=tab[item], - style=CLI_STYLE.edit_text + style=cli_style.edit_text ), ],width=D())) @@ -256,7 +256,7 @@ def prepare_properties(self): name=item, value=tab[item], text_type='integer', - style=CLI_STYLE.edit_text + style=cli_style.edit_text ), ],width=D())) @@ -266,7 +266,7 @@ def prepare_properties(self): name=item, height=3, value='\n'.join(tab[item]), - style=CLI_STYLE.edit_text + style=cli_style.edit_text ), ],width=D())) @@ -276,7 +276,7 @@ def prepare_properties(self): item, name=item, checked= tab[item], - style=CLI_STYLE.checkbox), + style=cli_style.checkbox), ],width=D())) self.tabs[tab_temp.format(self.value.index(tab))] = HSplit(tab_list,width=D()) @@ -300,7 +300,7 @@ def prepare_properties(self): self.property, name=self.property, checked= self.value, - style=CLI_STYLE.checkbox), + style=cli_style.checkbox), ],width=D()) elif prop_type == 'dict': @@ -311,7 +311,7 @@ def prepare_properties(self): item , name=item, value=self.value[item], - style=CLI_STYLE.edit_text + style=cli_style.edit_text ), ],width=D())) @@ -321,7 +321,7 @@ def prepare_properties(self): name=item, value=self.value[item], text_type='integer', - style=CLI_STYLE.edit_text + style=cli_style.edit_text ), ],width=D())) @@ -331,7 +331,7 @@ def prepare_properties(self): name=item, height=3, value='\n'.join(self.value[item]), - style=CLI_STYLE.edit_text + style=cli_style.edit_text ), ],width=D())) @@ -341,7 +341,7 @@ def prepare_properties(self): item, name=item, checked= self.value[item], - style=CLI_STYLE.checkbox), + style=cli_style.checkbox), ],width=D())) else : @@ -349,7 +349,7 @@ def prepare_properties(self): item, name=item, value="No Items Here", - style=CLI_STYLE.edit_text, + style=cli_style.edit_text, read_only=True, ), ],width=D())) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/view_uma_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_uma_dialog.py index 71cbc1b9c20..d58a3a107cd 100644 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/view_uma_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_uma_dialog.py @@ -17,7 +17,7 @@ import cli_style from utils.multi_lang import _ from utils.utils import DialogUtils -from utils.static import DialogResult, CLI_STYLE +from utils.static import DialogResult, cli_style from wui_components.jans_nav_bar import JansNavBar from wui_components.jans_cli_dialog import JansGDialog @@ -80,7 +80,7 @@ def cancel() -> None: name='id', value=self.data.get('id',''), read_only=True, - style=CLI_STYLE.edit_text, + style=cli_style.edit_text, ), self.myparent.getTitledText( @@ -88,14 +88,14 @@ def cancel() -> None: name='name', value=self.data.get('name',''), read_only=True, - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), self.myparent.getTitledText( _("IconURL"), name='iconUri', value=self.data.get('iconUri',''), read_only=True, - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), VSplit([ @@ -112,17 +112,17 @@ def cancel() -> None: name='clients', value=self.data.get('clients',''), read_only=True, - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), self.myparent.getTitledText( _("Creation time"), name='creationDate', value=self.data.get('creationDate',''), read_only=True, - style=CLI_STYLE.edit_text), + style=cli_style.edit_text), ], padding=1,width=100,style='class:outh-uma-tabs' - # key_bindings=self.get_uma_dialog_key_bindings() + ), buttons=[ Button( @@ -135,7 +135,7 @@ def cancel() -> None: ) ], with_background=False, - # width=140, + ) def UMA_prepare_containers(self) -> None: @@ -147,7 +147,7 @@ def UMA_prepare_containers(self) -> None: name='scopes', value='\n'.join(self.data.get('scopes',[])), read_only=True, - style=CLI_STYLE.edit_text, + style=cli_style.edit_text, height=3, ) ],width=D()) @@ -158,7 +158,7 @@ def UMA_prepare_containers(self) -> None: name='scopeExpression', value='\n'.join(self.data.get('scopeExpression',[])), read_only=True, - style=CLI_STYLE.edit_text, + style=cli_style.edit_text, height=3, ), ],width=D()) diff --git a/jans-cli-tui/cli_tui/utils/static.py b/jans-cli-tui/cli_tui/utils/static.py index e1c6de4d8bc..d38b8cbe8fa 100755 --- a/jans-cli-tui/cli_tui/utils/static.py +++ b/jans-cli-tui/cli_tui/utils/static.py @@ -5,7 +5,7 @@ class DialogResult(Enum): ACCEPT = 1 OK = 2 -class CLI_STYLE: +class cli_style: edit_text = 'class:plugin-text' edit_text_required = 'class:plugin-textrequired' check_box = 'class:plugin-checkbox' @@ -16,6 +16,6 @@ class CLI_STYLE: navbar_headcolor = "class:plugin-navbar-headcolor" navbar_entriescolor = "class:plugin-navbar-entriescolor" -class COMMON_STRINGS: +class common_strings: enter_to_search = "Press enter to perform search" no_matching_result = "No matching result" diff --git a/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py b/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py index 5680206f952..2d66197bc4e 100755 --- a/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py +++ b/jans-cli-tui/cli_tui/wui_components/jans_date_picker.py @@ -24,7 +24,7 @@ import datetime import cli_style -DATE_TIME_TEMP = '%Y-%m-%dT%H:%M:%S' +date_time_temp = '%Y-%m-%dT%H:%M:%S' class JansSelectDate: """_summary_ @@ -33,9 +33,9 @@ class JansSelectDate: def __init__( self, date: Optional[str] = '', - months: Optional[list] = [], - mytime: Optional[list] = [], - )-> HSplit: + months: Optional[list] = None, + mytime: Optional[list] = None, + )-> HSplit: """_summary_ @@ -44,10 +44,10 @@ def __init__( months (list, optional): _description_. Defaults to []. mytime (list, optional): _description_. Defaults to []. """ - self.hours , self.minuts , self.seconds = mytime + self.hours , self.minuts , self.seconds = mytime if mytime else [0,0,0] self.change_date = True self.date = date #"11/27/2023" - self.months = months + self.months = months if months else [] self.cord_y = 0 self.cord_x = 0 self.old_cord_x = 0 @@ -350,7 +350,7 @@ def __init__( if value: self.text = value - ts = time.strptime(value[:19], DATE_TIME_TEMP) # "2023-11-27" + ts = time.strptime(value[:19], date_time_temp) # "2023-11-27" self.date = time.strftime("%m/%d/%Y", ts) # "11/27/2023" self.hours = int(time.strftime("%H",ts)) self.minuts =int(time.strftime("%M",ts)) @@ -403,7 +403,7 @@ def make_time( Args: text (str): the text that appear on the wigdet """ - ts = time.strptime(text[:19], DATE_TIME_TEMP) # "2023-11-27" + ts = time.strptime(text[:19], date_time_temp) # "2023-11-27" years =int(time.strftime("%Y",ts)) months = int(time.strftime("%m",ts)) days = int(time.strftime("%d",ts)) @@ -413,7 +413,7 @@ def make_time( t = (years, months,days,self.hours,self.minuts,self.seconds,0,0,0) ## the up increment t = time.mktime(t) - self.text= (time.strftime(DATE_TIME_TEMP, time.gmtime(t))) + self.text= (time.strftime(date_time_temp, time.gmtime(t))) def _get_text(self)-> AnyFormattedText: """To get The selected value @@ -452,7 +452,7 @@ def _enter(event) -> None: t = (years, months,days,(self.select_box.hours-8),self.select_box.minuts,self.select_box.seconds,0,0,0) ## the up increment t = time.mktime(t) - self.text= (time.strftime(DATE_TIME_TEMP, time.gmtime(t))) + self.text= (time.strftime(date_time_temp, time.gmtime(t))) get_app().layout.container.floats.remove(self.select_box_float) @kb.add("up") @@ -475,16 +475,6 @@ def _left(event): if self.select_box_float in get_app().layout.container.floats: self.select_box.left() - # @kb.add("+") - # def _plus(event): - # if self.select_box_float not in get_app().layout.container.floats: - # self.make_time(self.text) - - # @kb.add("-") - # def _minus(event): - # if self.select_box_float not in get_app().layout.container.floats: - # self.make_time(self.text) - @kb.add("tab") def _tab(event): if self.select_box_float in get_app().layout.container.floats: From 9d2dfd797263b09f1c6a03dd7b0b4fe5f4dee400 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Mon, 2 Jan 2023 14:21:52 +0300 Subject: [PATCH 30/30] fix: jans-cli-tui typo --- .../010_auth_server/edit_scope_dialog.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py index d059b823573..fc7266970b4 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py @@ -332,20 +332,22 @@ def prepare_tabs(self) -> None: self.alt_tabs['openid'] = HSplit(open_id_widgets, width=D()) self.alt_tabs['dynamic'] = HSplit([ - - self.myparent.getTitledText(_("Dynamic Scope Script"), + + self.myparent.getTitledText( + _("Dynamic Scope Script"), name='dynamicScopeScripts', value='\n'.join(self.data.get('dynamicScopeScripts', [])), jans_help=self.myparent.get_help_from_schema(self.schema, 'dynamicScopeScripts'), height=3, - style=cli_style.edit_text), - + style=cli_style.edit_text + ), + self.myparent.getTitledText( _("Search"), name='__search_claims__', style='class:outh-scope-textsearch',width=10, - jans_help=_("Press enter to perform search"), - ) + jans_help=_("Press enter to perform search") + ), self.myparent.getTitledText( _("Claims"), @@ -353,7 +355,8 @@ def prepare_tabs(self) -> None: value='\n'.join(self.data.get('claims', [])), height=3, jans_help=self.myparent.get_help_from_schema(self.schema, 'claims'), - style=cli_style.edit_text), + style=cli_style.edit_text + ), ],width=D(), )