@hpcc-js/marshaller 2.28.7 → 2.28.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.
Files changed (55) hide show
  1. package/LICENSE +43 -43
  2. package/dist/index.es6.js +25 -13
  3. package/dist/index.es6.js.map +1 -1
  4. package/dist/index.js +25 -13
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.js +2 -2
  7. package/dist/index.min.js.map +1 -1
  8. package/package.json +12 -12
  9. package/src/__package__.ts +3 -3
  10. package/src/dashy.css +239 -239
  11. package/src/dashy.ts +521 -521
  12. package/src/ddl1/DDLApi.ts +229 -229
  13. package/src/ddl1/FlyoutButton.ts +120 -120
  14. package/src/ddl1/Graph.ts +93 -93
  15. package/src/ddl1/HTML.ts +77 -77
  16. package/src/ddl1/HipieDDL.ts +2437 -2437
  17. package/src/ddl1/HipieDDLMixin.ts +380 -380
  18. package/src/ddl1/Tabbed.ts +91 -91
  19. package/src/ddl1/TargetMarshaller.ts +57 -57
  20. package/src/ddl2/PopupManager.ts +89 -89
  21. package/src/ddl2/activities/activity.ts +431 -431
  22. package/src/ddl2/activities/databomb.ts +237 -237
  23. package/src/ddl2/activities/datasource.ts +52 -52
  24. package/src/ddl2/activities/dspicker.ts +106 -106
  25. package/src/ddl2/activities/filter.ts +542 -542
  26. package/src/ddl2/activities/form.ts +153 -153
  27. package/src/ddl2/activities/groupby.ts +439 -439
  28. package/src/ddl2/activities/hipiepipeline.ts +114 -114
  29. package/src/ddl2/activities/limit.ts +49 -49
  30. package/src/ddl2/activities/logicalfile.ts +62 -62
  31. package/src/ddl2/activities/nullview.ts +12 -12
  32. package/src/ddl2/activities/project.ts +764 -764
  33. package/src/ddl2/activities/rest.ts +568 -568
  34. package/src/ddl2/activities/roxie.ts +490 -490
  35. package/src/ddl2/activities/sampledata.json +16264 -16264
  36. package/src/ddl2/activities/sort.ts +176 -176
  37. package/src/ddl2/activities/wuresult.ts +395 -395
  38. package/src/ddl2/dashboard.css +13 -13
  39. package/src/ddl2/dashboard.ts +330 -330
  40. package/src/ddl2/dashboardDockPanel.ts +123 -123
  41. package/src/ddl2/dashboardGrid.ts +202 -202
  42. package/src/ddl2/ddl.ts +410 -410
  43. package/src/ddl2/ddleditor.ts +60 -60
  44. package/src/ddl2/dsTable.ts +238 -238
  45. package/src/ddl2/dvTable.ts +31 -31
  46. package/src/ddl2/graphadapter.ts +297 -297
  47. package/src/ddl2/javascriptadapter.ts +354 -354
  48. package/src/ddl2/model/element.ts +398 -398
  49. package/src/ddl2/model/visualization.ts +351 -351
  50. package/src/ddl2/model/vizChartPanel.ts +149 -149
  51. package/src/ddl2/pipelinePanel.css +4 -4
  52. package/src/ddl2/pipelinePanel.ts +465 -465
  53. package/src/index.ts +26 -26
  54. package/types/__package__.d.ts +2 -2
  55. package/types-3.4/__package__.d.ts +2 -2
