@datagrok/compute 1.13.0 → 1.13.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/CHANGELOG.md +14 -0
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +2 -2
- package/src/model-handler.ts +21 -54
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/compute",
|
|
3
3
|
"friendlyName": "Compute",
|
|
4
|
-
"version": "1.13.
|
|
4
|
+
"version": "1.13.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aufar Zakiev",
|
|
7
7
|
"email": "aufar.zakiev@softwarecountry.com"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/Compute"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@datagrok-libraries/compute-utils": "^1.13.
|
|
16
|
+
"@datagrok-libraries/compute-utils": "^1.13.2",
|
|
17
17
|
"cash-dom": "latest",
|
|
18
18
|
"datagrok-api": "^1.15.3",
|
|
19
19
|
"dayjs": "=1.11.7",
|
package/src/model-handler.ts
CHANGED
|
@@ -28,24 +28,6 @@ export class ModelHandler extends DG.ObjectHandler {
|
|
|
28
28
|
return x instanceof DG.Func && x.hasTag('model');
|
|
29
29
|
}
|
|
30
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
|
-
|
|
49
31
|
renderIcon(x: DG.Func, context: any = null): HTMLElement {
|
|
50
32
|
if (x.options['icon'] != null && (x.options['icon'].startsWith('http://') || x.options['icon'].startsWith('https://'))) {
|
|
51
33
|
return ui.iconImage('model-icon', x.options['icon']);
|
|
@@ -67,14 +49,14 @@ export class ModelHandler extends DG.ObjectHandler {
|
|
|
67
49
|
renderMarkup(x: DG.Func): HTMLElement {
|
|
68
50
|
let markup = ui.span([this.renderIcon(x), ui.label(x.friendlyName)]);
|
|
69
51
|
markup.ondblclick = (e) => { ModelHandler.openModel(x); }
|
|
52
|
+
markup.onclick = (e) => { ModelHandler.openHelp(x); }
|
|
70
53
|
return markup;
|
|
71
54
|
}
|
|
72
55
|
|
|
73
56
|
async renderPreview(x: DG.Func) {
|
|
74
|
-
const editorName = x.options.editor ?? 'Compute:
|
|
57
|
+
const editorName = x.options.editor ?? 'Compute:RichFunctionViewEditor';
|
|
75
58
|
const editor = await grok.functions.find(editorName);
|
|
76
59
|
if (editor !== null && editor instanceof DG.Func) {
|
|
77
|
-
console.log(editor);
|
|
78
60
|
const viewCall = editor.prepare({'call': x.prepare()});
|
|
79
61
|
await viewCall.call(false, undefined, {processed: true});
|
|
80
62
|
const view = viewCall.getOutputParamValue();
|
|
@@ -85,48 +67,23 @@ export class ModelHandler extends DG.ObjectHandler {
|
|
|
85
67
|
return super.renderPreview(x);
|
|
86
68
|
}
|
|
87
69
|
|
|
88
|
-
renderProperties(
|
|
70
|
+
renderProperties(func: DG.Func) {
|
|
89
71
|
const a = ui.accordion('ComputeModel');
|
|
90
|
-
a.context =
|
|
72
|
+
a.context = func;
|
|
91
73
|
let titleDiv = ui.div([
|
|
92
|
-
ui.span([this.renderIcon(
|
|
74
|
+
ui.span([this.renderIcon(func), ui.label(func.friendlyName), ui.contextActions(func), ui.star(func.id)])]);
|
|
93
75
|
a.addTitle(titleDiv);
|
|
94
76
|
|
|
95
|
-
if (
|
|
96
|
-
titleDiv.appendChild(ui.div([ui.markdown(
|
|
97
|
-
titleDiv.appendChild(ui.tags(
|
|
98
|
-
if (
|
|
99
|
-
titleDiv.appendChild(ui.tableFromMap({Status:
|
|
100
|
-
|
|
101
|
-
if (x.options['video'] != null || x.options['education'] != null) {
|
|
102
|
-
let educationLink = ui.link('Education materials', x.options['education']);
|
|
103
|
-
ui.setDisplay(educationLink, x.options['education'] != null);
|
|
104
|
-
let video = ui.div(ui.icons.play(() => {window.open(x.options['video'], '_blank')}), 'model-catalog-video');
|
|
105
|
-
ui.setDisplay(video, x.options['video'] != null);
|
|
106
|
-
video.style.backgroundImage = `url('${this.getVideoBackgroundUrl(x)}')`;
|
|
107
|
-
|
|
108
|
-
a.addPane('Documentation', () => {
|
|
109
|
-
return ui.divV([
|
|
110
|
-
educationLink,
|
|
111
|
-
video], {style: {lineHeight: '150%'}});
|
|
112
|
-
}, true);
|
|
113
|
-
}
|
|
77
|
+
if (func.description != null)
|
|
78
|
+
titleDiv.appendChild(ui.div([ui.markdown(func.description)], 'model-catalog-description'));
|
|
79
|
+
titleDiv.appendChild(ui.tags(func));
|
|
80
|
+
if ( func.options['dev.status'] != null)
|
|
81
|
+
titleDiv.appendChild(ui.tableFromMap({Status: func.options['dev.status']}));
|
|
82
|
+
|
|
114
83
|
a.end();
|
|
115
84
|
return a.root;
|
|
116
85
|
}
|
|
117
86
|
|
|
118
|
-
renderDetails(x: DG.Func) {
|
|
119
|
-
let status = ui.markdown(`**Status:** ${x.options['dev.status']}`);
|
|
120
|
-
ui.setDisplay(status, x.options['dev.status'] != null);
|
|
121
|
-
return ui.divV([
|
|
122
|
-
ui.markdown(`**Description: ** ${x.description}`),
|
|
123
|
-
status,
|
|
124
|
-
ui.markdown('**Tags:**'),
|
|
125
|
-
ui.tags(x),
|
|
126
|
-
ui.markdown('**Documentation:**'),
|
|
127
|
-
], {style: {lineHeight: '150%'}});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
87
|
renderTooltip(x: DG.Func) {
|
|
131
88
|
let h = this.renderMarkup(x);
|
|
132
89
|
h.classList.add('d4-link-label');
|
|
@@ -143,9 +100,19 @@ export class ModelHandler extends DG.ObjectHandler {
|
|
|
143
100
|
h.classList.add('d4-link-label');
|
|
144
101
|
let card = ui.bind(x, ui.h2(h));
|
|
145
102
|
card.ondblclick = (e) => { ModelHandler.openModel(x); }
|
|
103
|
+
card.onclick = (e) => { ModelHandler.openHelp(x); }
|
|
146
104
|
return card;
|
|
147
105
|
}
|
|
148
106
|
|
|
107
|
+
static async openHelp(func: DG.Func) {
|
|
108
|
+
if (func.options['readme'] != null) {
|
|
109
|
+
const path = `System:AppData/${func.package.name}/${func.options['readme']}`;
|
|
110
|
+
const readmeText = await grok.dapi.files.readAsText(path);
|
|
111
|
+
|
|
112
|
+
grok.shell.windows.help.showHelp(ui.markdown(readmeText));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
149
116
|
static getModelCatalogView(): ModelCatalogView {
|
|
150
117
|
let modelsView = this.findModelCatalogView();
|
|
151
118
|
if (modelsView == null) {
|