@datagrok/hit-triage 1.10.8 → 1.11.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 (129) hide show
  1. package/.grokignore +2 -0
  2. package/.turbo/turbo-build.log +24 -6
  3. package/.vscode/settings.json +16 -0
  4. package/CHANGELOG.md +80 -1
  5. package/CLAUDE.md +87 -10
  6. package/README_HD.md +14 -14
  7. package/README_HT.md +6 -6
  8. package/README_PH.md +110 -0
  9. package/bdd/bdd.config.json +3 -0
  10. package/bdd/bindings/campaign.ts +626 -0
  11. package/bdd/bindings/hit-design.ts +93 -0
  12. package/bdd/bindings/landing.ts +839 -0
  13. package/bdd/bindings/pepti-hit.ts +35 -0
  14. package/bdd/features/campaign/crumbs.feature +22 -0
  15. package/bdd/features/campaign/grid.feature +56 -0
  16. package/bdd/features/campaign/merge.feature +105 -0
  17. package/bdd/features/campaign/molecule-vid.feature +40 -0
  18. package/bdd/features/campaign/permissions.feature +46 -0
  19. package/bdd/features/campaign/progress-tracker.feature +89 -0
  20. package/bdd/features/campaign/refresh-hint.feature +33 -0
  21. package/bdd/features/campaign/ribbon.feature +49 -0
  22. package/bdd/features/campaign/stage-choices.feature +39 -0
  23. package/bdd/features/campaign/submit.feature +135 -0
  24. package/bdd/features/campaign/tracker-cards.feature +46 -0
  25. package/bdd/features/campaign/view-only.feature +37 -0
  26. package/bdd/features/hit-design/campaign-column-metadata.feature +61 -0
  27. package/bdd/features/landing/campaign-deep-links.feature +61 -0
  28. package/bdd/features/landing/hit-design-campaigns-fixes.feature +116 -0
  29. package/bdd/features/landing/hit-design-campaigns.feature +153 -0
  30. package/bdd/features/landing/hit-triage-campaigns.feature +99 -0
  31. package/bdd/features/landing/new-campaign.feature +69 -0
  32. package/bdd/features/landing/pep-triage-campaigns.feature +41 -0
  33. package/bdd/features/landing/pepti-hit-landing.feature +132 -0
  34. package/bdd/features/pepti-hit/helm-edit.feature +47 -0
  35. package/bdd/features/templates/template-editor.feature +130 -0
  36. package/bdd/features/templates/template-picker.feature +112 -0
  37. package/bdd/features/templates/triage-forms.feature +59 -0
  38. package/bdd/fixtures/bar-chart.layout +1 -0
  39. package/bdd/fixtures/merge-local.csv +2 -0
  40. package/bdd/generated/campaign/crumbs.test.ts +33 -0
  41. package/bdd/generated/campaign/grid.test.ts +79 -0
  42. package/bdd/generated/campaign/merge.test.ts +134 -0
  43. package/bdd/generated/campaign/molecule-vid.test.ts +52 -0
  44. package/bdd/generated/campaign/permissions.test.ts +58 -0
  45. package/bdd/generated/campaign/progress-tracker.test.ts +129 -0
  46. package/bdd/generated/campaign/refresh-hint.test.ts +44 -0
  47. package/bdd/generated/campaign/ribbon.test.ts +65 -0
  48. package/bdd/generated/campaign/stage-choices.test.ts +55 -0
  49. package/bdd/generated/campaign/submit.test.ts +167 -0
  50. package/bdd/generated/campaign/tracker-cards.test.ts +49 -0
  51. package/bdd/generated/campaign/view-only.test.ts +51 -0
  52. package/bdd/generated/hit-design/campaign-column-metadata.test.ts +76 -0
  53. package/bdd/generated/landing/campaign-deep-links.test.ts +68 -0
  54. package/bdd/generated/landing/hit-design-campaigns-fixes.test.ts +99 -0
  55. package/bdd/generated/landing/hit-design-campaigns.test.ts +160 -0
  56. package/bdd/generated/landing/hit-triage-campaigns.test.ts +107 -0
  57. package/bdd/generated/landing/new-campaign.test.ts +78 -0
  58. package/bdd/generated/landing/pep-triage-campaigns.test.ts +52 -0
  59. package/bdd/generated/landing/pepti-hit-landing.test.ts +130 -0
  60. package/bdd/generated/pepti-hit/helm-edit.test.ts +64 -0
  61. package/bdd/generated/templates/template-editor.test.ts +137 -0
  62. package/bdd/generated/templates/template-picker.test.ts +119 -0
  63. package/bdd/generated/templates/triage-forms.test.ts +68 -0
  64. package/bdd/package.json +1 -0
  65. package/bdd/tsconfig.json +13 -0
  66. package/css/hit-triage.css +27 -23
  67. package/dist/package-test.js +690 -4
  68. package/dist/package-test.js.map +1 -1
  69. package/dist/package.js +318 -73
  70. package/dist/package.js.map +1 -1
  71. package/package.json +15 -8
  72. package/queries/locks.sql +37 -0
  73. package/src/app/accordeons/layout-input.ts +52 -44
  74. package/src/app/accordeons/new-campaign-accordeon.ts +91 -54
  75. package/src/app/accordeons/new-hit-design-campaign-accordeon.ts +3 -67
  76. package/src/app/accordeons/new-pep-triage-template-accordeon.ts +39 -41
  77. package/src/app/accordeons/new-template-accordeon.ts +41 -24
  78. package/src/app/ai/view-functions.ts +22 -19
  79. package/src/app/base-view.ts +99 -8
  80. package/src/app/consts.ts +8 -5
  81. package/src/app/dialogs/functions-dialog.ts +14 -9
  82. package/src/app/dialogs/merge-table-dialog.ts +181 -325
  83. package/src/app/hit-app-base.ts +61 -90
  84. package/src/app/hit-design-app.ts +492 -882
  85. package/src/app/hit-design-views/info-view.ts +57 -407
  86. package/src/app/hit-design-views/submit-view.ts +216 -111
  87. package/src/app/hit-design-views/tiles-view.ts +168 -123
  88. package/src/app/hit-design-views/utils.css +0 -8
  89. package/src/app/hit-triage-app.ts +69 -38
  90. package/src/app/hit-triage-views/info-view.ts +70 -371
  91. package/src/app/pep-triage-app.ts +2 -2
  92. package/src/app/pep-triage-views/info-view.ts +42 -83
  93. package/src/app/pepti-hit-app.ts +32 -183
  94. package/src/app/pepti-hits-views/info-view.ts +15 -37
  95. package/src/app/shared/campaign-catalog.ts +408 -0
  96. package/src/app/shared/campaign-session.ts +557 -0
  97. package/src/app/shared/compute-editor.ts +274 -0
  98. package/src/app/shared/hit-home.ts +45 -0
  99. package/src/app/shared/new-campaign-form.ts +90 -0
  100. package/src/app/shared/permissions-editor.ts +93 -0
  101. package/src/app/shared/template-editor.ts +331 -0
  102. package/src/app/shared/template-picker.ts +154 -0
  103. package/src/app/types.ts +2 -0
  104. package/src/app/utils/merge-table.ts +183 -78
  105. package/src/app/utils.ts +34 -325
  106. package/src/package-api.ts +29 -8
  107. package/src/package-test.ts +17 -2
  108. package/src/package.g.ts +12 -8
  109. package/src/package.ts +19 -7
  110. package/src/tests/ai.ts +244 -0
  111. package/src/tests/campaign-layout.ts +82 -0
  112. package/src/tests/campaign-session.ts +168 -0
  113. package/src/tests/campaigns.ts +23 -0
  114. package/src/tests/catalog.ts +156 -0
  115. package/src/tests/compat.ts +482 -0
  116. package/src/tests/compute.ts +165 -0
  117. package/src/tests/fixtures.ts +359 -0
  118. package/src/tests/merge.ts +149 -0
  119. package/src/tests/owners.ts +11 -0
  120. package/src/tests/save-lock.ts +932 -0
  121. package/src/tests/storage.ts +106 -0
  122. package/src/tests/template-editor.ts +538 -0
  123. package/src/tests/templates.ts +143 -0
  124. package/src/tests/triage-start.ts +81 -0
  125. package/src/tests/u2-guards.ts +384 -0
  126. package/src/tests/vid.ts +77 -0
  127. package/tsconfig.json +3 -0
  128. package/src/app/accordeons/new-hit-design-template-accordeon.ts +0 -238
  129. package/src/app/dialogs/permissions-dialog.ts +0 -66