@@ -1,380 +1,380 @@
1
- import { Platform, PropertyExt, Utility } from "@hpcc-js/common";
2
- import { Modal, Surface } from "@hpcc-js/layout";
3
- import { Persist } from "@hpcc-js/other";
4
- import { map as d3Map } from "d3-collection";
5
- import { select as d3Select } from "d3-selection";
6
- import { FlyoutButton } from "./FlyoutButton";
7
- import * as HipieDDL from "./HipieDDL";
8
-
9
- const tpl =
10
- "<!doctype html><html><head><meta charset='utf-8'>" +
11
- "<script src='http://viz.hpccsystems.com/v1.14.0-rc5/dist-amd/hpcc-viz.js'></script>" +
12
- "<script src='http://viz.hpccsystems.com/v1.14.0-rc5/dist-amd/hpcc-viz-common.js'></script>" +
13
- "</head>" +
14
- "<body style='padding:0px; margin:0px; overflow:hidden'><div id='placeholder' style='width:100%; height:100vh'></div><script>" +
15
- " require(['src/other/Persist'], function (Persist) {\n" +
16
- " Persist.create({STATE}).then(function(widget) {\n" +
17
- " widget\n" +
18
- " .target('placeholder')\n" +
19
- " .ddlUrl('{DDL}')\n" +
20
- " .databomb('{DATABOMB}')\n" +
21
- " .render()\n" +
22
- " ;\n" +
23
- " });\n" +
24
- " });" +
25
- "</script></body></html>";
26
-
27
- export class HipieDDLMixin extends PropertyExt {
28
- _ddlDashboards;
29
- _ddlVisualizations;
30
- _ddlPopupVisualizations;
31
- _ddlLayerVisualizations;
32
- _ddlModalVisualizations;
33
- _prev_ddlUrl;
34
- _prev_databomb;
35
- _marshaller;
36
- _initialState;
37
-
38
- constructor() {
39
- super();
40
- PropertyExt.call(this);
41
- }
42
-
43
- _gatherDashboards(marshaller, databomb) {
44
- if (databomb instanceof Object) {
45
- } else if (databomb) {
46
- databomb = JSON.parse(databomb);
47
- }
48
- this._ddlDashboards = [];
49
- this._ddlVisualizations = [];
50
- this._ddlPopupVisualizations = [];
51
- this._ddlLayerVisualizations = [];
52
- this._ddlModalVisualizations = [];
53
- const context = this;
54
- let curr = null;
55
- marshaller.accept({
56
- visit: (item) => {
57
- if (item instanceof HipieDDL.Dashboard) {
58
- curr = {
59
- dashboard: item,
60
- visualizations: [],
61
- popupVisualizations: [],
62
- layerVisualizations: [],
63
- modalVisualizations: []
64
- };
65
- context._ddlDashboards.push(curr);
66
- } else if (item instanceof HipieDDL.Datasource) {
67
- if (item.databomb && databomb[item.id]) {
68
- item.comms.databomb(databomb[item.id]);
69
- }
70
- } else if (item instanceof HipieDDL.Output) {
71
- if (item.datasource.databomb) {
72
- item.datasource.comms.databombOutput(item.from, item.id);
73
- }
74
- } else if (item instanceof HipieDDL.Visualization) {
75
- if (item.widget) {
76
- if (item.properties.flyout) {
77
- curr.popupVisualizations.push(item);
78
- context._ddlPopupVisualizations.push(item);
79
- } else if (item.parentVisualization) {
80
- curr.layerVisualizations.push(item);
81
- context._ddlLayerVisualizations.push(item);
82
- } else if (item.properties.modalIfData && !context.disableModals()) {
83
- curr.modalVisualizations.push(item);
84
- context._ddlModalVisualizations.push(item);
85
- } else {
86
- curr.visualizations.push(item);
87
- context._ddlVisualizations.push(item);
88
- }
89
- }
90
- }
91
- }
92
- });
93
- }
94
-
95
- _marshallerRender(BaseClass, callback) {
96
- if (this.ddlUrl() === "" || (this.ddlUrl() === this._prev_ddlUrl && this.databomb() === this._prev_databomb)) {
97
- if (this._marshaller) {
98
- this._marshaller
99
- .proxyMappings(this.proxyMappings())
100
- .timeout(this.timeout())
101
- .clearDataOnUpdate(this.clearDataOnUpdate())
102
- .propogateClear(this.propogateClear())
103
- .missingDataString(this.missingDataString())
104
- ;
105
- }
106
- return BaseClass.render.call(this, function (widget) {
107
- if (callback) {
108
- callback(widget);
109
- }
110
- });
111
- }
112
- if (this._prev_ddlUrl && this._prev_ddlUrl !== this.ddlUrl()) {
113
- // DDL has actually changed (not just a deserialization)
114
- this
115
- .clearContent()
116
- ;
117
- }
118
- this._prev_ddlUrl = this.ddlUrl();
119
- this._prev_databomb = this.databomb();
120
-
121
- // Gather existing widgets for reuse ---
122
- const widgetArr = [];
123
- Persist.widgetArrayWalker(this.content(), function (w) {
124
- widgetArr.push(w);
125
- });
126
- const widgetMap = d3Map(widgetArr, function (d) {
127
- return d.id();
128
- });
129
- const removedMap = d3Map(widgetArr.filter(function (d) { return d.id().indexOf(d._idSeed) !== 0 && d.id().indexOf("_pe") !== 0; }), function (d) {
130
- return d.id();
131
- });
132
-
133
- const context = this;
134
- this._marshaller = new HipieDDL.Marshaller()
135
- .proxyMappings(this.proxyMappings())
136
- .clearDataOnUpdate(this.clearDataOnUpdate())
137
- .propogateClear(this.propogateClear())
138
- .missingDataString(this.missingDataString())
139
- .widgetMappings(widgetMap)
140
- .on("commsEvent", function (source, error) {
141
- context.commsEvent.apply(context, arguments);
142
- })
143
- .on("vizEvent", function () {
144
- context.vizEvent.apply(context, arguments);
145
- })
146
- ;
147
-
148
- // Parse DDL ---
149
- if (this.ddlUrl()[0] === "[" || this.ddlUrl()[0] === "{") {
150
- this._marshaller.parse(this.ddlUrl(), postParse);
151
- } else {
152
- this._marshaller.url(this.ddlUrl(), postParse);
153
- }
154
-
155
- function postParse() {
156
- context._gatherDashboards(context._marshaller, context.databomb());
157
- // Remove existing widgets not used and prime popups ---
158
- context._ddlVisualizations.forEach(function (viz) {
159
- removedMap.remove(viz.id);
160
- if (!context._marshaller.widgetMappings().get(viz.id)) {
161
- // New widget ---
162
- viz.newWidgetSurface = null;
163
- if (viz.widget instanceof Surface || viz.widget.classID() === "composite_MegaChart") {
164
- viz.newWidgetSurface = viz.widget;
165
- } else {
166
- viz.newWidgetSurface = new Surface()
167
- .widget(viz.widget)
168
- ;
169
- }
170
- viz.newWidgetSurface.title(viz.title);
171
- viz.widget.size({ width: 0, height: 0 });
172
- }
173
- });
174
- context._ddlPopupVisualizations.forEach(function (viz) {
175
- removedMap.remove(viz.id);
176
- viz.widget.classed({ flyout: true });
177
- const targetVizs = viz.events.getUpdatesVisualizations();
178
- targetVizs.forEach(function (targetViz) {
179
- switch (targetViz.widget.classID()) {
180
- case "composite_MegaChart":
181
- if (!viz._flyoutButton) {
182
- viz._flyoutButton = new FlyoutButton()
183
- .classed({ "composite_MegaChart-flyout": true })
184
- .title(viz.title)
185
- .widget(viz.widget)
186
- .autoClose(context.autoCloseFlyout())
187
- ;
188
- targetViz.widget.toolbarWidgets().push(viz._flyoutButton);
189
- } else {
190
- targetViz.widget.toolbarWidgets().push(viz._flyoutButton.reference());
191
- }
192
- break;
193
- }
194
- });
195
- });
196
- context._ddlModalVisualizations.forEach(function (viz) {
197
- if (viz.widget.showCSV) {
198
- viz.widget.showToolbar(true);
199
- } else if (viz.widget.showToolbar) {
200
- viz.widget.showToolbar(false);
201
- }
202
- viz._modalTarget = d3Select("body").append("div").node();
203
- viz._modal = new Modal().target(viz._modalTarget)
204
- .overflowX("hidden")
205
- .overflowY("hidden")
206
- ;
207
- viz._modal._widget = viz.widget;
208
- const origRender = viz.widget.render;
209
- viz.widget.render = function (callback) {
210
- if (this.__inModal) {
211
- return origRender.apply(this, arguments);
212
- }
213
- if (this.data().length) {
214
- this.__inModal = true;
215
- const widgetContext = this;
216
- const modalTitle = viz.widget.title();
217
- if (viz.widget.showToolbar()) {
218
- viz.widget.titleFontColor("transparent");
219
- }
220
- viz._modal
221
- .title(modalTitle)
222
- .visible(true)
223
- .fixedWidth("80%")
224
- .fixedHeight("80%")
225
- .render(function (w) {
226
- if (callback) {
227
- callback(widgetContext);
228
- }
229
- setTimeout(function () {
230
- widgetContext.__inModal = false;
231
- }, 300); // Must be longer than debounce timeout...
232
- });
233
- } else {
234
- if (callback) {
235
- callback(this);
236
- }
237
- }
238
- return this;
239
- };
240
- });
241
- removedMap.each(function (key, value) {
242
- context.clearContent(value);
243
- });
244
- context.populateContent();
245
- if (context._initialState) {
246
- context._marshaller.deserializeState(context._initialState.marshaller);
247
- delete context._initialState;
248
- BaseClass.render.call(context, callback);
249
- } else {
250
- BaseClass.render.call(context, function (widget) {
251
- context._marshaller.primeData().then(function (response) {
252
- if (callback) {
253
- callback(widget);
254
- }
255
- });
256
- });
257
- }
258
- }
259
- }
260
-
261
- primeData(state) {
262
- if (this._marshaller) {
263
- return this._marshaller.primeData(state);
264
- }
265
- return Promise.resolve();
266
- }
267
-
268
- dashboards() {
269
- const retVal = {};
270
- for (const key in this._marshaller.dashboards) {
271
- retVal[key] = {};
272
- this._marshaller.dashboards[key].visualizations.forEach(function (ddlViz) {
273
- retVal[key][ddlViz.id] = ddlViz.widget;
274
- }, this);
275
- }
276
- return retVal;
277
- }
278
-
279
- visualizations() {
280
- return this._marshaller._visualizationArray.map(function (ddlViz) {
281
- return ddlViz.newWidgetSurface || ddlViz.widget;
282
- });
283
- }
284
-
285
- generateTestPage() {
286
- if (this._marshaller) {
287
- const context = this;
288
- const state = Persist.serialize(context, function (widget, publishItem) {
289
- if (publishItem.id === "databomb" || publishItem.id === "ddlUrl") {
290
- return true;
291
- }
292
- return false;
293
- });
294
- const databomb = this._marshaller.createDatabomb();
295
- const page = tpl
296
- .replace("{VERSION}", Platform.version())
297
- .replace("{STATE}", state)
298
- .replace("{DDL}", context._marshaller._json.replace("WUID", "databomb"))
299
- .replace("{DATABOMB}", JSON.stringify(databomb))
300
- ;
301
- Utility.downloadString("TEXT", page, "test");
302
- }
303
- }
304
-
305
- vizEvent(sourceWidget, eventID, row, col, selected) {
306
- }
307
-
308
- commsEvent(ddlSource, eventID, request, response) {
309
- }
310
-
311
- state(_) {
312
- if (!arguments.length) {
313
- return this.serializeState();
314
- }
315
- this.deserializeState(_);
316
- return this;
317
- }
318
-
319
- serializeState() {
320
- return {
321
- marshaller: this._marshaller ? this._marshaller.serializeState() : {}
322
- };
323
- }
324
-
325
- deserializeState(state) {
326
- if (this._marshaller) {
327
- this._marshaller.deserializeState(state.marshaller);
328
- } else {
329
- this._initialState = state;
330
- }
331
- return this;
332
- }
333
-
334
- serializeRequests() {
335
- let retVal = null;
336
- this._ddlPopupVisualizations.concat(this._ddlVisualizations).forEach(function (ddlViz) {
337
- if (ddlViz.hasSelection()) {
338
- if (!retVal) {
339
- retVal = {};
340
- }
341
- retVal[ddlViz.id] = ddlViz.reverseMappedSelection();
342
- }
343
- });
344
- return retVal;
345
- }
346
- // HipieDDLMixin abstract methods ---
347
- content: () => this;
348
- populateContent: () => this;
349
- clearContent: (value?) => this;
350
-
351
- ddlUrl: { (): string; (_: string): HipieDDLMixin };
352
- ddlUrl_exists: () => boolean;
353
- databomb: { (): string; (_: string): HipieDDLMixin };
354
- databomb_exists: () => boolean;
355
- proxyMappings: { (): object; (_: object): HipieDDLMixin };
356
- proxyMappings_exists: () => boolean;
357
- timeout: { (): number; (_: number): HipieDDLMixin };
358
- timeout_exists: () => boolean;
359
- clearDataOnUpdate: { (): boolean; (_: boolean): HipieDDLMixin };
360
- clearDataOnUpdate_exists: () => boolean;
361
- propogateClear: { (): boolean; (_: boolean): HipieDDLMixin };
362
- propogateClear_exists: () => boolean;
363
- missingDataString: { (): string; (_: string): HipieDDLMixin };
364
- missingDataString_exists: () => boolean;
365
- autoCloseFlyout: { (): boolean; (_: boolean): HipieDDLMixin };
366
- autoCloseFlyout_exists: () => boolean;
367
- disableModals: { (): boolean; (_: boolean): HipieDDLMixin };
368
- }
369
- HipieDDLMixin.prototype.mixin(PropertyExt);
370
- HipieDDLMixin.prototype._class += " marshaller_HipieDDLMixin";
371
-
372
- HipieDDLMixin.prototype.publish("ddlUrl", "", "string", "DDL URL", null, { tags: ["Private"] });
373
- HipieDDLMixin.prototype.publish("databomb", "", "string", "Data Bomb", null, { tags: ["Private"] });
374
- HipieDDLMixin.prototype.publish("proxyMappings", {}, "object", "Proxy Mappings", null, { tags: ["Private"] });
375
- HipieDDLMixin.prototype.publish("timeout", null, "number", "Timout (seconds)", null, { optional: true });
376
- HipieDDLMixin.prototype.publish("clearDataOnUpdate", true, "boolean", "Clear data prior to refresh", null);
377
- HipieDDLMixin.prototype.publish("propogateClear", false, "boolean", "Propogate clear to dependent visualizations", null);
378
- HipieDDLMixin.prototype.publish("missingDataString", "***MISSING***", "string", "Missing data display string");
379
- HipieDDLMixin.prototype.publish("autoCloseFlyout", true, "boolean", "Auto Close Flyout Filters");
380
- HipieDDLMixin.prototype.publish("disableModals", false, "boolean", "If true, widgets with 'modalIfData' will display as standard Grid widgets");
1
+ import { Platform, PropertyExt, Utility } from "@hpcc-js/common";
2
+ import { Modal, Surface } from "@hpcc-js/layout";
3
+ import { Persist } from "@hpcc-js/other";
4
+ import { map as d3Map } from "d3-collection";
5
+ import { select as d3Select } from "d3-selection";
6
+ import { FlyoutButton } from "./FlyoutButton";
7
+ import * as HipieDDL from "./HipieDDL";
8
+
9
+ const tpl =
10
+ "<!doctype html><html><head><meta charset='utf-8'>" +
11
+ "<script src='http://viz.hpccsystems.com/v1.14.0-rc5/dist-amd/hpcc-viz.js'></script>" +
12
+ "<script src='http://viz.hpccsystems.com/v1.14.0-rc5/dist-amd/hpcc-viz-common.js'></script>" +
13
+ "</head>" +
14
+ "<body style='padding:0px; margin:0px; overflow:hidden'><div id='placeholder' style='width:100%; height:100vh'></div><script>" +
15
+ " require(['src/other/Persist'], function (Persist) {\n" +
16
+ " Persist.create({STATE}).then(function(widget) {\n" +
17
+ " widget\n" +
18
+ " .target('placeholder')\n" +
19
+ " .ddlUrl('{DDL}')\n" +
20
+ " .databomb('{DATABOMB}')\n" +
21
+ " .render()\n" +
22
+ " ;\n" +
23
+ " });\n" +
24
+ " });" +
25
+ "</script></body></html>";
26
+
27
+ export class HipieDDLMixin extends PropertyExt {
28
+ _ddlDashboards;
29
+ _ddlVisualizations;
30
+ _ddlPopupVisualizations;
31
+ _ddlLayerVisualizations;
32
+ _ddlModalVisualizations;
33
+ _prev_ddlUrl;
34
+ _prev_databomb;
35
+ _marshaller;
36
+ _initialState;
37
+
38
+ constructor() {
39
+ super();
40
+ PropertyExt.call(this);
41
+ }
42
+
43
+ _gatherDashboards(marshaller, databomb) {
44
+ if (databomb instanceof Object) {
45
+ } else if (databomb) {
46
+ databomb = JSON.parse(databomb);
47
+ }
48
+ this._ddlDashboards = [];
49
+ this._ddlVisualizations = [];
50
+ this._ddlPopupVisualizations = [];
51
+ this._ddlLayerVisualizations = [];
52
+ this._ddlModalVisualizations = [];
53
+ const context = this;
54
+ let curr = null;
55
+ marshaller.accept({
56
+ visit: (item) => {
57
+ if (item instanceof HipieDDL.Dashboard) {
58
+ curr = {
59
+ dashboard: item,
60
+ visualizations: [],
61
+ popupVisualizations: [],
62
+ layerVisualizations: [],
63
+ modalVisualizations: []
64
+ };
65
+ context._ddlDashboards.push(curr);
66
+ } else if (item instanceof HipieDDL.Datasource) {
67
+ if (item.databomb && databomb[item.id]) {
68
+ item.comms.databomb(databomb[item.id]);
69
+ }
70
+ } else if (item instanceof HipieDDL.Output) {
71
+ if (item.datasource.databomb) {
72
+ item.datasource.comms.databombOutput(item.from, item.id);
73
+ }
74
+ } else if (item instanceof HipieDDL.Visualization) {
75
+ if (item.widget) {
76
+ if (item.properties.flyout) {
77
+ curr.popupVisualizations.push(item);
78
+ context._ddlPopupVisualizations.push(item);
79
+ } else if (item.parentVisualization) {
80
+ curr.layerVisualizations.push(item);
81
+ context._ddlLayerVisualizations.push(item);
82
+ } else if (item.properties.modalIfData && !context.disableModals()) {
83
+ curr.modalVisualizations.push(item);
84
+ context._ddlModalVisualizations.push(item);
85
+ } else {
86
+ curr.visualizations.push(item);
87
+ context._ddlVisualizations.push(item);
88
+ }
89
+ }
90
+ }
91
+ }
92
+ });
93
+ }
94
+
95
+ _marshallerRender(BaseClass, callback) {
96
+ if (this.ddlUrl() === "" || (this.ddlUrl() === this._prev_ddlUrl && this.databomb() === this._prev_databomb)) {
97
+ if (this._marshaller) {
98
+ this._marshaller
99
+ .proxyMappings(this.proxyMappings())
100
+ .timeout(this.timeout())
101
+ .clearDataOnUpdate(this.clearDataOnUpdate())
102
+ .propogateClear(this.propogateClear())
103
+ .missingDataString(this.missingDataString())
104
+ ;
105
+ }
106
+ return BaseClass.render.call(this, function (widget) {
107
+ if (callback) {
108
+ callback(widget);
109
+ }
110
+ });
111
+ }
112
+ if (this._prev_ddlUrl && this._prev_ddlUrl !== this.ddlUrl()) {
113
+ // DDL has actually changed (not just a deserialization)
114
+ this
115
+ .clearContent()
116
+ ;
117
+ }
118
+ this._prev_ddlUrl = this.ddlUrl();
119
+ this._prev_databomb = this.databomb();
120
+
121
+ // Gather existing widgets for reuse ---
122
+ const widgetArr = [];
123
+ Persist.widgetArrayWalker(this.content(), function (w) {
124
+ widgetArr.push(w);
125
+ });
126
+ const widgetMap = d3Map(widgetArr, function (d) {
127
+ return d.id();
128
+ });
129
+ const removedMap = d3Map(widgetArr.filter(function (d) { return d.id().indexOf(d._idSeed) !== 0 && d.id().indexOf("_pe") !== 0; }), function (d) {
130
+ return d.id();
131
+ });
132
+
133
+ const context = this;
134
+ this._marshaller = new HipieDDL.Marshaller()
135
+ .proxyMappings(this.proxyMappings())
136
+ .clearDataOnUpdate(this.clearDataOnUpdate())
137
+ .propogateClear(this.propogateClear())
138
+ .missingDataString(this.missingDataString())
139
+ .widgetMappings(widgetMap)
140
+ .on("commsEvent", function (source, error) {
141
+ context.commsEvent.apply(context, arguments);
142
+ })
143
+ .on("vizEvent", function () {
144
+ context.vizEvent.apply(context, arguments);
145
+ })
146
+ ;
147
+
148
+ // Parse DDL ---
149
+ if (this.ddlUrl()[0] === "[" || this.ddlUrl()[0] === "{") {
150
+ this._marshaller.parse(this.ddlUrl(), postParse);
151
+ } else {
152
+ this._marshaller.url(this.ddlUrl(), postParse);
153
+ }
154
+
155
+ function postParse() {
156
+ context._gatherDashboards(context._marshaller, context.databomb());
157
+ // Remove existing widgets not used and prime popups ---
158
+ context._ddlVisualizations.forEach(function (viz) {
159
+ removedMap.remove(viz.id);
160
+ if (!context._marshaller.widgetMappings().get(viz.id)) {
161
+ // New widget ---
162
+ viz.newWidgetSurface = null;
163
+ if (viz.widget instanceof Surface || viz.widget.classID() === "composite_MegaChart") {
164
+ viz.newWidgetSurface = viz.widget;
165
+ } else {
166
+ viz.newWidgetSurface = new Surface()
167
+ .widget(viz.widget)
168
+ ;
169
+ }
170
+ viz.newWidgetSurface.title(viz.title);
171
+ viz.widget.size({ width: 0, height: 0 });
172
+ }
173
+ });
174
+ context._ddlPopupVisualizations.forEach(function (viz) {
175
+ removedMap.remove(viz.id);
176
+ viz.widget.classed({ flyout: true });
177
+ const targetVizs = viz.events.getUpdatesVisualizations();
178
+ targetVizs.forEach(function (targetViz) {
179
+ switch (targetViz.widget.classID()) {
180
+ case "composite_MegaChart":
181
+ if (!viz._flyoutButton) {
182
+ viz._flyoutButton = new FlyoutButton()
183
+ .classed({ "composite_MegaChart-flyout": true })
184
+ .title(viz.title)
185
+ .widget(viz.widget)
186
+ .autoClose(context.autoCloseFlyout())
187
+ ;
188
+ targetViz.widget.toolbarWidgets().push(viz._flyoutButton);
189
+ } else {
190
+ targetViz.widget.toolbarWidgets().push(viz._flyoutButton.reference());
191
+ }
192
+ break;
193
+ }
194
+ });
195
+ });
196
+ context._ddlModalVisualizations.forEach(function (viz) {
197
+ if (viz.widget.showCSV) {
198
+ viz.widget.showToolbar(true);
199
+ } else if (viz.widget.showToolbar) {
200
+ viz.widget.showToolbar(false);
201
+ }
202
+ viz._modalTarget = d3Select("body").append("div").node();
203
+ viz._modal = new Modal().target(viz._modalTarget)
204
+ .overflowX("hidden")
205
+ .overflowY("hidden")
206
+ ;
207
+ viz._modal._widget = viz.widget;
208
+ const origRender = viz.widget.render;
209
+ viz.widget.render = function (callback) {
210
+ if (this.__inModal) {
211
+ return origRender.apply(this, arguments);
212
+ }
213
+ if (this.data().length) {
214
+ this.__inModal = true;
215
+ const widgetContext = this;
216
+ const modalTitle = viz.widget.title();
217
+ if (viz.widget.showToolbar()) {
218
+ viz.widget.titleFontColor("transparent");
219
+ }
220
+ viz._modal
221
+ .title(modalTitle)
222
+ .visible(true)
223
+ .fixedWidth("80%")
224
+ .fixedHeight("80%")
225
+ .render(function (w) {
226
+ if (callback) {
227
+ callback(widgetContext);
228
+ }
229
+ setTimeout(function () {
230
+ widgetContext.__inModal = false;
231
+ }, 300); // Must be longer than debounce timeout...
232
+ });
233
+ } else {
234
+ if (callback) {
235
+ callback(this);
236
+ }
237
+ }
238
+ return this;
239
+ };
240
+ });
241
+ removedMap.each(function (key, value) {
242
+ context.clearContent(value);
243
+ });
244
+ context.populateContent();
245
+ if (context._initialState) {
246
+ context._marshaller.deserializeState(context._initialState.marshaller);
247
+ delete context._initialState;
248
+ BaseClass.render.call(context, callback);
249
+ } else {
250
+ BaseClass.render.call(context, function (widget) {
251
+ context._marshaller.primeData().then(function (response) {
252
+ if (callback) {
253
+ callback(widget);
254
+ }
255
+ });
256
+ });
257
+ }
258
+ }
259
+ }
260
+
261
+ primeData(state) {
262
+ if (this._marshaller) {
263
+ return this._marshaller.primeData(state);
264
+ }
265
+ return Promise.resolve();
266
+ }
267
+
268
+ dashboards() {
269
+ const retVal = {};
270
+ for (const key in this._marshaller.dashboards) {
271
+ retVal[key] = {};
272
+ this._marshaller.dashboards[key].visualizations.forEach(function (ddlViz) {
273
+ retVal[key][ddlViz.id] = ddlViz.widget;
274
+ }, this);
275
+ }
276
+ return retVal;
277
+ }
278
+
279
+ visualizations() {
280
+ return this._marshaller._visualizationArray.map(function (ddlViz) {
281
+ return ddlViz.newWidgetSurface || ddlViz.widget;
282
+ });
283
+ }
284
+
285
+ generateTestPage() {
286
+ if (this._marshaller) {
287
+ const context = this;
288
+ const state = Persist.serialize(context, function (widget, publishItem) {
289
+ if (publishItem.id === "databomb" || publishItem.id === "ddlUrl") {
290
+ return true;
291
+ }
292
+ return false;
293
+ });
294
+ const databomb = this._marshaller.createDatabomb();
295
+ const page = tpl
296
+ .replace("{VERSION}", Platform.version())
297
+ .replace("{STATE}", state)
298
+ .replace("{DDL}", context._marshaller._json.replace("WUID", "databomb"))
299
+ .replace("{DATABOMB}", JSON.stringify(databomb))
300
+ ;
301
+ Utility.downloadString("TEXT", page, "test");
302
+ }
303
+ }
304
+
305
+ vizEvent(sourceWidget, eventID, row, col, selected) {
306
+ }
307
+
308
+ commsEvent(ddlSource, eventID, request, response) {
309
+ }
310
+
311
+ state(_) {
312
+ if (!arguments.length) {
313
+ return this.serializeState();
314
+ }
315
+ this.deserializeState(_);
316
+ return this;
317
+ }
318
+
319
+ serializeState() {
320
+ return {
321
+ marshaller: this._marshaller ? this._marshaller.serializeState() : {}
322
+ };
323
+ }
324
+
325
+ deserializeState(state) {
326
+ if (this._marshaller) {
327
+ this._marshaller.deserializeState(state.marshaller);
328
+ } else {
329
+ this._initialState = state;
330
+ }
331
+ return this;
332
+ }
333
+
334
+ serializeRequests() {
335
+ let retVal = null;
336
+ this._ddlPopupVisualizations.concat(this._ddlVisualizations).forEach(function (ddlViz) {
337
+ if (ddlViz.hasSelection()) {
338
+ if (!retVal) {
339
+ retVal = {};
340
+ }
341
+ retVal[ddlViz.id] = ddlViz.reverseMappedSelection();
342
+ }
343
+ });
344
+ return retVal;
345
+ }
346
+ // HipieDDLMixin abstract methods ---
347
+ content: () => this;
348
+ populateContent: () => this;
349
+ clearContent: (value?) => this;
350
+
351
+ ddlUrl: { (): string; (_: string): HipieDDLMixin };
352
+ ddlUrl_exists: () => boolean;
353
+ databomb: { (): string; (_: string): HipieDDLMixin };
354
+ databomb_exists: () => boolean;
355
+ proxyMappings: { (): object; (_: object): HipieDDLMixin };
356
+ proxyMappings_exists: () => boolean;
357
+ timeout: { (): number; (_: number): HipieDDLMixin };
358
+ timeout_exists: () => boolean;
359
+ clearDataOnUpdate: { (): boolean; (_: boolean): HipieDDLMixin };
360
+ clearDataOnUpdate_exists: () => boolean;
361
+ propogateClear: { (): boolean; (_: boolean): HipieDDLMixin };
362
+ propogateClear_exists: () => boolean;
363
+ missingDataString: { (): string; (_: string): HipieDDLMixin };
364
+ missingDataString_exists: () => boolean;
365
+ autoCloseFlyout: { (): boolean; (_: boolean): HipieDDLMixin };
366
+ autoCloseFlyout_exists: () => boolean;
367
+ disableModals: { (): boolean; (_: boolean): HipieDDLMixin };
368
+ }
369
+ HipieDDLMixin.prototype.mixin(PropertyExt);
370
+ HipieDDLMixin.prototype._class += " marshaller_HipieDDLMixin";
371
+
372
+ HipieDDLMixin.prototype.publish("ddlUrl", "", "string", "DDL URL", null, { tags: ["Private"] });
373
+ HipieDDLMixin.prototype.publish("databomb", "", "string", "Data Bomb", null, { tags: ["Private"] });
374
+ HipieDDLMixin.prototype.publish("proxyMappings", {}, "object", "Proxy Mappings", null, { tags: ["Private"] });
375
+ HipieDDLMixin.prototype.publish("timeout", null, "number", "Timout (seconds)", null, { optional: true });
376
+ HipieDDLMixin.prototype.publish("clearDataOnUpdate", true, "boolean", "Clear data prior to refresh", null);
377
+ HipieDDLMixin.prototype.publish("propogateClear", false, "boolean", "Propogate clear to dependent visualizations", null);
378
+ HipieDDLMixin.prototype.publish("missingDataString", "***MISSING***", "string", "Missing data display string");
379
+ HipieDDLMixin.prototype.publish("autoCloseFlyout", true, "boolean", "Auto Close Flyout Filters");
380
+ HipieDDLMixin.prototype.publish("disableModals", false, "boolean", "If true, widgets with 'modalIfData' will display as standard Grid widgets");