Skip to content

Commit 88e7c13

Browse files
committed
Removed sorting from admin jobs table and added task type dropdown on tasks admin page
1 parent 9fa8abe commit 88e7c13

File tree

4 files changed

+57
-11
lines changed

4 files changed

+57
-11
lines changed

src/lib/components/v2/jobs/JobsList.svelte

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
* @param {Array<import('fractal-components/types/api').ApplyWorkflowV2>} jobs
140140
*/
141141
function getSortedJobs(jobs) {
142+
if (admin) {
143+
return jobs;
144+
}
142145
const sortedRows = [...jobs];
143146
const sortColumns = columns.filter(
144147
(c) => c.direction !== undefined && c.priority !== undefined && c.field
@@ -413,12 +416,14 @@
413416
{#if column.field}
414417
<th onclick={() => updateSortField(column)} style="cursor: pointer">
415418
{column.label}
416-
{#if column.direction === 'asc'}
417-
418-
{:else if column.direction === 'desc'}
419-
420-
{:else}
421-
419+
{#if !admin}
420+
{#if column.direction === 'asc'}
421+
422+
{:else if column.direction === 'desc'}
423+
424+
{:else}
425+
426+
{/if}
422427
{/if}
423428
</th>
424429
{:else}
@@ -480,23 +485,29 @@
480485
<td>
481486
<button
482487
class="btn btn-info"
488+
aria-label="Info"
483489
onclick={(event) => {
484490
event.preventDefault();
485491
jobInfoModal.show(row);
486492
}}
487493
>
488494
<i class="bi-info-circle"></i>
489-
Info
495+
{#if !admin}
496+
Info
497+
{/if}
490498
</button>
491499
<button
492500
class="btn btn-light"
501+
aria-label="Logs"
493502
onclick={(event) => {
494503
event.preventDefault();
495504
jobLogsModal.show(row, admin);
496505
}}
497506
>
498507
<i class="bi-list-columns-reverse"></i>
499-
Logs
508+
{#if !admin}
509+
Logs
510+
{/if}
500511
</button>
501512
{#if (admin && row.id) || (row.project_id !== null && row.user_email === currentUserEmail)}
502513
<a

src/routes/v2/admin/jobs/+page.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/** @type {import('fractal-components/types/api').Pagination<import('fractal-components/types/api').ApplyWorkflowV2> | undefined} */
2323
let jobs = $state();
2424
let currentPage = $state(1);
25-
let pageSize = $state(10);
25+
let pageSize = $state(50);
2626
let totalCount = $state(0);
2727
2828
let status = $state();
@@ -170,6 +170,9 @@
170170
datasetId = '';
171171
searched = false;
172172
jobs = undefined;
173+
currentPage = 1;
174+
pageSize = 50;
175+
totalCount = 0;
173176
jobsListComponent?.setJobs([]);
174177
}
175178

src/routes/v2/admin/tasks/+page.svelte

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
let id = $state('');
1010
let version = $state('');
1111
let resource = $state('');
12+
let taskType = $state('');
1213
/** @type {Array<import('fractal-components/types/api').Resource>} */
1314
const resources = $derived(page.data.resources || []);
1415
@@ -20,7 +21,7 @@
2021
/** @type {import('fractal-components/types/api').Pagination<import('fractal-components/types/api').TaskV2Info> | undefined} */
2122
let results = $state();
2223
let currentPage = $state(1);
23-
let pageSize = $state(10);
24+
let pageSize = $state(50);
2425
let totalCount = $state(0);
2526
2627
/** @type {Modal|undefined} */
@@ -51,6 +52,9 @@
5152
if (resource) {
5253
url.searchParams.append('resource_id', resource);
5354
}
55+
if (taskType) {
56+
url.searchParams.append('task_type', taskType);
57+
}
5458
url.searchParams.append('page', selectedPage.toString());
5559
url.searchParams.append('page_size', selectedPageSize.toString());
5660
const response = await fetch(url);
@@ -81,11 +85,12 @@
8185
id = '';
8286
version = '';
8387
resource = '';
88+
taskType = '';
8489
searched = false;
8590
results = undefined;
8691
currentPage = 1;
8792
totalCount = 0;
88-
pageSize = 10;
93+
pageSize = 50;
8994
}
9095
9196
/**
@@ -197,6 +202,23 @@
197202
</div>
198203
</div>
199204
</div>
205+
<div class="col-lg-4 pe-5">
206+
<div class="row mt-1">
207+
<div class="col-xl-4 col-lg-5 col-3 col-form-label">
208+
<label for="task_type">Task type</label>
209+
</div>
210+
<div class="col-xl-8 col-lg-7 col-9">
211+
<select class="form-select" bind:value={taskType} id="task_type">
212+
<option value="">Select...</option>
213+
<option value="compound">compound</option>
214+
<option value="converter_compound">converter_compound</option>
215+
<option value="non_parallel">non_parallel</option>
216+
<option value="converter_non_parallel">converter_non_parallel</option>
217+
<option value="parallel">parallel</option>
218+
</select>
219+
</div>
220+
</div>
221+
</div>
200222
</div>
201223
</div>
202224
</div>
@@ -230,6 +252,7 @@
230252
<col width="60" />
231253
<col width="auto" />
232254
<col width="90" />
255+
<col width="195" />
233256
<col width="120" />
234257
<col width="150" />
235258
<col width="100" />
@@ -239,6 +262,7 @@
239262
<th>Id</th>
240263
<th>Name</th>
241264
<th>Version</th>
265+
<th>Type</th>
242266
<th># Workflows</th>
243267
<th># Users</th>
244268
<th>Options</th>
@@ -250,6 +274,7 @@
250274
<td>{taskInfo.task.id}</td>
251275
<td>{taskInfo.task.name}</td>
252276
<td>{taskInfo.task.version || '-'}</td>
277+
<td>{taskInfo.task.type}</td>
253278
<td>
254279
{taskInfo.relationships.length || '-'}
255280
</td>

tests/v2/tasks_admin.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ test('Tasks admin page [v2]', async ({ page, workflow }) => {
7777
await waitModalClosed(page);
7878
});
7979

80+
await test.step('Search tasks by type', async () => {
81+
await reset(page);
82+
await page.getByRole('combobox', { name: 'Task type' }).selectOption('non_parallel');
83+
await searchTasks(page);
84+
await expect(page.getByRole('row', { name: 'non_parallel' }).first()).toBeVisible();
85+
});
86+
8087
await test.step('Cleanup test tasks', async () => {
8188
await workflow.openWorkflowPage();
8289
await workflow.selectTask(taskName);

0 commit comments

Comments
 (0)