@datagrok/curves 1.6.0 → 1.9.0

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 (58) hide show
  1. package/.eslintrc.json +39 -0
  2. package/.vscode/launch.json +10 -9
  3. package/.vscode/tasks.json +14 -0
  4. package/CHANGELOG.md +33 -0
  5. package/README.md +36 -8
  6. package/databases/plates/0000_init.sql +167 -0
  7. package/detectors.js +2 -2
  8. package/dist/package-test.js +15930 -1
  9. package/dist/package-test.js.map +1 -1
  10. package/dist/package.js +13750 -1
  11. package/dist/package.js.map +1 -1
  12. package/img/plate-dose-response-series.gif +0 -0
  13. package/img/plate-readers.gif +0 -0
  14. package/package.json +17 -11
  15. package/queries/plates-crud.sql +148 -0
  16. package/src/fit/const.ts +60 -59
  17. package/src/fit/data-to-curves.ts +220 -0
  18. package/src/fit/fit-demo.ts +6 -6
  19. package/src/fit/fit-grid-cell-handler.ts +94 -85
  20. package/src/fit/fit-renderer.ts +162 -98
  21. package/src/fit/multi-curve-viewer.ts +69 -28
  22. package/src/fit/render-utils.ts +346 -288
  23. package/src/package-api.ts +167 -0
  24. package/src/package-test.ts +7 -1
  25. package/src/package.g.ts +140 -2
  26. package/src/package.ts +221 -79
  27. package/src/plate/excel-plates.ts +112 -0
  28. package/src/plate/plate-cell-renderer.ts +48 -0
  29. package/src/plate/plate-drc-analysis.ts +262 -0
  30. package/src/plate/plate-reader.ts +28 -0
  31. package/src/plate/plate-well-validators.ts +41 -0
  32. package/src/plate/plate-widget.ts +242 -0
  33. package/src/plate/plate.ts +557 -0
  34. package/src/plate/plates-folder-preview.ts +63 -0
  35. package/src/plate/readers/bmg-pherastar-96.ts +42 -0
  36. package/src/plate/readers/delfia-envision-96-max-rlu.ts +16 -0
  37. package/src/plate/readers/delfia-envision-by-row.ts +18 -0
  38. package/src/plate/readers/spectramax.ts +42 -0
  39. package/src/plate/utils.ts +141 -0
  40. package/src/plates/numeric_matcher.ts +191 -0
  41. package/src/plates/objects/plate-template-handler.ts +48 -0
  42. package/src/plates/plates-app.ts +64 -0
  43. package/src/plates/plates-crud.ts +502 -0
  44. package/src/plates/plates-demo.ts +107 -0
  45. package/src/plates/plates.sql +169 -0
  46. package/src/plates/views/plates-create-view.ts +123 -0
  47. package/src/plates/views/plates-schema-view.ts +58 -0
  48. package/src/plates/views/plates-search-view.ts +137 -0
  49. package/src/plates/views/plates-templates-view.ts +38 -0
  50. package/src/tests/curves-cell-renderer-tests.ts +95 -75
  51. package/src/tests/detector-tests.ts +3 -2
  52. package/src/tests/fit-tests.ts +199 -163
  53. package/src/tests/plate-tests.ts +153 -0
  54. package/src/tests/transform-tests.ts +6 -6
  55. package/test-console-output-1.log +435 -0
  56. package/test-record-1.mp4 +0 -0
  57. package/tsconfig.json +1 -1
  58. package/src/fit/cell-render-viewer.ts +0 -54
