Skip to content

Commit a5a09cd

Browse files
committed
Used new pagination fields
1 parent af7880c commit a5a09cd

File tree

5 files changed

+22
-24
lines changed

5 files changed

+22
-24
lines changed

components/src/lib/types/api.d.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ export type Image = {
7575
types: { [key: string]: boolean };
7676
};
7777

78-
export type Pagination = {
78+
export type Pagination<T> = {
7979
total_count: number;
8080
page_size: number;
8181
current_page: number;
82+
items: Array<T>;
8283
};
8384

84-
export type ImagePage = Pagination & {
85+
export type ImagePage = Pagination<Image> & {
8586
attributes: { [key: string]: Array<string | number | boolean> };
8687
types: Array<string>;
87-
images: Array<Image>;
8888
};
8989

9090
export type TaskV2Type = 'non_parallel' | 'parallel' | 'compound';
@@ -276,15 +276,13 @@ export type TypeFiltersFlow = {
276276
output_filters: Array<{ [key: string]: bool }>;
277277
};
278278

279-
export type Accounting = Pagination & {
280-
records: Array<{
281-
id: number;
282-
user_id: number;
283-
timestamp: string;
284-
num_tasks: number;
285-
num_new_images: number;
286-
}>;
287-
};
279+
export type Accounting = Pagination<{
280+
id: number;
281+
user_id: number;
282+
timestamp: string;
283+
num_tasks: number;
284+
num_new_images: number;
285+
}>;
288286

289287
export type HistoryItemV2 = {
290288
id: number;

src/lib/components/admin/Accounting.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
return;
5050
}
5151
const header = ['id', 'user_id', 'user_email', 'timestamp', 'num_tasks', 'num_new_images'];
52-
const rows = accounting.records.map((record) => [
52+
const rows = accounting.items.map((record) => [
5353
record.id,
5454
record.user_id,
5555
getUserById(record.user_id)?.email || '',
@@ -190,7 +190,7 @@
190190
</tr>
191191
</thead>
192192
<tbody>
193-
{#each accounting.records as row}
193+
{#each accounting.items as row}
194194
<tr>
195195
<td>{row.id}</td>
196196
<td>{getUserById(row.user_id)?.email || row.user_id}</td>

src/lib/components/jobs/ImagesStatusModal.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/** @type {Modal} */
2525
let modal;
2626
27-
/** @type {(import('fractal-components/types/api').Pagination & {images: string[]})|undefined} */
27+
/** @type {(import('fractal-components/types/api').Pagination<string>)|undefined} */
2828
let data = undefined;
2929
3030
let loadingLogs = false;
@@ -105,7 +105,7 @@
105105
loadingLogs = false;
106106
return;
107107
}
108-
const { log } = await response.json();
108+
const log = await response.json();
109109
if (status === 'failed') {
110110
logParts = extractJobErrorParts(log, false, true);
111111
} else {
@@ -144,10 +144,10 @@
144144
</div>
145145
</div>
146146
{:else if data}
147-
{#if data.images.length > 0}
147+
{#if data.items.length > 0}
148148
<table class="table table-striped">
149149
<tbody>
150-
{#each data.images as image}
150+
{#each data.items as image}
151151
<tr>
152152
<td>{image}</td>
153153
<td>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@
403403
reloadTypeFilters(imagePage);
404404
// Go to first page if the search returns no values and we are not in the first page
405405
// This happens when we are in a given page and we restrict the search setting more filters
406-
if (imagePage.images.length === 0 && imagePage.current_page > 1) {
406+
if (imagePage.items.length === 0 && imagePage.current_page > 1) {
407407
imagePage.current_page = 1;
408408
await searchImages();
409409
}
@@ -475,7 +475,7 @@
475475
);
476476
if (response.ok) {
477477
// If we are deleting the last image of the current page go to previous page
478-
if (imagePage.images.length === 1 && imagePage.current_page > 1) {
478+
if (imagePage.items.length === 1 && imagePage.current_page > 1) {
479479
imagePage.current_page--;
480480
}
481481
await searchImages();
@@ -691,7 +691,7 @@
691691
</tr>
692692
</thead>
693693
<tbody>
694-
{#each imagePage.images as image}
694+
{#each imagePage.items as image}
695695
<tr>
696696
<td>{getRelativePath(image.zarr_url)}</td>
697697
{#each Object.keys(imagePage.attributes) as attribute}

src/routes/v2/projects/[projectId]/datasets/[datasetId]/+page.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
selectedPlate = '';
4343
return;
4444
}
45-
let imageWithPlate = imagePage.images.find((i) => i.attributes['plate'] === selectedPlate);
45+
let imageWithPlate = imagePage.items.find((i) => i.attributes['plate'] === selectedPlate);
4646
if (!imageWithPlate) {
4747
platePathLoading = true;
4848
imageWithPlate = await loadImageForSelectedPlate();
@@ -82,13 +82,13 @@
8282
}
8383
/** @type {import('fractal-components/types/api').ImagePage}*/
8484
const result = await response.json();
85-
if (result.images.length === 0) {
85+
if (result.items.length === 0) {
8686
console.error(
8787
`Unable to load image for plate ${selectedPlate}. Server replied with empty list`
8888
);
8989
return undefined;
9090
}
91-
return result.images[0];
91+
return result.items[0];
9292
}
9393
9494
async function handleExportDataset() {

0 commit comments

Comments
 (0)