|
16 | 16 | let datasetId; |
17 | 17 | /** @type {number} */ |
18 | 18 | let workflowTaskId; |
19 | | - /** @type {string} */ |
20 | | - let status; |
21 | 19 |
|
22 | 20 | /** @type {Modal} */ |
23 | 21 | let modal; |
24 | 22 |
|
25 | | - /** @type {(import('fractal-components/types/api').Pagination<string>)|undefined} */ |
| 23 | + /** @type {(import('fractal-components/types/api').Pagination<{ zarr_url: string, status: string }>)|undefined} */ |
26 | 24 | let data = undefined; |
27 | 25 |
|
28 | 26 | let loadingLogs = false; |
29 | 27 | let selectedLogImage = ''; |
30 | 28 | /** @type {Array<{text: string, highlight: boolean}>} */ |
31 | 29 | let logParts = []; |
| 30 | + let loadedLogsStatus = ''; |
32 | 31 |
|
33 | 32 | /** |
34 | 33 | * @param {number} _projectId |
35 | 34 | * @param {number} _datasetId |
36 | 35 | * @param {number} _workflowTaskId |
37 | | - * @param {string} _status |
38 | 36 | */ |
39 | | - export async function open(_projectId, _datasetId, _workflowTaskId, _status) { |
| 37 | + export async function open(_projectId, _datasetId, _workflowTaskId) { |
40 | 38 | loading = true; |
41 | 39 | data = undefined; |
42 | 40 | page = 1; |
|
47 | 45 | projectId = _projectId; |
48 | 46 | datasetId = _datasetId; |
49 | 47 | workflowTaskId = _workflowTaskId; |
50 | | - status = _status; |
51 | 48 | modal.show(); |
52 | 49 | await loadImages(page, pageSize); |
53 | 50 | } |
|
62 | 59 | */ |
63 | 60 | async function loadImages(currentPage, selectedPageSize) { |
64 | 61 | 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}`; |
66 | 63 | const response = await fetch(url); |
67 | 64 | if (!response.ok) { |
68 | 65 | loading = false; |
|
80 | 77 |
|
81 | 78 | /** |
82 | 79 | * @param {string} zarrUrl |
| 80 | + * @param {string} status |
83 | 81 | */ |
84 | | - async function loadLogs(zarrUrl) { |
| 82 | + async function loadLogs(zarrUrl, status) { |
85 | 83 | loadingLogs = true; |
86 | 84 | const headers = new Headers(); |
87 | 85 | 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 | + }); |
100 | 95 | if (!response.ok) { |
101 | 96 | modal.displayErrorAlert(await getAlertErrorFromResponse(response)); |
102 | 97 | loadingLogs = false; |
103 | 98 | return; |
104 | 99 | } |
105 | 100 | const log = await response.json(); |
| 101 | + loadedLogsStatus = status; |
106 | 102 | if (status === 'failed') { |
107 | 103 | logParts = extractJobErrorParts(log, false, true); |
108 | 104 | } else { |
|
119 | 115 | {#if selectedLogImage && !loadingLogs} |
120 | 116 | Logs for {selectedLogImage} |
121 | 117 | {:else} |
122 | | - Images with status='{status}' |
| 118 | + Images |
123 | 119 | {/if} |
124 | 120 | </h1> |
125 | 121 | </svelte:fragment> |
|
130 | 126 | {:else if selectedLogImage && !loadingLogs} |
131 | 127 | <div class="row"> |
132 | 128 | <div class="col"> |
133 | | - <ExpandableLog bind:logParts highlight={status === 'failed'} /> |
| 129 | + <ExpandableLog bind:logParts highlight={loadedLogsStatus === 'failed'} /> |
134 | 130 | </div> |
135 | 131 | </div> |
136 | 132 | <div class="row"> |
|
143 | 139 | {:else if data} |
144 | 140 | {#if data.items.length > 0} |
145 | 141 | <table class="table table-striped"> |
| 142 | + <thead> |
| 143 | + <tr> |
| 144 | + <th>Zarr URL</th> |
| 145 | + <th>Status</th> |
| 146 | + <th /> |
| 147 | + </tr> |
| 148 | + </thead> |
146 | 149 | <tbody> |
147 | 150 | {#each data.items as image} |
148 | 151 | <tr> |
149 | | - <td>{image}</td> |
| 152 | + <td>{image.zarr_url}</td> |
| 153 | + <td>{image.status || '-'}</td> |
150 | 154 | <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 | + > |
152 | 159 | {#if loadingLogs} |
153 | 160 | <span |
154 | 161 | class="spinner-border spinner-border-sm" |
|
0 commit comments