diff --git a/jans-cli-tui/cli_tui/cli/config_cli.py b/jans-cli-tui/cli_tui/cli/config_cli.py
index c8ed11eff01..bbc25ed4262 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)
@@ -1419,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:
+ 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('/')}]
diff --git a/jans-cli-tui/cli_tui/cli_style.py b/jans-cli-tui/cli_tui/cli_style.py
index ac940f37f25..2daa3d1e190 100755
--- a/jans-cli-tui/cli_tui/cli_style.py
+++ b/jans-cli-tui/cli_tui/cli_style.py
@@ -59,6 +59,24 @@
"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",
+ "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 4a16c018e8c..5ac14ab8027 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
@@ -63,19 +74,16 @@
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 +117,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()),
@@ -290,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()
@@ -364,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()
@@ -380,6 +389,167 @@ 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)
+
+
+ # ------------------------------------------------------------------------------------ #
+ # ------------------------------------------------------------------------------------ #
+ # ------------------------------------------------------------------------------------ #
+ style_tmp = ''
+ style_tmp_red = ''
+
+ res=[]
+ res.append(HTML(style_tmp.format("Copy")))
+ res.append("\n")
+ res.append(HTML(style_tmp.format("Cut")))
+ res.append("\n")
+ res.append(HTML(style_tmp.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:
+ 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:
+ pass
+
+
+ if get_app().layout.container.floats:
+ try :
+ get_float_name = get_app().layout.container.floats[-1].name
+ except Exception:
+ 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(style_tmp_red.format("Copy ")))
+ res.append("\n")
+ res.append(HTML(style_tmp.format("Cut")))
+ res.append("\n")
+ 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'
+ elif self.mouse_cord[1] == y-2:
+ res = []
+ res.append(HTML(style_tmp.format("Copy")))
+ res.append("\n")
+ res.append(HTML(style_tmp_red.format("Cut ")))
+ res.append("\n")
+ 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'
+ elif self.mouse_cord[1] == y-3:
+ res = []
+ res.append(HTML(style_tmp.format("Copy")))
+ res.append("\n")
+ res.append(HTML(style_tmp.format("Cut")))
+ res.append("\n")
+ 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'
+ else:
+ self.mouse_select = 'None'
+ else:
+ res = []
+ res.append(HTML(style_tmp.format("Copy")))
+ res.append("\n")
+ res.append(HTML(style_tmp.format("Cut")))
+ res.append("\n")
+ 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'
def up(self, ev: KeyPressEvent) -> None:
get_app().layout.focus(Frame(self.nav_bar.nav_window))
@@ -548,7 +718,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
@@ -633,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_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 86%
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
index 0ede9d2d20f..402dd3fb459 100755
--- 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
@@ -15,13 +15,13 @@
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
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_date_picker import DateSelectWidget
from utils.utils import DialogUtils
from wui_components.jans_vetrical_nav import JansVerticalNav
from view_uma_dialog import ViewUMADialog
@@ -33,6 +33,8 @@
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
@@ -44,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`
@@ -57,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))
@@ -184,43 +186,43 @@ 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"),
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'),
+ style=cli_style.radio_button),
self.myparent.getTitledRadioButton(
_("Subject Type"),
@@ -228,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='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 +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='class:outh-client-checkbox'),
+ style=cli_style.check_box),
self.myparent.getTitledRadioButton(
_("Application Type"),
@@ -267,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='class:outh-client-radiobutton'),
+ style=cli_style.radio_button),
self.myparent.getTitledText(
_("Redirect Uris"),
@@ -282,19 +284,19 @@ 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='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'
+ style=cli_style.tabs
)
self.tabs['Tokens'] = HSplit([
@@ -304,39 +306,39 @@ 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(
- _("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'),
- style='class:outh-client-checkbox'),
+ style=cli_style.check_box),
self.myparent.getTitledCheckBox(
_("Run introspection script before JWT access token creation"),
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='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"),
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='class:outh-client-text',
+ style=cli_style.check_box,
height = 3),
self.myparent.getTitledText(
@@ -345,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='class:outh-client-text'),
+ style=cli_style.check_box),
self.myparent.getTitledText(
_("Refresh token lifetime"),
@@ -353,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='class:outh-client-text'),
+ style=cli_style.check_box),
self.myparent.getTitledText(
_("Defult max authn age"),
@@ -361,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='class:outh-client-text'),
+ style=cli_style.check_box),
- ],width=D(),style='class:outh-client-tabs')
+ ],width=D(),style=cli_style.tabs)
self.tabs['Logout'] = HSplit([
@@ -372,23 +374,23 @@ 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"),
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='class:outh-client-text'
+ height=3, style=cli_style.check_box
),
self.myparent.getTitledCheckBox(
@@ -396,9 +398,9 @@ 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='class:outh-client-checkbox'
+ style=cli_style.check_box
),
self.myparent.getTitledCheckBox(
@@ -406,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='class:outh-client-checkbox'),
+ style=cli_style.check_box),
- ],width=D(),style='class:outh-client-tabs'
+ ],width=D(),style=cli_style.tabs
)
self.tabs['SoftwareInfo'] = HSplit([
@@ -418,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='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')
+ ],width=D(),style=cli_style.tabs)
self.uma_resources = HSplit([],width=D())
@@ -462,55 +464,55 @@ 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',
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'),
),
- Label(text=_("PAR"),style='class:outh-client-label'),
+ Label(text=_("PAR"),style=cli_style.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'),
+ self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH),
'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'),
),
- Label(_("UMA"), style='class:outh-client-label'),
+ Label(_("UMA"), style=cli_style.label),
self.myparent.getTitledRadioButton(
_("PRT token type"),
@@ -518,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='class:outh-client-radiobutton'),
+ style=cli_style.radio_button),
self.myparent.getTitledText(
title =_("Claims redirect URI"),
@@ -526,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='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'),
@@ -540,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
)
@@ -550,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='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),
]
@@ -612,10 +614,10 @@ 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='class:outh-client-text')
+ style=cli_style.check_box)
self.tabs['Advanced Client Properties'] = HSplit([
@@ -625,10 +627,10 @@ 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='class:outh-client-checkbox'
+ style=cli_style.check_box
),
self.myparent.getTitledCheckBox(
@@ -636,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='class:outh-client-checkbox'),
+ style=cli_style.check_box),
self.myparent.getTitledCheckBox(
_("Allow spontaneos scopes"),
@@ -644,16 +646,16 @@ 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='class:outh-client-checkbox'
+ style=cli_style.check_box
),
self.spontaneous_scopes,
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,
@@ -668,38 +670,38 @@ 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',
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='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'),
+ self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH),
'tlsClientAuthSubjectDn'),
),
@@ -713,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([
@@ -724,44 +726,44 @@ 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='class:outh-client-text'),
+ style=cli_style.check_box),
self.myparent.getTitledText(_("Update Token"),
name='updateTokenScriptDns',
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'),
- 'updateTokenScriptDns'),
- style='class:outh-client-text'),
+ self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH),
+ 'updateTokenScriptDns'),
+ style=cli_style.check_box),
self.myparent.getTitledText(_("Post Authn"),
name='postAuthnScripts',
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='class:outh-client-text'),
+ style=cli_style.check_box),
self.myparent.getTitledText(_("Introspection"),
name='introspectionScripts',
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='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'),
+ self.myparent.cli_object.get_schema_from_reference('', ATTRIBUTE_SCHEMA_PATH),
'ropcScripts'),
),
@@ -770,16 +772,16 @@ 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='class:outh-client-text'),
- ],width=D(),style='class:outh-client-tabs'
+ style=cli_style.check_box),
+ ],width=D(),style=cli_style.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 +795,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 +873,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 +903,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:
@@ -927,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',
@@ -963,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_oxauth/edit_scope_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_scope_dialog.py
similarity index 86%
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
index 1d983e7308a..fc7266970b4 100755
--- 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
@@ -30,20 +30,17 @@
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
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
-
-
class EditScopeDialog(JansGDialog, DialogUtils):
"""The Main Scope Dialog that contain every thing related to The Scope
"""
@@ -144,22 +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='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(
@@ -167,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='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'),
@@ -196,7 +192,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
@@ -208,8 +204,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='',
@@ -217,17 +215,15 @@ def get_named_claims(
data={}
)
except Exception as e:
- self.myparent.show_message(_("Error getting claims"), str(e))
- return
+ self.myparent.show_message(_("Error getting claims"), str(e))
+ return calims_names
- if responce.status_code not in (200, 201):
- self.myparent.show_message(_("Error getting clients"), str(responce.text))
- return
+ if response.status_code not in (200, 201):
+ self.myparent.show_message(_("Error getting claims"), str(response.text))
+ return calims_names
+ result = response.json()
- result = responce.json()
-
- calims_names=[]
for entry in result["entries"] :
for claim in claims_list:
if claim == entry['dn']:
@@ -250,7 +246,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':
@@ -273,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='class:outh-scope-checkbox',
+ style=cli_style.check_box,
),
self.myparent.getTitledCheckBox(
@@ -281,7 +277,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(),)
@@ -293,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='class:outh-scope-checkbox',
+ style=cli_style.check_box,
),
self.myparent.getTitledCheckBox(
@@ -301,7 +297,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),
@@ -316,41 +312,42 @@ 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())
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='class:outh-scope-text'),
-
- # Window(char='-', height=1),
+ 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"),
@@ -358,9 +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='class:outh-scope-text'),
-
- # Label(text=_("Claims"),style='red'), ## name = claims TODO
+ style=cli_style.edit_text
+ ),
],width=D(),
)
@@ -370,7 +366,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
@@ -380,7 +376,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(),
@@ -395,7 +391,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"),
@@ -403,14 +399,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
@@ -419,13 +415,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
@@ -445,7 +441,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),
@@ -456,7 +452,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,9 +476,7 @@ def add_selected_claims(dialog):
values_uniqe = []
for k in values:
- if k[0][0] in current_data:
- pass
- else:
+ if k[0][0] not in current_data:
values_uniqe.append(k)
if not values_uniqe:
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 91%
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
index e9bd5f3864c..6990ff5a6a3 100755
--- a/jans-cli-tui/cli_tui/plugins/010_oxauth/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
"""
@@ -41,13 +43,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
@@ -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)
@@ -334,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
@@ -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())
@@ -468,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='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 +485,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
@@ -527,10 +529,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:
@@ -561,8 +559,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']
)
@@ -601,7 +599,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:
@@ -626,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))
@@ -660,9 +658,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 +667,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)
@@ -682,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
@@ -716,13 +708,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':
@@ -744,13 +736,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':
@@ -794,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='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
@@ -841,10 +833,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_oxauth/view_property.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_property.py
similarity index 91%
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
index a9f35d83d0f..67ee4d7f09f 100644
--- 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
@@ -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_oxauth/view_uma_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/view_uma_dialog.py
similarity index 91%
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
index d6c551df023..d58a3a107cd 100644
--- 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
@@ -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,17 +112,17 @@ 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()
+
),
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='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/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/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,
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..e90cf9f689d 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
@@ -137,7 +137,7 @@ def scripts_update_list(
buttons = []
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)
@@ -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/edit_user_dialog.py b/jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py
index e16c82fa843..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 ''
@@ -242,7 +244,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']))
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..ead042a5973 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.
"""
@@ -263,8 +263,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)
diff --git a/jans-cli-tui/cli_tui/utils/static.py b/jans-cli-tui/cli_tui/utils/static.py
index e331702ef8d..d38b8cbe8fa 100755
--- a/jans-cli-tui/cli_tui/utils/static.py
+++ b/jans-cli-tui/cli_tui/utils/static.py
@@ -4,3 +4,18 @@ 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'
+ 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/utils/utils.py b/jans-cli-tui/cli_tui/utils/utils.py
index 2d28644fd93..f5dd69c1506 100755
--- a/jans-cli-tui/cli_tui/utils/utils.py
+++ b/jans-cli-tui/cli_tui/utils/utils.py
@@ -5,9 +5,10 @@
from cli_style import style
from wui_components.jans_drop_down import DropDownWidget
-from wui_components.jans_data_picker import DateSelectWidget
from wui_components.jans_spinner import Spinner
+import sys
+from wui_components.jans_date_picker import DateSelectWidget
common_data = SimpleNamespace()
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 91%
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
index 9123faa82d6..2d66197bc4e 100755
--- a/jans-cli-tui/cli_tui/wui_components/jans_data_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
@@ -33,6 +24,8 @@
import datetime
import cli_style
+date_time_temp = '%Y-%m-%dT%H:%M:%S'
+
class JansSelectDate:
"""_summary_
"""
@@ -40,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_
@@ -51,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
@@ -95,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,
@@ -108,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
@@ -176,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
@@ -288,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)
@@ -299,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)
@@ -312,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:
@@ -327,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:
@@ -365,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))
@@ -407,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,
@@ -419,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))
@@ -429,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
@@ -468,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")
@@ -491,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:
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