Skip to content

Commit 838029e

Browse files
committed
Handled selectable types on images status modal
1 parent 87dea8a commit 838029e

File tree

3 files changed

+33
-36
lines changed

3 files changed

+33
-36
lines changed

src/lib/components/jobs/ImagesStatus.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<button
5959
aria-label="Submitted images"
6060
class="status-modal-btn btn btn-link text-decoration-none p-0"
61-
on:click={() => imagesStatusModal.open(dataset, workflowTask.id)}
61+
on:click={() => imagesStatusModal.open(dataset, workflowTask)}
6262
>
6363
<span class="d-flex pe-1">
6464
<span class="pe-1 status-wrapper text-primary">
@@ -77,7 +77,7 @@
7777
<button
7878
aria-label="Done images"
7979
class="status-modal-btn btn btn-link text-decoration-none p-0"
80-
on:click={() => imagesStatusModal.open(dataset, workflowTask.id)}
80+
on:click={() => imagesStatusModal.open(dataset, workflowTask)}
8181
>
8282
<span class="d-flex">
8383
<span class="status-wrapper text-success ps-1">
@@ -94,7 +94,7 @@
9494
<button
9595
aria-label="Failed images"
9696
class="status-modal-btn btn btn-link text-decoration-none p-0"
97-
on:click={() => imagesStatusModal.open(dataset, workflowTask.id)}
97+
on:click={() => imagesStatusModal.open(dataset, workflowTask)}
9898
>
9999
<span class="d-flex">
100100
<span class="status-wrapper text-danger ps-1">

