@datagrok/compute 0.6.1 → 0.6.5
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/package.json +2 -1
- package/src/export-funccall.ts +95 -28
- package/src/function-editor/function-editor.ts +304 -225
- package/src/outliers-selection/outliers-selection-viewer.ts +8 -70
- package/src/package.ts +9 -9
- package/scripts/pMax.js +0 -204
- package/scripts/vMaxJS.js +0 -182
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/compute",
|
|
3
3
|
"friendlyName": "Compute",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.5",
|
|
5
5
|
"description": "",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"cash-dom": "latest",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"dayjs": "latest",
|
|
11
11
|
"exceljs": "^4.3.0",
|
|
12
12
|
"file-saver": "^2.0.5",
|
|
13
|
+
"rxjs": "^7.4.0",
|
|
13
14
|
"ts-loader": "latest",
|
|
14
15
|
"typescript": "latest",
|
|
15
16
|
"wu": "latest"
|
package/src/export-funccall.ts
CHANGED
|
@@ -4,6 +4,17 @@ import * as DG from 'datagrok-api/dg';
|
|
|
4
4
|
import ExcelJS from 'exceljs';
|
|
5
5
|
import {saveAs} from 'file-saver';
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
const getSheetName = (name: string, direction: DIRECTION) => {
|
|
9
|
+
const idealName = `${direction} - ${name}`;
|
|
10
|
+
return (idealName.length > 31) ? name.substring(0, 32) : idealName;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
enum DIRECTION {
|
|
14
|
+
INPUT = 'Input',
|
|
15
|
+
OUTPUT = 'Output'
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
export async function exportFuncCall(call: DG.FuncCall) {
|
|
8
19
|
//todo: check status
|
|
9
20
|
// if (call.status != FuncCall.STATUS_COMPLETED) ...
|
|
@@ -22,8 +33,12 @@ export async function exportFuncCall(call: DG.FuncCall) {
|
|
|
22
33
|
const dfOutputs = call.func.outputs.filter((output) => isDataFrame(output.propertyType));
|
|
23
34
|
const scalarOutputs = call.func.outputs.filter((output) => isScalarType(output.propertyType));
|
|
24
35
|
|
|
36
|
+
const realNames: Record<string, string> = {};
|
|
37
|
+
|
|
25
38
|
dfInputs.forEach((dfInput) => {
|
|
26
|
-
const
|
|
39
|
+
const visibleTitle = dfInput.options.caption || dfInput.name;
|
|
40
|
+
const currentDfSheet = exportWorkbook.addWorksheet(getSheetName(visibleTitle, DIRECTION.INPUT));
|
|
41
|
+
realNames[visibleTitle] = dfInput.name;
|
|
27
42
|
const currentDf = (call.inputs[dfInput.name] as DG.DataFrame);
|
|
28
43
|
currentDfSheet.addRow((currentDf.columns as DG.ColumnList).names());
|
|
29
44
|
for (let i = 0; i < currentDf.rowCount; i++) {
|
|
@@ -31,13 +46,17 @@ export async function exportFuncCall(call: DG.FuncCall) {
|
|
|
31
46
|
}
|
|
32
47
|
});
|
|
33
48
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
49
|
+
if (scalarInputs.length) {
|
|
50
|
+
const inputScalarsSheet = exportWorkbook.addWorksheet('Input scalars');
|
|
51
|
+
scalarInputs.forEach((scalarInput) => {
|
|
52
|
+
inputScalarsSheet.addRow([scalarInput.name, call.inputs[scalarInput.name]]);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
38
55
|
|
|
39
56
|
dfOutputs.forEach((dfOutput) => {
|
|
40
|
-
const
|
|
57
|
+
const visibleTitle = dfOutput.options.caption || dfOutput.name;
|
|
58
|
+
const currentDfSheet = exportWorkbook.addWorksheet(getSheetName(visibleTitle, DIRECTION.OUTPUT));
|
|
59
|
+
realNames[visibleTitle] = dfOutput.name;
|
|
41
60
|
const currentDf = (call.outputs[dfOutput.name] as DG.DataFrame);
|
|
42
61
|
currentDfSheet.addRow((currentDf.columns as DG.ColumnList).names());
|
|
43
62
|
for (let i = 0; i < currentDf.rowCount; i++) {
|
|
@@ -57,12 +76,18 @@ export async function exportFuncCall(call: DG.FuncCall) {
|
|
|
57
76
|
|
|
58
77
|
const titleDivs = document.getElementsByClassName('grok-func-results-header');
|
|
59
78
|
if (!titleDivs.length) continue;
|
|
79
|
+
let skipNext = false;
|
|
60
80
|
|
|
61
81
|
for (let i = 0; i < titleDivs.length; i++) {
|
|
82
|
+
if (skipNext) {
|
|
83
|
+
skipNext = false;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
62
86
|
const titleDiv = titleDivs[i];
|
|
87
|
+
if (titleDiv.parentElement?.style.display === 'none') continue;
|
|
63
88
|
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
89
|
+
const visibleTitle = titleDiv.firstChild?.textContent;
|
|
90
|
+
if (visibleTitle === null || visibleTitle === undefined) continue;
|
|
66
91
|
|
|
67
92
|
let imageId;
|
|
68
93
|
let width = 0;
|
|
@@ -82,11 +107,25 @@ export async function exportFuncCall(call: DG.FuncCall) {
|
|
|
82
107
|
width = imageDiv.clientWidth;
|
|
83
108
|
height = imageDiv.clientHeight;
|
|
84
109
|
} else {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (
|
|
110
|
+
let plotDiv: ChildNode | null | undefined = titleDiv.nextSibling;
|
|
111
|
+
|
|
112
|
+
if (plotDiv && !titleDiv.getElementsByClassName('svg-table').length && (plotDiv as HTMLElement).getAttribute('name') === 'viewer-Grid') continue;
|
|
88
113
|
|
|
89
|
-
if (
|
|
114
|
+
if (plotDiv && titleDiv.getElementsByClassName('svg-table').length) {
|
|
115
|
+
if ((plotDiv as HTMLElement).getAttribute('name') === 'viewer-OutliersSelectionViewer') {
|
|
116
|
+
plotDiv = titleDiv.parentElement?.nextSibling?.firstChild?.nextSibling;
|
|
117
|
+
skipNext = true;
|
|
118
|
+
}
|
|
119
|
+
if ((plotDiv as HTMLElement).getAttribute('name') === 'viewer-Grid') {
|
|
120
|
+
(titleDiv.getElementsByClassName('svg-table')[0] as HTMLElement).click();
|
|
121
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
122
|
+
plotDiv = titleDiv.nextSibling;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
console.log(plotDiv);
|
|
126
|
+
|
|
127
|
+
if (plotDiv) {
|
|
128
|
+
const plot = (plotDiv as HTMLElement).getElementsByClassName('d4-layout-middle')[0];
|
|
90
129
|
const canvas = await DG.HtmlUtils.renderToCanvas(plot as HTMLElement);
|
|
91
130
|
const dataUrl = canvas.toDataURL('image/png');
|
|
92
131
|
|
|
@@ -101,15 +140,22 @@ export async function exportFuncCall(call: DG.FuncCall) {
|
|
|
101
140
|
|
|
102
141
|
if (imageId === null || imageId === undefined) continue;
|
|
103
142
|
|
|
104
|
-
const worksheet = exportWorkbook.getWorksheet(
|
|
143
|
+
const worksheet = exportWorkbook.getWorksheet(getSheetName(visibleTitle, DIRECTION.INPUT)) ||
|
|
144
|
+
exportWorkbook.getWorksheet(getSheetName(visibleTitle, DIRECTION.OUTPUT));
|
|
105
145
|
if (worksheet) {
|
|
106
|
-
|
|
146
|
+
console.log(visibleTitle);
|
|
147
|
+
console.log(realNames[visibleTitle]);
|
|
148
|
+
const columnForImage = (((call
|
|
149
|
+
.inputs[realNames[visibleTitle]] || call
|
|
150
|
+
.outputs[realNames[visibleTitle]]) as DG.DataFrame)
|
|
151
|
+
.columns as DG.ColumnList)
|
|
152
|
+
.length + 1;
|
|
107
153
|
worksheet.addImage(imageId, {
|
|
108
154
|
tl: {col: columnForImage, row: 0},
|
|
109
155
|
ext: {width, height},
|
|
110
156
|
});
|
|
111
157
|
} else {
|
|
112
|
-
const newWorksheet = exportWorkbook.addWorksheet(`Output - Plot - ${
|
|
158
|
+
const newWorksheet = exportWorkbook.addWorksheet(`Output - Plot - ${visibleTitle}`);
|
|
113
159
|
newWorksheet.addImage(imageId, {
|
|
114
160
|
tl: {col: 0, row: 0},
|
|
115
161
|
ext: {width, height},
|
|
@@ -121,10 +167,17 @@ export async function exportFuncCall(call: DG.FuncCall) {
|
|
|
121
167
|
} else {
|
|
122
168
|
const resultView = document.getElementsByClassName('ui-panel grok-func-results')[0];
|
|
123
169
|
const titleDivs = resultView.getElementsByClassName('grok-func-results-header');
|
|
170
|
+
let skipNext = false;
|
|
171
|
+
|
|
124
172
|
for (let i=0; i< titleDivs.length; i++) {
|
|
173
|
+
if (skipNext) {
|
|
174
|
+
skipNext = false;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
|
|
125
178
|
const titleDiv = titleDivs[i];
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
179
|
+
const visibleTitle = titleDiv.firstChild?.textContent;
|
|
180
|
+
if (visibleTitle === null || visibleTitle === undefined) continue;
|
|
128
181
|
|
|
129
182
|
let imageId;
|
|
130
183
|
let width = 0;
|
|
@@ -144,11 +197,20 @@ export async function exportFuncCall(call: DG.FuncCall) {
|
|
|
144
197
|
width = imageDiv.clientWidth;
|
|
145
198
|
height = imageDiv.clientHeight;
|
|
146
199
|
} else {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
200
|
+
let plotDiv: ChildNode | null | undefined = titleDiv.nextSibling;
|
|
201
|
+
if (plotDiv &&
|
|
202
|
+
((plotDiv as HTMLElement).getAttribute('name') === 'viewer-Grid' ||
|
|
203
|
+
(plotDiv as HTMLElement).getAttribute('name') === 'viewer-OutliersSelectionViewer')) {
|
|
204
|
+
if (titleDiv.getElementsByClassName('svg-table').length) {
|
|
205
|
+
plotDiv = titleDiv.parentElement?.nextSibling?.firstChild?.nextSibling;
|
|
206
|
+
skipNext = true;
|
|
207
|
+
} else {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
150
211
|
|
|
151
|
-
if (
|
|
212
|
+
if (plotDiv) {
|
|
213
|
+
const plot = (plotDiv as HTMLElement).getElementsByClassName('d4-layout-middle')[0];
|
|
152
214
|
const canvas = await DG.HtmlUtils.renderToCanvas(plot as HTMLElement);
|
|
153
215
|
const dataUrl = canvas.toDataURL('image/png');
|
|
154
216
|
|
|
@@ -163,15 +225,18 @@ export async function exportFuncCall(call: DG.FuncCall) {
|
|
|
163
225
|
|
|
164
226
|
if (imageId === null || imageId === undefined) continue;
|
|
165
227
|
|
|
166
|
-
const worksheet = exportWorkbook.getWorksheet(
|
|
228
|
+
const worksheet = exportWorkbook.getWorksheet(getSheetName(visibleTitle, DIRECTION.OUTPUT));
|
|
167
229
|
if (worksheet) {
|
|
168
|
-
const columnForImage = ((call
|
|
230
|
+
const columnForImage = ((call
|
|
231
|
+
.outputs[realNames[visibleTitle]] as DG.DataFrame)
|
|
232
|
+
.columns as DG.ColumnList)
|
|
233
|
+
.length + 1;
|
|
169
234
|
worksheet.addImage(imageId, {
|
|
170
235
|
tl: {col: columnForImage, row: 0},
|
|
171
236
|
ext: {width, height},
|
|
172
237
|
});
|
|
173
238
|
} else {
|
|
174
|
-
const newWorksheet = exportWorkbook.addWorksheet(`Output - Plot - ${
|
|
239
|
+
const newWorksheet = exportWorkbook.addWorksheet(`Output - Plot - ${visibleTitle}`);
|
|
175
240
|
newWorksheet.addImage(imageId, {
|
|
176
241
|
tl: {col: 0, row: 0},
|
|
177
242
|
ext: {width, height},
|
|
@@ -180,10 +245,12 @@ export async function exportFuncCall(call: DG.FuncCall) {
|
|
|
180
245
|
}
|
|
181
246
|
}
|
|
182
247
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
248
|
+
if (scalarOutputs.length) {
|
|
249
|
+
const outputScalarsSheet = exportWorkbook.addWorksheet('Output scalars');
|
|
250
|
+
scalarOutputs.forEach((scalarOutput) => {
|
|
251
|
+
outputScalarsSheet.addRow([scalarOutput.name, call.outputs[scalarOutput.name]]);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
187
254
|
|
|
188
255
|
exportWorkbook.xlsx.writeBuffer().then((data) => {
|
|
189
256
|
const blob = new Blob([data], {type: BLOB_TYPE});
|