@yuneta/gobj-ui 7.27.26 → 7.27.28

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.
@@ -16,24 +16,41 @@
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", gobj,
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: the card the reader is on stays open.
27
+ * trace info of `gclass` again: what the reader is on stays
28
+ * open.
28
29
  *
29
- * In "remote" the popover of a card has a TRACES block: one
30
- * row per level (the gclass' own, then the global ones), a
31
- * checkbox for THIS gobj (`set-gobj-trace`) and one for every
32
- * gobj of its gclass (`set-gclass-trace`). A level that is on
33
- * for the gclass, or globally, is shown on and locked in the
34
- * gobj column, with where it comes from: it cannot be turned
35
- * off from one gobj. A gclass level is saved by the yuno and
36
- * survives a restart; a gobj level lasts until the yuno ends.
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; so does a gobj level of a named service (SDK
53
+ * 7.27.3+). Any other gobj's level lasts until the yuno ends.
37
54
  *
38
55
  * The output events are published ONLY in "remote", so a host
39
56
  * of a local tree (the Frontend view) declares none of them.
@@ -86,6 +103,7 @@ import {
86
103
  node_status_symbol,
87
104
  node_can_pause,
88
105
  trace_rows,
106
+ global_trace_rows,
89
107
  own_trace_levels,
90
108
  } from "./gobj_tree_model.js";
91
109
  import {text_node} from "./yui_text.js";
@@ -451,6 +469,8 @@ let PRIVATE_DATA = {
451
469
  remote_root: null, // the descriptor of the backend tree, as last loaded
452
470
  trace_info: {}, // gclass -> {gclass_levels, global_levels, gclass_on, global_on, error}
453
471
  trace_pending: false, // a trace was set: the block is locked until the host answers
472
+ popover_mode: "", // what the popover shows: "node" (a card) | "yuno" (the yuno's traces)
473
+ viewer_stale: "", // a gclass whose open viewer must be asked again after a yuno set
454
474
  view_refused: false, // the saved camera showed no card: the opening's framing replaces it
455
475
  };
456
476
 
@@ -1243,6 +1263,28 @@ function make_toolbar(gobj)
1243
1263
  }]
1244
1264
  );
1245
1265
  priv.$layout_select = $wrap.querySelector("select");
1266
+
1267
+ /* The yuno's own scope of traces (`set-global-trace`) is the
1268
+ * yuno's, not any one gobj's: it opens from here, not from a card.
1269
+ * Its label goes on mobile -- the row is full there. */
1270
+ if(is_remote(gobj)) {
1271
+ right_items.push(createElement2(['button', {
1272
+ type: 'button',
1273
+ class: 'GOBJ_TREE_YUNO_TRACES_BUTTON button',
1274
+ style: {height: toolbar_wide, "margin-left": "0.5em"},
1275
+ title: t("traces of the yuno"), 'data-i18n-title': "traces of the yuno",
1276
+ 'aria-label': t("traces of the yuno"), 'data-i18n-aria-label': "traces of the yuno",
1277
+ }, [
1278
+ ['span', {class: 'icon'}, [['i', {class: 'yi-list-check'}]]],
1279
+ ['span', {class: 'is-hidden-mobile', i18n: "traces of the yuno"},
1280
+ t("traces of the yuno")]
1281
+ ], {
1282
+ click: (evt) => {
1283
+ evt.stopPropagation();
1284
+ gobj_send_event(gobj, "EV_OPEN_YUNO_TRACES", {}, gobj);
1285
+ }
1286
+ }]));
1287
+ }
1246
1288
  right_items.push($wrap);
1247
1289
 
1248
1290
  const $toolbar = yui_toolbar({}, [
@@ -2146,40 +2188,116 @@ function is_remote(gobj)
2146
2188
  }
2147
2189
 
2148
2190
  /************************************************************
2149
- * The TRACES block of a backend gobj's popover.
2191
+ * Paint again whatever the popover is showing: a card, or
2192
+ * the yuno's traces.
2193
+ ************************************************************/
2194
+ function render_current_popover(gobj)
2195
+ {
2196
+ let priv = gobj.priv;
2197
+ if(!priv.$popover || priv.$popover.style.display !== "block") {
2198
+ return;
2199
+ }
2200
+ if(priv.popover_mode === "yuno") {
2201
+ priv.$popover_body.textContent = "";
2202
+ priv.$popover_body.appendChild(build_yuno_traces_block(gobj));
2203
+ } else if(priv.popover_node) {
2204
+ render_popover_body(gobj, priv.popover_node);
2205
+ }
2206
+ }
2207
+
2208
+ /************************************************************
2209
+ * The TRACES block of a backend gobj's popover: what THIS
2210
+ * gobj traces (`set-gobj-trace`), one row per level -- the
2211
+ * gclass' own, then the kernel's (trace_rows() in the model).
2212
+ *
2213
+ * ONE scope here, the gobj's. The other two live where they
2214
+ * belong: every gobj of the gclass in the gclass viewer (its
2215
+ * `trace levels` zone), the whole yuno behind the toolbar's
2216
+ * `traces of the yuno`. A level one of them holds is shown on
2217
+ * and LOCKED here, saying which one, because unticking the
2218
+ * gobj's own bit would not stop it.
2150
2219
  *
2151
- * Two columns of checkboxes, THIS gobj and every gobj of its
2152
- * gclass, one row per level (trace_rows() in the model says
2153
- * what each row holds). A box is an action: its change is
2154
- * sent to the FSM, which publishes it to the host, and the
2155
- * block stays locked until the host has loaded what the
2156
- * backend says now -- the box shows the backend's state, not
2157
- * the click.
2220
+ * A box is an action: its change goes to the FSM, which
2221
+ * publishes it to the host, and the block stays locked until
2222
+ * the host has loaded what the backend says now -- the box
2223
+ * shows the backend's state, not the click.
2158
2224
  ************************************************************/
2159
2225
  const TRACES_NOTE_STYLE = 'color:var(--bulma-text-weak, #6B7280); margin:4px 0;';
2160
2226
  const TRACES_CELL_STYLE = 'padding:1px 4px; text-align:center;';
2227
+ const TRACES_ORIGIN_STYLE = 'margin-left:6px; color:var(--bulma-text-weak, #6B7280);';
2228
+ const TRACES_BUTTON_STYLE = 'padding:0 8px; height:22px; font-size:11px; white-space:nowrap;';
2229
+
2230
+ /* What the block says while the levels are not in, or could not be
2231
+ * read. Null when they are. */
2232
+ function traces_state_note(info)
2233
+ {
2234
+ if(!info) {
2235
+ return ['div', {class: 'GOBJ_TREE_TRACES_NOTE', i18n: 'loading',
2236
+ style: TRACES_NOTE_STYLE}, t('loading')];
2237
+ }
2238
+ if(info.error) {
2239
+ return ['div', {class: 'GOBJ_TREE_TRACES_ERROR',
2240
+ style: 'color:var(--bulma-danger, #dc2626); margin:4px 0;'},
2241
+ text_node(info.error)];
2242
+ }
2243
+ return null;
2244
+ }
2245
+
2246
+ /* The level cell: its name, the backend's own text for it as the
2247
+ * tooltip (data, not a key), and where an inherited level comes
2248
+ * from. */
2249
+ function trace_level_cell(level, description, $origin)
2250
+ {
2251
+ let $level = createElement2(['td', {class: 'GOBJ_TREE_TRACES_LEVEL',
2252
+ style: 'padding:1px 4px; word-break:break-all;'}, []]);
2253
+ $level.appendChild(text_node(level));
2254
+ if($origin) {
2255
+ $level.appendChild($origin);
2256
+ }
2257
+ $level.setAttribute('title', description);
2258
+ return $level;
2259
+ }
2260
+
2261
+ function trace_group_row(span, $label)
2262
+ {
2263
+ return ['tr', {class: 'GOBJ_TREE_TRACES_GROUP'}, [
2264
+ ['td', {colspan: span, style: 'padding:4px 4px 1px 4px; font-weight:600; ' +
2265
+ 'color:var(--bulma-text-weak, #6B7280);'}, [$label]]
2266
+ ]];
2267
+ }
2268
+
2269
+ /* `names` are the button's i18n, title and aria-label, written by the
2270
+ * caller with its literal key; `$label` its text. */
2271
+ function traces_remove_button(gobj, scope, names, $label, disabled)
2272
+ {
2273
+ let $b = createElement2(['button', Object.assign({
2274
+ type: 'button',
2275
+ class: `GOBJ_TREE_TRACES_CLEAR_${scope.toUpperCase()} button is-small`,
2276
+ style: TRACES_BUTTON_STYLE,
2277
+ }, names), [$label], {
2278
+ click: (evt) => {
2279
+ evt.stopPropagation();
2280
+ gobj_send_event(gobj, "EV_TRACES_CLEARED", {scope: scope}, gobj);
2281
+ }
2282
+ }]);
2283
+ $b.disabled = !!disabled;
2284
+ return createElement2(['div', {class: 'GOBJ_TREE_TRACES_TOOLS',
2285
+ style: 'display:flex; flex-wrap:wrap; gap:4px; margin-top:4px;'},
2286
+ [$b]]);
2287
+ }
2161
2288
 
2162
2289
  function build_traces_block(gobj, d)
2163
2290
  {
2164
2291
  let priv = gobj.priv;
2165
2292
  let info = priv.trace_info[d.gclass] || null;
2166
2293
 
2167
- let kids = [
2168
- ['div', {class: 'GOBJ_TREE_TRACES_HEAD', i18n: 'traces',
2169
- style: 'font-weight:700; margin:8px 0 2px 0; ' +
2170
- 'padding-top:6px; border-top:1px solid var(--bulma-border-weak, #E5E7EB);'},
2171
- t('traces')]
2172
- ];
2173
-
2174
- if(!info) {
2175
- kids.push(['div', {class: 'GOBJ_TREE_TRACES_NOTE', i18n: 'loading',
2176
- style: TRACES_NOTE_STYLE}, t('loading')]);
2177
- return createElement2(['div', {class: 'GOBJ_TREE_TRACES'}, kids]);
2178
- }
2179
- if(info.error) {
2180
- kids.push(['div', {class: 'GOBJ_TREE_TRACES_ERROR',
2181
- style: 'color:var(--bulma-danger, #dc2626); margin:4px 0;'},
2182
- text_node(info.error)]);
2294
+ let kids = [['div', {class: 'GOBJ_TREE_TRACES_HEAD', i18n: 'traces of this gobj',
2295
+ style: 'font-weight:700; margin:8px 0 2px 0; padding-top:6px; ' +
2296
+ 'border-top:1px solid var(--bulma-border-weak, #E5E7EB);'},
2297
+ t('traces of this gobj')]];
2298
+ let state = traces_state_note(info);
2299
+ if(state) {
2300
+ kids.push(state);
2183
2301
  return createElement2(['div', {class: 'GOBJ_TREE_TRACES'}, kids]);
2184
2302
  }
2185
2303
 
@@ -2191,41 +2309,27 @@ function build_traces_block(gobj, d)
2191
2309
  for(let r of rows) {
2192
2310
  if(r.group !== group) {
2193
2311
  group = r.group;
2194
- let $label = (group === "gclass")?
2312
+ trs.push(trace_group_row(2, (group === "gclass")?
2195
2313
  text_node(d.gclass):
2196
- createElement2(['span', {i18n: 'global'}, t('global')]);
2197
- trs.push(['tr', {class: 'GOBJ_TREE_TRACES_GROUP'}, [
2198
- ['td', {colspan: 3, style: 'padding:4px 4px 1px 4px; font-weight:600; ' +
2199
- 'color:var(--bulma-text-weak, #6B7280);'}, [$label]]
2200
- ]]);
2314
+ createElement2(['span', {i18n: 'kernel levels'}, t('kernel levels')])));
2201
2315
  }
2202
- let origin = null;
2316
+ let $origin = null;
2203
2317
  if(r.origin === "global") {
2204
- origin = ['span', {class: 'GOBJ_TREE_TRACES_ORIGIN', i18n: 'global',
2205
- style: 'margin-left:6px; color:var(--bulma-text-weak, #6B7280);'},
2206
- t('global')];
2318
+ $origin = createElement2(['span', {
2319
+ class: 'GOBJ_TREE_TRACES_ORIGIN', i18n: 'yuno', style: TRACES_ORIGIN_STYLE,
2320
+ title: t('on for the whole yuno'), 'data-i18n-title': 'on for the whole yuno',
2321
+ }, t('yuno')]);
2207
2322
  } else if(r.origin === "gclass") {
2208
- origin = ['span', {class: 'GOBJ_TREE_TRACES_ORIGIN', i18n: 'gclass',
2209
- style: 'margin-left:6px; color:var(--bulma-text-weak, #6B7280);'},
2210
- t('gclass')];
2211
- }
2212
- let $level = createElement2(['td', {class: 'GOBJ_TREE_TRACES_LEVEL',
2213
- style: 'padding:1px 4px; word-break:break-all;'}, []]);
2214
- $level.appendChild(text_node(r.level));
2215
- if(origin) {
2216
- $level.appendChild(createElement2(origin));
2323
+ $origin = createElement2(['span', {
2324
+ class: 'GOBJ_TREE_TRACES_ORIGIN', style: TRACES_ORIGIN_STYLE,
2325
+ title: t('on for all of the gclass'), 'data-i18n-title': 'on for all of the gclass',
2326
+ }, [text_node(d.gclass)]]);
2217
2327
  }
2218
- /* What the level does is the backend's text: data, not a key. */
2219
- $level.setAttribute('title', r.description);
2220
-
2221
2328
  trs.push(['tr', {class: 'GOBJ_TREE_TRACES_ROW'}, [
2222
- $level,
2329
+ trace_level_cell(r.level, r.description, $origin),
2223
2330
  ['td', {style: TRACES_CELL_STYLE}, [
2224
2331
  trace_checkbox(gobj, "gobj", r.level, r.gobj_on, pending || r.gobj_locked)
2225
2332
  ]],
2226
- ['td', {style: TRACES_CELL_STYLE}, [
2227
- trace_checkbox(gobj, "gclass", r.level, r.gclass_on, pending || r.gclass_locked)
2228
- ]],
2229
2333
  ]]);
2230
2334
  }
2231
2335
 
@@ -2235,72 +2339,110 @@ function build_traces_block(gobj, d)
2235
2339
  ['tr', {}, [
2236
2340
  ['th', {i18n: 'level', style: 'padding:1px 4px; text-align:left;'}, t('level')],
2237
2341
  ['th', {i18n: 'this gobj', style: TRACES_CELL_STYLE}, t('this gobj')],
2238
- ['th', {i18n: 'all of the gclass', style: TRACES_CELL_STYLE}, t('all of the gclass')],
2239
2342
  ]]
2240
2343
  ]],
2241
2344
  ['tbody', {}, trs]
2242
2345
  ]]);
