meerschaum 2.9.4__py3-none-any.whl → 3.0.0rc1__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/__init__.py +5 -2
- meerschaum/_internal/__init__.py +1 -0
- meerschaum/_internal/arguments/_parse_arguments.py +4 -4
- meerschaum/_internal/arguments/_parser.py +17 -1
- meerschaum/_internal/entry.py +6 -6
- meerschaum/_internal/shell/Shell.py +1 -1
- meerschaum/_internal/static.py +372 -0
- meerschaum/actions/api.py +12 -2
- meerschaum/actions/bootstrap.py +7 -7
- meerschaum/actions/edit.py +142 -18
- meerschaum/actions/register.py +137 -6
- meerschaum/actions/show.py +117 -29
- meerschaum/actions/stop.py +4 -1
- meerschaum/actions/sync.py +1 -1
- meerschaum/actions/tag.py +9 -8
- meerschaum/api/__init__.py +9 -2
- meerschaum/api/_events.py +39 -2
- meerschaum/api/_oauth2.py +118 -8
- meerschaum/api/_tokens.py +102 -0
- meerschaum/api/dash/__init__.py +0 -1
- meerschaum/api/dash/callbacks/custom.py +2 -2
- meerschaum/api/dash/callbacks/dashboard.py +133 -18
- meerschaum/api/dash/callbacks/plugins.py +0 -1
- meerschaum/api/dash/callbacks/register.py +1 -1
- meerschaum/api/dash/callbacks/settings/__init__.py +1 -0
- meerschaum/api/dash/callbacks/settings/password_reset.py +2 -2
- meerschaum/api/dash/callbacks/settings/tokens.py +388 -0
- meerschaum/api/dash/components.py +30 -8
- meerschaum/api/dash/keys.py +19 -93
- meerschaum/api/dash/pages/dashboard.py +1 -20
- meerschaum/api/dash/pages/settings/__init__.py +1 -0
- meerschaum/api/dash/pages/settings/password_reset.py +1 -1
- meerschaum/api/dash/pages/settings/tokens.py +55 -0
- meerschaum/api/dash/pipes.py +156 -58
- meerschaum/api/dash/sessions.py +12 -0
- meerschaum/api/dash/tokens.py +606 -0
- meerschaum/api/dash/websockets.py +1 -1
- meerschaum/api/dash/webterm.py +4 -0
- meerschaum/api/models/__init__.py +23 -3
- meerschaum/api/models/_actions.py +22 -0
- meerschaum/api/models/_pipes.py +85 -7
- meerschaum/api/models/_tokens.py +81 -0
- meerschaum/api/resources/static/css/dash.css +16 -0
- meerschaum/api/resources/templates/termpage.html +12 -0
- meerschaum/api/routes/__init__.py +1 -0
- meerschaum/api/routes/_actions.py +3 -4
- meerschaum/api/routes/_connectors.py +3 -7
- meerschaum/api/routes/_jobs.py +14 -35
- meerschaum/api/routes/_login.py +49 -12
- meerschaum/api/routes/_misc.py +5 -10
- meerschaum/api/routes/_pipes.py +134 -111
- meerschaum/api/routes/_plugins.py +38 -28
- meerschaum/api/routes/_tokens.py +236 -0
- meerschaum/api/routes/_users.py +47 -35
- meerschaum/api/routes/_version.py +3 -3
- meerschaum/config/__init__.py +43 -20
- meerschaum/config/_default.py +32 -5
- meerschaum/config/_edit.py +28 -24
- meerschaum/config/_environment.py +1 -1
- meerschaum/config/_patch.py +6 -6
- meerschaum/config/_paths.py +5 -1
- meerschaum/config/_read_config.py +65 -34
- meerschaum/config/_sync.py +6 -3
- meerschaum/config/_version.py +1 -1
- meerschaum/config/stack/__init__.py +24 -5
- meerschaum/config/static.py +18 -0
- meerschaum/connectors/_Connector.py +10 -4
- meerschaum/connectors/__init__.py +4 -20
- meerschaum/connectors/api/_APIConnector.py +34 -6
- meerschaum/connectors/api/_actions.py +2 -2
- meerschaum/connectors/api/_jobs.py +1 -1
- meerschaum/connectors/api/_login.py +33 -7
- meerschaum/connectors/api/_misc.py +2 -2
- meerschaum/connectors/api/_pipes.py +15 -14
- meerschaum/connectors/api/_plugins.py +2 -2
- meerschaum/connectors/api/_request.py +1 -1
- meerschaum/connectors/api/_tokens.py +146 -0
- meerschaum/connectors/api/_users.py +70 -58
- meerschaum/connectors/instance/_InstanceConnector.py +83 -0
- meerschaum/connectors/instance/__init__.py +10 -0
- meerschaum/connectors/instance/_pipes.py +442 -0
- meerschaum/connectors/instance/_plugins.py +151 -0
- meerschaum/connectors/instance/_tokens.py +296 -0
- meerschaum/connectors/instance/_users.py +181 -0
- meerschaum/connectors/parse.py +4 -1
- meerschaum/connectors/sql/_SQLConnector.py +8 -5
- meerschaum/connectors/sql/_cli.py +12 -11
- meerschaum/connectors/sql/_create_engine.py +6 -154
- meerschaum/connectors/sql/_fetch.py +2 -18
- meerschaum/connectors/sql/_pipes.py +42 -31
- meerschaum/connectors/sql/_plugins.py +29 -0
- meerschaum/connectors/sql/_sql.py +9 -2
- meerschaum/connectors/sql/_users.py +29 -2
- meerschaum/connectors/sql/tables/__init__.py +1 -1
- meerschaum/connectors/valkey/_ValkeyConnector.py +2 -4
- meerschaum/connectors/valkey/_pipes.py +9 -10
- meerschaum/connectors/valkey/_plugins.py +2 -26
- meerschaum/core/Pipe/__init__.py +31 -14
- meerschaum/core/Pipe/_attributes.py +156 -58
- meerschaum/core/Pipe/_bootstrap.py +54 -24
- meerschaum/core/Pipe/_data.py +41 -1
- meerschaum/core/Pipe/_dtypes.py +29 -14
- meerschaum/core/Pipe/_edit.py +12 -4
- meerschaum/core/Pipe/_show.py +5 -5
- meerschaum/core/Pipe/_sync.py +48 -53
- meerschaum/core/Pipe/_verify.py +1 -1
- meerschaum/{plugins → core/Plugin}/_Plugin.py +9 -11
- meerschaum/core/Plugin/__init__.py +1 -1
- meerschaum/core/Token/_Token.py +221 -0
- meerschaum/core/Token/__init__.py +12 -0
- meerschaum/core/User/_User.py +34 -8
- meerschaum/core/User/__init__.py +9 -1
- meerschaum/core/__init__.py +1 -0
- meerschaum/jobs/_Job.py +3 -2
- meerschaum/jobs/__init__.py +3 -2
- meerschaum/jobs/systemd.py +1 -1
- meerschaum/models/__init__.py +35 -0
- meerschaum/models/pipes.py +247 -0
- meerschaum/models/tokens.py +38 -0
- meerschaum/models/users.py +26 -0
- meerschaum/plugins/__init__.py +22 -7
- meerschaum/plugins/bootstrap.py +2 -1
- meerschaum/utils/_get_pipes.py +68 -27
- meerschaum/utils/daemon/Daemon.py +2 -1
- meerschaum/utils/daemon/__init__.py +30 -2
- meerschaum/utils/dataframe.py +96 -15
- meerschaum/utils/dtypes/__init__.py +93 -21
- meerschaum/utils/dtypes/sql.py +44 -0
- meerschaum/utils/formatting/__init__.py +1 -1
- meerschaum/utils/formatting/_pipes.py +5 -4
- meerschaum/utils/formatting/_shell.py +11 -9
- meerschaum/utils/misc.py +237 -80
- meerschaum/utils/packages/__init__.py +3 -6
- meerschaum/utils/packages/_packages.py +34 -32
- meerschaum/utils/pipes.py +181 -0
- meerschaum/utils/process.py +1 -1
- meerschaum/utils/prompt.py +3 -1
- meerschaum/utils/schedule.py +1 -0
- meerschaum/utils/sql.py +115 -39
- meerschaum/utils/typing.py +1 -4
- meerschaum/utils/venv/_Venv.py +2 -2
- meerschaum/utils/venv/__init__.py +5 -7
- {meerschaum-2.9.4.dist-info → meerschaum-3.0.0rc1.dist-info}/METADATA +88 -80
- meerschaum-3.0.0rc1.dist-info/RECORD +282 -0
- {meerschaum-2.9.4.dist-info → meerschaum-3.0.0rc1.dist-info}/WHEEL +1 -1
- meerschaum/api/models/_interfaces.py +0 -15
- meerschaum/api/models/_locations.py +0 -15
- meerschaum/api/models/_metrics.py +0 -15
- meerschaum/config/static/__init__.py +0 -186
- meerschaum-2.9.4.dist-info/RECORD +0 -263
- {meerschaum-2.9.4.dist-info → meerschaum-3.0.0rc1.dist-info}/entry_points.txt +0 -0
- {meerschaum-2.9.4.dist-info → meerschaum-3.0.0rc1.dist-info}/licenses/LICENSE +0 -0
- {meerschaum-2.9.4.dist-info → meerschaum-3.0.0rc1.dist-info}/top_level.txt +0 -0
- {meerschaum-2.9.4.dist-info → meerschaum-3.0.0rc1.dist-info}/zip-safe +0 -0
@@ -11,10 +11,11 @@ from __future__ import annotations
|
|
11
11
|
import textwrap
|
12
12
|
import json
|
13
13
|
import uuid
|
14
|
-
from datetime import datetime, timezone
|
15
14
|
|
16
15
|
from dash.dependencies import Input, Output, State, ALL, MATCH
|
17
16
|
from dash.exceptions import PreventUpdate
|
17
|
+
|
18
|
+
import meerschaum as mrsm
|
18
19
|
from meerschaum.utils.typing import List, Optional, Any, Tuple
|
19
20
|
from meerschaum.api import get_api_connector, endpoints, no_auth, CHECK_UPDATE
|
20
21
|
from meerschaum.api.dash import dash_app, debug
|
@@ -26,7 +27,12 @@ from meerschaum.api.dash.sessions import (
|
|
26
27
|
from meerschaum.api.dash.sessions import is_session_authenticated
|
27
28
|
from meerschaum.api.dash.connectors import get_web_connector
|
28
29
|
from meerschaum.connectors.parse import parse_instance_keys
|
29
|
-
from meerschaum.api.dash.pipes import
|
30
|
+
from meerschaum.api.dash.pipes import (
|
31
|
+
get_pipes_cards,
|
32
|
+
pipe_from_ctx,
|
33
|
+
accordion_items_from_pipe,
|
34
|
+
get_backtrack_text,
|
35
|
+
)
|
30
36
|
from meerschaum.api.dash.jobs import get_jobs_cards
|
31
37
|
from meerschaum.api.dash.plugins import get_plugins_cards
|
32
38
|
from meerschaum.api.dash.users import get_users_cards
|
@@ -41,7 +47,7 @@ from meerschaum.api.dash.components import (
|
|
41
47
|
from meerschaum.api.dash import pages
|
42
48
|
from meerschaum.utils.typing import Dict
|
43
49
|
from meerschaum.utils.packages import attempt_import, import_html, import_dcc
|
44
|
-
from meerschaum.utils.misc import filter_keywords, flatten_list
|
50
|
+
from meerschaum.utils.misc import filter_keywords, flatten_list, string_to_dict
|
45
51
|
from meerschaum.utils.yaml import yaml
|
46
52
|
from meerschaum.actions import get_subactions, actions
|
47
53
|
from meerschaum._internal.arguments._parser import parser
|
@@ -55,11 +61,8 @@ keys_state = (
|
|
55
61
|
State('connector-keys-dropdown', 'value'),
|
56
62
|
State('metric-keys-dropdown', 'value'),
|
57
63
|
State('location-keys-dropdown', 'value'),
|
58
|
-
State('
|
59
|
-
State('
|
60
|
-
State('location-keys-input', 'value'),
|
61
|
-
State('search-parameters-editor', 'value'),
|
62
|
-
State('pipes-filter-tabs', 'active_tab'),
|
64
|
+
State('tags-dropdown', 'value'),
|
65
|
+
State('tags-dropdown-div', 'style'),
|
63
66
|
State('action-dropdown', 'value'),
|
64
67
|
State('subaction-dropdown', 'value'),
|
65
68
|
State('subaction-dropdown', 'options'),
|
@@ -295,6 +298,7 @@ dash_app.clientside_callback(
|
|
295
298
|
connector_keys,
|
296
299
|
metric_keys,
|
297
300
|
location_keys,
|
301
|
+
tags,
|
298
302
|
flags,
|
299
303
|
input_flags,
|
300
304
|
input_flags_texts,
|
@@ -317,6 +321,7 @@ dash_app.clientside_callback(
|
|
317
321
|
connector_keys: connector_keys,
|
318
322
|
metric_keys: metric_keys,
|
319
323
|
location_keys: location_keys,
|
324
|
+
tags: tags,
|
320
325
|
flags: flags,
|
321
326
|
input_flags: input_flags,
|
322
327
|
input_flags_texts: input_flags_texts,
|
@@ -333,6 +338,7 @@ dash_app.clientside_callback(
|
|
333
338
|
State('connector-keys-dropdown', 'value'),
|
334
339
|
State('metric-keys-dropdown', 'value'),
|
335
340
|
State('location-keys-dropdown', 'value'),
|
341
|
+
State('tags-dropdown', 'value'),
|
336
342
|
State('flags-dropdown', 'value'),
|
337
343
|
State({'type': 'input-flags-dropdown', 'index': ALL}, 'value'),
|
338
344
|
State({'type': 'input-flags-dropdown-text', 'index': ALL}, 'value'),
|
@@ -358,7 +364,7 @@ def update_actions(action: str, subaction: str):
|
|
358
364
|
_actions_options = sorted([
|
359
365
|
{
|
360
366
|
'label': a.replace('_', ' '),
|
361
|
-
'value': a,
|
367
|
+
'value': a.replace('_', ' '),
|
362
368
|
'title': (textwrap.dedent(f.__doc__).lstrip() if f.__doc__ else 'No help available.'),
|
363
369
|
}
|
364
370
|
for a, f in actions.items() if a not in omit_actions
|
@@ -366,7 +372,7 @@ def update_actions(action: str, subaction: str):
|
|
366
372
|
_subactions_options = sorted([
|
367
373
|
{
|
368
374
|
'label': sa.replace('_', ' '),
|
369
|
-
'value': sa,
|
375
|
+
'value': sa.replace('_', ' '),
|
370
376
|
'title': (textwrap.dedent(f.__doc__).lstrip() if f.__doc__ else 'No help available.'),
|
371
377
|
}
|
372
378
|
for sa, f in get_subactions(action).items()
|
@@ -497,11 +503,15 @@ def update_flags(input_flags_dropdown_values, n_clicks, input_flags_texts):
|
|
497
503
|
Output('location-keys-dropdown', 'options'),
|
498
504
|
Output('location-keys-list', 'children'),
|
499
505
|
Output('location-keys-dropdown', 'value'),
|
506
|
+
Output('tags-dropdown', 'options'),
|
507
|
+
Output('tags-list', 'children'),
|
508
|
+
Output('tags-dropdown', 'value'),
|
500
509
|
Output('instance-select', 'value'),
|
501
510
|
Output('instance-alert-div', 'children'),
|
502
511
|
Input('connector-keys-dropdown', 'value'),
|
503
512
|
Input('metric-keys-dropdown', 'value'),
|
504
513
|
Input('location-keys-dropdown', 'value'),
|
514
|
+
Input('tags-dropdown', 'value'),
|
505
515
|
Input('instance-select', 'value'),
|
506
516
|
*keys_state ### NOTE: Necessary for `ctx.states`.
|
507
517
|
)
|
@@ -509,6 +519,7 @@ def update_keys_options(
|
|
509
519
|
connector_keys: Optional[List[str]],
|
510
520
|
metric_keys: Optional[List[str]],
|
511
521
|
location_keys: Optional[List[str]],
|
522
|
+
tags: Optional[List[str]],
|
512
523
|
instance_keys: Optional[str],
|
513
524
|
*keys
|
514
525
|
):
|
@@ -543,6 +554,8 @@ def update_keys_options(
|
|
543
554
|
metric_keys = []
|
544
555
|
if location_keys is None:
|
545
556
|
location_keys = []
|
557
|
+
if tags is None:
|
558
|
+
tags = []
|
546
559
|
num_filter = 0
|
547
560
|
if connector_keys:
|
548
561
|
num_filter += 1
|
@@ -550,13 +563,17 @@ def update_keys_options(
|
|
550
563
|
num_filter += 1
|
551
564
|
if location_keys:
|
552
565
|
num_filter += 1
|
566
|
+
if tags:
|
567
|
+
num_filter += 1
|
553
568
|
|
554
569
|
_ck_filter = connector_keys
|
555
570
|
_mk_filter = metric_keys
|
556
571
|
_lk_filter = location_keys
|
572
|
+
_tags_filter = tags
|
557
573
|
_ck_alone = (connector_keys and num_filter == 1) or instance_click
|
558
574
|
_mk_alone = (metric_keys and num_filter == 1) or instance_click
|
559
575
|
_lk_alone = (location_keys and num_filter == 1) or instance_click
|
576
|
+
_tags_alone = (tags and num_filter == 1) or instance_click
|
560
577
|
|
561
578
|
from meerschaum.utils import fetch_pipes_keys
|
562
579
|
|
@@ -568,15 +585,31 @@ def update_keys_options(
|
|
568
585
|
connector_keys=_ck_filter,
|
569
586
|
metric_keys=_mk_filter,
|
570
587
|
location_keys=_lk_filter,
|
588
|
+
tags=_tags_filter,
|
589
|
+
)
|
590
|
+
_tags_pipes = mrsm.get_pipes(
|
591
|
+
connector_keys=_ck_filter,
|
592
|
+
metric_keys=_mk_filter,
|
593
|
+
location_keys=_lk_filter,
|
594
|
+
tags=_tags_filter,
|
595
|
+
instance=get_web_connector(ctx.states),
|
596
|
+
as_tags_dict=True,
|
571
597
|
)
|
598
|
+
_all_tags = list(
|
599
|
+
mrsm.get_pipes(
|
600
|
+
instance=get_web_connector(ctx.states),
|
601
|
+
as_tags_dict=True,
|
602
|
+
)
|
603
|
+
) if _tags_alone else []
|
572
604
|
except Exception as e:
|
573
605
|
instance_alerts += [alert_from_success_tuple((False, str(e)))]
|
574
606
|
_all_keys, _keys = [], []
|
575
607
|
_connectors_options = []
|
576
608
|
_metrics_options = []
|
577
609
|
_locations_options = []
|
610
|
+
_tags_options = []
|
578
611
|
|
579
|
-
_seen_keys = {'ck' : set(), 'mk' : set(), 'lk' : set()}
|
612
|
+
_seen_keys = {'ck' : set(), 'mk' : set(), 'lk' : set(), 'tags': set()}
|
580
613
|
|
581
614
|
def add_options(options, keys, key_type):
|
582
615
|
for ck, mk, lk in keys:
|
@@ -589,9 +622,16 @@ def update_keys_options(
|
|
589
622
|
add_options(_connectors_options, _all_keys if _ck_alone else _keys, 'ck')
|
590
623
|
add_options(_metrics_options, _all_keys if _mk_alone else _keys, 'mk')
|
591
624
|
add_options(_locations_options, _all_keys if _lk_alone else _keys, 'lk')
|
625
|
+
|
626
|
+
_tags_options = [
|
627
|
+
{'label': tag, 'value': tag}
|
628
|
+
for tag in (_all_tags if _tags_alone else _tags_pipes)
|
629
|
+
]
|
630
|
+
|
592
631
|
_connectors_options.sort(key=lambda x: str(x).lower())
|
593
632
|
_metrics_options.sort(key=lambda x: str(x).lower())
|
594
633
|
_locations_options.sort(key=lambda x: str(x).lower())
|
634
|
+
_tags_options.sort(key=lambda x: str(x).lower())
|
595
635
|
connector_keys = [
|
596
636
|
ck
|
597
637
|
for ck in connector_keys
|
@@ -616,9 +656,18 @@ def update_keys_options(
|
|
616
656
|
for _lk in _locations_options
|
617
657
|
]
|
618
658
|
]
|
659
|
+
tags = [
|
660
|
+
tag
|
661
|
+
for tag in tags
|
662
|
+
if tag in [
|
663
|
+
_tag['value']
|
664
|
+
for _tag in _tags_options
|
665
|
+
]
|
666
|
+
]
|
619
667
|
_connectors_datalist = [html.Option(value=o['value']) for o in _connectors_options]
|
620
668
|
_metrics_datalist = [html.Option(value=o['value']) for o in _metrics_options]
|
621
669
|
_locations_datalist = [html.Option(value=o['value']) for o in _locations_options]
|
670
|
+
_tags_datalist = [html.Option(value=o['value']) for o in _tags_options]
|
622
671
|
return (
|
623
672
|
_connectors_options,
|
624
673
|
_connectors_datalist,
|
@@ -629,6 +678,9 @@ def update_keys_options(
|
|
629
678
|
_locations_options,
|
630
679
|
_locations_datalist,
|
631
680
|
location_keys,
|
681
|
+
_tags_options,
|
682
|
+
_tags_datalist,
|
683
|
+
tags,
|
632
684
|
(instance_keys if update_instance_keys else dash.no_update),
|
633
685
|
instance_alerts,
|
634
686
|
)
|
@@ -861,7 +913,6 @@ def update_pipe_accordion(item, session_store_data):
|
|
861
913
|
def update_pipe_parameters_click(n_clicks, parameters_editor_text):
|
862
914
|
if not n_clicks:
|
863
915
|
raise PreventUpdate
|
864
|
-
ctx = dash.callback_context
|
865
916
|
triggered = dash.callback_context.triggered
|
866
917
|
if triggered[0]['value'] is None:
|
867
918
|
raise PreventUpdate
|
@@ -890,12 +941,11 @@ def update_pipe_parameters_click(n_clicks, parameters_editor_text):
|
|
890
941
|
@dash_app.callback(
|
891
942
|
Output({'type': 'update-sql-success-div', 'index': MATCH}, 'children'),
|
892
943
|
Input({'type': 'update-sql-button', 'index': MATCH}, 'n_clicks'),
|
893
|
-
State({'type': 'sql-editor', 'index': MATCH}, 'value')
|
944
|
+
State({'type': 'sql-editor', 'index': MATCH}, 'value'),
|
894
945
|
)
|
895
946
|
def update_pipe_sql_click(n_clicks, sql_editor_text):
|
896
947
|
if not n_clicks:
|
897
948
|
raise PreventUpdate
|
898
|
-
ctx = dash.callback_context
|
899
949
|
triggered = dash.callback_context.triggered
|
900
950
|
if triggered[0]['value'] is None:
|
901
951
|
raise PreventUpdate
|
@@ -923,7 +973,6 @@ def update_pipe_sql_click(n_clicks, sql_editor_text):
|
|
923
973
|
def sync_documents_click(n_clicks, sync_editor_text):
|
924
974
|
if not n_clicks:
|
925
975
|
raise PreventUpdate
|
926
|
-
ctx = dash.callback_context
|
927
976
|
triggered = dash.callback_context.triggered
|
928
977
|
if triggered[0]['value'] is None:
|
929
978
|
raise PreventUpdate
|
@@ -937,6 +986,15 @@ def sync_documents_click(n_clicks, sync_editor_text):
|
|
937
986
|
except Exception as e:
|
938
987
|
docs = None
|
939
988
|
msg = str(e)
|
989
|
+
|
990
|
+
if docs is None:
|
991
|
+
try:
|
992
|
+
lines = sync_editor_text.splitlines()
|
993
|
+
docs = [string_to_dict(line) for line in lines]
|
994
|
+
msg = '... '
|
995
|
+
except Exception:
|
996
|
+
docs = None
|
997
|
+
|
940
998
|
if docs is None:
|
941
999
|
success, msg = False, (msg + f"Unable to sync documents to {pipe}.")
|
942
1000
|
else:
|
@@ -949,6 +1007,37 @@ def sync_documents_click(n_clicks, sync_editor_text):
|
|
949
1007
|
|
950
1008
|
return alert_from_success_tuple((success, msg))
|
951
1009
|
|
1010
|
+
@dash_app.callback(
|
1011
|
+
Output({'type': 'query-result-div', 'index': MATCH}, 'children'),
|
1012
|
+
Input({'type': 'query-data-button', 'index': MATCH}, 'n_clicks'),
|
1013
|
+
State({'type': 'query-editor', 'index': MATCH}, 'value'),
|
1014
|
+
State({'type': 'limit-input', 'index': MATCH}, 'value'),
|
1015
|
+
State({'type': 'query-data-begin-input', 'index': MATCH}, 'value'),
|
1016
|
+
State({'type': 'query-data-end-input', 'index': MATCH}, 'value'),
|
1017
|
+
)
|
1018
|
+
def query_data_click(n_clicks, query_editor_text, limit_value, begin, end):
|
1019
|
+
triggered = dash.callback_context.triggered
|
1020
|
+
if triggered[0]['value'] is None:
|
1021
|
+
raise PreventUpdate
|
1022
|
+
pipe = pipe_from_ctx(triggered, 'n_clicks')
|
1023
|
+
if pipe is None:
|
1024
|
+
raise PreventUpdate
|
1025
|
+
|
1026
|
+
try:
|
1027
|
+
params_query = json.loads(query_editor_text)
|
1028
|
+
except Exception as e:
|
1029
|
+
return alert_from_success_tuple((False, f"Invalid query:\n{e}"))
|
1030
|
+
|
1031
|
+
if limit_value is None:
|
1032
|
+
limit_value = 100
|
1033
|
+
|
1034
|
+
df = pipe.get_data(params=params_query, debug=debug, begin=begin, end=end, limit=limit_value)
|
1035
|
+
if df is None:
|
1036
|
+
return [html.P("No data returned.")]
|
1037
|
+
df = df.astype(str)
|
1038
|
+
table = dbc.Table.from_dataframe(df, bordered=False, hover=True)
|
1039
|
+
return table
|
1040
|
+
|
952
1041
|
|
953
1042
|
dash_app.clientside_callback(
|
954
1043
|
"""
|
@@ -1012,8 +1101,8 @@ dash_app.clientside_callback(
|
|
1012
1101
|
|
1013
1102
|
@dash_app.callback(
|
1014
1103
|
Output("navbar-collapse", "is_open"),
|
1015
|
-
|
1016
|
-
|
1104
|
+
Input("navbar-toggler", "n_clicks"),
|
1105
|
+
State("navbar-collapse", "is_open"),
|
1017
1106
|
)
|
1018
1107
|
def toggle_navbar_collapse(n_clicks: Optional[int], is_open: bool) -> bool:
|
1019
1108
|
"""
|
@@ -1072,7 +1161,6 @@ def parameters_as_yaml_or_json_click(
|
|
1072
1161
|
if not yaml_n_clicks and not json_n_clicks:
|
1073
1162
|
raise PreventUpdate
|
1074
1163
|
|
1075
|
-
ctx = dash.callback_context
|
1076
1164
|
triggered = dash.callback_context.triggered
|
1077
1165
|
if triggered[0]['value'] is None:
|
1078
1166
|
raise PreventUpdate
|
@@ -1086,6 +1174,33 @@ def parameters_as_yaml_or_json_click(
|
|
1086
1174
|
return json.dumps(pipe.parameters, indent=4, separators=(',', ': '), sort_keys=True)
|
1087
1175
|
|
1088
1176
|
|
1177
|
+
@dash_app.callback(
|
1178
|
+
Output({'type': 'sync-editor', 'index': MATCH}, 'value'),
|
1179
|
+
Input({'type': 'sync-as-json-button', 'index': MATCH}, 'n_clicks'),
|
1180
|
+
Input({'type': 'sync-as-lines-button', 'index': MATCH}, 'n_clicks'),
|
1181
|
+
)
|
1182
|
+
def sync_as_json_or_lines_click(
|
1183
|
+
json_n_clicks: Optional[int],
|
1184
|
+
lines_n_clicks: Optional[int],
|
1185
|
+
):
|
1186
|
+
"""
|
1187
|
+
When the `YAML` button is clicked under the parameters editor, switch the content to YAML.
|
1188
|
+
"""
|
1189
|
+
if not json_n_clicks and not lines_n_clicks:
|
1190
|
+
raise PreventUpdate
|
1191
|
+
|
1192
|
+
triggered = dash.callback_context.triggered
|
1193
|
+
if triggered[0]['value'] is None:
|
1194
|
+
raise PreventUpdate
|
1195
|
+
|
1196
|
+
as_lines = 'lines' in triggered[0]['prop_id']
|
1197
|
+
pipe = pipe_from_ctx(triggered, 'n_clicks')
|
1198
|
+
if pipe is None:
|
1199
|
+
raise PreventUpdate
|
1200
|
+
|
1201
|
+
return get_backtrack_text(pipe, lines=as_lines)
|
1202
|
+
|
1203
|
+
|
1089
1204
|
@dash_app.callback(
|
1090
1205
|
Output('pages-offcanvas', 'is_open'),
|
1091
1206
|
Output('pages-offcanvas', 'children'),
|
@@ -13,7 +13,7 @@ from meerschaum.api.dash.sessions import set_session
|
|
13
13
|
from dash.dependencies import Input, Output, State, ALL, MATCH
|
14
14
|
from dash.exceptions import PreventUpdate
|
15
15
|
from meerschaum.core import User
|
16
|
-
from meerschaum.
|
16
|
+
from meerschaum._internal.static import STATIC_CONFIG
|
17
17
|
from meerschaum.utils.packages import attempt_import
|
18
18
|
dash = attempt_import('dash', check_update=CHECK_UPDATE)
|
19
19
|
from fastapi.exceptions import HTTPException
|
@@ -11,7 +11,7 @@ from dash.dependencies import Input, Output, State
|
|
11
11
|
import dash_bootstrap_components as dbc
|
12
12
|
|
13
13
|
from meerschaum.core.User import User
|
14
|
-
from meerschaum.
|
14
|
+
from meerschaum._internal.static import STATIC_CONFIG
|
15
15
|
from meerschaum.api import get_api_connector, debug
|
16
16
|
from meerschaum.api.dash import dash_app
|
17
17
|
from meerschaum.api.dash.components import alert_from_success_tuple
|
@@ -39,7 +39,7 @@ def password_reset_button_click(n_clicks, new_password_value, session_store_data
|
|
39
39
|
)
|
40
40
|
|
41
41
|
instance_connector = get_api_connector()
|
42
|
-
user = User(username, new_password_value)
|
42
|
+
user = User(username, new_password_value, instance=instance_connector)
|
43
43
|
success, msg = instance_connector.edit_user(user, debug=debug)
|
44
44
|
return alert_from_success_tuple((success, msg))
|
45
45
|
|