@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
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* gclass_traces.wiring.test.js
|
|
3
|
+
*
|
|
4
|
+
* C_YUI_GCLASS, the gclass viewer, as the gobj tree opens it for a
|
|
5
|
+
* BACKEND gclass: its trace levels can be set for every gobj of
|
|
6
|
+
* the gclass (`set-gclass-trace`), one box per level, the yuno's
|
|
7
|
+
* own scope shown locked; and the layout that came out of the
|
|
8
|
+
* review of 7.27.27 -- the short zones first, a long table capped,
|
|
9
|
+
* the instance named beside its state, the methods in the head.
|
|
10
|
+
*
|
|
11
|
+
* The real gclass, hosted by a test gclass that declares what the
|
|
12
|
+
* viewer publishes.
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2026, ArtGins.
|
|
15
|
+
* All Rights Reserved.
|
|
16
|
+
***********************************************************************/
|
|
17
|
+
import {describe, test, expect, beforeAll, beforeEach} from "vitest";
|
|
18
|
+
import {install_dom_double, fake_event} from "../test/dom_double.js";
|
|
19
|
+
|
|
20
|
+
install_dom_double();
|
|
21
|
+
|
|
22
|
+
if(typeof globalThis.ResizeObserver === "undefined") {
|
|
23
|
+
globalThis.ResizeObserver = class {
|
|
24
|
+
observe() {
|
|
25
|
+
}
|
|
26
|
+
unobserve() {
|
|
27
|
+
}
|
|
28
|
+
disconnect() {
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
SDATA_END, gclass_create,
|
|
35
|
+
gobj_start_up, gobj_create_yuno, gobj_create,
|
|
36
|
+
gobj_start, gobj_read_attr, gobj_send_event,
|
|
37
|
+
set_log_callback,
|
|
38
|
+
} = await import("@yuneta/gobj-js");
|
|
39
|
+
const {register_c_yui_gclass} = await import("./c_yui_gclass.js");
|
|
40
|
+
|
|
41
|
+
const logged = [];
|
|
42
|
+
const asked = [];
|
|
43
|
+
let yuno = null;
|
|
44
|
+
let host = null;
|
|
45
|
+
let seq = 0;
|
|
46
|
+
|
|
47
|
+
/* A C-dialect description: 25 attrs, a machine whose actions the
|
|
48
|
+
* backend does not name, one output event. */
|
|
49
|
+
const DESCRIPTION = {
|
|
50
|
+
id: "C_TCP",
|
|
51
|
+
gcflag: [],
|
|
52
|
+
instances: 4,
|
|
53
|
+
attrs: Array.from({length: 25}, (_, i) => ({
|
|
54
|
+
id: `attr_${i}`, type: "string", flag: "SDF_RD|SDF_REQUIRED",
|
|
55
|
+
default_value: "", description: `attribute ${i}`
|
|
56
|
+
})),
|
|
57
|
+
commands: [],
|
|
58
|
+
gclass_methods: ["mt_create", "mt_start"],
|
|
59
|
+
internal_methods: [],
|
|
60
|
+
FSM: {
|
|
61
|
+
events: [
|
|
62
|
+
{event_name: "EV_RX_DATA", event_flag: ""},
|
|
63
|
+
{event_name: "EV_CONNECTED", event_flag: "EVF_OUTPUT_EVENT|EVF_PUBLIC_EVENT"},
|
|
64
|
+
],
|
|
65
|
+
states: {
|
|
66
|
+
ST_CONNECTED: [{event_name: "EV_RX_DATA", action: "action", next_state: ""}],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
info_gclass_trace: {traffic: "Trace dump traffic", connections: "Trace connections"},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/* What the host read: `connections` on for the gclass, `machine` for
|
|
73
|
+
* the whole yuno (so get-gclass-trace answers it too). */
|
|
74
|
+
const INFO = {
|
|
75
|
+
gclass_levels: {traffic: "Trace dump traffic", connections: "Trace connections"},
|
|
76
|
+
global_levels: {machine: "Trace machine", ev_kw: "Trace event keywords"},
|
|
77
|
+
gclass_on: ["connections", "machine"],
|
|
78
|
+
global_on: ["machine"],
|
|
79
|
+
error: "",
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
function record(gobj, event, kw, src)
|
|
83
|
+
{
|
|
84
|
+
asked.push({event: event, kw: kw});
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
beforeAll(async () => {
|
|
89
|
+
const i18next = (await import("i18next")).default;
|
|
90
|
+
await i18next.init({lng: "en", resources: {en: {translation: {
|
|
91
|
+
"instances": "instances",
|
|
92
|
+
"instances_one": "instance",
|
|
93
|
+
"machine states": "{{count}} states",
|
|
94
|
+
"machine states_one": "{{count}} state",
|
|
95
|
+
"machine events": "{{count}} events",
|
|
96
|
+
"machine events_one": "{{count}} event",
|
|
97
|
+
"show all {{n}}": "show all {{n}}",
|
|
98
|
+
}}}});
|
|
99
|
+
gobj_start_up(null, null, null, null, null, null, null);
|
|
100
|
+
set_log_callback((level, msg) => {
|
|
101
|
+
logged.push({level: String(level), msg: String(msg)});
|
|
102
|
+
});
|
|
103
|
+
gclass_create("C_TEST_GCLASS_YUNO", [], [["ST_IDLE", []]], {}, 0,
|
|
104
|
+
[SDATA_END()], {}, 0, 0, 0, 0);
|
|
105
|
+
gclass_create("C_TEST_GCLASS_TRACES_HOST",
|
|
106
|
+
[["EV_SET_GCLASS_TRACE", 0]],
|
|
107
|
+
[["ST_IDLE", [["EV_SET_GCLASS_TRACE", record, null]]]],
|
|
108
|
+
{}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
|
|
109
|
+
register_c_yui_gclass();
|
|
110
|
+
yuno = gobj_create_yuno("gclass_traces_yuno", "C_TEST_GCLASS_YUNO", {});
|
|
111
|
+
gobj_start(yuno);
|
|
112
|
+
host = gobj_create("host", "C_TEST_GCLASS_TRACES_HOST", {}, yuno);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
beforeEach(() => {
|
|
116
|
+
logged.length = 0;
|
|
117
|
+
asked.length = 0;
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
function problems()
|
|
121
|
+
{
|
|
122
|
+
return logged.filter((l) => l.level === "error" || l.level === "warning").map((l) => l.msg);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function open(kw)
|
|
126
|
+
{
|
|
127
|
+
const view = gobj_create(`gclass_view_${++seq}`, "C_YUI_GCLASS",
|
|
128
|
+
Object.assign({description: DESCRIPTION}, kw || {}), host);
|
|
129
|
+
gobj_start(view);
|
|
130
|
+
return view;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function box_of(view, level)
|
|
134
|
+
{
|
|
135
|
+
return gobj_read_attr(view, "$container").querySelectorAll(".GCLASS_TRACE_GCLASS")
|
|
136
|
+
.find((b) => b.getAttribute("data-level") === level);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function visible_rows(view, zone)
|
|
140
|
+
{
|
|
141
|
+
return gobj_read_attr(view, "$container")
|
|
142
|
+
.querySelectorAll(`.GCLASS_ZONE[data-zone="${zone}"] tbody tr`)
|
|
143
|
+
.filter((tr) => !tr.classList.contains("is-hidden")).length;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
describe("C_YUI_GCLASS: the gclass' trace levels, set from the viewer", () => {
|
|
147
|
+
test("one box per level, own and kernel, the yuno's locked", () => {
|
|
148
|
+
const view = open({traces: {info: INFO, pending: false}});
|
|
149
|
+
expect([box_of(view, "traffic").checked, box_of(view, "traffic").disabled]).toEqual([false, false]);
|
|
150
|
+
expect([box_of(view, "connections").checked, box_of(view, "connections").disabled])
|
|
151
|
+
.toEqual([true, false]);
|
|
152
|
+
expect([box_of(view, "machine").checked, box_of(view, "machine").disabled]).toEqual([true, true]);
|
|
153
|
+
expect([box_of(view, "ev_kw").checked, box_of(view, "ev_kw").disabled]).toEqual([false, false]);
|
|
154
|
+
expect(problems()).toEqual([]);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("a box asks the host, and the zone stays locked until it answers", () => {
|
|
158
|
+
const view = open({traces: {info: INFO, pending: false}});
|
|
159
|
+
const $b = box_of(view, "ev_kw");
|
|
160
|
+
$b.checked = true;
|
|
161
|
+
$b.dispatchEvent(fake_event("change"));
|
|
162
|
+
expect(asked).toEqual([{event: "EV_SET_GCLASS_TRACE",
|
|
163
|
+
kw: {gclass: "C_TCP", levels: ["ev_kw"], set: true}}]);
|
|
164
|
+
expect(box_of(view, "traffic").disabled).toBe(true);
|
|
165
|
+
|
|
166
|
+
gobj_send_event(view, "EV_SET_TRACES", {info: Object.assign({}, INFO,
|
|
167
|
+
{gclass_on: ["connections", "machine", "ev_kw"]}), pending: false}, host);
|
|
168
|
+
expect([box_of(view, "ev_kw").checked, box_of(view, "ev_kw").disabled]).toEqual([true, false]);
|
|
169
|
+
expect(problems()).toEqual([]);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("remove the traces of the gclass turns off its own, not the yuno's", () => {
|
|
173
|
+
const view = open({traces: {info: INFO, pending: false}});
|
|
174
|
+
gobj_read_attr(view, "$container").querySelector(".GCLASS_TRACES_CLEAR").click();
|
|
175
|
+
expect(asked.map((a) => [a.kw.levels, a.kw.set])).toEqual([[["connections"], false]]);
|
|
176
|
+
expect(problems()).toEqual([]);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test("with no host that can set them, the levels are only listed", () => {
|
|
180
|
+
const view = open({});
|
|
181
|
+
const $c = gobj_read_attr(view, "$container");
|
|
182
|
+
expect($c.querySelectorAll(".GCLASS_TRACE_GCLASS").length).toBe(0);
|
|
183
|
+
expect($c.querySelectorAll('.GCLASS_ZONE[data-zone="traces"] tbody tr').length).toBe(2);
|
|
184
|
+
expect(problems()).toEqual([]);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe("C_YUI_GCLASS: the layout", () => {
|
|
189
|
+
test("the short zones first, the long tables last, the methods in the head", () => {
|
|
190
|
+
const view = open({});
|
|
191
|
+
const $c = gobj_read_attr(view, "$container");
|
|
192
|
+
expect($c.querySelectorAll(".GCLASS_ZONE").map((z) => z.getAttribute("data-zone")))
|
|
193
|
+
.toEqual(["machine", "traces", "attrs", "commands"]);
|
|
194
|
+
expect($c.querySelectorAll(".GCLASS_HEAD .GCLASS_METHOD").map((m) => m.textContent))
|
|
195
|
+
.toEqual(["mt_create", "mt_start"]);
|
|
196
|
+
expect($c.querySelector('.GCLASS_ZONE[data-zone="machine"] .GCLASS_ZONE_COUNT').textContent)
|
|
197
|
+
.toBe("1 state · 1 event");
|
|
198
|
+
expect($c.querySelector(".GCLASS_INSTANCES_LABEL").textContent).toBe("instances");
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("the state the reader came from is said with its instance", () => {
|
|
202
|
+
const view = open({current_state: "ST_CONNECTED", instance_name: "tcp1"});
|
|
203
|
+
const $c = gobj_read_attr(view, "$container");
|
|
204
|
+
expect($c.querySelector(".GCLASS_CURRENT_INSTANCE").textContent).toBe("tcp1");
|
|
205
|
+
expect($c.querySelector(".GCLASS_CURRENT_STATE").textContent).toBe("ST_CONNECTED");
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
test("an action the backend does not name has its own line in the legend", () => {
|
|
209
|
+
const view = open({});
|
|
210
|
+
const $c = gobj_read_attr(view, "$container");
|
|
211
|
+
expect($c.querySelector(".GCLASS_LEGEND_SWATCH.is-unnamed")).not.toBe(null);
|
|
212
|
+
/* no empty cell is drawn, so no legend for one */
|
|
213
|
+
expect($c.querySelector(".GCLASS_LEGEND_SWATCH.is-none")).toBe(null);
|
|
214
|
+
expect($c.querySelectorAll(".GCLASS_PUB_ROW").length).toBe(1);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test("a long table shows 20 rows and a button for the rest; a search shows every match", () => {
|
|
218
|
+
const view = open({});
|
|
219
|
+
const $c = gobj_read_attr(view, "$container");
|
|
220
|
+
expect(visible_rows(view, "attrs")).toBe(20);
|
|
221
|
+
const $more = $c.querySelector('.GCLASS_SHOW_ALL[data-zone="attrs"]');
|
|
222
|
+
expect($more.classList.contains("is-hidden")).toBe(false);
|
|
223
|
+
|
|
224
|
+
gobj_send_event(view, "EV_SEARCH", {text: "attr_24"}, view);
|
|
225
|
+
expect(visible_rows(view, "attrs")).toBe(1);
|
|
226
|
+
expect($more.classList.contains("is-hidden")).toBe(true);
|
|
227
|
+
|
|
228
|
+
gobj_send_event(view, "EV_SEARCH", {text: ""}, view);
|
|
229
|
+
expect(visible_rows(view, "attrs")).toBe(20);
|
|
230
|
+
$more.click();
|
|
231
|
+
expect(visible_rows(view, "attrs")).toBe(25);
|
|
232
|
+
expect($more.classList.contains("is-hidden")).toBe(true);
|
|
233
|
+
expect(problems()).toEqual([]);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
@@ -31,7 +31,7 @@ if(typeof globalThis.ResizeObserver === "undefined") {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const camera = vi.hoisted(() => ({zoom: NaN, position: [NaN, NaN], zoomed: [], moved: [],
|
|
34
|
-
size: null, viewport: null}));
|
|
34
|
+
size: null, viewport: null, plugins: []}));
|
|
35
35
|
vi.mock("@antv/g6", async (importOriginal) => {
|
|
36
36
|
const real = await importOriginal();
|
|
37
37
|
class FakeGraph {
|
|
@@ -93,8 +93,16 @@ vi.mock("@antv/g6", async (importOriginal) => {
|
|
|
93
93
|
getEdgeData() {
|
|
94
94
|
return [];
|
|
95
95
|
}
|
|
96
|
+
/* The plugins the view asked for, kept so a test can read
|
|
97
|
+
* them (camera.plugins). */
|
|
96
98
|
getPlugins() {
|
|
97
|
-
return
|
|
99
|
+
return camera.plugins;
|
|
100
|
+
}
|
|
101
|
+
setPlugins(arg) {
|
|
102
|
+
camera.plugins = (typeof arg === "function")? arg(camera.plugins) : arg;
|
|
103
|
+
}
|
|
104
|
+
getPluginInstance(key) {
|
|
105
|
+
return camera.plugins.some((p) => p.key === key)? {destroyed: false} : undefined;
|
|
98
106
|
}
|
|
99
107
|
getBehaviors() {
|
|
100
108
|
return [];
|
|
@@ -119,6 +127,7 @@ const {
|
|
|
119
127
|
gobj_start, gobj_read_attr, gobj_send_event, set_log_callback, register_c_timer,
|
|
120
128
|
} = await import("@yuneta/gobj-js");
|
|
121
129
|
const {register_c_yui_gobj_tree_js} = await import("./c_yui_gobj_tree_js.js");
|
|
130
|
+
const {describe_js_gobj} = await import("./gobj_tree_model.js");
|
|
122
131
|
|
|
123
132
|
const logged = [];
|
|
124
133
|
let yuno = null;
|
|
@@ -146,6 +155,7 @@ beforeEach(() => {
|
|
|
146
155
|
camera.moved = [];
|
|
147
156
|
camera.size = null;
|
|
148
157
|
camera.viewport = null;
|
|
158
|
+
camera.plugins = [];
|
|
149
159
|
});
|
|
150
160
|
|
|
151
161
|
function errors()
|
|
@@ -153,10 +163,10 @@ function errors()
|
|
|
153
163
|
return logged.filter((l) => l.level === "error").map((l) => l.msg);
|
|
154
164
|
}
|
|
155
165
|
|
|
156
|
-
async function mount(name)
|
|
166
|
+
async function mount(name, kw)
|
|
157
167
|
{
|
|
158
168
|
const view = gobj_create_pure_child(name, "C_YUI_GOBJ_TREE_JS",
|
|
159
|
-
{$container: document.createElement("div")}, yuno);
|
|
169
|
+
{$container: document.createElement("div"), ...(kw || {})}, yuno);
|
|
160
170
|
document.body.appendChild(gobj_read_attr(view, "$container"));
|
|
161
171
|
gobj_start(view);
|
|
162
172
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
@@ -259,3 +269,33 @@ describe("C_YUI_GOBJ_TREE_JS opens centred on its root", () => {
|
|
|
259
269
|
expect(errors()).toEqual([]);
|
|
260
270
|
});
|
|
261
271
|
});
|
|
272
|
+
|
|
273
|
+
describe("C_YUI_GOBJ_TREE_JS shows a minimap when the tree is big enough", () => {
|
|
274
|
+
test("from minimap_min_nodes cards on, anchored by css at the bottom left", async () => {
|
|
275
|
+
await mount(`camera_${++seq}`, {minimap_min_nodes: 1});
|
|
276
|
+
const minimap = camera.plugins.find((p) => p.key === "minimap");
|
|
277
|
+
expect(minimap).toBeTruthy();
|
|
278
|
+
expect(minimap.type).toBe("minimap");
|
|
279
|
+
expect(minimap.containerStyle).toMatchObject({top: "auto", bottom: "12px", left: "12px"});
|
|
280
|
+
expect(typeof minimap.shape).toBe("function");
|
|
281
|
+
expect(errors()).toEqual([]);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test("none below the threshold, and none at all with 0", async () => {
|
|
285
|
+
await mount(`camera_${++seq}`, {minimap_min_nodes: 100000});
|
|
286
|
+
expect(camera.plugins.some((p) => p.key === "minimap")).toBe(false);
|
|
287
|
+
await mount(`camera_${++seq}`, {minimap_min_nodes: 0});
|
|
288
|
+
expect(camera.plugins.some((p) => p.key === "minimap")).toBe(false);
|
|
289
|
+
expect(errors()).toEqual([]);
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
describe("a gobj of this browser says whether play and pause mean anything to it", () => {
|
|
294
|
+
test("play_methods follows the gclass' mt_play / mt_pause", () => {
|
|
295
|
+
gclass_create("C_TEST_WITH_PLAY", [], [["ST_IDLE", []]],
|
|
296
|
+
{mt_play: () => 0}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
|
|
297
|
+
const player = gobj_create_pure_child(`player_${++seq}`, "C_TEST_WITH_PLAY", {}, yuno);
|
|
298
|
+
expect(describe_js_gobj(player, false).play_methods).toBe(true);
|
|
299
|
+
expect(describe_js_gobj(yuno, true).play_methods).toBe(false);
|
|
300
|
+
});
|
|
301
|
+
});
|
package/src/gobj_tree_model.js
CHANGED
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
* the field names are the ones `gobj2json()` writes in
|
|
16
16
|
* `kernel/c/gobj-c/src/gobj.c` (fullname, shortname, gclass,
|
|
17
17
|
* name, parent, state, running, playing, service, disabled,
|
|
18
|
-
* volatil, bottom_gobj, gobj_flags, commands, gobj_trace_level
|
|
19
|
-
* Anything the browser runtime cannot answer is
|
|
20
|
-
* and every reader here treats absent as "not
|
|
21
|
-
* false
|
|
18
|
+
* volatil, bottom_gobj, gobj_flags, commands, gobj_trace_level,
|
|
19
|
+
* play_methods). Anything the browser runtime cannot answer is
|
|
20
|
+
* simply absent, and every reader here treats absent as "not
|
|
21
|
+
* known", never as false -- `play_methods` included, which a
|
|
22
|
+
* backend built before it was added does not answer.
|
|
22
23
|
*
|
|
23
24
|
* Copyright (c) 2026, ArtGins.
|
|
24
25
|
* All Rights Reserved.
|
|
@@ -88,6 +89,25 @@ function node_status(d)
|
|
|
88
89
|
return d.playing? "playing": "running";
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
/************************************************************
|
|
93
|
+
* Whether play and pause MEAN something to the node: its
|
|
94
|
+
* gclass has an mt_play or an mt_pause.
|
|
95
|
+
*
|
|
96
|
+
* Most gclasses have neither -- a C_TCP, a C_TIMER, a C_NODE
|
|
97
|
+
* -- and nothing ever plays them, so a gobj of theirs that
|
|
98
|
+
* runs is doing all it can. Calling it paused painted almost
|
|
99
|
+
* every card of a backend yuno amber, which is the colour of
|
|
100
|
+
* something to look at.
|
|
101
|
+
*
|
|
102
|
+
* `play_methods` is unknown (null) for a backend yuno that does
|
|
103
|
+
* not answer it in `view-gobj-tree`, and then the node is taken
|
|
104
|
+
* as one that can be paused, which is what was said before.
|
|
105
|
+
************************************************************/
|
|
106
|
+
function node_can_pause(d)
|
|
107
|
+
{
|
|
108
|
+
return !d || d.play_methods !== false;
|
|
109
|
+
}
|
|
110
|
+
|
|
91
111
|
/*
|
|
92
112
|
* What the status LOOKS like, before any word is read.
|
|
93
113
|
*
|
|
@@ -110,6 +130,10 @@ const STATUS_SYMBOLS = {
|
|
|
110
130
|
"stopped": "\u25A0\uFE0E", /* stop */
|
|
111
131
|
};
|
|
112
132
|
|
|
133
|
+
/* Running, for a gobj with nothing to play: ON, a shape of its own,
|
|
134
|
+
* neither the play it never gets nor the pause it is not in. */
|
|
135
|
+
const RUNNING_SYMBOL = "\u25CF"; /* a filled circle */
|
|
136
|
+
|
|
113
137
|
const DISABLED_SYMBOL = "\u2298"; /* a slashed circle */
|
|
114
138
|
|
|
115
139
|
/************************************************************
|
|
@@ -122,13 +146,18 @@ function node_status_symbol(d)
|
|
|
122
146
|
if(d && d.disabled) {
|
|
123
147
|
return DISABLED_SYMBOL;
|
|
124
148
|
}
|
|
125
|
-
|
|
149
|
+
let status = node_status(d);
|
|
150
|
+
if(status === "running" && !node_can_pause(d)) {
|
|
151
|
+
return RUNNING_SYMBOL;
|
|
152
|
+
}
|
|
153
|
+
return STATUS_SYMBOLS[status] || STATUS_SYMBOLS.stopped;
|
|
126
154
|
}
|
|
127
155
|
|
|
128
156
|
/************************************************************
|
|
129
157
|
* The i18n key of the status, which is NOT the status itself:
|
|
130
158
|
* a gobj that runs and does not play is PAUSED to the reader,
|
|
131
|
-
* and "running" alone never said which of the two it was
|
|
159
|
+
* and "running" alone never said which of the two it was --
|
|
160
|
+
* unless play and pause mean nothing to it (node_can_pause()).
|
|
132
161
|
************************************************************/
|
|
133
162
|
function node_status_key(d)
|
|
134
163
|
{
|
|
@@ -136,7 +165,7 @@ function node_status_key(d)
|
|
|
136
165
|
case "playing":
|
|
137
166
|
return "playing";
|
|
138
167
|
case "running":
|
|
139
|
-
return "running (paused)";
|
|
168
|
+
return node_can_pause(d)? "running (paused)": "running";
|
|
140
169
|
default:
|
|
141
170
|
return "stopped";
|
|
142
171
|
}
|
|
@@ -185,6 +214,8 @@ function describe_js_gobj(target_gobj, is_root)
|
|
|
185
214
|
|
|
186
215
|
bottom_gobj: bottom? (gobj_short_name(bottom) || ""): "",
|
|
187
216
|
commands: !!(target_gobj.gclass && target_gobj.gclass.command_table),
|
|
217
|
+
play_methods: !!(target_gobj.gclass && target_gobj.gclass.gmt &&
|
|
218
|
+
(target_gobj.gclass.gmt.mt_play || target_gobj.gclass.gmt.mt_pause)),
|
|
188
219
|
is_yuno: !!is_root,
|
|
189
220
|
children: [],
|
|
190
221
|
};
|
|
@@ -233,6 +264,8 @@ function describe_backend_node(shortname, node, is_root)
|
|
|
233
264
|
disabled: !!node.disabled,
|
|
234
265
|
bottom_gobj: node.bottom_gobj || "",
|
|
235
266
|
commands: !!node.commands,
|
|
267
|
+
/* Unknown (null) for a yuno that does not answer it. */
|
|
268
|
+
play_methods: (typeof node.play_methods === "boolean")? node.play_methods: null,
|
|
236
269
|
gobj_flags: flags,
|
|
237
270
|
gobj_trace_level: Array.isArray(node.gobj_trace_level)?
|
|
238
271
|
node.gobj_trace_level: [],
|
|
@@ -365,6 +398,7 @@ function node_labels(t)
|
|
|
365
398
|
status: {
|
|
366
399
|
"playing": t("playing"),
|
|
367
400
|
"running (paused)": t("running (paused)"),
|
|
401
|
+
"running": t("running"),
|
|
368
402
|
"stopped": t("stopped"),
|
|
369
403
|
},
|
|
370
404
|
/* The glanceable ones, for the pill on the card, which has
|
|
@@ -477,9 +511,19 @@ function node_info_rows(d, t)
|
|
|
477
511
|
|
|
478
512
|
|
|
479
513
|
/************************************************************
|
|
480
|
-
* The
|
|
481
|
-
*
|
|
482
|
-
*
|
|
514
|
+
* The trace levels of a backend gobj, one row per level it
|
|
515
|
+
* can trace: the gclass' own levels first (the ones that are
|
|
516
|
+
* about this gobj), then the KERNEL's (`machine`,
|
|
517
|
+
* `create_delete`, `ev_kw`...).
|
|
518
|
+
*
|
|
519
|
+
* Two families of levels and three scopes, and the words must
|
|
520
|
+
* not mix them. The kernel's levels are the table of gobj.c
|
|
521
|
+
* that the C side calls "global" -- but they are not global
|
|
522
|
+
* TRACES: every one of them can be set for one gobj
|
|
523
|
+
* (`set-gobj-trace`), for every gobj of a gclass
|
|
524
|
+
* (`set-gclass-trace`, the way to trace the machine of C_TCP
|
|
525
|
+
* alone) or for the whole yuno (`set-global-trace`). A
|
|
526
|
+
* gclass' own levels have only the first two scopes.
|
|
483
527
|
*
|
|
484
528
|
* `d` is the descriptor (its `gobj_trace_level` is what the
|
|
485
529
|
* gobj traces NOW, whatever the reason). `info` is what the
|
|
@@ -491,19 +535,21 @@ function node_info_rows(d, t)
|
|
|
491
535
|
* global_on [name, ...] get-global-trace
|
|
492
536
|
*
|
|
493
537
|
* `get-gclass-trace` answers the gclass' levels OR'ed with the
|
|
494
|
-
*
|
|
495
|
-
*
|
|
538
|
+
* yuno's (gobj_get_gclass_trace_level), so a level on in both
|
|
539
|
+
* is counted as the yuno's: that is the one that would still
|
|
496
540
|
* hold it on if the gclass let go.
|
|
497
541
|
*
|
|
498
|
-
* Each row says, for
|
|
542
|
+
* Each row says, for each scope:
|
|
499
543
|
*
|
|
544
|
+
* group "gclass" | "kernel"
|
|
500
545
|
* gobj_on, gobj_locked the gobj traces it; locked when
|
|
501
546
|
* that comes from its gclass or
|
|
502
|
-
* from the
|
|
503
|
-
*
|
|
547
|
+
* from the yuno -- turning the
|
|
548
|
+
* gobj's own bit off would not
|
|
504
549
|
* stop it
|
|
505
550
|
* gclass_on, gclass_locked every gobj of the gclass traces
|
|
506
|
-
* it; locked when
|
|
551
|
+
* it; locked when the yuno does
|
|
552
|
+
* global_on the whole yuno traces it
|
|
507
553
|
* origin "global" | "gclass" | ""
|
|
508
554
|
************************************************************/
|
|
509
555
|
function trace_rows(d, info)
|
|
@@ -537,12 +583,38 @@ function trace_rows(d, info)
|
|
|
537
583
|
gobj_locked: by_global || by_gclass,
|
|
538
584
|
gclass_on: by_global || by_gclass,
|
|
539
585
|
gclass_locked: by_global,
|
|
586
|
+
global_on: by_global,
|
|
540
587
|
origin: by_global? "global": (by_gclass? "gclass": ""),
|
|
541
588
|
});
|
|
542
589
|
}
|
|
543
590
|
};
|
|
544
591
|
add("gclass", info.gclass_levels);
|
|
545
|
-
add("
|
|
592
|
+
add("kernel", info.global_levels);
|
|
593
|
+
return rows;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/************************************************************
|
|
597
|
+
* The rows of the YUNO's scope: the kernel's levels, and
|
|
598
|
+
* whether the whole yuno traces each one (`set-global-trace`).
|
|
599
|
+
* A gclass' own levels have no such scope.
|
|
600
|
+
************************************************************/
|
|
601
|
+
function global_trace_rows(info)
|
|
602
|
+
{
|
|
603
|
+
let rows = [];
|
|
604
|
+
if(!info) {
|
|
605
|
+
return rows;
|
|
606
|
+
}
|
|
607
|
+
let global_on = Array.isArray(info.global_on)? info.global_on: [];
|
|
608
|
+
let levels = (info.global_levels && typeof info.global_levels === "object")?
|
|
609
|
+
info.global_levels: {};
|
|
610
|
+
for(let level of Object.keys(levels)) {
|
|
611
|
+
rows.push({
|
|
612
|
+
level: level,
|
|
613
|
+
description: String(levels[level] || ""),
|
|
614
|
+
group: "kernel",
|
|
615
|
+
global_on: global_on.indexOf(level) >= 0,
|
|
616
|
+
});
|
|
617
|
+
}
|
|
546
618
|
return rows;
|
|
547
619
|
}
|
|
548
620
|
|
|
@@ -560,6 +632,8 @@ function own_trace_levels(rows, scope)
|
|
|
560
632
|
out.push(r.level);
|
|
561
633
|
} else if(scope === "gclass" && r.gclass_on && !r.gclass_locked) {
|
|
562
634
|
out.push(r.level);
|
|
635
|
+
} else if(scope === "global" && r.global_on) {
|
|
636
|
+
out.push(r.level);
|
|
563
637
|
}
|
|
564
638
|
}
|
|
565
639
|
return out;
|
|
@@ -571,6 +645,7 @@ export {
|
|
|
571
645
|
STATUS_SYMBOLS,
|
|
572
646
|
node_role,
|
|
573
647
|
node_status,
|
|
648
|
+
node_can_pause,
|
|
574
649
|
node_status_key,
|
|
575
650
|
node_status_symbol,
|
|
576
651
|
node_badge_keys,
|
|
@@ -581,5 +656,6 @@ export {
|
|
|
581
656
|
describe_backend_node,
|
|
582
657
|
describe_backend_tree,
|
|
583
658
|
trace_rows,
|
|
659
|
+
global_trace_rows,
|
|
584
660
|
own_trace_levels,
|
|
585
661
|
};
|
|
@@ -4,11 +4,13 @@ import {
|
|
|
4
4
|
node_status,
|
|
5
5
|
node_status_symbol,
|
|
6
6
|
node_status_key,
|
|
7
|
+
node_can_pause,
|
|
7
8
|
node_badge_keys,
|
|
8
9
|
node_info_rows,
|
|
9
10
|
describe_backend_node,
|
|
10
11
|
describe_backend_tree,
|
|
11
12
|
trace_rows,
|
|
13
|
+
global_trace_rows,
|
|
12
14
|
own_trace_levels,
|
|
13
15
|
} from "./gobj_tree_model.js";
|
|
14
16
|
|
|
@@ -120,6 +122,26 @@ describe("node_status", () => {
|
|
|
120
122
|
it("a gobj that plays without running cannot happen, and reads stopped", () => {
|
|
121
123
|
expect(node_status({running: false, playing: true})).toBe("stopped");
|
|
122
124
|
});
|
|
125
|
+
|
|
126
|
+
it("never says paused for a gobj with nothing to play", () => {
|
|
127
|
+
let d = {running: true, playing: false, play_methods: false};
|
|
128
|
+
expect(node_can_pause(d)).toBe(false);
|
|
129
|
+
expect(node_status(d)).toBe("running");
|
|
130
|
+
expect(node_status_key(d)).toBe("running");
|
|
131
|
+
expect(node_status_symbol(d)).toBe("\u25CF");
|
|
132
|
+
/* Played anyway, it says so; stopped is stopped. */
|
|
133
|
+
expect(node_status_key({running: true, playing: true, play_methods: false}))
|
|
134
|
+
.toBe("playing");
|
|
135
|
+
expect(node_status_key({running: false, play_methods: false}))
|
|
136
|
+
.toBe("stopped");
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("an unknown play_methods keeps the old word: paused", () => {
|
|
140
|
+
expect(node_can_pause({running: true, play_methods: null})).toBe(true);
|
|
141
|
+
expect(node_can_pause({running: true})).toBe(true);
|
|
142
|
+
expect(node_status_key({running: true, playing: false, play_methods: true}))
|
|
143
|
+
.toBe("running (paused)");
|
|
144
|
+
});
|
|
123
145
|
});
|
|
124
146
|
|
|
125
147
|
describe("node_badge_keys", () => {
|
|
@@ -157,10 +179,10 @@ describe("trace_rows", () => {
|
|
|
157
179
|
return map;
|
|
158
180
|
};
|
|
159
181
|
|
|
160
|
-
it("lists the gclass levels first, then the
|
|
182
|
+
it("lists the gclass levels first, then the kernel's, each once", () => {
|
|
161
183
|
let rows = trace_rows({gobj_trace_level: []}, INFO);
|
|
162
184
|
expect(rows.map((r) => [r.level, r.group])).toEqual([
|
|
163
|
-
["traffic", "gclass"], ["connections", "gclass"], ["machine", "
|
|
185
|
+
["traffic", "gclass"], ["connections", "gclass"], ["machine", "kernel"]
|
|
164
186
|
]);
|
|
165
187
|
});
|
|
166
188
|
|
|
@@ -171,7 +193,8 @@ describe("trace_rows", () => {
|
|
|
171
193
|
expect(r.connections).toMatchObject({gobj_on: true, gobj_locked: true,
|
|
172
194
|
gclass_on: true, gclass_locked: false, origin: "gclass"});
|
|
173
195
|
expect(r.machine).toMatchObject({gobj_on: true, gobj_locked: true,
|
|
174
|
-
gclass_on: true, gclass_locked: true, origin: "global"});
|
|
196
|
+
gclass_on: true, gclass_locked: true, global_on: true, origin: "global"});
|
|
197
|
+
expect(r.connections.global_on).toBe(false);
|
|
175
198
|
});
|
|
176
199
|
|
|
177
200
|
it("what each scope holds on its own is what its remove turns off", () => {
|
|
@@ -183,6 +206,15 @@ describe("trace_rows", () => {
|
|
|
183
206
|
it("no info, no rows", () => {
|
|
184
207
|
expect(trace_rows({gobj_trace_level: ["machine"]}, null)).toEqual([]);
|
|
185
208
|
expect(own_trace_levels(null, "gobj")).toEqual([]);
|
|
209
|
+
expect(global_trace_rows(null)).toEqual([]);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("the yuno's scope has the kernel's levels only, and what it traces", () => {
|
|
213
|
+
let rows = global_trace_rows(INFO);
|
|
214
|
+
expect(rows.map((r) => [r.level, r.global_on])).toEqual([
|
|
215
|
+
["machine", true], ["connections", false]
|
|
216
|
+
]);
|
|
217
|
+
expect(own_trace_levels(rows, "global")).toEqual(["machine"]);
|
|
186
218
|
});
|
|
187
219
|
});
|
|
188
220
|
|
|
@@ -221,6 +253,19 @@ describe("node_info_rows", () => {
|
|
|
221
253
|
expect(r["flags"]).toBe("gobj_flag_yuno, gobj_flag_service");
|
|
222
254
|
});
|
|
223
255
|
|
|
256
|
+
it("reads play_methods from the backend only when it answers a boolean", () => {
|
|
257
|
+
expect(describe_backend_node("C_X^x", {play_methods: false}, false).play_methods)
|
|
258
|
+
.toBe(false);
|
|
259
|
+
expect(describe_backend_node("C_X^x", {play_methods: true}, false).play_methods)
|
|
260
|
+
.toBe(true);
|
|
261
|
+
expect(describe_backend_node("C_X^x", {}, false).play_methods).toBe(null);
|
|
262
|
+
expect(describe_backend_node("C_X^x", {play_methods: 1}, false).play_methods)
|
|
263
|
+
.toBe(null);
|
|
264
|
+
let r = rows_of(describe_backend_node("C_TCP^x",
|
|
265
|
+
{gclass: "C_TCP", running: true, playing: false, play_methods: false}, false));
|
|
266
|
+
expect(r["status"]).toBe("\u25CF running");
|
|
267
|
+
});
|
|
268
|
+
|
|
224
269
|
it("omits every row whose fact is absent", () => {
|
|
225
270
|
let r = rows_of(describe_backend_node("C_X^x", {gclass: "C_X"}, false));
|
|
226
271
|
expect(r["bottom gobj"]).toBeUndefined();
|