mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2025-01-08 05:52:10 +07:00
ditatompel
48fe09c1cb
This table used to store majority fee of monero nettype. By calculating majority fee via "cron" every 300s, the function to get majority fee for nettypes can be done with single query. The frontend majority static data in the frontend removed and now use `/api/v1/fees` endpoint to get majority fee value. Note: Don't know if it works well with `onload` method or not. Let see.
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import { apiUri } from '$lib/utils/common';
|
|
|
|
/**
|
|
* @typedef {import('@vincjo/datatables/remote').State} State
|
|
* @param {State} state - The state object from the data table.
|
|
*/
|
|
export const loadData = async (state) => {
|
|
const response = await fetch(apiUri(`/api/v1/nodes?${getParams(state)}`));
|
|
const json = await response.json();
|
|
state.setTotalRows(json.data.total_rows ?? 0);
|
|
return json.data.items ?? [];
|
|
};
|
|
|
|
export const loadCountries = async () => {
|
|
const response = await fetch(apiUri('/api/v1/countries'));
|
|
const json = await response.json();
|
|
return json.data ?? [];
|
|
};
|
|
|
|
export const loadFees = async () => {
|
|
const response = await fetch(apiUri('/api/v1/fees'));
|
|
const json = await response.json();
|
|
return json.data ?? [];
|
|
};
|
|
|
|
/** @param {State} state - The state object from the data table. */
|
|
const getParams = ({ pageNumber, rowsPerPage, sort, filters }) => {
|
|
let params = `page=${pageNumber}&limit=${rowsPerPage}`;
|
|
|
|
if (sort) {
|
|
params += `&sort_by=${sort.orderBy}&sort_direction=${sort.direction}`;
|
|
}
|
|
if (filters) {
|
|
params += filters.map(({ filterBy, value }) => `&${filterBy}=${value}`).join('');
|
|
}
|
|
return params;
|
|
};
|