nice-gui-utils 0.2.4__tar.gz → 0.3.1.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/PKG-INFO +5 -2
- nice_gui_utils-0.3.1.dev1/README.md +6 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/pyproject.toml +1 -1
- nice_gui_utils-0.3.1.dev1/src/nice_gui_utils/__init__.py +5 -0
- nice_gui_utils-0.3.1.dev1/src/nice_gui_utils/keycloak_js/__init__.py +4 -0
- nice_gui_utils-0.3.1.dev1/src/nice_gui_utils/keycloak_js/keycloak.py +94 -0
- nice_gui_utils-0.3.1.dev1/src/nice_gui_utils/router/__init__.py +4 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils/router/router.py +31 -3
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils.egg-info/PKG-INFO +5 -2
- nice_gui_utils-0.2.4/README.md +0 -3
- nice_gui_utils-0.2.4/src/nice_gui_utils/__init__.py +0 -0
- nice_gui_utils-0.2.4/src/nice_gui_utils/keycloak_js/__init__.py +0 -1
- nice_gui_utils-0.2.4/src/nice_gui_utils/keycloak_js/keycloak.py +0 -47
- nice_gui_utils-0.2.4/src/nice_gui_utils/router/__init__.py +0 -1
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/LICENSE +0 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/requirements.txt +0 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/setup.cfg +0 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils/keycloak_js/keycloak.js +0 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils/router/router_frame.js +0 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils.egg-info/SOURCES.txt +0 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils.egg-info/dependency_links.txt +0 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils.egg-info/requires.txt +0 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils.egg-info/top_level.txt +0 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/tests/test_login.py +0 -0
- {nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/tests/test_single_page.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nice_gui_utils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1.dev1
|
|
4
4
|
Summary: Utils to use with NiceGUI.
|
|
5
5
|
Author: Harter Kern
|
|
6
6
|
Project-URL: Homepage, https://gitlab.com/harter-kern-public/nice-gui-utils
|
|
@@ -13,6 +13,9 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: nicegui>=1.4.0
|
|
15
15
|
|
|
16
|
-
#
|
|
16
|
+
# nice_gui_utils - a collection of utilities for [nicegui](https://nicegui.io/)
|
|
17
17
|
|
|
18
|
+
## [Documentation](https://nice-gui-utils-harter-kern-8e1d5c74ce521b132e29aa9329b109a50ad7.gitlab.io)
|
|
19
|
+
|
|
20
|
+
## Pipeline status
|
|
18
21
|
[](https://gitlab.com/harter-kern/nice-gui-utils/-/commits/main)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# nice_gui_utils - a collection of utilities for [nicegui](https://nicegui.io/)
|
|
2
|
+
|
|
3
|
+
## [Documentation](https://nice-gui-utils-harter-kern-8e1d5c74ce521b132e29aa9329b109a50ad7.gitlab.io)
|
|
4
|
+
|
|
5
|
+
## Pipeline status
|
|
6
|
+
[](https://gitlab.com/harter-kern/nice-gui-utils/-/commits/main)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Implementation of the keycloak wrapper class.
|
|
3
|
+
See keycloak-js api reference for more info.
|
|
4
|
+
"""
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import AnyStr, Dict, Any
|
|
7
|
+
|
|
8
|
+
from nicegui import ui
|
|
9
|
+
from nicegui.awaitable_response import AwaitableResponse
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class KeycloakConfig:
|
|
14
|
+
"""
|
|
15
|
+
Base Keycloak config.
|
|
16
|
+
"""
|
|
17
|
+
url: AnyStr
|
|
18
|
+
realm: AnyStr
|
|
19
|
+
client_id: AnyStr
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Keycloak(ui.element, component='keycloak.js'):
|
|
23
|
+
"""
|
|
24
|
+
Wrapper class. Exposes part of the api of keycloak-js.
|
|
25
|
+
Will automatically refresh tokens after initialization.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
config: KeycloakConfig = None
|
|
29
|
+
require_login: bool = None
|
|
30
|
+
|
|
31
|
+
def __init__(self,
|
|
32
|
+
config: KeycloakConfig,
|
|
33
|
+
js_source: AnyStr = '/static/keycloak.js',
|
|
34
|
+
init_options: Dict = None):
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
:param config: base keycloak config
|
|
38
|
+
:param js_source: url of keycloak-js source
|
|
39
|
+
:param init_options: options used for initialization
|
|
40
|
+
"""
|
|
41
|
+
super().__init__()
|
|
42
|
+
|
|
43
|
+
ui.add_head_html(f'<script src="{js_source}"></script>')
|
|
44
|
+
|
|
45
|
+
props: Dict[str, Any] = self._props
|
|
46
|
+
props['url'] = config.url
|
|
47
|
+
props['realm'] = config.realm
|
|
48
|
+
props['clientId'] = config.client_id
|
|
49
|
+
|
|
50
|
+
props['initOptions'] = init_options if init_options else {}
|
|
51
|
+
|
|
52
|
+
def token(self) -> AwaitableResponse:
|
|
53
|
+
"""
|
|
54
|
+
Get a token that can be sent in the Authorization header in requests to services.
|
|
55
|
+
|
|
56
|
+
:return: base64 encoded token
|
|
57
|
+
"""
|
|
58
|
+
return self.run_method('token')
|
|
59
|
+
|
|
60
|
+
def refresh_token(self) -> AwaitableResponse:
|
|
61
|
+
"""
|
|
62
|
+
Get a refresh token that can be used to retrieve a new token.
|
|
63
|
+
|
|
64
|
+
:return: base64 encoded refresh token
|
|
65
|
+
"""
|
|
66
|
+
return self.run_method('refreshToken')
|
|
67
|
+
|
|
68
|
+
def authenticated(self) -> AwaitableResponse:
|
|
69
|
+
"""
|
|
70
|
+
Returns true if the user is authenticated, false otherwise.
|
|
71
|
+
|
|
72
|
+
:return: whether the used is authenticated
|
|
73
|
+
"""
|
|
74
|
+
return self.run_method('authenticated')
|
|
75
|
+
|
|
76
|
+
async def login(self, options: Dict = None) -> None:
|
|
77
|
+
"""
|
|
78
|
+
Redirects to login form.
|
|
79
|
+
See keycloak-js api reference
|
|
80
|
+
for more info about available options.
|
|
81
|
+
|
|
82
|
+
:param options: optional object
|
|
83
|
+
"""
|
|
84
|
+
await self.run_method('login', options if options else {})
|
|
85
|
+
|
|
86
|
+
async def logout(self, options: Dict = None) -> None:
|
|
87
|
+
"""
|
|
88
|
+
Redirects to logout.
|
|
89
|
+
See keycloak-js api reference
|
|
90
|
+
for more info about available options.
|
|
91
|
+
|
|
92
|
+
:param options: optional object
|
|
93
|
+
"""
|
|
94
|
+
await self.run_method('logout', options if options else {})
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"""
|
|
2
|
+
A single page router enabling navigation without page reloading.
|
|
3
|
+
"""
|
|
1
4
|
from functools import singledispatchmethod
|
|
2
5
|
from typing import Callable, Dict, Optional, AnyStr, Union, Any
|
|
3
6
|
|
|
@@ -12,18 +15,33 @@ class _RouterFrame(ui.element, component='router_frame.js'):
|
|
|
12
15
|
props: Dict[AnyStr, Any] = self._props
|
|
13
16
|
props['checkInterval'] = check_interval
|
|
14
17
|
|
|
15
|
-
def update_history(self, path):
|
|
18
|
+
def update_history(self, path) -> None:
|
|
19
|
+
"""
|
|
20
|
+
Update browser history.
|
|
21
|
+
You do not need to call this directly.
|
|
22
|
+
|
|
23
|
+
:param path: path to add to the history
|
|
24
|
+
"""
|
|
16
25
|
self.run_method('updateHistory', path)
|
|
17
26
|
|
|
18
27
|
|
|
19
28
|
class Router:
|
|
29
|
+
"""
|
|
30
|
+
Single page router.
|
|
31
|
+
"""
|
|
20
32
|
|
|
21
33
|
def __init__(self, check_interval: int = None) -> None:
|
|
22
34
|
self.routes: Dict[AnyStr, Callable] = {}
|
|
23
35
|
self.content: Optional[ui.element] = None
|
|
24
36
|
self.router_frame: _RouterFrame = _RouterFrame(check_interval if check_interval else 10)
|
|
25
37
|
|
|
26
|
-
def path(self, path:
|
|
38
|
+
def path(self, path: AnyStr):
|
|
39
|
+
"""
|
|
40
|
+
Decorator method. Register a path with this router.
|
|
41
|
+
|
|
42
|
+
:param path: path to register
|
|
43
|
+
"""
|
|
44
|
+
|
|
27
45
|
def decorator(func: Callable):
|
|
28
46
|
self.routes[path] = func
|
|
29
47
|
return func
|
|
@@ -31,7 +49,12 @@ class Router:
|
|
|
31
49
|
return decorator
|
|
32
50
|
|
|
33
51
|
@singledispatchmethod
|
|
34
|
-
def go_to(self, target: Union[Callable, AnyStr]):
|
|
52
|
+
def go_to(self, target: Union[Callable, AnyStr]) -> None:
|
|
53
|
+
"""
|
|
54
|
+
Navigate to another registered page.
|
|
55
|
+
|
|
56
|
+
:param target: page to go to
|
|
57
|
+
"""
|
|
35
58
|
path = {target: path for path, target in self.routes.items()}[target]
|
|
36
59
|
self.go_to(path)
|
|
37
60
|
|
|
@@ -51,5 +74,10 @@ class Router:
|
|
|
51
74
|
background_tasks.create(build())
|
|
52
75
|
|
|
53
76
|
def frame(self) -> ui.element:
|
|
77
|
+
"""
|
|
78
|
+
Add content to page.
|
|
79
|
+
|
|
80
|
+
:return: the ui element to display
|
|
81
|
+
"""
|
|
54
82
|
self.content = self.router_frame.on('open', lambda e: self.go_to(e.args))
|
|
55
83
|
return self.content
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nice_gui_utils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1.dev1
|
|
4
4
|
Summary: Utils to use with NiceGUI.
|
|
5
5
|
Author: Harter Kern
|
|
6
6
|
Project-URL: Homepage, https://gitlab.com/harter-kern-public/nice-gui-utils
|
|
@@ -13,6 +13,9 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: nicegui>=1.4.0
|
|
15
15
|
|
|
16
|
-
#
|
|
16
|
+
# nice_gui_utils - a collection of utilities for [nicegui](https://nicegui.io/)
|
|
17
17
|
|
|
18
|
+
## [Documentation](https://nice-gui-utils-harter-kern-8e1d5c74ce521b132e29aa9329b109a50ad7.gitlab.io)
|
|
19
|
+
|
|
20
|
+
## Pipeline status
|
|
18
21
|
[](https://gitlab.com/harter-kern/nice-gui-utils/-/commits/main)
|
nice_gui_utils-0.2.4/README.md
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .keycloak import KeycloakConfig, Keycloak
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass
|
|
2
|
-
from typing import AnyStr, Dict, Any
|
|
3
|
-
|
|
4
|
-
from nicegui import ui
|
|
5
|
-
from nicegui.awaitable_response import AwaitableResponse
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@dataclass
|
|
9
|
-
class KeycloakConfig:
|
|
10
|
-
url: AnyStr
|
|
11
|
-
realm: AnyStr
|
|
12
|
-
client_id: AnyStr
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class Keycloak(ui.element, component='keycloak.js'):
|
|
16
|
-
config: KeycloakConfig = None
|
|
17
|
-
require_login: bool = None
|
|
18
|
-
|
|
19
|
-
def __init__(self,
|
|
20
|
-
config: KeycloakConfig,
|
|
21
|
-
js_source: AnyStr = '/static/keycloak.js',
|
|
22
|
-
init_options: Dict = None):
|
|
23
|
-
super().__init__()
|
|
24
|
-
|
|
25
|
-
ui.add_head_html(f'<script src="{js_source}"></script>')
|
|
26
|
-
|
|
27
|
-
props: Dict[str, Any] = self._props
|
|
28
|
-
props['url'] = config.url
|
|
29
|
-
props['realm'] = config.realm
|
|
30
|
-
props['clientId'] = config.client_id
|
|
31
|
-
|
|
32
|
-
props['initOptions'] = init_options if init_options else {}
|
|
33
|
-
|
|
34
|
-
def token(self) -> AwaitableResponse:
|
|
35
|
-
return self.run_method('token')
|
|
36
|
-
|
|
37
|
-
def refresh_token(self) -> AwaitableResponse:
|
|
38
|
-
return self.run_method('refreshToken')
|
|
39
|
-
|
|
40
|
-
def authenticated(self) -> AwaitableResponse:
|
|
41
|
-
return self.run_method('authenticated')
|
|
42
|
-
|
|
43
|
-
def login(self, options=None) -> AwaitableResponse:
|
|
44
|
-
return self.run_method('login', options if options else {})
|
|
45
|
-
|
|
46
|
-
def logout(self, options=None) -> AwaitableResponse:
|
|
47
|
-
return self.run_method('logout', options if options else {})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .router import Router
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils/keycloak_js/keycloak.js
RENAMED
|
File without changes
|
{nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils/router/router_frame.js
RENAMED
|
File without changes
|
|
File without changes
|
{nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{nice_gui_utils-0.2.4 → nice_gui_utils-0.3.1.dev1}/src/nice_gui_utils.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|