src/lib/components/jobs/ImagesStatusModal.svelte

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
1818
/** @type {import('fractal-components/types/api').DatasetV2} */
1919
let dataset;
20-
/** @type {number} */
21-
let workflowTaskId;
20+
/** @type {import('fractal-components/types/api').WorkflowTaskV2} */
21+
let workflowTask;
22+
/** @type {string[]} */
23+
let disabledTypes = [];
2224
2325
/** @type {Modal} */
2426
let modal;
@@ -28,25 +30,27 @@
2830
/** @type {Array<{text: string, highlight: boolean}>} */
2931
let logParts = [];
3032
let loadedLogsStatus = '';
31-
let projectDir = '';
3233
3334
/** @type {DatasetImagesTable} */
3435
let datasetImagesTable;
3536
3637
/**
3738
* @param {import('fractal-components/types/api').DatasetV2} _dataset
38-
* @param {number} _workflowTaskId
39+
* @param {import('fractal-components/types/api').WorkflowTaskV2} _workflowTask
3940
*/
40-
export async function open(_dataset, _workflowTaskId) {
41+
export async function open(_dataset, _workflowTask) {
4142
loading = true;
4243
imagePage = null;
4344
loadingLogs = false;
4445
logParts = [];
4546
selectedLogImage = '';
4647
dataset = _dataset;
47-
workflowTaskId = _workflowTaskId;
48+
workflowTask = _workflowTask;
49+
disabledTypes = Object.keys({
50+
...workflowTask.type_filters,
51+
...workflowTask.task.input_types
52+
});
4853
modal.show();
49-
await loadProjectDir();
5054
await loadImages();
5155
await tick();
5256
await datasetImagesTable.load();
@@ -56,21 +60,11 @@
5660
imagePage = null;
5761
}
5862
59-
async function loadProjectDir() {
60-
const response = await fetch('/api/auth/current-user/settings');
61-
if (!response.ok) {
62-
return;
63-
}
64-
/** @type {import('fractal-components/types/api').UserSettings} */
65-
const result = await response.json();
66-
projectDir = result.project_dir || '';
67-
}
68-
6963
async function loadImages() {
7064
loading = true;
7165
const headers = new Headers();
7266
headers.set('Content-Type', 'application/json');
73-
const url = `/api/v2/project/${dataset.project_id}/status/images?workflowtask_id=${workflowTaskId}&dataset_id=${dataset.id}&page=1&page_size=10`;
67+
const url = `/api/v2/project/${dataset.project_id}/status/images?workflowtask_id=${workflowTask.id}&dataset_id=${dataset.id}&page=1&page_size=10`;
7468
const response = await fetch(url, {
7569
method: 'POST',
7670
headers,
@@ -99,7 +93,7 @@
9993
method: 'POST',
10094
headers,
10195
body: JSON.stringify({
102-
workflowtask_id: workflowTaskId,
96+
workflowtask_id: workflowTask.id,
10397
dataset_id: dataset.id,
10498
zarr_url: zarrUrl
10599
})
@@ -160,8 +154,9 @@
160154
{dataset}
161155
bind:imagePage
162156
{vizarrViewerUrl}
157+
{disabledTypes}
163158
imagesStatusModal={true}
164-
imagesStatusModalUrl={`/api/v2/project/${dataset.project_id}/status/images?workflowtask_id=${workflowTaskId}&dataset_id=${dataset.id}`}
159+
imagesStatusModalUrl={`/api/v2/project/${dataset.project_id}/status/images?workflowtask_id=${workflowTask.id}&dataset_id=${dataset.id}`}
165160
>
166161
<svelte:fragment slot="extra-buttons" let:image>
167162
<button

src/lib/components/v2/projects/datasets/DatasetImagesTable.svelte

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
])
231231
);
232232
233-
if (runWorkflowModal) {
233+
if (disabledTypes.length > 0) {
234234
for (const [key, typeSelector] of Object.entries(typesSelectors)) {
235235
if (disabledTypes.includes(key)) {
236236
typeSelector.disable();
@@ -239,12 +239,6 @@
239239
}
240240
}
241241
}
242-
243-
if (imagesStatusModal) {
244-
for (const selector of Object.values(typesSelectors)) {
245-
selector.disable();
246-
}
247-
}
248242
}
249243
250244
/**
@@ -363,7 +357,12 @@
363357
}
364358
}
365359
});
366-
setSlimSelectOptions(statusSelector, ['done', 'submitted', 'failed']);
360+
setSlimSelectOptions(statusSelector, [
361+
'done',
362+
'submitted',
363+
'failed',
364+
{ text: 'not processed', value: 'unset' }
365+
]);
367366
if (imagesStatusFilter) {
368367
statusSelector.setSelected(imagesStatusFilter);
369368
}
@@ -372,13 +371,15 @@
372371
/**
373372
* Updates SlimSelect options. This rebuilds the HTML elements and unset the selected value.
374373
* @param {SlimSelect|undefined} select
375-
* @param {Array<string>} values
374+
* @param {Array<string | { text: string, value: string }>} values
376375
*/
377376
function setSlimSelectOptions(select, values) {
378377
if (!select) {
379378
return;
380379
}
381-
const options = values.map((v) => ({ text: v.toString(), value: v.toString() }));
380+
const options = values.map((v) =>
381+
typeof v === 'string' ? { text: v.toString(), value: v.toString() } : v
382+
);
382383
select.setData([{ text: 'All', placeholder: true }, ...options]);
383384
}
384385
@@ -444,7 +445,8 @@
444445
headers,
445446
body: JSON.stringify(
446447
stripNullAndEmptyObjectsAndArrays({
447-
attribute_filters: attributes
448+
attribute_filters: attributes,
449+
type_filters: types
448450
})
449451
)
450452
});
@@ -644,7 +646,7 @@
644646
<colgroup>
645647
<col width="auto" />
646648
{#if imagesStatusModal}
647-
<col width="150" />
649+
<col width="190" />
648650
{/if}
649651
<!-- eslint-disable-next-line no-unused-vars -->
650652
{#each Object.keys(imagePage.attributes) as _}
@@ -752,7 +754,7 @@
752754
<td>{getRelativePath(image.zarr_url)}</td>
753755
{#if imagesStatusModal}
754756
<td>
755-
{image.status}
757+
{image.status || '-'}
756758
</td>
757759
{/if}
758760
{#each Object.keys(imagePage.attributes) as attribute}

0 commit comments

Comments
 (0)