fastapi-voyager 0.9.2__tar.gz → 0.9.4__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.
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/PKG-INFO +15 -34
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/README.md +14 -33
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/version.py +1 -1
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/voyager.py +5 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/component/route-code-display.js +4 -12
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/component/schema-code-display.js +24 -33
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/graph-ui.js +36 -7
- fastapi_voyager-0.9.4/src/fastapi_voyager/web/index.html +404 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/vue-main.js +16 -12
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/demo.py +16 -1
- fastapi_voyager-0.9.2/src/fastapi_voyager/web/index.html +0 -436
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/.gitignore +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/.python-version +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/LICENSE +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/pyproject.toml +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/__init__.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/cli.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/filter.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/module.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/render.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/server.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/type.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/type_helper.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/component/render-graph.js +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/component/schema-field-filter.js +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/graphviz.svg.css +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/graphviz.svg.js +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/icon/android-chrome-192x192.png +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/icon/android-chrome-512x512.png +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/icon/apple-touch-icon.png +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/icon/favicon-16x16.png +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/icon/favicon-32x32.png +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/icon/favicon.ico +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/icon/site.webmanifest +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/quasar.min.css +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/src/fastapi_voyager/web/quasar.min.js +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/__init__.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/demo_anno.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/programatic.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/service/__init__.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/service/schema.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/test_analysis.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/test_filter.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/test_generic.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/test_import.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/test_module.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/tests/test_type_helper.py +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/uv.lock +0 -0
- {fastapi_voyager-0.9.2 → fastapi_voyager-0.9.4}/voyager.jpg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi-voyager
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.4
|
|
4
4
|
Summary: Visualize FastAPI application's routing tree and dependencies
|
|
5
5
|
Project-URL: Homepage, https://github.com/allmonday/fastapi-voyager
|
|
6
6
|
Project-URL: Source, https://github.com/allmonday/fastapi-voyager
|
|
@@ -27,6 +27,8 @@ Description-Content-Type: text/markdown
|
|
|
27
27
|
|
|
28
28
|
[](https://pypi.python.org/pypi/fastapi-voyager)
|
|
29
29
|

|
|
30
|
+
[](https://pepy.tech/projects/fastapi-voyager)
|
|
31
|
+
|
|
30
32
|
|
|
31
33
|
> This repo is still in early stage, it supports pydantic v2 only
|
|
32
34
|
|
|
@@ -163,7 +165,6 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
|
|
|
163
165
|
- [ ] user can generate nodes/edges manually and connect to generated ones
|
|
164
166
|
- [ ] add owner
|
|
165
167
|
- [ ] add extra info for schema
|
|
166
|
-
- [ ] fixed left/right bar show field information
|
|
167
168
|
- [ ] display standard ER diagram `hard`
|
|
168
169
|
- [ ] display potential invalid links
|
|
169
170
|
- [ ] support dataclass (pending)
|
|
@@ -211,6 +212,15 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
|
|
|
211
212
|
- [x] improve initialization time cost
|
|
212
213
|
- [x] query route / schema info through realtime api
|
|
213
214
|
- [x] adjust fe
|
|
215
|
+
- 0.9.3
|
|
216
|
+
- [x] adjust layout
|
|
217
|
+
- [x] show field detail in right panel
|
|
218
|
+
- [x] show route info in bottom
|
|
219
|
+
- 0.9.4
|
|
220
|
+
- [x] close schema sidebar when switch tag/route
|
|
221
|
+
- [x] schema detail panel show fields by default
|
|
222
|
+
- [x] adjust schema panel's height
|
|
223
|
+
- [x] show from base information in subset case
|
|
214
224
|
|
|
215
225
|
#### 0.10
|
|
216
226
|
- [ ] support opening route in swagger
|
|
@@ -235,6 +245,9 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
|
|
|
235
245
|
- [ ] show hint for resolve, post fields
|
|
236
246
|
- [ ] display loader as edges
|
|
237
247
|
|
|
248
|
+
#### 0.13
|
|
249
|
+
- [ ] config release pipeline
|
|
250
|
+
- [ ]
|
|
238
251
|
|
|
239
252
|
## Using with pydantic-resolve
|
|
240
253
|
|
|
@@ -256,35 +269,3 @@ pydantic-resolve's @ensure_subset decorator is helpful to pick fields from `sour
|
|
|
256
269
|
- [pydantic-resolve](https://github.com/allmonday/pydantic-resolve)
|
|
257
270
|
- Quasar
|
|
258
271
|
|
|
259
|
-
|
|
260
|
-
## Changelog
|
|
261
|
-
|
|
262
|
-
- 0.9:
|
|
263
|
-
- 0.9.2:
|
|
264
|
-
- fix: missing fields in schema detail panel
|
|
265
|
-
- optimization: clean up fe codes.
|
|
266
|
-
- 0.9.1:
|
|
267
|
-
- api change: from `create_app_with_fastapi` to `create_voyager`, and expose as `from fastapi_voyager import create_voyager`
|
|
268
|
-
- optimization: lazy load vscode link and source code, speed up the initialization.
|
|
269
|
-
- 0.8:
|
|
270
|
-
- 0.8.3
|
|
271
|
-
- upgrade theme
|
|
272
|
-
- 0.8.2
|
|
273
|
-
- fix silly typo.
|
|
274
|
-
- 0.8.1
|
|
275
|
-
- add feature: hide primitive routes
|
|
276
|
-
- 0.7:
|
|
277
|
-
- 0.7.5
|
|
278
|
-
- fix show all display issue
|
|
279
|
-
- 0.7.4
|
|
280
|
-
- optimize tag/route, move to left.
|
|
281
|
-
- fresh on change, no need to click generate any more.
|
|
282
|
-
- 0.7.3
|
|
283
|
-
- fix `module_color` failure
|
|
284
|
-
- 0.7.2
|
|
285
|
-
- keep links inside filtered nodes.
|
|
286
|
-
- 0.7.1
|
|
287
|
-
- support brief mode, you can use `--module_prefix tests.service` to show links between routes and filtered schemas, to make the graph less complicated.
|
|
288
|
-
- 0.6:
|
|
289
|
-
- 0.6.2:
|
|
290
|
-
- fix generic related issue
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
[](https://pypi.python.org/pypi/fastapi-voyager)
|
|
2
2
|

|
|
3
|
+
[](https://pepy.tech/projects/fastapi-voyager)
|
|
4
|
+
|
|
3
5
|
|
|
4
6
|
> This repo is still in early stage, it supports pydantic v2 only
|
|
5
7
|
|
|
@@ -136,7 +138,6 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
|
|
|
136
138
|
- [ ] user can generate nodes/edges manually and connect to generated ones
|
|
137
139
|
- [ ] add owner
|
|
138
140
|
- [ ] add extra info for schema
|
|
139
|
-
- [ ] fixed left/right bar show field information
|
|
140
141
|
- [ ] display standard ER diagram `hard`
|
|
141
142
|
- [ ] display potential invalid links
|
|
142
143
|
- [ ] support dataclass (pending)
|
|
@@ -184,6 +185,15 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
|
|
|
184
185
|
- [x] improve initialization time cost
|
|
185
186
|
- [x] query route / schema info through realtime api
|
|
186
187
|
- [x] adjust fe
|
|
188
|
+
- 0.9.3
|
|
189
|
+
- [x] adjust layout
|
|
190
|
+
- [x] show field detail in right panel
|
|
191
|
+
- [x] show route info in bottom
|
|
192
|
+
- 0.9.4
|
|
193
|
+
- [x] close schema sidebar when switch tag/route
|
|
194
|
+
- [x] schema detail panel show fields by default
|
|
195
|
+
- [x] adjust schema panel's height
|
|
196
|
+
- [x] show from base information in subset case
|
|
187
197
|
|
|
188
198
|
#### 0.10
|
|
189
199
|
- [ ] support opening route in swagger
|
|
@@ -208,6 +218,9 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
|
|
|
208
218
|
- [ ] show hint for resolve, post fields
|
|
209
219
|
- [ ] display loader as edges
|
|
210
220
|
|
|
221
|
+
#### 0.13
|
|
222
|
+
- [ ] config release pipeline
|
|
223
|
+
- [ ]
|
|
211
224
|
|
|
212
225
|
## Using with pydantic-resolve
|
|
213
226
|
|
|
@@ -229,35 +242,3 @@ pydantic-resolve's @ensure_subset decorator is helpful to pick fields from `sour
|
|
|
229
242
|
- [pydantic-resolve](https://github.com/allmonday/pydantic-resolve)
|
|
230
243
|
- Quasar
|
|
231
244
|
|
|
232
|
-
|
|
233
|
-
## Changelog
|
|
234
|
-
|
|
235
|
-
- 0.9:
|
|
236
|
-
- 0.9.2:
|
|
237
|
-
- fix: missing fields in schema detail panel
|
|
238
|
-
- optimization: clean up fe codes.
|
|
239
|
-
- 0.9.1:
|
|
240
|
-
- api change: from `create_app_with_fastapi` to `create_voyager`, and expose as `from fastapi_voyager import create_voyager`
|
|
241
|
-
- optimization: lazy load vscode link and source code, speed up the initialization.
|
|
242
|
-
- 0.8:
|
|
243
|
-
- 0.8.3
|
|
244
|
-
- upgrade theme
|
|
245
|
-
- 0.8.2
|
|
246
|
-
- fix silly typo.
|
|
247
|
-
- 0.8.1
|
|
248
|
-
- add feature: hide primitive routes
|
|
249
|
-
- 0.7:
|
|
250
|
-
- 0.7.5
|
|
251
|
-
- fix show all display issue
|
|
252
|
-
- 0.7.4
|
|
253
|
-
- optimize tag/route, move to left.
|
|
254
|
-
- fresh on change, no need to click generate any more.
|
|
255
|
-
- 0.7.3
|
|
256
|
-
- fix `module_color` failure
|
|
257
|
-
- 0.7.2
|
|
258
|
-
- keep links inside filtered nodes.
|
|
259
|
-
- 0.7.1
|
|
260
|
-
- support brief mode, you can use `--module_prefix tests.service` to show links between routes and filtered schemas, to make the graph less complicated.
|
|
261
|
-
- 0.6:
|
|
262
|
-
- 0.6.2:
|
|
263
|
-
- fix generic related issue
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
__all__ = ["__version__"]
|
|
2
|
-
__version__ = "0.9.
|
|
2
|
+
__version__ = "0.9.4"
|
|
@@ -144,6 +144,11 @@ class Voyager:
|
|
|
144
144
|
"""
|
|
145
145
|
full_name = full_class_name(schema)
|
|
146
146
|
bases_fields = get_bases_fields([s for s in schema.__bases__ if is_inheritance_of_pydantic_base(s)])
|
|
147
|
+
|
|
148
|
+
subset_reference = getattr(schema, const.ENSURE_SUBSET_REFERENCE, None)
|
|
149
|
+
if subset_reference and is_inheritance_of_pydantic_base(subset_reference):
|
|
150
|
+
bases_fields.update(get_bases_fields([subset_reference]))
|
|
151
|
+
|
|
147
152
|
if full_name not in self.node_set:
|
|
148
153
|
# skip meta info for normal queries
|
|
149
154
|
self.node_set[full_name] = SchemaNode(
|
|
@@ -3,12 +3,10 @@ const { defineComponent, ref, watch, onMounted } = window.Vue;
|
|
|
3
3
|
// Component: RouteCodeDisplay
|
|
4
4
|
// Props:
|
|
5
5
|
// routeId: route id key in routeItems
|
|
6
|
-
// modelValue: dialog visibility
|
|
7
6
|
export default defineComponent({
|
|
8
7
|
name: "RouteCodeDisplay",
|
|
9
8
|
props: {
|
|
10
9
|
routeId: { type: String, required: true },
|
|
11
|
-
modelValue: { type: Boolean, default: false },
|
|
12
10
|
},
|
|
13
11
|
emits: ["close"],
|
|
14
12
|
setup(props, { emit }) {
|
|
@@ -99,32 +97,26 @@ export default defineComponent({
|
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
|
|
102
|
-
watch(
|
|
103
|
-
() => props.modelValue,
|
|
104
|
-
(v) => {
|
|
105
|
-
if (v) load();
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
100
|
watch(
|
|
109
101
|
() => props.routeId,
|
|
110
102
|
() => {
|
|
111
|
-
|
|
103
|
+
load();
|
|
112
104
|
}
|
|
113
105
|
);
|
|
114
106
|
|
|
115
107
|
onMounted(() => {
|
|
116
|
-
|
|
108
|
+
load();
|
|
117
109
|
});
|
|
118
110
|
|
|
119
111
|
return { loading, code, error, close, link };
|
|
120
112
|
},
|
|
121
113
|
template: `
|
|
122
|
-
<div class="frv-route-code-display" style="border:1px solid #ccc; position:relative;
|
|
114
|
+
<div class="frv-route-code-display" style="border:1px solid #ccc; position:relative; background:#fff;">
|
|
123
115
|
<q-btn dense flat round icon="close" @click="close" aria-label="Close" style="position:absolute; top:6px; right:6px; z-index:10; background:rgba(255,255,255,0.85)" />
|
|
124
116
|
<div v-if="link" class="q-ml-md q-mt-md" style="padding-top:4px;">
|
|
125
117
|
<a :href="link" target="_blank" rel="noopener" style="font-size:12px; color:#3b82f6;">Open in VSCode</a>
|
|
126
118
|
</div>
|
|
127
|
-
<div style="padding:40px 16px 16px 16px;
|
|
119
|
+
<div style="padding:40px 16px 16px 16px; box-sizing:border-box; overflow:auto;">
|
|
128
120
|
<div v-if="loading" style="font-family:Menlo, monospace; font-size:12px;">Loading source...</div>
|
|
129
121
|
<div v-else-if="error" style="color:#c10015; font-family:Menlo, monospace; font-size:12px;">{{ error }}</div>
|
|
130
122
|
<pre v-else style="margin:0;"><code class="language-python">{{ code }}</code></pre>
|
|
@@ -13,23 +13,17 @@ export default defineComponent({
|
|
|
13
13
|
name: "SchemaCodeDisplay",
|
|
14
14
|
props: {
|
|
15
15
|
schemaName: { type: String, required: true },
|
|
16
|
-
modelValue: { type: Boolean, default: false },
|
|
17
16
|
schemas: { type: Object, default: () => ({}) },
|
|
18
17
|
},
|
|
19
|
-
emits: ["close"],
|
|
20
18
|
setup(props, { emit }) {
|
|
21
|
-
const loading = ref(false);
|
|
22
19
|
const code = ref("");
|
|
23
20
|
const link = ref("");
|
|
24
21
|
const error = ref("");
|
|
25
22
|
const fields = ref([]); // schema fields list
|
|
26
|
-
const tab = ref("
|
|
23
|
+
const tab = ref("fields");
|
|
27
24
|
|
|
28
|
-
function close() {
|
|
29
|
-
emit("close");
|
|
30
|
-
}
|
|
31
25
|
|
|
32
|
-
function highlightLater() {
|
|
26
|
+
async function highlightLater() {
|
|
33
27
|
// wait a tick for DOM update
|
|
34
28
|
requestAnimationFrame(() => {
|
|
35
29
|
try {
|
|
@@ -38,6 +32,10 @@ export default defineComponent({
|
|
|
38
32
|
".frv-code-display pre code.language-python"
|
|
39
33
|
);
|
|
40
34
|
if (block) {
|
|
35
|
+
// If already highlighted by highlight.js, remove the flag so it can be highlighted again
|
|
36
|
+
if (block.dataset && block.dataset.highlighted) {
|
|
37
|
+
block.removeAttribute("data-highlighted");
|
|
38
|
+
}
|
|
41
39
|
window.hljs.highlightElement(block);
|
|
42
40
|
}
|
|
43
41
|
}
|
|
@@ -50,7 +48,6 @@ export default defineComponent({
|
|
|
50
48
|
async function loadSource() {
|
|
51
49
|
if (!props.schemaName) return;
|
|
52
50
|
|
|
53
|
-
loading.value = true;
|
|
54
51
|
error.value = null;
|
|
55
52
|
code.value = "";
|
|
56
53
|
link.value = "";
|
|
@@ -77,7 +74,6 @@ export default defineComponent({
|
|
|
77
74
|
} catch (e) {
|
|
78
75
|
error.value = "Failed to load source";
|
|
79
76
|
} finally {
|
|
80
|
-
loading.value = false;
|
|
81
77
|
}
|
|
82
78
|
|
|
83
79
|
try {
|
|
@@ -99,12 +95,12 @@ export default defineComponent({
|
|
|
99
95
|
} catch (e) {
|
|
100
96
|
error.value = "Failed to load source";
|
|
101
97
|
} finally {
|
|
102
|
-
loading.value = false;
|
|
103
98
|
}
|
|
104
99
|
|
|
105
|
-
|
|
100
|
+
const schema = props.schemas && props.schemas[props.schemaName];
|
|
101
|
+
fields.value = Array.isArray(schema?.fields) ? schema.fields : [];
|
|
106
102
|
|
|
107
|
-
if (
|
|
103
|
+
if (tab.value === "source") {
|
|
108
104
|
highlightLater();
|
|
109
105
|
}
|
|
110
106
|
}
|
|
@@ -120,25 +116,21 @@ export default defineComponent({
|
|
|
120
116
|
);
|
|
121
117
|
|
|
122
118
|
watch(
|
|
123
|
-
() => props.
|
|
124
|
-
(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
}
|
|
119
|
+
() => props.schemaName,
|
|
120
|
+
() => {
|
|
121
|
+
loadSource();
|
|
122
|
+
},
|
|
129
123
|
);
|
|
130
124
|
|
|
131
125
|
onMounted(() => {
|
|
132
|
-
|
|
126
|
+
loadSource();
|
|
133
127
|
});
|
|
134
128
|
|
|
135
|
-
return {
|
|
129
|
+
return { link, code, error, fields, tab };
|
|
136
130
|
},
|
|
137
131
|
template: `
|
|
138
|
-
<div class="frv-code-display" style="border: 1px solid #ccc; border-left: none; position:relative;
|
|
139
|
-
|
|
140
|
-
style="position:absolute; top:6px; right:6px; z-index:10; background:rgba(255,255,255,0.85)" />
|
|
141
|
-
<div v-if="link" class="q-ml-md q-mt-md">
|
|
132
|
+
<div class="frv-code-display" style="border: 1px solid #ccc; border-left: none; position:relative; height:100%; background:#fff;">
|
|
133
|
+
<div class="q-ml-lg q-mt-md">
|
|
142
134
|
<a :href="link" target="_blank" rel="noopener" style="font-size:12px; color:#3b82f6;">
|
|
143
135
|
Open in VSCode
|
|
144
136
|
</a>
|
|
@@ -146,25 +138,21 @@ export default defineComponent({
|
|
|
146
138
|
|
|
147
139
|
<div style="padding:8px 12px 0 12px; box-sizing:border-box;">
|
|
148
140
|
<q-tabs v-model="tab" align="left" dense active-color="primary" indicator-color="primary" class="text-grey-8">
|
|
149
|
-
<q-tab name="source" label="Source Code" />
|
|
150
141
|
<q-tab name="fields" label="Fields" />
|
|
142
|
+
<q-tab name="source" label="Source Code" />
|
|
151
143
|
</q-tabs>
|
|
152
144
|
</div>
|
|
153
145
|
<q-separator />
|
|
154
|
-
<div style="padding:8px 16px 16px 16px;
|
|
155
|
-
<div v-if="
|
|
156
|
-
<div v-else-if="error" style="color:#c10015; font-family:Menlo, monospace; font-size:12px;">{{ error }}</div>
|
|
146
|
+
<div style="padding:8px 16px 16px 16px; box-sizing:border-box; overflow:auto;">
|
|
147
|
+
<div v-if="error" style="color:#c10015; font-family:Menlo, monospace; font-size:12px;">{{ error }}</div>
|
|
157
148
|
<template v-else>
|
|
158
|
-
<div v-show="tab === 'source'">
|
|
159
|
-
<pre style="margin:0;"><code class="language-python">{{ code }}</code></pre>
|
|
160
|
-
</div>
|
|
161
149
|
<div v-show="tab === 'fields'">
|
|
162
150
|
<table style="border-collapse:collapse; width:100%; font-size:12px; font-family:Menlo, monospace;">
|
|
163
151
|
<thead>
|
|
164
152
|
<tr>
|
|
165
153
|
<th style="text-align:left; border-bottom:1px solid #ddd; padding:4px 6px;">Field</th>
|
|
166
154
|
<th style="text-align:left; border-bottom:1px solid #ddd; padding:4px 6px;">Type</th>
|
|
167
|
-
<th style="text-align:left; border-bottom:1px solid #ddd; padding:4px 6px;">
|
|
155
|
+
<th style="text-align:left; border-bottom:1px solid #ddd; padding:4px 6px;">Inherited</th>
|
|
168
156
|
</tr>
|
|
169
157
|
</thead>
|
|
170
158
|
<tbody>
|
|
@@ -179,6 +167,9 @@ export default defineComponent({
|
|
|
179
167
|
</tbody>
|
|
180
168
|
</table>
|
|
181
169
|
</div>
|
|
170
|
+
<div v-show="tab === 'source'">
|
|
171
|
+
<pre style="margin:0;"><code class="language-python">{{ code }}</code></pre>
|
|
172
|
+
</div>
|
|
182
173
|
</template>
|
|
183
174
|
</div>
|
|
184
175
|
</div>
|
|
@@ -69,23 +69,27 @@ export class GraphUI {
|
|
|
69
69
|
const set = $();
|
|
70
70
|
set.push(this);
|
|
71
71
|
const obj = { set, direction: "bidirectional" };
|
|
72
|
-
|
|
72
|
+
|
|
73
|
+
const schemaName = event.currentTarget.dataset.name;
|
|
73
74
|
if (event.shiftKey && self.options.onSchemaClick) {
|
|
74
75
|
// try data-name or title text
|
|
75
|
-
const schemaName = event.currentTarget.dataset.name;
|
|
76
76
|
if (schemaName) {
|
|
77
77
|
try {
|
|
78
|
-
self.options.
|
|
78
|
+
self.options.onSchemaShiftClick(schemaName);
|
|
79
79
|
} catch (e) {
|
|
80
|
-
console.warn("
|
|
80
|
+
console.warn("onSchemaShiftClick callback failed", e);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
} else if (event.altKey && self.options.onSchemaAltClick) {
|
|
84
|
-
const schemaName = event.currentTarget.dataset.name;
|
|
85
|
-
self.options.onSchemaAltClick(schemaName);
|
|
86
83
|
} else {
|
|
87
84
|
self.currentSelection = [obj];
|
|
88
85
|
self._highlight();
|
|
86
|
+
if (schemaName) {
|
|
87
|
+
try {
|
|
88
|
+
self.options.onSchemaClick(schemaName);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
console.warn("onSchemaClick callback failed", e);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
89
93
|
}
|
|
90
94
|
});
|
|
91
95
|
|
|
@@ -101,6 +105,31 @@ export class GraphUI {
|
|
|
101
105
|
self._highlight();
|
|
102
106
|
});
|
|
103
107
|
|
|
108
|
+
// svg 背景点击高亮清空
|
|
109
|
+
|
|
110
|
+
$(document).off('click.graphui').on('click.graphui', function (evt) {
|
|
111
|
+
// 如果点击目标不在 graph 容器内,直接退出
|
|
112
|
+
const graphContainer = $(self.selector)[0];
|
|
113
|
+
if (!graphContainer || !evt.target || !graphContainer.contains(evt.target)) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let isNode = false;
|
|
118
|
+
const $nodes = self.gv.nodes();
|
|
119
|
+
const node = evt.target.parentNode;
|
|
120
|
+
$nodes.each(function () {
|
|
121
|
+
if (this === node) {
|
|
122
|
+
isNode = true;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
if (!isNode && self.gv) {
|
|
126
|
+
self.gv.highlight();
|
|
127
|
+
if (self.options.resetCb) {
|
|
128
|
+
self.options.resetCb();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
104
133
|
$(document).on("keydown.graphui", function (evt) {
|
|
105
134
|
if (evt.keyCode === 27 && self.gv) {
|
|
106
135
|
self.gv.highlight();
|