@yuneta/gobj-ui 7.27.25 → 7.27.27
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.
- package/README.md +93 -29
- package/dist/gobj-ui.cjs.js +38450 -37624
- package/dist/gobj-ui.es.js +38445 -37619
- package/package.json +4 -4
- package/src/c_g6_nodes_tree.js +36 -96
- package/src/c_yui_gclass.css +104 -22
- package/src/c_yui_gclass.js +413 -94
- package/src/c_yui_gobj_tree_js.js +544 -144
- package/src/gclass_traces.wiring.test.js +235 -0
- package/src/gobj_tree_camera.wiring.test.js +44 -4
- package/src/gobj_tree_model.js +93 -17
- package/src/gobj_tree_model.test.js +48 -3
- package/src/gobj_tree_remote.wiring.test.js +84 -7
- package/src/yui_gclass_view.js +11 -0
- package/src/yui_graph_minimap.js +128 -0
|
@@ -16,24 +16,40 @@
|
|
|
16
16
|
* out EV_TRACE_INFO_WANTED {gclass} a card was opened
|
|
17
17
|
* in EV_TRACE_INFO {gclass, gclass_levels, global_levels,
|
|
18
18
|
* gclass_on, global_on, error}
|
|
19
|
-
* out EV_SET_TRACE_LEVEL {scope: "gobj"|"gclass",
|
|
20
|
-
* gclass, levels: [...], set}
|
|
19
|
+
* out EV_SET_TRACE_LEVEL {scope: "gobj"|"gclass"|"global",
|
|
20
|
+
* gobj, gclass, levels: [...], set}
|
|
21
21
|
* out EV_GCLASS_WANTED {gclass} the gclass button
|
|
22
22
|
* in EV_GCLASS_DESCRIPTION {gclass, description}
|
|
23
23
|
*
|
|
24
24
|
* The host loads the FIRST tree on its own (it opened the
|
|
25
25
|
* view); the view asks again only when Refresh is pressed.
|
|
26
26
|
* After a trace is set the host loads the tree and the
|
|
27
|
-
* trace info again:
|
|
27
|
+
* trace info of `gclass` again: what the reader is on stays
|
|
28
|
+
* open.
|
|
28
29
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
30
|
+
* TRACES, in "remote": three scopes, each where it belongs.
|
|
31
|
+
* The kernel's levels (`machine`, `create_delete`...; the
|
|
32
|
+
* table gobj.c calls "global") are valid in all three, a
|
|
33
|
+
* gclass' own levels in the first two:
|
|
34
|
+
*
|
|
35
|
+
* this gobj the popover of its card: one box per
|
|
36
|
+
* level (`set-gobj-trace`). A level its
|
|
37
|
+
* gclass or the yuno holds is on and
|
|
38
|
+
* locked, saying which.
|
|
39
|
+
* every gobj of the gclass viewer the card's GClass
|
|
40
|
+
* the gclass button opens: its `trace levels` zone
|
|
41
|
+
* (`set-gclass-trace`). The viewer is this
|
|
42
|
+
* view's child and publishes
|
|
43
|
+
* EV_SET_GCLASS_TRACE {gclass, levels, set},
|
|
44
|
+
* which goes out as EV_SET_TRACE_LEVEL.
|
|
45
|
+
* the whole yuno the toolbar's `traces of the yuno`, in
|
|
46
|
+
* the popover (`set-global-trace`). Its
|
|
47
|
+
* levels are read with EV_TRACE_INFO_WANTED
|
|
48
|
+
* of the ROOT's gclass, whose answer
|
|
49
|
+
* carries them like every other one.
|
|
50
|
+
*
|
|
51
|
+
* A gclass or yuno level is saved by the yuno and survives a
|
|
52
|
+
* restart; a gobj level lasts until the yuno ends.
|
|
37
53
|
*
|
|
38
54
|
* The output events are published ONLY in "remote", so a host
|
|
39
55
|
* of a local tree (the Frontend view) declares none of them.
|
|
@@ -61,6 +77,7 @@ import {
|
|
|
61
77
|
kw_set_local_storage_value,
|
|
62
78
|
gobj_write_str_attr,
|
|
63
79
|
gobj_read_str_attr,
|
|
80
|
+
gobj_read_integer_attr,
|
|
64
81
|
gobj_yuno,
|
|
65
82
|
gobj_yuno_name,
|
|
66
83
|
gobj_short_name,
|
|
@@ -83,7 +100,9 @@ import {
|
|
|
83
100
|
node_status,
|
|
84
101
|
node_status_key,
|
|
85
102
|
node_status_symbol,
|
|
103
|
+
node_can_pause,
|
|
86
104
|
trace_rows,
|
|
105
|
+
global_trace_rows,
|
|
87
106
|
own_trace_levels,
|
|
88
107
|
} from "./gobj_tree_model.js";
|
|
89
108
|
import {text_node} from "./yui_text.js";
|
|
@@ -123,6 +142,7 @@ import { ensure_pinch_zoom_patch } from "./g6_touch_gestures.js";
|
|
|
123
142
|
import { yui_is_dark, yui_theme_now, yui_watch_theme } from "./yui_theme.js";
|
|
124
143
|
import {g6_event_kw} from "./g6_event_kw.js";
|
|
125
144
|
import {keep_canvas_tab_order} from "./g6_canvas_tab_order.js";
|
|
145
|
+
import {yui_graph_minimap_options, yui_graph_minimap_block} from "./yui_graph_minimap.js";
|
|
126
146
|
|
|
127
147
|
/***************************************************************
|
|
128
148
|
* Constants
|
|
@@ -148,6 +168,7 @@ SDATA(data_type_t.DTP_STRING, "yuno_name", 0, "", "remote: the nam
|
|
|
148
168
|
SDATA(data_type_t.DTP_STRING, "wide", 0, "40px", "Height of header. 40px and not 36: it is what an untouched Bulma control measures, so the find box stood 4px taller than every button beside it, and it is what the third graph of the family (C_YUI_TREEDB_GRAPH) uses"),
|
|
149
169
|
SDATA(data_type_t.DTP_STRING, "layout", 0, "vertical-compact", "Current layout key"),
|
|
150
170
|
SDATA(data_type_t.DTP_INTEGER, "collapse_threshold", 0, 10, "Auto-collapse a node whose direct children exceed this number. 0 disables auto-collapse."),
|
|
171
|
+
SDATA(data_type_t.DTP_INTEGER, "minimap_min_nodes", 0, 20, "Show the minimap from this many cards on (0 = never). Lower than the treedb graph's 30: this tree opens at actual size, not fitted, so the reader is past its edge sooner"),
|
|
151
172
|
|
|
152
173
|
SDATA_END()
|
|
153
174
|
];
|
|
@@ -447,6 +468,8 @@ let PRIVATE_DATA = {
|
|
|
447
468
|
remote_root: null, // the descriptor of the backend tree, as last loaded
|
|
448
469
|
trace_info: {}, // gclass -> {gclass_levels, global_levels, gclass_on, global_on, error}
|
|
449
470
|
trace_pending: false, // a trace was set: the block is locked until the host answers
|
|
471
|
+
popover_mode: "", // what the popover shows: "node" (a card) | "yuno" (the yuno's traces)
|
|
472
|
+
viewer_stale: "", // a gclass whose open viewer must be asked again after a yuno set
|
|
450
473
|
view_refused: false, // the saved camera showed no card: the opening's framing replaces it
|
|
451
474
|
};
|
|
452
475
|
|
|
@@ -569,7 +592,13 @@ function status_card_style(d, dark)
|
|
|
569
592
|
if(d.disabled) {
|
|
570
593
|
return table.disabled;
|
|
571
594
|
}
|
|
572
|
-
|
|
595
|
+
let status = node_status(d);
|
|
596
|
+
if(status === "running" && !node_can_pause(d)) {
|
|
597
|
+
/* Nothing to play: running is all it does, so it wears the
|
|
598
|
+
* green of a gobj at work, not the amber of a pause. */
|
|
599
|
+
return table.playing;
|
|
600
|
+
}
|
|
601
|
+
return table[status] || table.stopped;
|
|
573
602
|
}
|
|
574
603
|
|
|
575
604
|
/***************************************************************
|
|
@@ -1233,6 +1262,28 @@ function make_toolbar(gobj)
|
|
|
1233
1262
|
}]
|
|
1234
1263
|
);
|
|
1235
1264
|
priv.$layout_select = $wrap.querySelector("select");
|
|
1265
|
+
|
|
1266
|
+
/* The yuno's own scope of traces (`set-global-trace`) is the
|
|
1267
|
+
* yuno's, not any one gobj's: it opens from here, not from a card.
|
|
1268
|
+
* Its label goes on mobile -- the row is full there. */
|
|
1269
|
+
if(is_remote(gobj)) {
|
|
1270
|
+
right_items.push(createElement2(['button', {
|
|
1271
|
+
type: 'button',
|
|
1272
|
+
class: 'GOBJ_TREE_YUNO_TRACES_BUTTON button',
|
|
1273
|
+
style: {height: toolbar_wide, "margin-left": "0.5em"},
|
|
1274
|
+
title: t("traces of the yuno"), 'data-i18n-title': "traces of the yuno",
|
|
1275
|
+
'aria-label': t("traces of the yuno"), 'data-i18n-aria-label': "traces of the yuno",
|
|
1276
|
+
}, [
|
|
1277
|
+
['span', {class: 'icon'}, [['i', {class: 'yi-list-check'}]]],
|
|
1278
|
+
['span', {class: 'is-hidden-mobile', i18n: "traces of the yuno"},
|
|
1279
|
+
t("traces of the yuno")]
|
|
1280
|
+
], {
|
|
1281
|
+
click: (evt) => {
|
|
1282
|
+
evt.stopPropagation();
|
|
1283
|
+
gobj_send_event(gobj, "EV_OPEN_YUNO_TRACES", {}, gobj);
|
|
1284
|
+
}
|
|
1285
|
+
}]));
|
|
1286
|
+
}
|
|
1236
1287
|
right_items.push($wrap);
|
|
1237
1288
|
|
|
1238
1289
|
const $toolbar = yui_toolbar({}, [
|
|
@@ -1416,6 +1467,76 @@ function apply_layout(gobj)
|
|
|
1416
1467
|
});
|
|
1417
1468
|
}
|
|
1418
1469
|
|
|
1470
|
+
/************************************************************
|
|
1471
|
+
* The minimap plugin of the graph, or null when it has none.
|
|
1472
|
+
************************************************************/
|
|
1473
|
+
function minimap_plugin(gobj)
|
|
1474
|
+
{
|
|
1475
|
+
let graph = gobj.priv.graph;
|
|
1476
|
+
let plugins = graph.getPlugins() || [];
|
|
1477
|
+
if(!plugins.some((p) => typeof p === "object" && p.key === "minimap")) {
|
|
1478
|
+
return null;
|
|
1479
|
+
}
|
|
1480
|
+
return graph.getPluginInstance("minimap") || null;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
/************************************************************
|
|
1484
|
+
* Show or hide the minimap, deciding by the number of cards
|
|
1485
|
+
* about to be drawn (`n`).
|
|
1486
|
+
*
|
|
1487
|
+
* A minimap of a tree that fits on screen is decoration; one of
|
|
1488
|
+
* a yuno with a thousand gobjs is the only way to know where you
|
|
1489
|
+
* are. So it is not a setting the reader has to find: it appears
|
|
1490
|
+
* from `minimap_min_nodes` cards on.
|
|
1491
|
+
*
|
|
1492
|
+
* Called BEFORE the render, not after it: the minimap builds its
|
|
1493
|
+
* canvas off the graph's render events, so one added after the
|
|
1494
|
+
* last render is bound and never painted. Its frame and anchor
|
|
1495
|
+
* are the library's (yui_graph_minimap.js); its blocks wear the
|
|
1496
|
+
* ROLE colour of their card, the one the card's border wears --
|
|
1497
|
+
* read at each paint, so a change of theme repaints them with
|
|
1498
|
+
* the tree.
|
|
1499
|
+
************************************************************/
|
|
1500
|
+
function refresh_minimap(gobj, n)
|
|
1501
|
+
{
|
|
1502
|
+
let graph = gobj.priv.graph;
|
|
1503
|
+
let threshold = gobj_read_integer_attr(gobj, "minimap_min_nodes");
|
|
1504
|
+
let plugin = minimap_plugin(gobj);
|
|
1505
|
+
|
|
1506
|
+
if(!threshold || n < threshold) {
|
|
1507
|
+
if(plugin) {
|
|
1508
|
+
graph.setPlugins((graph.getPlugins() || []).filter(
|
|
1509
|
+
(p) => !(typeof p === "object" && p.key === "minimap")
|
|
1510
|
+
));
|
|
1511
|
+
if(!plugin.destroyed && plugin.destroy) {
|
|
1512
|
+
plugin.destroy();
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
return;
|
|
1516
|
+
}
|
|
1517
|
+
if(plugin) {
|
|
1518
|
+
return; /* already up */
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
let shape = (id, element_type, element) => {
|
|
1522
|
+
if(element_type !== "node") {
|
|
1523
|
+
return element; /* edges clone themselves fine */
|
|
1524
|
+
}
|
|
1525
|
+
try {
|
|
1526
|
+
let nd = graph.getNodeData(id);
|
|
1527
|
+
let colors = get_role_colors(nd && nd.data);
|
|
1528
|
+
return yui_graph_minimap_block(nd, yui_is_dark()? colors.accent: colors.stroke);
|
|
1529
|
+
} catch(e) {
|
|
1530
|
+
log_error(`${gobj_short_name(gobj)}: minimap shape failed: ${e}`);
|
|
1531
|
+
return element;
|
|
1532
|
+
}
|
|
1533
|
+
};
|
|
1534
|
+
graph.setPlugins((plugins) => [
|
|
1535
|
+
...plugins,
|
|
1536
|
+
{key: "minimap", type: "minimap", ...yui_graph_minimap_options(shape)}
|
|
1537
|
+
]);
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1419
1540
|
/************************************************************
|
|
1420
1541
|
* The role colours of a node.
|
|
1421
1542
|
*
|
|
@@ -1838,6 +1959,12 @@ function load_tree(gobj)
|
|
|
1838
1959
|
|
|
1839
1960
|
build_gobj_nodes(gobj, root, nodes, edges, null, layout_cfg.compact, labels);
|
|
1840
1961
|
|
|
1962
|
+
try {
|
|
1963
|
+
refresh_minimap(gobj, nodes.length);
|
|
1964
|
+
} catch(e) {
|
|
1965
|
+
log_error(`${gobj_short_name(gobj)}: refresh_minimap failed: ${e}`);
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1841
1968
|
if(nodes.length > 0) {
|
|
1842
1969
|
let root_id = nodes[0].id; /* built before its children */
|
|
1843
1970
|
graph.setData({nodes: nodes, edges: edges});
|
|
@@ -2060,40 +2187,116 @@ function is_remote(gobj)
|
|
|
2060
2187
|
}
|
|
2061
2188
|
|
|
2062
2189
|
/************************************************************
|
|
2063
|
-
*
|
|
2190
|
+
* Paint again whatever the popover is showing: a card, or
|
|
2191
|
+
* the yuno's traces.
|
|
2192
|
+
************************************************************/
|
|
2193
|
+
function render_current_popover(gobj)
|
|
2194
|
+
{
|
|
2195
|
+
let priv = gobj.priv;
|
|
2196
|
+
if(!priv.$popover || priv.$popover.style.display !== "block") {
|
|
2197
|
+
return;
|
|
2198
|
+
}
|
|
2199
|
+
if(priv.popover_mode === "yuno") {
|
|
2200
|
+
priv.$popover_body.textContent = "";
|
|
2201
|
+
priv.$popover_body.appendChild(build_yuno_traces_block(gobj));
|
|
2202
|
+
} else if(priv.popover_node) {
|
|
2203
|
+
render_popover_body(gobj, priv.popover_node);
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
/************************************************************
|
|
2208
|
+
* The TRACES block of a backend gobj's popover: what THIS
|
|
2209
|
+
* gobj traces (`set-gobj-trace`), one row per level -- the
|
|
2210
|
+
* gclass' own, then the kernel's (trace_rows() in the model).
|
|
2064
2211
|
*
|
|
2065
|
-
*
|
|
2066
|
-
*
|
|
2067
|
-
*
|
|
2068
|
-
*
|
|
2069
|
-
*
|
|
2070
|
-
*
|
|
2071
|
-
*
|
|
2212
|
+
* ONE scope here, the gobj's. The other two live where they
|
|
2213
|
+
* belong: every gobj of the gclass in the gclass viewer (its
|
|
2214
|
+
* `trace levels` zone), the whole yuno behind the toolbar's
|
|
2215
|
+
* `traces of the yuno`. A level one of them holds is shown on
|
|
2216
|
+
* and LOCKED here, saying which one, because unticking the
|
|
2217
|
+
* gobj's own bit would not stop it.
|
|
2218
|
+
*
|
|
2219
|
+
* A box is an action: its change goes to the FSM, which
|
|
2220
|
+
* publishes it to the host, and the block stays locked until
|
|
2221
|
+
* the host has loaded what the backend says now -- the box
|
|
2222
|
+
* shows the backend's state, not the click.
|
|
2072
2223
|
************************************************************/
|
|
2073
2224
|
const TRACES_NOTE_STYLE = 'color:var(--bulma-text-weak, #6B7280); margin:4px 0;';
|
|
2074
2225
|
const TRACES_CELL_STYLE = 'padding:1px 4px; text-align:center;';
|
|
2226
|
+
const TRACES_ORIGIN_STYLE = 'margin-left:6px; color:var(--bulma-text-weak, #6B7280);';
|
|
2227
|
+
const TRACES_BUTTON_STYLE = 'padding:0 8px; height:22px; font-size:11px; white-space:nowrap;';
|
|
2228
|
+
|
|
2229
|
+
/* What the block says while the levels are not in, or could not be
|
|
2230
|
+
* read. Null when they are. */
|
|
2231
|
+
function traces_state_note(info)
|
|
2232
|
+
{
|
|
2233
|
+
if(!info) {
|
|
2234
|
+
return ['div', {class: 'GOBJ_TREE_TRACES_NOTE', i18n: 'loading',
|
|
2235
|
+
style: TRACES_NOTE_STYLE}, t('loading')];
|
|
2236
|
+
}
|
|
2237
|
+
if(info.error) {
|
|
2238
|
+
return ['div', {class: 'GOBJ_TREE_TRACES_ERROR',
|
|
2239
|
+
style: 'color:var(--bulma-danger, #dc2626); margin:4px 0;'},
|
|
2240
|
+
text_node(info.error)];
|
|
2241
|
+
}
|
|
2242
|
+
return null;
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
/* The level cell: its name, the backend's own text for it as the
|
|
2246
|
+
* tooltip (data, not a key), and where an inherited level comes
|
|
2247
|
+
* from. */
|
|
2248
|
+
function trace_level_cell(level, description, $origin)
|
|
2249
|
+
{
|
|
2250
|
+
let $level = createElement2(['td', {class: 'GOBJ_TREE_TRACES_LEVEL',
|
|
2251
|
+
style: 'padding:1px 4px; word-break:break-all;'}, []]);
|
|
2252
|
+
$level.appendChild(text_node(level));
|
|
2253
|
+
if($origin) {
|
|
2254
|
+
$level.appendChild($origin);
|
|
2255
|
+
}
|
|
2256
|
+
$level.setAttribute('title', description);
|
|
2257
|
+
return $level;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
function trace_group_row(span, $label)
|
|
2261
|
+
{
|
|
2262
|
+
return ['tr', {class: 'GOBJ_TREE_TRACES_GROUP'}, [
|
|
2263
|
+
['td', {colspan: span, style: 'padding:4px 4px 1px 4px; font-weight:600; ' +
|
|
2264
|
+
'color:var(--bulma-text-weak, #6B7280);'}, [$label]]
|
|
2265
|
+
]];
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
/* `names` are the button's i18n, title and aria-label, written by the
|
|
2269
|
+
* caller with its literal key; `$label` its text. */
|
|
2270
|
+
function traces_remove_button(gobj, scope, names, $label, disabled)
|
|
2271
|
+
{
|
|
2272
|
+
let $b = createElement2(['button', Object.assign({
|
|
2273
|
+
type: 'button',
|
|
2274
|
+
class: `GOBJ_TREE_TRACES_CLEAR_${scope.toUpperCase()} button is-small`,
|
|
2275
|
+
style: TRACES_BUTTON_STYLE,
|
|
2276
|
+
}, names), [$label], {
|
|
2277
|
+
click: (evt) => {
|
|
2278
|
+
evt.stopPropagation();
|
|
2279
|
+
gobj_send_event(gobj, "EV_TRACES_CLEARED", {scope: scope}, gobj);
|
|
2280
|
+
}
|
|
2281
|
+
}]);
|
|
2282
|
+
$b.disabled = !!disabled;
|
|
2283
|
+
return createElement2(['div', {class: 'GOBJ_TREE_TRACES_TOOLS',
|
|
2284
|
+
style: 'display:flex; flex-wrap:wrap; gap:4px; margin-top:4px;'},
|
|
2285
|
+
[$b]]);
|
|
2286
|
+
}
|
|
2075
2287
|
|
|
2076
2288
|
function build_traces_block(gobj, d)
|
|
2077
2289
|
{
|
|
2078
2290
|
let priv = gobj.priv;
|
|
2079
2291
|
let info = priv.trace_info[d.gclass] || null;
|
|
2080
2292
|
|
|
2081
|
-
let kids = [
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
if(!info) {
|
|
2089
|
-
kids.push(['div', {class: 'GOBJ_TREE_TRACES_NOTE', i18n: 'loading',
|
|
2090
|
-
style: TRACES_NOTE_STYLE}, t('loading')]);
|
|
2091
|
-
return createElement2(['div', {class: 'GOBJ_TREE_TRACES'}, kids]);
|
|
2092
|
-
}
|
|
2093
|
-
if(info.error) {
|
|
2094
|
-
kids.push(['div', {class: 'GOBJ_TREE_TRACES_ERROR',
|
|
2095
|
-
style: 'color:var(--bulma-danger, #dc2626); margin:4px 0;'},
|
|
2096
|
-
text_node(info.error)]);
|
|
2293
|
+
let kids = [['div', {class: 'GOBJ_TREE_TRACES_HEAD', i18n: 'traces of this gobj',
|
|
2294
|
+
style: 'font-weight:700; margin:8px 0 2px 0; padding-top:6px; ' +
|
|
2295
|
+
'border-top:1px solid var(--bulma-border-weak, #E5E7EB);'},
|
|
2296
|
+
t('traces of this gobj')]];
|
|
2297
|
+
let state = traces_state_note(info);
|
|
2298
|
+
if(state) {
|
|
2299
|
+
kids.push(state);
|
|
2097
2300
|
return createElement2(['div', {class: 'GOBJ_TREE_TRACES'}, kids]);
|
|
2098
2301
|
}
|
|
2099
2302
|
|
|
@@ -2105,41 +2308,27 @@ function build_traces_block(gobj, d)
|
|
|
2105
2308
|
for(let r of rows) {
|
|
2106
2309
|
if(r.group !== group) {
|
|
2107
2310
|
group = r.group;
|
|
2108
|
-
|
|
2311
|
+
trs.push(trace_group_row(2, (group === "gclass")?
|
|
2109
2312
|
text_node(d.gclass):
|
|
2110
|
-
createElement2(['span', {i18n: '
|
|
2111
|
-
trs.push(['tr', {class: 'GOBJ_TREE_TRACES_GROUP'}, [
|
|
2112
|
-
['td', {colspan: 3, style: 'padding:4px 4px 1px 4px; font-weight:600; ' +
|
|
2113
|
-
'color:var(--bulma-text-weak, #6B7280);'}, [$label]]
|
|
2114
|
-
]]);
|
|
2313
|
+
createElement2(['span', {i18n: 'kernel levels'}, t('kernel levels')])));
|
|
2115
2314
|
}
|
|
2116
|
-
let origin = null;
|
|
2315
|
+
let $origin = null;
|
|
2117
2316
|
if(r.origin === "global") {
|
|
2118
|
-
origin = ['span', {
|
|
2119
|
-
|
|
2120
|
-
t('
|
|
2317
|
+
$origin = createElement2(['span', {
|
|
2318
|
+
class: 'GOBJ_TREE_TRACES_ORIGIN', i18n: 'yuno', style: TRACES_ORIGIN_STYLE,
|
|
2319
|
+
title: t('on for the whole yuno'), 'data-i18n-title': 'on for the whole yuno',
|
|
2320
|
+
}, t('yuno')]);
|
|
2121
2321
|
} else if(r.origin === "gclass") {
|
|
2122
|
-
origin = ['span', {
|
|
2123
|
-
|
|
2124
|
-
t('gclass')
|
|
2125
|
-
|
|
2126
|
-
let $level = createElement2(['td', {class: 'GOBJ_TREE_TRACES_LEVEL',
|
|
2127
|
-
style: 'padding:1px 4px; word-break:break-all;'}, []]);
|
|
2128
|
-
$level.appendChild(text_node(r.level));
|
|
2129
|
-
if(origin) {
|
|
2130
|
-
$level.appendChild(createElement2(origin));
|
|
2322
|
+
$origin = createElement2(['span', {
|
|
2323
|
+
class: 'GOBJ_TREE_TRACES_ORIGIN', style: TRACES_ORIGIN_STYLE,
|
|
2324
|
+
title: t('on for all of the gclass'), 'data-i18n-title': 'on for all of the gclass',
|
|
2325
|
+
}, [text_node(d.gclass)]]);
|
|
2131
2326
|
}
|
|
2132
|
-
/* What the level does is the backend's text: data, not a key. */
|
|
2133
|
-
$level.setAttribute('title', r.description);
|
|
2134
|
-
|
|
2135
2327
|
trs.push(['tr', {class: 'GOBJ_TREE_TRACES_ROW'}, [
|
|
2136
|
-
|
|
2328
|
+
trace_level_cell(r.level, r.description, $origin),
|
|
2137
2329
|
['td', {style: TRACES_CELL_STYLE}, [
|
|
2138
2330
|
trace_checkbox(gobj, "gobj", r.level, r.gobj_on, pending || r.gobj_locked)
|
|
2139
2331
|
]],
|
|
2140
|
-
['td', {style: TRACES_CELL_STYLE}, [
|
|
2141
|
-
trace_checkbox(gobj, "gclass", r.level, r.gclass_on, pending || r.gclass_locked)
|
|
2142
|
-
]],
|
|
2143
2332
|
]]);
|
|
2144
2333
|
}
|
|
2145
2334
|
|
|
@@ -2149,7 +2338,6 @@ function build_traces_block(gobj, d)
|
|
|
2149
2338
|
['tr', {}, [
|
|
2150
2339
|
['th', {i18n: 'level', style: 'padding:1px 4px; text-align:left;'}, t('level')],
|
|
2151
2340
|
['th', {i18n: 'this gobj', style: TRACES_CELL_STYLE}, t('this gobj')],
|
|
2152
|
-
['th', {i18n: 'all of the gclass', style: TRACES_CELL_STYLE}, t('all of the gclass')],
|
|
2153
2341
|
]]
|
|
2154
2342
|
]],
|
|
2155
2343
|
['tbody', {}, trs]
|
|
@@ -2160,61 +2348,93 @@ function build_traces_block(gobj, d)
|
|
|
2160
2348
|
style: TRACES_NOTE_STYLE},
|
|
2161
2349
|
t('gclass traces survive a restart, gobj traces end with the yuno')]);
|
|
2162
2350
|
|
|
2163
|
-
|
|
2164
|
-
let none_gclass = pending || own_trace_levels(rows, "gclass").length === 0;
|
|
2165
|
-
let btn_style = 'padding:0 8px; height:22px; font-size:11px; white-space:nowrap;';
|
|
2166
|
-
let clear = (scope) => {
|
|
2167
|
-
return {
|
|
2168
|
-
click: (evt) => {
|
|
2169
|
-
evt.stopPropagation();
|
|
2170
|
-
gobj_send_event(gobj, "EV_TRACES_CLEARED", {scope: scope}, gobj);
|
|
2171
|
-
}
|
|
2172
|
-
};
|
|
2173
|
-
};
|
|
2174
|
-
let $clear_gobj = createElement2(['button', {
|
|
2175
|
-
type: 'button', class: 'GOBJ_TREE_TRACES_CLEAR_GOBJ button is-small', style: btn_style,
|
|
2176
|
-
i18n: 'remove the traces of this gobj',
|
|
2351
|
+
kids.push(traces_remove_button(gobj, "gobj", {
|
|
2177
2352
|
title: t('remove the traces of this gobj'),
|
|
2178
2353
|
'data-i18n-title': 'remove the traces of this gobj',
|
|
2179
2354
|
'aria-label': t('remove the traces of this gobj'),
|
|
2180
2355
|
'data-i18n-aria-label': 'remove the traces of this gobj',
|
|
2181
|
-
},
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
i18n: 'remove the traces of the gclass',
|
|
2185
|
-
title: t('remove the traces of the gclass'),
|
|
2186
|
-
'data-i18n-title': 'remove the traces of the gclass',
|
|
2187
|
-
'aria-label': t('remove the traces of the gclass'),
|
|
2188
|
-
'data-i18n-aria-label': 'remove the traces of the gclass',
|
|
2189
|
-
}, t('remove the traces of the gclass'), clear("gclass")]);
|
|
2190
|
-
$clear_gobj.disabled = none_gobj;
|
|
2191
|
-
$clear_gclass.disabled = none_gclass;
|
|
2192
|
-
kids.push(['div', {class: 'GOBJ_TREE_TRACES_TOOLS',
|
|
2193
|
-
style: 'display:flex; flex-wrap:wrap; gap:4px; margin-top:4px;'},
|
|
2194
|
-
[$clear_gobj, $clear_gclass]]);
|
|
2356
|
+
}, createElement2(['span', {i18n: 'remove the traces of this gobj'},
|
|
2357
|
+
t('remove the traces of this gobj')]),
|
|
2358
|
+
pending || own_trace_levels(rows, "gobj").length === 0));
|
|
2195
2359
|
|
|
2196
2360
|
return createElement2(['div', {class: 'GOBJ_TREE_TRACES'}, kids]);
|
|
2197
2361
|
}
|
|
2198
2362
|
|
|
2199
|
-
|
|
2363
|
+
/************************************************************
|
|
2364
|
+
* The yuno's traces (`set-global-trace`): the kernel's levels,
|
|
2365
|
+
* and whether every gobj of the yuno traces each one. Drawn in
|
|
2366
|
+
* the popover, opened from the toolbar, and read from the
|
|
2367
|
+
* answer for the ROOT's gclass -- the yuno itself, whose
|
|
2368
|
+
* answer carries the yuno's levels like every other one.
|
|
2369
|
+
************************************************************/
|
|
2370
|
+
function build_yuno_traces_block(gobj)
|
|
2371
|
+
{
|
|
2372
|
+
let priv = gobj.priv;
|
|
2373
|
+
let root = priv.remote_root;
|
|
2374
|
+
let info = (root && priv.trace_info[root.gclass]) || null;
|
|
2375
|
+
|
|
2376
|
+
let kids = [];
|
|
2377
|
+
let state = traces_state_note(info);
|
|
2378
|
+
if(state) {
|
|
2379
|
+
kids.push(state);
|
|
2380
|
+
return createElement2(['div', {class: 'GOBJ_TREE_YUNO_TRACES'}, kids]);
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
let rows = global_trace_rows(info);
|
|
2384
|
+
let pending = !!priv.trace_pending;
|
|
2385
|
+
|
|
2386
|
+
let trs = rows.map((r) => ['tr', {class: 'GOBJ_TREE_TRACES_ROW'}, [
|
|
2387
|
+
trace_level_cell(r.level, r.description, null),
|
|
2388
|
+
['td', {style: TRACES_CELL_STYLE}, [
|
|
2389
|
+
trace_checkbox(gobj, "global", r.level, r.global_on, pending)
|
|
2390
|
+
]],
|
|
2391
|
+
]]);
|
|
2392
|
+
|
|
2393
|
+
kids.push(['table', {class: 'GOBJ_TREE_TRACES_TABLE',
|
|
2394
|
+
style: 'width:100%; border-collapse:collapse;'}, [
|
|
2395
|
+
['thead', {}, [
|
|
2396
|
+
['tr', {}, [
|
|
2397
|
+
['th', {i18n: 'kernel levels', style: 'padding:1px 4px; text-align:left;'},
|
|
2398
|
+
t('kernel levels')],
|
|
2399
|
+
['th', {i18n: 'the whole yuno', style: TRACES_CELL_STYLE}, t('the whole yuno')],
|
|
2400
|
+
]]
|
|
2401
|
+
]],
|
|
2402
|
+
['tbody', {}, trs]
|
|
2403
|
+
]]);
|
|
2404
|
+
|
|
2405
|
+
kids.push(['div', {class: 'GOBJ_TREE_TRACES_NOTE',
|
|
2406
|
+
i18n: "the yuno's traces survive a restart",
|
|
2407
|
+
style: TRACES_NOTE_STYLE},
|
|
2408
|
+
t("the yuno's traces survive a restart")]);
|
|
2409
|
+
|
|
2410
|
+
kids.push(traces_remove_button(gobj, "global", {
|
|
2411
|
+
title: t('remove the traces of the yuno'),
|
|
2412
|
+
'data-i18n-title': 'remove the traces of the yuno',
|
|
2413
|
+
'aria-label': t('remove the traces of the yuno'),
|
|
2414
|
+
'data-i18n-aria-label': 'remove the traces of the yuno',
|
|
2415
|
+
}, createElement2(['span', {i18n: 'remove the traces of the yuno'},
|
|
2416
|
+
t('remove the traces of the yuno')]),
|
|
2417
|
+
pending || own_trace_levels(rows, "global").length === 0));
|
|
2418
|
+
|
|
2419
|
+
return createElement2(['div', {class: 'GOBJ_TREE_YUNO_TRACES'}, kids]);
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
/* One box of a block. `checked` and `disabled` are set as
|
|
2200
2423
|
* PROPERTIES: createElement2 writes attributes, and an attribute
|
|
2201
2424
|
* `checked="false"` is a checked box. */
|
|
2425
|
+
const TRACE_BOX = {
|
|
2426
|
+
gobj: {cls: 'GOBJ_TREE_TRACE_GOBJ', key: 'this gobj'},
|
|
2427
|
+
global: {cls: 'GOBJ_TREE_TRACE_GLOBAL', key: 'the whole yuno'},
|
|
2428
|
+
};
|
|
2429
|
+
|
|
2202
2430
|
function trace_checkbox(gobj, scope, level, on, locked)
|
|
2203
2431
|
{
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
}]);
|
|
2211
|
-
} else {
|
|
2212
|
-
$cb = createElement2(['input', {
|
|
2213
|
-
type: 'checkbox', class: 'GOBJ_TREE_TRACE_GCLASS',
|
|
2214
|
-
title: t('all of the gclass'), 'data-i18n-title': 'all of the gclass',
|
|
2215
|
-
'aria-label': t('all of the gclass'), 'data-i18n-aria-label': 'all of the gclass',
|
|
2216
|
-
}]);
|
|
2217
|
-
}
|
|
2432
|
+
const box = TRACE_BOX[scope];
|
|
2433
|
+
let $cb = createElement2(['input', {
|
|
2434
|
+
type: 'checkbox', class: box.cls,
|
|
2435
|
+
title: t(box.key), 'data-i18n-title': box.key,
|
|
2436
|
+
'aria-label': t(box.key), 'data-i18n-aria-label': box.key,
|
|
2437
|
+
}]);
|
|
2218
2438
|
$cb.setAttribute('data-level', level);
|
|
2219
2439
|
$cb.checked = !!on;
|
|
2220
2440
|
$cb.disabled = !!locked;
|
|
@@ -2235,13 +2455,22 @@ function reload_keeping_popover(gobj, opts)
|
|
|
2235
2455
|
{
|
|
2236
2456
|
let priv = gobj.priv;
|
|
2237
2457
|
let $popover = priv.$popover;
|
|
2238
|
-
let
|
|
2458
|
+
let shown = !!($popover && $popover.style.display === "block");
|
|
2459
|
+
let keep = (shown && priv.popover_mode === "node" && priv.popover_node)?
|
|
2239
2460
|
priv.popover_node.full_name: null;
|
|
2461
|
+
let keep_yuno = shown && priv.popover_mode === "yuno";
|
|
2240
2462
|
let left = $popover? $popover.style.left: "";
|
|
2241
2463
|
let top = $popover? $popover.style.top: "";
|
|
2242
2464
|
|
|
2243
2465
|
refresh_tree(gobj, opts); /* hides the popover */
|
|
2244
2466
|
|
|
2467
|
+
if(keep_yuno) {
|
|
2468
|
+
open_popover_frame(gobj, "yuno", t("traces of the yuno"));
|
|
2469
|
+
$popover.style.left = left;
|
|
2470
|
+
$popover.style.top = top;
|
|
2471
|
+
render_current_popover(gobj);
|
|
2472
|
+
return;
|
|
2473
|
+
}
|
|
2245
2474
|
if(!keep || !priv.node_by_id) {
|
|
2246
2475
|
return;
|
|
2247
2476
|
}
|
|
@@ -2249,13 +2478,11 @@ function reload_keeping_popover(gobj, opts)
|
|
|
2249
2478
|
let d = priv.node_by_id[id];
|
|
2250
2479
|
if(d.full_name === keep) {
|
|
2251
2480
|
priv.popover_node = d;
|
|
2252
|
-
|
|
2253
|
-
(d.gclass + (d.name ? "^" + d.name : ""));
|
|
2254
|
-
priv.$popover_title.title = priv.$popover_title.textContent;
|
|
2481
|
+
open_popover_frame(gobj, "node", d.short_name ||
|
|
2482
|
+
(d.gclass + (d.name ? "^" + d.name : "")));
|
|
2255
2483
|
render_popover_body(gobj, d);
|
|
2256
2484
|
$popover.style.left = left;
|
|
2257
2485
|
$popover.style.top = top;
|
|
2258
|
-
$popover.style.display = "block";
|
|
2259
2486
|
return;
|
|
2260
2487
|
}
|
|
2261
2488
|
}
|
|
@@ -2277,10 +2504,8 @@ function show_popover(gobj, node_data, client_x, client_y)
|
|
|
2277
2504
|
}
|
|
2278
2505
|
|
|
2279
2506
|
priv.popover_node = node_data;
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
(node_data.gclass + (node_data.name ? "^" + node_data.name : ""));
|
|
2283
|
-
$title.title = $title.textContent;
|
|
2507
|
+
open_popover_frame(gobj, "node", node_data.short_name ||
|
|
2508
|
+
(node_data.gclass + (node_data.name ? "^" + node_data.name : "")));
|
|
2284
2509
|
|
|
2285
2510
|
render_popover_body(gobj, node_data);
|
|
2286
2511
|
|
|
@@ -2332,6 +2557,51 @@ function hide_popover(gobj)
|
|
|
2332
2557
|
priv.$popover_title.textContent = "";
|
|
2333
2558
|
}
|
|
2334
2559
|
priv.popover_node = null;
|
|
2560
|
+
priv.popover_mode = "";
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
/************************************************************
|
|
2564
|
+
* The popover's frame for what it is about to show: its
|
|
2565
|
+
* title, and the gclass button only for a card -- the yuno's
|
|
2566
|
+
* traces are no gclass of their own.
|
|
2567
|
+
************************************************************/
|
|
2568
|
+
function open_popover_frame(gobj, mode, title)
|
|
2569
|
+
{
|
|
2570
|
+
let priv = gobj.priv;
|
|
2571
|
+
priv.popover_mode = mode;
|
|
2572
|
+
priv.$popover_title.textContent = title;
|
|
2573
|
+
priv.$popover_title.title = title;
|
|
2574
|
+
if(priv.$popover_gclass) {
|
|
2575
|
+
priv.$popover_gclass.classList.toggle("is-hidden", mode !== "node");
|
|
2576
|
+
}
|
|
2577
|
+
priv.$popover.style.display = "block";
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
/************************************************************
|
|
2581
|
+
* The yuno's traces, in the popover, under the toolbar
|
|
2582
|
+
* button that opened them.
|
|
2583
|
+
************************************************************/
|
|
2584
|
+
function show_yuno_traces(gobj)
|
|
2585
|
+
{
|
|
2586
|
+
let priv = gobj.priv;
|
|
2587
|
+
let $popover = priv.$popover;
|
|
2588
|
+
let $container = gobj_read_attr(gobj, "$container");
|
|
2589
|
+
if(!$popover || !$container) {
|
|
2590
|
+
return;
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
priv.popover_node = null;
|
|
2594
|
+
open_popover_frame(gobj, "yuno", t("traces of the yuno"));
|
|
2595
|
+
render_current_popover(gobj);
|
|
2596
|
+
|
|
2597
|
+
let rect = $container.getBoundingClientRect();
|
|
2598
|
+
let $btn = $container.querySelector(".GOBJ_TREE_YUNO_TRACES_BUTTON");
|
|
2599
|
+
let b = $btn? $btn.getBoundingClientRect(): null;
|
|
2600
|
+
let pop = $popover.getBoundingClientRect();
|
|
2601
|
+
let left = b? (b.right - rect.left - pop.width): (rect.width - pop.width - 8);
|
|
2602
|
+
let top = b? (b.bottom - rect.top + 6): 8;
|
|
2603
|
+
$popover.style.left = Math.max(4, left) + "px";
|
|
2604
|
+
$popover.style.top = Math.max(4, top) + "px";
|
|
2335
2605
|
}
|
|
2336
2606
|
|
|
2337
2607
|
/************************************************************
|
|
@@ -3261,7 +3531,7 @@ function ac_open_gclass(gobj, event, kw, src)
|
|
|
3261
3531
|
return 0;
|
|
3262
3532
|
}
|
|
3263
3533
|
|
|
3264
|
-
open_gclass_window(gobj, node_data.gclass, null, node_data
|
|
3534
|
+
open_gclass_window(gobj, node_data.gclass, null, node_data);
|
|
3265
3535
|
|
|
3266
3536
|
return 0;
|
|
3267
3537
|
}
|
|
@@ -3278,12 +3548,13 @@ function ac_gclass_description(gobj, event, kw, src)
|
|
|
3278
3548
|
}
|
|
3279
3549
|
let d = priv.popover_node;
|
|
3280
3550
|
open_gclass_window(gobj, kw.gclass, kw.description,
|
|
3281
|
-
(d && d.gclass === kw.gclass)?
|
|
3551
|
+
(d && d.gclass === kw.gclass)? d: null);
|
|
3282
3552
|
return 0;
|
|
3283
3553
|
}
|
|
3284
3554
|
|
|
3285
|
-
/* One window at a time: a second gclass replaces the first.
|
|
3286
|
-
|
|
3555
|
+
/* One window at a time: a second gclass replaces the first. `d` is
|
|
3556
|
+
* the card the reader came from, or null. */
|
|
3557
|
+
function open_gclass_window(gobj, gclass, description, d)
|
|
3287
3558
|
{
|
|
3288
3559
|
let priv = gobj.priv;
|
|
3289
3560
|
|
|
@@ -3297,7 +3568,10 @@ function open_gclass_window(gobj, gclass, description, state)
|
|
|
3297
3568
|
* CLASS and cannot carry it, and the tree is the only party
|
|
3298
3569
|
* that knows -- so the machine lights the column the reader
|
|
3299
3570
|
* is actually standing in. */
|
|
3300
|
-
current_state: state,
|
|
3571
|
+
current_state: (d && d.state) || "",
|
|
3572
|
+
/* ...and which instance that is: a gclass has several, and a
|
|
3573
|
+
* state with no name beside it belongs to none of them. */
|
|
3574
|
+
instance_name: (d && d.name) || "",
|
|
3301
3575
|
on_close: () => {
|
|
3302
3576
|
if(gobj_is_destroying(gobj)) {
|
|
3303
3577
|
return;
|
|
@@ -3308,6 +3582,12 @@ function open_gclass_window(gobj, gclass, description, state)
|
|
|
3308
3582
|
if(description) {
|
|
3309
3583
|
opts.description = description;
|
|
3310
3584
|
}
|
|
3585
|
+
/* A backend gclass' traces can be set for every gobj of it, from
|
|
3586
|
+
* the viewer: it is handed what the host read, and tells this
|
|
3587
|
+
* view what to set (EV_SET_GCLASS_TRACE). */
|
|
3588
|
+
if(is_remote(gobj)) {
|
|
3589
|
+
opts.traces = viewer_traces(gobj, gclass);
|
|
3590
|
+
}
|
|
3311
3591
|
priv.gclass_view = open_gclass_view(gobj, /* i18n: data */ gclass, opts);
|
|
3312
3592
|
}
|
|
3313
3593
|
|
|
@@ -3371,32 +3651,98 @@ function ac_trace_info(gobj, event, kw, src)
|
|
|
3371
3651
|
priv.trace_pending = false;
|
|
3372
3652
|
|
|
3373
3653
|
let d = priv.popover_node;
|
|
3374
|
-
|
|
3375
|
-
|
|
3654
|
+
let root = priv.remote_root;
|
|
3655
|
+
if((priv.popover_mode === "node" && d && d.gclass === kw.gclass) ||
|
|
3656
|
+
(priv.popover_mode === "yuno" && root && root.gclass === kw.gclass)) {
|
|
3657
|
+
render_current_popover(gobj);
|
|
3658
|
+
}
|
|
3659
|
+
|
|
3660
|
+
let viewer = gclass_viewer_gobj(gobj);
|
|
3661
|
+
if(viewer) {
|
|
3662
|
+
let shown = gobj_read_str_attr(viewer, "gclass_name");
|
|
3663
|
+
if(shown === kw.gclass) {
|
|
3664
|
+
gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
|
|
3665
|
+
} else if(priv.viewer_stale === shown) {
|
|
3666
|
+
/* A set of the YUNO's scope: what the viewer shows as held by
|
|
3667
|
+
* the yuno moved too, and the host refreshed only the root's
|
|
3668
|
+
* gclass. */
|
|
3669
|
+
gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", {gclass: shown});
|
|
3670
|
+
}
|
|
3376
3671
|
}
|
|
3672
|
+
priv.viewer_stale = "";
|
|
3377
3673
|
return 0;
|
|
3378
3674
|
}
|
|
3379
3675
|
|
|
3676
|
+
/************************************************************
|
|
3677
|
+
* The gclass viewer this view opened, while it is open.
|
|
3678
|
+
************************************************************/
|
|
3679
|
+
function gclass_viewer_gobj(gobj)
|
|
3680
|
+
{
|
|
3681
|
+
let h = gobj.priv.gclass_view;
|
|
3682
|
+
return (h && h.json_gobj && !gobj_is_destroying(h.json_gobj))? h.json_gobj: null;
|
|
3683
|
+
}
|
|
3684
|
+
|
|
3685
|
+
/************************************************************
|
|
3686
|
+
* What the gclass viewer needs to draw the traces of `gclass`
|
|
3687
|
+
* for every gobj of it: the levels the host read, and whether a
|
|
3688
|
+
* set is still in flight. Plain json: it rides in a kw.
|
|
3689
|
+
************************************************************/
|
|
3690
|
+
function viewer_traces(gobj, gclass)
|
|
3691
|
+
{
|
|
3692
|
+
let priv = gobj.priv;
|
|
3693
|
+
return {
|
|
3694
|
+
info: priv.trace_info[gclass] || null,
|
|
3695
|
+
pending: !!priv.trace_pending,
|
|
3696
|
+
};
|
|
3697
|
+
}
|
|
3698
|
+
|
|
3380
3699
|
/************************************************************
|
|
3381
3700
|
* A box of the TRACES block was ticked or cleared.
|
|
3382
3701
|
************************************************************/
|
|
3383
3702
|
function ac_trace_toggled(gobj, event, kw, src)
|
|
3384
3703
|
{
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
if(!is_remote(gobj) || !d) {
|
|
3388
|
-
log_error(`${gobj_short_name(gobj)}: a trace set with no backend card open`);
|
|
3704
|
+
if(!kw.level) {
|
|
3705
|
+
log_error(`${gobj_short_name(gobj)}: a trace set of no level, scope '${kw.scope}'`);
|
|
3389
3706
|
return -1;
|
|
3390
3707
|
}
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
return -1;
|
|
3708
|
+
let target = trace_target(gobj, kw.scope);
|
|
3709
|
+
if(!target) {
|
|
3710
|
+
return -1; // Error already logged
|
|
3395
3711
|
}
|
|
3396
|
-
set_trace_levels(gobj,
|
|
3712
|
+
set_trace_levels(gobj, target, kw.scope, [kw.level], !!kw.set);
|
|
3397
3713
|
return 0;
|
|
3398
3714
|
}
|
|
3399
3715
|
|
|
3716
|
+
/************************************************************
|
|
3717
|
+
* What a set of `scope` acts on: the card the popover is on
|
|
3718
|
+
* (gobj), or the yuno itself, the root (global). Null, and
|
|
3719
|
+
* logged, when the popover is not showing it.
|
|
3720
|
+
************************************************************/
|
|
3721
|
+
function trace_target(gobj, scope)
|
|
3722
|
+
{
|
|
3723
|
+
let priv = gobj.priv;
|
|
3724
|
+
if(!is_remote(gobj)) {
|
|
3725
|
+
log_error(`${gobj_short_name(gobj)}: a trace set on a tree that is not remote`);
|
|
3726
|
+
return null;
|
|
3727
|
+
}
|
|
3728
|
+
if(scope === "gobj") {
|
|
3729
|
+
if(priv.popover_mode !== "node" || !priv.popover_node) {
|
|
3730
|
+
log_error(`${gobj_short_name(gobj)}: a gobj trace set with no backend card open`);
|
|
3731
|
+
return null;
|
|
3732
|
+
}
|
|
3733
|
+
return priv.popover_node;
|
|
3734
|
+
}
|
|
3735
|
+
if(scope === "global") {
|
|
3736
|
+
if(priv.popover_mode !== "yuno" || !priv.remote_root) {
|
|
3737
|
+
log_error(`${gobj_short_name(gobj)}: a yuno trace set with the yuno's traces closed`);
|
|
3738
|
+
return null;
|
|
3739
|
+
}
|
|
3740
|
+
return priv.remote_root;
|
|
3741
|
+
}
|
|
3742
|
+
log_error(`${gobj_short_name(gobj)}: a trace set of no scope the popover has: '${scope}'`);
|
|
3743
|
+
return null;
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3400
3746
|
/************************************************************
|
|
3401
3747
|
* "Remove the traces" of the gobj or of its gclass: every
|
|
3402
3748
|
* level that scope holds on its own.
|
|
@@ -3404,39 +3750,88 @@ function ac_trace_toggled(gobj, event, kw, src)
|
|
|
3404
3750
|
function ac_traces_cleared(gobj, event, kw, src)
|
|
3405
3751
|
{
|
|
3406
3752
|
let priv = gobj.priv;
|
|
3407
|
-
let
|
|
3408
|
-
if(!
|
|
3409
|
-
|
|
3410
|
-
return -1;
|
|
3753
|
+
let target = trace_target(gobj, kw.scope);
|
|
3754
|
+
if(!target) {
|
|
3755
|
+
return -1; // Error already logged
|
|
3411
3756
|
}
|
|
3412
|
-
let
|
|
3757
|
+
let info = priv.trace_info[target.gclass];
|
|
3758
|
+
let rows = (kw.scope === "global")? global_trace_rows(info): trace_rows(target, info);
|
|
3413
3759
|
let levels = own_trace_levels(rows, kw.scope);
|
|
3414
3760
|
if(!levels.length) {
|
|
3415
3761
|
/* The button is off when there is nothing: reaching here is
|
|
3416
3762
|
* a button that did not follow the block. */
|
|
3417
|
-
log_error(`${gobj_short_name(gobj)}: no ${kw.scope} trace of ${
|
|
3763
|
+
log_error(`${gobj_short_name(gobj)}: no ${kw.scope} trace of ${target.full_name} to remove`);
|
|
3418
3764
|
return -1;
|
|
3419
3765
|
}
|
|
3420
|
-
set_trace_levels(gobj,
|
|
3766
|
+
set_trace_levels(gobj, target, kw.scope, levels, false);
|
|
3421
3767
|
return 0;
|
|
3422
3768
|
}
|
|
3423
3769
|
|
|
3424
|
-
|
|
3425
|
-
*
|
|
3426
|
-
|
|
3770
|
+
/************************************************************
|
|
3771
|
+
* The gclass viewer asked for a set of every gobj of its
|
|
3772
|
+
* gclass ({gclass, levels, set}).
|
|
3773
|
+
************************************************************/
|
|
3774
|
+
function ac_set_gclass_trace(gobj, event, kw, src)
|
|
3775
|
+
{
|
|
3776
|
+
let levels = (kw && Array.isArray(kw.levels))? kw.levels: [];
|
|
3777
|
+
if(!is_remote(gobj) || !kw.gclass || !levels.length) {
|
|
3778
|
+
log_error(`${gobj_short_name(gobj)}: a gclass trace set of no gclass or level, ` +
|
|
3779
|
+
`or on a tree that is not remote: '${kw && kw.gclass}'`);
|
|
3780
|
+
return -1;
|
|
3781
|
+
}
|
|
3782
|
+
set_trace_levels(gobj, {full_name: "", gclass: kw.gclass}, "gclass", levels, !!kw.set);
|
|
3783
|
+
return 0;
|
|
3784
|
+
}
|
|
3785
|
+
|
|
3786
|
+
/* Lock every block and hand the change to the host. The blocks are
|
|
3787
|
+
* repainted from what the backend says next, never from here.
|
|
3788
|
+
*
|
|
3789
|
+
* `target.gclass` is the gclass whose levels the host reads again
|
|
3790
|
+
* afterwards: the card's, the viewer's, or the root's for a set of
|
|
3791
|
+
* the yuno's scope -- which also moves what an open viewer of
|
|
3792
|
+
* ANOTHER gclass shows as held by the yuno, so that one is asked
|
|
3793
|
+
* for again when the answer is in (ac_trace_info). */
|
|
3794
|
+
function set_trace_levels(gobj, target, scope, levels, set)
|
|
3427
3795
|
{
|
|
3428
3796
|
let priv = gobj.priv;
|
|
3429
3797
|
priv.trace_pending = true;
|
|
3430
|
-
|
|
3798
|
+
render_current_popover(gobj);
|
|
3799
|
+
|
|
3800
|
+
let viewer = gclass_viewer_gobj(gobj);
|
|
3801
|
+
if(viewer) {
|
|
3802
|
+
let shown = gobj_read_str_attr(viewer, "gclass_name");
|
|
3803
|
+
if(scope === "global" && shown !== target.gclass) {
|
|
3804
|
+
priv.viewer_stale = shown;
|
|
3805
|
+
}
|
|
3806
|
+
gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
|
|
3807
|
+
}
|
|
3808
|
+
|
|
3431
3809
|
gobj_publish_event(gobj, "EV_SET_TRACE_LEVEL", {
|
|
3432
3810
|
scope: scope,
|
|
3433
|
-
gobj:
|
|
3434
|
-
gclass:
|
|
3811
|
+
gobj: target.full_name || "",
|
|
3812
|
+
gclass: target.gclass,
|
|
3435
3813
|
levels: levels,
|
|
3436
3814
|
set: set,
|
|
3437
3815
|
});
|
|
3438
3816
|
}
|
|
3439
3817
|
|
|
3818
|
+
/************************************************************
|
|
3819
|
+
* The toolbar's "traces of the yuno": the popover shows the
|
|
3820
|
+
* yuno's scope, read from the answer for the root's gclass.
|
|
3821
|
+
************************************************************/
|
|
3822
|
+
function ac_open_yuno_traces(gobj, event, kw, src)
|
|
3823
|
+
{
|
|
3824
|
+
let priv = gobj.priv;
|
|
3825
|
+
let root = priv.remote_root;
|
|
3826
|
+
if(!is_remote(gobj) || !root) {
|
|
3827
|
+
log_error(`${gobj_short_name(gobj)}: the yuno's traces asked with no backend tree loaded`);
|
|
3828
|
+
return -1;
|
|
3829
|
+
}
|
|
3830
|
+
show_yuno_traces(gobj);
|
|
3831
|
+
gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", {gclass: root.gclass});
|
|
3832
|
+
return 0;
|
|
3833
|
+
}
|
|
3834
|
+
|
|
3440
3835
|
/************************************************************
|
|
3441
3836
|
* The app switched language.
|
|
3442
3837
|
*
|
|
@@ -3517,6 +3912,8 @@ function create_gclass(gclass_name)
|
|
|
3517
3912
|
["EV_TRACE_TOGGLED", ac_trace_toggled, null],
|
|
3518
3913
|
["EV_TRACES_CLEARED", ac_traces_cleared, null],
|
|
3519
3914
|
["EV_GCLASS_DESCRIPTION", ac_gclass_description, null],
|
|
3915
|
+
["EV_OPEN_YUNO_TRACES", ac_open_yuno_traces, null],
|
|
3916
|
+
["EV_SET_GCLASS_TRACE", ac_set_gclass_trace, null],
|
|
3520
3917
|
]]
|
|
3521
3918
|
];
|
|
3522
3919
|
|
|
@@ -3549,6 +3946,9 @@ function create_gclass(gclass_name)
|
|
|
3549
3946
|
["EV_TRACE_TOGGLED", 0],
|
|
3550
3947
|
["EV_TRACES_CLEARED", 0],
|
|
3551
3948
|
["EV_GCLASS_DESCRIPTION", 0],
|
|
3949
|
+
["EV_OPEN_YUNO_TRACES", 0],
|
|
3950
|
+
/* From the gclass viewer this view opens (its child). */
|
|
3951
|
+
["EV_SET_GCLASS_TRACE", 0],
|
|
3552
3952
|
/* Published only when `source` is "remote" (see the header). */
|
|
3553
3953
|
["EV_TREE_WANTED", event_flag_t.EVF_OUTPUT_EVENT],
|
|
3554
3954
|
["EV_TRACE_INFO_WANTED", event_flag_t.EVF_OUTPUT_EVENT],
|