@@ -1,135 +1,240 @@
1
- /* eslint-disable max-len */
2
- import * as ui from 'datagrok-api/ui';
1
+ /* The Submit dialog of a Hit Design / PeptiHit campaign: what the campaign is (read-only rows, its name and folder
2
+ editable in place), its status with the statuses other campaigns have, and the function it is submitted to. SAVE
3
+ stores the status; SUBMIT runs the function on the campaign's rows, then saves. A campaign the user may only view
4
+ offers neither, saying why. */
3
5
  import * as grok from 'datagrok-api/grok';
4
6
  import * as DG from 'datagrok-api/dg';
5
- import {HitDesignApp} from '../hit-design-app';
6
- import {_package} from '../../package';
7
- import {HitDesignTemplate} from '../types';
8
- import {HitBaseView} from '../base-view';
9
- import {HitTriageSubmitTag} from '../consts';
10
- import {getFuncPackageNameSafe} from '../utils';
7
+ import {ChoiceInput, Dialog, DynamicInput, Form, Input, LabelColumn, SuggestInput, TextInput, computed, div,
8
+ iconButton, signal} from '@datagrok-libraries/u2';
9
+ import {ViewHost} from '@datagrok-libraries/u2/dg';
10
+ import type {HitDesignApp} from '../hit-design-app';
11
+ import {CampaignTableName, HitTriageSubmitTag, i18n} from '../consts';
12
+ import {checkFileExists, getFuncPackageNameSafe} from '../utils';
13
+ import {fieldText} from '../shared/campaign-catalog';
11
14
 
