mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2025-01-08 05:52:10 +07:00
Frontend display countries option
This commit is contained in:
parent
59b368d91e
commit
3acfdd2905
2 changed files with 14 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
<script>
|
||||
import { DataHandler } from '@vincjo/datatables/remote';
|
||||
import { format, formatDistance } from 'date-fns';
|
||||
import { loadData } from './api-handler';
|
||||
import { loadData, loadCountries } from './api-handler';
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import {
|
||||
DtSrRowsPerPage,
|
||||
|
@ -27,6 +27,9 @@
|
|||
let filterStatus = -1;
|
||||
let checkboxCors = false;
|
||||
|
||||
/** @type {{total_nodes: number, cc: string, name: string}[]} */
|
||||
let countries = [];
|
||||
|
||||
const handler = new DataHandler([], { rowsPerPage: 10, totalRows: 0 });
|
||||
let rows = handler.getRows();
|
||||
|
||||
|
@ -109,6 +112,9 @@
|
|||
clearInterval(intervalId); // Clear the interval when the component is destroyed
|
||||
});
|
||||
onMount(() => {
|
||||
loadCountries().then((data) => {
|
||||
countries = data;
|
||||
});
|
||||
handler.onChange((state) => loadData(state));
|
||||
handler.invalidate();
|
||||
});
|
||||
|
@ -233,8 +239,7 @@
|
|||
}}
|
||||
>
|
||||
<option value="any">Any</option>
|
||||
<!--
|
||||
{#each data.countries as country}
|
||||
{#each countries as country}
|
||||
{#if country.cc === ''}
|
||||
<option value="UNKNOWN">UNKNOWN ({country.total_nodes})</option>
|
||||
{:else}
|
||||
|
@ -243,7 +248,6 @@
|
|||
>
|
||||
{/if}
|
||||
{/each}
|
||||
-->
|
||||
</select>
|
||||
</th>
|
||||
<th colspan="2">
|
||||
|
|
|
@ -8,6 +8,12 @@ export const loadData = async (state) => {
|
|||
return json.data.items ?? [];
|
||||
};
|
||||
|
||||
export const loadCountries = async () => {
|
||||
const response = await fetch(apiUri('/api/v1/countries'));
|
||||
const json = await response.json();
|
||||
return json.data ?? [];
|
||||
};
|
||||
|
||||
const getParams = ({ pageNumber, rowsPerPage, sort, filters }) => {
|
||||
let params = `page=${pageNumber}&limit=${rowsPerPage}`;
|
||||
|
||||
|
|
Loading…
Reference in a new issue