@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.
- package/LICENSE +43 -43
- package/dist/index.es6.js +25 -13
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js +25 -13
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/package.json +12 -12
- 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
- package/types/__package__.d.ts +2 -2
- package/types-3.4/__package__.d.ts +2 -2
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import { Widget } from "@hpcc-js/common";
|
|
2
|
-
import { DockPanel, IClosable, WidgetAdapter } from "@hpcc-js/phosphor";
|
|
3
|
-
import { compare } from "@hpcc-js/util";
|
|
4
|
-
import { select as d3Select } from "d3-selection";
|
|
5
|
-
import { Element, ElementContainer } from "./model/element";
|
|
6
|
-
import { IVizPopupPanelOwner } from "./model/vizChartPanel";
|
|
7
|
-
import { PopupManager } from "./PopupManager";
|
|
8
|
-
|
|
9
|
-
export class DashboardDockPanel extends DockPanel implements IClosable, IVizPopupPanelOwner {
|
|
10
|
-
|
|
11
|
-
constructor(private _ec: ElementContainer) {
|
|
12
|
-
super();
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
tabTitle(element: Element): string {
|
|
17
|
-
if (this.hideSingleTabs()) {
|
|
18
|
-
return element.visualization().title ? element.visualization().title() : element.visualization().id();
|
|
19
|
-
}
|
|
20
|
-
return element.id();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
titleClassed(wa: WidgetAdapter, classID: string, include: boolean) {
|
|
24
|
-
let classes = wa.title.className.split(" ");
|
|
25
|
-
if (include && classes.indexOf(classID) < 0) {
|
|
26
|
-
classes.push(classID);
|
|
27
|
-
} else if (!include && classes.indexOf(classID) > 0) {
|
|
28
|
-
classes = classes.filter(c => c !== classID);
|
|
29
|
-
}
|
|
30
|
-
wa.title.className = classes.join(" ");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
updateTitle(w: Widget) {
|
|
34
|
-
const wa: WidgetAdapter = this.getWidgetAdapter(w);
|
|
35
|
-
const element: Element = this._ec.element(w);
|
|
36
|
-
const errors = element.validate();
|
|
37
|
-
wa.title.label = this.tabTitle(element);
|
|
38
|
-
this.titleClassed(wa, "error", errors.length > 0);
|
|
39
|
-
wa.title.caption = errors.map(err => `${err.source}: ${err.msg}`).join("\n");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
activate(element: Element) {
|
|
43
|
-
const wa = this.getWidgetAdapter(element.visualization().chartPanel());
|
|
44
|
-
if (wa) {
|
|
45
|
-
wa.activate();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
syncMinSize(w: any): boolean {
|
|
50
|
-
if (w.minWidth_exists() || w.minHeight_exists()) {
|
|
51
|
-
const wa = this.getWidgetAdapter(w);
|
|
52
|
-
d3Select(wa.node)
|
|
53
|
-
.style("min-width", `${w.minWidth()}px`)
|
|
54
|
-
.style("min-height", `${w.minHeight()}px`)
|
|
55
|
-
;
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
syncWidgets() {
|
|
62
|
-
const prevWidgets = this.widgets();
|
|
63
|
-
const diffWidgets = compare(prevWidgets, this._ec.elements().filter(e => e.visualization().visibility() === "normal").map(viz => viz.visualization().chartPanel()));
|
|
64
|
-
|
|
65
|
-
let refit = false;
|
|
66
|
-
for (const w of diffWidgets.exit) {
|
|
67
|
-
this.removeWidget(w);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
for (const w of diffWidgets.enter) {
|
|
71
|
-
const element: Element = this._ec.element(w);
|
|
72
|
-
this.addWidget(w, this.tabTitle(element), "split-bottom", undefined, this.hideSingleTabs() ? undefined : this);
|
|
73
|
-
refit = this.syncMinSize(w) || refit; // ensure syncMinSize is called
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
for (const w of diffWidgets.update) {
|
|
77
|
-
this.updateTitle(w);
|
|
78
|
-
refit = this.syncMinSize(w) || refit; // ensure syncMinSize is called
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (refit) {
|
|
82
|
-
this.refit();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Events ---
|
|
89
|
-
childActivation(w: Widget, wa: WidgetAdapter) {
|
|
90
|
-
super.childActivation(w, wa);
|
|
91
|
-
this.vizActivation(this._ec.element(w));
|
|
92
|
-
for (const wa2 of this.widgetAdapters()) {
|
|
93
|
-
if (wa2 === wa) {
|
|
94
|
-
wa2.addClass("active");
|
|
95
|
-
this.titleClassed(wa2, "active", true);
|
|
96
|
-
wa2.title.iconClass = "active";
|
|
97
|
-
} else {
|
|
98
|
-
wa2.removeClass("active");
|
|
99
|
-
this.titleClassed(wa2, "active", false);
|
|
100
|
-
wa2.title.iconClass = "";
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
vizActivation(viz: Element) {
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// IClosable ---
|
|
109
|
-
canClose(w: Widget, wa: WidgetAdapter): boolean {
|
|
110
|
-
const id = this._ec.element(w).id();
|
|
111
|
-
const retVal = window.confirm(`Remove Widget "${id}"?`);
|
|
112
|
-
if (retVal) {
|
|
113
|
-
this._ec.clear(id);
|
|
114
|
-
this.syncWidgets();
|
|
115
|
-
this.vizActivation(undefined);
|
|
116
|
-
}
|
|
117
|
-
return retVal;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
syncPopups() { }
|
|
121
|
-
}
|
|
122
|
-
DashboardDockPanel.prototype._class += " marshaller_DashboardDockPanel";
|
|
123
|
-
DashboardDockPanel.prototype.mixin(PopupManager);
|
|
1
|
+
import { Widget } from "@hpcc-js/common";
|
|
2
|
+
import { DockPanel, IClosable, WidgetAdapter } from "@hpcc-js/phosphor";
|
|
3
|
+
import { compare } from "@hpcc-js/util";
|
|
4
|
+
import { select as d3Select } from "d3-selection";
|
|
5
|
+
import { Element, ElementContainer } from "./model/element";
|
|
6
|
+
import { IVizPopupPanelOwner } from "./model/vizChartPanel";
|
|
7
|
+
import { PopupManager } from "./PopupManager";
|
|
8
|
+
|
|
9
|
+
export class DashboardDockPanel extends DockPanel implements IClosable, IVizPopupPanelOwner {
|
|
10
|
+
|
|
11
|
+
constructor(private _ec: ElementContainer) {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
tabTitle(element: Element): string {
|
|
17
|
+
if (this.hideSingleTabs()) {
|
|
18
|
+
return element.visualization().title ? element.visualization().title() : element.visualization().id();
|
|
19
|
+
}
|
|
20
|
+
return element.id();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
titleClassed(wa: WidgetAdapter, classID: string, include: boolean) {
|
|
24
|
+
let classes = wa.title.className.split(" ");
|
|
25
|
+
if (include && classes.indexOf(classID) < 0) {
|
|
26
|
+
classes.push(classID);
|
|
27
|
+
} else if (!include && classes.indexOf(classID) > 0) {
|
|
28
|
+
classes = classes.filter(c => c !== classID);
|
|
29
|
+
}
|
|
30
|
+
wa.title.className = classes.join(" ");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
updateTitle(w: Widget) {
|
|
34
|
+
const wa: WidgetAdapter = this.getWidgetAdapter(w);
|
|
35
|
+
const element: Element = this._ec.element(w);
|
|
36
|
+
const errors = element.validate();
|
|
37
|
+
wa.title.label = this.tabTitle(element);
|
|
38
|
+
this.titleClassed(wa, "error", errors.length > 0);
|
|
39
|
+
wa.title.caption = errors.map(err => `${err.source}: ${err.msg}`).join("\n");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
activate(element: Element) {
|
|
43
|
+
const wa = this.getWidgetAdapter(element.visualization().chartPanel());
|
|
44
|
+
if (wa) {
|
|
45
|
+
wa.activate();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
syncMinSize(w: any): boolean {
|
|
50
|
+
if (w.minWidth_exists() || w.minHeight_exists()) {
|
|
51
|
+
const wa = this.getWidgetAdapter(w);
|
|
52
|
+
d3Select(wa.node)
|
|
53
|
+
.style("min-width", `${w.minWidth()}px`)
|
|
54
|
+
.style("min-height", `${w.minHeight()}px`)
|
|
55
|
+
;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
syncWidgets() {
|
|
62
|
+
const prevWidgets = this.widgets();
|
|
63
|
+
const diffWidgets = compare(prevWidgets, this._ec.elements().filter(e => e.visualization().visibility() === "normal").map(viz => viz.visualization().chartPanel()));
|
|
64
|
+
|
|
65
|
+
let refit = false;
|
|
66
|
+
for (const w of diffWidgets.exit) {
|
|
67
|
+
this.removeWidget(w);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
for (const w of diffWidgets.enter) {
|
|
71
|
+
const element: Element = this._ec.element(w);
|
|
72
|
+
this.addWidget(w, this.tabTitle(element), "split-bottom", undefined, this.hideSingleTabs() ? undefined : this);
|
|
73
|
+
refit = this.syncMinSize(w) || refit; // ensure syncMinSize is called
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
for (const w of diffWidgets.update) {
|
|
77
|
+
this.updateTitle(w);
|
|
78
|
+
refit = this.syncMinSize(w) || refit; // ensure syncMinSize is called
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (refit) {
|
|
82
|
+
this.refit();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Events ---
|
|
89
|
+
childActivation(w: Widget, wa: WidgetAdapter) {
|
|
90
|
+
super.childActivation(w, wa);
|
|
91
|
+
this.vizActivation(this._ec.element(w));
|
|
92
|
+
for (const wa2 of this.widgetAdapters()) {
|
|
93
|
+
if (wa2 === wa) {
|
|
94
|
+
wa2.addClass("active");
|
|
95
|
+
this.titleClassed(wa2, "active", true);
|
|
96
|
+
wa2.title.iconClass = "active";
|
|
97
|
+
} else {
|
|
98
|
+
wa2.removeClass("active");
|
|
99
|
+
this.titleClassed(wa2, "active", false);
|
|
100
|
+
wa2.title.iconClass = "";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
vizActivation(viz: Element) {
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// IClosable ---
|
|
109
|
+
canClose(w: Widget, wa: WidgetAdapter): boolean {
|
|
110
|
+
const id = this._ec.element(w).id();
|
|
111
|
+
const retVal = window.confirm(`Remove Widget "${id}"?`);
|
|
112
|
+
if (retVal) {
|
|
113
|
+
this._ec.clear(id);
|
|
114
|
+
this.syncWidgets();
|
|
115
|
+
this.vizActivation(undefined);
|
|
116
|
+
}
|
|
117
|
+
return retVal;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
syncPopups() { }
|
|
121
|
+
}
|
|
122
|
+
DashboardDockPanel.prototype._class += " marshaller_DashboardDockPanel";
|
|
123
|
+
DashboardDockPanel.prototype.mixin(PopupManager);
|
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
import { Widget } from "@hpcc-js/common";
|
|
2
|
-
import { Cell, Grid } from "@hpcc-js/layout";
|
|
3
|
-
import { IClosable, WidgetAdapter } from "@hpcc-js/phosphor";
|
|
4
|
-
import { compare } from "@hpcc-js/util";
|
|
5
|
-
import { IDockPanel } from "./dashboard";
|
|
6
|
-
import { Element, ElementContainer } from "./model/element";
|
|
7
|
-
import { IVizPopupPanelOwner } from "./model/vizChartPanel";
|
|
8
|
-
import { PopupManager } from "./PopupManager";
|
|
9
|
-
|
|
10
|
-
export class DashboardGrid extends Grid implements IClosable, IVizPopupPanelOwner, IDockPanel {
|
|
11
|
-
private _layoutCache = [];
|
|
12
|
-
constructor(private _ec: ElementContainer) {
|
|
13
|
-
super();
|
|
14
|
-
|
|
15
|
-
this.designMode(false);
|
|
16
|
-
this.surfacePadding("0");
|
|
17
|
-
this.surfaceBorderWidth(0);
|
|
18
|
-
}
|
|
19
|
-
updateGrid(resize, transitionDuration: number = 0, _noRender: boolean = false) {
|
|
20
|
-
super.updateGrid(resize, transitionDuration, _noRender);
|
|
21
|
-
this._layoutCache = this.content().map(cellWidget => {
|
|
22
|
-
return {
|
|
23
|
-
id: cellWidget.widget().id(),
|
|
24
|
-
position: [
|
|
25
|
-
cellWidget.gridCol(),
|
|
26
|
-
cellWidget.gridRow(),
|
|
27
|
-
cellWidget.gridColSpan(),
|
|
28
|
-
cellWidget.gridRowSpan()
|
|
29
|
-
]
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
layoutObj(_: object | null): this {
|
|
34
|
-
if (_) {
|
|
35
|
-
if ((_ as any).main) {
|
|
36
|
-
const convertedLayout = ddl2_layout(_, 10, 10);
|
|
37
|
-
this._layoutCache = convertedLayout;
|
|
38
|
-
} else if (_ instanceof Array) {
|
|
39
|
-
this._layoutCache = _;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return this;
|
|
43
|
-
|
|
44
|
-
function ddl2_layout(layoutObject, rows, cols) {
|
|
45
|
-
const ret = [];
|
|
46
|
-
dive(layoutObject.main, 0, 0, rows, cols);
|
|
47
|
-
return ret;
|
|
48
|
-
function dive(o, x, y, w, h) {
|
|
49
|
-
if (o.children) {
|
|
50
|
-
if (o.type === "split-area") {
|
|
51
|
-
if (o.orientation === "horizontal") {
|
|
52
|
-
o.children.forEach((child, i) => {
|
|
53
|
-
const _w = o.sizes[i] * w;
|
|
54
|
-
const _h = h;
|
|
55
|
-
const _x = i === 0 ? x : x + o.sizes[0] * w;
|
|
56
|
-
const _y = y;
|
|
57
|
-
dive(o.children[i], _x, _y, _w, _h);
|
|
58
|
-
});
|
|
59
|
-
} else if (o.orientation === "vertical") {
|
|
60
|
-
o.children.forEach((child, i) => {
|
|
61
|
-
const _w = w;
|
|
62
|
-
const _h = o.sizes[i] * h;
|
|
63
|
-
const _x = x;
|
|
64
|
-
const _y = i === 0 ? y : y + o.sizes[0] * h;
|
|
65
|
-
dive(o.children[i], _x, _y, _w, _h);
|
|
66
|
-
});
|
|
67
|
-
} else {
|
|
68
|
-
console.error("wtf");
|
|
69
|
-
}
|
|
70
|
-
} else if (o.type === "tab-area") {
|
|
71
|
-
o.children.forEach((child, i) => {
|
|
72
|
-
const _w = w;
|
|
73
|
-
const _h = o.sizes[i] * h;
|
|
74
|
-
const _x = x;
|
|
75
|
-
const _y = i === 0 ? y : y + o.sizes[0] * h;
|
|
76
|
-
dive(o.children[i], _x, _y, _w, _h);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
ret.push([x, y, w, h].map(Math.round));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
layout() {
|
|
86
|
-
return this._layoutCache;
|
|
87
|
-
}
|
|
88
|
-
widgets() {
|
|
89
|
-
return this.content().map(c => c.widget());
|
|
90
|
-
}
|
|
91
|
-
hideSingleTabs() {
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
getWidgetAdapter() {
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
tabTitle(element: Element): string {
|
|
98
|
-
if (this.hideSingleTabs()) {
|
|
99
|
-
return element.visualization().title ? element.visualization().title() : element.visualization().id();
|
|
100
|
-
}
|
|
101
|
-
return element.id();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
updateTitle(w: Widget) {
|
|
105
|
-
const cell: Cell = this.getWidgetCell(w.id());
|
|
106
|
-
const element: Element = this._ec.element(w);
|
|
107
|
-
const tabTitle = this.tabTitle(element);
|
|
108
|
-
(cell.widget() as any)
|
|
109
|
-
.title(tabTitle)
|
|
110
|
-
;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
activate(element: Element) {
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
removeWidget(w: Widget) {
|
|
117
|
-
const cell = this.getWidgetCell(w.id());
|
|
118
|
-
this.clearContent(cell);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
syncMinSize(w: any): boolean {
|
|
122
|
-
if (w.minWidth_exists() || w.minHeight_exists()) {
|
|
123
|
-
const cell: Cell = this.getWidgetCell(w.id());
|
|
124
|
-
cell.element()
|
|
125
|
-
.style("min-width", `${w.minWidth()}px`)
|
|
126
|
-
.style("min-height", `${w.minHeight()}px`)
|
|
127
|
-
;
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
syncWidgets() {
|
|
134
|
-
const prevWidgets = this.widgets();
|
|
135
|
-
const diffWidgets = compare(prevWidgets, this._ec.elements().filter(e => e.visualization().visibility() === "normal").map(viz => viz.visualization().chartPanel()));
|
|
136
|
-
|
|
137
|
-
for (const w of diffWidgets.exit) {
|
|
138
|
-
this.removeWidget(w);
|
|
139
|
-
}
|
|
140
|
-
let maxX = 0;
|
|
141
|
-
let maxY = 0;
|
|
142
|
-
const no_layout_added = [];
|
|
143
|
-
for (const widget of diffWidgets.enter) {
|
|
144
|
-
const element: Element = this._ec.element(widget);
|
|
145
|
-
const i = this.content().length;
|
|
146
|
-
if (this._layoutCache && this._layoutCache[i]) {
|
|
147
|
-
const layout = (this._layoutCache as any).find(n => n.id === widget.id());
|
|
148
|
-
if (layout) {
|
|
149
|
-
const [x, y, w, h] = layout.position;
|
|
150
|
-
this.setContent(y, x, element.visualization().chartPanel(), "", h, w);
|
|
151
|
-
if (x + w > maxX) maxX = x + w;
|
|
152
|
-
if (y + h > maxY) maxY = y + h;
|
|
153
|
-
} else {
|
|
154
|
-
no_layout_added.push(element.visualization().chartPanel());
|
|
155
|
-
}
|
|
156
|
-
} else {
|
|
157
|
-
no_layout_added.push(element.visualization().chartPanel());
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
let freeRow = this.content().reduce((prev, curr) => Math.max(prev, curr.gridRow() + curr.gridRowSpan()), 0);
|
|
161
|
-
no_layout_added.forEach(cp => {
|
|
162
|
-
this.setContent(freeRow, 0, cp, "", 3, 3);
|
|
163
|
-
freeRow += 3;
|
|
164
|
-
});
|
|
165
|
-
for (const w of diffWidgets.update) {
|
|
166
|
-
this.updateTitle(w);
|
|
167
|
-
}
|
|
168
|
-
return this;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Events ---
|
|
172
|
-
childActivation(w: Widget, wa?: WidgetAdapter) {
|
|
173
|
-
this.vizActivation(this._ec.element(w));
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
postSelectionChange() {
|
|
177
|
-
super.postSelectionChange();
|
|
178
|
-
const selected = this._selectionBag.get();
|
|
179
|
-
if (selected.length > 0) {
|
|
180
|
-
this.childActivation(selected[0].widget.widget());
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
vizActivation(viz: Element) {
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// IClosable ---
|
|
188
|
-
canClose(w: Widget, wa: WidgetAdapter): boolean {
|
|
189
|
-
const id = this._ec.element(w).id();
|
|
190
|
-
const retVal = window.confirm(`Remove Widget "${id}"?`);
|
|
191
|
-
if (retVal) {
|
|
192
|
-
this._ec.clear(id);
|
|
193
|
-
this.syncWidgets();
|
|
194
|
-
this.vizActivation(undefined);
|
|
195
|
-
}
|
|
196
|
-
return retVal;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
syncPopups() { }
|
|
200
|
-
}
|
|
201
|
-
DashboardGrid.prototype._class += " marshaller_DashboardGrid";
|
|
202
|
-
DashboardGrid.prototype.mixin(PopupManager);
|
|
1
|
+
import { Widget } from "@hpcc-js/common";
|
|
2
|
+
import { Cell, Grid } from "@hpcc-js/layout";
|
|
3
|
+
import { IClosable, WidgetAdapter } from "@hpcc-js/phosphor";
|
|
4
|
+
import { compare } from "@hpcc-js/util";
|
|
5
|
+
import { IDockPanel } from "./dashboard";
|
|
6
|
+
import { Element, ElementContainer } from "./model/element";
|
|
7
|
+
import { IVizPopupPanelOwner } from "./model/vizChartPanel";
|
|
8
|
+
import { PopupManager } from "./PopupManager";
|
|
9
|
+
|
|
10
|
+
export class DashboardGrid extends Grid implements IClosable, IVizPopupPanelOwner, IDockPanel {
|
|
11
|
+
private _layoutCache = [];
|
|
12
|
+
constructor(private _ec: ElementContainer) {
|
|
13
|
+
super();
|
|
14
|
+
|
|
15
|
+
this.designMode(false);
|
|
16
|
+
this.surfacePadding("0");
|
|
17
|
+
this.surfaceBorderWidth(0);
|
|
18
|
+
}
|
|
19
|
+
updateGrid(resize, transitionDuration: number = 0, _noRender: boolean = false) {
|
|
20
|
+
super.updateGrid(resize, transitionDuration, _noRender);
|
|
21
|
+
this._layoutCache = this.content().map(cellWidget => {
|
|
22
|
+
return {
|
|
23
|
+
id: cellWidget.widget().id(),
|
|
24
|
+
position: [
|
|
25
|
+
cellWidget.gridCol(),
|
|
26
|
+
cellWidget.gridRow(),
|
|
27
|
+
cellWidget.gridColSpan(),
|
|
28
|
+
cellWidget.gridRowSpan()
|
|
29
|
+
]
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
layoutObj(_: object | null): this {
|
|
34
|
+
if (_) {
|
|
35
|
+
if ((_ as any).main) {
|
|
36
|
+
const convertedLayout = ddl2_layout(_, 10, 10);
|
|
37
|
+
this._layoutCache = convertedLayout;
|
|
38
|
+
} else if (_ instanceof Array) {
|
|
39
|
+
this._layoutCache = _;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return this;
|
|
43
|
+
|
|
44
|
+
function ddl2_layout(layoutObject, rows, cols) {
|
|
45
|
+
const ret = [];
|
|
46
|
+
dive(layoutObject.main, 0, 0, rows, cols);
|
|
47
|
+
return ret;
|
|
48
|
+
function dive(o, x, y, w, h) {
|
|
49
|
+
if (o.children) {
|
|
50
|
+
if (o.type === "split-area") {
|
|
51
|
+
if (o.orientation === "horizontal") {
|
|
52
|
+
o.children.forEach((child, i) => {
|
|
53
|
+
const _w = o.sizes[i] * w;
|
|
54
|
+
const _h = h;
|
|
55
|
+
const _x = i === 0 ? x : x + o.sizes[0] * w;
|
|
56
|
+
const _y = y;
|
|
57
|
+
dive(o.children[i], _x, _y, _w, _h);
|
|
58
|
+
});
|
|
59
|
+
} else if (o.orientation === "vertical") {
|
|
60
|
+
o.children.forEach((child, i) => {
|
|
61
|
+
const _w = w;
|
|
62
|
+
const _h = o.sizes[i] * h;
|
|
63
|
+
const _x = x;
|
|
64
|
+
const _y = i === 0 ? y : y + o.sizes[0] * h;
|
|
65
|
+
dive(o.children[i], _x, _y, _w, _h);
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
console.error("wtf");
|
|
69
|
+
}
|
|
70
|
+
} else if (o.type === "tab-area") {
|
|
71
|
+
o.children.forEach((child, i) => {
|
|
72
|
+
const _w = w;
|
|
73
|
+
const _h = o.sizes[i] * h;
|
|
74
|
+
const _x = x;
|
|
75
|
+
const _y = i === 0 ? y : y + o.sizes[0] * h;
|
|
76
|
+
dive(o.children[i], _x, _y, _w, _h);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
ret.push([x, y, w, h].map(Math.round));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
layout() {
|
|
86
|
+
return this._layoutCache;
|
|
87
|
+
}
|
|
88
|
+
widgets() {
|
|
89
|
+
return this.content().map(c => c.widget());
|
|
90
|
+
}
|
|
91
|
+
hideSingleTabs() {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
getWidgetAdapter() {
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
tabTitle(element: Element): string {
|
|
98
|
+
if (this.hideSingleTabs()) {
|
|
99
|
+
return element.visualization().title ? element.visualization().title() : element.visualization().id();
|
|
100
|
+
}
|
|
101
|
+
return element.id();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
updateTitle(w: Widget) {
|
|
105
|
+
const cell: Cell = this.getWidgetCell(w.id());
|
|
106
|
+
const element: Element = this._ec.element(w);
|
|
107
|
+
const tabTitle = this.tabTitle(element);
|
|
108
|
+
(cell.widget() as any)
|
|
109
|
+
.title(tabTitle)
|
|
110
|
+
;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
activate(element: Element) {
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
removeWidget(w: Widget) {
|
|
117
|
+
const cell = this.getWidgetCell(w.id());
|
|
118
|
+
this.clearContent(cell);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
syncMinSize(w: any): boolean {
|
|
122
|
+
if (w.minWidth_exists() || w.minHeight_exists()) {
|
|
123
|
+
const cell: Cell = this.getWidgetCell(w.id());
|
|
124
|
+
cell.element()
|
|
125
|
+
.style("min-width", `${w.minWidth()}px`)
|
|
126
|
+
.style("min-height", `${w.minHeight()}px`)
|
|
127
|
+
;
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
syncWidgets() {
|
|
134
|
+
const prevWidgets = this.widgets();
|
|
135
|
+
const diffWidgets = compare(prevWidgets, this._ec.elements().filter(e => e.visualization().visibility() === "normal").map(viz => viz.visualization().chartPanel()));
|
|
136
|
+
|
|
137
|
+
for (const w of diffWidgets.exit) {
|
|
138
|
+
this.removeWidget(w);
|
|
139
|
+
}
|
|
140
|
+
let maxX = 0;
|
|
141
|
+
let maxY = 0;
|
|
142
|
+
const no_layout_added = [];
|
|
143
|
+
for (const widget of diffWidgets.enter) {
|
|
144
|
+
const element: Element = this._ec.element(widget);
|
|
145
|
+
const i = this.content().length;
|
|
146
|
+
if (this._layoutCache && this._layoutCache[i]) {
|
|
147
|
+
const layout = (this._layoutCache as any).find(n => n.id === widget.id());
|
|
148
|
+
if (layout) {
|
|
149
|
+
const [x, y, w, h] = layout.position;
|
|
150
|
+
this.setContent(y, x, element.visualization().chartPanel(), "", h, w);
|
|
151
|
+
if (x + w > maxX) maxX = x + w;
|
|
152
|
+
if (y + h > maxY) maxY = y + h;
|
|
153
|
+
} else {
|
|
154
|
+
no_layout_added.push(element.visualization().chartPanel());
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
no_layout_added.push(element.visualization().chartPanel());
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
let freeRow = this.content().reduce((prev, curr) => Math.max(prev, curr.gridRow() + curr.gridRowSpan()), 0);
|
|
161
|
+
no_layout_added.forEach(cp => {
|
|
162
|
+
this.setContent(freeRow, 0, cp, "", 3, 3);
|
|
163
|
+
freeRow += 3;
|
|
164
|
+
});
|
|
165
|
+
for (const w of diffWidgets.update) {
|
|
166
|
+
this.updateTitle(w);
|
|
167
|
+
}
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Events ---
|
|
172
|
+
childActivation(w: Widget, wa?: WidgetAdapter) {
|
|
173
|
+
this.vizActivation(this._ec.element(w));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
postSelectionChange() {
|
|
177
|
+
super.postSelectionChange();
|
|
178
|
+
const selected = this._selectionBag.get();
|
|
179
|
+
if (selected.length > 0) {
|
|
180
|
+
this.childActivation(selected[0].widget.widget());
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
vizActivation(viz: Element) {
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// IClosable ---
|
|
188
|
+
canClose(w: Widget, wa: WidgetAdapter): boolean {
|
|
189
|
+
const id = this._ec.element(w).id();
|
|
190
|
+
const retVal = window.confirm(`Remove Widget "${id}"?`);
|
|
191
|
+
if (retVal) {
|
|
192
|
+
this._ec.clear(id);
|
|
193
|
+
this.syncWidgets();
|
|
194
|
+
this.vizActivation(undefined);
|
|
195
|
+
}
|
|
196
|
+
return retVal;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
syncPopups() { }
|
|
200
|
+
}
|
|
201
|
+
DashboardGrid.prototype._class += " marshaller_DashboardGrid";
|
|
202
|
+
DashboardGrid.prototype.mixin(PopupManager);
|