@datagrok/api-samples 1.0.7 → 1.0.12

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.
Files changed (122) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/package-test.js +2 -2
  3. package/files/viewer-events/bar-chart/on-category-clicked.js +1 -0
  4. package/files/viewer-events/grid/on-cell-clicked.js +1 -0
  5. package/files/viewer-events/pc-plot/on-line-clicked.js +1 -0
  6. package/files/viewer-events/pie-chart/on-segment-clicked.js +1 -0
  7. package/files/viewer-events/scatter-plot/on-point-clicked.js +1 -0
  8. package/files/viewer-events/scatter-plot/on-rendered.js +1 -0
  9. package/layouts/demog-table-layout.json +329 -181
  10. package/package.json +17 -13
  11. package/scripts/dapi/files.js +14 -13
  12. package/scripts/dapi/projects-open.js +1 -1
  13. package/scripts/dapi/sticky-meta-1-tags.js +54 -0
  14. package/scripts/dapi/sticky-meta-2-semtype.js +33 -0
  15. package/scripts/data-access/db-master-details-manual.js +3 -2
  16. package/scripts/data-access/external/stock-prices.js +1 -1
  17. package/scripts/data-access/open-table-by-id.js +11 -3
  18. package/scripts/data-access/output-layouts.js +3 -1
  19. package/scripts/data-frame/advanced/data-frames-in-columns.js +4 -1
  20. package/scripts/data-frame/advanced/virtual-columns.js +1 -1
  21. package/scripts/data-frame/aggregation/unpivot.js +1 -1
  22. package/scripts/data-frame/column-access.js +1 -3
  23. package/scripts/data-frame/compare-tables.js +3 -2
  24. package/scripts/data-frame/construction/create-from-csv-format.js +3 -3
  25. package/scripts/data-frame/construction/create-from-typed-arrays.js +7 -2
  26. package/scripts/data-frame/construction/export-to-csv-advanced.js +14 -4
  27. package/scripts/data-frame/construction/export-to-csv-molblock.js +3 -0
  28. package/scripts/data-frame/construction/export-to-csv.js +1 -1
  29. package/scripts/data-frame/events/calculated-columns/creation.js +1 -1
  30. package/scripts/data-frame/events/calculated-columns/deletion.js +1 -1
  31. package/scripts/data-frame/events/calculated-columns/update.js +1 -1
  32. package/scripts/data-frame/filtering/update-filter-state.js +13 -0
  33. package/scripts/data-frame/join-link/link-tables-dynamic.js +3 -5
  34. package/scripts/data-frame/metadata/dataframe-meta.js +1 -1
  35. package/scripts/data-frame/modification/add-columns.js +1 -1
  36. package/scripts/data-frame/modification/append.js +1 -1
  37. package/scripts/data-frame/modification/calculated-columns/edit-formula.js +2 -2
  38. package/scripts/data-frame/modification/double-precision.js +26 -0
  39. package/scripts/data-frame/modification/manipulate.js +3 -3
  40. package/scripts/domains/chem/sketcher.js +2 -2
  41. package/scripts/events/form-creation.js +2 -2
  42. package/scripts/events/global-events.js +1 -1
  43. package/scripts/events/layout-events.js +5 -6
  44. package/scripts/events/viewer-data-events.js +11 -0
  45. package/scripts/functions/calling.js +1 -1
  46. package/scripts/functions/func-call.js +5 -0
  47. package/scripts/grid/advanced/cell-renderer.js +1 -1
  48. package/scripts/grid/advanced/format-formula.js +7 -0
  49. package/scripts/grid/advanced/link-click.js +3 -3
  50. package/scripts/grid/advanced/markup-link.js +6 -0
  51. package/scripts/grid/advanced/paint-counts.js +4 -1
  52. package/scripts/grid/{color-coding-conditional.js → color-coding/color-coding-conditional.js} +17 -10
  53. package/scripts/grid/color-coding/color-coding.js +5 -9
  54. package/scripts/grid/color-coding/get-cell-color.js +3 -5
  55. package/scripts/grid/column-cell-styles.js +10 -0
  56. package/scripts/grid/column-controlled-values.js +2 -2
  57. package/scripts/grid/data-format.js +4 -4
  58. package/scripts/grid/hit-test.js +1 -1
  59. package/scripts/grid/html-cells/html-table-cells.js +1 -1
  60. package/scripts/misc/audit/test-tracking.js +1 -1
  61. package/scripts/misc/user-settings-storage.js +48 -0
  62. package/scripts/performance/all-chembl-structures.js +1 -1
  63. package/scripts/scripting/files-for-scripting.js +24 -0
  64. package/scripts/scripting/grok-scripting.js +1 -1
  65. package/scripts/scripting/package-scripting.js +6 -0
  66. package/scripts/shell/last-error.js +1 -1
  67. package/scripts/shell/ui-parts.js +9 -9
  68. package/scripts/shell/windows/browse/customize-tree.js +3 -0
  69. package/scripts/ui/apps/bioreactor.js +5 -5
  70. package/scripts/ui/components/accordion.js +3 -3
  71. package/scripts/ui/components/tree-view-adv.js +4 -2
  72. package/scripts/ui/containers/splitters.js +13 -13
  73. package/scripts/ui/dialogs/wizard.js +8 -8
  74. package/scripts/ui/docking/docking.js +4 -1
  75. package/scripts/ui/handlers/markup-handlers.js +61 -0
  76. package/scripts/ui/inputs/advanced/all-input-types.js +37 -24
  77. package/scripts/ui/inputs/advanced/input-api.js +39 -0
  78. package/scripts/ui/inputs/advanced/input-events.js +10 -10
  79. package/scripts/ui/inputs/advanced/input-form.js +8 -8
  80. package/scripts/ui/inputs/choice-input.js +5 -5
  81. package/scripts/ui/inputs/column-combo-box.js +3 -3
  82. package/scripts/ui/inputs/column-inputs.js +3 -3
  83. package/scripts/ui/inputs/forms.js +10 -10
  84. package/scripts/ui/inputs/helm-input-ui.js +7 -0
  85. package/scripts/ui/inputs/inputs-events.js +8 -8
  86. package/scripts/ui/inputs/inputs-extended.js +2 -2
  87. package/scripts/ui/inputs/inputs.js +17 -15
  88. package/scripts/ui/inputs/molecule-input.js +1 -1
  89. package/scripts/ui/inputs/table-input.js +1 -1
  90. package/scripts/ui/inputs/tags-input.js +2 -2
  91. package/scripts/ui/inputs/typeahead-input.js +16 -17
  92. package/scripts/ui/inputs/validation/input-validators.js +11 -0
  93. package/scripts/ui/inputs/validation/script-param-validation.js +6 -0
  94. package/scripts/ui/inputs/validation/visible-enabled.js +9 -0
  95. package/scripts/ui/interactivity/drag-and-drop.js +3 -3
  96. package/scripts/ui/tooltips/tooltips.js +6 -2
  97. package/scripts/ui/viewers/advanced/attached-properties.js +5 -5
  98. package/scripts/ui/viewers/advanced/default-axis-type.js +1 -1
  99. package/scripts/ui/viewers/advanced/init-function.js +21 -0
  100. package/scripts/ui/viewers/advanced/init-script.js +15 -0
  101. package/scripts/ui/viewers/filters/add-single-filter.js +5 -5
  102. package/scripts/ui/viewers/filters/custom-filters.js +3 -3
  103. package/scripts/ui/viewers/filters/filter-group.js +6 -1
  104. package/scripts/ui/viewers/filters/multi-value-filter.js +1 -1
  105. package/scripts/ui/viewers/js viewers/chord-viewer.js +1 -1
  106. package/scripts/ui/viewers/js viewers/sankey-viewer.js +1 -1
  107. package/scripts/ui/viewers/js viewers/word-cloud.js +1 -1
  108. package/scripts/ui/viewers/scatter-plot-events.js +6 -1
  109. package/scripts/ui/viewers/trellis-plot-with-summary-viewer.js +3 -1
  110. package/scripts/ui/viewers/types/markup-advanced.js +1 -1
  111. package/scripts/ui/viewers/types/trellis-plot.js +13 -1
  112. package/scripts/ui/viewers/types/word-cloud.js +1 -1
  113. package/scripts/ui/views/default-views.js +3 -3
  114. package/scripts/ui/views/layouts.js +16 -17
  115. package/scripts/ui/views/multi-view.js +1 -1
  116. package/src/global.d.ts +13 -0
  117. package/src/package-test.ts +121 -22
  118. package/webpack.config.js +4 -1
  119. package/scripts/misc/user-data-storage.js +0 -49
  120. package/scripts/scripting/scripting.js +0 -6
  121. package/scripts/ui/docking/README.md +0 -16
  122. /package/{scripts/ui/handlers → to fix}/dynamic-loading.js +0 -0
