@datagrok/compute 0.9.0 → 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@datagrok/compute",
3
3
  "friendlyName": "Compute",
4
- "version": "0.9.0",
4
+ "version": "0.9.1",
5
5
  "description": "Provides additional analytical and UI blocks for [Datagrok scientific computing](../../help/compute/compute.md)",
6
6
  "repository": {
7
7
  "type": "git",
@@ -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
  }
@@ -23,7 +23,7 @@ export class ModelCatalogView extends DG.CustomCardView {
23
23
  this.objectType = 'Func';
24
24
  this.categoryFilters = {
25
25
  'options.department': 'Department',
26
- 'options.group': 'Group',
26
+ 'options.HL_process': 'HL_process',
27
27
  'options.process': 'Process',
28
28
  'tag': 'Tags'
29
29
  };
@@ -36,13 +36,13 @@ export class ModelCatalogView extends DG.CustomCardView {
36
36
 
37
37
  this.hierarchy = [
38
38
  'options.department',
39
- 'options.group',
39
+ 'options.HL_process',
40
40
  'options.process'
41
41
  ];
42
42
 
43
43
  this.hierarchyProperties = {
44
44
  'options.department': 'Department',
45
- 'options.group': 'Group',
45
+ 'options.HL_process': 'HL_process',
46
46
  'options.process': 'Process'
47
47
  };
48
48
 
@@ -28,6 +28,24 @@ 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
+
31
49
  renderIcon(x: DG.Func, context: any = null): HTMLElement {
32
50
  if (x.options['icon'] != null && (x.options['icon'].startsWith('http://') || x.options['icon'].startsWith('https://'))) {
33
51
  return ui.iconImage('model-icon', x.options['icon']);
@@ -56,27 +74,42 @@ export class ModelHandler extends DG.ObjectHandler {
56
74
  renderProperties(x: DG.Func) {
57
75
  const a = ui.accordion('ComputeModel');
58
76
  a.context = x;
59
- a.addTitle(ui.span([this.renderIcon(x), ui.label(x.friendlyName), ui.contextActions(x), ui.star(x.id)]));
60
- a.addPane('Details', () => {
61
- return this.renderDetails(x);
62
- }, true);
77
+ let titleDiv = ui.div([
78
+ ui.span([this.renderIcon(x), ui.label(x.friendlyName), ui.contextActions(x), ui.star(x.id)])]);
79
+ a.addTitle(titleDiv);
80
+
81
+ if (x.description != null)
82
+ titleDiv.appendChild(ui.div([ui.markdown(x.description)], 'model-catalog-description'));
83
+ titleDiv.appendChild(ui.tags(x));
84
+ if ( x.options['dev.status'] != null)
85
+ titleDiv.appendChild(ui.tableFromMap({Status: x.options['dev.status']}));
86
+
87
+ if (x.options['video'] != null || x.options['education'] != null) {
88
+ let educationLink = ui.link('Education materials', x.options['education']);
89
+ ui.setDisplay(educationLink, x.options['education'] != null);
90
+ let video = ui.div(ui.icons.play(() => {window.open(x.options['video'], '_blank')}), 'model-catalog-video');
91
+ ui.setDisplay(video, x.options['video'] != null);
92
+ video.style.backgroundImage = `url('${this.getVideoBackgroundUrl(x)}')`;
93
+
94
+ a.addPane('Documentation', () => {
95
+ return ui.divV([
96
+ educationLink,
97
+ video], {style: {lineHeight: '150%'}});
98
+ }, true);
99
+ }
63
100
  a.end();
64
101
  return a.root;
65
102
  }
66
103
 
67
104
  renderDetails(x: DG.Func) {
68
- let educationLink = ui.link('Education materials', x.options['education']);
69
- ui.setDisplay(educationLink, x.options['education'] != null);
70
- let video = ui.link('Video', x.options['video']);
71
- ui.setDisplay(video, x.options['video'] != null);
72
- let status = ui.markdown(`Status: ${x.options['dev.status']}`);
105
+ let status = ui.markdown(`**Status:** ${x.options['dev.status']}`);
73
106
  ui.setDisplay(status, x.options['dev.status'] != null);
74
107
  return ui.divV([
108
+ ui.markdown(`**Description: ** ${x.description}`),
75
109
  status,
76
- ui.markdown(x.description),
110
+ ui.markdown('**Tags:**'),
77
111
  ui.tags(x),
78
- educationLink,
79
- video
112
+ ui.markdown('**Documentation:**'),
80
113
  ], {style: {lineHeight: '150%'}});
81
114
  }
82
115