@datagrok/compute 0.6.7 → 0.7.3

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.
@@ -7,23 +7,17 @@ export class OutliersSelectionViewer extends DG.JsViewer {
7
7
  super();
8
8
  }
9
9
 
10
- // override to handle property changes
11
- onPropertyChanged(prop: any) {
12
- grok.shell.info(`${prop.name}: ${prop.get(this)}`);
10
+ onFrameAttached(dataFrame: DG.DataFrame): void {
11
+ this.dataFrame = dataFrame;
12
+ this.render();
13
13
  }
14
14
 
15
- onTableAttached() {
16
- if (this.dataFrame) {
17
- this.initialRender();
18
- }
15
+ onTableAttached(): void {
16
+ this.render();
19
17
  }
20
18
 
21
19
  render() {
22
-
23
- }
24
-
25
- initialRender() {
26
- if (!this.dataFrame) {
20
+ if (!this.dataFrame || this.dataFrame.rowCount <= 0) {
27
21
  this.root.innerHTML = '';
28
22
  return;
29
23
  }
@@ -33,24 +27,6 @@ export class OutliersSelectionViewer extends DG.JsViewer {
33
27
  const OUTLIER_RATIONALE_COL_LABEL = 'Rationale';
34
28
  const OUTLIER_COUNT_COL_LABEL = 'Count';
35
29
  const IS_GROUP_CONFIRMED_LABEL = 'isConfirmed';
36
- const FLUX = 't/V (hr/(L/m²))';
37
- const DEFAULT_TEST_AREA = 3.5;
38
-
39
- if (!inputData.columns.byName(IS_OUTLIER_COL_LABEL)) {
40
- inputData.columns
41
- .add(DG.Column.fromBitSet(IS_OUTLIER_COL_LABEL, DG.BitSet.create(inputData.rowCount, () => false)));
42
- }
43
-
44
- if (!inputData.columns.byName(OUTLIER_RATIONALE_COL_LABEL)) {
45
- inputData.columns
46
- .add(DG.Column.fromStrings(OUTLIER_RATIONALE_COL_LABEL, Array.from({length: inputData.rowCount}, () => '')));
47
- }
48
-
49
- if (!inputData.columns.byName(FLUX)) {
50
- (inputData.columns as DG.ColumnList).addNew(FLUX, 'double').init((index) => (inputData.cell(index, 'time (min)').value/60.0) / ((inputData.cell(index, 'filtrate volume (mL)').value/1000.0) / (DEFAULT_TEST_AREA / 10000.0)));
51
- }
52
-
53
- const initialData = inputData.clone();
54
30
 
55
31
  const clearTable = () => {
56
32
  return DG.DataFrame.fromColumns([
@@ -75,6 +51,19 @@ export class OutliersSelectionViewer extends DG.JsViewer {
75
51
  ui.iconFA('check', () => {
76
52
  if (!groupsListGrid.dataFrame) return;
77
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
+
78
67
  const newRationale =
79
68
  groupsListGrid.dataFrame?.cell(groupsListGrid.dataFrame.rowCount-1, OUTLIER_RATIONALE_COL_LABEL).value;
80
69
 
@@ -142,14 +131,30 @@ export class OutliersSelectionViewer extends DG.JsViewer {
142
131
  });
143
132
 
144
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
+
145
148
  const uniqueValues: {[key:string]: number} = {};
146
- for (let i = 0; i < inputData.rowCount; i++) {
147
- const record = inputData.columns.byName(OUTLIER_RATIONALE_COL_LABEL).get(i);
148
- const count = uniqueValues[record];
149
- if (record != '') {
150
- count ?
151
- uniqueValues[record]++ :
152
- uniqueValues[record] = 1;
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
+ }
153
158
  }
154
159
  }
155
160
  groupsListGrid.dataFrame = clearTable();
@@ -183,14 +188,8 @@ export class OutliersSelectionViewer extends DG.JsViewer {
183
188
 
184
189
  updateGroupsTable();
185
190
 
186
- // const info = ui.info(
187
- // ui.div([
188
- // ui.p('Hold the “SHIFT” key and start to draw a freehand selection on the plot area'),
189
- // ], {style: {'white-space': 'pre-wrap'}}),
190
- // );
191
- // info.style.marginBottom = '0px';
192
-
193
- this.root.replaceWith(
191
+ this.root.innerHTML = '';
192
+ this.root.appendChild(
194
193
  ui.divV([
195
194
  ui.divV([
196
195
  groupsListGrid.root,
package/src/package.ts CHANGED
@@ -3,21 +3,18 @@ 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
- import {_functionEditor} from './function-editor/function-editor';
11
9
  import {OutliersSelectionViewer} from './outliers-selection/outliers-selection-viewer';
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";
12
14
 
13
15
  let initCompleted: boolean = false;
14
16
  export const _package = new DG.Package();
15
17
 
16
- //name: test
17
- export function test() {
18
- grok.shell.info(_package.webRoot);
19
- }
20
-
21
18
  //name: OutliersSelectionViewer
22
19
  //description: Creates an outliers selection viewer
23
20
  //tags: viewer
@@ -26,81 +23,12 @@ export function OutliersSelection() {
26
23
  return new OutliersSelectionViewer();
27
24
  }
28
25
 
29
- //name: Export to Excel
30
- //input: funccall call
31
- //tags: export
32
- export function exportToExcel(call: DG.FuncCall) {
33
- exportFuncCall(call);
34
- }
35
26
 
36
- //name: Function Editor
37
- export function functionEditor() {
38
- const sampleScript = `
39
- #name: Chemical Space Using tSNE
40
- #description: Chemical space using t-distributed Stochastic Neighbor Embedding
41
- #help-url: https://datagrok.ai/help/domains/chem/functions/tsne
42
- #language: python
43
- #sample: chem/smiles_coordinates.csv
44
- #tags: demo, chem, rdkit
45
- #input: dataframe t1 {columns: numerical; category: test} [first input data table]
46
- #input: dataframe t2 {columns: numerical} [second input data table]
47
- #input: column x {type: numerical; table: t1} [x axis column name]
48
- #input: column y {type: numerical} [y axis column name]
49
- #input: column date {type: datetime; format: mm/dd/yyyy} [date column name]
50
- #input: column_list numdata {type :numerical; table:t1} [numerical columns names]
51
- #input: int numcomp = 2 {min: 2; max: 7; units: mm} [number of components]
52
- #input: bool center = true [number of components]
53
- #input: string type = high {choices: ["high", "low"]} [type of filter]
54
- #output: dataframe result {action: join(t1)} [pca components]
55
- #output: graphics scatter [scatter plot]
56
-
57
- import numba
58
- import hdbscan
59
- import numpy as np
60
- import matplotlib.pyplot as plt
61
- from sklearn.manifold import TSNE
62
- from rdkit import Chem
63
- from rdkit.Chem import AllChem
64
- from rdkit.Chem import Draw
65
- from rdkit.Chem import DataStructs
66
-
67
- smiles = data[smiles]
68
- mols = [Chem.MolFromSmiles(mol) for mol in smiles]
69
- mols = [mol for mol in mols if mol is not None]
70
- for mol in mols:
71
- AllChem.Compute2DCoords(mol)
72
- X = []
73
- for mol in mols:
74
- arr = np.zeros((0,))
75
- fp = AllChem.GetMorganFingerprintAsBitVect(mol, 2)
76
- DataStructs.ConvertToNumpyArray(fp, arr)
77
- X.append(arr)
78
-
79
- @numba.njit()
80
- def tanimoto_dist(a, b):
81
- dotprod = np.dot(a, b)
82
- tc = dotprod / (np.sum(a) + np.sum(b) - dotprod)
83
- return 1.0 - tc
84
-
85
- tsne = TSNE(n_components=components, metric=tanimoto_dist)
86
- tsne_X = tsne.fit_transform(X)
87
- cluster_tsne = hdbscan.HDBSCAN(min_cluster_size=minClusterSize, gen_min_span_tree=True)
88
- cluster_tsne.fit(tsne_X)
89
-
90
- plt.figure(0)
91
- cluster_tsne.minimum_spanning_tree_.plot(
92
- edge_cmap='viridis', edge_alpha=0.6,
93
- node_size=90, edge_linewidth=2)
94
-
95
- plt.figure(1)
96
- cluster_tsne.single_linkage_tree_.plot(cmap='viridis', colorbar=True)
97
-
98
- plt.figure(2)
99
- plt.scatter(tsne_X.T[0], tsne_X.T[1], c=cluster_tsne.labels_, cmap='plasma')
100
- plt.title('Chemical space')
101
- `;
102
- _functionEditor(sampleScript);
103
- }
27
+ /*//output: widget result
28
+ //tags: dashboard
29
+ export function modelsWidget(): DG.Widget {
30
+ return new ModelsWidget();
31
+ }*/
104
32
 
105
33
  /* eslint-disable */
106
34
 
@@ -110,10 +38,13 @@ export function functionEditor() {
110
38
  //output: view result
111
39
  export function functionParametersGrid(f: DG.Func): DG.View {
112
40
  return _functionParametersGrid(f);
41
+ document.getElementById('root')?.appendChild(ui.h1('Hello World'));
113
42
  }
114
43
 
115
44
  //name: hof
45
+ //tags: model
116
46
  export function hof() {
47
+ grok.shell.info('blablabla');
117
48
  let f: DG.Func = DG.Func.byName('Sin');
118
49
  let v: DG.View = functionParametersGrid(f);
119
50
  grok.shell.addView(v);
@@ -200,8 +131,8 @@ export function init() {
200
131
  }).root;
201
132
  });
202
133
 
203
- grok.events.onViewAdding.subscribe((v: DG.View) => {
204
- if (v instanceof DG.FunctionView && v.func?.hasTag("model")) {
134
+ /* grok.events.onViewAdding.subscribe((v: DG.ViewBase) => {
135
+ if (v instanceof ComputationView && (v as ComputationView).func?.hasTag("model")) {
205
136
  let modelsView = wu(grok.shell.views).find((v) => v.parentCall?.func.name == 'modelCatalog');
206
137
  if (modelsView != undefined) {
207
138
  v.parentCall = modelsView!.parentCall;
@@ -209,20 +140,33 @@ export function init() {
209
140
  v.toolbox = modelsList;
210
141
  }
211
142
  }
212
- });
143
+ });*/
213
144
 
214
145
  initCompleted = true;
215
146
  }
216
147
 
217
148
  //name: Model Catalog
218
149
  //tags: app
219
- export function modelCatalog() {
220
- /* let view = new DG.MultiView({
221
- viewFactories: {
222
- 'Models': {factory: () => new ModelCatalogView(), allowClose: false}
223
- }
224
- });*/
225
- let view = new ModelCatalogView();
226
- view.name = 'Models';
227
- grok.shell.addView(view);
150
+ export function modelCatalog() {
151
+ let view = new ModelCatalogView();
152
+ view.name = 'Models';
153
+ grok.shell.addView(view);
154
+ }
155
+
156
+
157
+ //name: computationTest
158
+ //input: int delayMs {description: Wait time; units: ms}
159
+ //input: string error {description: When specified, throws this error}
160
+ //output: dataframe result
161
+ export async function computationTest(delayMs: number, error: string): Promise<DG.DataFrame> {
162
+ await delay(delayMs);
163
+ if (error != null || error != '')
164
+ throw error;
165
+ return grok.data.demo.demog();
166
+ }
167
+
168
+ //name: testComputationView();
169
+ export function testComputationView() {
170
+ let f = DG.Func.find({name: 'computationTest'})[0];
171
+ //grok.shell.addView(new ComputationView(f));
228
172
  }
@@ -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/detectors.js DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * The class contains semantic type detectors.
3
- * Detectors are functions tagged with `DG.FUNC_TYPES.SEM_TYPE_DETECTOR`.
4
- * See also: https://datagrok.ai/help/develop/how-to/define-semantic-type-detectors
5
- * The class name is comprised of <PackageName> and the `PackageDetectors` suffix.
6
- * Follow this naming convention to ensure that your detectors are properly loaded.
7
- */
8
- class ComputePackageDetectors extends DG.Package {
9
- }
@@ -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
- }