@datagrok/hit-triage 1.10.9 → 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.
- package/.grokignore +2 -0
- package/.turbo/turbo-build.log +25 -3
- package/CHANGELOG.md +78 -0
- package/CLAUDE.md +87 -10
- package/README_HD.md +14 -14
- package/README_HT.md +6 -6
- package/README_PH.md +110 -0
- package/bdd/bdd.config.json +3 -1
- package/bdd/bindings/campaign.ts +626 -0
- package/bdd/bindings/hit-design.ts +36 -42
- package/bdd/bindings/landing.ts +839 -0
- package/bdd/bindings/pepti-hit.ts +35 -0
- package/bdd/features/campaign/crumbs.feature +22 -0
- package/bdd/features/campaign/grid.feature +56 -0
- package/bdd/features/campaign/merge.feature +105 -0
- package/bdd/features/campaign/molecule-vid.feature +40 -0
- package/bdd/features/campaign/permissions.feature +46 -0
- package/bdd/features/campaign/progress-tracker.feature +89 -0
- package/bdd/features/campaign/refresh-hint.feature +33 -0
- package/bdd/features/campaign/ribbon.feature +49 -0
- package/bdd/features/campaign/stage-choices.feature +39 -0
- package/bdd/features/campaign/submit.feature +135 -0
- package/bdd/features/campaign/tracker-cards.feature +46 -0
- package/bdd/features/campaign/view-only.feature +37 -0
- package/bdd/features/landing/campaign-deep-links.feature +61 -0
- package/bdd/features/landing/hit-design-campaigns-fixes.feature +116 -0
- package/bdd/features/landing/hit-design-campaigns.feature +153 -0
- package/bdd/features/landing/hit-triage-campaigns.feature +99 -0
- package/bdd/features/landing/new-campaign.feature +69 -0
- package/bdd/features/landing/pep-triage-campaigns.feature +41 -0
- package/bdd/features/landing/pepti-hit-landing.feature +132 -0
- package/bdd/features/pepti-hit/helm-edit.feature +47 -0
- package/bdd/features/templates/template-editor.feature +130 -0
- package/bdd/features/templates/template-picker.feature +112 -0
- package/bdd/features/templates/triage-forms.feature +59 -0
- package/bdd/fixtures/bar-chart.layout +1 -0
- package/bdd/fixtures/merge-local.csv +2 -0
- package/bdd/generated/campaign/crumbs.test.ts +33 -0
- package/bdd/generated/campaign/grid.test.ts +79 -0
- package/bdd/generated/campaign/merge.test.ts +134 -0
- package/bdd/generated/campaign/molecule-vid.test.ts +52 -0
- package/bdd/generated/campaign/permissions.test.ts +58 -0
- package/bdd/generated/campaign/progress-tracker.test.ts +129 -0
- package/bdd/generated/campaign/refresh-hint.test.ts +44 -0
- package/bdd/generated/campaign/ribbon.test.ts +65 -0
- package/bdd/generated/campaign/stage-choices.test.ts +55 -0
- package/bdd/generated/campaign/submit.test.ts +167 -0
- package/bdd/generated/campaign/tracker-cards.test.ts +49 -0
- package/bdd/generated/campaign/view-only.test.ts +51 -0
- package/bdd/generated/hit-design/campaign-column-metadata.test.ts +1 -0
- package/bdd/generated/landing/campaign-deep-links.test.ts +68 -0
- package/bdd/generated/landing/hit-design-campaigns-fixes.test.ts +99 -0
- package/bdd/generated/landing/hit-design-campaigns.test.ts +160 -0
- package/bdd/generated/landing/hit-triage-campaigns.test.ts +107 -0
- package/bdd/generated/landing/new-campaign.test.ts +78 -0
- package/bdd/generated/landing/pep-triage-campaigns.test.ts +52 -0
- package/bdd/generated/landing/pepti-hit-landing.test.ts +130 -0
- package/bdd/generated/pepti-hit/helm-edit.test.ts +64 -0
- package/bdd/generated/templates/template-editor.test.ts +137 -0
- package/bdd/generated/templates/template-picker.test.ts +119 -0
- package/bdd/generated/templates/triage-forms.test.ts +68 -0
- package/css/hit-triage.css +27 -23
- package/dist/package-test.js +690 -4
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +318 -73
- package/dist/package.js.map +1 -1
- package/package.json +11 -7
- package/queries/locks.sql +37 -0
- package/src/app/accordeons/layout-input.ts +52 -44
- package/src/app/accordeons/new-campaign-accordeon.ts +91 -54
- package/src/app/accordeons/new-hit-design-campaign-accordeon.ts +3 -67
- package/src/app/accordeons/new-pep-triage-template-accordeon.ts +39 -41
- package/src/app/accordeons/new-template-accordeon.ts +41 -24
- package/src/app/ai/view-functions.ts +22 -19
- package/src/app/base-view.ts +99 -8
- package/src/app/consts.ts +8 -5
- package/src/app/dialogs/functions-dialog.ts +14 -9
- package/src/app/dialogs/merge-table-dialog.ts +181 -325
- package/src/app/hit-app-base.ts +61 -90
- package/src/app/hit-design-app.ts +481 -886
- package/src/app/hit-design-views/info-view.ts +57 -407
- package/src/app/hit-design-views/submit-view.ts +216 -111
- package/src/app/hit-design-views/tiles-view.ts +168 -123
- package/src/app/hit-design-views/utils.css +0 -8
- package/src/app/hit-triage-app.ts +69 -38
- package/src/app/hit-triage-views/info-view.ts +70 -371
- package/src/app/pep-triage-app.ts +2 -2
- package/src/app/pep-triage-views/info-view.ts +42 -83
- package/src/app/pepti-hit-app.ts +32 -183
- package/src/app/pepti-hits-views/info-view.ts +15 -37
- package/src/app/shared/campaign-catalog.ts +408 -0
- package/src/app/shared/campaign-session.ts +557 -0
- package/src/app/shared/compute-editor.ts +274 -0
- package/src/app/shared/hit-home.ts +45 -0
- package/src/app/shared/new-campaign-form.ts +90 -0
- package/src/app/shared/permissions-editor.ts +93 -0
- package/src/app/shared/template-editor.ts +331 -0
- package/src/app/shared/template-picker.ts +154 -0
- package/src/app/utils/merge-table.ts +183 -78
- package/src/app/utils.ts +34 -325
- package/src/package-api.ts +29 -8
- package/src/package-test.ts +17 -2
- package/src/package.g.ts +12 -8
- package/src/package.ts +19 -7
- package/src/tests/ai.ts +244 -0
- package/src/tests/campaign-layout.ts +82 -0
- package/src/tests/campaign-session.ts +168 -0
- package/src/tests/campaigns.ts +23 -0
- package/src/tests/catalog.ts +156 -0
- package/src/tests/compat.ts +482 -0
- package/src/tests/compute.ts +165 -0
- package/src/tests/fixtures.ts +359 -0
- package/src/tests/merge.ts +149 -0
- package/src/tests/owners.ts +11 -0
- package/src/tests/save-lock.ts +932 -0
- package/src/tests/storage.ts +106 -0
- package/src/tests/template-editor.ts +538 -0
- package/src/tests/templates.ts +143 -0
- package/src/tests/triage-start.ts +81 -0
- package/src/tests/u2-guards.ts +384 -0
- package/src/tests/vid.ts +77 -0
- package/src/app/accordeons/new-hit-design-template-accordeon.ts +0 -238
- package/src/app/dialogs/permissions-dialog.ts +0 -66
package/src/app/utils.ts
CHANGED
|
@@ -3,11 +3,8 @@ import * as grok from 'datagrok-api/grok';
|
|
|
3
3
|
import * as ui from 'datagrok-api/ui';
|
|
4
4
|
import * as DG from 'datagrok-api/dg';
|
|
5
5
|
import {Subscription} from 'rxjs';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
HTCampaignTableColumns, HTCampaignsGroupingLSKey, HTCampaignsTableSortingLSKey, HTCampaignTableColumnsLSKey, HTDefaultCampaignTableInfoGetters,
|
|
9
|
-
HTFunctionOrderingLSKey, i18n} from './consts';
|
|
10
|
-
import {AppName, CampaignsType, HitDesignCampaign, HitTriageCampaign, TriagePermissions} from './types';
|
|
6
|
+
import {CampaignJsonName, HTFunctionOrderingLSKey} from './consts';
|
|
7
|
+
import {AppName, CampaignsType, TriagePermissions} from './types';
|
|
11
8
|
import {_package} from '../package';
|
|
12
9
|
|
|
13
10
|
// Re-export shared compute-function utilities from the statistics library
|
|
@@ -82,18 +79,6 @@ export function modifyUrl(key: string, value: string) {
|
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
81
|
|
|
85
|
-
export function hideComponents(styles: CSSStyleDeclaration[]) {
|
|
86
|
-
styles.forEach((style) => {
|
|
87
|
-
style.display = 'none';
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function showComponents(styles: CSSStyleDeclaration[]) {
|
|
92
|
-
styles.forEach((style) => {
|
|
93
|
-
style.display = 'flex';
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
82
|
export function addBreadCrumbsToRibbons(view: DG.ViewBase, firstPath: string, secondPath: string, handler: Function):
|
|
98
83
|
{breadcrumbs: DG.Breadcrumbs, sub: Subscription} {
|
|
99
84
|
const breadcrumbs = ui.breadcrumbs([firstPath, secondPath]);
|
|
@@ -162,12 +147,13 @@ export async function loadCampaigns<T extends AppName>(
|
|
|
162
147
|
const campaignFolders = (await _package.files.list(`${appName}/campaigns`))
|
|
163
148
|
.filter((f) => deletedCampaigns.indexOf(f.name) === -1);
|
|
164
149
|
const campaignNamesMap: {[name: string]: CampaignsType[T]} = {};
|
|
150
|
+
const membership: MembershipCache = new Map();
|
|
165
151
|
const campaignPromises = campaignFolders.map(async (folder) => {
|
|
166
152
|
try {
|
|
167
153
|
const campaignJson: CampaignsType[T] = JSON.parse(await _package.files
|
|
168
154
|
.readAsText(`${appName}/campaigns/${folder.name}/${CampaignJsonName}`));
|
|
169
155
|
if (campaignJson.authorUserId && campaignJson.permissions &&
|
|
170
|
-
!await checkViewPermissions(campaignJson.authorUserId, campaignJson.permissions)
|
|
156
|
+
!await checkViewPermissions(campaignJson.authorUserId, campaignJson.permissions, membership)
|
|
171
157
|
)
|
|
172
158
|
return null;
|
|
173
159
|
if (campaignJson.authorUserId && !campaignJson.authorUserFriendlyName) {
|
|
@@ -177,7 +163,7 @@ export async function loadCampaigns<T extends AppName>(
|
|
|
177
163
|
}
|
|
178
164
|
campaignNamesMap[campaignJson.name] = campaignJson;
|
|
179
165
|
} catch (e) {
|
|
180
|
-
console.
|
|
166
|
+
console.warn(`Skipped campaign ${appName}/${folder.name}:`, e);
|
|
181
167
|
}
|
|
182
168
|
return null;
|
|
183
169
|
});
|
|
@@ -185,26 +171,33 @@ export async function loadCampaigns<T extends AppName>(
|
|
|
185
171
|
return campaignNamesMap;
|
|
186
172
|
}
|
|
187
173
|
|
|
188
|
-
|
|
174
|
+
/** The groups the current user was looked up in, each once: the campaigns of one list share it. */
|
|
175
|
+
export type MembershipCache = Map<string, Promise<boolean>>;
|
|
176
|
+
|
|
177
|
+
async function isMember(groupId: string): Promise<boolean> {
|
|
178
|
+
const user = DG.User.current();
|
|
179
|
+
const group = await grok.dapi.groups.find(groupId);
|
|
180
|
+
if (!group)
|
|
181
|
+
return false;
|
|
182
|
+
if (group.personal)
|
|
183
|
+
return (await grok.dapi.groups.getUser(group))?.id === user.id;
|
|
184
|
+
const own = user.group?.id;
|
|
185
|
+
return !!own && [...group.members ?? [], ...group.adminMembers ?? []].some((member) => member?.id === own);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function checkPermissions(authorId: string, groupIdList: string[], cache?: MembershipCache): Promise<boolean> {
|
|
189
189
|
try {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (authorId === userId)
|
|
190
|
+
// the server does not list the members of All users, so the lookup below would never find the user there
|
|
191
|
+
if (authorId === DG.User.current().id || groupIdList.includes(DG.Group.defaultGroupsIds['All users']))
|
|
193
192
|
return true;
|
|
194
193
|
for (const groupId of groupIdList) {
|
|
195
|
-
|
|
196
|
-
if (
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const user = await grok.dapi.groups.getUser(group);
|
|
200
|
-
if (user?.id === userId)
|
|
201
|
-
return true;
|
|
202
|
-
} else if (userGroupId) {
|
|
203
|
-
if ((group.members?.length ?? 0) > 0 && group.members.some((memberGroup) => memberGroup?.id === userGroupId))
|
|
204
|
-
return true;
|
|
205
|
-
if ((group.adminMembers?.length ?? 0) > 0 && group.adminMembers.some((memberGroup) => memberGroup?.id === userGroupId))
|
|
206
|
-
return true;
|
|
194
|
+
let member = cache?.get(groupId);
|
|
195
|
+
if (member === undefined) {
|
|
196
|
+
member = isMember(groupId);
|
|
197
|
+
cache?.set(groupId, member);
|
|
207
198
|
}
|
|
199
|
+
if (await member)
|
|
200
|
+
return true;
|
|
208
201
|
}
|
|
209
202
|
} catch (e) {
|
|
210
203
|
_package.logger.error(e);
|
|
@@ -212,294 +205,14 @@ async function checkPermissions(authorId: string, groupIdList: string[]): Promis
|
|
|
212
205
|
return false;
|
|
213
206
|
}
|
|
214
207
|
|
|
215
|
-
export async function checkEditPermissions(authorId: string, permissions: TriagePermissions
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
export async function checkViewPermissions(authorId: string, permissions: TriagePermissions): Promise<boolean> {
|
|
220
|
-
return checkPermissions(authorId, Array.from(new Set([...permissions.view, ...permissions.edit])));
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export function getLocalStorageValue<T = string>(key: string): T | null {
|
|
224
|
-
return localStorage.getItem(key) as unknown as T;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export function setLocalStorageValue(key: string, value: string) {
|
|
228
|
-
localStorage.setItem(key, value as unknown as string);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export function getSavedCampaignsGrouping(): CampaignGroupingType {
|
|
232
|
-
return getLocalStorageValue<CampaignGroupingType>(HDCampaignsGroupingLSKey) ?? CampaignGrouping.None;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export function setSavedCampaignsGrouping(value: CampaignGroupingType) {
|
|
236
|
-
setLocalStorageValue(HDCampaignsGroupingLSKey, value);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export type SavedCampaignsTableSorting = {
|
|
240
|
-
columnName: CampaignTableColumns,
|
|
241
|
-
ascending: boolean,
|
|
208
|
+
export async function checkEditPermissions(authorId: string, permissions: TriagePermissions,
|
|
209
|
+
cache?: MembershipCache): Promise<boolean> {
|
|
210
|
+
return checkPermissions(authorId, permissions.edit, cache);
|
|
242
211
|
}
|
|
243
212
|
|
|
244
|
-
export function
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return null;
|
|
248
|
-
return JSON.parse(sortingString) as SavedCampaignsTableSorting;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
export function setSavedCampaignsSorting(value: SavedCampaignsTableSorting | null) {
|
|
252
|
-
value ? setLocalStorageValue(HDCampaignsTableSortingLSKey, JSON.stringify(value)) :
|
|
253
|
-
localStorage.removeItem(HDCampaignsTableSortingLSKey);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export function sortCampaigns<T extends HitDesignCampaign | HitTriageCampaign>(
|
|
257
|
-
campaigns: T[], sorting: {columnName: string, ascending: boolean} | null,
|
|
258
|
-
getters?: {[key: string]: (a: T) => string},
|
|
259
|
-
) {
|
|
260
|
-
if (!sorting)
|
|
261
|
-
return;
|
|
262
|
-
const defaultGetters = (getters ?? DefaultCampaignTableInfoGetters) as {[key: string]: (a: T) => string};
|
|
263
|
-
const getter = sorting.columnName in defaultGetters ?
|
|
264
|
-
defaultGetters[sorting.columnName] : (campaign: T) =>
|
|
265
|
-
campaign.campaignFields?.[sorting.columnName.replace('campaignFields.', '') ?? ''] ?? '';
|
|
266
|
-
const vs: Map<HitDesignCampaign, any> = new Map();
|
|
267
|
-
campaigns.forEach((c) => {
|
|
268
|
-
vs.set(c, getter(c));
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
// probe for numbers or dates
|
|
272
|
-
const allNumbers = Array.from(vs.values()).every((v) => isNil(v) || !isNaN(Number(v?.toString() ?? '')));
|
|
273
|
-
const allDates = !allNumbers && Array.from(vs.values()).every((v) => isNil(v) || !isNaN(Date.parse(v?.toString() ?? '')));
|
|
274
|
-
if (allNumbers) {
|
|
275
|
-
campaigns.forEach((c) => {
|
|
276
|
-
vs.set(c, isNil(vs.get(c)) ? (sorting.ascending ? Infinity : -Infinity) : Number(vs.get(c)));
|
|
277
|
-
});
|
|
278
|
-
} else if (allDates) {
|
|
279
|
-
campaigns.forEach((c) => {
|
|
280
|
-
vs.set(c, isNil(vs.get(c)) ? (sorting.ascending ? Infinity : -Infinity) : Date.parse(vs.get(c)?.toString() ?? ''));
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
campaigns.sort((a, b) => {
|
|
285
|
-
const aVal = vs.get(a);
|
|
286
|
-
const bVal = vs.get(b);
|
|
287
|
-
if (allNumbers || allDates)
|
|
288
|
-
return sorting.ascending ? aVal - bVal : bVal - aVal;
|
|
289
|
-
const aa = isNil(aVal) ? '' : aVal.toString();
|
|
290
|
-
const bb = isNil(bVal) ? '' : bVal.toString();
|
|
291
|
-
return sorting.ascending ? aa.localeCompare(bb) : bb.localeCompare(aa);
|
|
292
|
-
});
|
|
293
|
-
vs.clear();
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export function getSavedCampaignTableColumns(): CampaignTableColumns[] {
|
|
297
|
-
const columnsString = getLocalStorageValue<string>(HDCampaignTableColumnsLSKey);
|
|
298
|
-
const defaultCols: CampaignTableColumns[] = ['Code', 'Created', 'Author', 'Last Modified by', 'Molecules', 'Status'];
|
|
299
|
-
if (!columnsString)
|
|
300
|
-
return defaultCols;
|
|
301
|
-
try {
|
|
302
|
-
const columnsP = JSON.parse(columnsString);
|
|
303
|
-
if (Array.isArray(columnsP) && columnsP.every((c) => typeof c === 'string'))
|
|
304
|
-
return columnsP as CampaignTableColumns[];
|
|
305
|
-
return defaultCols;
|
|
306
|
-
} catch (e) {
|
|
307
|
-
console.error('error parsing campaign table columns', e);
|
|
308
|
-
return defaultCols;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
export function setSavedCampaignTableColumns(columns: CampaignTableColumns[]) {
|
|
313
|
-
setLocalStorageValue(HDCampaignTableColumnsLSKey, JSON.stringify(columns));
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// ---- Hit Triage-specific localStorage wrappers ----
|
|
317
|
-
|
|
318
|
-
export function getHTSavedCampaignsGrouping(): CampaignGroupingType {
|
|
319
|
-
return getLocalStorageValue<CampaignGroupingType>(HTCampaignsGroupingLSKey) ?? CampaignGrouping.None;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export function setHTSavedCampaignsGrouping(value: CampaignGroupingType) {
|
|
323
|
-
setLocalStorageValue(HTCampaignsGroupingLSKey, value);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
export type HTSavedCampaignsTableSorting = {
|
|
327
|
-
columnName: HTCampaignTableColumns,
|
|
328
|
-
ascending: boolean,
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
export function getHTSavedCampaignsSorting(): HTSavedCampaignsTableSorting | null {
|
|
332
|
-
const sortingString = getLocalStorageValue<string>(HTCampaignsTableSortingLSKey);
|
|
333
|
-
if (!sortingString)
|
|
334
|
-
return null;
|
|
335
|
-
return JSON.parse(sortingString) as HTSavedCampaignsTableSorting;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
export function setHTSavedCampaignsSorting(value: HTSavedCampaignsTableSorting | null) {
|
|
339
|
-
value ? setLocalStorageValue(HTCampaignsTableSortingLSKey, JSON.stringify(value)) :
|
|
340
|
-
localStorage.removeItem(HTCampaignsTableSortingLSKey);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
export function getHTSavedCampaignTableColumns(): HTCampaignTableColumns[] {
|
|
344
|
-
const columnsString = getLocalStorageValue<string>(HTCampaignTableColumnsLSKey);
|
|
345
|
-
const defaultCols: HTCampaignTableColumns[] = ['Created', 'Author', 'Total', 'Selected', 'Status'];
|
|
346
|
-
if (!columnsString)
|
|
347
|
-
return defaultCols;
|
|
348
|
-
try {
|
|
349
|
-
const columnsP = JSON.parse(columnsString);
|
|
350
|
-
if (Array.isArray(columnsP) && columnsP.every((c) => typeof c === 'string'))
|
|
351
|
-
return columnsP as HTCampaignTableColumns[];
|
|
352
|
-
return defaultCols;
|
|
353
|
-
} catch (e) {
|
|
354
|
-
console.error('error parsing HT campaign table columns', e);
|
|
355
|
-
return defaultCols;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
export function setHTSavedCampaignTableColumns(columns: HTCampaignTableColumns[]) {
|
|
360
|
-
setLocalStorageValue(HTCampaignTableColumnsLSKey, JSON.stringify(columns));
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
export const getGroupingKey = <T extends HitDesignCampaign | HitTriageCampaign = HitDesignCampaign>(grouping: CampaignGroupingType, campaign: T): string => {
|
|
365
|
-
switch (grouping) {
|
|
366
|
-
case CampaignGrouping.Template:
|
|
367
|
-
return campaign.template?.key ?? campaign.templateName;
|
|
368
|
-
case CampaignGrouping.Status:
|
|
369
|
-
return campaign.status;
|
|
370
|
-
case CampaignGrouping.Author:
|
|
371
|
-
return campaign.authorUserFriendlyName ?? i18n.noInformation;
|
|
372
|
-
case CampaignGrouping.LastModifiedUser:
|
|
373
|
-
return campaign.lastModifiedUserName ?? i18n.noInformation;
|
|
374
|
-
default:
|
|
375
|
-
if (grouping.startsWith('campaignFields.')) {
|
|
376
|
-
const fieldName = grouping.replace('campaignFields.', '');
|
|
377
|
-
return campaign.campaignFields?.[fieldName] ?? i18n.noInformation;
|
|
378
|
-
}
|
|
379
|
-
return '';
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
export function getGroupedCampaigns<T extends HitDesignCampaign | HitTriageCampaign = HitDesignCampaign>(campaigns: T[], grouping: CampaignGroupingType):
|
|
384
|
-
{[key: string]: T[]} {
|
|
385
|
-
if (grouping === CampaignGrouping.None)
|
|
386
|
-
return {'': campaigns};
|
|
387
|
-
const groupedCampaigns: {[key: string]: T[]} = {};
|
|
388
|
-
for (const campaign of campaigns) {
|
|
389
|
-
const key = getGroupingKey(grouping, campaign);
|
|
390
|
-
if (!groupedCampaigns[key])
|
|
391
|
-
groupedCampaigns[key] = [];
|
|
392
|
-
groupedCampaigns[key].push(campaign);
|
|
393
|
-
}
|
|
394
|
-
return groupedCampaigns;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
export function processGroupingTable<T extends HitDesignCampaign | HitTriageCampaign = HitDesignCampaign>(table: HTMLTableElement, groupedCampaigns: {[key: string]: T[]}, numCols = 9) {
|
|
398
|
-
table.classList.add('hit-design-groupped-campaigns-table');
|
|
399
|
-
const keys = Object.keys(groupedCampaigns);
|
|
400
|
-
if (keys.length < 2)
|
|
401
|
-
return table;
|
|
402
|
-
const body = table.getElementsByTagName('tbody')[0];
|
|
403
|
-
const rows = Array.from(table.getElementsByTagName('tr')).filter((row) => !row.classList.contains('header'));
|
|
404
|
-
let curRow = 0;
|
|
405
|
-
|
|
406
|
-
const setState = (expanded: boolean, start: number, end: number) => {
|
|
407
|
-
for (let i = start; i < end; i++)
|
|
408
|
-
rows[i]?.style && (rows[i].style.display = expanded ? 'table-row' : 'none');
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
for (const key of keys) {
|
|
413
|
-
const row = rows[curRow];
|
|
414
|
-
if (!row)
|
|
415
|
-
break;
|
|
416
|
-
const l = groupedCampaigns[key].length;
|
|
417
|
-
const startRow = curRow;
|
|
418
|
-
const endRow = curRow + l;
|
|
419
|
-
const acc = ui.accordion(`Hit-Design-campaigns-group-${key}`);
|
|
420
|
-
const pane = acc.addPane(key, () => {return ui.div();}, undefined, undefined, false);
|
|
421
|
-
pane.root.style.marginLeft = '-24px';
|
|
422
|
-
pane.root.onclick = () => {
|
|
423
|
-
setState(pane.expanded, startRow, endRow);
|
|
424
|
-
};
|
|
425
|
-
setState(pane.expanded, startRow, endRow);
|
|
426
|
-
const newRow = body.insertRow(0);
|
|
427
|
-
const newCell = newRow.insertCell(0);
|
|
428
|
-
newCell.appendChild(pane.root);
|
|
429
|
-
newCell.colSpan = numCols;
|
|
430
|
-
body.insertBefore(newRow, row);
|
|
431
|
-
curRow += l;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
export type EditableFieldOptions = {
|
|
436
|
-
onChange?: (val?: string | null) => void,
|
|
437
|
-
onOk?: (val?: string | null) => Promise<void>,
|
|
438
|
-
validator?: (val?: string | null) => Promise<string | null>,
|
|
439
|
-
onCancel?: () => void,
|
|
440
|
-
afterEditTextContent?: (val: string) => string,
|
|
441
|
-
beforeEditTextContent?: (val: string) => string,
|
|
442
|
-
nullable?: boolean,
|
|
443
|
-
tooltip?: string,
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
export function editableTableField(field: HTMLElement, options?: EditableFieldOptions) {
|
|
447
|
-
const editIcon = ui.icons.edit(() => {
|
|
448
|
-
let tooltipMsg = options?.tooltip ?? field.textContent ?? '';
|
|
449
|
-
const beforeEditTextContent = options?.beforeEditTextContent ?? ((val) => val);
|
|
450
|
-
const afterEditTextContent = options?.afterEditTextContent ?? ((val) => val);
|
|
451
|
-
const input = ui.input.string('smth', {value: beforeEditTextContent(field.textContent ?? ''), onValueChanged: async () => {
|
|
452
|
-
const vr = await internalValidator();
|
|
453
|
-
setTimeout(() => {
|
|
454
|
-
if (vr) {
|
|
455
|
-
input.input.classList.add('d4-invalid');
|
|
456
|
-
tooltipMsg = vr;
|
|
457
|
-
return;
|
|
458
|
-
} else {
|
|
459
|
-
input.input.classList.remove('d4-invalid');
|
|
460
|
-
tooltipMsg = options?.tooltip ?? field.textContent ?? '';
|
|
461
|
-
}
|
|
462
|
-
}, 100);
|
|
463
|
-
options?.onChange?.(input.value);
|
|
464
|
-
}});
|
|
465
|
-
ui.tooltip.bind(input.input, () => tooltipMsg);
|
|
466
|
-
const labelElement = input.root.getElementsByTagName('label').item(0);
|
|
467
|
-
if (labelElement)
|
|
468
|
-
labelElement.remove();
|
|
469
|
-
input.root.style.width = '100%';
|
|
470
|
-
const internalValidator = async () => {
|
|
471
|
-
const initialRes = !!input.value?.trim() ? null : !!options?.nullable ? null :'Field cannot be empty';
|
|
472
|
-
return initialRes ?? (options?.validator ? await options.validator(input.value) : null);
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
const saveButton = ui.button('Save', async () => {
|
|
476
|
-
const vr = await internalValidator();
|
|
477
|
-
if (vr) {
|
|
478
|
-
grok.shell.error(vr);
|
|
479
|
-
return;
|
|
480
|
-
}
|
|
481
|
-
await options?.onOk?.(input.value);
|
|
482
|
-
field.textContent = afterEditTextContent(input.value) ?? '';
|
|
483
|
-
ui.empty(container);
|
|
484
|
-
container.appendChild(field);
|
|
485
|
-
container.appendChild(editIcon);
|
|
486
|
-
});
|
|
487
|
-
const cancelButton = ui.button('Cancel', () => {
|
|
488
|
-
ui.empty(container);
|
|
489
|
-
container.appendChild(field);
|
|
490
|
-
container.appendChild(editIcon);
|
|
491
|
-
options?.onCancel?.();
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
ui.empty(container);
|
|
495
|
-
input.addOptions(cancelButton);
|
|
496
|
-
input.addOptions(saveButton);
|
|
497
|
-
container.appendChild(input.root);
|
|
498
|
-
input.input.focus();
|
|
499
|
-
}, options?.tooltip ?? 'Edit');
|
|
500
|
-
const container = ui.divH([field, editIcon], {style: {display: 'flex', alignItems: 'center'}});
|
|
501
|
-
editIcon.style.marginLeft = '5px';
|
|
502
|
-
return container;
|
|
213
|
+
export async function checkViewPermissions(authorId: string, permissions: TriagePermissions,
|
|
214
|
+
cache?: MembershipCache): Promise<boolean> {
|
|
215
|
+
return checkPermissions(authorId, Array.from(new Set([...permissions.view, ...permissions.edit])), cache);
|
|
503
216
|
}
|
|
504
217
|
|
|
505
218
|
export async function checkFileExists(path: string) {
|
|
@@ -536,10 +249,6 @@ export function timeoutOneTimeEventListener(element: HTMLElement, eventName: str
|
|
|
536
249
|
// return df;
|
|
537
250
|
// }
|
|
538
251
|
|
|
539
|
-
export function isNil(something: any) {
|
|
540
|
-
return something === '' || something === null || something === undefined || (typeof something == 'number' && isNaN(something));
|
|
541
|
-
}
|
|
542
|
-
|
|
543
252
|
export async function loadTemplate<T extends {compute: TemplateCompute}>(path: string): Promise<T> {
|
|
544
253
|
return JSON.parse(await _package.files.readAsText(path)) as T;
|
|
545
254
|
}
|
package/src/package-api.ts
CHANGED
|
@@ -29,6 +29,27 @@ export namespace queries {
|
|
|
29
29
|
return await grok.data.query('HitTriage:GetLastModified', { appName, campaignId });
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Get the last save time of every campaign of an app.
|
|
34
|
+
*/
|
|
35
|
+
export async function getLastModifiedAll(appName: string ): Promise<DG.DataFrame> {
|
|
36
|
+
return await grok.data.query('HitTriage:GetLastModifiedAll', { appName });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Drop the caller's lock without logging a save: the campaign was not written under it. A lock another session holds stays.
|
|
41
|
+
*/
|
|
42
|
+
export async function dropCampaignLock(appName: string , campaignId: string , lockedBy: string ): Promise<DG.DataFrame> {
|
|
43
|
+
return await grok.data.query('HitTriage:DropCampaignLock', { appName, campaignId, lockedBy });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Remove what the database keeps of a deleted campaign: its last save, its lock and its V-iD links.
|
|
48
|
+
*/
|
|
49
|
+
export async function deleteCampaignRecords(appName: string , campaignId: string ): Promise<DG.DataFrame> {
|
|
50
|
+
return await grok.data.query('HitTriage:DeleteCampaignRecords', { appName, campaignId });
|
|
51
|
+
}
|
|
52
|
+
|
|
32
53
|
/**
|
|
33
54
|
* Add a molecule to the dictionary. Returns VID for new or existing molecule.
|
|
34
55
|
*/
|
|
@@ -75,24 +96,24 @@ export namespace funcs {
|
|
|
75
96
|
return await grok.functions.call('HitTriage:PeptiHitAppTreeBrowser', { treeNode });
|
|
76
97
|
}
|
|
77
98
|
|
|
78
|
-
export async function hitTriageApp(): Promise<DG.View> {
|
|
79
|
-
return await grok.functions.call('HitTriage:HitTriageApp', {});
|
|
99
|
+
export async function hitTriageApp(campaignId?: string ): Promise<DG.View> {
|
|
100
|
+
return await grok.functions.call('HitTriage:HitTriageApp', { campaignId });
|
|
80
101
|
}
|
|
81
102
|
|
|
82
|
-
export async function hitDesignApp(): Promise<DG.View> {
|
|
83
|
-
return await grok.functions.call('HitTriage:HitDesignApp', {});
|
|
103
|
+
export async function hitDesignApp(campaignId?: string ): Promise<DG.View> {
|
|
104
|
+
return await grok.functions.call('HitTriage:HitDesignApp', { campaignId });
|
|
84
105
|
}
|
|
85
106
|
|
|
86
|
-
export async function peptiHitApp(): Promise<DG.View> {
|
|
87
|
-
return await grok.functions.call('HitTriage:PeptiHitApp', {});
|
|
107
|
+
export async function peptiHitApp(campaignId?: string ): Promise<DG.View> {
|
|
108
|
+
return await grok.functions.call('HitTriage:PeptiHitApp', { campaignId });
|
|
88
109
|
}
|
|
89
110
|
|
|
90
111
|
export async function pepTriageAppTreeBrowser(treeNode: any ): Promise<void> {
|
|
91
112
|
return await grok.functions.call('HitTriage:PepTriageAppTreeBrowser', { treeNode });
|
|
92
113
|
}
|
|
93
114
|
|
|
94
|
-
export async function pepTriageApp(): Promise<DG.View> {
|
|
95
|
-
return await grok.functions.call('HitTriage:PepTriageApp', {});
|
|
115
|
+
export async function pepTriageApp(campaignId?: string ): Promise<DG.View> {
|
|
116
|
+
return await grok.functions.call('HitTriage:PepTriageApp', { campaignId });
|
|
96
117
|
}
|
|
97
118
|
|
|
98
119
|
export async function demoFileIngest(): Promise<DG.DataFrame> {
|
package/src/package-test.ts
CHANGED
|
@@ -2,9 +2,24 @@ import * as DG from 'datagrok-api/dg';
|
|
|
2
2
|
import * as grok from 'datagrok-api/grok';
|
|
3
3
|
|
|
4
4
|
import {runTests, tests, TestContext, initAutoTests as initTests } from '@datagrok-libraries/test/src/test';
|
|
5
|
+
import {_package} from './package';
|
|
6
|
+
import './tests/campaigns';
|
|
7
|
+
import './tests/compat';
|
|
8
|
+
import './tests/templates';
|
|
9
|
+
import './tests/template-editor';
|
|
10
|
+
import './tests/save-lock';
|
|
11
|
+
import './tests/campaign-session';
|
|
12
|
+
import './tests/compute';
|
|
13
|
+
import './tests/merge';
|
|
14
|
+
import './tests/campaign-layout';
|
|
15
|
+
import './tests/triage-start';
|
|
16
|
+
import './tests/vid';
|
|
17
|
+
import './tests/storage';
|
|
18
|
+
import './tests/catalog';
|
|
19
|
+
import './tests/ai';
|
|
20
|
+
import './tests/u2-guards';
|
|
5
21
|
|
|
6
|
-
export
|
|
7
|
-
export {tests};
|
|
22
|
+
export {_package, tests};
|
|
8
23
|
|
|
9
24
|
//name: test
|
|
10
25
|
//input: string category {optional: true}
|
package/src/package.g.ts
CHANGED
|
@@ -26,31 +26,34 @@ export async function peptiHitAppTreeBrowser(treeNode: any) : Promise<void> {
|
|
|
26
26
|
|
|
27
27
|
//name: Hit Triage
|
|
28
28
|
//tags: app
|
|
29
|
+
//input: string campaignId { optional: true }
|
|
29
30
|
//output: view result
|
|
30
31
|
//meta.role: app
|
|
31
32
|
//meta.browsePath: Chem
|
|
32
|
-
export async function hitTriageApp() : Promise<any> {
|
|
33
|
-
return await PackageFunctions.hitTriageApp();
|
|
33
|
+
export async function hitTriageApp(_campaignId?: string) : Promise<any> {
|
|
34
|
+
return await PackageFunctions.hitTriageApp(_campaignId);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
//name: Hit Design
|
|
37
38
|
//tags: app
|
|
39
|
+
//input: string campaignId { optional: true }
|
|
38
40
|
//output: view result
|
|
39
41
|
//meta.role: app
|
|
40
42
|
//meta.icon: images/icons/hit-design-icon.png
|
|
41
43
|
//meta.browsePath: Chem
|
|
42
|
-
export async function hitDesignApp() : Promise<any> {
|
|
43
|
-
return await PackageFunctions.hitDesignApp();
|
|
44
|
+
export async function hitDesignApp(_campaignId?: string) : Promise<any> {
|
|
45
|
+
return await PackageFunctions.hitDesignApp(_campaignId);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
//name: PeptiHit
|
|
47
49
|
//tags: app
|
|
50
|
+
//input: string campaignId { optional: true }
|
|
48
51
|
//output: view result
|
|
49
52
|
//meta.role: app
|
|
50
53
|
//meta.icon: images/icons/pepti-hit-icon.png
|
|
51
54
|
//meta.browsePath: Peptides
|
|
52
|
-
export async function peptiHitApp() : Promise<any> {
|
|
53
|
-
return await PackageFunctions.peptiHitApp();
|
|
55
|
+
export async function peptiHitApp(_campaignId?: string) : Promise<any> {
|
|
56
|
+
return await PackageFunctions.peptiHitApp(_campaignId);
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
//input: dynamic treeNode
|
|
@@ -61,12 +64,13 @@ export async function pepTriageAppTreeBrowser(treeNode: any) : Promise<void> {
|
|
|
61
64
|
|
|
62
65
|
//name: PepTriage
|
|
63
66
|
//tags: app
|
|
67
|
+
//input: string campaignId { optional: true }
|
|
64
68
|
//output: view result
|
|
65
69
|
//meta.role: app
|
|
66
70
|
//meta.icon: images/icons/hit-triage-icon.png
|
|
67
71
|
//meta.browsePath: Peptides
|
|
68
|
-
export async function pepTriageApp() : Promise<any> {
|
|
69
|
-
return await PackageFunctions.pepTriageApp();
|
|
72
|
+
export async function pepTriageApp(_campaignId?: string) : Promise<any> {
|
|
73
|
+
return await PackageFunctions.pepTriageApp(_campaignId);
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
//name: Demo Molecules 100
|
package/src/package.ts
CHANGED
|
@@ -28,8 +28,10 @@ export class HTPackage extends DG.Package {
|
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
/** The app's campaigns the user may view, read once per page (the Browse tree, the landing and the assistant share
|
|
32
|
+
* the list); `fresh` reads them again from the server. */
|
|
33
|
+
async loadCampaigns<T extends AppName>(appName: T, deletedCampaigns?: string[], fresh = false) {
|
|
34
|
+
if (fresh || !this.campaignsCache[appName])
|
|
33
35
|
this.campaignsCache[appName] = (await loadCampaigns(appName, deletedCampaigns ?? [])) as typeof this.campaignsCache[T];
|
|
34
36
|
|
|
35
37
|
return this.campaignsCache[appName]! as { [name: string]: CampaignsType[T] };
|
|
@@ -38,7 +40,9 @@ export class HTPackage extends DG.Package {
|
|
|
38
40
|
async saveCampaignJson<T extends AppName>(appName: T, campaign: CampaignsType[T]) {
|
|
39
41
|
const path = `${appName}/campaigns/${campaign.name}/${CampaignJsonName}`;
|
|
40
42
|
await this.files.writeAsText(path, JSON.stringify(campaign));
|
|
41
|
-
|
|
43
|
+
const cached = this.campaignsCache[appName] as { [name: string]: CampaignsType[T] } | undefined;
|
|
44
|
+
if (cached)
|
|
45
|
+
cached[campaign.name] = campaign;
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
|
|
@@ -163,7 +167,9 @@ export class PackageFunctions {
|
|
|
163
167
|
name: 'Hit Triage',
|
|
164
168
|
tags: ['app'],
|
|
165
169
|
})
|
|
166
|
-
static async hitTriageApp(
|
|
170
|
+
static async hitTriageApp(
|
|
171
|
+
@grok.decorators.param({name: 'campaignId', options: {optional: true}}) _campaignId?: string,
|
|
172
|
+
): Promise<DG.ViewBase> {
|
|
167
173
|
const c = grok.functions.getCurrentCall();
|
|
168
174
|
return new HitTriageApp(c).multiView;
|
|
169
175
|
}
|
|
@@ -175,7 +181,9 @@ export class PackageFunctions {
|
|
|
175
181
|
name: 'Hit Design',
|
|
176
182
|
tags: ['app'],
|
|
177
183
|
})
|
|
178
|
-
static async hitDesignApp(
|
|
184
|
+
static async hitDesignApp(
|
|
185
|
+
@grok.decorators.param({name: 'campaignId', options: {optional: true}}) _campaignId?: string,
|
|
186
|
+
): Promise<DG.ViewBase> {
|
|
179
187
|
const c = grok.functions.getCurrentCall();
|
|
180
188
|
return new HitDesignApp(c).multiView;
|
|
181
189
|
}
|
|
@@ -187,7 +195,9 @@ export class PackageFunctions {
|
|
|
187
195
|
name: 'PeptiHit',
|
|
188
196
|
tags: ['app'],
|
|
189
197
|
})
|
|
190
|
-
static async peptiHitApp(
|
|
198
|
+
static async peptiHitApp(
|
|
199
|
+
@grok.decorators.param({name: 'campaignId', options: {optional: true}}) _campaignId?: string,
|
|
200
|
+
): Promise<DG.ViewBase> {
|
|
191
201
|
const c = grok.functions.getCurrentCall();
|
|
192
202
|
await grok.functions.call('Bio:initBio', {});
|
|
193
203
|
return new PeptiHitApp(c).multiView;
|
|
@@ -206,7 +216,9 @@ export class PackageFunctions {
|
|
|
206
216
|
name: 'PepTriage',
|
|
207
217
|
tags: ['app'],
|
|
208
218
|
})
|
|
209
|
-
static async pepTriageApp(
|
|
219
|
+
static async pepTriageApp(
|
|
220
|
+
@grok.decorators.param({name: 'campaignId', options: {optional: true}}) _campaignId?: string,
|
|
221
|
+
): Promise<DG.ViewBase> {
|
|
210
222
|
const c = grok.functions.getCurrentCall();
|
|
211
223
|
await grok.functions.call('Bio:initBio', {});
|
|
212
224
|
return new PepTriageApp(c).multiView;
|