@datagrok/hit-triage 1.10.0 → 1.10.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/hit-triage",
3
3
  "friendlyName": "Hit Triage",
4
- "version": "1.10.0",
4
+ "version": "1.10.1",
5
5
  "author": {
6
6
  "name": "Davit Rizhinashvili",
7
7
  "email": "drizhinashvili@datagrok.ai"
@@ -0,0 +1,360 @@
1
+ /* eslint-disable max-len */
2
+ import * as DG from 'datagrok-api/dg';
3
+ import * as ui from 'datagrok-api/ui';
4
+ import * as grok from 'datagrok-api/grok';
5
+ import {HitDesignApp} from '../hit-design-app';
6
+ import {HitAppBase} from '../hit-app-base';
7
+ import {HitDesignMergeClashStrategy, HitDesignMergeConfig, HitDesignMergeMode} from '../types';
8
+ import {guessMoleculeColumn, guessVidColumn, isLocalUploadFileInfo, mergeIntoCampaign} from '../utils/merge-table';
9
+ import {_package} from '../../package';
10
+
11
+ // Mirrors the drag-n-drop path in HitDesignApp.handleUploadingDataframe: csv goes through
12
+ // DG.DataFrame.fromCsv, anything else is delegated to a registered file-handler function.
13
+ // HitAppBase.molFileExtReaders is statically filtered to only those extensions for which
14
+ // the platform actually exposes a reader, so this list reflects what we can really parse.
15
+ const ALLOWED_EXTENSIONS: string[] = ['csv', ...HitAppBase.molFileExtReaders.map((r) => r.ext)];
16
+
17
+ function getExtension(fi: DG.FileInfo): string {
18
+ const ext = fi.extension?.toLowerCase();
19
+ if (ext) return ext;
20
+ const name = fi.name?.toLowerCase() ?? '';
21
+ const dot = name.lastIndexOf('.');
22
+ return dot >= 0 ? name.slice(dot + 1) : '';
23
+ }
24
+
25
+ async function readFileInfoToDataFrame(fi: DG.FileInfo): Promise<DG.DataFrame | null> {
26
+ const ext = getExtension(fi);
27
+ if (ext === 'csv') {
28
+ const text = await fi.readAsString();
29
+ return DG.DataFrame.fromCsv(text);
30
+ }
31
+ const reader = HitAppBase.molFileExtReaders.find((r) => r.ext === ext);
32
+ if (!reader) return null;
33
+ const bytes = await fi.readAsBytes();
34
+ if (!bytes) return null;
35
+ const bytesArg = reader.handlerFunc.inputs[0].name;
36
+ const result: any = await reader.handlerFunc.apply({[bytesArg]: bytes});
37
+ return Array.isArray(result) ? result[0] : result;
38
+ }
39
+
40
+ const MODE_LABELS: Record<HitDesignMergeMode, string> = {
41
+ smiles: 'By canonical SMILES',
42
+ vid: 'By V-iD',
43
+ };
44
+ const CLASH_LABELS: Record<HitDesignMergeClashStrategy, string> = {
45
+ skip: 'Skip (keep campaign value)',
46
+ overwrite: 'Overwrite (use incoming value)',
47
+ };
48
+
49
+ const NONE_OPTION = '(none)';
50
+
51
+ function setChoiceItems(input: DG.InputBase<string | null>, items: string[], desired?: string | null): void {
52
+ (input as unknown as DG.ChoiceInput<string>).items = items;
53
+ if (desired != null && items.includes(desired))
54
+ input.value = desired;
55
+ else if (items.length > 0)
56
+ input.value = items[0];
57
+ else
58
+ input.value = null;
59
+ }
60
+
61
+ export async function openMergeTableDialog<T extends HitDesignApp>(app: T): Promise<void> {
62
+ if (!app.dataFrame) {
63
+ grok.shell.error('Cannot merge: campaign has no data.');
64
+ return;
65
+ }
66
+ const saved: HitDesignMergeConfig | undefined = app.campaign?.mergeConfig;
67
+
68
+ // Mutable dialog state
69
+ let incomingDf: DG.DataFrame | null = null;
70
+ let isLoadingFile = false;
71
+ // Re-entrancy guard — onValueChanged on the file input fires for both user actions and
72
+ // programmatic resets. We only want the validate-then-load behavior on user actions.
73
+ let suppressFileChange = false;
74
+
75
+ // ---- Inputs ----
76
+ const fileInput = ui.input.file('Source file', {
77
+ nullable: true,
78
+ tooltipText: `Pick a file from your computer or from a Datagrok file share.\n` +
79
+ `Allowed extensions: ${ALLOWED_EXTENSIONS.join(', ')}.\n` +
80
+ `Files picked from a share are remembered with the campaign and reloaded automatically next time.`,
81
+ onValueChanged: (v) => onFileChanged(v),
82
+ });
83
+ fileInput.input.setAttribute('placeholder', `Drop file or pick from share — ${ALLOWED_EXTENSIONS.join(', ')}`);
84
+
85
+ const modeInput = ui.input.choice<string>('Merge by', {
86
+ items: Object.values(MODE_LABELS),
87
+ value: MODE_LABELS[saved?.mode ?? 'vid'],
88
+ nullable: false,
89
+ tooltipText: 'Join key. "Canonical SMILES" matches by canonicalized molecule structure; ' +
90
+ '"V-iD" matches by the campaign\'s V-iD identifier.',
91
+ onValueChanged: () => runValidation(),
92
+ });
93
+
94
+ const molColInput = ui.input.choice<string>('Molecule column (incoming)', {
95
+ items: [],
96
+ value: null as unknown as string,
97
+ nullable: true,
98
+ tooltipText: 'Column in the incoming table holding the molecules. ' +
99
+ 'Required for SMILES merge. In V-iD merge it is optional — if set, ' +
100
+ 'unmatched rows can be added to the campaign and registered with new V-iDs.',
101
+ onValueChanged: () => runValidation(),
102
+ });
103
+
104
+ const vidColInput = ui.input.choice<string>('V-iD column (incoming)', {
105
+ items: [],
106
+ value: null as unknown as string,
107
+ nullable: true,
108
+ tooltipText: 'Column in the incoming table holding V-iD strings. Used as the join key when merging by V-iD.',
109
+ onValueChanged: () => runValidation(),
110
+ });
111
+
112
+ const addRowsInput = ui.input.bool('Add unmatched rows', {
113
+ value: saved?.addNewRows ?? true,
114
+ tooltipText: 'When on, rows from the incoming table whose key is not present in the campaign are added as new rows. ' +
115
+ 'When off, only existing rows are updated. ' +
116
+ 'Disabled when no incoming molecule column is selected (nothing to register the new row with).',
117
+ onValueChanged: () => runValidation(),
118
+ });
119
+
120
+ const runComputeInput = ui.input.bool('Run compute on new rows', {
121
+ value: saved?.runComputeOnNewRows ?? true,
122
+ tooltipText: 'Run the campaign\'s compute pipeline (descriptors, functions, scripts, queries) on the incoming molecules ' +
123
+ 'so new rows arrive with all calculated columns filled in. Disabled when no rows will be added.',
124
+ onValueChanged: () => runValidation(),
125
+ });
126
+
127
+ const clashInput = ui.input.choice<string>('On clashing data', {
128
+ items: Object.values(CLASH_LABELS),
129
+ value: CLASH_LABELS[saved?.clashStrategy ?? 'overwrite'],
130
+ nullable: false,
131
+ tooltipText: 'How to resolve cells that have a value on both sides for a matched row. ' +
132
+ '"Skip" keeps the existing campaign value; "Overwrite" replaces it with the incoming value. ' +
133
+ 'Empty campaign cells are always filled from the incoming table regardless of this setting.',
134
+ onValueChanged: () => runValidation(),
135
+ });
136
+
137
+ const errorDiv = ui.divText('');
138
+ errorDiv.style.color = 'var(--failure)';
139
+ errorDiv.style.fontSize = '12px';
140
+ errorDiv.style.marginTop = '8px';
141
+ errorDiv.style.minHeight = '16px';
142
+
143
+ const inputsRoot = ui.divV([
144
+ fileInput.root,
145
+ modeInput.root,
146
+ molColInput.root,
147
+ vidColInput.root,
148
+ addRowsInput.root,
149
+ runComputeInput.root,
150
+ clashInput.root,
151
+ errorDiv,
152
+ ]);
153
+ inputsRoot.style.minWidth = '420px';
154
+
155
+ // ---- Helpers reading current input state ----
156
+ const labelToMode = (label: string | null): HitDesignMergeMode =>
157
+ label === MODE_LABELS.vid ? 'vid' : 'smiles';
158
+ const labelToClash = (label: string | null): HitDesignMergeClashStrategy =>
159
+ label === CLASH_LABELS.overwrite ? 'overwrite' : 'skip';
160
+ const colChoiceValue = (input: DG.InputBase<string | null>): string | undefined => {
161
+ const v = input.value;
162
+ return v && v !== NONE_OPTION ? v : undefined;
163
+ };
164
+
165
+ // ---- Core validation / state machine ----
166
+ function runValidation(): void {
167
+ const mode = labelToMode(modeInput.value);
168
+ const fileLoaded = !!incomingDf && !isLoadingFile;
169
+
170
+ // Block / unblock inputs based on availability of incoming data + selected mode.
171
+ modeInput.enabled = fileLoaded;
172
+ molColInput.enabled = fileLoaded;
173
+ vidColInput.enabled = fileLoaded && mode === 'vid';
174
+ clashInput.enabled = fileLoaded;
175
+
176
+ const molCol = colChoiceValue(molColInput);
177
+ const vidCol = colChoiceValue(vidColInput);
178
+
179
+ // Disable downstream toggles when their precondition isn't met, but DON'T clobber the
180
+ // user's chosen value — the OK handler only honors them when they're effective, so the
181
+ // value sticks across input changes (e.g. the user briefly unsets the molecule column).
182
+ const canChooseAddRows = fileLoaded && !!molCol;
183
+ addRowsInput.enabled = canChooseAddRows;
184
+
185
+ const canRunCompute = canChooseAddRows && addRowsInput.value === true;
186
+ runComputeInput.enabled = canRunCompute;
187
+
188
+ let errorMessage = '';
189
+ if (isLoadingFile)
190
+ errorMessage = 'Reading file…';
191
+ else if (!fileLoaded)
192
+ errorMessage = 'Pick a source file to merge from.';
193
+ else if (mode === 'smiles' && !molCol)
194
+ errorMessage = 'Pick the molecule column from the incoming table.';
195
+ else if (mode === 'vid' && !vidCol)
196
+ errorMessage = 'Pick the V-iD column from the incoming table.';
197
+
198
+ errorDiv.textContent = errorMessage;
199
+ setOkEnabled(errorMessage === '');
200
+ }
201
+
202
+ // ---- File loading ----
203
+ async function loadAndApplyFile(fi: DG.FileInfo, savedToApply: HitDesignMergeConfig | null): Promise<void> {
204
+ isLoadingFile = true;
205
+ incomingDf = null;
206
+ runValidation();
207
+ ui.setUpdateIndicator(inputsRoot, true, 'Reading file...');
208
+ try {
209
+ const df = await readFileInfoToDataFrame(fi);
210
+ if (!df) throw new Error('Empty result');
211
+ df.name = (fi.name ?? '').replace(/\.[^.]+$/, '');
212
+ await df.meta.detectSemanticTypes();
213
+ await grok.data.detectSemanticTypes(df);
214
+ incomingDf = df;
215
+ } catch (e) {
216
+ _package.logger.error(e);
217
+ grok.shell.error(`Failed to read "${fi.name}". Check that the file is accessible and well-formed.`);
218
+ incomingDf = null;
219
+ } finally {
220
+ ui.setUpdateIndicator(inputsRoot, false);
221
+ isLoadingFile = false;
222
+ }
223
+ populateColumnChoices(savedToApply);
224
+ if (savedToApply)
225
+ applySavedScalarChoices(savedToApply);
226
+ runValidation();
227
+ }
228
+
229
+ function populateColumnChoices(savedToApply: HitDesignMergeConfig | null): void {
230
+ if (!incomingDf) {
231
+ setChoiceItems(molColInput, []);
232
+ setChoiceItems(vidColInput, []);
233
+ return;
234
+ }
235
+ const colNames = incomingDf.columns.toList().map((c) => c.name);
236
+
237
+ const molDesired = savedToApply?.molColName ?? guessMoleculeColumn(incomingDf)?.name ?? null;
238
+ const molItems = [NONE_OPTION, ...colNames];
239
+ setChoiceItems(molColInput, molItems, molDesired ?? NONE_OPTION);
240
+
241
+ const vidDesired = savedToApply?.vidColName ?? guessVidColumn(incomingDf)?.name ?? null;
242
+ const vidItems = [NONE_OPTION, ...colNames];
243
+ setChoiceItems(vidColInput, vidItems, vidDesired ?? NONE_OPTION);
244
+ }
245
+
246
+ function applySavedScalarChoices(savedToApply: HitDesignMergeConfig): void {
247
+ modeInput.value = MODE_LABELS[savedToApply.mode];
248
+ addRowsInput.value = savedToApply.addNewRows;
249
+ runComputeInput.value = savedToApply.runComputeOnNewRows;
250
+ clashInput.value = CLASH_LABELS[savedToApply.clashStrategy];
251
+ }
252
+
253
+ async function onFileChanged(fi: DG.FileInfo | null): Promise<void> {
254
+ if (suppressFileChange) return;
255
+
256
+ if (!fi) {
257
+ incomingDf = null;
258
+ populateColumnChoices(null);
259
+ runValidation();
260
+ return;
261
+ }
262
+ const ext = getExtension(fi);
263
+ if (!ALLOWED_EXTENSIONS.includes(ext as typeof ALLOWED_EXTENSIONS[number])) {
264
+ // Defer the clear to break the change → handler → change loop, and to make sure
265
+ // we see the user's actual selection before reverting.
266
+ setTimeout(() => {
267
+ suppressFileChange = true;
268
+ try {
269
+ fileInput.value = null;
270
+ } finally {
271
+ suppressFileChange = false;
272
+ }
273
+ runValidation();
274
+ }, 0);
275
+ grok.shell.warning(`Unsupported file type ".${ext || '?'}". Allowed: ${ALLOWED_EXTENSIONS.join(', ')}.`);
276
+ return;
277
+ }
278
+ await loadAndApplyFile(fi, null);
279
+ }
280
+
281
+ // ---- Dialog ----
282
+ const dialog = ui.dialog('Merge with table');
283
+ dialog.add(inputsRoot);
284
+ dialog.onOK(async () => {
285
+ await onOk();
286
+ });
287
+
288
+ function setOkEnabled(enabled: boolean): void {
289
+ const okBtn = dialog.getButton('OK');
290
+ if (!okBtn) return;
291
+ if (enabled) {
292
+ okBtn.removeAttribute('disabled');
293
+ okBtn.classList.remove('disabled');
294
+ } else {
295
+ okBtn.setAttribute('disabled', 'true');
296
+ okBtn.classList.add('disabled');
297
+ }
298
+ }
299
+
300
+ async function onOk(): Promise<void> {
301
+ if (!incomingDf) return;
302
+ const mode = labelToMode(modeInput.value);
303
+ const molCol = colChoiceValue(molColInput);
304
+ const vidCol = colChoiceValue(vidColInput);
305
+ const fi = fileInput.value;
306
+ const filePath = fi && !isLocalUploadFileInfo(fi) ? fi.fullPath : undefined;
307
+
308
+ const cfg: HitDesignMergeConfig = {
309
+ mode,
310
+ filePath,
311
+ molColName: molCol,
312
+ vidColName: mode === 'vid' ? vidCol : undefined,
313
+ addNewRows: !!addRowsInput.value && !!molCol,
314
+ runComputeOnNewRows: !!runComputeInput.value && !!addRowsInput.value && !!molCol,
315
+ clashStrategy: labelToClash(clashInput.value),
316
+ };
317
+
318
+ const pg = DG.TaskBarProgressIndicator.create('Merging table into campaign...');
319
+ try {
320
+ await mergeIntoCampaign(app, incomingDf, cfg);
321
+ if (app.campaign) {
322
+ app.campaign.mergeConfig = cfg;
323
+ await app.saveCampaign(false);
324
+ }
325
+ grok.shell.info('Table merged into campaign.');
326
+ } catch (e) {
327
+ _package.logger.error(e);
328
+ grok.shell.error('Merge failed. See console for details.');
329
+ } finally {
330
+ pg.close();
331
+ }
332
+ }
333
+
334
+ dialog.show();
335
+ // Initial state: nothing loaded yet, all dependent inputs disabled.
336
+ runValidation();
337
+
338
+ // If the campaign already has a remembered file path, try to recreate the FileInfo and
339
+ // walk through the same load → restore flow as a fresh user pick would.
340
+ if (saved?.filePath) {
341
+ try {
342
+ const exists = await grok.dapi.files.exists(saved.filePath);
343
+ if (!exists)
344
+ grok.shell.warning(`Saved merge file not found or not accessible: ${saved.filePath}`);
345
+ else {
346
+ const restoredFi = DG.FileInfo.fromString(saved.filePath, '');
347
+ suppressFileChange = true;
348
+ try {
349
+ fileInput.value = restoredFi;
350
+ } finally {
351
+ suppressFileChange = false;
352
+ }
353
+ await loadAndApplyFile(restoredFi, saved);
354
+ }
355
+ } catch (e) {
356
+ _package.logger.error(e);
357
+ grok.shell.warning('Could not restore previously saved merge file.');
358
+ }
359
+ }
360
+ }
@@ -14,7 +14,7 @@ export abstract class HitAppBase<T> {
14
14
  public template?: T;
15
15
  public baseUrl!: string;
16
16
  public computeFunctions: ComputeFunctions;
17
- protected isJoining = false;
17
+ public isJoining = false;
18
18
  protected hasEditPermission = false;
19
19
  private _appName: AppName;
20
20
  public get appName(): AppName {return this._appName;}
@@ -22,7 +22,9 @@ import {filter} from 'rxjs/operators';
22
22
  import {defaultPermissions, PermissionsDialog} from './dialogs/permissions-dialog';
23
23
  import {getDefaultCampaignStorageSettings, getDefaultSharingSettings} from '../packageSettingsEditor';
24
24
  import * as api from '../package-api';
25
- import {registerMol, registerMolsBatch} from './utils/molreg';
25
+ import {registerMol} from './utils/molreg';
26
+ import {mergeIntoCampaign} from './utils/merge-table';
27
+ import {openMergeTableDialog} from './dialogs/merge-table-dialog';
26
28
 
27
29
  export class HitDesignApp<T extends HitDesignTemplate = HitDesignTemplate> extends HitAppBase<T> {
28
30
  multiView: DG.MultiView;
@@ -58,7 +60,8 @@ export class HitDesignApp<T extends HitDesignTemplate = HitDesignTemplate> exten
58
60
  }
59
61
 
60
62
  /**
61
- * Correctly joins the incoming dataframe with the existing campaign dataframe
63
+ * Correctly joins the incoming dataframe with the existing campaign dataframe.
64
+ * Drag-n-drop entry point — uses SMILES-based join with the historical defaults.
62
65
  * @param df Dataframe to be joined into existing campaign dataframe
63
66
  */
64
67
  async handleJoiningDataframe(df: DG.DataFrame) {
@@ -89,49 +92,19 @@ export class HitDesignApp<T extends HitDesignTemplate = HitDesignTemplate> exten
89
92
  } else
90
93
  chosenMolColName = molCols[0]!.name!;
91
94
 
92
-
93
- const molCol = df.col(chosenMolColName);
94
- if (!molCol) { // should not happen, but oh well
95
+ if (!df.col(chosenMolColName)) {
95
96
  grok.shell.error('No molecule column found');
96
97
  return;
97
98
  }
98
99
 
99
- const compute = this.campaign?.template?.compute ?? this.template?.compute;
100
- if (!compute) {
101
- grok.shell.warning('No compute functions found');
102
- return;
103
- }
104
- const mols = molCol.toList();
105
- const descriptors = compute.descriptors.enabled ? compute.descriptors.args ?? [] : [];
106
- const calcDf = await calculateCellValues(mols, descriptors, compute.functions, compute.scripts, compute.queries);
107
- //merge into adding dataframe
108
- this.unionDataframes(calcDf, df, HitDesignMolColName, molCol.name);
109
-
110
- if (this.stages.length > 0 && this.dataFrame!.columns.contains(TileCategoriesColName)) {
111
- const newTilesCol = df.columns.getOrCreate(TileCategoriesColName, DG.TYPE.STRING);
112
- for (let i = 0; i < df.rowCount; i++) {
113
- if (newTilesCol.isNone(i))
114
- newTilesCol.set(i, this.stages[0], false);
115
- }
116
- }
117
-
118
- // handle the VID column for new table
119
- // joining data is not allowed to have the VID column, so remove it if it exists
120
- if (df.columns.contains(ViDColName))
121
- df.columns.remove(ViDColName);
122
-
123
- const vidCol = df.columns.addNewString(ViDColName);
124
- // batch register the molecules
125
- const registeredVids = await registerMolsBatch(mols, this._campaignId!, this.appName);
126
- for (let i = 0; i < df.rowCount; i++) {
127
- const mol = molCol.get(i);
128
- const vid = registeredVids.get(mol);
129
- if (vid)
130
- vidCol.set(i, vid);
131
- }
132
- //merge changes into existing dataframe
133
- this.unionDataframes(df, this.dataFrame!, molCol.name, this.molColName);
134
- this.saveCampaign(false);
100
+ await mergeIntoCampaign(this, df, {
101
+ mode: 'smiles',
102
+ molColName: chosenMolColName,
103
+ addNewRows: true,
104
+ runComputeOnNewRows: true,
105
+ clashStrategy: 'overwrite',
106
+ });
107
+ await this.saveCampaign(false);
135
108
  }
136
109
 
137
110
  public get submitParams() {
@@ -575,9 +548,11 @@ export class HitDesignApp<T extends HitDesignTemplate = HitDesignTemplate> exten
575
548
  };
576
549
 
577
550
  const calculateRibbon = ui.iconFA('wrench', getComputeDialog, 'Calculate additional properties');
551
+ const mergeTableButton = ui.iconFA('code-merge', () => {openMergeTableDialog(this);},
552
+ 'Merge another table into the campaign');
578
553
  const addNewRowButton = ui.icons.add(() => {this.dataFrame?.rows.addNew(null, true);}, 'Add new row');
579
554
  const applyLayoutButton = ui.iconSvg('view-layout', () => {this.applyTemplateLayout(view);}, `Apply template layout ${this.template?.localLayoutPath ? '(Loaded from mounted file storage)' : '(Static)'}`);
580
- this._refreshCampaignIcon = ui.icons.sync(async () => {this.refreshCampaign();});
555
+ this._refreshCampaignIcon = ui.icons.sync(async () => {this.refreshCampaign();}, 'Refresh');
581
556
  ui.tooltip.bind(this._refreshCampaignIcon, () => this._refreshIconTooltip);
582
557
  const permissionsButton = ui.iconFA('share', async () => {
583
558
  await (new PermissionsDialog(this.campaign?.permissions)).show((res) => {
@@ -647,6 +622,7 @@ export class HitDesignApp<T extends HitDesignTemplate = HitDesignTemplate> exten
647
622
  ribbonButtons.unshift(designerButton);
648
623
  }
649
624
  ribbonButtons.unshift(calculateRibbon);
625
+ ribbonButtons.unshift(mergeTableButton);
650
626
  ribbonButtons.unshift(addNewRowButton);
651
627
  ribbonButtons.unshift(this._refreshCampaignIcon);
652
628
 
@@ -1062,6 +1038,7 @@ export class HitDesignApp<T extends HitDesignTemplate = HitDesignTemplate> exten
1062
1038
  authorUserFriendlyName: authorName,
1063
1039
  lastModifiedUserName: grok.shell.user.friendlyName,
1064
1040
  permissions,
1041
+ mergeConfig: this.campaign?.mergeConfig,
1065
1042
  };
1066
1043
  if (!this.hasEditPermission) {
1067
1044
  grok.shell.error('You do not have permission to modify this campaign');
@@ -25,9 +25,14 @@ export class HitDesignInfoView
25
25
  <T extends HitDesignTemplate = HitDesignTemplate, K extends HitDesignApp = HitDesignApp>
26
26
  extends HitBaseView<T, K> {
27
27
  currentGroupping: string = 'None';
28
+ protected _appHeader: HTMLElement | null = null;
29
+ protected _contentRoot: HTMLElement = ui.div([], {classes: 'hit-triage-info-view-container'});
28
30
  constructor(app: K) {
29
31
  super(app);
30
32
  this.name = 'Hit Design';
33
+ this._appHeader = this.getAppHeader();
34
+ this.root.appendChild(ui.div([this._appHeader], {style: {marginLeft: '10px'}}));
35
+ this.root.appendChild(this._contentRoot);
31
36
  grok.shell.windows.showHelp = true;
32
37
  grok.shell.windows.help.showHelp(_package.webRoot + 'README_HD.md'); // TODO: Separate readme for Hit Design
33
38
  this.checkCampaign().then((c) => {this.app.campaign = c; this.init();});
@@ -76,7 +81,6 @@ export class HitDesignInfoView
76
81
  const continueCampaignsHeader = ui.h1(i18n.continueCampaigns);
77
82
 
78
83
  const createNewCampaignHeader = ui.h1(i18n.createNewCampaignHeader, {style: {marginLeft: '10px'}});
79
- const appHeader = this.getAppHeader();
80
84
 
81
85
  const campaignAccordionDiv = ui.div();
82
86
  const templatesDiv = ui.divH([]);
@@ -109,7 +113,7 @@ export class HitDesignInfoView
109
113
  });
110
114
 
111
115
  menu.show({element: sortingHeader, x: 120, y: sortingHeader.offsetTop + 30});
112
- });
116
+ }, 'Group by');
113
117
  groupIcon.style.marginBottom = '9px';
114
118
  groupIcon.style.marginLeft = '8px';
115
119
  groupIcon.style.fontSize = '15px';
@@ -152,7 +156,7 @@ export class HitDesignInfoView
152
156
 
153
157
  // then add the custom fields
154
158
  menu.show({element: sortingHeader, x: 100, y: sortingHeader.offsetTop + 30});
155
- });
159
+ }, 'View');
156
160
  ui.tooltip.bind(editColumnsIcon, 'Edit visible columns in campaigns table');