2243
2346
 
2244
- kids.push(['div', {class: 'GOBJ_TREE_TRACES_NOTE',
2245
- i18n: 'gclass traces survive a restart, gobj traces end with the yuno',
2246
- style: TRACES_NOTE_STYLE},
2247
- t('gclass traces survive a restart, gobj traces end with the yuno')]);
2248
-
2249
- let none_gobj = pending || own_trace_levels(rows, "gobj").length === 0;
2250
- let none_gclass = pending || own_trace_levels(rows, "gclass").length === 0;
2251
- let btn_style = 'padding:0 8px; height:22px; font-size:11px; white-space:nowrap;';
2252
- let clear = (scope) => {
2253
- return {
2254
- click: (evt) => {
2255
- evt.stopPropagation();
2256
- gobj_send_event(gobj, "EV_TRACES_CLEARED", {scope: scope}, gobj);
2257
- }
2258
- };
2259
- };
2260
- let $clear_gobj = createElement2(['button', {
2261
- type: 'button', class: 'GOBJ_TREE_TRACES_CLEAR_GOBJ button is-small', style: btn_style,
2262
- i18n: 'remove the traces of this gobj',
2347
+ /* What the yuno keeps of them (SDK 7.27.3+): the traces of a named
2348
+ * service are saved and re-applied at start up, any other gobj's are
2349
+ * not -- they could never be found again. */
2350
+ kids.push(d.service?
2351
+ ['div', {class: 'GOBJ_TREE_TRACES_NOTE',
2352
+ i18n: 'the traces of a service survive a restart', style: TRACES_NOTE_STYLE},
2353
+ t('the traces of a service survive a restart')]:
2354
+ ['div', {class: 'GOBJ_TREE_TRACES_NOTE',
2355
+ i18n: 'the traces of a gobj that is not a service end with the yuno',
2356
+ style: TRACES_NOTE_STYLE},
2357
+ t('the traces of a gobj that is not a service end with the yuno')]);
2358
+
2359
+ kids.push(traces_remove_button(gobj, "gobj", {
2263
2360
  title: t('remove the traces of this gobj'),
2264
2361
  'data-i18n-title': 'remove the traces of this gobj',
2265
2362
  'aria-label': t('remove the traces of this gobj'),
2266
2363
  'data-i18n-aria-label': 'remove the traces of this gobj',
2267
- }, t('remove the traces of this gobj'), clear("gobj")]);
2268
- let $clear_gclass = createElement2(['button', {
2269
- type: 'button', class: 'GOBJ_TREE_TRACES_CLEAR_GCLASS button is-small', style: btn_style,
2270
- i18n: 'remove the traces of the gclass',
2271
- title: t('remove the traces of the gclass'),
2272
- 'data-i18n-title': 'remove the traces of the gclass',
2273
- 'aria-label': t('remove the traces of the gclass'),
2274
- 'data-i18n-aria-label': 'remove the traces of the gclass',
2275
- }, t('remove the traces of the gclass'), clear("gclass")]);
2276
- $clear_gobj.disabled = none_gobj;
2277
- $clear_gclass.disabled = none_gclass;
2278
- kids.push(['div', {class: 'GOBJ_TREE_TRACES_TOOLS',
2279
- style: 'display:flex; flex-wrap:wrap; gap:4px; margin-top:4px;'},
2280
- [$clear_gobj, $clear_gclass]]);
2364
+ }, createElement2(['span', {i18n: 'remove the traces of this gobj'},
2365
+ t('remove the traces of this gobj')]),
2366
+ pending || own_trace_levels(rows, "gobj").length === 0));
2281
2367
 
