pyegeria 5.3.3.12__py3-none-any.whl → 5.3.3.13__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.
- pyegeria/__init__.py +2 -1
- pyegeria/commands/tech/list_information_supply_chains.py +10 -7
- pyegeria/commands/tech/work/mermaid_graphs/Clinical Trial Subject Onboarding.html +135 -0
- pyegeria/commands/tech/work/mermaid_graphs/{Clinical Trial Treatment Validation.mmd → Clinical Trial Treatment Validation.html } +127 -41
- pyegeria/commands/tech/work/mermaid_graphs/Employee Expense Payment.html +126 -0
- pyegeria/commands/tech/work/mermaid_graphs/New Drug Product Information Distribution.html +141 -0
- pyegeria/commands/tech/work/mermaid_graphs/New Employee Onboarding.html +138 -0
- pyegeria/commands/tech/work/mermaid_graphs/Personalized Treatment Ordering.html +143 -0
- pyegeria/commands/tech/work/mermaid_graphs/{Physical Inventory Tracking.mmd → Physical Inventory Tracking.html } +114 -28
- pyegeria/commands/tech/work/mermaid_graphs/{Sustainability Reporting.mmd → Sustainability Reporting.html } +112 -26
- pyegeria/commands/tech/work/mermaid_graphs/{{displayName}}.html +115 -0
- pyegeria/mermaid_utilities.py +277 -72
- {pyegeria-5.3.3.12.dist-info → pyegeria-5.3.3.13.dist-info}/METADATA +1 -1
- {pyegeria-5.3.3.12.dist-info → pyegeria-5.3.3.13.dist-info}/RECORD +19 -94
- pyegeria/.DS_Store +0 -0
- pyegeria/commands/.DS_Store +0 -0
- pyegeria/commands/__pycache__/__init__.cpython-312.pyc +0 -0
- pyegeria/commands/__pycache__/server_status_widget.cpython-312-pytest-7.4.4.pyc +0 -0
- pyegeria/commands/cat/__pycache__/__init__.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/get_asset_graph.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/get_collection.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/get_project_dependencies.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/get_project_structure.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/get_tech_type_elements.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/glossary_actions.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_assets.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_cert_types.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_collections.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_deployed_catalogs.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_deployed_database_schemas.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_deployed_databases.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_glossaries.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_projects.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_servers_deployed_imp.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_tech_type_elements.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_tech_types.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_terms.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_todos.cpython-312.pyc +0 -0
- pyegeria/commands/cat/__pycache__/list_user_ids.cpython-312.pyc +0 -0
- pyegeria/commands/cli/__pycache__/__init__.cpython-312.pyc +0 -0
- pyegeria/commands/cli/__pycache__/egeria_login_tui.cpython-312.pyc +0 -0
- pyegeria/commands/cli/__pycache__/egeria_ops.cpython-312.pyc +0 -0
- pyegeria/commands/cli/__pycache__/ops_config.cpython-312.pyc +0 -0
- pyegeria/commands/doc/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/cat/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/cat/show/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/cat/show/deployed-data/.DS_Store +0 -0
- pyegeria/commands/doc/glossary/.DS_Store +0 -0
- pyegeria/commands/doc/glossary/images/.DS_Store +0 -0
- pyegeria/commands/doc/hey_egeria: a pyegeria command line interface/.DS_Store +0 -0
- pyegeria/commands/doc/hey_egeria: a pyegeria command line interface/images/.DS_Store +0 -0
- pyegeria/commands/my/__pycache__/__init__.cpython-312.pyc +0 -0
- pyegeria/commands/my/__pycache__/list_my_profile.cpython-312.pyc +0 -0
- pyegeria/commands/my/__pycache__/list_my_roles.cpython-312.pyc +0 -0
- pyegeria/commands/my/__pycache__/monitor_my_todos.cpython-312.pyc +0 -0
- pyegeria/commands/my/__pycache__/monitor_open_todos.cpython-312.pyc +0 -0
- pyegeria/commands/my/__pycache__/todo_actions.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/__init__.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/gov_server_actions.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/list_archives.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/list_catalog_targets.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/load_archive.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/monitor_engine_activity.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/monitor_engine_activity_c.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/monitor_gov_eng_status.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/monitor_integ_daemon_status.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/monitor_platform_status.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/monitor_server_startup.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/monitor_server_status.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/refresh_integration_daemon.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/restart_integration_daemon.cpython-312.pyc +0 -0
- pyegeria/commands/ops/__pycache__/table_integ_daemon_status.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/__init__.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/get_element_info.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/get_guid_info.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/get_tech_details.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/get_tech_type_template.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/list_anchored_elements.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/list_asset_types.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/list_elements_by_property_value.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/list_elements_for_classification.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/list_gov_action_processes.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/list_registered_services.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/list_related_specification.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/list_relationship_types.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/list_relationships.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/list_tech_templates.cpython-312.pyc +0 -0
- pyegeria/commands/tech/__pycache__/list_valid_metadata_values.cpython-312.pyc +0 -0
- pyegeria/commands/tech/work/mermaid_graphs/Clinical Trial Subject Onboarding.mmd +0 -49
- pyegeria/commands/tech/work/mermaid_graphs/Employee Expense Payment.mmd +0 -40
- pyegeria/commands/tech/work/mermaid_graphs/New Drug Product Information Distribution.mmd +0 -55
- pyegeria/commands/tech/work/mermaid_graphs/New Employee Onboarding.mmd +0 -52
- pyegeria/commands/tech/work/mermaid_graphs/Personalized Treatment Ordering.mmd +0 -57
- pyegeria/commands/tech/work/mermaid_graphs/{{displayName}}.mmd +0 -29
- /pyegeria/commands/tech/{list_isolution_blueprints.py → list_solution_blueprints.py} +0 -0
- /pyegeria/commands/tech/{list_isolution_blueprints2.py → list_solution_blueprints2.py} +0 -0
- {pyegeria-5.3.3.12.dist-info → pyegeria-5.3.3.13.dist-info}/LICENSE +0 -0
- {pyegeria-5.3.3.12.dist-info → pyegeria-5.3.3.13.dist-info}/WHEEL +0 -0
- {pyegeria-5.3.3.12.dist-info → pyegeria-5.3.3.13.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,115 @@
|
|
1
|
+
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<style type="text/css">
|
5
|
+
#mySvgId {
|
6
|
+
width: 100%;
|
7
|
+
height: 100%;
|
8
|
+
overflow: hidden;
|
9
|
+
border: 1px solid #ccc;
|
10
|
+
position: relative;
|
11
|
+
margin-bottom: 10px;
|
12
|
+
}
|
13
|
+
svg {
|
14
|
+
cursor: grab;
|
15
|
+
}
|
16
|
+
|
17
|
+
</style>
|
18
|
+
</head>
|
19
|
+
|
20
|
+
<body>
|
21
|
+
<div id="graphDiv"></div>
|
22
|
+
<script src="https://bumbu.me/svg-pan-zoom/dist/svg-pan-zoom.min.js"></script>
|
23
|
+
<script type="module">
|
24
|
+
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
|
25
|
+
|
26
|
+
mermaid.initialize({startOnLoad: false});
|
27
|
+
await mermaid.run({
|
28
|
+
querySelector: '.mermaid',
|
29
|
+
postRenderCallback: (id) => {
|
30
|
+
const container = document.getElementById("diagram-container");
|
31
|
+
const svgElement = container.querySelector("svg");
|
32
|
+
|
33
|
+
// Initialize Panzoom
|
34
|
+
const panzoomInstance = Panzoom(svgElement, {
|
35
|
+
maxScale: 5,
|
36
|
+
minScale: 0.5,
|
37
|
+
step: 0.1,
|
38
|
+
});
|
39
|
+
|
40
|
+
// Add mouse wheel zoom
|
41
|
+
container.addEventListener("wheel", (event) => {
|
42
|
+
panzoomInstance.zoomWithWheel(event);
|
43
|
+
});
|
44
|
+
}
|
45
|
+
});
|
46
|
+
|
47
|
+
|
48
|
+
const drawDiagram = async function () {
|
49
|
+
const element = document.querySelector('#graphDiv');
|
50
|
+
const graphDefinition = `
|
51
|
+
flowchart TD
|
52
|
+
%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
53
|
+
|
54
|
+
ba3ab0dd-3ec5-4ec5-9db9-f3dc56e3a732@{ shape: flip-tri, label: "*Information Supply Chain*
|
55
|
+
**{{displayName}}**"}
|
56
|
+
40130bec-d839-48cc-992a-3b2a2fc82caa@{ shape: text, label: "*Description*
|
57
|
+
**{{description}}**"}
|
58
|
+
ba3ab0dd-3ec5-4ec5-9db9-f3dc56e3a732~~~40130bec-d839-48cc-992a-3b2a2fc82caa
|
59
|
+
style ba3ab0dd-3ec5-4ec5-9db9-f3dc56e3a732 color:#FFFFFF, fill:#004563, stroke:#b7c0c7
|
60
|
+
style 40130bec-d839-48cc-992a-3b2a2fc82caa color:#000000, fill:#F9F7ED, stroke:#b7c0c7`;
|
61
|
+
const {svg} = await mermaid.render('mySvgId', graphDefinition);
|
62
|
+
element.innerHTML = svg.replace(/( )*max-width:( 0-9\.)*px;/i, '');
|
63
|
+
|
64
|
+
var doPan = false;
|
65
|
+
var eventsHandler;
|
66
|
+
var panZoom;
|
67
|
+
var mousepos;
|
68
|
+
|
69
|
+
eventsHandler = {
|
70
|
+
haltEventListeners: ['mousedown', 'mousemove', 'mouseup']
|
71
|
+
|
72
|
+
, mouseDownHandler: function (ev) {
|
73
|
+
if (event.target.className == "[object SVGAnimatedString]") {
|
74
|
+
doPan = true;
|
75
|
+
mousepos = {x: ev.clientX, y: ev.clientY}
|
76
|
+
}
|
77
|
+
;
|
78
|
+
}
|
79
|
+
|
80
|
+
, mouseMoveHandler: function (ev) {
|
81
|
+
if (doPan) {
|
82
|
+
panZoom.panBy({x: ev.clientX - mousepos.x, y: ev.clientY - mousepos.y});
|
83
|
+
mousepos = {x: ev.clientX, y: ev.clientY};
|
84
|
+
window.getSelection().removeAllRanges();
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
, mouseUpHandler: function (ev) {
|
89
|
+
doPan = false;
|
90
|
+
}
|
91
|
+
|
92
|
+
, init: function (options) {
|
93
|
+
options.svgElement.addEventListener('mousedown', this.mouseDownHandler, false);
|
94
|
+
options.svgElement.addEventListener('mousemove', this.mouseMoveHandler, false);
|
95
|
+
options.svgElement.addEventListener('mouseup', this.mouseUpHandler, false);
|
96
|
+
}
|
97
|
+
|
98
|
+
, destroy: function (options) {
|
99
|
+
options.svgElement.removeEventListener('mousedown', this.mouseDownHandler, false);
|
100
|
+
options.svgElement.removeEventListener('mousemove', this.mouseMoveHandler, false);
|
101
|
+
options.svgElement.removeEventListener('mouseup', this.mouseUpHandler, false);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
panZoom = svgPanZoom('#mySvgId', {
|
105
|
+
zoomEnabled: true
|
106
|
+
, controlIconsEnabled: true
|
107
|
+
, fit: 1
|
108
|
+
, center: 1
|
109
|
+
, customEventsHandler: eventsHandler
|
110
|
+
})
|
111
|
+
};
|
112
|
+
await drawDiagram();
|
113
|
+
</script>
|
114
|
+
</body>
|
115
|
+
|
pyegeria/mermaid_utilities.py
CHANGED
@@ -42,35 +42,7 @@ EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
|
|
42
42
|
EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
|
43
43
|
EGERIA_MERMAID_FOLDER = os.environ.get("EGERIA_MERMAID_FOLDER", "./work/mermaid_graphs")
|
44
44
|
|
45
|
-
|
46
|
-
# def check_mermaid_version():
|
47
|
-
# """Check the version of Mermaid.js loaded in Jupyter Notebook"""
|
48
|
-
# display(HTML("""
|
49
|
-
# <script>
|
50
|
-
# function checkMermaid() {
|
51
|
-
# if (window.mermaid && typeof window.mermaid.version !== "undefined") {
|
52
|
-
# console.log("Mermaid.js version:", mermaid.version);
|
53
|
-
# alert("Mermaid.js version: " + mermaid.version);
|
54
|
-
# } else {
|
55
|
-
# console.warn("Mermaid.js is not loaded yet. Please ensure it's properly injected.");
|
56
|
-
# alert("Mermaid.js is not loaded yet. Please ensure it's properly injected.");
|
57
|
-
# }
|
58
|
-
# }
|
59
|
-
# // Delay execution to ensure Mermaid.js has had time to load
|
60
|
-
# setTimeout(checkMermaid, 1000);
|
61
|
-
# </script>
|
62
|
-
# """))
|
63
|
-
|
64
|
-
# another site to get mermaid from is "https://cdnjs.cloudflare.com/ajax/libs/mermaid/11.4.1/mermaid.min.js";
|
65
|
-
# below was:
|
66
|
-
#<script src="https://unpkg.com/mermaid@11.4.0/dist/mermaid.min.js"></script>
|
67
|
-
# <script type="text/javascript">
|
68
|
-
# if (!window.mermaid) {
|
69
|
-
# var mermaidScript = document.createElement('script');
|
70
|
-
# mermaidScript.src = https://unpkg.com/mermaid@11.4.1/dist/mermaid.min.js"
|
71
|
-
# document.head.appendChild(mermaidScript);
|
72
|
-
# }
|
73
|
-
# </script>
|
45
|
+
|
74
46
|
def load_mermaid():
|
75
47
|
"""Inject Mermaid.js library"""
|
76
48
|
# Alternative CDN URL via unpkg
|
@@ -83,60 +55,293 @@ def load_mermaid():
|
|
83
55
|
</script>
|
84
56
|
|
85
57
|
"""
|
86
|
-
|
87
|
-
# <script src="https://unpkg.com/mermaid@11.4.0/dist/mermaid.min.js"></script>
|
88
|
-
# <script>
|
89
|
-
# document.addEventListener('DOMContentLoaded', function() {{
|
90
|
-
# mermaid.initialize({{"startOnLoad": true}});
|
91
|
-
# }});
|
92
|
-
# </script>
|
93
|
-
#
|
94
|
-
# """
|
58
|
+
|
95
59
|
display(HTML(mermaid_js))
|
96
60
|
|
97
61
|
|
62
|
+
# def render_mermaid(mermaid_code):
|
63
|
+
# """Function to display a Mermaid diagram in a Jupyter notebook"""
|
64
|
+
# mermaid_html = f"""
|
65
|
+
# <div class="mermaid">
|
66
|
+
# {mermaid_code}
|
67
|
+
# </div>
|
68
|
+
# <script type="text/javascript">
|
69
|
+
# if (window.mermaid) {{
|
70
|
+
# mermaid.initialize({{startOnLoad: true}});
|
71
|
+
# mermaid.contentLoaded();
|
72
|
+
# }}
|
73
|
+
# </script>
|
74
|
+
# """
|
75
|
+
# display(HTML(mermaid_html))
|
98
76
|
def render_mermaid(mermaid_code):
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
77
|
+
return display(HTML(construct_mermaid_html(mermaid_code)))
|
78
|
+
|
79
|
+
|
80
|
+
def parse_mermaid_code(mermaid_code):
|
81
|
+
parts = mermaid_code.split('---', maxsplit=3)
|
82
|
+
if len(parts) == 3:
|
83
|
+
title = parts[1].strip()
|
84
|
+
mermaid_code = parts[2].strip()
|
85
|
+
else:
|
86
|
+
title = "No Title"
|
87
|
+
return title, mermaid_code
|
88
|
+
|
89
|
+
def construct_mermaid_html(mermaid_str: str) -> str:
|
90
|
+
"""Function to display a HTML code in a Jupyter notebook"""
|
91
|
+
title, mermaid_code = parse_mermaid_code(mermaid_str)
|
92
|
+
|
93
|
+
html_section1 = """
|
94
|
+
<html>
|
95
|
+
<head>
|
96
|
+
<style type="text/css">
|
97
|
+
#mySvgId {
|
98
|
+
width: 100%;
|
99
|
+
height: 600px;
|
100
|
+
overflow: scroll;
|
101
|
+
border: 2px solid #ccc;
|
102
|
+
position: relative;
|
103
|
+
margin-bottom: 10px;
|
104
|
+
}
|
105
|
+
svg {
|
106
|
+
cursor: grab;
|
107
|
+
}
|
108
|
+
|
109
|
+
</style>
|
110
|
+
</head>
|
111
|
+
"""
|
112
|
+
html_section2 = """"
|
113
|
+
<title>{title}</title>
|
114
|
+
"""
|
115
|
+
html_section3 = """
|
116
|
+
<body>
|
117
|
+
|
118
|
+
<div id="graphDiv"></div>
|
119
|
+
<script src="https://bumbu.me/svg-pan-zoom/dist/svg-pan-zoom.min.js"></script>
|
120
|
+
<script type="module">
|
121
|
+
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
|
122
|
+
|
123
|
+
mermaid.initialize({startOnLoad: false});
|
124
|
+
await mermaid.run({
|
125
|
+
querySelector: '.mermaid',
|
126
|
+
postRenderCallback: (id) => {
|
127
|
+
const container = document.getElementById("diagram-container");
|
128
|
+
const svgElement = container.querySelector("svg");
|
129
|
+
|
130
|
+
// Initialize Panzoom
|
131
|
+
const panzoomInstance = Panzoom(svgElement, {
|
132
|
+
maxScale: 5,
|
133
|
+
minScale: 0.5,
|
134
|
+
step: 0.1,
|
135
|
+
});
|
136
|
+
|
137
|
+
// Add mouse wheel zoom
|
138
|
+
container.addEventListener("wheel", (event) => {
|
139
|
+
panzoomInstance.zoomWithWheel(event);
|
140
|
+
});
|
141
|
+
}
|
142
|
+
});
|
143
|
+
|
144
|
+
|
145
|
+
const drawDiagram = async function () {
|
146
|
+
const element = document.querySelector('#graphDiv');
|
147
|
+
const graphDefinition = `
|
110
148
|
"""
|
111
|
-
display(HTML(mermaid_html))
|
112
149
|
|
113
|
-
|
150
|
+
html_section4 = """`;
|
151
|
+
const {svg} = await mermaid.render('mySvgId', graphDefinition);
|
152
|
+
element.innerHTML = svg.replace(/( )*max-width:( 0-9\.)*px;/i, '');
|
153
|
+
|
154
|
+
var doPan = false;
|
155
|
+
var eventsHandler;
|
156
|
+
var panZoom;
|
157
|
+
var mousepos;
|
158
|
+
|
159
|
+
eventsHandler = {
|
160
|
+
haltEventListeners: ['mousedown', 'mousemove', 'mouseup']
|
161
|
+
|
162
|
+
, mouseDownHandler: function (ev) {
|
163
|
+
if (event.target.className == "[object SVGAnimatedString]") {
|
164
|
+
doPan = true;
|
165
|
+
mousepos = {x: ev.clientX, y: ev.clientY}
|
166
|
+
}
|
167
|
+
;
|
168
|
+
}
|
169
|
+
|
170
|
+
, mouseMoveHandler: function (ev) {
|
171
|
+
if (doPan) {
|
172
|
+
panZoom.panBy({x: ev.clientX - mousepos.x, y: ev.clientY - mousepos.y});
|
173
|
+
mousepos = {x: ev.clientX, y: ev.clientY};
|
174
|
+
window.getSelection().removeAllRanges();
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
, mouseUpHandler: function (ev) {
|
179
|
+
doPan = false;
|
180
|
+
}
|
181
|
+
|
182
|
+
, init: function (options) {
|
183
|
+
options.svgElement.addEventListener('mousedown', this.mouseDownHandler, false);
|
184
|
+
options.svgElement.addEventListener('mousemove', this.mouseMoveHandler, false);
|
185
|
+
options.svgElement.addEventListener('mouseup', this.mouseUpHandler, false);
|
186
|
+
}
|
187
|
+
|
188
|
+
, destroy: function (options) {
|
189
|
+
options.svgElement.removeEventListener('mousedown', this.mouseDownHandler, false);
|
190
|
+
options.svgElement.removeEventListener('mousemove', this.mouseMoveHandler, false);
|
191
|
+
options.svgElement.removeEventListener('mouseup', this.mouseUpHandler, false);
|
192
|
+
}
|
193
|
+
}
|
194
|
+
panZoom = svgPanZoom('#mySvgId', {
|
195
|
+
zoomEnabled: true
|
196
|
+
, controlIconsEnabled: true
|
197
|
+
, fit: 1
|
198
|
+
, center: 1
|
199
|
+
, customEventsHandler: eventsHandler
|
200
|
+
})
|
201
|
+
};
|
202
|
+
await drawDiagram();
|
203
|
+
</script>
|
204
|
+
</body>
|
205
|
+
"""
|
206
|
+
|
207
|
+
return html_section1 + html_section2 + html_section3 + mermaid_code + html_section4
|
208
|
+
|
209
|
+
def save_mermaid_html(title: str, mermaid_str: str, folder:str = EGERIA_MERMAID_FOLDER):
|
114
210
|
"""Save a Mermaid diagram to a file"""
|
115
211
|
if not os.path.exists(folder):
|
116
212
|
os.makedirs(folder)
|
117
|
-
mermaid_file = os.path.join(folder, title + ".
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
"""
|
213
|
+
mermaid_file = os.path.join(folder, title + ".html")
|
214
|
+
|
215
|
+
payload = construct_mermaid_html(mermaid_str)
|
216
|
+
|
217
|
+
with open(mermaid_file, "w") as f:
|
218
|
+
f.write(payload)
|
219
|
+
return mermaid_file
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
def save_mermaid_graph(title, mermaid_str, folder:str = EGERIA_MERMAID_FOLDER):
|
225
|
+
"""Save a Mermaid diagram to a file"""
|
226
|
+
if not os.path.exists(folder):
|
227
|
+
os.makedirs(folder)
|
228
|
+
mermaid_file = os.path.join(folder, title + ".html")
|
229
|
+
|
230
|
+
title, mermaid_code = parse_mermaid_code(mermaid_str)
|
231
|
+
|
232
|
+
html_prefix = """
|
233
|
+
<html>
|
234
|
+
<head>
|
235
|
+
<style type="text/css">
|
236
|
+
#mySvgId {
|
237
|
+
width: 100%;
|
238
|
+
height: 100%;
|
239
|
+
overflow: hidden;
|
240
|
+
border: 1px solid #ccc;
|
241
|
+
position: relative;
|
242
|
+
margin-bottom: 10px;
|
243
|
+
}
|
244
|
+
svg {
|
245
|
+
cursor: grab;
|
246
|
+
}
|
247
|
+
|
248
|
+
</style>
|
249
|
+
</head>
|
250
|
+
|
251
|
+
<body>
|
252
|
+
<div id="graphDiv"></div>
|
253
|
+
<script src="https://bumbu.me/svg-pan-zoom/dist/svg-pan-zoom.min.js"></script>
|
254
|
+
<script type="module">
|
255
|
+
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
|
256
|
+
|
257
|
+
mermaid.initialize({startOnLoad: false});
|
258
|
+
await mermaid.run({
|
259
|
+
querySelector: '.mermaid',
|
260
|
+
postRenderCallback: (id) => {
|
261
|
+
const container = document.getElementById("diagram-container");
|
262
|
+
const svgElement = container.querySelector("svg");
|
263
|
+
|
264
|
+
// Initialize Panzoom
|
265
|
+
const panzoomInstance = Panzoom(svgElement, {
|
266
|
+
maxScale: 5,
|
267
|
+
minScale: 0.5,
|
268
|
+
step: 0.1,
|
269
|
+
});
|
270
|
+
|
271
|
+
// Add mouse wheel zoom
|
272
|
+
container.addEventListener("wheel", (event) => {
|
273
|
+
panzoomInstance.zoomWithWheel(event);
|
274
|
+
});
|
275
|
+
}
|
276
|
+
});
|
277
|
+
|
278
|
+
|
279
|
+
const drawDiagram = async function () {
|
280
|
+
const element = document.querySelector('#graphDiv');
|
281
|
+
const graphDefinition = `
|
282
|
+
"""
|
283
|
+
|
284
|
+
html_postfix = """`;
|
285
|
+
const {svg} = await mermaid.render('mySvgId', graphDefinition);
|
286
|
+
element.innerHTML = svg.replace(/( )*max-width:( 0-9\.)*px;/i, '');
|
287
|
+
|
288
|
+
var doPan = false;
|
289
|
+
var eventsHandler;
|
290
|
+
var panZoom;
|
291
|
+
var mousepos;
|
292
|
+
|
293
|
+
eventsHandler = {
|
294
|
+
haltEventListeners: ['mousedown', 'mousemove', 'mouseup']
|
295
|
+
|
296
|
+
, mouseDownHandler: function (ev) {
|
297
|
+
if (event.target.className == "[object SVGAnimatedString]") {
|
298
|
+
doPan = true;
|
299
|
+
mousepos = {x: ev.clientX, y: ev.clientY}
|
300
|
+
}
|
301
|
+
;
|
302
|
+
}
|
303
|
+
|
304
|
+
, mouseMoveHandler: function (ev) {
|
305
|
+
if (doPan) {
|
306
|
+
panZoom.panBy({x: ev.clientX - mousepos.x, y: ev.clientY - mousepos.y});
|
307
|
+
mousepos = {x: ev.clientX, y: ev.clientY};
|
308
|
+
window.getSelection().removeAllRanges();
|
309
|
+
}
|
310
|
+
}
|
311
|
+
|
312
|
+
, mouseUpHandler: function (ev) {
|
313
|
+
doPan = false;
|
314
|
+
}
|
315
|
+
|
316
|
+
, init: function (options) {
|
317
|
+
options.svgElement.addEventListener('mousedown', this.mouseDownHandler, false);
|
318
|
+
options.svgElement.addEventListener('mousemove', this.mouseMoveHandler, false);
|
319
|
+
options.svgElement.addEventListener('mouseup', this.mouseUpHandler, false);
|
320
|
+
}
|
321
|
+
|
322
|
+
, destroy: function (options) {
|
323
|
+
options.svgElement.removeEventListener('mousedown', this.mouseDownHandler, false);
|
324
|
+
options.svgElement.removeEventListener('mousemove', this.mouseMoveHandler, false);
|
325
|
+
options.svgElement.removeEventListener('mouseup', this.mouseUpHandler, false);
|
326
|
+
}
|
327
|
+
}
|
328
|
+
panZoom = svgPanZoom('#mySvgId', {
|
329
|
+
zoomEnabled: true
|
330
|
+
, controlIconsEnabled: true
|
331
|
+
, fit: 1
|
332
|
+
, center: 1
|
333
|
+
, customEventsHandler: eventsHandler
|
334
|
+
})
|
335
|
+
};
|
336
|
+
await drawDiagram();
|
337
|
+
</script>
|
338
|
+
</body>
|
339
|
+
"""
|
340
|
+
|
341
|
+
payload = html_prefix + mermaid_code + html_postfix
|
137
342
|
|
138
343
|
with open(mermaid_file, "w") as f:
|
139
|
-
f.write(
|
344
|
+
f.write(payload)
|
140
345
|
return mermaid_file
|
141
346
|
|
142
347
|
|