mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2025-01-08 05:52:10 +07:00
Add pagination and fix UI total row count
This commit is contained in:
parent
1d65a4fb3e
commit
dbc07e66a8
2 changed files with 10 additions and 2 deletions
|
@ -3,7 +3,13 @@
|
|||
import { format, formatDistance } from 'date-fns';
|
||||
import { loadData } from './api-handler';
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { DtSrThSort, DtSrThFilter, DtSrRowCount } from '$lib/components/datatables/server';
|
||||
import {
|
||||
DtSrRowsPerPage,
|
||||
DtSrThSort,
|
||||
DtSrThFilter,
|
||||
DtSrRowCount,
|
||||
DtSrPagination
|
||||
} from '$lib/components/datatables/server';
|
||||
|
||||
const handler = new DataHandler([], { rowsPerPage: 10, totalRows: 0 });
|
||||
let rows = handler.getRows();
|
||||
|
@ -64,6 +70,7 @@
|
|||
|
||||
<div class="dashboard-card">
|
||||
<div class="flex justify-between">
|
||||
<DtSrRowsPerPage {handler} />
|
||||
<div class="invisible flex place-items-center md:visible">
|
||||
<label for="autoRefreshInterval">Auto Refresh:</label>
|
||||
<select
|
||||
|
@ -116,5 +123,6 @@
|
|||
|
||||
<div class="flex justify-between mb-2">
|
||||
<DtSrRowCount {handler} />
|
||||
<DtSrPagination {handler} />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -4,7 +4,7 @@ import { apiUri } from '$lib/utils/common';
|
|||
export const loadData = async (state) => {
|
||||
const response = await fetch(apiUri(`/api/v1/prober?${getParams(state)}`));
|
||||
const json = await response.json();
|
||||
state.setTotalRows(json.data.length ?? 0);
|
||||
state.setTotalRows(json.data.total_rows ?? 0);
|
||||
return json.data.items ?? [];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue