@datagrok/compute 0.7.1 → 0.8.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.
- package/README.md +3 -4
- package/dist/package.js +1518 -0
- package/package.json +20 -7
- package/scripts/Fab Arm Exchange.py +4 -3
- package/scripts/Heat Exchange.js +2 -2
- package/scripts/IntervalsFromECG.py +0 -1
- package/scripts/Logistic Map.js +1 -1
- package/scripts/Lorenz Attractor.js +1 -1
- package/scripts/Lotka-Volterra.js +2 -1
- package/scripts/Maximal Volume.R +0 -1
- package/scripts/pkpd.R +0 -1
- package/scripts/popPK.R +0 -1
- package/scripts/trig.js +0 -1
- package/scripts/vmax.js +180 -0
- package/scripts/wrapper.js +8 -0
- package/src/css/model-card.css +61 -0
- package/src/function-views/compute-view.ts +162 -0
- package/src/model-catalog-view.ts +23 -13
- package/src/model-handler.ts +52 -38
- package/src/models-widget.ts +97 -44
- package/src/outliers-selection/outliers-selection-viewer.ts +37 -28
- package/src/package.ts +60 -23
- package/src/view-samples/computation-test-view.ts +8 -0
- package/.eslintrc.json +0 -35
- package/src/export-funccall.ts +0 -200
package/src/model-handler.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
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
|
|
4
|
+
import wu from "wu";
|
|
5
5
|
|
|
6
6
|
export class ModelHandler extends DG.ObjectHandler {
|
|
7
7
|
get type() {
|
|
8
8
|
return 'Model';
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
async getById(id: string): Promise<DG.
|
|
12
|
-
|
|
13
|
-
return await grok.dapi.scripts.find(id);
|
|
11
|
+
async getById(id: string): Promise<DG.Func> {
|
|
12
|
+
return await grok.dapi.functions.find(id);
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
async refresh(x: DG.Script): Promise<DG.
|
|
17
|
-
|
|
18
|
-
console.log('script:', script);
|
|
19
|
-
return script;
|
|
15
|
+
async refresh(x: DG.Script): Promise<DG.Func> {
|
|
16
|
+
return await this.getById(x.id);
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
getLanguageIcon(language: string) {
|
|
@@ -27,59 +24,76 @@ export class ModelHandler extends DG.ObjectHandler {
|
|
|
27
24
|
|
|
28
25
|
// Checks whether this is the handler for [x]
|
|
29
26
|
isApplicable(x: any) {
|
|
30
|
-
return x instanceof DG.
|
|
27
|
+
return x instanceof DG.Func && x.hasTag('model');
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
renderIcon(x: DG.
|
|
34
|
-
|
|
30
|
+
renderIcon(x: DG.Func, context: any = null): HTMLElement {
|
|
31
|
+
if (x instanceof DG.Script)
|
|
32
|
+
return this.getLanguageIcon(x.language);
|
|
33
|
+
let iconUrl = x.package.getIconUrl();
|
|
34
|
+
if (x.options['icon'] != null) {
|
|
35
|
+
let packagePathSegments = iconUrl.split('/');
|
|
36
|
+
packagePathSegments.pop();
|
|
37
|
+
packagePathSegments.push(x.options['icon']);
|
|
38
|
+
iconUrl = packagePathSegments.join('/')
|
|
39
|
+
}
|
|
40
|
+
return ui.iconImage(x.package.name, iconUrl);
|
|
35
41
|
}
|
|
36
42
|
|
|
37
|
-
renderMarkup(x: DG.
|
|
38
|
-
|
|
43
|
+
renderMarkup(x: DG.Func): HTMLElement {
|
|
44
|
+
let markup = ui.span([this.renderIcon(x), ui.label(x.friendlyName)]);
|
|
45
|
+
let c = grok.functions.getCurrentCall();
|
|
46
|
+
markup.ondblclick = (e) => {
|
|
47
|
+
ModelHandler.openModel(x, c); }
|
|
48
|
+
return markup;
|
|
39
49
|
}
|
|
40
50
|
|
|
41
|
-
renderProperties(x: DG.
|
|
42
|
-
const a = ui.accordion();
|
|
51
|
+
renderProperties(x: DG.Func) {
|
|
52
|
+
const a = ui.accordion('ComputeModel');
|
|
43
53
|
a.context = x;
|
|
44
54
|
a.addTitle(ui.span([this.renderIcon(x), ui.label(x.friendlyName), ui.contextActions(x), ui.star(x.id)]));
|
|
45
55
|
a.addPane('Details', () => {
|
|
46
56
|
return this.renderDetails(x);
|
|
47
|
-
});
|
|
48
|
-
a.addCountPane('Usage', () => {
|
|
49
|
-
return ui.span(['Usage statistics']);
|
|
50
|
-
}, () => 99);
|
|
57
|
+
}, true);
|
|
51
58
|
a.end();
|
|
52
59
|
return a.root;
|
|
53
60
|
}
|
|
54
61
|
|
|
55
|
-
renderDetails(x: DG.
|
|
56
|
-
return ui.divV([ui.render(x.author), ui.render(x.createdOn)], {style: {lineHeight: '150%'}});
|
|
62
|
+
renderDetails(x: DG.Func) {
|
|
63
|
+
return ui.divV([ui.markdown(x.description), ui.span([ui.render(x.author), ' created ', ui.render(x.createdOn)])], {style: {lineHeight: '150%'}});
|
|
57
64
|
}
|
|
58
65
|
|
|
59
|
-
renderTooltip(x: DG.
|
|
60
|
-
|
|
66
|
+
renderTooltip(x: DG.Func) {
|
|
67
|
+
let h = this.renderMarkup(x);
|
|
68
|
+
h.classList.add('d4-link-label');
|
|
69
|
+
let card = ui.bind(x, ui.divV([
|
|
70
|
+
ui.h2(h),
|
|
71
|
+
ui.divV([ui.divText(x.description, 'ui-description')], {style: {lineHeight: '150%'}})
|
|
72
|
+
]));
|
|
73
|
+
let c = grok.functions.getCurrentCall();
|
|
74
|
+
card.ondblclick = (e) => { ModelHandler.openModel(x, c); }
|
|
75
|
+
return card;
|
|
61
76
|
}
|
|
62
77
|
|
|
63
|
-
renderCard(x: DG.
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
card.ondblclick = (e) => {
|
|
70
|
-
ModelHandler.openModel(x);
|
|
71
|
-
}
|
|
78
|
+
renderCard(x: DG.Func, context?: any): HTMLElement {
|
|
79
|
+
let h = this.renderMarkup(x);
|
|
80
|
+
h.classList.add('d4-link-label');
|
|
81
|
+
let card = ui.bind(x, ui.h2(h));
|
|
82
|
+
let c = grok.functions.getCurrentCall();
|
|
83
|
+
card.ondblclick = (e) => { ModelHandler.openModel(x, c); }
|
|
72
84
|
return card;
|
|
73
85
|
}
|
|
74
86
|
|
|
75
|
-
static openModel(x: DG.
|
|
76
|
-
let
|
|
77
|
-
|
|
87
|
+
static openModel(x: DG.Func, parentCall?: DG.FuncCall) {
|
|
88
|
+
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
|
+
fc.edit();
|
|
78
95
|
}
|
|
79
96
|
|
|
80
97
|
init() {
|
|
81
|
-
this.registerParamFunc('Open', async (t: DG.Script) => {
|
|
82
|
-
|
|
83
|
-
});
|
|
84
98
|
}
|
|
85
99
|
}
|
package/src/models-widget.ts
CHANGED
|
@@ -1,67 +1,120 @@
|
|
|
1
1
|
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
|
+
import {ModelHandler} from './model-handler';
|
|
5
|
+
import {TYPE} from "datagrok-api/dg";
|
|
4
6
|
import $ from 'cash-dom';
|
|
7
|
+
import {FunctionView} from "@datagrok-libraries/utils/src/function-view";
|
|
8
|
+
const api = <any>window;
|
|
9
|
+
|
|
10
|
+
/*
|
|
5
11
|
|
|
6
12
|
export class ModelsWidget extends DG.Widget {
|
|
7
13
|
caption: string;
|
|
8
14
|
order: string;
|
|
15
|
+
meta: ModelHandler;
|
|
16
|
+
name: string;
|
|
17
|
+
permanentFilter: string;
|
|
18
|
+
objectType: string;
|
|
19
|
+
modelsList: HTMLDivElement;
|
|
9
20
|
|
|
10
21
|
constructor() {
|
|
11
|
-
super(ui.
|
|
12
|
-
|
|
22
|
+
super(ui.box());
|
|
23
|
+
|
|
24
|
+
this.meta = new ModelHandler();
|
|
25
|
+
this.name = 'Models';
|
|
26
|
+
this.permanentFilter = '#model';
|
|
27
|
+
this.objectType = 'Script';
|
|
28
|
+
|
|
29
|
+
this.caption = super.addProperty('caption', DG.TYPE.STRING, 'Models');
|
|
13
30
|
this.order = super.addProperty('order', DG.TYPE.STRING, '0');
|
|
14
|
-
|
|
31
|
+
|
|
32
|
+
let topbar = ui.divH([
|
|
33
|
+
ui.choiceInput('', 'Recent', ['Recent','Newest','Oldest'], (v:string) => {
|
|
34
|
+
this.modelsList.innerHTML = '';
|
|
35
|
+
this.getModels(v);
|
|
36
|
+
}).root,
|
|
37
|
+
ui.link('Open Model Catalog', ()=>{
|
|
38
|
+
grok.functions.call("Compute:ModelCatalog");
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
for (let v of grok.shell.views)
|
|
41
|
+
if (v.name === 'Models')
|
|
42
|
+
grok.shell.v = v;
|
|
43
|
+
}, 500);
|
|
44
|
+
})
|
|
45
|
+
]);
|
|
46
|
+
topbar.style.justifyContent = 'space-between';
|
|
47
|
+
topbar.style.margin = '0 12px';
|
|
48
|
+
topbar.style.alignItems = 'center';
|
|
49
|
+
|
|
50
|
+
this.modelsList = ui.divV([]);
|
|
51
|
+
this.modelsList.style.marginLeft = '12px';
|
|
52
|
+
|
|
53
|
+
this.root.appendChild(ui.splitV([
|
|
54
|
+
ui.box(topbar, {style:{maxHeight:'40px'}}),
|
|
55
|
+
this.modelsList
|
|
56
|
+
]));
|
|
57
|
+
|
|
58
|
+
DG.ObjectHandler.register(new ModelHandler());
|
|
59
|
+
|
|
60
|
+
this.getModels('updatedOn');
|
|
15
61
|
}
|
|
16
62
|
|
|
17
|
-
|
|
18
|
-
let count = (await grok.dapi.scripts.filter('#model').list()).length;
|
|
19
|
-
let titles = [ui.h3('Simulation'), ui.h3('Other')];
|
|
20
|
-
for (let i in titles){
|
|
21
|
-
titles[i].style.color = 'var(--grey-3)';
|
|
22
|
-
titles[i].style.fontSize = '12px';
|
|
23
|
-
titles[i].style.textTransform = 'uppercase';
|
|
24
|
-
titles[i].style.letterSpacing = '1px';
|
|
25
|
-
titles[i].style.margin = '5px 0';
|
|
26
|
-
}
|
|
63
|
+
|
|
27
64
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
65
|
+
async getModels(order:string){
|
|
66
|
+
let b = true;
|
|
67
|
+
let v = order;
|
|
68
|
+
|
|
69
|
+
switch(order){
|
|
70
|
+
case 'Recent':
|
|
71
|
+
v = 'updatedOn';
|
|
72
|
+
break;
|
|
73
|
+
case 'Newest':
|
|
74
|
+
v = 'createdOn';
|
|
75
|
+
break;
|
|
76
|
+
case 'Oldest':
|
|
77
|
+
v = 'createdOn';
|
|
78
|
+
b = false;
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
v = 'updatedOn';
|
|
82
|
+
}
|
|
34
83
|
|
|
35
84
|
grok.dapi.scripts
|
|
36
85
|
.filter('#model')
|
|
86
|
+
.order(v, b)
|
|
37
87
|
.list()
|
|
38
88
|
.then((scripts) => scripts.map((p) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
89
|
+
let d = this.meta.renderMarkup(p);
|
|
90
|
+
d.ondblclick = (e) => {
|
|
91
|
+
ModelsWidget.openModel(p);
|
|
92
|
+
}
|
|
93
|
+
d.style.color = 'var(--blue-1)';
|
|
94
|
+
d.style.margin = '4px 0';
|
|
95
|
+
$(d).find('.ui-label').addClass('ui-link');
|
|
96
|
+
|
|
97
|
+
this.modelsList.append(d)
|
|
48
98
|
}));
|
|
99
|
+
}
|
|
49
100
|
|
|
50
|
-
|
|
101
|
+
static openModel(x: DG.Script, parentCall?: DG.FuncCall) {
|
|
102
|
+
let views = []
|
|
103
|
+
for (let v of grok.shell.views)
|
|
104
|
+
views.push(v.name)
|
|
105
|
+
|
|
106
|
+
if (views.includes('Models')){
|
|
107
|
+
let view = new FunctionView(x);
|
|
108
|
+
view.parentCall = parentCall!;
|
|
109
|
+
grok.shell.addView(view);
|
|
110
|
+
}else{
|
|
111
|
+
grok.functions.call("Compute:ModelCatalog");
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
let view = new FunctionView(x);
|
|
114
|
+
view.parentCall = parentCall!;
|
|
115
|
+
grok.shell.addView(view);
|
|
116
|
+
}, 500)
|
|
117
|
+
}
|
|
51
118
|
}
|
|
52
|
-
}
|
|
53
119
|
|
|
54
|
-
|
|
55
|
-
let img = ui.iconImage('logo', `/images/entities/${p.language}.png`);
|
|
56
|
-
img.style.width = '30px';
|
|
57
|
-
img.style.height = '30px';
|
|
58
|
-
img.style.border = 'none';
|
|
59
|
-
let card = ui.cards.summary(
|
|
60
|
-
img,
|
|
61
|
-
[
|
|
62
|
-
ui.div(ui.link(p.friendlyName, p, undefined, null)),
|
|
63
|
-
ui.div([p.updatedOn], {style:{color:'var(--grey-4)'}})
|
|
64
|
-
]);
|
|
65
|
-
ui.tooltip.bind(card, p);
|
|
66
|
-
return card;
|
|
67
|
-
}
|
|
120
|
+
} */
|
|
@@ -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
|
-
import {ModelsWidget} from './models-widget'
|
|
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 './css/model-card.css';
|
|
12
15
|
|
|
13
16
|
let initCompleted: boolean = false;
|
|
14
17
|
export const _package = new DG.Package();
|
|
@@ -21,19 +24,21 @@ export function OutliersSelection() {
|
|
|
21
24
|
return new OutliersSelectionViewer();
|
|
22
25
|
}
|
|
23
26
|
|
|
27
|
+
//name: ComputationViewTest
|
|
28
|
+
//description: Creates an outliers selection viewer
|
|
29
|
+
//tags: viewer
|
|
30
|
+
//input: funccall call
|
|
31
|
+
//output: view result
|
|
32
|
+
export function ComputationViewTest(call: DG.FuncCall) {
|
|
33
|
+
// return new ComputationView(call.func);
|
|
34
|
+
}
|
|
35
|
+
|
|
24
36
|
|
|
25
|
-
|
|
37
|
+
/*//output: widget result
|
|
26
38
|
//tags: dashboard
|
|
27
39
|
export function modelsWidget(): DG.Widget {
|
|
28
40
|
return new ModelsWidget();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
//name: Export to Excel
|
|
32
|
-
//input: funccall call
|
|
33
|
-
//tags: export
|
|
34
|
-
export function exportToExcel(call: DG.FuncCall) {
|
|
35
|
-
exportFuncCall(call);
|
|
36
|
-
}
|
|
41
|
+
}*/
|
|
37
42
|
|
|
38
43
|
/* eslint-disable */
|
|
39
44
|
|
|
@@ -43,12 +48,31 @@ export function exportToExcel(call: DG.FuncCall) {
|
|
|
43
48
|
//output: view result
|
|
44
49
|
export function functionParametersGrid(f: DG.Func): DG.View {
|
|
45
50
|
return _functionParametersGrid(f);
|
|
51
|
+
document.getElementById('root')?.appendChild(ui.h1('Hello World'));
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
//name: hof
|
|
55
|
+
//tags: sidebar
|
|
56
|
+
//description: some description
|
|
49
57
|
export function hof() {
|
|
58
|
+
grok.shell.info('hof');
|
|
59
|
+
let f: DG.Func = DG.Func.byName('Sin');
|
|
60
|
+
let v: DG.View = functionParametersGrid(f);
|
|
61
|
+
v.parentCall = grok.functions.getCurrentCall();
|
|
62
|
+
//v.parentView = v.parentCall?.aux['view'];
|
|
63
|
+
grok.shell.addView(v);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
//name: hof2
|
|
68
|
+
//description: some description 2 2 2
|
|
69
|
+
export function hof2() {
|
|
70
|
+
grok.shell.info('hof2');
|
|
50
71
|
let f: DG.Func = DG.Func.byName('Sin');
|
|
51
72
|
let v: DG.View = functionParametersGrid(f);
|
|
73
|
+
v.parentCall = grok.functions.getCurrentCall().parentCall;
|
|
74
|
+
v.parentView = v.parentCall?.aux['view'];
|
|
75
|
+
v.path = 'hof';
|
|
52
76
|
grok.shell.addView(v);
|
|
53
77
|
}
|
|
54
78
|
|
|
@@ -133,8 +157,8 @@ export function init() {
|
|
|
133
157
|
}).root;
|
|
134
158
|
});
|
|
135
159
|
|
|
136
|
-
grok.events.onViewAdding.subscribe((v: DG.
|
|
137
|
-
if (v instanceof
|
|
160
|
+
/* grok.events.onViewAdding.subscribe((v: DG.ViewBase) => {
|
|
161
|
+
if (v instanceof ComputationView && (v as ComputationView).func?.hasTag("model")) {
|
|
138
162
|
let modelsView = wu(grok.shell.views).find((v) => v.parentCall?.func.name == 'modelCatalog');
|
|
139
163
|
if (modelsView != undefined) {
|
|
140
164
|
v.parentCall = modelsView!.parentCall;
|
|
@@ -142,20 +166,33 @@ export function init() {
|
|
|
142
166
|
v.toolbox = modelsList;
|
|
143
167
|
}
|
|
144
168
|
}
|
|
145
|
-
})
|
|
169
|
+
});*/
|
|
146
170
|
|
|
147
171
|
initCompleted = true;
|
|
148
172
|
}
|
|
149
173
|
|
|
150
174
|
//name: Model Catalog
|
|
151
175
|
//tags: app
|
|
152
|
-
export function modelCatalog() {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
176
|
+
export function modelCatalog() {
|
|
177
|
+
let view = new ModelCatalogView();
|
|
178
|
+
view.name = 'Models';
|
|
179
|
+
grok.shell.addView(view);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
//name: computationTest
|
|
184
|
+
//input: int delayMs {description: Wait time; units: ms}
|
|
185
|
+
//input: string error {description: When specified, throws this error}
|
|
186
|
+
//output: dataframe result
|
|
187
|
+
export async function computationTest(delayMs: number, error: string): Promise<DG.DataFrame> {
|
|
188
|
+
await delay(delayMs);
|
|
189
|
+
if (error != null || error != '')
|
|
190
|
+
throw error;
|
|
191
|
+
return grok.data.demo.demog();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
//name: testComputationView();
|
|
195
|
+
export function testComputationView() {
|
|
196
|
+
let f = DG.Func.find({name: 'computationTest'})[0];
|
|
197
|
+
//grok.shell.addView(new ComputationView(f));
|
|
161
198
|
}
|
|
@@ -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
|
-
}
|