Skip to content

Commit 9267275

Browse files
committed
Updated images status modal
1 parent 614580a commit 9267275

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed

src/lib/components/jobs/ImagesStatus.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
aria-label="Submitted images"
4848
class="status-modal-btn btn btn-link text-decoration-none p-0"
4949
on:click={() =>
50-
imagesStatusModal.open(projectId, datasetId, workflowTask.id, 'submitted')}
50+
imagesStatusModal.open(projectId, datasetId, workflowTask.id)}
5151
>
5252
<span class="d-flex">
5353
<span class="pe-1 image-status text-primary">
@@ -66,7 +66,7 @@
6666
<button
6767
aria-label="Done images"
6868
class="status-modal-btn btn btn-link text-decoration-none p-0"
69-
on:click={() => imagesStatusModal.open(projectId, datasetId, workflowTask.id, 'done')}
69+
on:click={() => imagesStatusModal.open(projectId, datasetId, workflowTask.id)}
7070
>
7171
<span class="d-flex">
7272
<span class="image-status text-success ps-1">
@@ -83,7 +83,7 @@
8383
<button
8484
aria-label="Failed images"
8585
class="status-modal-btn btn btn-link text-decoration-none p-0"
86-
on:click={() => imagesStatusModal.open(projectId, datasetId, workflowTask.id, 'failed')}
86+
on:click={() => imagesStatusModal.open(projectId, datasetId, workflowTask.id)}
8787
>
8888
<span class="d-flex">
8989
<span class="image-status text-danger ps-1">

src/lib/components/jobs/ImagesStatusModal.svelte

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,25 @@
1616
let datasetId;
1717
/** @type {number} */
1818
let workflowTaskId;
19-
/** @type {string} */
20-
let status;
2119
2220
/** @type {Modal} */
2321
let modal;
2422
25-
/** @type {(import('fractal-components/types/api').Pagination<string>)|undefined} */
23+
/** @type {(import('fractal-components/types/api').Pagination<{ zarr_url: string, status: string }>)|undefined} */
2624
let data = undefined;
2725
2826
let loadingLogs = false;
2927
let selectedLogImage = '';
3028
/** @type {Array<{text: string, highlight: boolean}>} */
3129
let logParts = [];
30+
let loadedLogsStatus = '';
3231
3332
/**
3433
* @param {number} _projectId
3534
* @param {number} _datasetId
3635
* @param {number} _workflowTaskId
37-
* @param {string} _status
3836
*/
39-
export async function open(_projectId, _datasetId, _workflowTaskId, _status) {
37+
export async function open(_projectId, _datasetId, _workflowTaskId) {
4038
loading = true;
4139
data = undefined;
4240
page = 1;
@@ -47,7 +45,6 @@
4745
projectId = _projectId;
4846
datasetId = _datasetId;
4947
workflowTaskId = _workflowTaskId;
50-
status = _status;
5148
modal.show();
5249
await loadImages(page, pageSize);
5350
}
@@ -62,7 +59,7 @@
6259
*/
6360
async function loadImages(currentPage, selectedPageSize) {
6461
loading = true;
65-
const url = `/api/v2/project/${projectId}/status/images?workflowtask_id=${workflowTaskId}&dataset_id=${datasetId}&status=${status}&page=${currentPage}&page_size=${selectedPageSize}`;
62+
const url = `/api/v2/project/${projectId}/status/images?workflowtask_id=${workflowTaskId}&dataset_id=${datasetId}&page=${currentPage}&page_size=${selectedPageSize}`;
6663
const response = await fetch(url);
6764
if (!response.ok) {
6865
loading = false;
@@ -80,29 +77,28 @@
8077
8178
/**
8279
* @param {string} zarrUrl
80+
* @param {string} status
8381
*/
84-
async function loadLogs(zarrUrl) {
82+
async function loadLogs(zarrUrl, status) {
8583
loadingLogs = true;
8684
const headers = new Headers();
8785
headers.set('Content-Type', 'application/json');
88-
const response = await fetch(
89-
`/api/v2/project/${projectId}/status/image-logs?workflowtask_id=${workflowTaskId}&dataset_id=${datasetId}&zarr_url=${zarrUrl}`,
90-
{
91-
method: 'POST',
92-
headers,
93-
body: JSON.stringify({
94-
workflowtask_id: workflowTaskId,
95-
dataset_id: datasetId,
96-
zarr_url: zarrUrl
97-
})
98-
}
99-
);
86+
const response = await fetch(`/api/v2/project/${projectId}/status/image-log`, {
87+
method: 'POST',
88+
headers,
89+
body: JSON.stringify({
90+
workflowtask_id: workflowTaskId,
91+
dataset_id: datasetId,
92+
zarr_url: zarrUrl
93+
})
94+
});
10095
if (!response.ok) {
10196
modal.displayErrorAlert(await getAlertErrorFromResponse(response));
10297
loadingLogs = false;
10398
return;
10499
}
105100
const log = await response.json();
101+
loadedLogsStatus = status;
106102
if (status === 'failed') {
107103
logParts = extractJobErrorParts(log, false, true);
108104
} else {
@@ -119,7 +115,7 @@
119115
{#if selectedLogImage && !loadingLogs}
120116
Logs for {selectedLogImage}
121117
{:else}
122-
Images with status='{status}'
118+
Images
123119
{/if}
124120
</h1>
125121
</svelte:fragment>
@@ -130,7 +126,7 @@
130126
{:else if selectedLogImage && !loadingLogs}
131127
<div class="row">
132128
<div class="col">
133-
<ExpandableLog bind:logParts highlight={status === 'failed'} />
129+
<ExpandableLog bind:logParts highlight={loadedLogsStatus === 'failed'} />
134130
</div>
135131
</div>
136132
<div class="row">
@@ -143,12 +139,23 @@
143139
{:else if data}
144140
{#if data.items.length > 0}
145141
<table class="table table-striped">
142+
<thead>
143+
<tr>
144+
<th>Zarr URL</th>
145+
<th>Status</th>
146+
<th />
147+
</tr>
148+
</thead>
146149
<tbody>
147150
{#each data.items as image}
148151
<tr>
149-
<td>{image}</td>
152+
<td>{image.zarr_url}</td>
153+
<td>{image.status || '-'}</td>
150154
<td>
151-
<button class="btn btn-light" on:click={() => loadLogs(image)}>
155+
<button
156+
class="btn btn-light"
157+
on:click={() => loadLogs(image.zarr_url, image.status)}
158+
>
152159
{#if loadingLogs}
153160
<span
154161
class="spinner-border spinner-border-sm"

0 commit comments

Comments
 (0)