12
- export class HitDesignSubmitView extends HitBaseView<HitDesignTemplate, HitDesignApp> {
13
- private statusInput: DG.InputBase<string | undefined>;
14
- private statusSuggestionsMenu: DG.Menu;
15
- content: HTMLDivElement;
16
- constructor(app: HitDesignApp) {
17
- super(app);
18
- this.name = 'Submit';
19
- this.statusInput = ui.input.string('Status', {value: this.app.campaign?.status, nullable: false});
20
- this.statusSuggestionsMenu = DG.Menu.popup();
21
- this.statusInput.root.style.marginLeft = '12px';
22
- this.content = ui.div();
15
+ const VIEW_ONLY = 'You can view this campaign but not change it';
16
+ const NOT_SAVED = 'The campaign was not saved';
23
17
 
24
- this.statusInput.onChanged.subscribe(() => {
25
- this.statusSuggestionsMenu.clear();
26
- const status = (this.statusInput.value ?? '').toLowerCase();
27
- // eslint-disable-next-line max-len
28
- const similarStatuses = this.app.existingStatuses.filter((s) => s?.toLowerCase()?.includes(status) && s?.toLowerCase() !== status).filter((_, i) => i < 5);
29
- if (similarStatuses.length) {
30
- similarStatuses.forEach((s) => {
31
- this.statusSuggestionsMenu.item(s, () => {
32
- this.statusInput.value = s;
33
- this.statusSuggestionsMenu.root.remove();
34
- this.statusInput.root.focus();
35
- });
36
- });
37
- if (this.content.parentElement?.parentElement) {
38
- const xOffset = this.statusInput.root.offsetLeft + (this.statusInput.input?.offsetLeft ?? 0);
39
- const yOffset = this.statusInput.root.offsetTop + this.statusInput.root.offsetHeight + this.content.parentElement.offsetTop;
40
- this.statusSuggestionsMenu.show({element: this.content.parentElement.parentElement!, x: xOffset, y: yOffset});
41
- }
42
- } else
43
- this.statusSuggestionsMenu.root.remove();
44
- });
45
- }
18
+ export class HitDesignSubmitView {
19
+ constructor(private readonly app: HitDesignApp) {}
46
20
 
47
- public getStatus() {
48
- return this.statusInput.value ?? this.app.campaign?.status ?? 'No Status';
21
+ /** The functions a campaign can be submitted to, by friendly name. */
22
+ private static submitFunctions(): Map<string, DG.Func> {
23
+ const funcs = new Set([...DG.Func.find({meta: {role: HitTriageSubmitTag}}),
24
+ ...DG.Func.find({tags: [HitTriageSubmitTag]})]);
25
+ return new Map([...funcs].map((f) => [f.friendlyName ?? f.name, f]));
49
26
  }
50
27
 
51
- /** Programmatic submit (used by the AI view functions): seeds the status the same
52
- * way the dialog does, then runs the regular submit flow. */
53
- public async submitWithStatus(status?: string): Promise<boolean> {
54
- this.statusInput.value = status?.trim() ? status.trim() : (this.app.campaign?.status ?? 'Submitted');
55
- return await this.submit();
56
- }
57
-
58
- render() {
59
- this.statusInput.value = this.app.campaign?.status ?? '';
60
- ui.empty(this.content);
61
-
62
- this.content = ui.divV([
63
- ui.h1('Summary'),
64
- ui.div([ui.tableFromMap(this.app.getSummary())]),
65
- this.statusInput.root,
66
- ]);
28
+ render(): void {
29
+ const app = this.app;
30
+ const campaign = app.campaign;
31
+ const canEdit = app.canEdit;
32
+ const functions = HitDesignSubmitView.submitFunctions();
33
+ const preset = app.submitParams;
34
+ const presetName = [...functions].find(([, f]) => f.name === preset?.fName &&
35
+ getFuncPackageNameSafe(f) === preset?.package)?.[0] ?? null;
36
+ const dialog = new Dialog('Submit', {name: 'submit'});
37
+ dialog.build(() => {
38
+ const column = new LabelColumn();
39
+ const summary = new Form({quiet: true, labelColumn: column});
40
+ for (const input of this.summaryRows())
41
+ summary.add(input);
42
+ const inputs = new Form({labelColumn: column});
43
+ const status = new SuggestInput({label: 'Status', name: 'status', value: campaign?.status ?? '',
44
+ readOnly: !canEdit, minChars: 1, source: async (query) => {
45
+ const q = query.toLowerCase();
46
+ return app.existingStatuses.filter((s) => s?.toLowerCase().includes(q) && s.toLowerCase() !== q).slice(0, 5);
47
+ }});
48
+ const func = new ChoiceInput({label: 'Submit function', name: 'submit-function', items: [...functions.keys()],
49
+ value: presetName, nullable: true, readOnly: !canEdit});
50
+ inputs.add(status);
51
+ inputs.add(func);
52
+ dialog.add(div([summary.root, inputs.root]));
67
53
 
68
-
69
- const dlg = ui.dialog('Submit');
70
- dlg.add(this.content);
71
- dlg.addButton('Save', () => {
72
- this.app.campaign!.status = this.getStatus();
73
- this.app.saveCampaign();
74
- dlg.close();
54
+ const statusToSave = () => status.peek()?.trim() || campaign?.status || 'No Status';
55
+ /** The chosen submit function into the campaign's template; answers the undo. */
56
+ const keepSubmitFunction = () => {
57
+ const template = app.campaign?.template;
58
+ const before = template?.submit;
59
+ const f = functions.get(func.peek() ?? '');
60
+ if (template)
61
+ template.submit = f ? {fName: f.name, package: getFuncPackageNameSafe(f)} : undefined;
62
+ return () => template && (template.submit = before);
63
+ };
64
+ const chosen = computed(() => functions.get(func.value ?? ''));
65
+ dialog.addButton('Save', async () => {
66
+ const saving = app.campaign;
67
+ if (!saving)
68
+ return;
69
+ const undo = keepSubmitFunction();
70
+ const before = saving.status;
71
+ saving.status = statusToSave();
72
+ if (await app.saveCampaign() !== undefined)
73
+ dialog.close();
74
+ else {
75
+ saving.status = before;
76
+ undo();
77
+ }
78
+ }, {disabled: canEdit ? null : VIEW_ONLY});
79
+ dialog.onOK(async () => {
80
+ const undo = keepSubmitFunction();
81
+ let submitted = false;
82
+ try {
83
+ submitted = await this.submit(statusToSave());
84
+ } finally {
85
+ // a submit function that threw leaves the template as it was; the dialog shows the error
86
+ if (!submitted)
87
+ undo();
88
+ }
89
+ return submitted;
90
+ }, {text: 'Submit', primary: true});
91
+ dialog.okDisabled(computed(() => !canEdit ? VIEW_ONLY :
92
+ chosen.value === undefined ? 'Choose a submit function' : null));
93
+ dialog.status(computed(() => chosen.value === undefined ? null :
94
+ `Submits ${app.dataFrame?.filter.trueCount ?? 0} molecules to ${chosen.value.friendlyName}`));
75
95
  });
76
- //dlg.addButton('Submit', ()=>{this.submit(); dlg.close();}, undefined, 'Submit the campaign file to the specified function');
77
- dlg.show();
78
-
79
- const submitFunctions = Array.from(new Set(DG.Func.find({meta: {role: HitTriageSubmitTag}}).concat(DG.Func.find({tags: [HitTriageSubmitTag]}))));
80
- const submitFunctionMap = submitFunctions.reduce((acc, fn) => {
81
- acc[fn.friendlyName ?? fn.name] = fn;
82
- return acc;
83
- }, {} as Record<string, DG.Func>);
84
- if (submitFunctions.length > 0) {
85
- const chosenFunctionParams = this.app.submitParams;
86
- const foundFunction = chosenFunctionParams ? submitFunctions.find((fn) => fn.name === chosenFunctionParams.fName && getFuncPackageNameSafe(fn) == chosenFunctionParams.package) : undefined;
87
- const foundFunctionKey = foundFunction?.friendlyName ?? foundFunction?.name;
88
- const submitFunctionInput = ui.input.choice('Submit function', {
89
- value: foundFunctionKey,
90
- items: [...Object.keys(submitFunctionMap)],
91
- nullable: true,
92
- });
96
+ ViewHost.of(app.designView!).show(dialog, {width: 640});
97
+ }
93
98
 
94
- submitFunctionInput.onChanged.subscribe(() => {
95
- const selectedFunction = submitFunctionMap[submitFunctionInput.value ?? ''];
96
- this.app.campaign!.template!.submit = selectedFunction ? {
97
- fName: selectedFunction.name,
98
- package: getFuncPackageNameSafe(selectedFunction),
99
- } : undefined;
100
- dlg.getButton('Submit')?.remove();
101
- if (selectedFunction) {
102
- dlg.addButton('Submit', () => {
103
- this.submit();
104
- dlg.close();
105
- }, undefined, 'Submit the campaign file to the specified function');
106
- }
99
+ /** The summary rows: what the campaign is, its fields, its size and compute, its name and folder editable. */
100
+ private summaryRows(): Input<any>[] {
101
+ const app = this.app;
102
+ const campaign = app.campaign;
103
+ const template = app.template;
104
+ const code = app.campaignId ?? campaign?.name ?? '';
105
+ const text = (label: string, value: unknown) => new TextInput({label, value: String(value ?? ''), readOnly: true});
106
+ const name = this.editable(text('Name', campaign?.friendlyName ?? campaign?.name ?? code), 'Edit Campaign Name',
107
+ async (value) => {
108
+ if (!value.trim())
109
+ return 'Campaign name can not be empty';
110
+ const saving = app.campaign!;
111
+ const before = saving.friendlyName;
112
+ saving.friendlyName = value;
113
+ if (await app.saveCampaign(true) !== undefined)
114
+ return null;
115
+ saving.friendlyName = before;
116
+ return NOT_SAVED;
107
117
  });
108
- submitFunctionInput.fireChanged();
109
- this.content.appendChild(submitFunctionInput.root);
118
+ const path = this.editable(text('File Path', app.campaignFolder), 'Edit file path', async (value) => {
119
+ if (!await checkFileExists(value))
120
+ return 'Given folder does not exist';
121
+ const before = app.filePath;
122
+ app.filePath = `${value.replace(/\/$/, '')}/${code}/${CampaignTableName}`;
123
+ if (app.campaign)
124
+ app.campaign.savePath = app.filePath;
125
+ if (await app.saveCampaign(true) !== undefined)
126
+ return null;
127
+ app.filePath = before;
128
+ if (app.campaign)
129
+ app.campaign.savePath = before;
130
+ return NOT_SAVED;
131
+ });
132
+ path.addOptions(iconButton('arrow-to-bottom', () => app.download(app.dataFrame!, code || 'Molecules'),
133
+ {tooltip: i18n.download}));
134
+ const rows: Input<any>[] = [name, text('Code', code), text('Template', template?.name ?? 'Molecules'), path];
135
+ if (campaign?.authorUserFriendlyName)
136
+ rows.push(text('Author', campaign.authorUserFriendlyName));
137
+ if (campaign?.lastModifiedUserName)
138
+ rows.push(text('Last Modified By', campaign.lastModifiedUserName));
139
+ if (campaign?.createDate)
140
+ rows.push(text('Create Date', campaign.createDate));
141
+ for (const [key, value] of Object.entries(campaign?.campaignFields ?? app.campaignProps)) {
142
+ const field = template?.campaignFields?.find((f) => f.name === key);
143
+ if (field?.type === 'Molecule' && value) {
144
+ rows.push(new DynamicInput<string>({label: key, value,
145
+ render: (smiles) => smiles ? grok.chem.drawMolecule(smiles, 160, 100) : null}));
146
+ }
147
+ else
148
+ rows.push(text(key, field?.type === 'Date' ? fieldText(value) : value));
110
149
  }
150
+ rows.push(text('Number of Molecules', app.dataFrame?.rowCount ?? 0));
151
+ const compute = template?.compute;
152
+ const friendly = (f: {package: string, name: string}) =>
153
+ DG.Func.find({package: f.package, name: f.name})[0]?.friendlyName ?? f.name;
154
+ const methods = [compute?.descriptors.enabled ? 'Descriptors' : '', ...(compute?.functions ?? []).map(friendly)];
155
+ rows.push(text('Enrichment Methods', methods.filter((m) => m.trim() !== '').join(', ')));
156
+ return rows;
157
+ }
158
+
159
+ /** A read-only row with a pencil: it turns into an input with save and cancel (Enter and Escape alike); a save
160
+ * that answers a problem keeps the input open, the problem under it. */
161
+ private editable(input: TextInput, tooltip: string, save: (value: string) => Promise<string | null>): TextInput {
162
+ const saved = signal(input.peek());
163
+ const editing = signal(false);
164
+ const problem = signal<{value: string, message: string} | null>(null);
165
+ input.addValidator((value) => problem.value?.value === value ? problem.value.message : null);
166
+ const done = (value: string) => {
167
+ saved.value = value;
168
+ problem.value = null;
169
+ input.reset(value);
170
+ editing.value = false;
171
+ };
172
+ const accept = async () => {
173
+ const value = input.peek() ?? '';
174
+ const error = await save(value);
175
+ if (error === null)
176
+ done(value);
177
+ else {
178
+ problem.value = {value, message: error};
179
+ input.touch();
180
+ }
181
+ };
182
+ const cancel = () => done(saved.peek() ?? '');
183
+ const pencil = iconButton('pencil', () => {
184
+ editing.value = true;
185
+ input.focus();
186
+ }, {tooltip});
187
+ const acceptButton = iconButton('check', accept, {tooltip: 'Save'});
188
+ const cancelButton = iconButton('times', cancel, {tooltip: 'Cancel'});
189
+ for (const option of [pencil, acceptButton, cancelButton])
190
+ input.addOptions(option);
191
+ // while editing, Enter and Escape are the row's: the dialog would submit or close
192
+ input.scope.listen(input.root, 'keydown', (e) => {
193
+ const key = (e as KeyboardEvent).key;
194
+ if (!editing.peek() || key !== 'Enter' && key !== 'Escape')
195
+ return;
196
+ e.preventDefault();
197
+ e.stopPropagation();
198
+ void (key === 'Enter' ? accept() : cancel());
199
+ });
200
+ input.effect(() => {
201
+ const on = editing.value;
202
+ input.readOnly = !on;
203
+ pencil.hidden = on;
204
+ acceptButton.hidden = !on;
205
+ cancelButton.hidden = !on;
206
+ });
207
+ return input;
111
208
  }
112
209
 
113
- onActivated(): void {
210
+ /** The AI's submit: the status given, else the campaign's, else "Submitted". */
211
+ async submitWithStatus(status?: string): Promise<boolean> {
212
+ return await this.submit(status?.trim() || this.app.campaign?.status || 'Submitted');
114
213
  }
115
214
 
116
- /** Resolves to whether the submit function ran and the campaign was saved. */
117
- async submit(): Promise<boolean> {
118
- const submitParams= this.app.submitParams;
119
- if (!submitParams) {
215
+ /** Runs the campaign's submit function on its rows (the filtered ones), then saves the campaign with `status`.
216
+ * Answers whether both happened. */
217
+ async submit(status: string = this.app.campaign?.status ?? 'No Status'): Promise<boolean> {
218
+ const app = this.app;
219
+ const params = app.submitParams;
220
+ if (!params) {
120
221
  grok.shell.error('No submit function selected. Please select a function to submit the campaign.');
121
222
  return false;
122
223
  }
123
-
124
- const submitFn = DG.Func.find({name: submitParams.fName, package: submitParams.package})[0];
125
- if (!submitFn) {
126
- grok.shell.error(`Function ${submitParams.fName} not found.`);
224
+ const fn = DG.Func.find({name: params.fName, package: params.package})[0];
225
+ if (!fn) {
226
+ grok.shell.error(`Function ${params.fName} not found.`);
227
+ return false;
228
+ }
229
+ const filtered = DG.DataFrame.fromCsv(app.dataFrame!.toCsv({filteredRowsOnly: true}));
230
+ await fn.apply({df: filtered, molecules: app.molColName});
231
+ const campaign = app.campaign!;
232
+ const before = campaign.status;
233
+ campaign.status = status;
234
+ if (await app.saveCampaign() === undefined) {
235
+ campaign.status = before;
127
236
  return false;
128
237
  }
129
- const filteredDf = DG.DataFrame.fromCsv(this.app.dataFrame!.toCsv({filteredRowsOnly: true}));
130
- await submitFn.apply({df: filteredDf, molecules: this.app.molColName});
131
- this.app.campaign!.status = this.getStatus();
132
- await this.app.saveCampaign();
133
238
  grok.shell.info('Submitted successfully.');
134
239
  return true;
135
240
  }