2282
2368
  return createElement2(['div', {class: 'GOBJ_TREE_TRACES'}, kids]);
2283
2369
  }
2284
2370
 
2285
- /* One box of the block. `checked` and `disabled` are set as
2371
+ /************************************************************
2372
+ * The yuno's traces (`set-global-trace`): the kernel's levels,
2373
+ * and whether every gobj of the yuno traces each one. Drawn in
2374
+ * the popover, opened from the toolbar, and read from the
2375
+ * answer for the ROOT's gclass -- the yuno itself, whose
2376
+ * answer carries the yuno's levels like every other one.
2377
+ ************************************************************/
2378
+ function build_yuno_traces_block(gobj)
2379
+ {
2380
+ let priv = gobj.priv;
2381
+ let root = priv.remote_root;
2382
+ let info = (root && priv.trace_info[root.gclass]) || null;
2383
+
2384
+ let kids = [];
2385
+ let state = traces_state_note(info);
2386
+ if(state) {
2387
+ kids.push(state);
2388
+ return createElement2(['div', {class: 'GOBJ_TREE_YUNO_TRACES'}, kids]);
2389
+ }
2390
+
2391
+ let rows = global_trace_rows(info);
2392
+ let pending = !!priv.trace_pending;
2393
+
2394
+ let trs = rows.map((r) => ['tr', {class: 'GOBJ_TREE_TRACES_ROW'}, [
2395
+ trace_level_cell(r.level, r.description, null),
2396
+ ['td', {style: TRACES_CELL_STYLE}, [
2397
+ trace_checkbox(gobj, "global", r.level, r.global_on, pending)
2398
+ ]],
2399
+ ]]);
2400
+
2401
+ kids.push(['table', {class: 'GOBJ_TREE_TRACES_TABLE',
2402
+ style: 'width:100%; border-collapse:collapse;'}, [
2403
+ ['thead', {}, [
2404
+ ['tr', {}, [
2405
+ ['th', {i18n: 'kernel levels', style: 'padding:1px 4px; text-align:left;'},
2406
+ t('kernel levels')],
2407
+ ['th', {i18n: 'the whole yuno', style: TRACES_CELL_STYLE}, t('the whole yuno')],
2408
+ ]]
2409
+ ]],
2410
+ ['tbody', {}, trs]
2411
+ ]]);
2412
+
2413
+ kids.push(['div', {class: 'GOBJ_TREE_TRACES_NOTE',
2414
+ i18n: "the yuno's traces survive a restart",
2415
+ style: TRACES_NOTE_STYLE},
2416
+ t("the yuno's traces survive a restart")]);
2417
+
2418
+ kids.push(traces_remove_button(gobj, "global", {
2419
+ title: t('remove the traces of the yuno'),
2420
+ 'data-i18n-title': 'remove the traces of the yuno',
2421
+ 'aria-label': t('remove the traces of the yuno'),
2422
+ 'data-i18n-aria-label': 'remove the traces of the yuno',
2423
+ }, createElement2(['span', {i18n: 'remove the traces of the yuno'},
2424
+ t('remove the traces of the yuno')]),
2425
+ pending || own_trace_levels(rows, "global").length === 0));
2426
+
2427
+ return createElement2(['div', {class: 'GOBJ_TREE_YUNO_TRACES'}, kids]);
2428
+ }
2429
+
2430
+ /* One box of a block. `checked` and `disabled` are set as
2286
2431
  * PROPERTIES: createElement2 writes attributes, and an attribute
2287
2432
  * `checked="false"` is a checked box. */
