meerschaum 2.4.0.dev1__py3-none-any.whl → 2.4.0rc2__py3-none-any.whl
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.
- meerschaum/_internal/arguments/_parse_arguments.py +2 -5
- meerschaum/_internal/docs/index.py +3 -2
- meerschaum/_internal/entry.py +13 -7
- meerschaum/_internal/shell/Shell.py +38 -44
- meerschaum/_internal/term/TermPageHandler.py +2 -3
- meerschaum/_internal/term/__init__.py +13 -11
- meerschaum/actions/api.py +10 -7
- meerschaum/actions/bootstrap.py +2 -1
- meerschaum/actions/delete.py +4 -1
- meerschaum/actions/register.py +1 -3
- meerschaum/actions/stack.py +24 -19
- meerschaum/actions/start.py +25 -26
- meerschaum/actions/sync.py +53 -52
- meerschaum/api/__init__.py +48 -14
- meerschaum/api/_events.py +15 -10
- meerschaum/api/_oauth2.py +2 -2
- meerschaum/api/_websockets.py +5 -4
- meerschaum/api/dash/__init__.py +1 -11
- meerschaum/api/dash/callbacks/dashboard.py +47 -55
- meerschaum/api/dash/callbacks/jobs.py +15 -16
- meerschaum/api/dash/callbacks/login.py +16 -10
- meerschaum/api/dash/callbacks/pipes.py +3 -4
- meerschaum/api/dash/callbacks/plugins.py +1 -1
- meerschaum/api/dash/callbacks/register.py +15 -11
- meerschaum/api/dash/components.py +54 -59
- meerschaum/api/dash/jobs.py +5 -9
- meerschaum/api/dash/pages/pipes.py +4 -1
- meerschaum/api/dash/pipes.py +13 -17
- meerschaum/api/dash/plugins.py +6 -4
- meerschaum/api/dash/sessions.py +176 -0
- meerschaum/api/dash/users.py +2 -53
- meerschaum/api/dash/webterm.py +12 -17
- meerschaum/api/resources/static/js/terminado.js +1 -1
- meerschaum/api/routes/_actions.py +4 -20
- meerschaum/api/routes/_jobs.py +8 -7
- meerschaum/api/routes/_webterm.py +5 -6
- meerschaum/config/_default.py +6 -1
- meerschaum/config/_version.py +1 -1
- meerschaum/config/stack/__init__.py +9 -7
- meerschaum/config/static/__init__.py +4 -0
- meerschaum/connectors/__init__.py +15 -9
- meerschaum/connectors/api/{APIConnector.py → _APIConnector.py} +3 -1
- meerschaum/connectors/api/__init__.py +2 -1
- meerschaum/connectors/parse.py +18 -16
- meerschaum/connectors/sql/__init__.py +3 -1
- meerschaum/connectors/sql/_pipes.py +39 -39
- meerschaum/connectors/valkey/{ValkeyConnector.py → _ValkeyConnector.py} +5 -5
- meerschaum/connectors/valkey/__init__.py +3 -1
- meerschaum/connectors/valkey/_pipes.py +13 -8
- meerschaum/core/Pipe/_data.py +155 -100
- meerschaum/jobs/_Job.py +1 -6
- meerschaum/jobs/__init__.py +7 -2
- meerschaum/utils/dataframe.py +4 -1
- meerschaum/utils/formatting/_shell.py +5 -6
- meerschaum/utils/packages/__init__.py +14 -9
- {meerschaum-2.4.0.dev1.dist-info → meerschaum-2.4.0rc2.dist-info}/METADATA +1 -1
- {meerschaum-2.4.0.dev1.dist-info → meerschaum-2.4.0rc2.dist-info}/RECORD +65 -65
- {meerschaum-2.4.0.dev1.dist-info → meerschaum-2.4.0rc2.dist-info}/WHEEL +1 -1
- meerschaum/api/dash/actions.py +0 -255
- /meerschaum/connectors/{Connector.py → _Connector.py} +0 -0
- /meerschaum/connectors/sql/{SQLConnector.py → _SQLConnector.py} +0 -0
- {meerschaum-2.4.0.dev1.dist-info → meerschaum-2.4.0rc2.dist-info}/LICENSE +0 -0
- {meerschaum-2.4.0.dev1.dist-info → meerschaum-2.4.0rc2.dist-info}/NOTICE +0 -0
- {meerschaum-2.4.0.dev1.dist-info → meerschaum-2.4.0rc2.dist-info}/entry_points.txt +0 -0
- {meerschaum-2.4.0.dev1.dist-info → meerschaum-2.4.0rc2.dist-info}/top_level.txt +0 -0
- {meerschaum-2.4.0.dev1.dist-info → meerschaum-2.4.0rc2.dist-info}/zip-safe +0 -0
@@ -7,18 +7,21 @@ Callbacks for the main dashboard.
|
|
7
7
|
"""
|
8
8
|
|
9
9
|
from __future__ import annotations
|
10
|
-
|
10
|
+
|
11
|
+
import textwrap
|
12
|
+
import json
|
13
|
+
import uuid
|
11
14
|
from dash.dependencies import Input, Output, State, ALL, MATCH
|
12
15
|
from dash.exceptions import PreventUpdate
|
13
|
-
from meerschaum.config import get_config
|
14
|
-
from meerschaum.config.static import _static_config
|
15
16
|
from meerschaum.utils.typing import List, Optional, Any, Tuple
|
16
17
|
from meerschaum.api import get_api_connector, endpoints, no_auth, CHECK_UPDATE
|
17
|
-
from meerschaum.api.dash import
|
18
|
-
|
19
|
-
|
18
|
+
from meerschaum.api.dash import dash_app, debug
|
19
|
+
from meerschaum.api.dash.sessions import (
|
20
|
+
is_session_active,
|
21
|
+
delete_session,
|
22
|
+
set_session,
|
20
23
|
)
|
21
|
-
from meerschaum.api.dash.
|
24
|
+
from meerschaum.api.dash.sessions import is_session_authenticated
|
22
25
|
from meerschaum.api.dash.connectors import get_web_connector
|
23
26
|
from meerschaum.connectors.parse import parse_instance_keys
|
24
27
|
from meerschaum.api.dash.pipes import get_pipes_cards, pipe_from_ctx, accordion_items_from_pipe
|
@@ -30,21 +33,14 @@ from meerschaum.api.dash.webterm import get_webterm
|
|
30
33
|
from meerschaum.api.dash.components import (
|
31
34
|
alert_from_success_tuple, console_div, build_cards_grid,
|
32
35
|
)
|
33
|
-
from meerschaum.api.dash
|
34
|
-
import meerschaum.api.dash.pages as pages
|
36
|
+
from meerschaum.api.dash import pages
|
35
37
|
from meerschaum.utils.typing import Dict
|
36
|
-
from meerschaum.utils.debug import dprint
|
37
38
|
from meerschaum.utils.packages import attempt_import, import_html, import_dcc
|
38
|
-
from meerschaum.utils.misc import
|
39
|
-
string_to_dict, get_connector_labels, json_serialize_datetime, filter_keywords,
|
40
|
-
flatten_list,
|
41
|
-
)
|
39
|
+
from meerschaum.utils.misc import filter_keywords, flatten_list
|
42
40
|
from meerschaum.utils.yaml import yaml
|
43
41
|
from meerschaum.actions import get_subactions, actions
|
44
|
-
from meerschaum._internal.arguments._parser import
|
42
|
+
from meerschaum._internal.arguments._parser import parser
|
45
43
|
from meerschaum.connectors.sql._fetch import set_pipe_query
|
46
|
-
import meerschaum as mrsm
|
47
|
-
import json
|
48
44
|
dash = attempt_import('dash', lazy=False, check_update=CHECK_UPDATE)
|
49
45
|
dbc = attempt_import('dash_bootstrap_components', lazy=False, check_update=CHECK_UPDATE)
|
50
46
|
dcc, html = import_dcc(check_update=CHECK_UPDATE), import_html(check_update=CHECK_UPDATE)
|
@@ -109,12 +105,12 @@ _required_login = {''}
|
|
109
105
|
@dash_app.callback(
|
110
106
|
Output('page-layout-div', 'children'),
|
111
107
|
Output('session-store', 'data'),
|
112
|
-
Input('location', 'pathname'),
|
108
|
+
Input('mrsm-location', 'pathname'),
|
113
109
|
Input('session-store', 'data'),
|
114
|
-
State('location', 'href'),
|
110
|
+
State('mrsm-location', 'href'),
|
115
111
|
)
|
116
112
|
def update_page_layout_div(
|
117
|
-
pathname: str,
|
113
|
+
pathname: str,
|
118
114
|
session_store_data: Dict[str, Any],
|
119
115
|
location_href: str,
|
120
116
|
) -> Tuple[List[Any], Dict[str, Any]]:
|
@@ -123,7 +119,7 @@ def update_page_layout_div(
|
|
123
119
|
|
124
120
|
Parameters
|
125
121
|
----------
|
126
|
-
pathname: str
|
122
|
+
pathname: str
|
127
123
|
The path in the browser.
|
128
124
|
|
129
125
|
session_store_data: Dict[str, Any]:
|
@@ -133,7 +129,6 @@ def update_page_layout_div(
|
|
133
129
|
-------
|
134
130
|
A tuple of the page layout and new session store data.
|
135
131
|
"""
|
136
|
-
ctx = dash.callback_context
|
137
132
|
dash_endpoint = endpoints['dash']
|
138
133
|
try:
|
139
134
|
session_id = session_store_data.get('session-id', None)
|
@@ -141,12 +136,12 @@ def update_page_layout_div(
|
|
141
136
|
session_id = None
|
142
137
|
|
143
138
|
### Bypass login if `--no-auth` is specified.
|
144
|
-
if
|
139
|
+
if not is_session_active(session_id) and no_auth:
|
145
140
|
session_store_data['session-id'] = str(uuid.uuid4())
|
146
|
-
|
141
|
+
set_session(session_id, {'username': 'no-auth'})
|
147
142
|
|
148
143
|
### Sometimes the href is an empty string, so store it here for later.
|
149
|
-
session_store_data['location.href'] = location_href
|
144
|
+
session_store_data['mrsm-location.href'] = location_href
|
150
145
|
session_store_to_return = session_store_data
|
151
146
|
else:
|
152
147
|
session_store_to_return = dash.no_update
|
@@ -176,7 +171,7 @@ def update_page_layout_div(
|
|
176
171
|
path_str
|
177
172
|
if no_auth or path_str not in _required_login else (
|
178
173
|
path_str
|
179
|
-
if session_id
|
174
|
+
if is_session_active(session_id)
|
180
175
|
else 'login'
|
181
176
|
)
|
182
177
|
)
|
@@ -195,7 +190,7 @@ def update_page_layout_div(
|
|
195
190
|
Input('get-plugins-button', 'n_clicks'),
|
196
191
|
Input('get-users-button', 'n_clicks'),
|
197
192
|
Input('get-graphs-button', 'n_clicks'),
|
198
|
-
State('location', 'href'),
|
193
|
+
State('mrsm-location', 'href'),
|
199
194
|
State('session-store', 'data'),
|
200
195
|
State('webterm-div', 'children'),
|
201
196
|
*keys_state,
|
@@ -206,7 +201,6 @@ def update_content(*args):
|
|
206
201
|
and execute the appropriate function.
|
207
202
|
"""
|
208
203
|
ctx = dash.callback_context
|
209
|
-
location_href = ctx.states['session-store.data'].get('location.href', None)
|
210
204
|
session_id = ctx.states['session-store.data'].get('session-id', None)
|
211
205
|
authenticated = is_session_authenticated(str(session_id))
|
212
206
|
|
@@ -238,9 +232,6 @@ def update_content(*args):
|
|
238
232
|
'get-pipes-button': 1,
|
239
233
|
'get-jobs-button': 2,
|
240
234
|
}
|
241
|
-
|
242
|
-
### NOTE: stop the running action if it exists
|
243
|
-
stop_action(ctx.states)
|
244
235
|
|
245
236
|
content, alerts = triggers[trigger](
|
246
237
|
ctx.states,
|
@@ -312,9 +303,9 @@ dash_app.clientside_callback(
|
|
312
303
|
return url;
|
313
304
|
}
|
314
305
|
""",
|
315
|
-
Output('location', 'href'),
|
306
|
+
Output('mrsm-location', 'href'),
|
316
307
|
Input('go-button', 'n_clicks'),
|
317
|
-
State('location', 'href'),
|
308
|
+
State('mrsm-location', 'href'),
|
318
309
|
State('connector-keys-dropdown', 'value'),
|
319
310
|
State('metric-keys-dropdown', 'value'),
|
320
311
|
State('location-keys-dropdown', 'value'),
|
@@ -491,12 +482,12 @@ def update_flags(input_flags_dropdown_values, n_clicks, input_flags_texts):
|
|
491
482
|
*keys_state
|
492
483
|
)
|
493
484
|
def update_keys_options(
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
485
|
+
connector_keys: Optional[List[str]],
|
486
|
+
metric_keys: Optional[List[str]],
|
487
|
+
location_keys: Optional[List[str]],
|
488
|
+
instance_keys: Optional[str],
|
489
|
+
*keys
|
490
|
+
):
|
500
491
|
"""
|
501
492
|
Update the keys dropdown menus' options.
|
502
493
|
"""
|
@@ -544,9 +535,9 @@ def update_keys_options(
|
|
544
535
|
_keys = fetch_pipes_keys(
|
545
536
|
'registered',
|
546
537
|
get_web_connector(ctx.states),
|
547
|
-
connector_keys
|
548
|
-
metric_keys
|
549
|
-
location_keys
|
538
|
+
connector_keys=_ck_filter,
|
539
|
+
metric_keys=_mk_filter,
|
540
|
+
location_keys=_lk_filter,
|
550
541
|
)
|
551
542
|
except Exception as e:
|
552
543
|
instance_alerts += [alert_from_success_tuple((False, str(e)))]
|
@@ -638,7 +629,7 @@ dash_app.clientside_callback(
|
|
638
629
|
return url;
|
639
630
|
}
|
640
631
|
""",
|
641
|
-
Output('location', 'href'),
|
632
|
+
Output('mrsm-location', 'href'),
|
642
633
|
Input('instance-select', 'value'),
|
643
634
|
)
|
644
635
|
|
@@ -711,11 +702,12 @@ dash_app.clientside_callback(
|
|
711
702
|
return url;
|
712
703
|
}
|
713
704
|
""",
|
714
|
-
Output('location', 'href'),
|
705
|
+
Output('mrsm-location', 'href'),
|
715
706
|
Input('console-pre', 'children'),
|
716
|
-
State('location', 'href'),
|
707
|
+
State('mrsm-location', 'href'),
|
717
708
|
)
|
718
709
|
|
710
|
+
|
719
711
|
@dash_app.callback(
|
720
712
|
Output("download-dataframe-csv", "data"),
|
721
713
|
Input({'type': 'pipe-download-csv-button', 'index': ALL}, 'n_clicks'),
|
@@ -737,7 +729,7 @@ def download_pipe_csv(n_clicks):
|
|
737
729
|
filename = str(pipe.target) + f" {begin} - {end}.csv"
|
738
730
|
try:
|
739
731
|
df = pipe.get_data(begin=begin, end=end, debug=debug)
|
740
|
-
except Exception
|
732
|
+
except Exception:
|
741
733
|
df = None
|
742
734
|
if df is not None:
|
743
735
|
return dcc.send_data_frame(df.to_csv, filename, index=False)
|
@@ -750,6 +742,9 @@ def download_pipe_csv(n_clicks):
|
|
750
742
|
State('session-store', 'data'),
|
751
743
|
)
|
752
744
|
def update_pipe_accordion(item, session_store_data):
|
745
|
+
"""
|
746
|
+
Expand the pipe accordion item and lazy load.
|
747
|
+
"""
|
753
748
|
if item is None:
|
754
749
|
raise PreventUpdate
|
755
750
|
|
@@ -761,7 +756,6 @@ def update_pipe_accordion(item, session_store_data):
|
|
761
756
|
raise PreventUpdate
|
762
757
|
|
763
758
|
session_id = session_store_data.get('session-id', None)
|
764
|
-
print(f"{session_id=}")
|
765
759
|
authenticated = is_session_authenticated(str(session_id))
|
766
760
|
return accordion_items_from_pipe(pipe, active_items=[item], authenticated=authenticated)
|
767
761
|
|
@@ -920,7 +914,7 @@ dash_app.clientside_callback(
|
|
920
914
|
""",
|
921
915
|
Output('content-div-right', 'children'),
|
922
916
|
Input({'type': 'manage-pipe-button', 'index': ALL, 'action': ALL}, 'n_clicks'),
|
923
|
-
State('location', 'href'),
|
917
|
+
State('mrsm-location', 'href'),
|
924
918
|
)
|
925
919
|
|
926
920
|
@dash_app.callback(
|
@@ -950,15 +944,15 @@ def toggle_navbar_collapse(n_clicks: Optional[int], is_open: bool) -> bool:
|
|
950
944
|
|
951
945
|
|
952
946
|
@dash_app.callback(
|
953
|
-
Output('location', 'pathname'),
|
947
|
+
Output('mrsm-location', 'pathname'),
|
954
948
|
Output('session-store', 'data'),
|
955
949
|
Input("sign-out-button", "n_clicks"),
|
956
950
|
State('session-store', 'data'),
|
957
951
|
)
|
958
952
|
def sign_out_button_click(
|
959
|
-
|
960
|
-
|
961
|
-
|
953
|
+
n_clicks: Optional[int],
|
954
|
+
session_store_data: Dict[str, Any],
|
955
|
+
):
|
962
956
|
"""
|
963
957
|
When the sign out button is clicked, remove the session data and redirect to the login page.
|
964
958
|
"""
|
@@ -966,9 +960,7 @@ def sign_out_button_click(
|
|
966
960
|
raise PreventUpdate
|
967
961
|
session_id = session_store_data.get('session-id', None)
|
968
962
|
if session_id:
|
969
|
-
|
970
|
-
_ = authenticated_sessions.pop(session_id, None)
|
971
|
-
_ = unauthenticated_sessions.pop(session_id, None)
|
963
|
+
delete_session(session_id)
|
972
964
|
return endpoints['dash'], {}
|
973
965
|
|
974
966
|
|
@@ -7,36 +7,35 @@ Callbacks for jobs' cards.
|
|
7
7
|
"""
|
8
8
|
|
9
9
|
from __future__ import annotations
|
10
|
+
|
10
11
|
import json
|
11
|
-
import functools
|
12
12
|
import time
|
13
13
|
import traceback
|
14
14
|
from datetime import datetime, timezone
|
15
|
-
import meerschaum as mrsm
|
16
15
|
from meerschaum.utils.typing import Optional, Dict, Any
|
17
|
-
from meerschaum.api import
|
18
|
-
from meerschaum.api.dash import dash_app
|
16
|
+
from meerschaum.api import CHECK_UPDATE
|
17
|
+
from meerschaum.api.dash import dash_app
|
18
|
+
from meerschaum.api.dash.sessions import get_username_from_session
|
19
19
|
from meerschaum.utils.packages import attempt_import, import_dcc, import_html
|
20
|
-
|
21
|
-
from dash.exceptions import PreventUpdate
|
22
|
-
from dash.dependencies import Input, Output, State, ALL, MATCH
|
23
|
-
from dash import Patch
|
24
|
-
html, dcc = import_html(check_update=CHECK_UPDATE), import_dcc(check_update=CHECK_UPDATE)
|
25
|
-
import dash_bootstrap_components as dbc
|
26
|
-
from meerschaum.api.dash.components import alert_from_success_tuple, build_cards_grid
|
27
|
-
from dash.exceptions import PreventUpdate
|
20
|
+
from meerschaum.api.dash.components import alert_from_success_tuple
|
28
21
|
from meerschaum.api.dash.jobs import (
|
29
22
|
build_manage_job_buttons_div_children,
|
30
23
|
build_status_children,
|
31
24
|
build_process_timestamps_children,
|
32
25
|
)
|
33
26
|
from meerschaum.jobs import Job
|
34
|
-
from meerschaum.api.dash.
|
27
|
+
from meerschaum.api.dash.sessions import is_session_authenticated
|
28
|
+
dash = attempt_import('dash', lazy=False, check_update=CHECK_UPDATE)
|
29
|
+
html, dcc = import_html(check_update=CHECK_UPDATE), import_dcc(check_update=CHECK_UPDATE)
|
30
|
+
from dash.exceptions import PreventUpdate
|
31
|
+
from dash.dependencies import Input, Output, State, ALL, MATCH
|
32
|
+
import dash_bootstrap_components as dbc
|
33
|
+
|
35
34
|
|
36
35
|
@dash_app.callback(
|
37
36
|
Output("download-logs", "data"),
|
38
37
|
Input({'type': 'job-download-logs-button', 'index': ALL}, 'n_clicks'),
|
39
|
-
prevent_initial_call
|
38
|
+
prevent_initial_call=True,
|
40
39
|
)
|
41
40
|
def download_job_logs(n_clicks):
|
42
41
|
"""
|
@@ -84,7 +83,7 @@ def manage_job_button_click(
|
|
84
83
|
raise PreventUpdate
|
85
84
|
|
86
85
|
session_id = session_data.get('session-id', None)
|
87
|
-
username =
|
86
|
+
username = get_username_from_session(session_id)
|
88
87
|
|
89
88
|
if not is_session_authenticated(session_id):
|
90
89
|
success, msg = False, f"User '{username}' is not authenticated to manage jobs."
|
@@ -182,7 +181,7 @@ dash_app.clientside_callback(
|
|
182
181
|
""",
|
183
182
|
Output('content-div-right', 'children'),
|
184
183
|
Input({'type': 'follow-logs-button', 'index': ALL}, 'n_clicks'),
|
185
|
-
State('location', 'href'),
|
184
|
+
State('mrsm-location', 'href'),
|
186
185
|
)
|
187
186
|
|
188
187
|
|
@@ -7,14 +7,17 @@ Callbacks for the login page.
|
|
7
7
|
"""
|
8
8
|
|
9
9
|
from __future__ import annotations
|
10
|
-
from meerschaum.api import endpoints, no_auth, CHECK_UPDATE
|
11
|
-
from meerschaum.utils.packages import attempt_import, import_html, import_dcc
|
12
|
-
dash = attempt_import('dash', lazy=False, check_update=CHECK_UPDATE)
|
13
10
|
import uuid
|
11
|
+
|
12
|
+
from meerschaum.api import CHECK_UPDATE
|
13
|
+
from meerschaum.utils.packages import attempt_import, import_html, import_dcc
|
14
14
|
from meerschaum.utils.typing import Optional
|
15
|
+
|
16
|
+
dash = attempt_import('dash', lazy=False, check_update=CHECK_UPDATE)
|
15
17
|
from dash.exceptions import PreventUpdate
|
16
18
|
from dash.dependencies import Input, Output, State
|
17
|
-
from meerschaum.api.dash import dash_app, debug, pipes, _get_pipes
|
19
|
+
from meerschaum.api.dash import dash_app, debug, pipes, _get_pipes
|
20
|
+
from meerschaum.api.dash.sessions import set_session
|
18
21
|
from meerschaum.api.dash.connectors import get_web_connector
|
19
22
|
from meerschaum.api.routes._login import login
|
20
23
|
from meerschaum.api.dash.components import alert_from_success_tuple
|
@@ -23,6 +26,7 @@ from fastapi.exceptions import HTTPException
|
|
23
26
|
dbc = attempt_import('dash_bootstrap_components', lazy=False, check_update=CHECK_UPDATE)
|
24
27
|
html, dcc = import_html(check_update=CHECK_UPDATE), import_dcc(check_update=CHECK_UPDATE)
|
25
28
|
|
29
|
+
|
26
30
|
@dash_app.callback(
|
27
31
|
Output('user-registration-disabled-collapse', 'is_open'),
|
28
32
|
Input('show-user-registration-disabled-button', 'n_clicks'),
|
@@ -36,18 +40,19 @@ def show_registration_disabled_collapse(n_clicks, is_open):
|
|
36
40
|
return not is_open
|
37
41
|
return is_open
|
38
42
|
|
43
|
+
|
39
44
|
@dash_app.callback(
|
40
45
|
Output('session-store', 'data'),
|
41
46
|
Output('username-input', 'className'),
|
42
|
-
Output('location', 'pathname'),
|
47
|
+
Output('mrsm-location', 'pathname'),
|
43
48
|
Output('login-alert-div', 'children'),
|
44
49
|
Input('username-input', 'n_submit'),
|
45
50
|
Input('password-input', 'n_submit'),
|
46
51
|
Input('login-button', 'n_clicks'),
|
47
52
|
State('username-input', 'value'),
|
48
53
|
State('password-input', 'value'),
|
49
|
-
State('location', 'href'),
|
50
|
-
State('location', 'pathname'),
|
54
|
+
State('mrsm-location', 'href'),
|
55
|
+
State('mrsm-location', 'pathname'),
|
51
56
|
)
|
52
57
|
def login_button_click(
|
53
58
|
username_submit,
|
@@ -69,11 +74,12 @@ def login_button_click(
|
|
69
74
|
|
70
75
|
try:
|
71
76
|
_ = login({'username': username, 'password': password})
|
77
|
+
session_id = str(uuid.uuid4())
|
72
78
|
session_data = {
|
73
|
-
'session-id':
|
74
|
-
'location.href': location_href,
|
79
|
+
'session-id': session_id,
|
80
|
+
'mrsm-location.href': location_href,
|
75
81
|
}
|
76
|
-
|
82
|
+
set_session(session_id, {'username': username})
|
77
83
|
alerts = []
|
78
84
|
except HTTPException:
|
79
85
|
form_class += ' is-invalid'
|
@@ -5,14 +5,13 @@
|
|
5
5
|
Define callbacks for the `/dash/pipes/` page.
|
6
6
|
"""
|
7
7
|
|
8
|
-
from dash.
|
9
|
-
from dash.dependencies import Input, Output, State
|
8
|
+
from dash.dependencies import Input, Output
|
10
9
|
from dash import no_update
|
11
10
|
|
12
11
|
import meerschaum as mrsm
|
13
|
-
from meerschaum.api.dash import dash_app
|
12
|
+
from meerschaum.api.dash import dash_app
|
14
13
|
from meerschaum.api.dash.pipes import build_pipe_card
|
15
|
-
from meerschaum.api import
|
14
|
+
from meerschaum.api import CHECK_UPDATE
|
16
15
|
from meerschaum.utils.packages import import_html, import_dcc
|
17
16
|
html, dcc = import_html(check_update=CHECK_UPDATE), import_dcc(check_update=CHECK_UPDATE)
|
18
17
|
|
@@ -9,7 +9,7 @@ Callbacks for the plugins page.
|
|
9
9
|
from __future__ import annotations
|
10
10
|
import json
|
11
11
|
from meerschaum.utils.typing import Optional, Dict, Any
|
12
|
-
from meerschaum.api.dash import dash_app, debug
|
12
|
+
from meerschaum.api.dash import dash_app, debug
|
13
13
|
from meerschaum.api import get_api_connector, endpoints, CHECK_UPDATE
|
14
14
|
from meerschaum.core import Plugin
|
15
15
|
from meerschaum.utils.packages import attempt_import, import_dcc, import_html
|
@@ -8,7 +8,8 @@ Callbacks for the registration page.
|
|
8
8
|
|
9
9
|
import uuid
|
10
10
|
from meerschaum.api import get_api_connector, endpoints, CHECK_UPDATE
|
11
|
-
from meerschaum.api.dash import dash_app, debug
|
11
|
+
from meerschaum.api.dash import dash_app, debug
|
12
|
+
from meerschaum.api.dash.sessions import set_session
|
12
13
|
from dash.dependencies import Input, Output, State, ALL, MATCH
|
13
14
|
from dash.exceptions import PreventUpdate
|
14
15
|
from meerschaum.core import User
|
@@ -57,7 +58,7 @@ def validate_email(email):
|
|
57
58
|
@dash_app.callback(
|
58
59
|
Output('session-store', 'data'),
|
59
60
|
Output('register-username-input', 'className'),
|
60
|
-
Output('location', 'pathname'),
|
61
|
+
Output('mrsm-location', 'pathname'),
|
61
62
|
Input('register-username-input', 'n_submit'),
|
62
63
|
Input('register-password-input', 'n_submit'),
|
63
64
|
Input('register-button', 'n_clicks'),
|
@@ -66,13 +67,16 @@ def validate_email(email):
|
|
66
67
|
State("register-email-input", "value"),
|
67
68
|
)
|
68
69
|
def register_button_click(
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
username_submit,
|
71
|
+
password_submit,
|
72
|
+
n_clicks,
|
73
|
+
username,
|
74
|
+
password,
|
75
|
+
email,
|
76
|
+
):
|
77
|
+
"""
|
78
|
+
Register the user and redirect to the console.
|
79
|
+
"""
|
76
80
|
if not n_clicks:
|
77
81
|
raise PreventUpdate
|
78
82
|
form_class = 'form-control'
|
@@ -93,9 +97,9 @@ def register_button_click(
|
|
93
97
|
form_class += ' is-invalid'
|
94
98
|
return {}, form_class, dash.no_update
|
95
99
|
try:
|
96
|
-
|
100
|
+
_ = login({'username': username, 'password': password})
|
97
101
|
session_data = {'session-id': str(uuid.uuid4())}
|
98
|
-
|
102
|
+
set_session(session_data['session-id'], {'username': username})
|
99
103
|
except HTTPException as e:
|
100
104
|
form_class += ' is-invalid'
|
101
105
|
session_data = None
|