157
161
  editColumnsIcon.style.marginBottom = '9px';
158
162
  editColumnsIcon.style.marginLeft = '8px';
@@ -161,19 +165,17 @@ export class HitDesignInfoView
161
165
 
162
166
  const refreshIcon = ui.iconFA('sync', async () => {
163
167
  await this.refreshCampaignsTable();
164
- });
168
+ }, 'Refresh');
165
169
  refreshIcon.style.marginBottom = '9px';
166
170
  refreshIcon.style.marginLeft = '8px';
167
171
  refreshIcon.style.color = 'var(--blue-1)';
168
172
  ui.tooltip.bind(refreshIcon, () => 'Refresh campaigns table');
169
173
  const sortingHeader = ui.divH([continueCampaignsHeader, editColumnsIcon, groupIcon, refreshIcon], {style: {alignItems: 'center'}});
170
- $(this.root).empty();
171
- this.root.appendChild(ui.div([
172
- ui.divV([appHeader, sortingHeader], {style: {marginLeft: '10px'}}),
173
- this.campaignsTableRoot,
174
- createNewCampaignHeader,
175
- contentDiv,
176
- ], {classes: 'hit-triage-info-view-container'}));
174
+ $(this._contentRoot).empty();
175
+ this._contentRoot.appendChild(ui.divV([sortingHeader], {style: {marginLeft: '10px'}}));
176
+ this._contentRoot.appendChild(this.campaignsTableRoot);
177
+ this._contentRoot.appendChild(createNewCampaignHeader);
178
+ this._contentRoot.appendChild(contentDiv);
177
179
  await this.startNewCampaign(campaignAccordionDiv, templatesDiv, presetTemplate);