@@ -1,20 +1,47 @@
1
- import * as DG from 'datagrok-api/dg';
2
- import * as grok from 'datagrok-api/grok';
3
- import {runTests, tests, TestContext, category, test as _test, delay} from '@datagrok-libraries/utils/src/test';
1
+ import { DataFrame, Script } from 'datagrok-api/dg';
2
+ import { runTests, tests, TestContext, category, test as _test, delay, initAutoTests as initCoreTests, expect, awaitCheck, before } from '@datagrok-libraries/utils/src/test';
4
3
  export const _package = new DG.Package();
5
- export {tests};
4
+ export { tests };
6
5
 
7
6
  import './tests/test';
8
7
 
9
8
  const skip = [
10
- 'function-events', 'demo', 'ui-events', 'last-error', 'chem-benchmark', 'menu-customization',
11
- 'README', '10k-columns-updates',
9
+ // Skipped
10
+ 'function-events', 'demo', 'ui-events', 'last-error', 'chem-benchmark',
11
+ 'menu-customization', '10k-columns-updates', '100-million-rows',
12
+ 'files' /* do not test manually */,
13
+
12
14
  // To fix
13
- 'scatter-plot-3d', 'network-diagram', 'chord-viewer', 'sankey-viewer', 'word-cloud',
14
- '100-million-rows', 'custom-viewer-properties', // Break
15
- 'files', 'open-table-by-id', 'all-chembl-structures', 'charts-in-cells',
16
- 'property-grid', 'tree-view-adv', 'attached-properties', 'all-input-types',
17
- 'add-single-filter', 'custom-filters', 'filter-group', 'dynamic-loading'
15
+ 'custom-viewer-properties',
16
+ 'open-table-by-id',
17
+ 'charts-in-cells',
18
+ 'property-grid',
19
+ 'tree-view-adv',
20
+ 'attached-properties',
21
+ 'all-input-types',
22
+ 'add-single-filter',
23
+ 'custom-filters',
24
+ 'filter-group',
25
+ 'dynamic-loading',
26
+ //performance
27
+ 'read-strings',
28
+ 'dataframe-access',
29
+ '1m-aggregation',
30
+ '100-million-rows',
31
+ '1-million-columns',
32
+ 'network-diagram',
33
+ 'output-layouts',
34
+ 'file-browser'
35
+ ];
36
+
37
+ const scriptViewer = [
38
+ 'parameterValidation',
39
+ 'parameter validation',
40
+ 'parameter expressions',
41
+ 'docking',
42
+ 'input-api',
43
+ 'helm-input-ui',
44
+ 'output-layouts'
18
45
  ];
