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>
|
<script>
|
||||||
import { DataHandler } from '@vincjo/datatables/remote';
|
import { DataHandler } from '@vincjo/datatables/remote';
|
||||||
import { format, formatDistance } from 'date-fns';
|
import { format, formatDistance } from 'date-fns';
|
||||||
import { loadData } from './api-handler';
|
import { loadData, loadCountries } from './api-handler';
|
||||||
import { onMount, onDestroy } from 'svelte';
|
import { onMount, onDestroy } from 'svelte';
|
||||||
import {
|
import {
|
||||||
DtSrRowsPerPage,
|
DtSrRowsPerPage,
|
||||||
|
@ -27,6 +27,9 @@
|
||||||
let filterStatus = -1;
|
let filterStatus = -1;
|
||||||
let checkboxCors = false;
|
let checkboxCors = false;
|
||||||
|
|
||||||
|
/** @type {{total_nodes: number, cc: string, name: string}[]} */
|
||||||
|
let countries = [];
|
||||||
|
|
||||||
const handler = new DataHandler([], { rowsPerPage: 10, totalRows: 0 });
|
const handler = new DataHandler([], { rowsPerPage: 10, totalRows: 0 });
|
||||||
let rows = handler.getRows();
|
let rows = handler.getRows();
|
||||||
|
|
||||||
|
@ -109,6 +112,9 @@
|
||||||
clearInterval(intervalId); // Clear the interval when the component is destroyed
|
clearInterval(intervalId); // Clear the interval when the component is destroyed
|
||||||
});
|
});
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
loadCountries().then((data) => {
|
||||||
|
countries = data;
|
||||||
|
});
|
||||||
handler.onChange((state) => loadData(state));
|
handler.onChange((state) => loadData(state));
|
||||||
handler.invalidate();
|
handler.invalidate();
|
||||||
});
|
});
|
||||||
|
@ -233,8 +239,7 @@
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<option value="any">Any</option>
|
<option value="any">Any</option>
|
||||||
<!--
|
{#each countries as country}
|
||||||
{#each data.countries as country}
|
|
||||||
{#if country.cc === ''}
|
{#if country.cc === ''}
|
||||||
<option value="UNKNOWN">UNKNOWN ({country.total_nodes})</option>
|
<option value="UNKNOWN">UNKNOWN ({country.total_nodes})</option>
|
||||||
{:else}
|
{:else}
|
||||||
|
@ -243,7 +248,6 @@
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
-->
|
|
||||||
</select>
|
</select>
|
||||||
</th>
|
</th>
|
||||||
<th colspan="2">
|
<th colspan="2">
|
||||||
|
|
|
@ -8,6 +8,12 @@ export const loadData = async (state) => {
|
||||||
return json.data.items ?? [];
|
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 }) => {
|
const getParams = ({ pageNumber, rowsPerPage, sort, filters }) => {
|
||||||
let params = `page=${pageNumber}&limit=${rowsPerPage}`;
|
let params = `page=${pageNumber}&limit=${rowsPerPage}`;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue