@datagrok/compute 0.8.3 → 0.9.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 +8755 -124
- package/help/{outliers_selection/auto_detection_demo.gif → OutliersSelection/auto-detection-demo.gif} +0 -0
- package/help/{outliers_selection → OutliersSelection}/main.md +3 -2
- package/help/{outliers_selection/manual_selection_demo.gif → OutliersSelection/manual-selection-demo.gif} +0 -0
- package/package.json +16 -11
- package/package.png +0 -0
- package/scripts/default-complex.m +28 -0
- package/scripts/default.m +18 -0
- package/scripts/{Fab Arm Exchange.py → fab-arm-exchange.py} +0 -0
- package/scripts/{Heat Exchange.js → heat-exchange.js} +0 -0
- package/scripts/{IntervalsFromECG.py → intervals-from-ecg.py} +0 -0
- package/scripts/{Logistic Map.js → logistic-map.js} +0 -0
- package/scripts/{Lorenz Attractor.js → lorenz-attractor.js} +0 -0
- package/scripts/{Maximal Volume.R → maximal-volume.R} +0 -0
- package/scripts/{popPK.R → pop-pk.R} +0 -0
- package/src/css/model-card.css +33 -0
- package/src/model-catalog-view.ts +25 -2
- package/src/model-handler.ts +94 -11
- package/src/package.ts +73 -31
|
File without changes
|
|
@@ -13,7 +13,7 @@ It returns
|
|
|
13
13
|
3) Enter the reason why the selected plot points are considered as outliers
|
|
14
14
|
4) Click `OK`
|
|
15
15
|
|
|
16
|
-
<img src="https://raw.githubusercontent.com/datagrok-ai/public/master/packages/Compute/help/
|
|
16
|
+
<img src="https://raw.githubusercontent.com/datagrok-ai/public/master/packages/Compute/help/OutliersSelection/manual-selection-demo.gif"/>
|
|
17
17
|
|
|
18
18
|
## Automatic detection
|
|
19
19
|
|
|
@@ -22,5 +22,6 @@ It returns
|
|
|
22
22
|
3) Fill the corresponding function input parameters
|
|
23
23
|
4) Click `OK`
|
|
24
24
|
|
|
25
|
-
<img src="https://raw.githubusercontent.com/datagrok-ai/public/master/packages/Compute/help/
|
|
25
|
+
<img src="https://raw.githubusercontent.com/datagrok-ai/public/master/packages/Compute/help/OutliersSelection/auto-detection-
|
|
26
|
+
demo.gif"/>
|
|
26
27
|
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/compute",
|
|
3
3
|
"friendlyName": "Compute",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.2",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Aufar Zakiev",
|
|
7
|
+
"email": "aufar.zakiev@arcadia.spb.ru"
|
|
8
|
+
},
|
|
5
9
|
"description": "Provides additional analytical and UI blocks for [Datagrok scientific computing](../../help/compute/compute.md)",
|
|
6
10
|
"repository": {
|
|
7
11
|
"type": "git",
|
|
@@ -9,10 +13,10 @@
|
|
|
9
13
|
"directory": "packages/Compute"
|
|
10
14
|
},
|
|
11
15
|
"dependencies": {
|
|
12
|
-
"@datagrok-libraries/utils": "^0.
|
|
16
|
+
"@datagrok-libraries/utils": "^0.5.0",
|
|
13
17
|
"cash-dom": "latest",
|
|
14
18
|
"codemirror": "^5.64.0",
|
|
15
|
-
"datagrok-api": "^1.
|
|
19
|
+
"datagrok-api": "^1.4.4",
|
|
16
20
|
"dayjs": "latest",
|
|
17
21
|
"exceljs": "^4.3.0",
|
|
18
22
|
"file-saver": "^2.0.5",
|
|
@@ -43,19 +47,20 @@
|
|
|
43
47
|
"build-compute": "webpack",
|
|
44
48
|
"build": "webpack",
|
|
45
49
|
"build-compute-local": "npm --prefix ./../../js-api run build && npm --prefix ./../../libraries/utils run build && npm run build",
|
|
46
|
-
"debug-compute-dev": "webpack && grok publish dev
|
|
50
|
+
"debug-compute-dev": "webpack && grok publish dev",
|
|
47
51
|
"release-compute-dev": "grok publish dev --release",
|
|
48
|
-
"debug-compute-local": "grok publish local
|
|
49
|
-
"release-compute-local": "grok publish local --
|
|
50
|
-
"debug-compute-localhost": "grok publish localhost
|
|
51
|
-
"release-compute-localhost": "grok publish localhost --
|
|
52
|
-
"debug-compute-compose": "grok publish compose
|
|
53
|
-
"release-compute-compose": "grok publish compose --
|
|
52
|
+
"debug-compute-local": "grok publish local",
|
|
53
|
+
"release-compute-local": "grok publish local --release",
|
|
54
|
+
"debug-compute-localhost": "grok publish localhost",
|
|
55
|
+
"release-compute-localhost": "grok publish localhost --release",
|
|
56
|
+
"debug-compute-compose": "grok publish compose",
|
|
57
|
+
"release-compute-compose": "grok publish compose --release"
|
|
54
58
|
},
|
|
55
59
|
"canEdit": [
|
|
56
60
|
"Developers"
|
|
57
61
|
],
|
|
58
62
|
"canView": [
|
|
59
63
|
"All users"
|
|
60
|
-
]
|
|
64
|
+
],
|
|
65
|
+
"category": "Machine Learning"
|
|
61
66
|
}
|
package/package.png
CHANGED
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#name: Default complex script
|
|
2
|
+
#description: Shows that default view works (or not)
|
|
3
|
+
#language: octave
|
|
4
|
+
#tags: bioreactor
|
|
5
|
+
#input: dataframe test { viewer: Line chart(x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) }
|
|
6
|
+
#input: double AA = 424.2832 {caption: AA; units: ft² * BTU / hr °F}
|
|
7
|
+
#input: double FWC = 12 {caption: Bblabla flowrate; units: L/min}
|
|
8
|
+
#input: double Dummy scalar = -2 {caption: Dummy scalar.; units: °C}
|
|
9
|
+
#input: double VCD = 5 {caption: VCD; units: cells/mL}
|
|
10
|
+
#input: double VL = 210.5 {caption: Final Volume; units: L}
|
|
11
|
+
#input: double IC = 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: 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 }
|
|
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
|
+
#editor: Compute:FunctionViewEditor
|
|
20
|
+
|
|
21
|
+
tempOnTime = test;
|
|
22
|
+
tempOnTime2 = tempOnTime;
|
|
23
|
+
tempOnTime3 = tempOnTime;
|
|
24
|
+
tempOnTime4 = tempOnTime;
|
|
25
|
+
tempOnTime5 = tempOnTime;
|
|
26
|
+
|
|
27
|
+
IC2 = IC
|
|
28
|
+
IC3 = IC
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#name: Default simple script
|
|
2
|
+
#description: Shows that default view works (or not)
|
|
3
|
+
#language: octave
|
|
4
|
+
#tags: bioreactor
|
|
5
|
+
#input: double AA = 424.2832 {caption: AA; units: ft² * BTU / hr °F}
|
|
6
|
+
#input: double FWC = 12 {caption:FWC; units: L/min}
|
|
7
|
+
#input: double Tcoolingin = -2 {caption: Coolant temp.; units: °C}
|
|
8
|
+
#input: double VCD = 5 {caption: Target VCD; units: cells/mL}
|
|
9
|
+
#input: double VL = 210.5 {caption: Final Volume; units: L}
|
|
10
|
+
#input: double IC = 31.1 {caption: Temp.; units: °C}
|
|
11
|
+
#output: dataframe tempOnTime { viewer: Line chart(x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false); category: Cooling rate }
|
|
12
|
+
#editor: Compute:FunctionViewEditor
|
|
13
|
+
|
|
14
|
+
tt = zeros(10, 1)
|
|
15
|
+
Sol = ones(10, 1)
|
|
16
|
+
|
|
17
|
+
labels = {"Time (hours)", "Temperature (°C)"};
|
|
18
|
+
tempOnTime = [labels; num2cell([tt, Sol])];
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/css/model-card.css
CHANGED
|
@@ -58,4 +58,37 @@
|
|
|
58
58
|
font-size: 14px;
|
|
59
59
|
padding: 4px 0;
|
|
60
60
|
color: var(--grey-6);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.model-catalog-video {
|
|
64
|
+
width: 80%;
|
|
65
|
+
height: 0;
|
|
66
|
+
padding-bottom: 50%;
|
|
67
|
+
margin: 10px 10px 0 0;
|
|
68
|
+
border: 1px solid var(--grey-2);
|
|
69
|
+
position: relative;
|
|
70
|
+
background-size: cover;
|
|
71
|
+
background-repeat: no-repeat;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.model-catalog-video i {
|
|
75
|
+
position: absolute;
|
|
76
|
+
right: 0;
|
|
77
|
+
left: 0;
|
|
78
|
+
bottom: 0;
|
|
79
|
+
top: 0;
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
font-weight: 600;
|
|
84
|
+
color: var(--grey-2);
|
|
85
|
+
font-size: 42px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.model-catalog-video i:hover {
|
|
89
|
+
color: var(--grey-1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.model-catalog-description {
|
|
93
|
+
padding: 10px 0 0 0;
|
|
61
94
|
}
|
|
@@ -3,9 +3,12 @@ import * as ui from 'datagrok-api/ui';
|
|
|
3
3
|
import * as DG from 'datagrok-api/dg';
|
|
4
4
|
import {ModelHandler} from './model-handler';
|
|
5
5
|
import {onboardModel} from './onboard-model';
|
|
6
|
+
import {Subscription} from "rxjs";
|
|
6
7
|
|
|
7
8
|
/* eslint-disable */
|
|
8
9
|
|
|
10
|
+
let propsSub: Subscription;
|
|
11
|
+
|
|
9
12
|
export class ModelCatalogView extends DG.CustomCardView {
|
|
10
13
|
|
|
11
14
|
constructor() {
|
|
@@ -20,7 +23,7 @@ export class ModelCatalogView extends DG.CustomCardView {
|
|
|
20
23
|
this.objectType = 'Func';
|
|
21
24
|
this.categoryFilters = {
|
|
22
25
|
'options.department': 'Department',
|
|
23
|
-
'options.
|
|
26
|
+
'options.HL_process': 'HL_process',
|
|
24
27
|
'options.process': 'Process',
|
|
25
28
|
'tag': 'Tags'
|
|
26
29
|
};
|
|
@@ -30,16 +33,36 @@ export class ModelCatalogView extends DG.CustomCardView {
|
|
|
30
33
|
'Favorites': 'starredBy = @current',
|
|
31
34
|
'Used by me': 'usedBy = @current'
|
|
32
35
|
};
|
|
36
|
+
|
|
33
37
|
this.hierarchy = [
|
|
34
38
|
'options.department',
|
|
35
|
-
'options.
|
|
39
|
+
'options.HL_process',
|
|
36
40
|
'options.process'
|
|
37
41
|
];
|
|
42
|
+
|
|
43
|
+
this.hierarchyProperties = {
|
|
44
|
+
'options.department': 'Department',
|
|
45
|
+
'options.HL_process': 'HL_process',
|
|
46
|
+
'options.process': 'Process'
|
|
47
|
+
};
|
|
48
|
+
|
|
38
49
|
this.showTree = true;
|
|
39
50
|
this.initRibbon();
|
|
40
51
|
this.initMenu();
|
|
52
|
+
this.currentCall = grok.functions.getCurrentCall();
|
|
53
|
+
if (propsSub == null && window.localStorage.getItem('ModelCatalogShowProperties') == null) { // @ts-ignore
|
|
54
|
+
propsSub = grok.events.onCurrentObjectChanged.subscribe((o) => {
|
|
55
|
+
if (new ModelHandler().isApplicable(o.sender)) {
|
|
56
|
+
grok.shell.windows.showProperties = true;
|
|
57
|
+
window.localStorage.setItem('ModelCatalogShowProperties', 'false');
|
|
58
|
+
propsSub.unsubscribe();
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
}
|
|
41
62
|
}
|
|
42
63
|
|
|
64
|
+
currentCall: DG.FuncCall;
|
|
65
|
+
|
|
43
66
|
initRibbon() {
|
|
44
67
|
this.setRibbonPanels([[ui.icons.sync(() => this.refresh())]]);
|
|
45
68
|
}
|
package/src/model-handler.ts
CHANGED
|
@@ -2,6 +2,7 @@ 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
4
|
import wu from "wu";
|
|
5
|
+
import {ModelCatalogView} from "./model-catalog-view";
|
|
5
6
|
|
|
6
7
|
export class ModelHandler extends DG.ObjectHandler {
|
|
7
8
|
get type() {
|
|
@@ -27,9 +28,32 @@ export class ModelHandler extends DG.ObjectHandler {
|
|
|
27
28
|
return x instanceof DG.Func && x.hasTag('model');
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
getVideoBackgroundUrl(x: DG.Func): string {
|
|
32
|
+
let url = x.options['video-preview'];
|
|
33
|
+
if (url == null)
|
|
34
|
+
return '';
|
|
35
|
+
if (url.startsWith('http://') || url.startsWith('https://'))
|
|
36
|
+
return url;
|
|
37
|
+
if (x instanceof DG.Script) {
|
|
38
|
+
if (x.options['icon'] != null) {
|
|
39
|
+
let iconPath = x.options['icon'].substring(0, x.options['icon'].lastIndexOf('/'));
|
|
40
|
+
return `${iconPath}/${url}`;
|
|
41
|
+
}
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
let iconPath = x.package.getIconUrl();
|
|
45
|
+
iconPath = iconPath.substring(0, iconPath.lastIndexOf('/'));
|
|
46
|
+
return `${iconPath}/${url}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
30
49
|
renderIcon(x: DG.Func, context: any = null): HTMLElement {
|
|
31
|
-
if (x
|
|
50
|
+
if (x.options['icon'] != null && (x.options['icon'].startsWith('http://') || x.options['icon'].startsWith('https://'))) {
|
|
51
|
+
return ui.iconImage('model-icon', x.options['icon']);
|
|
52
|
+
}
|
|
53
|
+
if (x instanceof DG.Script) {
|
|
32
54
|
return this.getLanguageIcon(x.language);
|
|
55
|
+
}
|
|
56
|
+
x = DG.Func.find({package: x.package.name, name: x.name})[0];
|
|
33
57
|
let iconUrl = x.package.getIconUrl();
|
|
34
58
|
if (x.options['icon'] != null) {
|
|
35
59
|
let packagePathSegments = iconUrl.split('/');
|
|
@@ -51,16 +75,43 @@ export class ModelHandler extends DG.ObjectHandler {
|
|
|
51
75
|
renderProperties(x: DG.Func) {
|
|
52
76
|
const a = ui.accordion('ComputeModel');
|
|
53
77
|
a.context = x;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
78
|
+
let titleDiv = ui.div([
|
|
79
|
+
ui.span([this.renderIcon(x), ui.label(x.friendlyName), ui.contextActions(x), ui.star(x.id)])]);
|
|
80
|
+
a.addTitle(titleDiv);
|
|
81
|
+
|
|
82
|
+
if (x.description != null)
|
|
83
|
+
titleDiv.appendChild(ui.div([ui.markdown(x.description)], 'model-catalog-description'));
|
|
84
|
+
titleDiv.appendChild(ui.tags(x));
|
|
85
|
+
if ( x.options['dev.status'] != null)
|
|
86
|
+
titleDiv.appendChild(ui.tableFromMap({Status: x.options['dev.status']}));
|
|
87
|
+
|
|
88
|
+
if (x.options['video'] != null || x.options['education'] != null) {
|
|
89
|
+
let educationLink = ui.link('Education materials', x.options['education']);
|
|
90
|
+
ui.setDisplay(educationLink, x.options['education'] != null);
|
|
91
|
+
let video = ui.div(ui.icons.play(() => {window.open(x.options['video'], '_blank')}), 'model-catalog-video');
|
|
92
|
+
ui.setDisplay(video, x.options['video'] != null);
|
|
93
|
+
video.style.backgroundImage = `url('${this.getVideoBackgroundUrl(x)}')`;
|
|
94
|
+
|
|
95
|
+
a.addPane('Documentation', () => {
|
|
96
|
+
return ui.divV([
|
|
97
|
+
educationLink,
|
|
98
|
+
video], {style: {lineHeight: '150%'}});
|
|
99
|
+
}, true);
|
|
100
|
+
}
|
|
58
101
|
a.end();
|
|
59
102
|
return a.root;
|
|
60
103
|
}
|
|
61
104
|
|
|
62
105
|
renderDetails(x: DG.Func) {
|
|
63
|
-
|
|
106
|
+
let status = ui.markdown(`**Status:** ${x.options['dev.status']}`);
|
|
107
|
+
ui.setDisplay(status, x.options['dev.status'] != null);
|
|
108
|
+
return ui.divV([
|
|
109
|
+
ui.markdown(`**Description: ** ${x.description}`),
|
|
110
|
+
status,
|
|
111
|
+
ui.markdown('**Tags:**'),
|
|
112
|
+
ui.tags(x),
|
|
113
|
+
ui.markdown('**Documentation:**'),
|
|
114
|
+
], {style: {lineHeight: '150%'}});
|
|
64
115
|
}
|
|
65
116
|
|
|
66
117
|
renderTooltip(x: DG.Func) {
|
|
@@ -84,16 +135,48 @@ export class ModelHandler extends DG.ObjectHandler {
|
|
|
84
135
|
return card;
|
|
85
136
|
}
|
|
86
137
|
|
|
138
|
+
static getModelCatalogView(): ModelCatalogView {
|
|
139
|
+
let modelsView = this.findModelCatalogView();
|
|
140
|
+
if (modelsView == null) {
|
|
141
|
+
let mc: DG.Func = DG.Func.find({package:'Compute', name: 'ModelCatalog'})[0];
|
|
142
|
+
let fc = mc.prepare();
|
|
143
|
+
let view = new ModelCatalogView();
|
|
144
|
+
view.name = 'Models';
|
|
145
|
+
view.parentCall = fc;
|
|
146
|
+
grok.shell.addView(view);
|
|
147
|
+
}
|
|
148
|
+
modelsView = this.findModelCatalogView();
|
|
149
|
+
return modelsView as ModelCatalogView;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static findModelCatalogView(): ModelCatalogView | undefined {
|
|
153
|
+
return wu(grok.shell.views).find((v) => v.parentCall?.func.name == 'modelCatalog') as ModelCatalogView;
|
|
154
|
+
}
|
|
155
|
+
|
|
87
156
|
static openModel(x: DG.Func, parentCall?: DG.FuncCall) {
|
|
88
157
|
let fc = x.prepare();
|
|
89
|
-
if (parentCall != null) {
|
|
90
|
-
let modelsView = wu(grok.shell.views).find((v) => v.parentCall?.func.name == 'modelCatalog');
|
|
91
|
-
parentCall.aux['view'] = modelsView;
|
|
92
|
-
fc.parentCall = parentCall;
|
|
93
|
-
}
|
|
94
158
|
fc.edit();
|
|
95
159
|
}
|
|
96
160
|
|
|
161
|
+
static bindModel(fc: DG.FuncCall) {
|
|
162
|
+
let modelsView = ModelHandler.getModelCatalogView();
|
|
163
|
+
fc.aux['showOnTaskBar'] = false;
|
|
164
|
+
if (modelsView != null) {
|
|
165
|
+
let parentCall = modelsView.parentCall;
|
|
166
|
+
if (parentCall != null) {
|
|
167
|
+
parentCall.aux['view'] = modelsView;
|
|
168
|
+
fc.parentCall = parentCall;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
97
173
|
init() {
|
|
174
|
+
setTimeout(() => {
|
|
175
|
+
grok.functions.onBeforeRunAction.subscribe((fc) => {
|
|
176
|
+
if (fc.func.hasTag('model') || fc.func.hasTag('model-editor')) {
|
|
177
|
+
ModelHandler.bindModel(fc);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
});
|
|
98
181
|
}
|
|
99
182
|
}
|
package/src/package.ts
CHANGED
|
@@ -8,9 +8,9 @@ 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
|
-
import {FunctionView} from "@datagrok-libraries/utils/src/function-view";
|
|
12
11
|
import {delay} from "@datagrok-libraries/utils/src/test";
|
|
13
12
|
import {ComputationView} from "@datagrok-libraries/utils/src/computation-view";
|
|
13
|
+
import {FunctionView} from "@datagrok-libraries/utils/src/function-view";
|
|
14
14
|
import './css/model-card.css';
|
|
15
15
|
|
|
16
16
|
let initCompleted: boolean = false;
|
|
@@ -24,13 +24,25 @@ export function OutliersSelection() {
|
|
|
24
24
|
return new OutliersSelectionViewer();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
//name:
|
|
28
|
-
//
|
|
29
|
-
//
|
|
27
|
+
//name: ComputationView
|
|
28
|
+
//tags: model-editor, editor
|
|
29
|
+
//input: funccall call
|
|
30
|
+
//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
|
|
30
42
|
//input: funccall call
|
|
31
43
|
//output: view result
|
|
32
|
-
export function
|
|
33
|
-
|
|
44
|
+
export function FunctionViewEditor(call: DG.FuncCall) {
|
|
45
|
+
return new FunctionView(call);
|
|
34
46
|
}
|
|
35
47
|
|
|
36
48
|
|
|
@@ -48,14 +60,13 @@ export function modelsWidget(): DG.Widget {
|
|
|
48
60
|
//output: view result
|
|
49
61
|
export function functionParametersGrid(f: DG.Func): DG.View {
|
|
50
62
|
return _functionParametersGrid(f);
|
|
51
|
-
document.getElementById('root')?.appendChild(ui.h1('Hello World'));
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
//name: hof
|
|
55
|
-
//tags: sidebar
|
|
56
66
|
//description: some description
|
|
67
|
+
//sidebar: @compute
|
|
57
68
|
export function hof() {
|
|
58
|
-
|
|
69
|
+
console.log('hof');
|
|
59
70
|
let f: DG.Func = DG.Func.byName('Sin');
|
|
60
71
|
let v: DG.View = functionParametersGrid(f);
|
|
61
72
|
v.parentCall = grok.functions.getCurrentCall();
|
|
@@ -65,14 +76,34 @@ export function hof() {
|
|
|
65
76
|
|
|
66
77
|
|
|
67
78
|
//name: hof2
|
|
79
|
+
//tags:
|
|
68
80
|
//description: some description 2 2 2
|
|
81
|
+
//sidebar: @compute
|
|
82
|
+
//meta.icon: package1.png
|
|
69
83
|
export function hof2() {
|
|
70
|
-
|
|
84
|
+
console.log('hof2');
|
|
85
|
+
|
|
71
86
|
let f: DG.Func = DG.Func.byName('Sin');
|
|
72
87
|
let v: DG.View = functionParametersGrid(f);
|
|
73
|
-
|
|
74
|
-
v.
|
|
75
|
-
|
|
88
|
+
|
|
89
|
+
v.root.appendChild(ui.narrowForm([
|
|
90
|
+
ui.switchInput('test', true),
|
|
91
|
+
ui.boolInput('test', true)]));
|
|
92
|
+
v.root.appendChild(ui.form([
|
|
93
|
+
ui.switchInput('test', true),
|
|
94
|
+
ui.boolInput('test', true)]));
|
|
95
|
+
v.parentCall = grok.functions.getCurrentCall(); // hof2 call itself
|
|
96
|
+
v.parentView = v.parentCall.parentCall?.aux['view']; // modelCatalog view
|
|
97
|
+
let path = v.parentCall.parentCall?.aux['url']; // uri if called from model catalog
|
|
98
|
+
// grok.shell.info(path);
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
let path2 = v.parentCall?.aux['url']; // uri if called directly (if app)
|
|
102
|
+
// grok.shell.info(path2);
|
|
103
|
+
|
|
104
|
+
v.basePath = '/' + v.parentCall.func.name;
|
|
105
|
+
v.path = '/';
|
|
106
|
+
|
|
76
107
|
grok.shell.addView(v);
|
|
77
108
|
}
|
|
78
109
|
|
|
@@ -116,7 +147,14 @@ function getCookie(name: string): string | undefined{
|
|
|
116
147
|
return matches ? decodeURIComponent(matches[1]) : undefined;
|
|
117
148
|
}
|
|
118
149
|
|
|
119
|
-
|
|
150
|
+
|
|
151
|
+
//tags: autostart
|
|
152
|
+
//meta.autostartImmediate: true
|
|
153
|
+
export function autostart() {
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//tags: init
|
|
120
158
|
export function init() {
|
|
121
159
|
if (initCompleted)
|
|
122
160
|
return;
|
|
@@ -132,7 +170,7 @@ export function init() {
|
|
|
132
170
|
if (!restPane)
|
|
133
171
|
acc.addPane('REST', () => ui.wait(async () => (await renderRestPanel(ent)).root));
|
|
134
172
|
});
|
|
135
|
-
|
|
173
|
+
/*
|
|
136
174
|
let modelsList = ui.waitBox(async () => {
|
|
137
175
|
let models = await grok.dapi.scripts
|
|
138
176
|
.filter('#model')
|
|
@@ -155,17 +193,6 @@ export function init() {
|
|
|
155
193
|
'LIST': list,
|
|
156
194
|
'TREE': tree
|
|
157
195
|
}).root;
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
/* grok.events.onViewAdding.subscribe((v: DG.ViewBase) => {
|
|
161
|
-
if (v instanceof ComputationView && (v as ComputationView).func?.hasTag("model")) {
|
|
162
|
-
let modelsView = wu(grok.shell.views).find((v) => v.parentCall?.func.name == 'modelCatalog');
|
|
163
|
-
if (modelsView != undefined) {
|
|
164
|
-
v.parentCall = modelsView!.parentCall;
|
|
165
|
-
v.parentView = modelsView!;
|
|
166
|
-
v.toolbox = modelsList;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
196
|
});*/
|
|
170
197
|
|
|
171
198
|
initCompleted = true;
|
|
@@ -173,11 +200,26 @@ export function init() {
|
|
|
173
200
|
|
|
174
201
|
//name: Model Catalog
|
|
175
202
|
//tags: app
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
203
|
+
//sidebar: @compute
|
|
204
|
+
export function modelCatalog() {
|
|
205
|
+
let modelsView = ModelHandler.findModelCatalogView();
|
|
206
|
+
if (modelsView == null) {
|
|
207
|
+
let view = new ModelCatalogView();
|
|
208
|
+
view.name = 'Models';
|
|
209
|
+
let parser = document.createElement('a');
|
|
210
|
+
parser.href = window.location.href;
|
|
211
|
+
let pathSegments = parser.pathname.split('/');
|
|
212
|
+
grok.shell.addView(view);
|
|
213
|
+
// console.log(parser.href);
|
|
214
|
+
if (pathSegments.length > 3) {
|
|
215
|
+
let c = grok.functions.getCurrentCall();
|
|
216
|
+
grok.dapi.functions.filter(`shortName = "${pathSegments[3]}" and #model`).list().then((lst) => {
|
|
217
|
+
if (lst.length == 1)
|
|
218
|
+
ModelHandler.openModel(lst[0], c);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
} else grok.shell.v = modelsView;
|
|
222
|
+
}
|
|
181
223
|
|
|
182
224
|
|
|
183
225
|
//name: computationTest
|