19
46
 
20
47
  //name: test
@@ -22,26 +49,98 @@ const skip = [
22
49
  //input: string test {optional: true}
23
50
  //input: object testContext {optional: true}
24
51
  //output: dataframe result
25
- export async function test(category: string, test: string, testContext: TestContext): Promise<DG.DataFrame> {
52
+ export async function test(category: string, test: string, testContext: TestContext): Promise<DataFrame> {
26
53
  testContext = new TestContext(false, false);
27
- const data = await runTests({category, test, testContext});
54
+ const data = await runTests({ category, test, testContext });
28
55
  return DG.DataFrame.fromObjects(data)!;
29
56
  }
57
+ interface ScriptObject {
58
+ [key: string]: () => Promise<void>;
59
+ }
60
+
61
+ let beforeArr : ScriptObject= {
62
+ ['Scripts:ui:inputs'] : async () => {
63
+ await grok.functions.call("Helm:getHelmHelper");}
64
+ }
65
+
66
+ let beforeArrAdded : string[] = [];
30
67
 
31
68
  //tags: init
32
69
  export async function initTests() {
70
+
33
71
  const scripts = await grok.dapi.scripts.filter('package.shortName = "ApiSamples"').list();
34
72
  for (const script of scripts) {
35
- category(('Scripts:' + script.options.path as string).replaceAll('/', ':'), () => {
73
+ let catName = ('Scripts:' + script.options.path as string).replaceAll('/', ':');
74
+ category(catName, () => {
75
+ if(!beforeArrAdded.includes(catName) && beforeArr[catName.replaceAll(' ', '')]){
76
+ before(async ()=>{
77
+ await beforeArr[catName.replaceAll(' ', '')]();
78
+ })
79
+ beforeArrAdded.push(catName);
80
+ }
81
+
36
82
  _test(script.friendlyName, async () => {
37
- await script.apply();
38
- await delay(300);
39
- // if (grok.shell.lastError) {
40
- // const err = grok.shell.lastError;
41
- // grok.shell.lastError = '';
42
- // throw new Error(err);
43
- // }
44
- }, skip.includes(script.friendlyName) ? {skipReason: 'skip'} : undefined);
83
+
84
+ const annotation = `//name: ${script.friendlyName}
85
+ //language: javascript
86
+ `;
87
+ debugger
88
+ if (scriptViewer.includes(script.friendlyName))
89
+ await runScriptViewer(script);
90
+ else
91
+ await evaluateScript(script);
92
+ grok.shell.closeAll();
93
+
94
+ async function runScriptViewer(script: Script) {
95
+ const scriptResult = new Promise<boolean>(async (resolve) => {
96
+ script.script = `${annotation}\n${script.script}`;
97
+ const scriptView = DG.ScriptView.create(script);
98
+ grok.shell.addView(scriptView);
99
+ let timeout: any;
100
+ const subscription = grok.functions.onAfterRunAction.subscribe((funcCall) => {
101
+ if ((funcCall.func as any).script === script.script.replaceAll('\r', '')) {
102
+ if (timeout)
103
+ clearTimeout(timeout);
104
+ subscription.unsubscribe();
105
+ scriptView.close();
106
+ resolve(true);
107
+ }
108
+ });
109
+ await delay(1000);
110
+ (document.getElementsByClassName("fa-play")[0] as any).click();
111
+ await delay(1000);
112
+ timeout = setTimeout(() => {
113
+ subscription.unsubscribe();
114
+ scriptView.close();
115
+ resolve(false);
116
+ }, 10000);
117
+ })
118
+
119
+ if (!(await scriptResult))
120
+ throw new Error(`Script ${'Scripts:' + script.options.path as string}.${script.friendlyName}`);
121
+ }
122
+
123
+ async function evaluateScript(script: Script) {
124
+ let timeout: any;
125
+ const subscription = grok.functions.onAfterRunAction.subscribe((funcCall) => {
126
+ if ((funcCall.func as any).script === script.script.replaceAll('\r', '')) {
127
+ if (timeout)
128
+ clearTimeout(timeout);
129
+ subscription.unsubscribe();
130
+ }
131
+ });
132
+ await script.apply();
133
+ timeout = setTimeout(() => {
134
+ subscription.unsubscribe();
135
+ throw new Error('Script didnt pass');
136
+ }, 10000);
137
+ }
138
+ }, skip.includes(script.friendlyName) ? { skipReason: 'skip' } : { timeout: 60000 });
45
139
  });
46
140
  }
47
141
  }
142
+
143
+ //name: initAutoTests
144
+ export async function initAutoTests() {
145
+ await initCoreTests(_package, _package.getModule('package-test.js'));
146
+ }
package/webpack.config.js CHANGED
@@ -2,12 +2,15 @@ const path = require('path');
2
2
 
3
3
  module.exports = {
4
4
  mode: 'development',
5
+ cache: {
6
+ type: 'filesystem',
7
+ },
5
8
  entry: {
6
9
  test: {filename: 'package-test.js', library: {type: 'var', name: `apisamples_test`}, import: './src/package-test.ts'},
7
10
  package: './src/package.ts',
8
11
  },
9
12
  resolve: {
10
- extensions: ['.wasm', '.mjs', '.js', '.json', '.ts', '.tsx'],
13
+ extensions: ['.wasm', '.mjs', '.ts', '.json', '.js', '.tsx'],
11
14
  },
12
15
  module: {
13
16
  rules: [
@@ -1,49 +0,0 @@
1
- // User data storage demo: Saving values to storage
2
-
3
- const STORAGE_NAME = 'user-data-storage-demo';
4
-
5
- let v = grok.shell.newView('demo: user data storage');
6
-
7
- let age = ui.intInput('Age', 30);
8
- let sex = ui.choiceInput('Sex', 'Male', ['Male', 'Female']);
9
- let music = ui.multiChoiceInput('Music genres', null, ['Classic', 'Rock', 'Pop', 'Jazz']);
10
-
11
- let inputs = [age, sex, music];
12
- v.append(ui.inputs(inputs));
13
-
14
- let storageButton = ui.iconFA('database', () => {
15
- grok.dapi.userDataStorage.get(STORAGE_NAME).then((entities) => {
16
- if (entities !== null && Object.keys(entities).length === 0)
17
- grok.shell.info('Storage is empty. Try to post something to the storage');
18
- else {
19
- let menu = DG.Menu.popup();
20
- for (let time of Object.keys(entities)) {
21
- let values = JSON.parse(entities[time]);
22
- menu.item(values.map(v => `${v.caption}: ${v.value}`).join(', '), () => {
23
- for (let input of values)
24
- inputs.find(i => i.caption === input.caption).load(input.value);
25
- });
26
- }
27
- menu.show();
28
- }
29
- });
30
- });
31
- storageButton.style.margin = '8px 24px 0 24px';
32
-
33
- let postButton = ui.button('Post to storage', () => {
34
- grok.shell.info(inputs.map((i) => `${i.caption}: ${i.stringValue}`).join('<br>'));
35
- grok.dapi.userDataStorage.postValue(STORAGE_NAME, `${Math.floor(Math.random() * Math.floor(1000))}`,
36
- JSON.stringify(inputs.map(i => {
37
- return {caption: i.caption, value: i.save()};
38
- })));
39
- });
40
-
41
- let clearButton = ui.button('Clear storage', () => {
42
- grok.dapi.userDataStorage.remove(STORAGE_NAME, null);
43
- });
44
-
45
- v.append(ui.divH([
46
- storageButton,
47
- postButton,
48
- clearButton
49
- ]));
@@ -1,6 +0,0 @@
1
- //tags: Script, Package
2
- //help-url: https://datagrok.ai/help/compute/scripting
3
- // An example of using scripting (R, Python etc.)
4
-
5
- grok.functions.call('Demo:PythonDup', {'s': '1010'}).then(result => grok.shell.info(result));
6
- grok.functions.call('Demo:RDup', {'s': '0101'}).then(result => grok.shell.info(result));
@@ -1,16 +0,0 @@
1
- # Docking
2
-
3
- Datagrok provides a flexible window management system, where windows
4
- could be either dragged out and positioned manually, or set up automatically.
5
-
6
- ## Top-level window docking
7
-
8
- Use `grok.shell.dockManager` to dock, undock, or reposition windows.
9
- See also `View.dockNode`
10
-
11
- ## Nested docking
12
-
13
- Some of the views contain a nested docking manager, which allows to manage
14
- windows within that particular view (they cannot be undocked and docked on
15
- a top level, or within a different view). See `dockManager` property of the
16
- View class.