@datagrok/compute 0.7.3 → 0.9.1

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
@@ -8,9 +8,10 @@ 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
+ import './css/model-card.css';
14
15
 
15
16
  let initCompleted: boolean = false;
16
17
  export const _package = new DG.Package();
@@ -23,6 +24,27 @@ export function OutliersSelection() {
23
24
  return new OutliersSelectionViewer();
24
25
  }
25
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
+ // }
39
+
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
+
26
48
 
27
49
  /*//output: widget result
28
50
  //tags: dashboard
@@ -38,15 +60,50 @@ export function modelsWidget(): DG.Widget {
38
60
  //output: view result
39
61
  export function functionParametersGrid(f: DG.Func): DG.View {
40
62
  return _functionParametersGrid(f);
41
- document.getElementById('root')?.appendChild(ui.h1('Hello World'));
42
63
  }
43
64
 
44
65
  //name: hof
45
- //tags: model
66
+ //description: some description
67
+ //sidebar: @compute
46
68
  export function hof() {
47
- grok.shell.info('blablabla');
69
+ console.log('hof');
48
70
  let f: DG.Func = DG.Func.byName('Sin');
49
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
+
50
107
  grok.shell.addView(v);
51
108
  }
52
109
 
@@ -90,7 +147,14 @@ function getCookie(name: string): string | undefined{
90
147
  return matches ? decodeURIComponent(matches[1]) : undefined;
91
148
  }
92
149
 
93
- //tags: init, autostart
150
+
151
+ //tags: autostart
152
+ //meta.autostartImmediate: true
153
+ export function autostart() {
154
+
155
+ }
156
+
157
+ //tags: init
94
158
  export function init() {
95
159
  if (initCompleted)
96
160
  return;
@@ -106,7 +170,7 @@ export function init() {
106
170
  if (!restPane)
107
171
  acc.addPane('REST', () => ui.wait(async () => (await renderRestPanel(ent)).root));
108
172
  });
109
-
173
+ /*
110
174
  let modelsList = ui.waitBox(async () => {
111
175
  let models = await grok.dapi.scripts
112
176
  .filter('#model')
@@ -129,17 +193,6 @@ export function init() {
129
193
  'LIST': list,
130
194
  'TREE': tree
131
195
  }).root;
132
- });
133
-
134
- /* grok.events.onViewAdding.subscribe((v: DG.ViewBase) => {
135
- if (v instanceof ComputationView && (v as ComputationView).func?.hasTag("model")) {
136
- let modelsView = wu(grok.shell.views).find((v) => v.parentCall?.func.name == 'modelCatalog');
137
- if (modelsView != undefined) {
138
- v.parentCall = modelsView!.parentCall;
139
- v.parentView = modelsView!;
140
- v.toolbox = modelsList;
141
- }
142
- }
143
196
  });*/
144
197
 
145
198
  initCompleted = true;
@@ -147,11 +200,26 @@ export function init() {
147
200
 
148
201
  //name: Model Catalog
149
202
  //tags: app
150
- export function modelCatalog() {
151
- let view = new ModelCatalogView();
152
- view.name = 'Models';
153
- grok.shell.addView(view);
154
- }
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
+ }
155
223
 
156
224
 
157
225
  //name: computationTest