chore: Adding JSdoc

This commit is contained in:
Cristian Ditaputratama 2024-05-31 17:40:02 +07:00
parent 009faa6aa8
commit db2d2195e9
Signed by: ditatompel
GPG key ID: 31D3D06D77950979

View file

@ -1,6 +1,9 @@
import { apiUri } from '$lib/utils/common'; import { apiUri } from '$lib/utils/common';
/** @param {import('@vincjo/datatables/remote/state')} state */ /**
* @typedef {import('@vincjo/datatables/remote').State} State
* @param {State} state - The state object from the data table.
*/
export const loadData = async (state) => { export const loadData = async (state) => {
const response = await fetch(apiUri(`/api/v1/nodes/logs?${getParams(state)}`)); const response = await fetch(apiUri(`/api/v1/nodes/logs?${getParams(state)}`));
const json = await response.json(); const json = await response.json();
@ -8,12 +11,14 @@ export const loadData = async (state) => {
return json.data.items ?? []; return json.data.items ?? [];
}; };
/** @param {string} nodeId */
export const loadNodeInfo = async (nodeId) => { export const loadNodeInfo = async (nodeId) => {
const response = await fetch(apiUri(`/api/v1/nodes/id/${nodeId}`)); const response = await fetch(apiUri(`/api/v1/nodes/id/${nodeId}`));
const json = await response.json(); const json = await response.json();
return json.data; return json.data;
}; };
/** @param {State} state - The state object from the data table. */
const getParams = ({ pageNumber, rowsPerPage, sort, filters }) => { const getParams = ({ pageNumber, rowsPerPage, sort, filters }) => {
let params = `page=${pageNumber}&limit=${rowsPerPage}`; let params = `page=${pageNumber}&limit=${rowsPerPage}`;