@hpcc-js/eclwatch 2.77.7 → 2.77.8

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/src/WUGraph.ts CHANGED
@@ -1,265 +1,265 @@
1
- import { Button, Spacer, ToggleButton, Widget } from "@hpcc-js/common";
2
- import { ScopeGraph, Workunit } from "@hpcc-js/comms";
3
- import { Table } from "@hpcc-js/dgrid";
4
- import { Graph as GraphWidget, Subgraph, Vertex } from "@hpcc-js/graph";
5
- import { Carousel, ChartPanel } from "@hpcc-js/layout";
6
- import { hashSum } from "@hpcc-js/util";
7
- import { WUGraphLegend } from "./WUGraphLegend";
8
- import { WUScopeController } from "./WUScopeController";
9
-
10
- import "../src/WUGraph.css";
11
-
12
- export class WUGraph extends ChartPanel {
13
-
14
- private _partialAll = new Button().faChar("fa-window-restore").tooltip("Partial All")
15
- .on("click", () => {
16
- this.stateClick(this._partialAll);
17
- });
18
-
19
- private _maxAll = new Button().faChar("fa-window-maximize").tooltip("Max All")
20
- .on("click", () => {
21
- this.stateClick(this._maxAll);
22
- });
23
-
24
- private _toggleGraph = new ToggleButton().faChar("fa-chain").tooltip("Graph")
25
- .selected(true)
26
- .on("click", () => {
27
- this.viewClick(this._toggleGraph);
28
- });
29
-
30
- private _toggleActivities = new ToggleButton().faChar("fa-table").tooltip("Activitiies")
31
- .selected(false)
32
- .on("click", () => {
33
- this.viewClick(this._toggleActivities);
34
- });
35
-
36
- private _toggleEdges = new ToggleButton().faChar("fa-table").tooltip("Edges")
37
- .selected(false)
38
- .on("click", () => {
39
- this.viewClick(this._toggleEdges);
40
- });
41
-
42
- private _toggleSubgraphs = new ToggleButton().faChar("fa-table").tooltip("Subgraphs")
43
- .selected(false)
44
- .on("click", () => {
45
- this.viewClick(this._toggleSubgraphs);
46
- });
47
-
48
- protected _graph = new GraphWidget()
49
- .layout("Hierarchy")
50
- .applyScaleOnLayout(true)
51
- .showToolbar(false)
52
- .allowDragging(false)
53
- ;
54
-
55
- private _activities = new Table()
56
- .pagination(false)
57
- ;
58
-
59
- private _edges = new Table()
60
- .pagination(false)
61
- ;
62
-
63
- private _subgraphs = new Table()
64
- .pagination(false)
65
- ;
66
-
67
- protected _legend = new WUGraphLegend(this)
68
- .on("click", kind => {
69
- this.render();
70
- })
71
- .on("mouseover", kind => {
72
- const verticesMap: { [id: string]: boolean } = {};
73
- for (const vertex of this._gc.vertices(kind)) {
74
- verticesMap[vertex.id()] = true;
75
- }
76
- this._graph.highlightVerticies(verticesMap);
77
- })
78
- .on("mouseout", kind => {
79
- this._graph.highlightVerticies();
80
- })
81
- ;
82
-
83
- protected _view = new Carousel().widgets([this._graph, this._activities, this._edges, this._subgraphs]);
84
-
85
- protected _gc = new WUScopeController();
86
-
87
- constructor() {
88
- super();
89
- this.topOverlay(false);
90
- this.widget(this._view);
91
- const buttons: Widget[] = [
92
- this._toggleGraph,
93
- this._toggleActivities,
94
- this._toggleEdges,
95
- this._toggleSubgraphs,
96
- new Spacer(),
97
- this._partialAll,
98
- this._maxAll,
99
- new Spacer(),
100
- ...this._graph.iconBarButtons(),
101
- new Spacer()];
102
- this.buttons(buttons.concat(this.buttons()));
103
- this._gc.minClick = (sg: Subgraph) => {
104
- this.loadGraph();
105
- this._graph.render(w => {
106
- this._graph
107
- .selection([sg])
108
- .centerOnItem(sg)
109
- ;
110
- });
111
- };
112
-
113
- this._graph.tooltipHTML((v: Vertex) => {
114
- return this._gc.calcGraphTooltip(v);
115
- });
116
- }
117
-
118
- stateClick(sourceB: Button) {
119
- switch (sourceB) {
120
- case this._partialAll:
121
- this._graph.data().subgraphs.forEach((sg: Subgraph) => {
122
- sg.minState("partial");
123
- });
124
- break;
125
- case this._maxAll:
126
- this._graph.data().subgraphs.forEach((sg: Subgraph) => {
127
- sg.minState("normal");
128
- });
129
- break;
130
- }
131
- this.render();
132
- }
133
-
134
- viewClick(sourceTB: ToggleButton) {
135
- this._toggleGraph.selected(sourceTB === this._toggleGraph);
136
- this._toggleActivities.selected(sourceTB === this._toggleActivities);
137
- this._toggleEdges.selected(sourceTB === this._toggleEdges);
138
- this._toggleSubgraphs.selected(sourceTB === this._toggleSubgraphs);
139
- switch (sourceTB) {
140
- case this._toggleGraph:
141
- this._view.active(0);
142
- break;
143
- case this._toggleActivities:
144
- this._view.active(1);
145
- break;
146
- case this._toggleEdges:
147
- this._view.active(2);
148
- break;
149
- case this._toggleSubgraphs:
150
- this._view.active(3);
151
- break;
152
- }
153
- this.render(w => {
154
- });
155
- }
156
-
157
- private _prevHashSum;
158
- private _prevScopeGraph: ScopeGraph;
159
- fetchScopeGraph(): Promise<ScopeGraph> {
160
- const hash = hashSum({
161
- baseUrl: this.baseUrl(),
162
- wuid: this.wuid(),
163
- graphID: this.graphID(),
164
- subgraphID: this.subgraphID()
165
- });
166
- if (!this._prevScopeGraph || this._prevHashSum !== hash) {
167
- this.startProgress();
168
- this._prevHashSum = hash;
169
- this._gc.clear();
170
- const wu = Workunit.attach({ baseUrl: this.baseUrl() }, this.wuid());
171
- return wu.fetchGraphs().then(graphs => {
172
- for (const graph of graphs) {
173
- if (graph.Name === this.graphID()) {
174
- this.finishProgress();
175
- return graph.fetchScopeGraph(this.subgraphID());
176
- }
177
- }
178
- }).then(scopeGraph => {
179
- this._prevScopeGraph = scopeGraph;
180
- return this._prevScopeGraph;
181
- });
182
- }
183
- return Promise.resolve(this._prevScopeGraph);
184
- }
185
-
186
- enter(domNode, _element) {
187
- super.enter(domNode, _element);
188
- }
189
-
190
- update(domNode, element) {
191
- super.update(domNode, element);
192
- }
193
-
194
- exit(domNode, element) {
195
- super.exit(domNode, element);
196
- }
197
-
198
- loadGraph() {
199
- this._gc.disabled(this._legend.disabled());
200
- this._graph
201
- .data(this._gc.graphData(), true)
202
- ;
203
- {
204
- const { columns, data } = this._gc.activityData();
205
- this._activities
206
- .columns(columns)
207
- .data(data)
208
- ;
209
- }
210
- {
211
- const { columns, data } = this._gc.edgeData();
212
- this._edges
213
- .columns(columns)
214
- .data(data)
215
- ;
216
- }
217
- {
218
- const { columns, data } = this._gc.subgraphData();
219
- this._subgraphs
220
- .columns(columns)
221
- .data(data)
222
- ;
223
- }
224
- }
225
-
226
- render(callback?: (w: Widget) => void): this {
227
- if (this.wuid() && this.graphID()) {
228
- this.fetchScopeGraph().then(scopedGraph => {
229
- this._gc.set(scopedGraph);
230
- this._legend.data(this._gc.calcLegend());
231
- this.loadGraph();
232
- super.render(callback);
233
- });
234
- } else {
235
- super.render(callback);
236
- }
237
- return this;
238
- }
239
-
240
- selection(_?) {
241
- if (!arguments.length) return this._graph.selection();
242
- const item = this._gc.vertex(_) || this._gc.edge(_) || this._gc.subgraph(_);
243
- if (item) {
244
- this._graph.selection([item]);
245
- }
246
- return this;
247
- }
248
- }
249
- WUGraph.prototype._class += " eclwatch_WUGraph";
250
-
251
- export interface WUGraph {
252
- baseUrl(): string;
253
- baseUrl(_: string): this;
254
- wuid(): string;
255
- wuid(_: string): this;
256
- graphID(): string;
257
- graphID(_: string): this;
258
- subgraphID(): string;
259
- subgraphID(_: string): this;
260
- }
261
-
262
- WUGraph.prototype.publish("baseUrl", "", "string", "HPCC Platform Base URL");
263
- WUGraph.prototype.publish("wuid", "", "string", "Workunit ID");
264
- WUGraph.prototype.publish("graphID", "", "string", "Graph ID");
265
- WUGraph.prototype.publish("subgraphID", "", "string", "Subgraph ID");
1
+ import { Button, Spacer, ToggleButton, Widget } from "@hpcc-js/common";
2
+ import { ScopeGraph, Workunit } from "@hpcc-js/comms";
3
+ import { Table } from "@hpcc-js/dgrid";
4
+ import { Graph as GraphWidget, Subgraph, Vertex } from "@hpcc-js/graph";
5
+ import { Carousel, ChartPanel } from "@hpcc-js/layout";
6
+ import { hashSum } from "@hpcc-js/util";
7
+ import { WUGraphLegend } from "./WUGraphLegend";
8
+ import { WUScopeController } from "./WUScopeController";
9
+
10
+ import "../src/WUGraph.css";
11
+
12
+ export class WUGraph extends ChartPanel {
13
+
14
+ private _partialAll = new Button().faChar("fa-window-restore").tooltip("Partial All")
15
+ .on("click", () => {
16
+ this.stateClick(this._partialAll);
17
+ });
18
+
19
+ private _maxAll = new Button().faChar("fa-window-maximize").tooltip("Max All")
20
+ .on("click", () => {
21
+ this.stateClick(this._maxAll);
22
+ });
23
+
24
+ private _toggleGraph = new ToggleButton().faChar("fa-chain").tooltip("Graph")
25
+ .selected(true)
26
+ .on("click", () => {
27
+ this.viewClick(this._toggleGraph);
28
+ });
29
+
30
+ private _toggleActivities = new ToggleButton().faChar("fa-table").tooltip("Activitiies")
31
+ .selected(false)
32
+ .on("click", () => {
33
+ this.viewClick(this._toggleActivities);
34
+ });
35
+
36
+ private _toggleEdges = new ToggleButton().faChar("fa-table").tooltip("Edges")
37
+ .selected(false)
38
+ .on("click", () => {
39
+ this.viewClick(this._toggleEdges);
40
+ });
41
+
42
+ private _toggleSubgraphs = new ToggleButton().faChar("fa-table").tooltip("Subgraphs")
43
+ .selected(false)
44
+ .on("click", () => {
45
+ this.viewClick(this._toggleSubgraphs);
46
+ });
47
+
48
+ protected _graph = new GraphWidget()
49
+ .layout("Hierarchy")
50
+ .applyScaleOnLayout(true)
51
+ .showToolbar(false)
52
+ .allowDragging(false)
53
+ ;
54
+
55
+ private _activities = new Table()
56
+ .pagination(false)
57
+ ;
58
+
59
+ private _edges = new Table()
60
+ .pagination(false)
61
+ ;
62
+
63
+ private _subgraphs = new Table()
64
+ .pagination(false)
65
+ ;
66
+
67
+ protected _legend = new WUGraphLegend(this)
68
+ .on("click", kind => {
69
+ this.render();
70
+ })
71
+ .on("mouseover", kind => {
72
+ const verticesMap: { [id: string]: boolean } = {};
73
+ for (const vertex of this._gc.vertices(kind)) {
74
+ verticesMap[vertex.id()] = true;
75
+ }
76
+ this._graph.highlightVerticies(verticesMap);
77
+ })
78
+ .on("mouseout", kind => {
79
+ this._graph.highlightVerticies();
80
+ })
81
+ ;
82
+
83
+ protected _view = new Carousel().widgets([this._graph, this._activities, this._edges, this._subgraphs]);
84
+
85
+ protected _gc = new WUScopeController();
86
+
87
+ constructor() {
88
+ super();
89
+ this.topOverlay(false);
90
+ this.widget(this._view);
91
+ const buttons: Widget[] = [
92
+ this._toggleGraph,
93
+ this._toggleActivities,
94
+ this._toggleEdges,
95
+ this._toggleSubgraphs,
96
+ new Spacer(),
97
+ this._partialAll,
98
+ this._maxAll,
99
+ new Spacer(),
100
+ ...this._graph.iconBarButtons(),
101
+ new Spacer()];
102
+ this.buttons(buttons.concat(this.buttons()));
103
+ this._gc.minClick = (sg: Subgraph) => {
104
+ this.loadGraph();
105
+ this._graph.render(w => {
106
+ this._graph
107
+ .selection([sg])
108
+ .centerOnItem(sg)
109
+ ;
110
+ });
111
+ };
112
+
113
+ this._graph.tooltipHTML((v: Vertex) => {
114
+ return this._gc.calcGraphTooltip(v);
115
+ });
116
+ }
117
+
118
+ stateClick(sourceB: Button) {
119
+ switch (sourceB) {
120
+ case this._partialAll:
121
+ this._graph.data().subgraphs.forEach((sg: Subgraph) => {
122
+ sg.minState("partial");
123
+ });
124
+ break;
125
+ case this._maxAll:
126
+ this._graph.data().subgraphs.forEach((sg: Subgraph) => {
127
+ sg.minState("normal");
128
+ });
129
+ break;
130
+ }
131
+ this.render();
132
+ }
133
+
134
+ viewClick(sourceTB: ToggleButton) {
135
+ this._toggleGraph.selected(sourceTB === this._toggleGraph);
136
+ this._toggleActivities.selected(sourceTB === this._toggleActivities);
137
+ this._toggleEdges.selected(sourceTB === this._toggleEdges);
138
+ this._toggleSubgraphs.selected(sourceTB === this._toggleSubgraphs);
139
+ switch (sourceTB) {
140
+ case this._toggleGraph:
141
+ this._view.active(0);
142
+ break;
143
+ case this._toggleActivities:
144
+ this._view.active(1);
145
+ break;
146
+ case this._toggleEdges:
147
+ this._view.active(2);
148
+ break;
149
+ case this._toggleSubgraphs:
150
+ this._view.active(3);
151
+ break;
152
+ }
153
+ this.render(w => {
154
+ });
155
+ }
156
+
157
+ private _prevHashSum;
158
+ private _prevScopeGraph: ScopeGraph;
159
+ fetchScopeGraph(): Promise<ScopeGraph> {
160
+ const hash = hashSum({
161
+ baseUrl: this.baseUrl(),
162
+ wuid: this.wuid(),
163
+ graphID: this.graphID(),
164
+ subgraphID: this.subgraphID()
165
+ });
166
+ if (!this._prevScopeGraph || this._prevHashSum !== hash) {
167
+ this.startProgress();
168
+ this._prevHashSum = hash;
169
+ this._gc.clear();
170
+ const wu = Workunit.attach({ baseUrl: this.baseUrl() }, this.wuid());
171
+ return wu.fetchGraphs().then(graphs => {
172
+ for (const graph of graphs) {
173
+ if (graph.Name === this.graphID()) {
174
+ this.finishProgress();
175
+ return graph.fetchScopeGraph(this.subgraphID());
176
+ }
177
+ }
178
+ }).then(scopeGraph => {
179
+ this._prevScopeGraph = scopeGraph;
180
+ return this._prevScopeGraph;
181
+ });
182
+ }
183
+ return Promise.resolve(this._prevScopeGraph);
184
+ }
185
+
186
+ enter(domNode, _element) {
187
+ super.enter(domNode, _element);
188
+ }
189
+
190
+ update(domNode, element) {
191
+ super.update(domNode, element);
192
+ }
193
+
194
+ exit(domNode, element) {
195
+ super.exit(domNode, element);
196
+ }
197
+
198
+ loadGraph() {
199
+ this._gc.disabled(this._legend.disabled());
200
+ this._graph
201
+ .data(this._gc.graphData(), true)
202
+ ;
203
+ {
204
+ const { columns, data } = this._gc.activityData();
205
+ this._activities
206
+ .columns(columns)
207
+ .data(data)
208
+ ;
209
+ }
210
+ {
211
+ const { columns, data } = this._gc.edgeData();
212
+ this._edges
213
+ .columns(columns)
214
+ .data(data)
215
+ ;
216
+ }
217
+ {
218
+ const { columns, data } = this._gc.subgraphData();
219
+ this._subgraphs
220
+ .columns(columns)
221
+ .data(data)
222
+ ;
223
+ }
224
+ }
225
+
226
+ render(callback?: (w: Widget) => void): this {
227
+ if (this.wuid() && this.graphID()) {
228
+ this.fetchScopeGraph().then(scopedGraph => {
229
+ this._gc.set(scopedGraph);
230
+ this._legend.data(this._gc.calcLegend());
231
+ this.loadGraph();
232
+ super.render(callback);
233
+ });
234
+ } else {
235
+ super.render(callback);
236
+ }
237
+ return this;
238
+ }
239
+
240
+ selection(_?) {
241
+ if (!arguments.length) return this._graph.selection();
242
+ const item = this._gc.vertex(_) || this._gc.edge(_) || this._gc.subgraph(_);
243
+ if (item) {
244
+ this._graph.selection([item]);
245
+ }
246
+ return this;
247
+ }
248
+ }
249
+ WUGraph.prototype._class += " eclwatch_WUGraph";
250
+
251
+ export interface WUGraph {
252
+ baseUrl(): string;
253
+ baseUrl(_: string): this;
254
+ wuid(): string;
255
+ wuid(_: string): this;
256
+ graphID(): string;
257
+ graphID(_: string): this;
258
+ subgraphID(): string;
259
+ subgraphID(_: string): this;
260
+ }
261
+
262
+ WUGraph.prototype.publish("baseUrl", "", "string", "HPCC Platform Base URL");
263
+ WUGraph.prototype.publish("wuid", "", "string", "Workunit ID");
264
+ WUGraph.prototype.publish("graphID", "", "string", "Graph ID");
265
+ WUGraph.prototype.publish("subgraphID", "", "string", "Subgraph ID");
@@ -1,7 +1,7 @@
1
- .eclwatch_WUGraphLegend .graph_Vertex {
2
- cursor: auto;
3
- }
4
-
5
- .eclwatch_WUGraphLegend .graph_Vertex .common_Icon {
6
- cursor: pointer;
7
- }
1
+ .eclwatch_WUGraphLegend .graph_Vertex {
2
+ cursor: auto;
3
+ }
4
+
5
+ .eclwatch_WUGraphLegend .graph_Vertex .common_Icon {
6
+ cursor: pointer;
7
+ }