2433
+ const TRACE_BOX = {
2434
+ gobj: {cls: 'GOBJ_TREE_TRACE_GOBJ', key: 'this gobj'},
2435
+ global: {cls: 'GOBJ_TREE_TRACE_GLOBAL', key: 'the whole yuno'},
2436
+ };
2437
+
2288
2438
  function trace_checkbox(gobj, scope, level, on, locked)
2289
2439
  {
2290
- let $cb = null;
2291
- if(scope === "gobj") {
2292
- $cb = createElement2(['input', {
2293
- type: 'checkbox', class: 'GOBJ_TREE_TRACE_GOBJ',
2294
- title: t('this gobj'), 'data-i18n-title': 'this gobj',
2295
- 'aria-label': t('this gobj'), 'data-i18n-aria-label': 'this gobj',
2296
- }]);
2297
- } else {
2298
- $cb = createElement2(['input', {
2299
- type: 'checkbox', class: 'GOBJ_TREE_TRACE_GCLASS',
2300
- title: t('all of the gclass'), 'data-i18n-title': 'all of the gclass',
2301
- 'aria-label': t('all of the gclass'), 'data-i18n-aria-label': 'all of the gclass',
2302
- }]);
2303
- }
2440
+ const box = TRACE_BOX[scope];
2441
+ let $cb = createElement2(['input', {
2442
+ type: 'checkbox', class: box.cls,
2443
+ title: t(box.key), 'data-i18n-title': box.key,
2444
+ 'aria-label': t(box.key), 'data-i18n-aria-label': box.key,
2445
+ }]);
2304
2446
  $cb.setAttribute('data-level', level);
2305
2447
  $cb.checked = !!on;
2306
2448
  $cb.disabled = !!locked;
@@ -2321,13 +2463,22 @@ function reload_keeping_popover(gobj, opts)
2321
2463
  {
2322
2464
  let priv = gobj.priv;
2323
2465
  let $popover = priv.$popover;
2324
- let keep = (priv.popover_node && $popover && $popover.style.display === "block")?
2466
+ let shown = !!($popover && $popover.style.display === "block");
2467
+ let keep = (shown && priv.popover_mode === "node" && priv.popover_node)?
2325
2468
  priv.popover_node.full_name: null;
2469
+ let keep_yuno = shown && priv.popover_mode === "yuno";
2326
2470
  let left = $popover? $popover.style.left: "";
2327
2471
  let top = $popover? $popover.style.top: "";
2328
2472
 
2329
2473
  refresh_tree(gobj, opts); /* hides the popover */
2330
2474
 
2475
+ if(keep_yuno) {
2476
+ open_popover_frame(gobj, "yuno", t("traces of the yuno"));
2477
+ $popover.style.left = left;
2478
+ $popover.style.top = top;
2479
+ render_current_popover(gobj);
2480
+ return;
2481
+ }
2331
2482
  if(!keep || !priv.node_by_id) {
2332
2483
  return;
2333
2484
  }
@@ -2335,13 +2486,11 @@ function reload_keeping_popover(gobj, opts)
2335
2486
  let d = priv.node_by_id[id];
2336
2487
  if(d.full_name === keep) {
2337
2488
  priv.popover_node = d;
2338
- priv.$popover_title.textContent = d.short_name ||
2339
- (d.gclass + (d.name ? "^" + d.name : ""));
2340
- priv.$popover_title.title = priv.$popover_title.textContent;
2489
+ open_popover_frame(gobj, "node", d.short_name ||
2490
+ (d.gclass + (d.name ? "^" + d.name : "")));
2341
2491
  render_popover_body(gobj, d);
2342
2492
  $popover.style.left = left;
2343
2493
  $popover.style.top = top;
2344
- $popover.style.display = "block";
2345
2494
  return;
2346
2495
  }
2347
2496
  }
@@ -2363,10 +2512,8 @@ function show_popover(gobj, node_data, client_x, client_y)
2363
2512
  }
2364
2513
 
2365
2514
  priv.popover_node = node_data;
2366
-
2367
- $title.textContent = node_data.short_name ||
2368
- (node_data.gclass + (node_data.name ? "^" + node_data.name : ""));
2369
- $title.title = $title.textContent;
2515
+ open_popover_frame(gobj, "node", node_data.short_name ||
2516
+ (node_data.gclass + (node_data.name ? "^" + node_data.name : "")));
2370
2517
 
2371
2518
  render_popover_body(gobj, node_data);
2372
2519
 
@@ -2418,6 +2565,51 @@ function hide_popover(gobj)
2418
2565
  priv.$popover_title.textContent = "";
2419
2566
  }
2420
2567
  priv.popover_node = null;
