@datagrok/compute 0.9.2 → 1.0.0

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.
@@ -1,19 +1,20 @@
1
1
  # Outliers selection
2
2
 
3
- The dialog performs manual or automatic outlier selection in the input dataframe.
3
+ The dialog performs manual or automatic outlier selection in the input dataframe.
4
4
 
5
- It returns
6
- 1) the input data with outliers marked in additional column
5
+ It returns
6
+
7
+ 1) the input data with outliers marked in additional column
7
8
  2) the input data with outliers removed
8
9
 
9
10
  ## Manual selection
10
11
 
11
- 1) Select the outliers on the scatterplot holding `Shift` key.
12
+ 1) Select the outliers on the scatterplot holding `Shift` key.
12
13
  2) Click the `Mark` button
13
14
  3) Enter the reason why the selected plot points are considered as outliers
14
15
  4) Click `OK`
15
16
 
16
- <img src="https://raw.githubusercontent.com/datagrok-ai/public/master/packages/Compute/help/OutliersSelection/manual-selection-demo.gif"/>
17
+ <img src="https://raw.githubusercontent.com/datagrok-ai/public/master/packages/Compute/help/outliers-selection/manual-selection-demo.gif"/>
17
18
 
18
19
  ## Automatic detection
19
20
 
@@ -22,6 +23,5 @@ It returns
22
23
  3) Fill the corresponding function input parameters
23
24
  4) Click `OK`
24
25
 
25
- <img src="https://raw.githubusercontent.com/datagrok-ai/public/master/packages/Compute/help/OutliersSelection/auto-detection-
26
+ <img src="https://raw.githubusercontent.com/datagrok-ai/public/master/packages/Compute/help/outliers-selection/auto-detection-
26
27
  demo.gif"/>
27
-
package/icons/flux.png ADDED
Binary file
package/package.json CHANGED
@@ -1,33 +1,28 @@
1
1
  {
2
2
  "name": "@datagrok/compute",
3
3
  "friendlyName": "Compute",
4
- "version": "0.9.2",
4
+ "version": "1.0.0",
5
5
  "author": {
6
6
  "name": "Aufar Zakiev",
7
- "email": "aufar.zakiev@arcadia.spb.ru"
7
+ "email": "aufar.zakiev@softwarecountry.com"
8
8
  },
9
- "description": "Provides additional analytical and UI blocks for [Datagrok scientific computing](../../help/compute/compute.md)",
9
+ "description": "Provides additional analytical and UI blocks for [Datagrok scientific computing](../../help/compute/compute.md).",
10
10
  "repository": {
11
- "type": "git",
12
- "url": "https://github.com/datagrok-ai/public.git",
13
- "directory": "packages/Compute"
14
- },
11
+ "type": "git",
12
+ "url": "https://github.com/datagrok-ai/public.git",
13
+ "directory": "packages/Compute"
14
+ },
15
15
  "dependencies": {
16
- "@datagrok-libraries/utils": "^0.5.0",
16
+ "@datagrok-libraries/utils": "3.0.0",
17
17
  "cash-dom": "latest",
18
- "codemirror": "^5.64.0",
19
- "datagrok-api": "^1.4.4",
18
+ "datagrok-api": "latest",
20
19
  "dayjs": "latest",
21
- "exceljs": "^4.3.0",
22
- "file-saver": "^2.0.5",
23
- "rxjs": "^7.4.0",
20
+ "rxjs": "^6.5.5",
24
21
  "ts-loader": "latest",
25
22
  "typescript": "latest",
26
23
  "wu": "latest"
27
24
  },
28
25
  "devDependencies": {
29
- "@types/codemirror": "^5.60.5",
30
- "@types/file-saver": "^2.0.3",
31
26
  "@types/wu": "latest",
32
27
  "@typescript-eslint/eslint-plugin": "^5.1.0",
33
28
  "@typescript-eslint/parser": "^5.1.0",
@@ -56,6 +51,10 @@
56
51
  "debug-compute-compose": "grok publish compose",
57
52
  "release-compute-compose": "grok publish compose --release"
58
53
  },
54
+ "sources": [
55
+ "common/exceljs.min.js",
56
+ "common/html2canvas.min.js"
57
+ ],
59
58
  "canEdit": [
60
59
  "Developers"
61
60
  ],
@@ -0,0 +1,30 @@
1
+ //name: Default complex script JS
2
+ //description: Shows that default view works (or not)
3
+ //language: javascript
4
+ //tags: bioreactor
5
+ //input: dataframe test { viewer: Line chart(x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) }
6
+ //input: double S1 = 50 {caption: S1; units: ft² * BTU / hr °F}
7
+ //input: double S2 = 12 {caption: Initial scalar; units: L/min}
8
+ //input: double S3 = -2 {caption: Dummy scalar.; units: °C}
9
+ //input: double S4 = 5 {caption: Final S4; units: cells/mL}
10
+ //input: double S5 = 210.5 {caption: Final Volume; units: L}
11
+ //input: double S = 31.1 {caption: Temp.; units: °C}
12
+ //output: dataframe tempOnTime { viewer: Line chart(x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false); category: Cooling rate }
13
+ //output: double IC2 {caption: Culture temp.; units: °C; category: Cooling rate}
14
+ //output: dataframe tempOnTime2 { viewer: Line chart(x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Grid(block: 50); category: Cooling rate 2 }
15
+ //output: dataframe tempOnTime3 { viewer: Line chart(block: 100, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Scatter plot(block: 100, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false); category: Cooling rate 3 }
16
+ //output: dataframe tempOnTime4 { viewer: Line chart(block: 50, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false); category: Cooling rate 3 }
17
+ //output: dataframe tempOnTime5 { viewer: Line chart(block: 50, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Line chart(block: 50, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false); category: Cooling rate 3 }
18
+ //output: double IC3 {caption: Culture temp.; units: °C; category: Cooling rate 3}
19
+ //output: double IC4 {caption: Culture temp.; units: °C; category: Cooling rate 3}
20
+ //editor: Compute:RichFunctionViewEditor
21
+
22
+ tempOnTime = test
23
+ tempOnTime2 = tempOnTime
24
+ tempOnTime3 = tempOnTime
25
+ tempOnTime4 = tempOnTime
26
+ tempOnTime5 = tempOnTime
27
+
28
+ IC2 = S1
29
+ IC3 = S1
30
+ IC4 = S1 * 2
@@ -0,0 +1,13 @@
1
+ //name: Default import script
2
+ //description: desc
3
+ //language: javascript
4
+ //input: file uploadedFile
5
+ //output: dataframe df { viewer: Grid(); }
6
+ //editor: Compute:RichFunctionViewEditor
7
+
8
+ const wb = new ExcelJS.Workbook();
9
+ await wb.xlsx.load(await uploadedFile.arrayBuffer());
10
+
11
+ const df_ws = wb.getWorksheet("df");
12
+ let data = await df_ws.workbook.csv.writeBuffer();
13
+ df = grok.data.parseCsv(data.toString());
@@ -0,0 +1,35 @@
1
+ //name: Default simple script JS
2
+ //description: Shows that default view works (or not)
3
+ //language: javascript
4
+ //tags: bioreactor
5
+ //input: double S1 = 1 {caption: S1; units: ft² * BTU / hr °F; category: Category1}
6
+ //input: double S2 = 100 {caption: Initial scalar; units: L/min; category: Category1}
7
+ //input: double S3 = -2 {caption: Dummy scalar.; units: °C; category: Category1}
8
+ //input: double S4 = 5 {caption: Final S4; units: cells/mL; category: Category2}
9
+ //input: double S5 = 210.5 {caption: Final Volume; units: L; category: Category2}
10
+ //input: double S = 31.1 {caption: Temp.; units: °C; category: Category2}
11
+ //output: dataframe tempOnTime { viewer: Line chart(block: 50, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Statistics(block: 50); category: CoolingRate }
12
+ //output: dataframe tempOnTime2 { viewer: Line chart(block: 25, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Grid(block: 75); category: CoolingRate2 }
13
+ //output: double O1 {caption: Temp 1.; units: °C; category: CoolingRate2 }
14
+ //output: dataframe tempOnTime3 { caption: "My lovely caption"; viewer: Line chart(block: 75, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Grid(block: 25); category: CoolingRate2 }
15
+ //output: double O2 {caption: Temp 2.; units: °C; category: CoolingRate3 }
16
+ //output: double O3 {caption: Temp 3.; units: °C; category: CoolingRate3 }
17
+ //output: double O4 {caption: Temp 4.; units: °C; category: CoolingRate3 }
18
+ //output: double O5 {caption: Temp 5.; units: °C; category: CoolingRate3 }
19
+ //editor: Compute:RichFunctionViewEditor
20
+
21
+ const tt = [...Array(S2).keys()]
22
+ const Sol = [...Array(S2).keys()].map((x) => x*2)
23
+
24
+ tempOnTime = DG.DataFrame.fromColumns([
25
+ DG.Column.float("Time (hours)", S2).init((i) => tt[i]),
26
+ DG.Column.float("Temperature (°C)", S2).init((i) => Sol[i]),
27
+ ])
28
+ tempOnTime2 = tempOnTime
29
+ tempOnTime3 = tempOnTime
30
+
31
+ O1 = S2
32
+ O2 = S2
33
+ O3 = S2
34
+ O4 = S2
35
+ O5 = S2
@@ -0,0 +1,12 @@
1
+ import * as rxjs from "rxjs";
2
+
3
+ export class ImportGeneratorStore {
4
+ scriptName: string = '';
5
+ description: string = '';
6
+ dfSheetsToSeek: string[] = [];
7
+ scalarsToSeek: string[] = []
8
+
9
+ scriptText = new rxjs.BehaviorSubject('');
10
+ infoText = new rxjs.BehaviorSubject('');
11
+ lastSavedScriptId = new rxjs.BehaviorSubject('');
12
+ }
@@ -0,0 +1,185 @@
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 { ImportGeneratorStore } from './store';
5
+
6
+ export class ImportScriptGeneratorApp extends DG.ViewBase {
7
+ store = new ImportGeneratorStore();
8
+ scriptNameInput = ui.stringInput('Script name', '', (v: string) => this.store.scriptName = v);
9
+ descriptionInput = ui.stringInput('Description', '', (v: string) => this.store.description = v);
10
+
11
+ constructor() {
12
+ super();
13
+
14
+ const runButton = ui.bigButton('Generate script', async () => await this.generate());
15
+ const saveButton = ui.bigButton('Save', async () => await this.save());
16
+ const openButton = ui.bigButton('Open', async () => this.open());
17
+ openButton.style.display = 'none';
18
+
19
+ this.store.lastSavedScriptId.subscribe((newId) => {
20
+ if (newId !== '') {
21
+ openButton.style.removeProperty('display');
22
+ }
23
+ })
24
+
25
+ const dynamicDFInput = (counter: number) => {
26
+ const deleteBtn = ui.button('Remove', () => {});
27
+ deleteBtn.style.width = deleteBtn.style.height;
28
+ deleteBtn.style.alignSelf = 'center';
29
+
30
+ this.store.dfSheetsToSeek.push('');
31
+
32
+ const containter = ui.divH([
33
+ ui.stringInput(`Sheet name #${counter}`, '', (v: string) => this.store.dfSheetsToSeek[counter] = v).root,
34
+ deleteBtn,
35
+ ], {style: {'justify-content': 'space-between'}});
36
+ deleteBtn.addEventListener('click', () => {
37
+ this.store.dfSheetsToSeek.splice(counter, 1);
38
+ containter.remove();
39
+ });
40
+
41
+ return containter;
42
+ }
43
+
44
+ const dynamicScalarInput = (counter: number) => {
45
+ const deleteBtn = ui.button('Remove', () => {});
46
+ deleteBtn.style.width = deleteBtn.style.height;
47
+ deleteBtn.style.alignSelf = 'center';
48
+
49
+ this.store.scalarsToSeek.push('');
50
+
51
+ const containter = ui.divH([
52
+ ui.stringInput(`Scalar name #${counter}`, '', (v: string) => this.store.scalarsToSeek[counter] = v).root,
53
+ deleteBtn,
54
+ ], {style: {'justify-content': 'space-between'}});
55
+ deleteBtn.addEventListener('click', () => {
56
+ this.store.scalarsToSeek.splice(counter, 1);
57
+ containter.remove();
58
+ });
59
+
60
+ return containter;
61
+ }
62
+
63
+ const dfInputsDiv = ui.divV([]);
64
+ const dfInputAddBtn = ui.button('Add DF to search', () => {
65
+ dfInputsDiv.append(dynamicDFInput(this.store.dfSheetsToSeek.length))
66
+ });
67
+
68
+ const scalarsInputsDiv = ui.divV([]);
69
+ const scalarsInputAddBtn = ui.button('Add scalar to search', () => {
70
+ scalarsInputsDiv.append(dynamicScalarInput(this.store.scalarsToSeek.length))
71
+ });
72
+
73
+ const formDiv = ui.divV([
74
+ ui.h3('Script properties'),
75
+ this.scriptNameInput.root,
76
+ this.descriptionInput.root,
77
+ ui.h3('Dataframes to search'),
78
+ dfInputsDiv,
79
+ dfInputAddBtn,
80
+ ui.h3('Scalars to search'),
81
+ scalarsInputsDiv,
82
+ scalarsInputAddBtn,
83
+ ui.divH([runButton], {style: {'justify-content': 'flex-end'}})
84
+ ], 'ui-form');
85
+
86
+ let scriptDiv = ui.divText(this.store.scriptText.value);
87
+ let infoDiv = ui.info(this.store.infoText.value);
88
+
89
+ const outputDiv = ui.panel([
90
+ ui.h3('Script text'),
91
+ scriptDiv,
92
+ infoDiv,
93
+ ui.divH([saveButton, openButton], {style: {'justify-content': 'flex-end'}})
94
+ ], {style: {display: 'none'}})
95
+ this.store.scriptText.subscribe((newScriptText) => {
96
+ const newScriptDiv = ui.divText(newScriptText);
97
+ scriptDiv.replaceWith(newScriptDiv);
98
+ scriptDiv = newScriptDiv;
99
+
100
+ if (newScriptText !== '') outputDiv.style.removeProperty('display');
101
+ })
102
+ this.store.infoText.subscribe((newInfoText) => {
103
+ const newInfoDiv = (newInfoText === '') ? ui.div([]) : ui.info(newInfoText);
104
+ infoDiv.replaceWith(newInfoDiv);
105
+ infoDiv = newInfoDiv;
106
+ })
107
+
108
+ this.root.appendChild(ui.splitH([formDiv, outputDiv], {style: {height: '100%', width: '100%'}}, true));
109
+
110
+ ui.tools.handleResize(formDiv.parentElement!, (width) => {
111
+ if (width < 350)
112
+ formDiv.classList.add('ui-form-condensed');
113
+ else
114
+ formDiv.classList.remove('ui-form-condensed');
115
+ });
116
+ formDiv.parentElement!.style.maxWidth = '340px';
117
+ }
118
+
119
+ async generate() {
120
+ const dfOutputsLines = this.store.dfSheetsToSeek.map((dfName) => `//output: dataframe ${dfName.trim()} { viewer: Grid(); }`).join("\n");
121
+ const scalarsLines = this.store.scalarsToSeek.map((scalarName) => `//output: string ${scalarName.trim()}`).join("\n");
122
+
123
+ const fileParsingCode =
124
+ `
125
+ const wb = new ExcelJS.Workbook();
126
+ await wb.xlsx.load(await uploadedFile.arrayBuffer());
127
+ const dfSheetsToSeek = ["${this.store.dfSheetsToSeek.join(`","`)}"];`
128
+
129
+ const dfParsingCode = (dfName: string) =>
130
+ `
131
+ const ${dfName}_ws = wb.getWorksheet("${dfName}");
132
+ let ${dfName}_data = await ${dfName}_ws.workbook.csv.writeBuffer();
133
+ ${dfName} = grok.data.parseCsv(${dfName}_data.toString());`
134
+
135
+ const getAllScalars = () =>
136
+ `
137
+ const scalarSheets = wb.worksheets.filter(ws => !dfSheetsToSeek.includes(ws.name));
138
+ const scalarNames = scalarSheets.flatMap((sheet) => sheet.getColumn(1).values);
139
+ const scalarValues = scalarSheets.flatMap((sheet) => sheet.getColumn(2).values);`
140
+
141
+ const scalarParsingCode = (searchName: string) =>
142
+ `
143
+ const ${searchName}_index = scalarNames.findIndex((scalarName) => scalarName === "${searchName}");
144
+ ${searchName} = (${searchName}_index >= 0) ? scalarValues[${searchName}_index] : '';`
145
+
146
+ let scriptText = `//name: ${this.store.scriptName}` + "\n";
147
+ scriptText += `//description: ${this.store.description}` + "\n";
148
+ scriptText += `//language: javascript` + "\n";
149
+ scriptText += `//input: file uploadedFile` + "\n";
150
+ scriptText += scalarsLines + "\n";
151
+ scriptText += dfOutputsLines + "\n";
152
+ scriptText += `//editor: Compute:FunctionViewEditor` + "\n";
153
+ scriptText += fileParsingCode + "\n";
154
+
155
+ this.store.dfSheetsToSeek.forEach((dfName) => {
156
+ scriptText += dfParsingCode(dfName.trim()) + "\n";
157
+ });
158
+
159
+ scriptText += getAllScalars();
160
+
161
+ this.store.scalarsToSeek.forEach((scalarName) => {
162
+ scriptText += scalarParsingCode(scalarName) + "\n";
163
+ })
164
+
165
+ this.store.scriptText.next(scriptText);
166
+
167
+ const duplicates = await grok.dapi.scripts.filter(`name="${this.store.scriptName}"`).list();
168
+ if (duplicates.length > 0){
169
+ this.store.infoText.next(`Script named "${this.store.scriptName}" already exists`);
170
+ }else {
171
+ this.store.infoText.next(``);
172
+ }
173
+ }
174
+
175
+ async save() {
176
+ const resultScript = DG.Script.create(this.store.scriptText.value);
177
+ const savedScript = await grok.dapi.scripts.save(resultScript);
178
+ this.store.lastSavedScriptId.next(savedScript.id);
179
+ grok.shell.info(`Script "${this.store.scriptName}" has been saved successfully`)
180
+ }
181
+
182
+ open() {
183
+ window.open(`${window.location.origin}/script/${this.store.lastSavedScriptId.value}`)
184
+ }
185
+ }
@@ -1,13 +1,12 @@
1
1
  import * as grok from 'datagrok-api/grok';
2
2
  import * as ui from 'datagrok-api/ui';
3
3
  import * as DG from 'datagrok-api/dg';
4
+ import * as rxjs from "rxjs";
4
5
  import {ModelHandler} from './model-handler';
5
- import {onboardModel} from './onboard-model';
6
- import {Subscription} from "rxjs";
7
6
 
8
7
  /* eslint-disable */
9
8
 
10
- let propsSub: Subscription;
9
+ let propsSub: rxjs.Subscription;
11
10
 
12
11
  export class ModelCatalogView extends DG.CustomCardView {
13
12
 
@@ -2,7 +2,6 @@ import * as grok from 'datagrok-api/grok';
2
2
  import * as DG from "datagrok-api/dg";
3
3
  import * as ui from "datagrok-api/ui";
4
4
  import {ModelHandler} from './model-handler';
5
- import {TYPE} from "datagrok-api/dg";
6
5
  import $ from 'cash-dom';
7
6
  import {FunctionView} from "@datagrok-libraries/utils/src/function-view";
8
7
  const api = <any>window;
@@ -28,6 +28,16 @@ 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
+
31
41
  const clearTable = () => {
32
42
  return DG.DataFrame.fromColumns([
33
43
  DG.Column.fromStrings(OUTLIER_RATIONALE_COL_LABEL, []),
@@ -51,16 +61,6 @@ export class OutliersSelectionViewer extends DG.JsViewer {
51
61
  ui.iconFA('check', () => {
52
62
  if (!groupsListGrid.dataFrame) return;
53
63
 
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
64
  //@ts-ignore
65
65
  inputData.col(IS_OUTLIER_COL_LABEL)?.markers.assign('true', DG.MARKER_TYPE.OUTLIER);
66
66
 
@@ -68,14 +68,15 @@ export class OutliersSelectionViewer extends DG.JsViewer {
68
68
  groupsListGrid.dataFrame?.cell(groupsListGrid.dataFrame.rowCount-1, OUTLIER_RATIONALE_COL_LABEL).value;
69
69
 
70
70
  inputData.selection.getSelectedIndexes().forEach((selectedIndex: number) => {
71
- inputData.set(IS_OUTLIER_COL_LABEL, selectedIndex, true);
72
- inputData.set(
73
- OUTLIER_RATIONALE_COL_LABEL,
71
+ inputData.col(IS_OUTLIER_COL_LABEL)!.set(selectedIndex, true, false);
72
+ inputData.col(OUTLIER_RATIONALE_COL_LABEL)!.set(
74
73
  selectedIndex,
75
74
  newRationale,
75
+ false,
76
76
  );
77
77
  });
78
78
  inputData.selection.setAll(false);
79
+ inputData.fireValuesChanged();
79
80
  }, 'Confirm the outliers'), {style: {'text-align': 'center', 'margin': '6px'}},
80
81
  );
81
82
 
@@ -92,10 +93,11 @@ export class OutliersSelectionViewer extends DG.JsViewer {
92
93
  ui.icons.delete(() => {
93
94
  for (let i = 0; i < inputData.rowCount; i++) {
94
95
  if (inputData.columns.byName(OUTLIER_RATIONALE_COL_LABEL).get(i) === rationale) {
95
- inputData.columns.byName(OUTLIER_RATIONALE_COL_LABEL).set(i, '');
96
- inputData.columns.byName(IS_OUTLIER_COL_LABEL).set(i, false);
96
+ inputData.columns.byName(OUTLIER_RATIONALE_COL_LABEL).set(i, '', false);
97
+ inputData.columns.byName(IS_OUTLIER_COL_LABEL).set(i, false, false);
97
98
  }
98
99
  }
100
+ inputData.fireValuesChanged();
99
101
  }, 'Remove the outliers group'), {style: {'text-align': 'center', 'margin': '6px'}},
100
102
  );
101
103
 
package/src/package.ts CHANGED
@@ -3,19 +3,30 @@ 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 {_functionParametersGrid} from './function-views/function-parameters-grid';
6
+ import {_functionParametersGrid} from './function-parameters-grid';
7
7
  import {ModelCatalogView} from './model-catalog-view';
8
8
  import wu from 'wu';
9
9
  import {OutliersSelectionViewer} from './outliers-selection/outliers-selection-viewer';
10
10
  //import {ModelsWidget} from './models-widget'
11
11
  import {delay} from "@datagrok-libraries/utils/src/test";
12
- import {ComputationView} from "@datagrok-libraries/utils/src/computation-view";
13
- import {FunctionView} from "@datagrok-libraries/utils/src/function-view";
12
+ import {RichFunctionView} from "@datagrok-libraries/utils/src/rich-function-view";
14
13
  import './css/model-card.css';
14
+ import { ImportScriptGeneratorApp } from './import-script-generator/view';
15
15
 
16
16
  let initCompleted: boolean = false;
17
17
  export const _package = new DG.Package();
18
18
 
19
+ //name: Import Script Generator
20
+ //description: Creates and registers a new script based on the input config
21
+ //tags: higher-order function, app
22
+ //meta.icon: icons/flux.png
23
+ export function importScriptGenerator(){
24
+ const app = new ImportScriptGeneratorApp();
25
+ app.name = 'Import Script Gen'
26
+ grok.shell.addView(app);
27
+ app.root.classList.remove('ui-panel');
28
+ }
29
+
19
30
  //name: OutliersSelectionViewer
20
31
  //description: Creates an outliers selection viewer
21
32
  //tags: viewer
@@ -24,28 +35,22 @@ export function OutliersSelection() {
24
35
  return new OutliersSelectionViewer();
25
36
  }
26
37
 
27
- //name: ComputationView
28
- //tags: model-editor, editor
38
+ //name: RichFunctionViewEditor
39
+ //tags: editor
29
40
  //input: funccall call
30
41
  //output: view result
31
- // export function ComputationViewEditor(call: DG.FuncCall) {
32
- // let v = new ComputationView(call);
33
- // v.parentCall = call;
34
- // v.name = call.func.friendlyName;
35
- // v.parentView = grok.functions.getCurrentCall().parentCall.aux['view']; // modelCatalog view
36
- // //todo: parse url, set parameters to call
37
- // return v;
38
- // }
39
-
40
- //name: FunctionView
41
- //tags: model-editor, editor
42
+ export function RichFunctionViewEditor(call: DG.FuncCall) {
43
+ return RichFunctionView.fromFuncCall(call, {historyEnabled: true, isTabbed: false});
44
+ }
45
+
46
+ //name: PipelineStepEditor
47
+ //tags: editor
42
48
  //input: funccall call
43
49
  //output: view result
44
- export function FunctionViewEditor(call: DG.FuncCall) {
45
- return new FunctionView(call);
50
+ export function PipelineStepEditor(call: DG.FuncCall) {
51
+ return RichFunctionView.fromFuncCall(call, {historyEnabled: false, isTabbed: true});
46
52
  }
47
53
 
48
-
49
54
  /*//output: widget result
50
55
  //tags: dashboard
51
56
  export function modelsWidget(): DG.Widget {
@@ -76,7 +81,7 @@ export function hof() {
76
81
 
77
82
 
78
83
  //name: hof2
79
- //tags:
84
+ //tags:
80
85
  //description: some description 2 2 2
81
86
  //sidebar: @compute
82
87
  //meta.icon: package1.png
@@ -205,7 +210,7 @@ export function modelCatalog() {
205
210
  let modelsView = ModelHandler.findModelCatalogView();
206
211
  if (modelsView == null) {
207
212
  let view = new ModelCatalogView();
208
- view.name = 'Models';
213
+ view.name = 'ModelHub';
209
214
  let parser = document.createElement('a');
210
215
  parser.href = window.location.href;
211
216
  let pathSegments = parser.pathname.split('/');
package/tsconfig.json CHANGED
@@ -6,7 +6,7 @@
6
6
  // "incremental": true, /* Enable incremental compilation */
7
7
  "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8
8
  "module": "es2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9
- "lib": ["es2020", "dom"], /* Specify library files to be included in the compilation. */
9
+ "lib": ["es2022", "dom"], /* Specify library files to be included in the compilation. */
10
10
  // "allowJs": true, /* Allow javascript files to be compiled. */
11
11
  // "checkJs": true, /* Report errors in .js files. */
12
12
  // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
@@ -57,12 +57,12 @@
57
57
  /* Source Map Options */
58
58
  // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
59
59
  // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
61
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
60
+ "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
61
+ "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
62
62
 
63
63
  /* Experimental Options */
64
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
65
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
64
+ "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
65
+ "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
66
66
 
67
67
  /* Advanced Options */
68
68
  "skipLibCheck": false, /* Skip type checking of declaration files. */
package/webpack.config.js CHANGED
@@ -17,8 +17,8 @@ module.exports = {
17
17
  },
18
18
  ],
19
19
  },
20
- devtool: 'inline-source-map',
21
- externals: {
20
+ devtool: 'source-map',
21
+ externals: { // external modules won't be loaded to the output, but taken from the environment
22
22
  'datagrok-api/dg': 'DG',
23
23
  'datagrok-api/grok': 'grok',
24
24
  'datagrok-api/ui': 'ui',
@@ -28,6 +28,8 @@ module.exports = {
28
28
  'cash-dom': '$',
29
29
  'dayjs': 'dayjs',
30
30
  'wu': 'wu',
31
+ 'exceljs': 'ExcelJS',
32
+ 'html2canvas': 'html2canvas'
31
33
  },
32
34
  output: {
33
35
  filename: '[name].js',
@@ -1,27 +0,0 @@
1
- [
2
- {
3
- "name": "Bioreactor simulation",
4
- "props": [
5
- {
6
- "name": "reactorType",
7
- "type": "string",
8
- "choices": ["Experimental", "Production"]
9
- },
10
- {
11
- "name": "department",
12
- "type": "string",
13
- "choices": ["", "Production"]
14
- }
15
- ]
16
- },
17
- {
18
- "name": "Biosensors",
19
- "props": [
20
- {
21
- "name": "sensor",
22
- "type": "string",
23
- "choices": ["Accelerometer", "GSR", "EEG", "ECG", "Eye Tracker"]
24
- }
25
- ]
26
- }
27
- ]