@hpcc-js/marshaller 2.28.5 → 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.
Files changed (55) hide show
  1. package/LICENSE +43 -43
  2. package/dist/index.es6.js +22 -22
  3. package/dist/index.es6.js.map +1 -1
  4. package/dist/index.js +20 -20
  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 +16 -16
  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,465 +1,465 @@
1
- import { JSONEditor } from "@hpcc-js/codemirror";
2
- import { Button, PropertyExt, publish, publishProxy, SelectionBar, SelectionButton, Spacer } from "@hpcc-js/common";
3
- import { DatasourceTable } from "@hpcc-js/dgrid";
4
- import { ChartPanel } from "@hpcc-js/layout";
5
- import { PropertyEditor } from "@hpcc-js/other";
6
- import { SplitPanel, TabPanel } from "@hpcc-js/phosphor";
7
- import { Activity } from "./activities/activity";
8
- import { DatasourceAdapt } from "./activities/databomb";
9
- import { Datasource } from "./activities/datasource";
10
- import { DSPicker } from "./activities/dspicker";
11
- import { Filters } from "./activities/filter";
12
- import { GroupBy } from "./activities/groupby";
13
- import { Limit } from "./activities/limit";
14
- import { Mappings, Project } from "./activities/project";
15
- import { Sort } from "./activities/sort";
16
- import { Element as ModelElement, IElementError, State } from "./model/element";
17
- import { Visualization } from "./model/visualization";
18
-
19
- import "../../src/ddl2/pipelinePanel.css";
20
-
21
- class PipelineSelectionButton extends SelectionButton {
22
-
23
- _label: string;
24
- label(): string;
25
- label(_: string): this;
26
- label(_?: string): string | this {
27
- if (!arguments.length) return this._label;
28
- this._label = _;
29
- this.tooltip(_);
30
- return this;
31
- }
32
-
33
- _elementErrors: IElementError[] = [];
34
- errors(): IElementError[];
35
- errors(_: IElementError[]): this;
36
- errors(_?: IElementError[]): IElementError[] | this {
37
- if (!arguments.length) return this._elementErrors;
38
- this._elementErrors = _;
39
- this.classed("error", _.length > 0);
40
- // this.element().classed("error", _.length > 0);
41
- if (_.length) {
42
- this.tooltip(_.map(err => {
43
- const errSourceParts = err.source.split(".");
44
- errSourceParts.splice(0, 1);
45
- return `${errSourceParts.join(".")}: ${err.msg}`;
46
- }).join("\n"));
47
- } else {
48
- this.tooltip(this._label);
49
- }
50
- this.render();
51
- return this;
52
- }
53
- }
54
-
55
- class PipelinePanel extends ChartPanel {
56
- _owner: PipelineSplitPanel;
57
-
58
- datasource = new PipelineSelectionButton().faChar("fa-database").label("Datasource").selected(true);
59
- filter = new PipelineSelectionButton().faChar("fa-filter").label("Filter");
60
- project = new PipelineSelectionButton().faChar("fa-random").label("Project");
61
- groupBy = new PipelineSelectionButton().faChar("fa-object-group").label("Group By");
62
- sort = new PipelineSelectionButton().faChar("fa-sort-alpha-asc").label("Sort");
63
- limit = new PipelineSelectionButton().faChar("fa-list-ol").label("Limit");
64
- mappings = new PipelineSelectionButton().faChar("fa-random").label("Mappings");
65
- chartPanel = new PipelineSelectionButton().faChar("fa-area-chart").label("Visualization");
66
- state = new PipelineSelectionButton().faChar("fa-check-square-o").label("State");
67
- debug = new PipelineSelectionButton().faChar("fa-bug").label("Debug");
68
- all = new PipelineSelectionButton().faChar("fa-list").label("All");
69
-
70
- _propEditor: PropertyEditor = new PropertyEditor()
71
- .show_header(false)
72
- .show_settings(false)
73
- .showFields(false)
74
- ;
75
-
76
- private _buttons = [
77
- this.datasource,
78
- this.filter,
79
- this.project,
80
- this.groupBy,
81
- this.sort,
82
- this.limit,
83
- new Spacer(),
84
- this.mappings,
85
- this.chartPanel,
86
- new Spacer(),
87
- this.state,
88
- this.debug,
89
- new Spacer(),
90
- this.all
91
- ];
92
- _pipelineButton: PipelineSelectionButton = this.datasource;
93
- private _pipelineSelection = new SelectionBar()
94
- .buttons(this._buttons).on("selected", sb => {
95
- this._pipelineButton = sb;
96
- this.title(sb.label()).render();
97
- });
98
-
99
- @publish([], "array", "Disabled pipeline items")
100
- disableActivities: publish<this, string[]>;
101
-
102
- constructor(owner: PipelineSplitPanel) {
103
- super();
104
- this._owner = owner;
105
- this.buttons([this._pipelineSelection]);
106
- this.title(this.datasource.label());
107
- super.widget(this._propEditor);
108
- this._propEditor.monitor((id: string, newValue: any, oldValue: any, source: PropertyExt) => {
109
- if (source !== this._propEditor) {
110
- this.propChanged(id, newValue, oldValue, source);
111
- this.updateState();
112
- }
113
- });
114
- }
115
-
116
- selectionButtons(): PipelineSelectionButton[] {
117
- return this._pipelineSelection.buttons().filter(b => b instanceof PipelineSelectionButton) as PipelineSelectionButton[];
118
- }
119
-
120
- private _propExt: PropertyExt;
121
- propExt(): PropertyExt;
122
- propExt(_: PropertyExt): this;
123
- propExt(_?: PropertyExt): PropertyExt | this {
124
- if (!arguments.length) return this._propExt;
125
- this._propExt = _;
126
- return this;
127
- }
128
-
129
- private peAsDatasource(): Datasource {
130
- if (this._propExt instanceof Datasource) {
131
- return this._propExt;
132
- } else if (this._propExt instanceof DSPicker) {
133
- return this._propExt;
134
- } else if (this._propExt instanceof ModelElement) {
135
- return this._propExt.hipiePipeline().datasource();
136
- }
137
- }
138
-
139
- private peAsFilter(): Filters {
140
- if (this._propExt instanceof Filters) {
141
- return this._propExt;
142
- } else if (this._propExt instanceof ModelElement) {
143
- return this._propExt.hipiePipeline().filters();
144
- }
145
- }
146
-
147
- private peAsProject(): Project {
148
- if (this._propExt instanceof Project) {
149
- return this._propExt;
150
- } else if (this._propExt instanceof ModelElement) {
151
- return this._propExt.hipiePipeline().project();
152
- }
153
- }
154
-
155
- private peAsGroupBy(): GroupBy {
156
- if (this._propExt instanceof GroupBy) {
157
- return this._propExt;
158
- } else if (this._propExt instanceof ModelElement) {
159
- return this._propExt.hipiePipeline().groupBy();
160
- }
161
- }
162
-
163
- private peAsSort(): Sort {
164
- if (this._propExt instanceof Sort) {
165
- return this._propExt;
166
- } else if (this._propExt instanceof ModelElement) {
167
- return this._propExt.hipiePipeline().sort();
168
- }
169
- }
170
-
171
- private peAsLimit(): Limit {
172
- if (this._propExt instanceof Limit) {
173
- return this._propExt;
174
- } else if (this._propExt instanceof ModelElement) {
175
- return this._propExt.hipiePipeline().limit();
176
- }
177
- }
178
-
179
- private peAsMappings(): Mappings {
180
- if (this._propExt instanceof Mappings) {
181
- return this._propExt;
182
- } else if (this._propExt instanceof ModelElement) {
183
- return this._propExt.visualization().mappings();
184
- } else if (this._propExt instanceof Visualization) {
185
- return this._propExt.mappings();
186
- }
187
- }
188
-
189
- private peAsChartPanel(): ChartPanel | Visualization {
190
- if (this._propExt instanceof ChartPanel) {
191
- return this._propExt;
192
- } else if (this._propExt instanceof Visualization) {
193
- return this._propExt;
194
- } else if (this._propExt instanceof ModelElement) {
195
- return this._propExt.visualization();
196
- }
197
- }
198
-
199
- private peAsState(): State {
200
- if (this._propExt instanceof State) {
201
- return this._propExt;
202
- } else if (this._propExt instanceof ModelElement) {
203
- return this._propExt.state();
204
- }
205
- }
206
-
207
- selectionButton(): PipelineSelectionButton {
208
- if (this._pipelineButton && this._pipelineButton.enabled()) {
209
- return this._pipelineButton;
210
- }
211
- for (const pb of this.selectionButtons()) {
212
- if (pb.enabled()) {
213
- pb.selected(true);
214
- return pb;
215
- }
216
- }
217
- return undefined;
218
- }
219
-
220
- _prevPropExt: PropertyExt;
221
- _prevPipelineButton: SelectionButton;
222
- update(domNode, element) {
223
- super.update(domNode, element);
224
- this.updateState();
225
- const pipelineButton = this.selectionButton();
226
- if (this._prevPropExt !== this._propExt || this._prevPipelineButton !== pipelineButton) {
227
- this._prevPropExt = this._propExt;
228
- this._prevPipelineButton = pipelineButton;
229
- if (this._propExt && pipelineButton) {
230
- switch (pipelineButton) {
231
- case this.datasource:
232
- this._propEditor.widget(this.peAsDatasource());
233
- break;
234
- case this.filter:
235
- this._propEditor.widget(this.peAsFilter());
236
- break;
237
- case this.project:
238
- this._propEditor.widget(this.peAsProject());
239
- break;
240
- case this.groupBy:
241
- this._propEditor.widget(this.peAsGroupBy());
242
- break;
243
- case this.sort:
244
- this._propEditor.widget(this.peAsSort());
245
- break;
246
- case this.limit:
247
- this._propEditor.widget(this.peAsLimit());
248
- break;
249
- case this.mappings:
250
- this._propEditor.widget(this.peAsMappings());
251
- break;
252
- case this.chartPanel:
253
- this._propEditor.widget(this.peAsChartPanel());
254
- break;
255
- case this.state:
256
- this._propEditor.widget(this.peAsState());
257
- break;
258
- case this.all:
259
- this._propEditor.widget(this._propExt);
260
- break;
261
- }
262
- } else {
263
- this._propEditor.widget(undefined);
264
- }
265
- this._owner.loadPreview(this._propEditor.widget());
266
- }
267
- }
268
-
269
- updateButtonState(pe, sb) {
270
- sb.enabled(!!pe);
271
- sb.errors(!!pe && pe.validate() || []);
272
- }
273
-
274
- updateState() {
275
- this.selectionButtons().forEach(sb => {
276
- if (sb instanceof PipelineSelectionButton) {
277
- if (this.disableActivities().indexOf(sb.label()) >= 0) {
278
- this.updateButtonState(undefined, sb);
279
- return;
280
- }
281
- }
282
-
283
- switch (sb) {
284
- case this.datasource:
285
- this.updateButtonState(this.peAsDatasource(), sb);
286
- break;
287
- case this.filter:
288
- this.updateButtonState(this.peAsFilter(), sb);
289
- break;
290
- case this.project:
291
- this.updateButtonState(this.peAsProject(), sb);
292
- break;
293
- case this.groupBy:
294
- this.updateButtonState(this.peAsGroupBy(), sb);
295
- break;
296
- case this.sort:
297
- this.updateButtonState(this.peAsSort(), sb);
298
- break;
299
- case this.limit:
300
- this.updateButtonState(this.peAsLimit(), sb);
301
- break;
302
- case this.mappings:
303
- this.updateButtonState(this.peAsMappings(), sb);
304
- break;
305
- case this.chartPanel:
306
- const cp = this.peAsChartPanel();
307
- sb.enabled(!!cp);
308
- break;
309
- case this.state:
310
- const st = this.peAsState();
311
- sb.enabled(!!st);
312
- break;
313
- case this.debug:
314
- sb.enabled(false);
315
- break;
316
- case this.all:
317
- sb.enabled(!!this._propExt);
318
- break;
319
- }
320
- if (sb.selected()) {
321
- this.title(sb.enabled() ? sb.label() : "");
322
- }
323
- });
324
- }
325
-
326
- // Events ---
327
- propChanged(id: string, newValue: any, oldValue: any, source: PropertyExt) {
328
- }
329
- }
330
- PipelinePanel.prototype._class += " marshaller_PipelinePanel";
331
-
332
- class DDLPreview extends ChartPanel {
333
-
334
- private _save = new Button().faChar("fa-save").tooltip("Save")
335
- .on("click", () => {
336
- const activity = this.activity();
337
- if (activity && (activity as any).fromDDL) {
338
- (activity as any).fromDDL(this._jsonEditor.json());
339
- }
340
- this.updateToolbar();
341
- });
342
-
343
- private _reset = new Button().faChar("fa-undo").tooltip("Reset")
344
- .on("click", () => {
345
- this._jsonEditor
346
- .text(this.jsonText())
347
- .lazyRender()
348
- ;
349
- this.updateToolbar();
350
- });
351
-
352
- private _jsonEditor = new JSONEditor()
353
- .on("changes", (changes: object[]) => {
354
- this.updateToolbar();
355
- });
356
-
357
- constructor() {
358
- super();
359
- this._titleBar.buttons([this._save, this._reset]);
360
- this.widget(this._jsonEditor);
361
- }
362
-
363
- private _activity: PropertyExt;
364
- activity(_: PropertyExt): this;
365
- activity(): PropertyExt;
366
- activity(_?: PropertyExt): PropertyExt | this {
367
- if (_ === void 0) return this._activity;
368
- if (this._activity !== _) {
369
- this._activity = _;
370
- delete this._prevJson;
371
- }
372
- return this;
373
- }
374
-
375
- jsonText(): string {
376
- const activity = this.activity();
377
- return activity && (activity as any).toDDL ? JSON.stringify((activity as any).toDDL(), undefined, 4) : "";
378
- }
379
-
380
- private _prevJson: string;
381
- update(domNode, element) {
382
- super.update(domNode, element);
383
- const json = this.jsonText();
384
- const editorJson = this._jsonEditor.text();
385
- if ((this._prevJson === undefined || this._prevJson === editorJson) && this._prevJson !== json) {
386
- this._prevJson = json;
387
- this._jsonEditor.text(json);
388
- }
389
- this.updateToolbar();
390
- }
391
-
392
- updateToolbar() {
393
- const activity = this.activity() as any;
394
- const json = this.jsonText();
395
- const editorJson = this._jsonEditor.text();
396
- this._save.enabled(activity && activity.fromDDL && json !== editorJson).lazyRender();
397
- this._reset.enabled(json !== editorJson).lazyRender();
398
- }
399
- }
400
-
401
- export class PipelineSplitPanel extends SplitPanel {
402
- private _rhsPropsPanel = new PipelinePanel(this).on("propChanged", (id: string, newValue: any, oldValue: any, source: PropertyExt) => {
403
- this.propChanged(id, newValue, oldValue, source);
404
- });
405
- private _previewPanel = new TabPanel();
406
- private _rhsDDLPreview = new DDLPreview();
407
- private _rhsDataPreview = new DatasourceTable().pagination(true);
408
-
409
- @publishProxy("_rhsPropsPanel")
410
- disableActivities: publish<this, string[]>;
411
-
412
- constructor() {
413
- super();
414
- this._previewPanel
415
- .addWidget(this._rhsDataPreview, "Data")
416
- .addWidget(this._rhsDDLPreview, "DDL")
417
- ;
418
- this
419
- .addWidget(this._rhsPropsPanel)
420
- .addWidget(this._previewPanel)
421
- ;
422
- }
423
-
424
- loadDataProps(pe: PropertyExt) {
425
- this._rhsPropsPanel
426
- .propExt(pe)
427
- .render()
428
- ;
429
- }
430
-
431
- loadPreview(activity: undefined | PropertyExt) {
432
- activity = activity instanceof Visualization ? activity.mappings() : activity;
433
- this._rhsDataPreview
434
- .datasource(new DatasourceAdapt(activity instanceof Activity ? activity : undefined))
435
- .lazyRender()
436
- ;
437
- this._rhsDDLPreview
438
- .activity(activity) // instanceof DSPicker ? activity.datasourceRef() : activity)
439
- .lazyRender()
440
- ;
441
- }
442
-
443
- refreshPreview() {
444
- const ds = this._rhsDataPreview.datasource() as DatasourceAdapt;
445
- if (ds) {
446
- ds.exec().then(() => {
447
- this._rhsDataPreview
448
- .invalidate()
449
- .lazyRender()
450
- ;
451
- this._rhsDDLPreview
452
- .lazyRender()
453
- ;
454
- });
455
- } else {
456
- this._rhsDDLPreview
457
- .lazyRender()
458
- ;
459
- }
460
- }
461
-
462
- // Events ---
463
- propChanged(id: string, newValue: any, oldValue: any, source: PropertyExt) {
464
- }
465
- }
1
+ import { JSONEditor } from "@hpcc-js/codemirror";
2
+ import { Button, PropertyExt, publish, publishProxy, SelectionBar, SelectionButton, Spacer } from "@hpcc-js/common";
3
+ import { DatasourceTable } from "@hpcc-js/dgrid";
4
+ import { ChartPanel } from "@hpcc-js/layout";
5
+ import { PropertyEditor } from "@hpcc-js/other";
6
+ import { SplitPanel, TabPanel } from "@hpcc-js/phosphor";
7
+ import { Activity } from "./activities/activity";
8
+ import { DatasourceAdapt } from "./activities/databomb";
9
+ import { Datasource } from "./activities/datasource";
10
+ import { DSPicker } from "./activities/dspicker";
11
+ import { Filters } from "./activities/filter";
12
+ import { GroupBy } from "./activities/groupby";
13
+ import { Limit } from "./activities/limit";
14
+ import { Mappings, Project } from "./activities/project";
15
+ import { Sort } from "./activities/sort";
16
+ import { Element as ModelElement, IElementError, State } from "./model/element";
17
+ import { Visualization } from "./model/visualization";
18
+
19
+ import "../../src/ddl2/pipelinePanel.css";
20
+
21
+ class PipelineSelectionButton extends SelectionButton {
22
+
23
+ _label: string;
24
+ label(): string;
25
+ label(_: string): this;
26
+ label(_?: string): string | this {
27
+ if (!arguments.length) return this._label;
28
+ this._label = _;
29
+ this.tooltip(_);
30
+ return this;
31
+ }
32
+
33
+ _elementErrors: IElementError[] = [];
34
+ errors(): IElementError[];
35
+ errors(_: IElementError[]): this;
36
+ errors(_?: IElementError[]): IElementError[] | this {
37
+ if (!arguments.length) return this._elementErrors;
38
+ this._elementErrors = _;
39
+ this.classed("error", _.length > 0);
40
+ // this.element().classed("error", _.length > 0);
41
+ if (_.length) {
42
+ this.tooltip(_.map(err => {
43
+ const errSourceParts = err.source.split(".");
44
+ errSourceParts.splice(0, 1);
45
+ return `${errSourceParts.join(".")}: ${err.msg}`;
46
+ }).join("\n"));
47
+ } else {
48
+ this.tooltip(this._label);
49
+ }
50
+ this.render();
51
+ return this;
52
+ }
53
+ }
54
+
55
+ class PipelinePanel extends ChartPanel {
56
+ _owner: PipelineSplitPanel;
57
+
58
+ datasource = new PipelineSelectionButton().faChar("fa-database").label("Datasource").selected(true);
59
+ filter = new PipelineSelectionButton().faChar("fa-filter").label("Filter");
60
+ project = new PipelineSelectionButton().faChar("fa-random").label("Project");
61
+ groupBy = new PipelineSelectionButton().faChar("fa-object-group").label("Group By");
62
+ sort = new PipelineSelectionButton().faChar("fa-sort-alpha-asc").label("Sort");
63
+ limit = new PipelineSelectionButton().faChar("fa-list-ol").label("Limit");
64
+ mappings = new PipelineSelectionButton().faChar("fa-random").label("Mappings");
65
+ chartPanel = new PipelineSelectionButton().faChar("fa-area-chart").label("Visualization");
66
+ state = new PipelineSelectionButton().faChar("fa-check-square-o").label("State");
67
+ debug = new PipelineSelectionButton().faChar("fa-bug").label("Debug");
68
+ all = new PipelineSelectionButton().faChar("fa-list").label("All");
69
+
70
+ _propEditor: PropertyEditor = new PropertyEditor()
71
+ .show_header(false)
72
+ .show_settings(false)
73
+ .showFields(false)
74
+ ;
75
+
76
+ private _buttons = [
77
+ this.datasource,
78
+ this.filter,
79
+ this.project,
80
+ this.groupBy,
81
+ this.sort,
82
+ this.limit,
83
+ new Spacer(),
84
+ this.mappings,
85
+ this.chartPanel,
86
+ new Spacer(),
87
+ this.state,
88
+ this.debug,
89
+ new Spacer(),
90
+ this.all
91
+ ];
92
+ _pipelineButton: PipelineSelectionButton = this.datasource;
93
+ private _pipelineSelection = new SelectionBar()
94
+ .buttons(this._buttons).on("selected", sb => {
95
+ this._pipelineButton = sb;
96
+ this.title(sb.label()).render();
97
+ });
98
+
99
+ @publish([], "array", "Disabled pipeline items")
100
+ disableActivities: publish<this, string[]>;
101
+
102
+ constructor(owner: PipelineSplitPanel) {
103
+ super();
104
+ this._owner = owner;
105
+ this.buttons([this._pipelineSelection]);
106
+ this.title(this.datasource.label());
107
+ super.widget(this._propEditor);
108
+ this._propEditor.monitor((id: string, newValue: any, oldValue: any, source: PropertyExt) => {
109
+ if (source !== this._propEditor) {
110
+ this.propChanged(id, newValue, oldValue, source);
111
+ this.updateState();
112
+ }
113
+ });
114
+ }
115
+
116
+ selectionButtons(): PipelineSelectionButton[] {
117
+ return this._pipelineSelection.buttons().filter(b => b instanceof PipelineSelectionButton) as PipelineSelectionButton[];
118
+ }
119
+
120
+ private _propExt: PropertyExt;
121
+ propExt(): PropertyExt;
122
+ propExt(_: PropertyExt): this;
123
+ propExt(_?: PropertyExt): PropertyExt | this {
124
+ if (!arguments.length) return this._propExt;
125
+ this._propExt = _;
126
+ return this;
127
+ }
128
+
129
+ private peAsDatasource(): Datasource {
130
+ if (this._propExt instanceof Datasource) {
131
+ return this._propExt;
132
+ } else if (this._propExt instanceof DSPicker) {
133
+ return this._propExt;
134
+ } else if (this._propExt instanceof ModelElement) {
135
+ return this._propExt.hipiePipeline().datasource();
136
+ }
137
+ }
138
+
139
+ private peAsFilter(): Filters {
140
+ if (this._propExt instanceof Filters) {
141
+ return this._propExt;
142
+ } else if (this._propExt instanceof ModelElement) {
143
+ return this._propExt.hipiePipeline().filters();
144
+ }
145
+ }
146
+
147
+ private peAsProject(): Project {
148
+ if (this._propExt instanceof Project) {
149
+ return this._propExt;
150
+ } else if (this._propExt instanceof ModelElement) {
151
+ return this._propExt.hipiePipeline().project();
152
+ }
153
+ }
154
+
155
+ private peAsGroupBy(): GroupBy {
156
+ if (this._propExt instanceof GroupBy) {
157
+ return this._propExt;
158
+ } else if (this._propExt instanceof ModelElement) {
159
+ return this._propExt.hipiePipeline().groupBy();
160
+ }
161
+ }
162
+
163
+ private peAsSort(): Sort {
164
+ if (this._propExt instanceof Sort) {
165
+ return this._propExt;
166
+ } else if (this._propExt instanceof ModelElement) {
167
+ return this._propExt.hipiePipeline().sort();
168
+ }
169
+ }
170
+
171
+ private peAsLimit(): Limit {
172
+ if (this._propExt instanceof Limit) {
173
+ return this._propExt;
174
+ } else if (this._propExt instanceof ModelElement) {
175
+ return this._propExt.hipiePipeline().limit();
176
+ }
177
+ }
178
+
179
+ private peAsMappings(): Mappings {
180
+ if (this._propExt instanceof Mappings) {
181
+ return this._propExt;
182
+ } else if (this._propExt instanceof ModelElement) {
183
+ return this._propExt.visualization().mappings();
184
+ } else if (this._propExt instanceof Visualization) {
185
+ return this._propExt.mappings();
186
+ }
187
+ }
188
+
189
+ private peAsChartPanel(): ChartPanel | Visualization {
190
+ if (this._propExt instanceof ChartPanel) {
191
+ return this._propExt;
192
+ } else if (this._propExt instanceof Visualization) {
193
+ return this._propExt;
194
+ } else if (this._propExt instanceof ModelElement) {
195
+ return this._propExt.visualization();
196
+ }
197
+ }
198
+
199
+ private peAsState(): State {
200
+ if (this._propExt instanceof State) {
201
+ return this._propExt;
202
+ } else if (this._propExt instanceof ModelElement) {
203
+ return this._propExt.state();
204
+ }
205
+ }
206
+
207
+ selectionButton(): PipelineSelectionButton {
208
+ if (this._pipelineButton && this._pipelineButton.enabled()) {
209
+ return this._pipelineButton;
210
+ }
211
+ for (const pb of this.selectionButtons()) {
212
+ if (pb.enabled()) {
213
+ pb.selected(true);
214
+ return pb;
215
+ }
216
+ }
217
+ return undefined;
218
+ }
219
+
220
+ _prevPropExt: PropertyExt;
221
+ _prevPipelineButton: SelectionButton;
222
+ update(domNode, element) {
223
+ super.update(domNode, element);
224
+ this.updateState();
225
+ const pipelineButton = this.selectionButton();
226
+ if (this._prevPropExt !== this._propExt || this._prevPipelineButton !== pipelineButton) {
227
+ this._prevPropExt = this._propExt;
228
+ this._prevPipelineButton = pipelineButton;
229
+ if (this._propExt && pipelineButton) {
230
+ switch (pipelineButton) {
231
+ case this.datasource:
232
+ this._propEditor.widget(this.peAsDatasource());
233
+ break;
234
+ case this.filter:
235
+ this._propEditor.widget(this.peAsFilter());
236
+ break;
237
+ case this.project:
238
+ this._propEditor.widget(this.peAsProject());
239
+ break;
240
+ case this.groupBy:
241
+ this._propEditor.widget(this.peAsGroupBy());
242
+ break;
243
+ case this.sort:
244
+ this._propEditor.widget(this.peAsSort());
245
+ break;
246
+ case this.limit:
247
+ this._propEditor.widget(this.peAsLimit());
248
+ break;
249
+ case this.mappings:
250
+ this._propEditor.widget(this.peAsMappings());
251
+ break;
252
+ case this.chartPanel:
253
+ this._propEditor.widget(this.peAsChartPanel());
254
+ break;
255
+ case this.state:
256
+ this._propEditor.widget(this.peAsState());
257
+ break;
258
+ case this.all:
259
+ this._propEditor.widget(this._propExt);
260
+ break;
261
+ }
262
+ } else {
263
+ this._propEditor.widget(undefined);
264
+ }
265
+ this._owner.loadPreview(this._propEditor.widget());
266
+ }
267
+ }
268
+
269
+ updateButtonState(pe, sb) {
270
+ sb.enabled(!!pe);
271
+ sb.errors(!!pe && pe.validate() || []);
272
+ }
273
+
274
+ updateState() {
275
+ this.selectionButtons().forEach(sb => {
276
+ if (sb instanceof PipelineSelectionButton) {
277
+ if (this.disableActivities().indexOf(sb.label()) >= 0) {
278
+ this.updateButtonState(undefined, sb);
279
+ return;
280
+ }
281
+ }
282
+
283
+ switch (sb) {
284
+ case this.datasource:
285
+ this.updateButtonState(this.peAsDatasource(), sb);
286
+ break;
287
+ case this.filter:
288
+ this.updateButtonState(this.peAsFilter(), sb);
289
+ break;
290
+ case this.project:
291
+ this.updateButtonState(this.peAsProject(), sb);
292
+ break;
293
+ case this.groupBy:
294
+ this.updateButtonState(this.peAsGroupBy(), sb);
295
+ break;
296
+ case this.sort:
297
+ this.updateButtonState(this.peAsSort(), sb);
298
+ break;
299
+ case this.limit:
300
+ this.updateButtonState(this.peAsLimit(), sb);
301
+ break;
302
+ case this.mappings:
303
+ this.updateButtonState(this.peAsMappings(), sb);
304
+ break;
305
+ case this.chartPanel:
306
+ const cp = this.peAsChartPanel();
307
+ sb.enabled(!!cp);
308
+ break;
309
+ case this.state:
310
+ const st = this.peAsState();
311
+ sb.enabled(!!st);
312
+ break;
313
+ case this.debug:
314
+ sb.enabled(false);
315
+ break;
316
+ case this.all:
317
+ sb.enabled(!!this._propExt);
318
+ break;
319
+ }
320
+ if (sb.selected()) {
321
+ this.title(sb.enabled() ? sb.label() : "");
322
+ }
323
+ });
324
+ }
325
+
326
+ // Events ---
327
+ propChanged(id: string, newValue: any, oldValue: any, source: PropertyExt) {
328
+ }
329
+ }
330
+ PipelinePanel.prototype._class += " marshaller_PipelinePanel";
331
+
332
+ class DDLPreview extends ChartPanel {
333
+
334
+ private _save = new Button().faChar("fa-save").tooltip("Save")
335
+ .on("click", () => {
336
+ const activity = this.activity();
337
+ if (activity && (activity as any).fromDDL) {
338
+ (activity as any).fromDDL(this._jsonEditor.json());
339
+ }
340
+ this.updateToolbar();
341
+ });
342
+
343
+ private _reset = new Button().faChar("fa-undo").tooltip("Reset")
344
+ .on("click", () => {
345
+ this._jsonEditor
346
+ .text(this.jsonText())
347
+ .lazyRender()
348
+ ;
349
+ this.updateToolbar();
350
+ });
351
+
352
+ private _jsonEditor = new JSONEditor()
353
+ .on("changes", (changes: object[]) => {
354
+ this.updateToolbar();
355
+ });
356
+
357
+ constructor() {
358
+ super();
359
+ this._titleBar.buttons([this._save, this._reset]);
360
+ this.widget(this._jsonEditor);
361
+ }
362
+
363
+ private _activity: PropertyExt;
364
+ activity(_: PropertyExt): this;
365
+ activity(): PropertyExt;
366
+ activity(_?: PropertyExt): PropertyExt | this {
367
+ if (_ === void 0) return this._activity;
368
+ if (this._activity !== _) {
369
+ this._activity = _;
370
+ delete this._prevJson;
371
+ }
372
+ return this;
373
+ }
374
+
375
+ jsonText(): string {
376
+ const activity = this.activity();
377
+ return activity && (activity as any).toDDL ? JSON.stringify((activity as any).toDDL(), undefined, 4) : "";
378
+ }
379
+
380
+ private _prevJson: string;
381
+ update(domNode, element) {
382
+ super.update(domNode, element);
383
+ const json = this.jsonText();
384
+ const editorJson = this._jsonEditor.text();
385
+ if ((this._prevJson === undefined || this._prevJson === editorJson) && this._prevJson !== json) {
386
+ this._prevJson = json;
387
+ this._jsonEditor.text(json);
388
+ }
389
+ this.updateToolbar();
390
+ }
391
+
392
+ updateToolbar() {
393
+ const activity = this.activity() as any;
394
+ const json = this.jsonText();
395
+ const editorJson = this._jsonEditor.text();
396
+ this._save.enabled(activity && activity.fromDDL && json !== editorJson).lazyRender();
397
+ this._reset.enabled(json !== editorJson).lazyRender();
398
+ }
399
+ }
400
+
401
+ export class PipelineSplitPanel extends SplitPanel {
402
+ private _rhsPropsPanel = new PipelinePanel(this).on("propChanged", (id: string, newValue: any, oldValue: any, source: PropertyExt) => {
403
+ this.propChanged(id, newValue, oldValue, source);
404
+ });
405
+ private _previewPanel = new TabPanel();
406
+ private _rhsDDLPreview = new DDLPreview();
407
+ private _rhsDataPreview = new DatasourceTable().pagination(true);
408
+
409
+ @publishProxy("_rhsPropsPanel")
410
+ disableActivities: publish<this, string[]>;
411
+
412
+ constructor() {
413
+ super();
414
+ this._previewPanel
415
+ .addWidget(this._rhsDataPreview, "Data")
416
+ .addWidget(this._rhsDDLPreview, "DDL")
417
+ ;
418
+ this
419
+ .addWidget(this._rhsPropsPanel)
420
+ .addWidget(this._previewPanel)
421
+ ;
422
+ }
423
+
424
+ loadDataProps(pe: PropertyExt) {
425
+ this._rhsPropsPanel
426
+ .propExt(pe)
427
+ .render()
428
+ ;
429
+ }
430
+
431
+ loadPreview(activity: undefined | PropertyExt) {
432
+ activity = activity instanceof Visualization ? activity.mappings() : activity;
433
+ this._rhsDataPreview
434
+ .datasource(new DatasourceAdapt(activity instanceof Activity ? activity : undefined))
435
+ .lazyRender()
436
+ ;
437
+ this._rhsDDLPreview
438
+ .activity(activity) // instanceof DSPicker ? activity.datasourceRef() : activity)
439
+ .lazyRender()
440
+ ;
441
+ }
442
+
443
+ refreshPreview() {
444
+ const ds = this._rhsDataPreview.datasource() as DatasourceAdapt;
445
+ if (ds) {
446
+ ds.exec().then(() => {
447
+ this._rhsDataPreview
448
+ .invalidate()
449
+ .lazyRender()
450
+ ;
451
+ this._rhsDDLPreview
452
+ .lazyRender()
453
+ ;
454
+ });
455
+ } else {
456
+ this._rhsDDLPreview
457
+ .lazyRender()
458
+ ;
459
+ }
460
+ }
461
+
462
+ // Events ---
463
+ propChanged(id: string, newValue: any, oldValue: any, source: PropertyExt) {
464
+ }
465
+ }