2568
+ priv.popover_mode = "";
2569
+ }
2570
+
2571
+ /************************************************************
2572
+ * The popover's frame for what it is about to show: its
2573
+ * title, and the gclass button only for a card -- the yuno's
2574
+ * traces are no gclass of their own.
2575
+ ************************************************************/
2576
+ function open_popover_frame(gobj, mode, title)
2577
+ {
2578
+ let priv = gobj.priv;
2579
+ priv.popover_mode = mode;
2580
+ priv.$popover_title.textContent = title;
2581
+ priv.$popover_title.title = title;
2582
+ if(priv.$popover_gclass) {
2583
+ priv.$popover_gclass.classList.toggle("is-hidden", mode !== "node");
2584
+ }
2585
+ priv.$popover.style.display = "block";
2586
+ }
2587
+
2588
+ /************************************************************
2589
+ * The yuno's traces, in the popover, under the toolbar
2590
+ * button that opened them.
2591
+ ************************************************************/
2592
+ function show_yuno_traces(gobj)
2593
+ {
2594
+ let priv = gobj.priv;
2595
+ let $popover = priv.$popover;
2596
+ let $container = gobj_read_attr(gobj, "$container");
2597
+ if(!$popover || !$container) {
2598
+ return;
2599
+ }
2600
+
2601
+ priv.popover_node = null;
2602
+ open_popover_frame(gobj, "yuno", t("traces of the yuno"));
2603
+ render_current_popover(gobj);
2604
+
2605
+ let rect = $container.getBoundingClientRect();
2606
+ let $btn = $container.querySelector(".GOBJ_TREE_YUNO_TRACES_BUTTON");
2607
+ let b = $btn? $btn.getBoundingClientRect(): null;
2608
+ let pop = $popover.getBoundingClientRect();
2609
+ let left = b? (b.right - rect.left - pop.width): (rect.width - pop.width - 8);
2610
+ let top = b? (b.bottom - rect.top + 6): 8;
2611
+ $popover.style.left = Math.max(4, left) + "px";
2612
+ $popover.style.top = Math.max(4, top) + "px";
2421
2613
  }
2422
2614
 
