@hpcc-js/eclwatch 2.77.6 → 2.77.7
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/LICENSE +43 -43
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +12 -12
- package/src/ECLArchiveViewer.ts +160 -160
- package/src/WUGraph.css +40 -40
- package/src/WUGraph.ts +265 -265
- package/src/WUGraphLegend.css +7 -7
- package/src/WUGraphLegend.ts +126 -126
- package/src/WUResult.ts +111 -111
- package/src/WUResultStore.ts +202 -202
- package/src/WUScopeController.ts +548 -548
- package/src/WUStatus.ts +206 -206
- package/src/WUTimeline.ts +122 -122
- package/src/__package__.ts +3 -3
- package/src/index.ts +7 -7
package/src/WUResultStore.ts
CHANGED
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
import { Exception, ResultFilter, Result, XSDSchema, XSDXMLNode } from "@hpcc-js/comms";
|
|
2
|
-
import { ColumnType, Deferred, domConstruct, QueryResults, RowFormatter } from "@hpcc-js/dgrid";
|
|
3
|
-
|
|
4
|
-
function entitiesEncode(str) {
|
|
5
|
-
return String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function safeEncode(item) {
|
|
9
|
-
switch (Object.prototype.toString.call(item)) {
|
|
10
|
-
case "[object Undefined]":
|
|
11
|
-
case "[object Boolean]":
|
|
12
|
-
case "[object Number]":
|
|
13
|
-
return item;
|
|
14
|
-
case "[object String]":
|
|
15
|
-
return entitiesEncode(item);
|
|
16
|
-
default:
|
|
17
|
-
console.warn("Unknown cell type: " + Object.prototype.toString.call(item));
|
|
18
|
-
}
|
|
19
|
-
return item;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class Store {
|
|
23
|
-
protected wuResult: Result;
|
|
24
|
-
protected schema: XSDSchema;
|
|
25
|
-
protected _columns: any[];
|
|
26
|
-
protected _cache: { [key: string]: Promise<{ totalLength: number, data: any[] }> } = {};
|
|
27
|
-
private rowFormatter: RowFormatter;
|
|
28
|
-
protected _filter: ResultFilter = {};
|
|
29
|
-
private onError?: (msg: string) => void;
|
|
30
|
-
|
|
31
|
-
constructor(wuResult: Result, schema: XSDSchema, renderHtml: boolean, filter: ResultFilter = {}, onError?: (msg: string) => void) {
|
|
32
|
-
this.wuResult = wuResult;
|
|
33
|
-
this.schema = schema;
|
|
34
|
-
this._columns = this.schema2Columns(this.schema.root);
|
|
35
|
-
this.rowFormatter = new RowFormatter(this._columns, renderHtml);
|
|
36
|
-
this._filter = filter;
|
|
37
|
-
this.onError = onError;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
columns() {
|
|
41
|
-
return this._columns;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
schema2Columns(parentNode: XSDXMLNode, prefix: string = ""): ColumnType[] {
|
|
45
|
-
if (!parentNode) return [];
|
|
46
|
-
return parentNode.children().filter(node => node.name.indexOf("__hidden", node.name.length - "__hidden".length) === -1).map((node, idx) => {
|
|
47
|
-
const label = node.name;
|
|
48
|
-
const keyed = node.attrs["hpcc:keyed"];
|
|
49
|
-
const column: ColumnType = {
|
|
50
|
-
field: prefix + label,
|
|
51
|
-
leafID: label,
|
|
52
|
-
idx,
|
|
53
|
-
label: label + (keyed ? " (i)" : ""),
|
|
54
|
-
className: "resultGridCell",
|
|
55
|
-
sortable: false,
|
|
56
|
-
width: keyed ? 16 : 0,
|
|
57
|
-
isSet: node.isSet
|
|
58
|
-
};
|
|
59
|
-
const children = this.schema2Columns(node, prefix + label + "_");
|
|
60
|
-
if (children.length) {
|
|
61
|
-
column.width += 10 + children.reduce((prev: number, childNode: ColumnType) => {
|
|
62
|
-
return prev + childNode.width!;
|
|
63
|
-
}, 0);
|
|
64
|
-
column.children = children;
|
|
65
|
-
} else {
|
|
66
|
-
column.width += node.charWidth() * 9;
|
|
67
|
-
column.formatter = (cell, row) => {
|
|
68
|
-
switch (typeof cell) {
|
|
69
|
-
case "string":
|
|
70
|
-
return {
|
|
71
|
-
html: cell.replace(/\t/g, " ").trim()
|
|
72
|
-
};
|
|
73
|
-
case "undefined":
|
|
74
|
-
return "";
|
|
75
|
-
}
|
|
76
|
-
return cell;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
return column;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
isChildDataset(cell) {
|
|
84
|
-
if (Object.prototype.toString.call(cell) !== "[object Object]") {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
let propCount = 0;
|
|
88
|
-
let firstPropType = null;
|
|
89
|
-
for (const key in cell) {
|
|
90
|
-
if (!firstPropType) {
|
|
91
|
-
firstPropType = Object.prototype.toString.call(cell[key]);
|
|
92
|
-
}
|
|
93
|
-
propCount++;
|
|
94
|
-
}
|
|
95
|
-
return propCount === 1 && firstPropType === "[object Array]";
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
rowToTable(cell, __row, node) {
|
|
99
|
-
if (this.isChildDataset(cell)) { // Don't display "Row" as a header ---
|
|
100
|
-
for (const key in cell) {
|
|
101
|
-
this.rowToTable(cell[key], __row, node);
|
|
102
|
-
}
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const table = domConstruct.create("table", { border: 1, cellspacing: 0, width: "100%" }, node);
|
|
107
|
-
switch (Object.prototype.toString.call(cell)) {
|
|
108
|
-
case "[object Object]":
|
|
109
|
-
let tr = domConstruct.create("tr", null, table);
|
|
110
|
-
for (const key in cell) {
|
|
111
|
-
domConstruct.create("th", { innerHTML: safeEncode(key) }, tr);
|
|
112
|
-
}
|
|
113
|
-
tr = domConstruct.create("tr", null, table);
|
|
114
|
-
for (const key in cell) {
|
|
115
|
-
switch (Object.prototype.toString.call(cell[key])) {
|
|
116
|
-
case "[object Object]":
|
|
117
|
-
case "[object Array]":
|
|
118
|
-
this.rowToTable(cell[key], __row, node);
|
|
119
|
-
break;
|
|
120
|
-
default:
|
|
121
|
-
domConstruct.create("td", { innerHTML: safeEncode(cell[key]) }, tr);
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
break;
|
|
126
|
-
case "[object Array]":
|
|
127
|
-
for (let i = 0; i < cell.length; ++i) {
|
|
128
|
-
switch (Object.prototype.toString.call(cell[i])) {
|
|
129
|
-
case "[object Boolean]":
|
|
130
|
-
case "[object Number]":
|
|
131
|
-
case "[object String]":
|
|
132
|
-
// Item in Scalar ---
|
|
133
|
-
const tr1 = domConstruct.create("tr", null, table);
|
|
134
|
-
domConstruct.create("td", { innerHTML: safeEncode(cell[i]) }, tr1);
|
|
135
|
-
break;
|
|
136
|
-
default:
|
|
137
|
-
// Child Dataset ---
|
|
138
|
-
if (i === 0) {
|
|
139
|
-
const tr2 = domConstruct.create("tr", null, table);
|
|
140
|
-
for (const key in cell[i]) {
|
|
141
|
-
domConstruct.create("th", { innerHTML: safeEncode(key) }, tr2);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
domConstruct.create("tr", null, table);
|
|
145
|
-
for (const key in cell[i]) {
|
|
146
|
-
if (cell[i][key]) {
|
|
147
|
-
if (Object.prototype.toString.call(cell[i][key]) === "[object Object]" || Object.prototype.toString.call(cell[i][key]) === "[object Array]") {
|
|
148
|
-
const td = domConstruct.create("td", null, tr1);
|
|
149
|
-
this.rowToTable(cell[i][key], cell[i], td);
|
|
150
|
-
} else if (key.indexOf("__html", key.length - "__html".length) !== -1) {
|
|
151
|
-
domConstruct.create("td", { innerHTML: cell[i][key] }, tr1);
|
|
152
|
-
} else if (key.indexOf("__javascript", key.length - "__javascript".length) !== -1) {
|
|
153
|
-
/*const td = */ domConstruct.create("td", null, tr1);
|
|
154
|
-
// this.injectJavascript(cell[i][key], cell[i], td);
|
|
155
|
-
} else {
|
|
156
|
-
const val = cell[i][key];
|
|
157
|
-
domConstruct.create("td", { innerHTML: safeEncode(val) }, tr1);
|
|
158
|
-
}
|
|
159
|
-
} else {
|
|
160
|
-
domConstruct.create("td", { innerHTML: "" }, tr1);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
getIdentity(row) {
|
|
170
|
-
return row.__hpcc_id;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
_request(start, end): Promise<{ totalLength: number, data: any[] }> {
|
|
174
|
-
if (!this.wuResult) return Promise.resolve({ totalLength: 0, data: [] });
|
|
175
|
-
const cacheKey = `${start}->${end}`;
|
|
176
|
-
if (this._cache[cacheKey]) return this._cache[cacheKey];
|
|
177
|
-
const retVal = this.wuResult.fetchRows(start, end - start, false, this._filter).then((rows: any[]) => {
|
|
178
|
-
return {
|
|
179
|
-
totalLength: this.wuResult.Total,
|
|
180
|
-
data: rows.map((row, idx) => {
|
|
181
|
-
const formattedRow: any = this.rowFormatter.format(row);
|
|
182
|
-
formattedRow.__hpcc_id = start + idx;
|
|
183
|
-
formattedRow.__hpcc_orig = row;
|
|
184
|
-
return formattedRow;
|
|
185
|
-
})
|
|
186
|
-
};
|
|
187
|
-
}).catch((err: Exception) => {
|
|
188
|
-
this.onError(err.Message || "An exception has occurred");
|
|
189
|
-
return { totalLength: 0, data: [] };
|
|
190
|
-
});
|
|
191
|
-
this._cache[cacheKey] = retVal;
|
|
192
|
-
return retVal;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
fetchRange(options): Promise<any[]> {
|
|
196
|
-
const retVal = new Deferred();
|
|
197
|
-
this._request(options.start, options.end).then(response => retVal.resolve(response));
|
|
198
|
-
return new QueryResults(retVal.then(response => response.data), {
|
|
199
|
-
totalLength: retVal.then(response => response.totalLength)
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
1
|
+
import { Exception, ResultFilter, Result, XSDSchema, XSDXMLNode } from "@hpcc-js/comms";
|
|
2
|
+
import { ColumnType, Deferred, domConstruct, QueryResults, RowFormatter } from "@hpcc-js/dgrid";
|
|
3
|
+
|
|
4
|
+
function entitiesEncode(str) {
|
|
5
|
+
return String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function safeEncode(item) {
|
|
9
|
+
switch (Object.prototype.toString.call(item)) {
|
|
10
|
+
case "[object Undefined]":
|
|
11
|
+
case "[object Boolean]":
|
|
12
|
+
case "[object Number]":
|
|
13
|
+
return item;
|
|
14
|
+
case "[object String]":
|
|
15
|
+
return entitiesEncode(item);
|
|
16
|
+
default:
|
|
17
|
+
console.warn("Unknown cell type: " + Object.prototype.toString.call(item));
|
|
18
|
+
}
|
|
19
|
+
return item;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class Store {
|
|
23
|
+
protected wuResult: Result;
|
|
24
|
+
protected schema: XSDSchema;
|
|
25
|
+
protected _columns: any[];
|
|
26
|
+
protected _cache: { [key: string]: Promise<{ totalLength: number, data: any[] }> } = {};
|
|
27
|
+
private rowFormatter: RowFormatter;
|
|
28
|
+
protected _filter: ResultFilter = {};
|
|
29
|
+
private onError?: (msg: string) => void;
|
|
30
|
+
|
|
31
|
+
constructor(wuResult: Result, schema: XSDSchema, renderHtml: boolean, filter: ResultFilter = {}, onError?: (msg: string) => void) {
|
|
32
|
+
this.wuResult = wuResult;
|
|
33
|
+
this.schema = schema;
|
|
34
|
+
this._columns = this.schema2Columns(this.schema.root);
|
|
35
|
+
this.rowFormatter = new RowFormatter(this._columns, renderHtml);
|
|
36
|
+
this._filter = filter;
|
|
37
|
+
this.onError = onError;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
columns() {
|
|
41
|
+
return this._columns;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
schema2Columns(parentNode: XSDXMLNode, prefix: string = ""): ColumnType[] {
|
|
45
|
+
if (!parentNode) return [];
|
|
46
|
+
return parentNode.children().filter(node => node.name.indexOf("__hidden", node.name.length - "__hidden".length) === -1).map((node, idx) => {
|
|
47
|
+
const label = node.name;
|
|
48
|
+
const keyed = node.attrs["hpcc:keyed"];
|
|
49
|
+
const column: ColumnType = {
|
|
50
|
+
field: prefix + label,
|
|
51
|
+
leafID: label,
|
|
52
|
+
idx,
|
|
53
|
+
label: label + (keyed ? " (i)" : ""),
|
|
54
|
+
className: "resultGridCell",
|
|
55
|
+
sortable: false,
|
|
56
|
+
width: keyed ? 16 : 0,
|
|
57
|
+
isSet: node.isSet
|
|
58
|
+
};
|
|
59
|
+
const children = this.schema2Columns(node, prefix + label + "_");
|
|
60
|
+
if (children.length) {
|
|
61
|
+
column.width += 10 + children.reduce((prev: number, childNode: ColumnType) => {
|
|
62
|
+
return prev + childNode.width!;
|
|
63
|
+
}, 0);
|
|
64
|
+
column.children = children;
|
|
65
|
+
} else {
|
|
66
|
+
column.width += node.charWidth() * 9;
|
|
67
|
+
column.formatter = (cell, row) => {
|
|
68
|
+
switch (typeof cell) {
|
|
69
|
+
case "string":
|
|
70
|
+
return {
|
|
71
|
+
html: cell.replace(/\t/g, " ").trim()
|
|
72
|
+
};
|
|
73
|
+
case "undefined":
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
return cell;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return column;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
isChildDataset(cell) {
|
|
84
|
+
if (Object.prototype.toString.call(cell) !== "[object Object]") {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
let propCount = 0;
|
|
88
|
+
let firstPropType = null;
|
|
89
|
+
for (const key in cell) {
|
|
90
|
+
if (!firstPropType) {
|
|
91
|
+
firstPropType = Object.prototype.toString.call(cell[key]);
|
|
92
|
+
}
|
|
93
|
+
propCount++;
|
|
94
|
+
}
|
|
95
|
+
return propCount === 1 && firstPropType === "[object Array]";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
rowToTable(cell, __row, node) {
|
|
99
|
+
if (this.isChildDataset(cell)) { // Don't display "Row" as a header ---
|
|
100
|
+
for (const key in cell) {
|
|
101
|
+
this.rowToTable(cell[key], __row, node);
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const table = domConstruct.create("table", { border: 1, cellspacing: 0, width: "100%" }, node);
|
|
107
|
+
switch (Object.prototype.toString.call(cell)) {
|
|
108
|
+
case "[object Object]":
|
|
109
|
+
let tr = domConstruct.create("tr", null, table);
|
|
110
|
+
for (const key in cell) {
|
|
111
|
+
domConstruct.create("th", { innerHTML: safeEncode(key) }, tr);
|
|
112
|
+
}
|
|
113
|
+
tr = domConstruct.create("tr", null, table);
|
|
114
|
+
for (const key in cell) {
|
|
115
|
+
switch (Object.prototype.toString.call(cell[key])) {
|
|
116
|
+
case "[object Object]":
|
|
117
|
+
case "[object Array]":
|
|
118
|
+
this.rowToTable(cell[key], __row, node);
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
domConstruct.create("td", { innerHTML: safeEncode(cell[key]) }, tr);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
case "[object Array]":
|
|
127
|
+
for (let i = 0; i < cell.length; ++i) {
|
|
128
|
+
switch (Object.prototype.toString.call(cell[i])) {
|
|
129
|
+
case "[object Boolean]":
|
|
130
|
+
case "[object Number]":
|
|
131
|
+
case "[object String]":
|
|
132
|
+
// Item in Scalar ---
|
|
133
|
+
const tr1 = domConstruct.create("tr", null, table);
|
|
134
|
+
domConstruct.create("td", { innerHTML: safeEncode(cell[i]) }, tr1);
|
|
135
|
+
break;
|
|
136
|
+
default:
|
|
137
|
+
// Child Dataset ---
|
|
138
|
+
if (i === 0) {
|
|
139
|
+
const tr2 = domConstruct.create("tr", null, table);
|
|
140
|
+
for (const key in cell[i]) {
|
|
141
|
+
domConstruct.create("th", { innerHTML: safeEncode(key) }, tr2);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
domConstruct.create("tr", null, table);
|
|
145
|
+
for (const key in cell[i]) {
|
|
146
|
+
if (cell[i][key]) {
|
|
147
|
+
if (Object.prototype.toString.call(cell[i][key]) === "[object Object]" || Object.prototype.toString.call(cell[i][key]) === "[object Array]") {
|
|
148
|
+
const td = domConstruct.create("td", null, tr1);
|
|
149
|
+
this.rowToTable(cell[i][key], cell[i], td);
|
|
150
|
+
} else if (key.indexOf("__html", key.length - "__html".length) !== -1) {
|
|
151
|
+
domConstruct.create("td", { innerHTML: cell[i][key] }, tr1);
|
|
152
|
+
} else if (key.indexOf("__javascript", key.length - "__javascript".length) !== -1) {
|
|
153
|
+
/*const td = */ domConstruct.create("td", null, tr1);
|
|
154
|
+
// this.injectJavascript(cell[i][key], cell[i], td);
|
|
155
|
+
} else {
|
|
156
|
+
const val = cell[i][key];
|
|
157
|
+
domConstruct.create("td", { innerHTML: safeEncode(val) }, tr1);
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
domConstruct.create("td", { innerHTML: "" }, tr1);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
getIdentity(row) {
|
|
170
|
+
return row.__hpcc_id;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_request(start, end): Promise<{ totalLength: number, data: any[] }> {
|
|
174
|
+
if (!this.wuResult) return Promise.resolve({ totalLength: 0, data: [] });
|
|
175
|
+
const cacheKey = `${start}->${end}`;
|
|
176
|
+
if (this._cache[cacheKey]) return this._cache[cacheKey];
|
|
177
|
+
const retVal = this.wuResult.fetchRows(start, end - start, false, this._filter).then((rows: any[]) => {
|
|
178
|
+
return {
|
|
179
|
+
totalLength: this.wuResult.Total,
|
|
180
|
+
data: rows.map((row, idx) => {
|
|
181
|
+
const formattedRow: any = this.rowFormatter.format(row);
|
|
182
|
+
formattedRow.__hpcc_id = start + idx;
|
|
183
|
+
formattedRow.__hpcc_orig = row;
|
|
184
|
+
return formattedRow;
|
|
185
|
+
})
|
|
186
|
+
};
|
|
187
|
+
}).catch((err: Exception) => {
|
|
188
|
+
this.onError(err.Message || "An exception has occurred");
|
|
189
|
+
return { totalLength: 0, data: [] };
|
|
190
|
+
});
|
|
191
|
+
this._cache[cacheKey] = retVal;
|
|
192
|
+
return retVal;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
fetchRange(options): Promise<any[]> {
|
|
196
|
+
const retVal = new Deferred();
|
|
197
|
+
this._request(options.start, options.end).then(response => retVal.resolve(response));
|
|
198
|
+
return new QueryResults(retVal.then(response => response.data), {
|
|
199
|
+
totalLength: retVal.then(response => response.totalLength)
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|