@datagrok/compute 0.7.1 → 0.7.2
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/dist/package.js +1455 -0
- package/package.json +12 -4
- package/scripts/vmax.js +178 -0
- package/scripts/wrapper.js +8 -0
- package/src/function-views/compute-view.ts +162 -0
- package/src/model-catalog-view.ts +2 -3
- package/src/model-handler.ts +20 -18
- package/src/models-widget.ts +96 -44
- package/src/outliers-selection/outliers-selection-viewer.ts +37 -28
- package/src/package.ts +33 -20
- package/src/view-samples/computation-test-view.ts +8 -0
- package/.eslintrc.json +0 -35
- package/src/export-funccall.ts +0 -200
|
@@ -28,19 +28,6 @@ export class OutliersSelectionViewer extends DG.JsViewer {
|
|
|
28
28
|
const OUTLIER_COUNT_COL_LABEL = 'Count';
|
|
29
29
|
const IS_GROUP_CONFIRMED_LABEL = 'isConfirmed';
|
|
30
30
|
|
|
31
|
-
if (!inputData.columns.byName(IS_OUTLIER_COL_LABEL)) {
|
|
32
|
-
inputData.columns
|
|
33
|
-
.add(DG.Column.fromBitSet(IS_OUTLIER_COL_LABEL, DG.BitSet.create(inputData.rowCount, () => false)));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!inputData.columns.byName(OUTLIER_RATIONALE_COL_LABEL)) {
|
|
37
|
-
inputData.columns
|
|
38
|
-
.add(DG.Column.fromStrings(OUTLIER_RATIONALE_COL_LABEL, Array.from({length: inputData.rowCount}, () => '')));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//@ts-ignore
|
|
42
|
-
inputData.col(IS_OUTLIER_COL_LABEL)?.markers.assign('true', DG.MARKER_TYPE.OUTLIER);
|
|
43
|
-
|
|
44
31
|
const clearTable = () => {
|
|
45
32
|
return DG.DataFrame.fromColumns([
|
|
46
33
|
DG.Column.fromStrings(OUTLIER_RATIONALE_COL_LABEL, []),
|
|
@@ -64,6 +51,19 @@ export class OutliersSelectionViewer extends DG.JsViewer {
|
|
|
64
51
|
ui.iconFA('check', () => {
|
|
65
52
|
if (!groupsListGrid.dataFrame) return;
|
|
66
53
|
|
|
54
|
+
if (!inputData.columns.byName(IS_OUTLIER_COL_LABEL)) {
|
|
55
|
+
inputData.columns
|
|
56
|
+
.add(DG.Column.fromBitSet(IS_OUTLIER_COL_LABEL, DG.BitSet.create(inputData.rowCount, () => false)));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!inputData.columns.byName(OUTLIER_RATIONALE_COL_LABEL)) {
|
|
60
|
+
inputData.columns
|
|
61
|
+
.add(DG.Column.fromStrings(OUTLIER_RATIONALE_COL_LABEL, Array.from({length: inputData.rowCount}, () => '')));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//@ts-ignore
|
|
65
|
+
inputData.col(IS_OUTLIER_COL_LABEL)?.markers.assign('true', DG.MARKER_TYPE.OUTLIER);
|
|
66
|
+
|
|
67
67
|
const newRationale =
|
|
68
68
|
groupsListGrid.dataFrame?.cell(groupsListGrid.dataFrame.rowCount-1, OUTLIER_RATIONALE_COL_LABEL).value;
|
|
69
69
|
|
|
@@ -131,14 +131,30 @@ export class OutliersSelectionViewer extends DG.JsViewer {
|
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
const updateGroupsTable = () => {
|
|
134
|
+
if ((inputData.columns as DG.ColumnList).byName(OUTLIER_RATIONALE_COL_LABEL)) {
|
|
135
|
+
for (let i = 0; i < inputData.rowCount; i++) {
|
|
136
|
+
if (inputData.columns.byName(IS_OUTLIER_COL_LABEL).get(i)) {
|
|
137
|
+
if (inputData.columns.byName(OUTLIER_RATIONALE_COL_LABEL).get(i) === '') {
|
|
138
|
+
(inputData.columns as DG.ColumnList).byName(OUTLIER_RATIONALE_COL_LABEL).set(i, "Manual", false)
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
if (inputData.columns.byName(OUTLIER_RATIONALE_COL_LABEL).get(i) !== '') {
|
|
142
|
+
(inputData.columns as DG.ColumnList).byName(OUTLIER_RATIONALE_COL_LABEL).set(i, '', false)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
134
148
|
const uniqueValues: {[key:string]: number} = {};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
149
|
+
if ((inputData.columns as DG.ColumnList).byName(OUTLIER_RATIONALE_COL_LABEL)) {
|
|
150
|
+
for (let i = 0; i < inputData.rowCount; i++) {
|
|
151
|
+
const record = inputData.columns.byName(OUTLIER_RATIONALE_COL_LABEL).get(i);
|
|
152
|
+
const count = uniqueValues[record];
|
|
153
|
+
if (record != '') {
|
|
154
|
+
count ?
|
|
155
|
+
uniqueValues[record]++ :
|
|
156
|
+
uniqueValues[record] = 1;
|
|
157
|
+
}
|
|
142
158
|
}
|
|
143
159
|
}
|
|
144
160
|
groupsListGrid.dataFrame = clearTable();
|
|
@@ -172,15 +188,8 @@ export class OutliersSelectionViewer extends DG.JsViewer {
|
|
|
172
188
|
|
|
173
189
|
updateGroupsTable();
|
|
174
190
|
|
|
175
|
-
// const info = ui.info(
|
|
176
|
-
// ui.div([
|
|
177
|
-
// ui.p('Hold the “SHIFT” key and start to draw a freehand selection on the plot area'),
|
|
178
|
-
// ], {style: {'white-space': 'pre-wrap'}}),
|
|
179
|
-
// );
|
|
180
|
-
// info.style.marginBottom = '0px';
|
|
181
|
-
|
|
182
191
|
this.root.innerHTML = '';
|
|
183
|
-
this.root.
|
|
192
|
+
this.root.appendChild(
|
|
184
193
|
ui.divV([
|
|
185
194
|
ui.divV([
|
|
186
195
|
groupsListGrid.root,
|
package/src/package.ts
CHANGED
|
@@ -3,12 +3,15 @@ import * as grok from 'datagrok-api/grok';
|
|
|
3
3
|
import * as ui from 'datagrok-api/ui';
|
|
4
4
|
import * as DG from 'datagrok-api/dg';
|
|
5
5
|
import {ModelHandler} from './model-handler';
|
|
6
|
-
import {exportFuncCall} from './export-funccall';
|
|
7
6
|
import {_functionParametersGrid} from './function-views/function-parameters-grid';
|
|
8
7
|
import {ModelCatalogView} from './model-catalog-view';
|
|
9
8
|
import wu from 'wu';
|
|
10
9
|
import {OutliersSelectionViewer} from './outliers-selection/outliers-selection-viewer';
|
|
11
10
|
import {ModelsWidget} from './models-widget'
|
|
11
|
+
import {FunctionView} from "@datagrok-libraries/utils/src/function-view";
|
|
12
|
+
import {delay} from "@datagrok-libraries/utils/src/test";
|
|
13
|
+
import {ComputationView} from "@datagrok-libraries/utils/src/computation-view";
|
|
14
|
+
import {ComputeView} from "./function-views/compute-view";
|
|
12
15
|
|
|
13
16
|
let initCompleted: boolean = false;
|
|
14
17
|
export const _package = new DG.Package();
|
|
@@ -28,13 +31,6 @@ export function modelsWidget(): DG.Widget {
|
|
|
28
31
|
return new ModelsWidget();
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
//name: Export to Excel
|
|
32
|
-
//input: funccall call
|
|
33
|
-
//tags: export
|
|
34
|
-
export function exportToExcel(call: DG.FuncCall) {
|
|
35
|
-
exportFuncCall(call);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
34
|
/* eslint-disable */
|
|
39
35
|
|
|
40
36
|
//description: A spreadsheet that lets you interactively edit parameters and evaluate functions
|
|
@@ -133,8 +129,8 @@ export function init() {
|
|
|
133
129
|
}).root;
|
|
134
130
|
});
|
|
135
131
|
|
|
136
|
-
grok.events.onViewAdding.subscribe((v: DG.
|
|
137
|
-
if (v
|
|
132
|
+
grok.events.onViewAdding.subscribe((v: DG.ViewBase) => {
|
|
133
|
+
if (v.type == 'function' && (v as FunctionView).func?.hasTag("model")) {
|
|
138
134
|
let modelsView = wu(grok.shell.views).find((v) => v.parentCall?.func.name == 'modelCatalog');
|
|
139
135
|
if (modelsView != undefined) {
|
|
140
136
|
v.parentCall = modelsView!.parentCall;
|
|
@@ -148,14 +144,31 @@ export function init() {
|
|
|
148
144
|
}
|
|
149
145
|
|
|
150
146
|
//name: Model Catalog
|
|
151
|
-
//
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
147
|
+
// export function modelCatalog() {
|
|
148
|
+
// /* let view = new DG.MultiView({
|
|
149
|
+
// viewFactories: {
|
|
150
|
+
// 'Models': {factory: () => new ModelCatalogView(), allowClose: false}
|
|
151
|
+
// }
|
|
152
|
+
// });*/
|
|
153
|
+
// let view = new ModelCatalogView();
|
|
154
|
+
// view.name = 'Models';
|
|
155
|
+
// grok.shell.addView(view);
|
|
156
|
+
// }
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
//name: computationTest
|
|
160
|
+
//input: int delayMs {description: Wait time; units: ms}
|
|
161
|
+
//input: string error {description: When specified, throws this error}
|
|
162
|
+
//output: dataframe result
|
|
163
|
+
export async function computationTest(delayMs: number, error: string): Promise<DG.DataFrame> {
|
|
164
|
+
await delay(delayMs);
|
|
165
|
+
if (error != null || error != '')
|
|
166
|
+
throw error;
|
|
167
|
+
return grok.data.demo.demog();
|
|
161
168
|
}
|
|
169
|
+
|
|
170
|
+
//name: testComputationView();
|
|
171
|
+
export function testComputationView() {
|
|
172
|
+
let f = DG.Func.find({name: 'computationTest'})[0];
|
|
173
|
+
grok.shell.addView(new ComputeView(f));
|
|
174
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as grok from 'datagrok-api/grok';
|
|
2
|
+
import * as ui from 'datagrok-api/ui';
|
|
3
|
+
import * as DG from 'datagrok-api/dg';
|
|
4
|
+
import {ComputationView} from "@datagrok-libraries/utils/src/computation-view";
|
|
5
|
+
|
|
6
|
+
export class ComputationTestView extends ComputationView {
|
|
7
|
+
|
|
8
|
+
}
|
package/.eslintrc.json
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es2021": true
|
|
5
|
-
},
|
|
6
|
-
"extends": [
|
|
7
|
-
"google"
|
|
8
|
-
],
|
|
9
|
-
"parserOptions": {
|
|
10
|
-
"ecmaVersion": 12,
|
|
11
|
-
"sourceType": "module"
|
|
12
|
-
},
|
|
13
|
-
"rules": {
|
|
14
|
-
"indent": [
|
|
15
|
-
"error",
|
|
16
|
-
2
|
|
17
|
-
],
|
|
18
|
-
"max-len": [
|
|
19
|
-
"error",
|
|
20
|
-
120,
|
|
21
|
-
{ "ignoreStrings": true }
|
|
22
|
-
],
|
|
23
|
-
"require-jsdoc": "off",
|
|
24
|
-
"spaced-comment": "off",
|
|
25
|
-
"valid-jsdoc": [
|
|
26
|
-
"error",
|
|
27
|
-
{ "requireParamType": false,
|
|
28
|
-
"requireReturnType": false }
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
"parser": "@typescript-eslint/parser",
|
|
32
|
-
"plugins": [
|
|
33
|
-
"@typescript-eslint"
|
|
34
|
-
]
|
|
35
|
-
}
|
package/src/export-funccall.ts
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import * as grok from 'datagrok-api/grok';
|
|
2
|
-
import * as ui from 'datagrok-api/ui';
|
|
3
|
-
import * as DG from 'datagrok-api/dg';
|
|
4
|
-
import ExcelJS from 'exceljs';
|
|
5
|
-
import {saveAs} from 'file-saver';
|
|
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
|
-
|
|
18
|
-
export async function exportFuncCall(call: DG.FuncCall) {
|
|
19
|
-
//todo: check status
|
|
20
|
-
// if (call.status != FuncCall.STATUS_COMPLETED) ...
|
|
21
|
-
|
|
22
|
-
const BLOB_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
|
|
23
|
-
const exportWorkbook = new ExcelJS.Workbook();
|
|
24
|
-
|
|
25
|
-
const isScalarType = (type: DG.TYPE) => {
|
|
26
|
-
return DG.TYPES_SCALAR.has(type);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const isDataFrame = (type: DG.TYPE) => (type === DG.TYPE.DATA_FRAME);
|
|
30
|
-
|
|
31
|
-
const dfInputs = call.func.inputs.filter((input) => isDataFrame(input.propertyType));
|
|
32
|
-
const scalarInputs = call.func.inputs.filter((input) => isScalarType(input.propertyType));
|
|
33
|
-
const dfOutputs = call.func.outputs.filter((output) => isDataFrame(output.propertyType));
|
|
34
|
-
const scalarOutputs = call.func.outputs.filter((output) => isScalarType(output.propertyType));
|
|
35
|
-
|
|
36
|
-
const realNames: Record<string, string> = {};
|
|
37
|
-
|
|
38
|
-
dfInputs.forEach((dfInput) => {
|
|
39
|
-
const visibleTitle = dfInput.options.caption || dfInput.name;
|
|
40
|
-
const currentDfSheet = exportWorkbook.addWorksheet(getSheetName(visibleTitle, DIRECTION.INPUT));
|
|
41
|
-
realNames[visibleTitle] = dfInput.name;
|
|
42
|
-
const currentDf = (call.inputs[dfInput.name] as DG.DataFrame);
|
|
43
|
-
currentDfSheet.addRow((currentDf.columns as DG.ColumnList).names());
|
|
44
|
-
for (let i = 0; i < currentDf.rowCount; i++) {
|
|
45
|
-
currentDfSheet.addRow([...currentDf.row(i).cells].map((cell: DG.Cell) => cell.value));
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (scalarInputs.length) {
|
|
50
|
-
const inputScalarsSheet = exportWorkbook.addWorksheet('Input scalars');
|
|
51
|
-
scalarInputs.forEach((scalarInput) => {
|
|
52
|
-
inputScalarsSheet.addRow([scalarInput.options['caption'] || scalarInput.name, call.inputs[scalarInput.name], scalarInput.options['units'] || '']);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
dfOutputs.forEach((dfOutput) => {
|
|
57
|
-
const visibleTitle = dfOutput.options.caption || dfOutput.name;
|
|
58
|
-
const currentDfSheet = exportWorkbook.addWorksheet(getSheetName(visibleTitle, DIRECTION.OUTPUT));
|
|
59
|
-
realNames[visibleTitle] = dfOutput.name;
|
|
60
|
-
const currentDf = (call.outputs[dfOutput.name] as DG.DataFrame);
|
|
61
|
-
currentDfSheet.addRow((currentDf.columns as DG.ColumnList).names());
|
|
62
|
-
for (let i = 0; i < currentDf.rowCount; i++) {
|
|
63
|
-
currentDfSheet.addRow([...currentDf.row(i).cells].map((cell: DG.Cell) => cell.value));
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const addToFile = (imageId: number, visibleTitle: string, width: number, height: number, plotCount?: number) => {
|
|
68
|
-
if (imageId === null || imageId === undefined) return;
|
|
69
|
-
|
|
70
|
-
const worksheet = exportWorkbook.getWorksheet(getSheetName(visibleTitle, DIRECTION.INPUT)) ||
|
|
71
|
-
exportWorkbook.getWorksheet(getSheetName(visibleTitle, DIRECTION.OUTPUT));
|
|
72
|
-
if (worksheet) {
|
|
73
|
-
const columnForImage = (
|
|
74
|
-
((call.inputs[realNames[visibleTitle]] ||
|
|
75
|
-
call.outputs[realNames[visibleTitle]]) as DG.DataFrame)
|
|
76
|
-
.columns as DG.ColumnList)
|
|
77
|
-
.length + 1 + (plotCount ? plotCount * (Math.ceil(width / 64.0) + 1): 0);
|
|
78
|
-
worksheet.addImage(imageId, {
|
|
79
|
-
tl: {col: columnForImage, row: 0},
|
|
80
|
-
ext: {width, height},
|
|
81
|
-
});
|
|
82
|
-
} else {
|
|
83
|
-
const newWorksheet = exportWorkbook.addWorksheet(`Output - Plot - ${visibleTitle}`);
|
|
84
|
-
newWorksheet.addImage(imageId, {
|
|
85
|
-
tl: {col: 0, row: 0},
|
|
86
|
-
ext: {width, height},
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const exportImage = async (imageDiv: Element, visibleTitle: string) => {
|
|
92
|
-
const regex = /background-image: url\(.*\)/;
|
|
93
|
-
const urlAttr = imageDiv.outerHTML.match(regex)?.[0];
|
|
94
|
-
if (!urlAttr) return;
|
|
95
|
-
const url = urlAttr.substring(23, urlAttr?.length - 2);
|
|
96
|
-
const pic = (await(await fetch(url)).arrayBuffer());
|
|
97
|
-
const imageId = exportWorkbook.addImage({
|
|
98
|
-
buffer: pic,
|
|
99
|
-
extension: 'png',
|
|
100
|
-
});
|
|
101
|
-
addToFile(imageId, visibleTitle, imageDiv.clientWidth, imageDiv.clientHeight);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const exportPlot = async (plotDiv: ChildNode | null | undefined,
|
|
105
|
-
blockDiv: Element, visibleTitle: string, plotCount? : number) => {
|
|
106
|
-
const titleDiv = blockDiv.firstChild as HTMLElement;
|
|
107
|
-
if (!titleDiv) return;
|
|
108
|
-
|
|
109
|
-
if (plotDiv && !titleDiv.getElementsByClassName('svg-table').length &&
|
|
110
|
-
(plotDiv as HTMLElement).getAttribute('name') === 'viewer-Grid') return;
|
|
111
|
-
|
|
112
|
-
if (plotDiv && titleDiv.getElementsByClassName('svg-table').length) {
|
|
113
|
-
if ((plotDiv as HTMLElement).getAttribute('name') === 'viewer-OutliersSelectionViewer') {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if ((plotDiv as HTMLElement).getAttribute('name') === 'viewer-Grid') {
|
|
117
|
-
(titleDiv.getElementsByClassName('svg-table')[0] as HTMLElement).click();
|
|
118
|
-
await new Promise((r) => setTimeout(r, 150));
|
|
119
|
-
plotDiv = titleDiv.nextSibling;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (plotDiv) {
|
|
124
|
-
const plot = (plotDiv as HTMLElement).getElementsByClassName('d4-layout-middle')[0];
|
|
125
|
-
const canvas = await DG.HtmlUtils.renderToCanvas(plot as HTMLElement);
|
|
126
|
-
const dataUrl = canvas.toDataURL('image/png');
|
|
127
|
-
|
|
128
|
-
const imageId = exportWorkbook.addImage({
|
|
129
|
-
base64: dataUrl,
|
|
130
|
-
extension: 'png',
|
|
131
|
-
});
|
|
132
|
-
addToFile(imageId, visibleTitle, canvas.width, canvas.height, plotCount);
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const exportTab = async (tab: HTMLElement) => {
|
|
137
|
-
const blockDivs = document.getElementsByClassName('ui-div ui-block');
|
|
138
|
-
let visibleTitle: string = '';
|
|
139
|
-
let plotCount: number = 0;
|
|
140
|
-
|
|
141
|
-
for (let i = 0; i < blockDivs.length; i++) {
|
|
142
|
-
const blockDiv = blockDivs[i];
|
|
143
|
-
|
|
144
|
-
if ((blockDiv as HTMLElement).style.display === 'none') continue;
|
|
145
|
-
|
|
146
|
-
if (blockDiv.firstChild?.firstChild?.textContent) {
|
|
147
|
-
visibleTitle = blockDiv.firstChild?.firstChild?.textContent;
|
|
148
|
-
plotCount = 0;
|
|
149
|
-
} else {
|
|
150
|
-
plotCount++;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if ((blockDiv.firstChild?.nextSibling as HTMLElement).getAttribute('name') === 'viewer-OutliersSelectionViewer') {
|
|
154
|
-
plotCount--;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const imageDiv = blockDiv.getElementsByClassName('grok-scripting-image-container')[0];
|
|
158
|
-
if (imageDiv) {
|
|
159
|
-
await exportImage(imageDiv, visibleTitle);
|
|
160
|
-
} else {
|
|
161
|
-
const plotDiv: ChildNode | null | undefined = blockDiv.firstChild?.nextSibling;
|
|
162
|
-
await exportPlot(plotDiv, blockDiv, visibleTitle, plotCount);
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
// UWAGA: very fragile solution
|
|
168
|
-
const funcView = document.getElementsByClassName('grok-view grok-view-func ui-box')[0];
|
|
169
|
-
const resultView = funcView.getElementsByClassName('d4-tab-host ui-box')[0];
|
|
170
|
-
if (resultView) {
|
|
171
|
-
const tabs = resultView.getElementsByClassName('d4-tab-header-stripe')[0].children;
|
|
172
|
-
const selectedByUser = resultView.getElementsByClassName('d4-tab-header selected')[0];
|
|
173
|
-
for (let i=0; i< tabs.length; i++) {
|
|
174
|
-
const tab = tabs[i] as HTMLElement;
|
|
175
|
-
tab.click();
|
|
176
|
-
await new Promise((r) => setTimeout(r, 150));
|
|
177
|
-
await exportTab(tab);
|
|
178
|
-
}
|
|
179
|
-
(selectedByUser as HTMLElement).click();
|
|
180
|
-
} else {
|
|
181
|
-
const resultView = document.getElementsByClassName('ui-panel grok-func-results')[0];
|
|
182
|
-
await exportTab(resultView as HTMLElement);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (scalarOutputs.length) {
|
|
186
|
-
const outputScalarsSheet = exportWorkbook.addWorksheet('Output scalars');
|
|
187
|
-
scalarOutputs.forEach((scalarOutput) => {
|
|
188
|
-
outputScalarsSheet.addRow([scalarOutput.name, call.outputs[scalarOutput.name]]);
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const metadataSheet = exportWorkbook.addWorksheet('Function run metadata');
|
|
193
|
-
metadataSheet.addRow(['Author', `${call.func.author.lastName} ${call.func.author.firstName}`]);
|
|
194
|
-
metadataSheet.addRow(['Login', call.func.author.toString()]);
|
|
195
|
-
|
|
196
|
-
exportWorkbook.xlsx.writeBuffer().then((data) => {
|
|
197
|
-
const blob = new Blob([data], {type: BLOB_TYPE});
|
|
198
|
-
saveAs(blob, `${call.func.name} - ${new Date().toLocaleString()}`);
|
|
199
|
-
});
|
|
200
|
-
}
|