2423
2615
  /************************************************************
@@ -3347,7 +3539,7 @@ function ac_open_gclass(gobj, event, kw, src)
3347
3539
  return 0;
3348
3540
  }
3349
3541
 
3350
- open_gclass_window(gobj, node_data.gclass, null, node_data.state || "");
3542
+ open_gclass_window(gobj, node_data.gclass, null, node_data);
3351
3543
 
3352
3544
  return 0;
3353
3545
  }
@@ -3364,12 +3556,13 @@ function ac_gclass_description(gobj, event, kw, src)
3364
3556
  }
3365
3557
  let d = priv.popover_node;
3366
3558
  open_gclass_window(gobj, kw.gclass, kw.description,
3367
- (d && d.gclass === kw.gclass)? (d.state || ""): "");
3559
+ (d && d.gclass === kw.gclass)? d: null);
3368
3560
  return 0;
3369
3561
  }
3370
3562
 
3371
- /* One window at a time: a second gclass replaces the first. */
3372
- function open_gclass_window(gobj, gclass, description, state)
3563
+ /* One window at a time: a second gclass replaces the first. `d` is
3564
+ * the card the reader came from, or null. */
3565
+ function open_gclass_window(gobj, gclass, description, d)
3373
3566
  {
3374
3567
  let priv = gobj.priv;
3375
3568
 
@@ -3383,7 +3576,10 @@ function open_gclass_window(gobj, gclass, description, state)
3383
3576
  * CLASS and cannot carry it, and the tree is the only party
3384
3577
  * that knows -- so the machine lights the column the reader
3385
3578
  * is actually standing in. */
3386
- current_state: state,
3579
+ current_state: (d && d.state) || "",
3580
+ /* ...and which instance that is: a gclass has several, and a
3581
+ * state with no name beside it belongs to none of them. */
3582
+ instance_name: (d && d.name) || "",
3387
3583
  on_close: () => {
3388
3584
  if(gobj_is_destroying(gobj)) {
3389
3585
  return;
@@ -3394,6 +3590,12 @@ function open_gclass_window(gobj, gclass, description, state)
3394
3590
  if(description) {
3395
3591
  opts.description = description;
3396
3592
  }
3593
+ /* A backend gclass' traces can be set for every gobj of it, from
3594
+ * the viewer: it is handed what the host read, and tells this
3595
+ * view what to set (EV_SET_GCLASS_TRACE). */
3596
+ if(is_remote(gobj)) {
3597
+ opts.traces = viewer_traces(gobj, gclass);
3598
+ }
3397
3599
  priv.gclass_view = open_gclass_view(gobj, /* i18n: data */ gclass, opts);
3398
3600
  }
3399
3601
 
@@ -3457,32 +3659,98 @@ function ac_trace_info(gobj, event, kw, src)
3457
3659
  priv.trace_pending = false;
3458
3660
 
3459
3661
  let d = priv.popover_node;
3460
- if(d && d.gclass === kw.gclass && priv.$popover && priv.$popover.style.display === "block") {
3461
- render_popover_body(gobj, d);
3662
+ let root = priv.remote_root;
3663
+ if((priv.popover_mode === "node" && d && d.gclass === kw.gclass) ||
3664
+ (priv.popover_mode === "yuno" && root && root.gclass === kw.gclass)) {
3665
+ render_current_popover(gobj);
3666
+ }
3667
+
3668
+ let viewer = gclass_viewer_gobj(gobj);
3669
+ if(viewer) {
3670
+ let shown = gobj_read_str_attr(viewer, "gclass_name");
3671
+ if(shown === kw.gclass) {
3672
+ gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
3673
+ } else if(priv.viewer_stale === shown) {
3674
+ /* A set of the YUNO's scope: what the viewer shows as held by
3675
+ * the yuno moved too, and the host refreshed only the root's
3676
+ * gclass. */
3677
+ gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", {gclass: shown});
3678
+ }
3462
3679
  }
3680
+ priv.viewer_stale = "";
3463
3681
  return 0;
3464
3682
  }
3465
3683
 
3684
+ /************************************************************
3685
+ * The gclass viewer this view opened, while it is open.
3686
+ ************************************************************/
3687
+ function gclass_viewer_gobj(gobj)
3688
+ {
3689
+ let h = gobj.priv.gclass_view;
3690
+ return (h && h.json_gobj && !gobj_is_destroying(h.json_gobj))? h.json_gobj: null;
3691
+ }
3692
+
3693
+ /************************************************************
3694
+ * What the gclass viewer needs to draw the traces of `gclass`
3695
+ * for every gobj of it: the levels the host read, and whether a
3696
+ * set is still in flight. Plain json: it rides in a kw.
3697
+ ************************************************************/
3698
+ function viewer_traces(gobj, gclass)
3699
+ {
3700
+ let priv = gobj.priv;
3701
+ return {
3702
+ info: priv.trace_info[gclass] || null,
3703
+ pending: !!priv.trace_pending,
3704
+ };
3705
+ }
3706
+
3466
3707
  /************************************************************
3467
3708
  * A box of the TRACES block was ticked or cleared.
3468
3709
  ************************************************************/
3469
3710
  function ac_trace_toggled(gobj, event, kw, src)
3470
3711
  {
3471
- let priv = gobj.priv;
3472
- let d = priv.popover_node;
3473
- if(!is_remote(gobj) || !d) {
3474
- log_error(`${gobj_short_name(gobj)}: a trace set with no backend card open`);
3712
+ if(!kw.level) {
3713
+ log_error(`${gobj_short_name(gobj)}: a trace set of no level, scope '${kw.scope}'`);
3475
3714
  return -1;
3476
3715
  }
3477
- if(!kw.level || (kw.scope !== "gobj" && kw.scope !== "gclass")) {
3478
- log_error(`${gobj_short_name(gobj)}: a trace set of no level or scope: ` +
3479
- `'${kw.scope}' '${kw.level}'`);
3480
- return -1;
3716
+ let target = trace_target(gobj, kw.scope);
3717
+ if(!target) {
3718
+ return -1; // Error already logged
3481
3719
  }
3482
- set_trace_levels(gobj, d, kw.scope, [kw.level], !!kw.set);
3720
+ set_trace_levels(gobj, target, kw.scope, [kw.level], !!kw.set);
3483
3721
  return 0;
3484
3722
  }
3485
3723
 
3724
+ /************************************************************
3725
+ * What a set of `scope` acts on: the card the popover is on
3726
+ * (gobj), or the yuno itself, the root (global). Null, and
3727
+ * logged, when the popover is not showing it.
3728
+ ************************************************************/
3729
+ function trace_target(gobj, scope)
3730
+ {
3731
+ let priv = gobj.priv;
3732
+ if(!is_remote(gobj)) {
3733
+ log_error(`${gobj_short_name(gobj)}: a trace set on a tree that is not remote`);
3734
+ return null;
3735
+ }
3736
+ if(scope === "gobj") {
3737
+ if(priv.popover_mode !== "node" || !priv.popover_node) {
3738
+ log_error(`${gobj_short_name(gobj)}: a gobj trace set with no backend card open`);
3739
+ return null;
3740
+ }
3741
+ return priv.popover_node;
3742
+ }
3743
+ if(scope === "global") {
3744
+ if(priv.popover_mode !== "yuno" || !priv.remote_root) {
3745
+ log_error(`${gobj_short_name(gobj)}: a yuno trace set with the yuno's traces closed`);
3746
+ return null;
3747
+ }
3748
+ return priv.remote_root;
3749
+ }
3750
+ log_error(`${gobj_short_name(gobj)}: a trace set of no scope the popover has: '${scope}'`);
3751
+ return null;
3752
+ }
3753
+
3486
3754
  /************************************************************
3487
3755
  * "Remove the traces" of the gobj or of its gclass: every
3488
3756
  * level that scope holds on its own.
@@ -3490,39 +3758,88 @@ function ac_trace_toggled(gobj, event, kw, src)
3490
3758
  function ac_traces_cleared(gobj, event, kw, src)
3491
3759
  {
3492
3760
  let priv = gobj.priv;
3493
- let d = priv.popover_node;
3494
- if(!is_remote(gobj) || !d) {
3495
- log_error(`${gobj_short_name(gobj)}: traces removed with no backend card open`);
3496
- return -1;
3761
+ let target = trace_target(gobj, kw.scope);
3762
+ if(!target) {
3763
+ return -1; // Error already logged
3497
3764
  }
3498
- let rows = trace_rows(d, priv.trace_info[d.gclass]);
3765
+ let info = priv.trace_info[target.gclass];
3766
+ let rows = (kw.scope === "global")? global_trace_rows(info): trace_rows(target, info);
3499
3767
  let levels = own_trace_levels(rows, kw.scope);
3500
3768
  if(!levels.length) {
3501
3769
  /* The button is off when there is nothing: reaching here is
3502
3770
  * a button that did not follow the block. */
3503
- log_error(`${gobj_short_name(gobj)}: no ${kw.scope} trace of ${d.full_name} to remove`);
3771
+ log_error(`${gobj_short_name(gobj)}: no ${kw.scope} trace of ${target.full_name} to remove`);
3504
3772
  return -1;
3505
3773
  }
3506
- set_trace_levels(gobj, d, kw.scope, levels, false);
3774
+ set_trace_levels(gobj, target, kw.scope, levels, false);
3507
3775
  return 0;
3508
3776
  }
3509
3777
 
3510
- /* Lock the block and hand the change to the host. The block is
3511
- * repainted from what the backend says next, never from here. */
3512
- function set_trace_levels(gobj, d, scope, levels, set)
3778
+ /************************************************************
3779
+ * The gclass viewer asked for a set of every gobj of its
3780
+ * gclass ({gclass, levels, set}).
3781
+ ************************************************************/
3782
+ function ac_set_gclass_trace(gobj, event, kw, src)
3783
+ {
3784
+ let levels = (kw && Array.isArray(kw.levels))? kw.levels: [];
3785
+ if(!is_remote(gobj) || !kw.gclass || !levels.length) {
3786
+ log_error(`${gobj_short_name(gobj)}: a gclass trace set of no gclass or level, ` +
3787
+ `or on a tree that is not remote: '${kw && kw.gclass}'`);
3788
+ return -1;
3789
+ }
3790
+ set_trace_levels(gobj, {full_name: "", gclass: kw.gclass}, "gclass", levels, !!kw.set);
3791
+ return 0;
3792
+ }
3793
+
3794
+ /* Lock every block and hand the change to the host. The blocks are
3795
+ * repainted from what the backend says next, never from here.
3796
+ *
3797
+ * `target.gclass` is the gclass whose levels the host reads again
3798
+ * afterwards: the card's, the viewer's, or the root's for a set of
3799
+ * the yuno's scope -- which also moves what an open viewer of
3800
+ * ANOTHER gclass shows as held by the yuno, so that one is asked
3801
+ * for again when the answer is in (ac_trace_info). */
3802
+ function set_trace_levels(gobj, target, scope, levels, set)
3513
3803
  {
3514
3804
  let priv = gobj.priv;
3515
3805
  priv.trace_pending = true;
3516
- render_popover_body(gobj, d);
3806
+ render_current_popover(gobj);
3807
+
3808
+ let viewer = gclass_viewer_gobj(gobj);
3809
+ if(viewer) {
3810
+ let shown = gobj_read_str_attr(viewer, "gclass_name");
3811
+ if(scope === "global" && shown !== target.gclass) {
3812
+ priv.viewer_stale = shown;
3813
+ }
3814
+ gobj_send_event(viewer, "EV_SET_TRACES", viewer_traces(gobj, shown), gobj);
3815
+ }
3816
+
3517
3817
  gobj_publish_event(gobj, "EV_SET_TRACE_LEVEL", {
3518
3818
  scope: scope,
3519
- gobj: d.full_name,
3520
- gclass: d.gclass,
3819
+ gobj: target.full_name || "",
3820
+ gclass: target.gclass,
3521
3821
  levels: levels,
3522
3822
  set: set,
3523
3823
  });
3524
3824
  }
3525
3825
 
3826
+ /************************************************************
3827
+ * The toolbar's "traces of the yuno": the popover shows the
3828
+ * yuno's scope, read from the answer for the root's gclass.
3829
+ ************************************************************/
3830
+ function ac_open_yuno_traces(gobj, event, kw, src)
3831
+ {
3832
+ let priv = gobj.priv;
3833
+ let root = priv.remote_root;
3834
+ if(!is_remote(gobj) || !root) {
3835
+ log_error(`${gobj_short_name(gobj)}: the yuno's traces asked with no backend tree loaded`);
3836
+ return -1;
3837
+ }
3838
+ show_yuno_traces(gobj);
3839
+ gobj_publish_event(gobj, "EV_TRACE_INFO_WANTED", {gclass: root.gclass});
3840
+ return 0;
3841
+ }
3842
+
3526
3843
  /************************************************************
3527
3844
  * The app switched language.
3528
3845
  *
@@ -3603,6 +3920,8 @@ function create_gclass(gclass_name)
3603
3920
  ["EV_TRACE_TOGGLED", ac_trace_toggled, null],
3604
3921
  ["EV_TRACES_CLEARED", ac_traces_cleared, null],
3605
3922
  ["EV_GCLASS_DESCRIPTION", ac_gclass_description, null],
3923
+ ["EV_OPEN_YUNO_TRACES", ac_open_yuno_traces, null],
3924
+ ["EV_SET_GCLASS_TRACE", ac_set_gclass_trace, null],
3606
3925
  ]]
3607
3926
  ];
3608
3927
 
@@ -3635,6 +3954,9 @@ function create_gclass(gclass_name)
3635
3954
  ["EV_TRACE_TOGGLED", 0],
3636
3955
  ["EV_TRACES_CLEARED", 0],
3637
3956
  ["EV_GCLASS_DESCRIPTION", 0],
3957
+ ["EV_OPEN_YUNO_TRACES", 0],
3958
+ /* From the gclass viewer this view opens (its child). */
3959
+ ["EV_SET_GCLASS_TRACE", 0],
3638
3960
  /* Published only when `source` is "remote" (see the header). */
3639
3961
  ["EV_TREE_WANTED", event_flag_t.EVF_OUTPUT_EVENT],
3640
3962
  ["EV_TRACE_INFO_WANTED", event_flag_t.EVF_OUTPUT_EVENT],