@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.
- package/CHANGELOG.md +9 -0
- package/dist/package-test.js +2 -2
- package/files/viewer-events/bar-chart/on-category-clicked.js +1 -0
- package/files/viewer-events/grid/on-cell-clicked.js +1 -0
- package/files/viewer-events/pc-plot/on-line-clicked.js +1 -0
- package/files/viewer-events/pie-chart/on-segment-clicked.js +1 -0
- package/files/viewer-events/scatter-plot/on-point-clicked.js +1 -0
- package/files/viewer-events/scatter-plot/on-rendered.js +1 -0
- package/layouts/demog-table-layout.json +329 -181
- package/package.json +17 -13
- package/scripts/dapi/files.js +14 -13
- package/scripts/dapi/projects-open.js +1 -1
- package/scripts/dapi/sticky-meta-1-tags.js +54 -0
- package/scripts/dapi/sticky-meta-2-semtype.js +33 -0
- package/scripts/data-access/db-master-details-manual.js +3 -2
- package/scripts/data-access/external/stock-prices.js +1 -1
- package/scripts/data-access/open-table-by-id.js +11 -3
- package/scripts/data-access/output-layouts.js +3 -1
- package/scripts/data-frame/advanced/data-frames-in-columns.js +4 -1
- package/scripts/data-frame/advanced/virtual-columns.js +1 -1
- package/scripts/data-frame/aggregation/unpivot.js +1 -1
- package/scripts/data-frame/column-access.js +1 -3
- package/scripts/data-frame/compare-tables.js +3 -2
- package/scripts/data-frame/construction/create-from-csv-format.js +3 -3
- package/scripts/data-frame/construction/create-from-typed-arrays.js +7 -2
- package/scripts/data-frame/construction/export-to-csv-advanced.js +14 -4
- package/scripts/data-frame/construction/export-to-csv-molblock.js +3 -0
- package/scripts/data-frame/construction/export-to-csv.js +1 -1
- package/scripts/data-frame/events/calculated-columns/creation.js +1 -1
- package/scripts/data-frame/events/calculated-columns/deletion.js +1 -1
- package/scripts/data-frame/events/calculated-columns/update.js +1 -1
- package/scripts/data-frame/filtering/update-filter-state.js +13 -0
- package/scripts/data-frame/join-link/link-tables-dynamic.js +3 -5
- package/scripts/data-frame/metadata/dataframe-meta.js +1 -1
- package/scripts/data-frame/modification/add-columns.js +1 -1
- package/scripts/data-frame/modification/append.js +1 -1
- package/scripts/data-frame/modification/calculated-columns/edit-formula.js +2 -2
- package/scripts/data-frame/modification/double-precision.js +26 -0
- package/scripts/data-frame/modification/manipulate.js +3 -3
- package/scripts/domains/chem/sketcher.js +2 -2
- package/scripts/events/form-creation.js +2 -2
- package/scripts/events/global-events.js +1 -1
- package/scripts/events/layout-events.js +5 -6
- package/scripts/events/viewer-data-events.js +11 -0
- package/scripts/functions/calling.js +1 -1
- package/scripts/functions/func-call.js +5 -0
- package/scripts/grid/advanced/cell-renderer.js +1 -1
- package/scripts/grid/advanced/format-formula.js +7 -0
- package/scripts/grid/advanced/link-click.js +3 -3
- package/scripts/grid/advanced/markup-link.js +6 -0
- package/scripts/grid/advanced/paint-counts.js +4 -1
- package/scripts/grid/{color-coding-conditional.js → color-coding/color-coding-conditional.js} +17 -10
- package/scripts/grid/color-coding/color-coding.js +5 -9
- package/scripts/grid/color-coding/get-cell-color.js +3 -5
- package/scripts/grid/column-cell-styles.js +10 -0
- package/scripts/grid/column-controlled-values.js +2 -2
- package/scripts/grid/data-format.js +4 -4
- package/scripts/grid/hit-test.js +1 -1
- package/scripts/grid/html-cells/html-table-cells.js +1 -1
- package/scripts/misc/audit/test-tracking.js +1 -1
- package/scripts/misc/user-settings-storage.js +48 -0
- package/scripts/performance/all-chembl-structures.js +1 -1
- package/scripts/scripting/files-for-scripting.js +24 -0
- package/scripts/scripting/grok-scripting.js +1 -1
- package/scripts/scripting/package-scripting.js +6 -0
- package/scripts/shell/last-error.js +1 -1
- package/scripts/shell/ui-parts.js +9 -9
- package/scripts/shell/windows/browse/customize-tree.js +3 -0
- package/scripts/ui/apps/bioreactor.js +5 -5
- package/scripts/ui/components/accordion.js +3 -3
- package/scripts/ui/components/tree-view-adv.js +4 -2
- package/scripts/ui/containers/splitters.js +13 -13
- package/scripts/ui/dialogs/wizard.js +8 -8
- package/scripts/ui/docking/docking.js +4 -1
- package/scripts/ui/handlers/markup-handlers.js +61 -0
- package/scripts/ui/inputs/advanced/all-input-types.js +37 -24
- package/scripts/ui/inputs/advanced/input-api.js +39 -0
- package/scripts/ui/inputs/advanced/input-events.js +10 -10
- package/scripts/ui/inputs/advanced/input-form.js +8 -8
- package/scripts/ui/inputs/choice-input.js +5 -5
- package/scripts/ui/inputs/column-combo-box.js +3 -3
- package/scripts/ui/inputs/column-inputs.js +3 -3
- package/scripts/ui/inputs/forms.js +10 -10
- package/scripts/ui/inputs/helm-input-ui.js +7 -0
- package/scripts/ui/inputs/inputs-events.js +8 -8
- package/scripts/ui/inputs/inputs-extended.js +2 -2
- package/scripts/ui/inputs/inputs.js +17 -15
- package/scripts/ui/inputs/molecule-input.js +1 -1
- package/scripts/ui/inputs/table-input.js +1 -1
- package/scripts/ui/inputs/tags-input.js +2 -2
- package/scripts/ui/inputs/typeahead-input.js +16 -17
- package/scripts/ui/inputs/validation/input-validators.js +11 -0
- package/scripts/ui/inputs/validation/script-param-validation.js +6 -0
- package/scripts/ui/inputs/validation/visible-enabled.js +9 -0
- package/scripts/ui/interactivity/drag-and-drop.js +3 -3
- package/scripts/ui/tooltips/tooltips.js +6 -2
- package/scripts/ui/viewers/advanced/attached-properties.js +5 -5
- package/scripts/ui/viewers/advanced/default-axis-type.js +1 -1
- package/scripts/ui/viewers/advanced/init-function.js +21 -0
- package/scripts/ui/viewers/advanced/init-script.js +15 -0
- package/scripts/ui/viewers/filters/add-single-filter.js +5 -5
- package/scripts/ui/viewers/filters/custom-filters.js +3 -3
- package/scripts/ui/viewers/filters/filter-group.js +6 -1
- package/scripts/ui/viewers/filters/multi-value-filter.js +1 -1
- package/scripts/ui/viewers/js viewers/chord-viewer.js +1 -1
- package/scripts/ui/viewers/js viewers/sankey-viewer.js +1 -1
- package/scripts/ui/viewers/js viewers/word-cloud.js +1 -1
- package/scripts/ui/viewers/scatter-plot-events.js +6 -1
- package/scripts/ui/viewers/trellis-plot-with-summary-viewer.js +3 -1
- package/scripts/ui/viewers/types/markup-advanced.js +1 -1
- package/scripts/ui/viewers/types/trellis-plot.js +13 -1
- package/scripts/ui/viewers/types/word-cloud.js +1 -1
- package/scripts/ui/views/default-views.js +3 -3
- package/scripts/ui/views/layouts.js +16 -17
- package/scripts/ui/views/multi-view.js +1 -1
- package/src/global.d.ts +13 -0
- package/src/package-test.ts +121 -22
- package/webpack.config.js +4 -1
- package/scripts/misc/user-data-storage.js +0 -49
- package/scripts/scripting/scripting.js +0 -6
- package/scripts/ui/docking/README.md +0 -16
- /package/{scripts/ui/handlers → to fix}/dynamic-loading.js +0 -0
package/src/package-test.ts
CHANGED
|
@@ -1,20 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
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
|
-
|
|
11
|
-
'
|
|
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
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'property-grid',
|
|
17
|
-
'
|
|
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<
|
|
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
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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', '.
|
|
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.
|
|
File without changes
|