178
180
  } finally {
179
181
  ui.setUpdateIndicator(this.root, false);
@@ -26,9 +26,14 @@ export class InfoView extends HitBaseView<HitTriageTemplate, HitTriageApp> {
26
26
  public readmePath = _package.webRoot + 'README_HT.md';
27
27
  private dataSourceFunctionsMap: {[key: string]: DG.Func | DG.DataQuery} = {};
28
28
  currentGroupping: string = 'None';
29
+ protected _appHeader: HTMLElement | null = null;
30
+ protected _contentRoot: HTMLElement = ui.div([], {classes: 'hit-triage-info-view-container'});
29
31
  constructor(app: HitTriageApp) {
30
32
  super(app);
31
33
  this.name = 'Hit Triage';
34
+ this._appHeader = this.getAppHeader();
35
+ this.root.appendChild(ui.div([this._appHeader], {style: {marginLeft: '10px'}}));
36
+ this.root.appendChild(this._contentRoot);
32
37
  grok.shell.windows.showHelp = true;
33
38
  grok.shell.windows.help.showHelp(this.readmePath);
34
39
  this.checkCampaign().then((c) => {this.app.campaign = c; this.init();});
@@ -87,7 +92,6 @@ export class InfoView extends HitBaseView<HitTriageTemplate, HitTriageApp> {
87
92
  try {
88
93
  const continueCampaignsHeader = ui.h1(i18n.continueCampaigns);
89
94
  const createNewCampaignHeader = ui.h1(i18n.createNewCampaignHeader, {style: {marginLeft: '10px'}});
90
- const appHeader = this.getAppHeader();
91
95
 
92
96
  const campaignAccordionDiv = ui.div();
93
97
  const templatesDiv = ui.div([], {classes: 'ui-form'});
@@ -119,7 +123,7 @@ export class InfoView extends HitBaseView<HitTriageTemplate, HitTriageApp> {
119
123
  });
120
124
 
121
125
  menu.show({element: sortingHeader, x: 120, y: sortingHeader.offsetTop + 30});
122
- });
126
+ }, 'Group by');
123
127
  groupIcon.style.marginBottom = '9px';
124
128
  groupIcon.style.marginLeft = '8px';
125
129
  groupIcon.style.fontSize = '15px';
@@ -161,7 +165,7 @@ export class InfoView extends HitBaseView<HitTriageTemplate, HitTriageApp> {
161
165
  });
162
166
 
163
167
  menu.show({element: sortingHeader, x: 100, y: sortingHeader.offsetTop + 30});
164
- });
168
+ }, 'View');
165
169
  ui.tooltip.bind(editColumnsIcon, 'Edit visible columns in campaigns table');
166
170
  editColumnsIcon.style.marginBottom = '9px';
167
171
  editColumnsIcon.style.marginLeft = '8px';
@@ -170,7 +174,7 @@ export class InfoView extends HitBaseView<HitTriageTemplate, HitTriageApp> {
170
174
 
171
175
  const refreshIcon = ui.iconFA('sync', async () => {
172
176
  await this.refreshCampaignsTable();
173
- });
177
+ }, 'Refresh');
174
178
  refreshIcon.style.marginBottom = '9px';
175
179
  refreshIcon.style.marginLeft = '8px';
176
180
  refreshIcon.style.color = 'var(--blue-1)';
@@ -178,14 +182,12 @@ export class InfoView extends HitBaseView<HitTriageTemplate, HitTriageApp> {
178
182
  const sortingHeader = ui.divH([continueCampaignsHeader, editColumnsIcon, groupIcon, refreshIcon], {style: {alignItems: 'center'}});
179
183
 
180
184
  await this.startNewCampaign(campaignAccordionDiv, templatesDiv, presetTemplate);
181
- $(this.root).empty();
182
- this.root.appendChild(ui.div([
183
- ui.divV([appHeader, sortingHeader], {style: {marginLeft: '10px'}}),
184
- this.campaignsTableRoot,
185
- createNewCampaignHeader,
186
- templatesDiv,
187
- campaignAccordionDiv,
188
- ], {classes: 'hit-triage-info-view-container'}));
185
+ $(this._contentRoot).empty();
186
+ this._contentRoot.appendChild(ui.divV([sortingHeader], {style: {marginLeft: '10px'}}));
187
+ this._contentRoot.appendChild(this.campaignsTableRoot);
188
+ this._contentRoot.appendChild(createNewCampaignHeader);
189
+ this._contentRoot.appendChild(templatesDiv);
190
+ this._contentRoot.appendChild(campaignAccordionDiv);
189
191
  } catch (e) {
190
192
  ui.setUpdateIndicator(this.root, false);
191
193
  throw e;
package/src/app/types.ts CHANGED
@@ -102,7 +102,26 @@ export type INewTemplateResult<T> = {
102
102
  export type HitDesignTemplate = Omit<HitTriageTemplate, 'dataSourceType' | 'queryFunctionName'> &
103
103
  {stages: string[]};
104
104
 
105
- export type HitDesignCampaign = Omit<HitTriageCampaign, 'filters' | 'ingest'> & {tilesViewerFormSketch?: string};
105
+ export type HitDesignMergeMode = 'smiles' | 'vid';
106
+ export type HitDesignMergeClashStrategy = 'skip' | 'overwrite';
107
+
108
+ export type HitDesignMergeConfig = {
109
+ mode: HitDesignMergeMode,
110
+ // Only set when the source file lives on the Datagrok file share, so it can be reopened later
111
+ filePath?: string,
112
+ // Incoming column name to use as molecule source (required for SMILES mode, optional for VID mode)
113
+ molColName?: string,
114
+ // Incoming column name carrying V-iD values (only used in VID mode)
115
+ vidColName?: string,
116
+ addNewRows: boolean,
117
+ runComputeOnNewRows: boolean,
118
+ clashStrategy: HitDesignMergeClashStrategy,
119
+ }
120
+
121
+ export type HitDesignCampaign = Omit<HitTriageCampaign, 'filters' | 'ingest'> & {
122
+ tilesViewerFormSketch?: string,
123
+ mergeConfig?: HitDesignMergeConfig,
124
+ };
106
125
 
107
126
  // todo: probably add some more stuff
108
127
  export type PeptiHitTemplate = HitDesignTemplate & {toAtomiLevelProps?: {[key: string]: any}}