@datagrok/compute 0.7.2 → 0.9.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.
package/src/package.ts CHANGED
@@ -7,11 +7,11 @@ import {_functionParametersGrid} from './function-views/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
- import {ModelsWidget} from './models-widget'
11
- import {FunctionView} from "@datagrok-libraries/utils/src/function-view";
10
+ //import {ModelsWidget} from './models-widget'
12
11
  import {delay} from "@datagrok-libraries/utils/src/test";
13
12
  import {ComputationView} from "@datagrok-libraries/utils/src/computation-view";
14
- import {ComputeView} from "./function-views/compute-view";
13
+ import {FunctionView} from "@datagrok-libraries/utils/src/function-view";
14
+ import './css/model-card.css';
15
15
 
16
16
  let initCompleted: boolean = false;
17
17
  export const _package = new DG.Package();
@@ -24,12 +24,33 @@ export function OutliersSelection() {
24
24
  return new OutliersSelectionViewer();
25
25
  }
26
26
 
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
+ // }
27
39
 
28
- //output: widget result
40
+ //name: FunctionView
41
+ //tags: model-editor, editor
42
+ //input: funccall call
43
+ //output: view result
44
+ export function FunctionViewEditor(call: DG.FuncCall) {
45
+ return new FunctionView(call);
46
+ }
47
+
48
+
49
+ /*//output: widget result
29
50
  //tags: dashboard
30
51
  export function modelsWidget(): DG.Widget {
31
52
  return new ModelsWidget();
32
- }
53
+ }*/
33
54
 
34
55
  /* eslint-disable */
35
56
 
@@ -42,9 +63,47 @@ export function functionParametersGrid(f: DG.Func): DG.View {
42
63
  }
43
64
 
44
65
  //name: hof
66
+ //description: some description
67
+ //sidebar: @compute
45
68
  export function hof() {
69
+ console.log('hof');
46
70
  let f: DG.Func = DG.Func.byName('Sin');
47
71
  let v: DG.View = functionParametersGrid(f);
72
+ v.parentCall = grok.functions.getCurrentCall();
73
+ //v.parentView = v.parentCall?.aux['view'];
74
+ grok.shell.addView(v);
75
+ }
76
+
77
+
78
+ //name: hof2
79
+ //tags:
80
+ //description: some description 2 2 2
81
+ //sidebar: @compute
82
+ //meta.icon: package1.png
83
+ export function hof2() {
84
+ console.log('hof2');
85
+
86
+ let f: DG.Func = DG.Func.byName('Sin');
87
+ let v: DG.View = functionParametersGrid(f);
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
+
48
107
  grok.shell.addView(v);
49
108
  }
50
109
 
@@ -88,7 +147,14 @@ function getCookie(name: string): string | undefined{
88
147
  return matches ? decodeURIComponent(matches[1]) : undefined;
89
148
  }
90
149
 
91
- //tags: init, autostart
150
+
151
+ //tags: autostart
152
+ //meta.autostartImmediate: true
153
+ export function autostart() {
154
+
155
+ }
156
+
157
+ //tags: init
92
158
  export function init() {
93
159
  if (initCompleted)
94
160
  return;
@@ -104,7 +170,7 @@ export function init() {
104
170
  if (!restPane)
105
171
  acc.addPane('REST', () => ui.wait(async () => (await renderRestPanel(ent)).root));
106
172
  });
107
-
173
+ /*
108
174
  let modelsList = ui.waitBox(async () => {
109
175
  let models = await grok.dapi.scripts
110
176
  .filter('#model')
@@ -127,33 +193,33 @@ export function init() {
127
193
  'LIST': list,
128
194
  'TREE': tree
129
195
  }).root;
130
- });
131
-
132
- grok.events.onViewAdding.subscribe((v: DG.ViewBase) => {
133
- if (v.type == 'function' && (v as FunctionView).func?.hasTag("model")) {
134
- let modelsView = wu(grok.shell.views).find((v) => v.parentCall?.func.name == 'modelCatalog');
135
- if (modelsView != undefined) {
136
- v.parentCall = modelsView!.parentCall;
137
- v.parentView = modelsView!;
138
- v.toolbox = modelsList;
139
- }
140
- }
141
- });
196
+ });*/
142
197
 
143
198
  initCompleted = true;
144
199
  }
145
200
 
146
201
  //name: Model Catalog
147
- // export function modelCatalog() {
148
- // /* let view = new DG.MultiView({
149
- // viewFactories: {
150
- // 'Models': {factory: () => new ModelCatalogView(), allowClose: false}
151
- // }
152
- // });*/
153
- // let view = new ModelCatalogView();
154
- // view.name = 'Models';
155
- // grok.shell.addView(view);
156
- // }
202
+ //tags: app
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
+ }
157
223
 
158
224
 
159
225
  //name: computationTest
@@ -170,5 +236,5 @@ export async function computationTest(delayMs: number, error: string): Promise<D
170
236
  //name: testComputationView();
171
237
  export function testComputationView() {
172
238
  let f = DG.Func.find({name: 'computationTest'})[0];
173
- grok.shell.addView(new ComputeView(f));
174
- }
239
+ //grok.shell.addView(new ComputationView(f));
240
+ }