@@ -0,0 +1,169 @@
1
+ DROP SCHEMA if exists plates cascade;
2
+ CREATE SCHEMA plates;
3
+
4
+ -- Explains the meaning of a scalar property.
5
+ CREATE TABLE plates.semantic_types (
6
+ id SERIAL PRIMARY KEY,
7
+ name TEXT NOT NULL, -- e.g., "Molecule", "Cell", "Tissue", "Organism", "Treatment", "Drug", "Image"
8
+ description TEXT
9
+ );
10
+
11
+ -- Similar to core.properties or MolTrack.properties
12
+ -- Consider merging
13
+ CREATE TABLE plates.properties (
14
+ id SERIAL PRIMARY KEY,
15
+ name TEXT NOT NULL,
16
+ nullable BOOLEAN NOT NULL DEFAULT TRUE, -- used for validation of the submitted data
17
+ type TEXT CHECK (type IN ('int', 'double', 'bool', 'datetime', 'string')),
18
+ semType TEXT, -- Semantic type
19
+ userEditable BOOLEAN, -- Whether the property should be editable via the UI
20
+ units TEXT, -- Units of measurement
21
+ min REAL, -- Minimum value. Applicable to numerical properties only
22
+ max REAL, -- Maximum value. Applicable to numerical properties only
23
+ step REAL, -- Step to be used in a slider. Only applies to numerical properties
24
+ showSlider REAL, -- Whether a slider appears next to the number input. Applies to numerical columns only
25
+ showPlusMinus REAL, -- Whether a plus/minus clicker appears next to the number input. Applies to numerical columns only
26
+ inputType TEXT, -- Property input type (see DG.InputType)
27
+ category TEXT, -- Corresponding category on the context panel
28
+ format TEXT, -- Value format, such as '0.000'
29
+ choices TEXT, -- JSON-encoded list of choices. Applicable to string properties only
30
+ validators TEXT, -- JSON-encoded list of validators, such as '[">42"]'
31
+ friendlyName TEXT, -- Custom field friendly name shown in [PropertyGrid]
32
+ options JSONB, -- Additional options
33
+
34
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
35
+ );
36
+
37
+ -- Allowed values for properties that are strings, floats, or integers.
38
+ -- When allowed values are present, the property value must be one of the allowed values.
39
+ CREATE TABLE plates.property_allowed_values (
40
+ id SERIAL PRIMARY KEY,
41
+ property_id INTEGER NOT NULL REFERENCES plates.properties(id),
42
+ value_string TEXT,
43
+ value_float REAL,
44
+ value_int INTEGER
45
+ );
46
+
47
+ -- maximum volume per well, material, shape (round bottom, conical).
48
+ CREATE TABLE plates.plate_types (
49
+ id SERIAL PRIMARY KEY,
50
+ name TEXT,
51
+ rows SMALLINT,
52
+ cols SMALLINT,
53
+ max_volume REAL -- microliters
54
+ );
55
+
56
+ -- layouts are reused across assay runs
57
+ CREATE TABLE plates.layouts (
58
+ id SERIAL PRIMARY KEY,
59
+ rows SMALLINT,
60
+ cols SMALLINT,
61
+ description TEXT,
62
+ details JSONB,
63
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
64
+ created_by UUID references users(id)
65
+ );
66
+
67
+ -- represents an assay plate
68
+ CREATE TABLE plates.plates (
69
+ id SERIAL PRIMARY KEY,
70
+ layout_id INTEGER references plates.layouts(id),
71
+ plate_type_id INTEGER references plates.plate_types(id),
72
+ barcode TEXT,
73
+ description TEXT,
74
+ details JSONB,
75
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
76
+ created_by UUID references users(id)
77
+ );
78
+
79
+ -- User-defined plate details
80
+ -- Stored in the Plate.meta in TypeScript
81
+ CREATE TABLE plates.plate_details (
82
+ plate_id INTEGER NOT NULL REFERENCES plates.plates(id),
83
+ property_id INTEGER NOT NULL REFERENCES plates.properties(id),
84
+
85
+ value_datetime TIMESTAMP WITH TIME ZONE,
86
+ value_uuid uuid,
87
+ value_num REAL,
88
+ value_string TEXT,
89
+ value_bool BOOLEAN,
90
+
91
+ PRIMARY KEY (plate_id, property_id)
92
+ );
93
+
94
+ -- A template specifies a set of properties applicable on plate and well levels.
95
+ -- See also template_plate_properties and template_well_properties.
96
+ CREATE TABLE plates.templates (
97
+ id SERIAL PRIMARY KEY,
98
+ plate_layout_id INTEGER REFERENCES plates.plates(id),
99
+ name TEXT,
100
+ description TEXT,
101
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
102
+ created_by UUID references users(id)
103
+ );
104
+
105
+ CREATE TABLE plates.template_plate_properties (
106
+ template_id INTEGER NOT NULL references plates.templates(id),
107
+ property_id INTEGER NOT NULL references plates.properties(id),
108
+ PRIMARY KEY (template_id, property_id)
109
+ );
110
+
111
+ CREATE TABLE plates.template_well_properties (
112
+ template_id INTEGER NOT NULL references plates.templates(id),
113
+ property_id INTEGER NOT NULL references plates.properties(id),
114
+ PRIMARY KEY (template_id, property_id)
115
+ );
116
+
117
+
118
+ CREATE TABLE plates.plate_layout_wells (
119
+ layout_id INTEGER NOT NULL references plates.plates(id),
120
+ row SMALLINT,
121
+ col SMALLINT,
122
+ PRIMARY KEY (layout_id, row, col)
123
+ );
124
+
125
+ CREATE TABLE plates.plate_wells (
126
+ plate_id INTEGER NOT NULL references plates.plates(id),
127
+ row SMALLINT,
128
+ col SMALLINT,
129
+ details JSONB,
130
+ PRIMARY KEY (plate_id, row, col)
131
+ );
132
+
133
+ CREATE TABLE plates.plate_well_values (
134
+ plate_id INTEGER NOT NULL references plates.plates(id),
135
+ row SMALLINT,
136
+ col SMALLINT,
137
+ property_id INTEGER references plates.properties(id),
138
+
139
+ value_num REAL,
140
+ value_string TEXT,
141
+ value_bool BOOLEAN
142
+ );
143
+
144
+
145
+ INSERT INTO plates.semantic_types (name) values ('Molecule');
146
+ INSERT INTO plates.semantic_types (name) values ('Solvent');
147
+ INSERT INTO plates.semantic_types (name) values ('URL');
148
+ INSERT INTO plates.semantic_types (name) values ('Image');
149
+
150
+ INSERT INTO plates.properties (id, name, type, units) values (1000, 'Volume', 'double', 'uL');
151
+ INSERT INTO plates.properties (id, name, type, units) values (1001, 'Concentration', 'double', 'uM');
152
+ INSERT INTO plates.properties (id, name, type) values (1002, 'Sample', 'string');
153
+ INSERT INTO plates.properties (id, name, type) values (1003, 'Well Role', 'string');
154
+
155
+ INSERT INTO plates.plate_types (id, name, rows, cols) values (1, 'Generic 96 wells', 8, 12);
156
+ INSERT INTO plates.plate_types (id, name, rows, cols) values (2, 'Generic 384 wells', 16, 24);
157
+ INSERT INTO plates.plate_types (id, name, rows, cols) values (3, 'Generic 1536 wells', 32, 48);
158
+
159
+ INSERT INTO plates.property_allowed_values (property_id, value_string)
160
+ VALUES
161
+ (1003, 'Empty'),
162
+ (1003, 'Sample'),
163
+ (1003, 'DMSO'),
164
+ (1003, 'Low Control'),
165
+ (1003, 'High Control');
166
+
167
+ GRANT ALL PRIVILEGES ON SCHEMA plates TO CURRENT_USER;
168
+ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA plates TO CURRENT_USER;
169
+ GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA plates TO CURRENT_USER;
@@ -0,0 +1,123 @@
1
+ /* eslint-disable max-len */
2
+ import * as DG from 'datagrok-api/dg';
3
+ import * as grok from 'datagrok-api/grok';
4
+ import * as ui from 'datagrok-api/ui';
5
+ import {Plate} from '../../plate/plate';
6
+ import {
7
+ getPlateById,
8
+ initPlates,
9
+ PlateTemplate,
10
+ plateTemplates,
11
+ PlateType,
12
+ plateTypes,
13
+ savePlate,
14
+ savePlateAsTemplate,
15
+ createNewPlateForTemplate
16
+ } from '../plates-crud';
17
+ import {PlateWidget} from '../../plate/plate-widget';
18
+
19
+
20
+ export function createPlatesView(): DG.View {
21
+ const view = DG.View.create();
22
+ view.name = 'Create Plate';
23
+ const platePropertiesHost = ui.divV([]);
24
+ let plateTemplateValues = {};
25
+ let plateType = plateTypes[0];
26
+ let plateTemplate = plateTemplates[0];
27
+ if (!plateTemplate) {
28
+ grok.shell.warning('No plate templates found. Please create a template first.');
29
+ throw new Error('No plate templates found. Please create a template first.');
30
+ }
31
+
32
+ const updatePlate = async () => {
33
+ plateWidget.plate = await createNewPlateForTemplate(plateType, plateTemplate);
34
+ plateWidget.editable = true;
35
+ };
36
+
37
+ const setTemplate = (template: PlateTemplate) => {
38
+ plateTemplate = template;
39
+ plateTemplateValues = {};
40
+ const form = ui.input.form(plateTemplateValues, template.plateProperties.map((p) => DG.Property.js(p.name!, p.type! as DG.TYPE)));
41
+ ui.empty(platePropertiesHost);
42
+ platePropertiesHost.appendChild(form);
43
+ updatePlate().then((_) => {});
44
+ };
45
+
46
+ const plateTypeSelector = ui.input.choice('Plate type', {
47
+ items: plateTypes.map((pt) => pt.name),
48
+ value: plateTypes[0].name,
49
+ onValueChanged: (v) => {
50
+ plateType = plateTypes.find((pt) => pt.name === v)!;
51
+ updatePlate().then((_) => {});
52
+ }
53
+ });
54
+
55
+ const plateTemplateSelector = ui.input.choice('Template', {
56
+ items: plateTemplates.map((pt) => pt.name),
57
+ value: plateTemplates[0]?.name,
58
+ onValueChanged: (v) => setTemplate(plateTemplates.find((pt) => pt.name === v)!)
59
+ });
60
+
61
+ const fileInput = ui.input.file('Import from Excel', {
62
+ nullable: true,
63
+ onValueChanged: async (file) => {
64
+ const plate = await Plate.fromExcel(await file.readAsBytes());
65
+ if (plate.rows !== plateType.rows || plate.cols !== plateType.cols) {
66
+ grok.shell.error(`Plate dimensions do not match the template: ${plate.rows}x${plate.cols} vs ${plateType.rows}x${plateType.cols}`);
67
+ return;
68
+ }
69
+
70
+ for (const layer of plate.getLayerNames().filter((l) => plateTemplate.wellProperties.find((p) => p.name?.toLowerCase() === l.toLowerCase()))) {
71
+ const excelCol = plate.data.col(layer)!;
72
+ plateWidget.plate.data.col(layer)!.init((i) => excelCol.get(i));
73
+ }
74
+
75
+ const missingLayers = plateTemplate.wellProperties.filter((p) => !plate.getLayerNames().includes(p.name!));
76
+ if (missingLayers.length > 0)
77
+ grok.shell.warning(`Plate is missing the following layers: ${missingLayers.map((p) => p.name!).join(', ')}`);
78
+
79
+ plateWidget.refresh();
80
+ }
81
+ });
82
+
83
+ // Create plate viewer
84
+ const plate = new Plate(plateType.rows, plateType.cols);
85
+ const plateWidget = PlateWidget.fromPlate(plate);
86
+ plateWidget.editable = true;
87
+ plateWidget.root.style.height = '400px';
88
+ setTemplate(plateTemplates[0]);
89
+
90
+ // Add components to view
91
+ view.root.appendChild(ui.divV([
92
+ ui.form([
93
+ plateTypeSelector,
94
+ plateTemplateSelector,
95
+ fileInput
96
+ ]),
97
+ platePropertiesHost,
98
+ plateWidget.root
99
+ ]));
100
+
101
+ const getPlate = () => {
102
+ const plate = plateWidget.plate;
103
+ plate.details = plateTemplateValues;
104
+ return plate;
105
+ };
106
+
107
+ view.setRibbonPanels([[
108
+ ui.bigButton('CREATE', async () => {
109
+ const plate = getPlate();
110
+ await savePlate(plate);
111
+ grok.shell.info(`Plate created: ${plate.id}`);
112
+ }),
113
+
114
+ ui.button('SAVE TEMPLATE', async () => {
115
+ const plate = getPlate();
116
+ await savePlateAsTemplate(plate, plateTemplate);
117
+ await initPlates();
118
+ grok.shell.info(`Plate template saved: ${plate.id}`);
119
+ })
120
+ ]]);
121
+
122
+ return view;
123
+ }
@@ -0,0 +1,58 @@
1
+ import * as DG from 'datagrok-api/dg';
2
+ import * as grok from 'datagrok-api/grok';
3
+ import * as ui from 'datagrok-api/ui';
4
+ import {createPlateTemplate, initPlates, PlateTemplate} from '../plates-crud';
5
+ import {SchemaEditor} from '@datagrok-libraries/utils/src/schema-editor';
6
+ import {merge} from 'rxjs';
7
+
8
+
9
+ export function propertySchemaView(template: PlateTemplate): DG.View {
10
+ const view = DG.View.create();
11
+ view.name = 'Templates / ' + template.name;
12
+
13
+ const extraPropertiesDiv = ui.div([]);
14
+ const platePropEditor =
15
+ new SchemaEditor({properties: template.plateProperties, extraPropertiesDiv: extraPropertiesDiv});
16
+ const wellPropEditor =
17
+ new SchemaEditor({properties: template.wellProperties, extraPropertiesDiv: extraPropertiesDiv});
18
+ const nameEditor = ui.input.string('Name', {value: template.name});
19
+ const descriptionEditor = ui.input.string('Description', {value: template.description});
20
+
21
+ const saveButton = ui.bigButton('SAVE', async () => {
22
+ template.name = nameEditor.value;
23
+ template.description = descriptionEditor.value;
24
+ template.plateProperties = platePropEditor.properties;
25
+ template.wellProperties = wellPropEditor.properties;
26
+ await createPlateTemplate(template);
27
+ await initPlates(true);
28
+ grok.shell.info('Template saved');
29
+ });
30
+
31
+ const updateSaveVisibility = () => saveButton.style.display = template.id !== -1 ? 'none' : 'block';
32
+ updateSaveVisibility();
33
+
34
+ merge(platePropEditor.table.onChanged, wellPropEditor.table.onChanged).subscribe((_) => updateSaveVisibility());
35
+
36
+ view.root.appendChild(ui.divV([
37
+ ui.h2('Template'),
38
+ ui.form([
39
+ nameEditor,
40
+ descriptionEditor,
41
+ ]),
42
+
43
+ ui.divH([
44
+ ui.divV([
45
+ ui.h2('Plate properties'),
46
+ platePropEditor,
47
+ ui.h2('Well properties'),
48
+ wellPropEditor,
49
+ ]),
50
+ ui.div([], {style: {width: '20px'}}),
51
+ extraPropertiesDiv
52
+ ]),
53
+ ]));
54
+
55
+ view.setRibbonPanels([[saveButton]]);
56
+
57
+ return view;
58
+ }
@@ -0,0 +1,137 @@
1
+ import {PlateQuery, PlateTemplate, PropertyCondition} from '../plates-crud';
2
+
3
+ import * as DG from 'datagrok-api/dg';
4
+ import * as grok from 'datagrok-api/grok';
5
+ import * as ui from 'datagrok-api/ui';
6
+ import {debounceTime} from 'rxjs/operators';
7
+ import {NumericMatcher, StringInListMatcher} from '../numeric_matcher';
8
+ import {PlateProperty, plateProperties, getPlateUniquePropertyValues,
9
+ getWellUniquePropertyValues, queryPlates, queryWells, wellProperties, plateTemplates} from '../plates-crud';
10
+
11
+
12
+ type PropInput = DG.InputBase & { prop: PlateProperty };
13
+
14
+
15
+ function getSearchForm(properties: PlateProperty[], getUniqueValues: (prop: any) => string[]): DG.InputForm {
16
+ const inputs: PropInput[] = [];
17
+ for (const prop of properties) {
18
+ if (prop.type == DG.TYPE.STRING) {
19
+ const items = getUniqueValues(prop);
20
+ const input = ui.input.multiChoice(prop.name, {items: items}) as PropInput;
21
+ input.prop = prop;
22
+ inputs.push(input);
23
+ } else if (prop.type == DG.TYPE.FLOAT) {
24
+ const input = ui.input.string(prop.name) as PropInput;
25
+ input.prop = prop;
26
+ input.addValidator((s) => NumericMatcher.parse(s) ? null : 'Invalid numerical criteria. Example: ">10"');
27
+ inputs.push(input);
28
+ }
29
+ }
30
+
31
+ return DG.InputForm.forInputs(inputs);
32
+ }
33
+
34
+ function getPlatesSearchForm(filteredProperties?: PlateProperty[]): DG.InputForm {
35
+ return getSearchForm(filteredProperties ?? plateProperties, getPlateUniquePropertyValues);
36
+ }
37
+
38
+ function getWellsSearchForm(filteredProperties?: PlateProperty[]): DG.InputForm {
39
+ return getSearchForm(filteredProperties ?? wellProperties, getWellUniquePropertyValues);
40
+ }
41
+
42
+ function searchFormToMatchers(form: DG.InputForm): PropertyCondition[] {
43
+ const matchers: PropertyCondition[] = [];
44
+
45
+ for (const input of form.inputs as PropInput[]) {
46
+ if (input.inputType == DG.InputType.MultiChoice && input.value.length > 0) {
47
+ matchers.push({
48
+ property: input.prop,
49
+ matcher: new StringInListMatcher(input.value)
50
+ });
51
+ } else if (input.inputType == DG.InputType.Text && input.value !== '' && NumericMatcher.parse(input.value)) {
52
+ matchers.push({
53
+ property: input.prop,
54
+ matcher: NumericMatcher.parse(input.value)!
55
+ });
56
+ }
57
+ }
58
+
59
+ return matchers;
60
+ }
61
+
62
+ function getSearchView(search: (query: PlateQuery) => Promise<DG.DataFrame>,
63
+ onResults: (grid: DG.Grid) => void
64
+ ): DG.View {
65
+ const dummy = DG.DataFrame.create(5, 'Search plates');
66
+ const view = DG.TableView.create(dummy);
67
+ let platesForm = getPlatesSearchForm();
68
+ let wellsForm = getWellsSearchForm();
69
+ const platesFormHost = ui.div();
70
+ const wellsFormHost = ui.div();
71
+ let plateTemplate = plateTemplates[0];
72
+ if (!plateTemplate) {
73
+ grok.shell.warning('No plate templates found. Please create a template first.');
74
+ throw new Error('No plate templates found. Please create a template first.');
75
+ }
76
+
77
+ const refreshUI = () => {
78
+ ui.empty(platesFormHost);
79
+ ui.empty(wellsFormHost);
80
+ platesForm = getPlatesSearchForm(plateTemplate?.plateProperties?.map((p) => p as PlateProperty));
81
+ wellsForm = getWellsSearchForm(plateTemplate?.wellProperties?.map((p) => p as PlateProperty));
82
+ platesForm.onInputChanged.pipe(debounceTime(500)).subscribe((_) => refreshResults());
83
+ wellsForm.onInputChanged.pipe(debounceTime(500)).subscribe((_) => refreshResults());
84
+ platesFormHost.appendChild(platesForm.root);
85
+ wellsFormHost.appendChild(wellsForm.root);
86
+ };
87
+
88
+ const setTemplate = (template: PlateTemplate) => {
89
+ plateTemplate = template;
90
+ refreshUI();
91
+ };
92
+
93
+ const plateTemplateSelector = ui.input.choice('Template', {
94
+ nullable: true,
95
+ items: plateTemplates.map((pt) => pt.name),
96
+ value: plateTemplates[0].name,
97
+ onValueChanged: (v) => setTemplate(plateTemplates.find((pt) => pt.name === v)!)
98
+ });
99
+
100
+
101
+ const refreshResults = () => {
102
+ const query: PlateQuery = {
103
+ plateMatchers: searchFormToMatchers(platesForm),
104
+ wellMatchers: searchFormToMatchers(wellsForm)
105
+ };
106
+
107
+ search(query).then((df) => {
108
+ view.dataFrame = df;
109
+ onResults(view.grid);
110
+ });
111
+ };
112
+
113
+ const searchHost = ui.divV([
114
+ plateTemplateSelector.root,
115
+ ui.divH([
116
+ ui.divV([ui.h2('Plates'), platesFormHost], {style: {flexGrow: '1'}}),
117
+ ui.divV([ui.h2('Wells'), wellsFormHost], {style: {flexGrow: '1'}})
118
+ ], {style: {height: '100%', width: '100%'}}),
119
+ ], {classes: 'ui-panel'});
120
+ view.dockManager.dock(searchHost, DG.DOCK_TYPE.TOP);
121
+
122
+ //refreshUI();
123
+ setTemplate(plateTemplates[0]);
124
+ refreshResults();
125
+ return view;
126
+ }
127
+
128
+ export function searchPlatesView(): DG.View {
129
+ return getSearchView(queryPlates, (grid) => {
130
+ grid.columns.add({gridColumnName: 'plate', cellType: 'Plate'})
131
+ .onPrepareValueScript = `return (await curves.getPlateByBarcode(gridCell.tableRow.get('barcode'))).data;`;
132
+ });
133
+ }
134
+
135
+ export function searchWellsView(): DG.View {
136
+ return getSearchView(queryWells, (grid) => {});
137
+ }
@@ -0,0 +1,38 @@
1
+ import * as DG from 'datagrok-api/dg';
2
+ import * as grok from 'datagrok-api/grok';
3
+ import * as ui from 'datagrok-api/ui';
4
+ import {plateTemplates} from '../plates-crud';
5
+ import {propertySchemaView} from './plates-schema-view';
6
+ import {PlateTemplateHandler} from '../objects/plate-template-handler';
7
+
8
+
9
+ export function createTemplatesView(): DG.View {
10
+ const view = DG.View.create();
11
+ view.name = 'Templates';
12
+
13
+ const templatesTable = ui.table(plateTemplates, (t) => [
14
+ t.name,
15
+ t.description,
16
+ ui.button('Edit', () => PlateTemplateHandler.editTemplate(t)),
17
+ ui.button('Clone', () => PlateTemplateHandler.openCloneTemplateView(t)),
18
+ ]);
19
+
20
+ view.root.appendChild(templatesTable);
21
+
22
+ view.setRibbonPanels([[
23
+ ui.bigButton('CREATE NEW', async () => {
24
+ const newTemplate = {
25
+ name: 'New Template',
26
+ description: '',
27
+ plateProperties: [],
28
+ wellProperties: [],
29
+ id: -1,
30
+ plate_layout_id: -1
31
+ };
32
+
33
+ grok.shell.addPreview(propertySchemaView(newTemplate));
34
+ }),
35
+ ]]);
36
+
37
+ return view;
38
+ }