@hpcc-js/marshaller 2.28.6 → 2.28.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 +19 -19
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js +17 -17
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +16 -16
- package/src/__package__.ts +3 -3
- package/src/dashy.css +239 -239
- package/src/dashy.ts +521 -521
- package/src/ddl1/DDLApi.ts +229 -229
- package/src/ddl1/FlyoutButton.ts +120 -120
- package/src/ddl1/Graph.ts +93 -93
- package/src/ddl1/HTML.ts +77 -77
- package/src/ddl1/HipieDDL.ts +2437 -2437
- package/src/ddl1/HipieDDLMixin.ts +380 -380
- package/src/ddl1/Tabbed.ts +91 -91
- package/src/ddl1/TargetMarshaller.ts +57 -57
- package/src/ddl2/PopupManager.ts +89 -89
- package/src/ddl2/activities/activity.ts +431 -431
- package/src/ddl2/activities/databomb.ts +237 -237
- package/src/ddl2/activities/datasource.ts +52 -52
- package/src/ddl2/activities/dspicker.ts +106 -106
- package/src/ddl2/activities/filter.ts +542 -542
- package/src/ddl2/activities/form.ts +153 -153
- package/src/ddl2/activities/groupby.ts +439 -439
- package/src/ddl2/activities/hipiepipeline.ts +114 -114
- package/src/ddl2/activities/limit.ts +49 -49
- package/src/ddl2/activities/logicalfile.ts +62 -62
- package/src/ddl2/activities/nullview.ts +12 -12
- package/src/ddl2/activities/project.ts +764 -764
- package/src/ddl2/activities/rest.ts +568 -568
- package/src/ddl2/activities/roxie.ts +490 -490
- package/src/ddl2/activities/sampledata.json +16264 -16264
- package/src/ddl2/activities/sort.ts +176 -176
- package/src/ddl2/activities/wuresult.ts +395 -395
- package/src/ddl2/dashboard.css +13 -13
- package/src/ddl2/dashboard.ts +330 -330
- package/src/ddl2/dashboardDockPanel.ts +123 -123
- package/src/ddl2/dashboardGrid.ts +202 -202
- package/src/ddl2/ddl.ts +410 -410
- package/src/ddl2/ddleditor.ts +60 -60
- package/src/ddl2/dsTable.ts +238 -238
- package/src/ddl2/dvTable.ts +31 -31
- package/src/ddl2/graphadapter.ts +297 -297
- package/src/ddl2/javascriptadapter.ts +354 -354
- package/src/ddl2/model/element.ts +398 -398
- package/src/ddl2/model/visualization.ts +351 -351
- package/src/ddl2/model/vizChartPanel.ts +149 -149
- package/src/ddl2/pipelinePanel.css +4 -4
- package/src/ddl2/pipelinePanel.ts +465 -465
- package/src/index.ts +26 -26
|
@@ -1,398 +1,398 @@
|
|
|
1
|
-
import { PropertyExt, publish, Widget } from "@hpcc-js/common";
|
|
2
|
-
import { IOptionsSend } from "@hpcc-js/comms";
|
|
3
|
-
import { DDL2 } from "@hpcc-js/ddl-shim";
|
|
4
|
-
import { find, hashSum, isArray } from "@hpcc-js/util";
|
|
5
|
-
import { Activity, IActivityError } from "../activities/activity";
|
|
6
|
-
import { emptyDatabomb } from "../activities/databomb";
|
|
7
|
-
import { DatasourceRefType } from "../activities/datasource";
|
|
8
|
-
import { HipiePipeline } from "../activities/hipiepipeline";
|
|
9
|
-
import { Mappings } from "../activities/project";
|
|
10
|
-
import { Visualization } from "./visualization";
|
|
11
|
-
import { VizChartPanel } from "./vizChartPanel";
|
|
12
|
-
|
|
13
|
-
export class State extends PropertyExt {
|
|
14
|
-
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
17
|
-
this.selection([]);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
set(_: Array<{ [key: string]: any }>): boolean {
|
|
21
|
-
const currSelHash = hashSum(this.selection());
|
|
22
|
-
const newSelHash = hashSum(_);
|
|
23
|
-
if (currSelHash !== newSelHash) {
|
|
24
|
-
this.selection(_);
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
removeInvalid(data: ReadonlyArray<object>): boolean {
|
|
31
|
-
const currSelection = this.selection();
|
|
32
|
-
const newSelection: object[] = [];
|
|
33
|
-
for (const selRow of currSelection) {
|
|
34
|
-
if (find(data, (row: { [key: string]: any }, index): boolean => {
|
|
35
|
-
for (const column in selRow) {
|
|
36
|
-
if (selRow[column] !== row[column]) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return true;
|
|
41
|
-
})) {
|
|
42
|
-
newSelection.push(selRow);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (newSelection.length !== currSelection.length) {
|
|
46
|
-
this.selection(newSelection);
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
State.prototype._class += " State";
|
|
53
|
-
export interface State {
|
|
54
|
-
selection(): Array<{ [key: string]: any }>;
|
|
55
|
-
selection(_: Array<{ [key: string]: any }>): this;
|
|
56
|
-
}
|
|
57
|
-
State.prototype.publish("selection", [], "array", "State");
|
|
58
|
-
|
|
59
|
-
let vizID = 0;
|
|
60
|
-
export class Element extends PropertyExt {
|
|
61
|
-
private _vizChartPanel: Visualization;
|
|
62
|
-
|
|
63
|
-
// @publishProxy("_MultiChartPanel")
|
|
64
|
-
// title: publish<this, string>;
|
|
65
|
-
@publish(null, "widget", "Data View")
|
|
66
|
-
hipiePipeline: publish<this, HipiePipeline>;
|
|
67
|
-
@publish(null, "widget", "Visualization")
|
|
68
|
-
_visualization: Visualization;
|
|
69
|
-
visualization(): Visualization;
|
|
70
|
-
visualization(_: Visualization): this;
|
|
71
|
-
visualization(_?: Visualization): Visualization | this {
|
|
72
|
-
if (!arguments.length) return this._visualization;
|
|
73
|
-
this._visualization = _;
|
|
74
|
-
this._visualization
|
|
75
|
-
.on("click", (_row: object | object[], col: string, sel: boolean, more?) => {
|
|
76
|
-
if (more && more.selection) {
|
|
77
|
-
this.selection(sel ? more.selection.map(r => r.__lparam || r) : []);
|
|
78
|
-
} else {
|
|
79
|
-
const row: any[] = isArray(_row) ? _row : [_row];
|
|
80
|
-
this.selection(sel ? row.map(r => r.__lparam || r) : []);
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
.on("vertex_click", (_row: object | object[], col: string, sel: boolean) => {
|
|
84
|
-
const row: any[] = isArray(_row) ? _row : [_row];
|
|
85
|
-
this.selection(sel ? row.map(r => r.__lparam || r) : []);
|
|
86
|
-
})
|
|
87
|
-
;
|
|
88
|
-
return this;
|
|
89
|
-
}
|
|
90
|
-
@publish(null, "widget", "State")
|
|
91
|
-
state: publish<this, State>;
|
|
92
|
-
|
|
93
|
-
constructor(private _ec: ElementContainer) {
|
|
94
|
-
super();
|
|
95
|
-
while (true) {
|
|
96
|
-
vizID++;
|
|
97
|
-
this._id = `e_${vizID}`;
|
|
98
|
-
if (!this._ec.elementExists(this._id)) {
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
const view = new HipiePipeline(this._ec, this._id);
|
|
103
|
-
this.hipiePipeline(view);
|
|
104
|
-
this._vizChartPanel = new Visualization(this._ec, this.hipiePipeline())
|
|
105
|
-
.id(`viz_${vizID}`)
|
|
106
|
-
.title(`Element ${vizID}`)
|
|
107
|
-
;
|
|
108
|
-
this._vizChartPanel.chartPanel().id(`cp_${vizID}`);
|
|
109
|
-
this.visualization(this._vizChartPanel);
|
|
110
|
-
this.state(new State());
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
id(): string;
|
|
114
|
-
id(_: string): this;
|
|
115
|
-
id(_?: string): string | this {
|
|
116
|
-
const retVal = super.id.apply(this, arguments);
|
|
117
|
-
if (arguments.length) {
|
|
118
|
-
this._vizChartPanel.id(_);
|
|
119
|
-
}
|
|
120
|
-
return retVal;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
chartType(): string {
|
|
124
|
-
return this._vizChartPanel.chartType();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
chartPanel(): VizChartPanel;
|
|
128
|
-
chartPanel(_: VizChartPanel): this;
|
|
129
|
-
chartPanel(_?: VizChartPanel): VizChartPanel | this {
|
|
130
|
-
if (!arguments.length) return this._vizChartPanel.chartPanel();
|
|
131
|
-
this._vizChartPanel.chartPanel(_);
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
chart(): Widget {
|
|
136
|
-
return this._vizChartPanel.chartPanel().widget();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
mappings(): Mappings;
|
|
140
|
-
mappings(_: Mappings): this;
|
|
141
|
-
mappings(_?: Mappings): Mappings | this {
|
|
142
|
-
if (!arguments.length) return this._vizChartPanel.mappings();
|
|
143
|
-
this._vizChartPanel.mappings(_);
|
|
144
|
-
return this;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
pipeline(activities: Activity[]): this {
|
|
148
|
-
this.hipiePipeline()
|
|
149
|
-
.activities(activities)
|
|
150
|
-
;
|
|
151
|
-
return this;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
updatedBy(): string[] {
|
|
155
|
-
const retVal = this.hipiePipeline().updatedBy();
|
|
156
|
-
if (this.visualization().secondaryDataviewID_exists()) {
|
|
157
|
-
retVal.push(this.visualization().secondaryDataviewID());
|
|
158
|
-
}
|
|
159
|
-
return retVal;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
dataProps(): PropertyExt {
|
|
163
|
-
return this.hipiePipeline();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
vizProps(): Widget {
|
|
167
|
-
return this.visualization().chartPanel();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
stateProps(): PropertyExt {
|
|
171
|
-
return this.state();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
private _errors: IElementError[] = [];
|
|
175
|
-
errors(): IElementError[] {
|
|
176
|
-
return this._errors;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
validate(): IElementError[] {
|
|
180
|
-
if (!this._initialized) {
|
|
181
|
-
return [];
|
|
182
|
-
}
|
|
183
|
-
this._errors = [];
|
|
184
|
-
const pipeline = this.hipiePipeline();
|
|
185
|
-
for (const activity of [...pipeline.activities(), this.mappings()]) {
|
|
186
|
-
for (const error of activity.validate()) {
|
|
187
|
-
this._errors.push({
|
|
188
|
-
elementID: this.id(),
|
|
189
|
-
...error
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return this._errors;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
private _initialized = false;
|
|
197
|
-
refresh(): Promise<void> {
|
|
198
|
-
const filters = this.hipiePipeline().filters().validFilters();
|
|
199
|
-
const desc: string[] = filters.map(f => f.createFilterDescription());
|
|
200
|
-
this.visualization().chartPanel().description(desc.join(", "));
|
|
201
|
-
return this.visualization().refresh().then(() => {
|
|
202
|
-
this._initialized = true;
|
|
203
|
-
const data = this.hipiePipeline().outData();
|
|
204
|
-
if (this.visualization().chartType() === "FieldForm") {
|
|
205
|
-
if (this.state().set([...data])) {
|
|
206
|
-
this.selectionChanged();
|
|
207
|
-
}
|
|
208
|
-
} else {
|
|
209
|
-
if (this.state().removeInvalid(data)) {
|
|
210
|
-
this.selectionChanged();
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Selection ---
|
|
217
|
-
selection(): object[];
|
|
218
|
-
selection(_: object[]): this;
|
|
219
|
-
selection(_?: object[]): object[] | this {
|
|
220
|
-
if (!arguments.length) return this.state().selection();
|
|
221
|
-
this.state().selection(_);
|
|
222
|
-
this.selectionChanged();
|
|
223
|
-
return this;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Events ---
|
|
227
|
-
selectionChanged() {
|
|
228
|
-
const promises: Array<Promise<void>> = [];
|
|
229
|
-
for (const filteredViz of this._ec.filteredBy(this.id())) {
|
|
230
|
-
promises.push(filteredViz.refresh());
|
|
231
|
-
}
|
|
232
|
-
Promise.all(promises).then(() => {
|
|
233
|
-
this._ec.vizStateChanged(this);
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
monitor(func: (id: string, newVal: any, oldVal: any, source: PropertyExt) => void): { remove: () => void; } {
|
|
238
|
-
return this.hipiePipeline().monitor(func);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
Element.prototype._class += " Viz";
|
|
242
|
-
|
|
243
|
-
export interface IPersist {
|
|
244
|
-
ddl: DDL2.Schema;
|
|
245
|
-
layout: any;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export interface IElementError extends IActivityError {
|
|
249
|
-
elementID: string;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export class ElementContainer extends PropertyExt {
|
|
253
|
-
|
|
254
|
-
private _nullElement;
|
|
255
|
-
|
|
256
|
-
private _datasources: DatasourceRefType[] = [emptyDatabomb];
|
|
257
|
-
private _elements: Element[] = [];
|
|
258
|
-
|
|
259
|
-
@publish(10, "number", "Number of samples")
|
|
260
|
-
samples: publish<this, number>;
|
|
261
|
-
@publish(100, "number", "Sample size")
|
|
262
|
-
sampleSize: publish<this, number>;
|
|
263
|
-
|
|
264
|
-
constructor() {
|
|
265
|
-
super();
|
|
266
|
-
this.clear();
|
|
267
|
-
this._nullElement = new Element(this);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
clear(eid?: string) {
|
|
271
|
-
this._datasources = eid === undefined ? [emptyDatabomb] : this._datasources;
|
|
272
|
-
this._elements = eid === undefined ? [] : this._elements.filter(d => d.id() !== eid);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
private _hookSend: IOptionsSend;
|
|
276
|
-
hookSend(): IOptionsSend;
|
|
277
|
-
hookSend(_: IOptionsSend): this;
|
|
278
|
-
hookSend(_?: IOptionsSend): IOptionsSend | this {
|
|
279
|
-
if (!arguments.length) return this._hookSend;
|
|
280
|
-
this._hookSend = _;
|
|
281
|
-
return this;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
datasources(): DatasourceRefType[];
|
|
285
|
-
datasources(_: DatasourceRefType[]): this;
|
|
286
|
-
datasources(_?: DatasourceRefType[]): DatasourceRefType[] | this {
|
|
287
|
-
if (!arguments.length) return this._datasources;
|
|
288
|
-
this._datasources = _;
|
|
289
|
-
return this;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
datasource(id): DatasourceRefType {
|
|
293
|
-
return this._datasources.filter(ds => ds.id() === id)[0];
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
appendDatasource(ds: DatasourceRefType): this {
|
|
297
|
-
this._datasources.push(ds);
|
|
298
|
-
return this;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
removeDatasource(ds: DatasourceRefType): this {
|
|
302
|
-
this._datasources = this._datasources.filter(row => row !== ds);
|
|
303
|
-
return this;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
elements(): Element[] {
|
|
307
|
-
return [...this._elements];
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
element(w: string | PropertyExt | VizChartPanel): Element {
|
|
311
|
-
let retVal: Element[];
|
|
312
|
-
if (typeof w === "string") {
|
|
313
|
-
retVal = this._elements.filter(viz => viz.id() === w);
|
|
314
|
-
} else if (w instanceof VizChartPanel) {
|
|
315
|
-
retVal = this._elements.filter(v => v.chartPanel() === w);
|
|
316
|
-
} else {
|
|
317
|
-
retVal = this._elements.filter(v => v.vizProps() === w);
|
|
318
|
-
}
|
|
319
|
-
if (retVal.length) {
|
|
320
|
-
return retVal[0];
|
|
321
|
-
}
|
|
322
|
-
return this._nullElement;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
elementExists(w: string | PropertyExt): boolean {
|
|
326
|
-
return this.element(w) !== this._nullElement;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
elementIDs() {
|
|
330
|
-
return this._elements.map(viz => viz.id());
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
append(element: Element): this {
|
|
334
|
-
this._elements.push(element);
|
|
335
|
-
return this;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
filteredBy(elemID: string): Element[] {
|
|
339
|
-
return this._elements.filter(otherViz => {
|
|
340
|
-
const filterIDs = otherViz.updatedBy();
|
|
341
|
-
return filterIDs.indexOf(elemID) >= 0;
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
views(): HipiePipeline[] {
|
|
346
|
-
return this._elements.map(viz => viz.hipiePipeline());
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
view(id: string): HipiePipeline | undefined {
|
|
350
|
-
return this.views().filter(view => view.id() === id)[0];
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
normalizePersist(seri: any): { [key: string]: { [key: string]: any } } {
|
|
354
|
-
const ret = {};
|
|
355
|
-
seri.__properties.content.map((n) => {
|
|
356
|
-
const _is_MegaChart = !!n.__properties.widget.__properties.chart;
|
|
357
|
-
const _cell = n;
|
|
358
|
-
const _panel = n.__properties.widget;
|
|
359
|
-
const _widget = _is_MegaChart ? n.__properties.widget.__properties.chart : n.__properties.widget.__properties.widget;
|
|
360
|
-
const _id = n.__properties.widget.__id ? n.__properties.widget.__id : n.__properties.widget.__properties.widget.__id;
|
|
361
|
-
ret[_id] = {
|
|
362
|
-
id: _id,
|
|
363
|
-
package: _widget.__class.split("_")[0],
|
|
364
|
-
object: _widget.__class.split("_")[1],
|
|
365
|
-
cell: _get_params(_cell, ["chart", "widget", "fields"]),
|
|
366
|
-
panel: _get_params(_panel, ["chart", "widget", "fields"]),
|
|
367
|
-
widget: _get_params(_widget, ["fields"])
|
|
368
|
-
};
|
|
369
|
-
});
|
|
370
|
-
return ret;
|
|
371
|
-
function _get_params(_o, exclude_list) {
|
|
372
|
-
const ret = {};
|
|
373
|
-
Object.keys(_o.__properties)
|
|
374
|
-
.filter(n => exclude_list.indexOf(n) === -1)
|
|
375
|
-
.forEach(n => ret[n] = _o.__properties[n]);
|
|
376
|
-
return ret;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
validate(): IElementError[] {
|
|
381
|
-
let retVal: IElementError[] = [];
|
|
382
|
-
this._elements.forEach(elem => {
|
|
383
|
-
retVal = retVal.concat(elem.validate());
|
|
384
|
-
});
|
|
385
|
-
return retVal;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
refresh(): Promise<this> {
|
|
389
|
-
return Promise.all(this.elements().map(element => element.refresh())).then(() => {
|
|
390
|
-
return this;
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// Events ---
|
|
395
|
-
vizStateChanged(viz: Element) {
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
ElementContainer.prototype._class += " dashboard_ElementContainer";
|
|
1
|
+
import { PropertyExt, publish, Widget } from "@hpcc-js/common";
|
|
2
|
+
import { IOptionsSend } from "@hpcc-js/comms";
|
|
3
|
+
import { DDL2 } from "@hpcc-js/ddl-shim";
|
|
4
|
+
import { find, hashSum, isArray } from "@hpcc-js/util";
|
|
5
|
+
import { Activity, IActivityError } from "../activities/activity";
|
|
6
|
+
import { emptyDatabomb } from "../activities/databomb";
|
|
7
|
+
import { DatasourceRefType } from "../activities/datasource";
|
|
8
|
+
import { HipiePipeline } from "../activities/hipiepipeline";
|
|
9
|
+
import { Mappings } from "../activities/project";
|
|
10
|
+
import { Visualization } from "./visualization";
|
|
11
|
+
import { VizChartPanel } from "./vizChartPanel";
|
|
12
|
+
|
|
13
|
+
export class State extends PropertyExt {
|
|
14
|
+
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.selection([]);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
set(_: Array<{ [key: string]: any }>): boolean {
|
|
21
|
+
const currSelHash = hashSum(this.selection());
|
|
22
|
+
const newSelHash = hashSum(_);
|
|
23
|
+
if (currSelHash !== newSelHash) {
|
|
24
|
+
this.selection(_);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
removeInvalid(data: ReadonlyArray<object>): boolean {
|
|
31
|
+
const currSelection = this.selection();
|
|
32
|
+
const newSelection: object[] = [];
|
|
33
|
+
for (const selRow of currSelection) {
|
|
34
|
+
if (find(data, (row: { [key: string]: any }, index): boolean => {
|
|
35
|
+
for (const column in selRow) {
|
|
36
|
+
if (selRow[column] !== row[column]) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
})) {
|
|
42
|
+
newSelection.push(selRow);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (newSelection.length !== currSelection.length) {
|
|
46
|
+
this.selection(newSelection);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
State.prototype._class += " State";
|
|
53
|
+
export interface State {
|
|
54
|
+
selection(): Array<{ [key: string]: any }>;
|
|
55
|
+
selection(_: Array<{ [key: string]: any }>): this;
|
|
56
|
+
}
|
|
57
|
+
State.prototype.publish("selection", [], "array", "State");
|
|
58
|
+
|
|
59
|
+
let vizID = 0;
|
|
60
|
+
export class Element extends PropertyExt {
|
|
61
|
+
private _vizChartPanel: Visualization;
|
|
62
|
+
|
|
63
|
+
// @publishProxy("_MultiChartPanel")
|
|
64
|
+
// title: publish<this, string>;
|
|
65
|
+
@publish(null, "widget", "Data View")
|
|
66
|
+
hipiePipeline: publish<this, HipiePipeline>;
|
|
67
|
+
@publish(null, "widget", "Visualization")
|
|
68
|
+
_visualization: Visualization;
|
|
69
|
+
visualization(): Visualization;
|
|
70
|
+
visualization(_: Visualization): this;
|
|
71
|
+
visualization(_?: Visualization): Visualization | this {
|
|
72
|
+
if (!arguments.length) return this._visualization;
|
|
73
|
+
this._visualization = _;
|
|
74
|
+
this._visualization
|
|
75
|
+
.on("click", (_row: object | object[], col: string, sel: boolean, more?) => {
|
|
76
|
+
if (more && more.selection) {
|
|
77
|
+
this.selection(sel ? more.selection.map(r => r.__lparam || r) : []);
|
|
78
|
+
} else {
|
|
79
|
+
const row: any[] = isArray(_row) ? _row : [_row];
|
|
80
|
+
this.selection(sel ? row.map(r => r.__lparam || r) : []);
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
.on("vertex_click", (_row: object | object[], col: string, sel: boolean) => {
|
|
84
|
+
const row: any[] = isArray(_row) ? _row : [_row];
|
|
85
|
+
this.selection(sel ? row.map(r => r.__lparam || r) : []);
|
|
86
|
+
})
|
|
87
|
+
;
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
@publish(null, "widget", "State")
|
|
91
|
+
state: publish<this, State>;
|
|
92
|
+
|
|
93
|
+
constructor(private _ec: ElementContainer) {
|
|
94
|
+
super();
|
|
95
|
+
while (true) {
|
|
96
|
+
vizID++;
|
|
97
|
+
this._id = `e_${vizID}`;
|
|
98
|
+
if (!this._ec.elementExists(this._id)) {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const view = new HipiePipeline(this._ec, this._id);
|
|
103
|
+
this.hipiePipeline(view);
|
|
104
|
+
this._vizChartPanel = new Visualization(this._ec, this.hipiePipeline())
|
|
105
|
+
.id(`viz_${vizID}`)
|
|
106
|
+
.title(`Element ${vizID}`)
|
|
107
|
+
;
|
|
108
|
+
this._vizChartPanel.chartPanel().id(`cp_${vizID}`);
|
|
109
|
+
this.visualization(this._vizChartPanel);
|
|
110
|
+
this.state(new State());
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
id(): string;
|
|
114
|
+
id(_: string): this;
|
|
115
|
+
id(_?: string): string | this {
|
|
116
|
+
const retVal = super.id.apply(this, arguments);
|
|
117
|
+
if (arguments.length) {
|
|
118
|
+
this._vizChartPanel.id(_);
|
|
119
|
+
}
|
|
120
|
+
return retVal;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
chartType(): string {
|
|
124
|
+
return this._vizChartPanel.chartType();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
chartPanel(): VizChartPanel;
|
|
128
|
+
chartPanel(_: VizChartPanel): this;
|
|
129
|
+
chartPanel(_?: VizChartPanel): VizChartPanel | this {
|
|
130
|
+
if (!arguments.length) return this._vizChartPanel.chartPanel();
|
|
131
|
+
this._vizChartPanel.chartPanel(_);
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
chart(): Widget {
|
|
136
|
+
return this._vizChartPanel.chartPanel().widget();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
mappings(): Mappings;
|
|
140
|
+
mappings(_: Mappings): this;
|
|
141
|
+
mappings(_?: Mappings): Mappings | this {
|
|
142
|
+
if (!arguments.length) return this._vizChartPanel.mappings();
|
|
143
|
+
this._vizChartPanel.mappings(_);
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
pipeline(activities: Activity[]): this {
|
|
148
|
+
this.hipiePipeline()
|
|
149
|
+
.activities(activities)
|
|
150
|
+
;
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
updatedBy(): string[] {
|
|
155
|
+
const retVal = this.hipiePipeline().updatedBy();
|
|
156
|
+
if (this.visualization().secondaryDataviewID_exists()) {
|
|
157
|
+
retVal.push(this.visualization().secondaryDataviewID());
|
|
158
|
+
}
|
|
159
|
+
return retVal;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
dataProps(): PropertyExt {
|
|
163
|
+
return this.hipiePipeline();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
vizProps(): Widget {
|
|
167
|
+
return this.visualization().chartPanel();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
stateProps(): PropertyExt {
|
|
171
|
+
return this.state();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private _errors: IElementError[] = [];
|
|
175
|
+
errors(): IElementError[] {
|
|
176
|
+
return this._errors;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
validate(): IElementError[] {
|
|
180
|
+
if (!this._initialized) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
this._errors = [];
|
|
184
|
+
const pipeline = this.hipiePipeline();
|
|
185
|
+
for (const activity of [...pipeline.activities(), this.mappings()]) {
|
|
186
|
+
for (const error of activity.validate()) {
|
|
187
|
+
this._errors.push({
|
|
188
|
+
elementID: this.id(),
|
|
189
|
+
...error
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return this._errors;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private _initialized = false;
|
|
197
|
+
refresh(): Promise<void> {
|
|
198
|
+
const filters = this.hipiePipeline().filters().validFilters();
|
|
199
|
+
const desc: string[] = filters.map(f => f.createFilterDescription());
|
|
200
|
+
this.visualization().chartPanel().description(desc.join(", "));
|
|
201
|
+
return this.visualization().refresh().then(() => {
|
|
202
|
+
this._initialized = true;
|
|
203
|
+
const data = this.hipiePipeline().outData();
|
|
204
|
+
if (this.visualization().chartType() === "FieldForm") {
|
|
205
|
+
if (this.state().set([...data])) {
|
|
206
|
+
this.selectionChanged();
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
if (this.state().removeInvalid(data)) {
|
|
210
|
+
this.selectionChanged();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Selection ---
|
|
217
|
+
selection(): object[];
|
|
218
|
+
selection(_: object[]): this;
|
|
219
|
+
selection(_?: object[]): object[] | this {
|
|
220
|
+
if (!arguments.length) return this.state().selection();
|
|
221
|
+
this.state().selection(_);
|
|
222
|
+
this.selectionChanged();
|
|
223
|
+
return this;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Events ---
|
|
227
|
+
selectionChanged() {
|
|
228
|
+
const promises: Array<Promise<void>> = [];
|
|
229
|
+
for (const filteredViz of this._ec.filteredBy(this.id())) {
|
|
230
|
+
promises.push(filteredViz.refresh());
|
|
231
|
+
}
|
|
232
|
+
Promise.all(promises).then(() => {
|
|
233
|
+
this._ec.vizStateChanged(this);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
monitor(func: (id: string, newVal: any, oldVal: any, source: PropertyExt) => void): { remove: () => void; } {
|
|
238
|
+
return this.hipiePipeline().monitor(func);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
Element.prototype._class += " Viz";
|
|
242
|
+
|
|
243
|
+
export interface IPersist {
|
|
244
|
+
ddl: DDL2.Schema;
|
|
245
|
+
layout: any;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface IElementError extends IActivityError {
|
|
249
|
+
elementID: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export class ElementContainer extends PropertyExt {
|
|
253
|
+
|
|
254
|
+
private _nullElement;
|
|
255
|
+
|
|
256
|
+
private _datasources: DatasourceRefType[] = [emptyDatabomb];
|
|
257
|
+
private _elements: Element[] = [];
|
|
258
|
+
|
|
259
|
+
@publish(10, "number", "Number of samples")
|
|
260
|
+
samples: publish<this, number>;
|
|
261
|
+
@publish(100, "number", "Sample size")
|
|
262
|
+
sampleSize: publish<this, number>;
|
|
263
|
+
|
|
264
|
+
constructor() {
|
|
265
|
+
super();
|
|
266
|
+
this.clear();
|
|
267
|
+
this._nullElement = new Element(this);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
clear(eid?: string) {
|
|
271
|
+
this._datasources = eid === undefined ? [emptyDatabomb] : this._datasources;
|
|
272
|
+
this._elements = eid === undefined ? [] : this._elements.filter(d => d.id() !== eid);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
private _hookSend: IOptionsSend;
|
|
276
|
+
hookSend(): IOptionsSend;
|
|
277
|
+
hookSend(_: IOptionsSend): this;
|
|
278
|
+
hookSend(_?: IOptionsSend): IOptionsSend | this {
|
|
279
|
+
if (!arguments.length) return this._hookSend;
|
|
280
|
+
this._hookSend = _;
|
|
281
|
+
return this;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
datasources(): DatasourceRefType[];
|
|
285
|
+
datasources(_: DatasourceRefType[]): this;
|
|
286
|
+
datasources(_?: DatasourceRefType[]): DatasourceRefType[] | this {
|
|
287
|
+
if (!arguments.length) return this._datasources;
|
|
288
|
+
this._datasources = _;
|
|
289
|
+
return this;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
datasource(id): DatasourceRefType {
|
|
293
|
+
return this._datasources.filter(ds => ds.id() === id)[0];
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
appendDatasource(ds: DatasourceRefType): this {
|
|
297
|
+
this._datasources.push(ds);
|
|
298
|
+
return this;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
removeDatasource(ds: DatasourceRefType): this {
|
|
302
|
+
this._datasources = this._datasources.filter(row => row !== ds);
|
|
303
|
+
return this;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
elements(): Element[] {
|
|
307
|
+
return [...this._elements];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
element(w: string | PropertyExt | VizChartPanel): Element {
|
|
311
|
+
let retVal: Element[];
|
|
312
|
+
if (typeof w === "string") {
|
|
313
|
+
retVal = this._elements.filter(viz => viz.id() === w);
|
|
314
|
+
} else if (w instanceof VizChartPanel) {
|
|
315
|
+
retVal = this._elements.filter(v => v.chartPanel() === w);
|
|
316
|
+
} else {
|
|
317
|
+
retVal = this._elements.filter(v => v.vizProps() === w);
|
|
318
|
+
}
|
|
319
|
+
if (retVal.length) {
|
|
320
|
+
return retVal[0];
|
|
321
|
+
}
|
|
322
|
+
return this._nullElement;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
elementExists(w: string | PropertyExt): boolean {
|
|
326
|
+
return this.element(w) !== this._nullElement;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
elementIDs() {
|
|
330
|
+
return this._elements.map(viz => viz.id());
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
append(element: Element): this {
|
|
334
|
+
this._elements.push(element);
|
|
335
|
+
return this;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
filteredBy(elemID: string): Element[] {
|
|
339
|
+
return this._elements.filter(otherViz => {
|
|
340
|
+
const filterIDs = otherViz.updatedBy();
|
|
341
|
+
return filterIDs.indexOf(elemID) >= 0;
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
views(): HipiePipeline[] {
|
|
346
|
+
return this._elements.map(viz => viz.hipiePipeline());
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
view(id: string): HipiePipeline | undefined {
|
|
350
|
+
return this.views().filter(view => view.id() === id)[0];
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
normalizePersist(seri: any): { [key: string]: { [key: string]: any } } {
|
|
354
|
+
const ret = {};
|
|
355
|
+
seri.__properties.content.map((n) => {
|
|
356
|
+
const _is_MegaChart = !!n.__properties.widget.__properties.chart;
|
|
357
|
+
const _cell = n;
|
|
358
|
+
const _panel = n.__properties.widget;
|
|
359
|
+
const _widget = _is_MegaChart ? n.__properties.widget.__properties.chart : n.__properties.widget.__properties.widget;
|
|
360
|
+
const _id = n.__properties.widget.__id ? n.__properties.widget.__id : n.__properties.widget.__properties.widget.__id;
|
|
361
|
+
ret[_id] = {
|
|
362
|
+
id: _id,
|
|
363
|
+
package: _widget.__class.split("_")[0],
|
|
364
|
+
object: _widget.__class.split("_")[1],
|
|
365
|
+
cell: _get_params(_cell, ["chart", "widget", "fields"]),
|
|
366
|
+
panel: _get_params(_panel, ["chart", "widget", "fields"]),
|
|
367
|
+
widget: _get_params(_widget, ["fields"])
|
|
368
|
+
};
|
|
369
|
+
});
|
|
370
|
+
return ret;
|
|
371
|
+
function _get_params(_o, exclude_list) {
|
|
372
|
+
const ret = {};
|
|
373
|
+
Object.keys(_o.__properties)
|
|
374
|
+
.filter(n => exclude_list.indexOf(n) === -1)
|
|
375
|
+
.forEach(n => ret[n] = _o.__properties[n]);
|
|
376
|
+
return ret;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
validate(): IElementError[] {
|
|
381
|
+
let retVal: IElementError[] = [];
|
|
382
|
+
this._elements.forEach(elem => {
|
|
383
|
+
retVal = retVal.concat(elem.validate());
|
|
384
|
+
});
|
|
385
|
+
return retVal;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
refresh(): Promise<this> {
|
|
389
|
+
return Promise.all(this.elements().map(element => element.refresh())).then(() => {
|
|
390
|
+
return this;
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Events ---
|
|
395
|
+
vizStateChanged(viz: Element) {
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
ElementContainer.prototype._class += " dashboard_ElementContainer";
|