refactor: remove unnecessary parameter in the fetching tool

main
Josue 4 years ago committed by Tsu-ba-me
parent 231c6dfdda
commit 8367a421c1
  1. 4
      striker-ui/components/Anvils/index.tsx
  2. 3
      striker-ui/components/CPU.tsx
  3. 3
      striker-ui/components/Memory.tsx
  4. 3
      striker-ui/components/Network/Network.tsx
  5. 3
      striker-ui/components/Nodes/index.tsx
  6. 3
      striker-ui/components/Servers.tsx
  7. 3
      striker-ui/components/SharedStorage/SharedStorage.tsx
  8. 3
      striker-ui/components/Storage.tsx
  9. 5
      striker-ui/lib/fetchers/periodicFetch.ts
  10. 3
      striker-ui/pages/index.tsx

@ -10,8 +10,8 @@ const Anvils = ({ list }: { list: AnvilList | undefined }): JSX.Element => {
list?.anvils.forEach((anvil: AnvilListItem) => {
const { data } = PeriodicFetch<AnvilStatus>(
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_status?anvil_uuid=`,
anvil.anvil_uuid,
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_status?anvil_uuid=
${anvil.anvil_uuid}`,
);
/* eslint-disable no-param-reassign */
anvils.push({

@ -10,8 +10,7 @@ const CPU = (): JSX.Element => {
const { uuid } = useContext(AnvilContext);
const { data, isLoading } = PeriodicFetch<AnvilCPU>(
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_cpu?anvil_uuid=`,
uuid,
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_cpu?anvil_uuid=${uuid}`,
);
const cpuData =

@ -10,8 +10,7 @@ import { AnvilContext } from './AnvilContext';
const Memory = (): JSX.Element => {
const { uuid } = useContext(AnvilContext);
const { data, isLoading } = PeriodicFetch<AnvilMemory>(
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_memory?anvil_uuid=`,
uuid,
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_memory?anvil_uuid=${uuid}`,
);
const memoryData = isLoading || !data ? { total: 0, free: 0 } : data;

@ -47,8 +47,7 @@ const Network = (): JSX.Element => {
const classes = useStyles();
const { data } = PeriodicFetch<AnvilNetwork>(
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_network?anvil_uuid=`,
uuid,
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_network?anvil_uuid=${uuid}`,
);
const processed = processNetworkData(data);

@ -9,8 +9,7 @@ const Nodes = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
const { uuid } = useContext(AnvilContext);
const { data } = PeriodicFetch<AnvilStatus>(
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_status?anvil_uuid=`,
uuid,
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_status?anvil_uuid=${uuid}`,
);
return (

@ -50,8 +50,7 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
const classes = useStyles();
const { data } = PeriodicFetch<AnvilServers>(
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_servers?anvil_uuid=`,
uuid,
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_servers?anvil_uuid=${uuid}`,
);
return (
<Panel>

@ -27,8 +27,7 @@ const SharedStorage = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
const classes = useStyles();
const { uuid } = useContext(AnvilContext);
const { data } = PeriodicFetch<AnvilSharedStorage>(
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_shared_storage?anvil_uuid=`,
uuid,
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_shared_storage?anvil_uuid=${uuid}`,
);
return (
<Panel>

@ -7,8 +7,7 @@ import PeriodicFetch from '../lib/fetchers/periodicFetch';
const Storage = ({ uuid }: { uuid: string }): JSX.Element => {
const { data, isLoading } = PeriodicFetch<AnvilMemory>(
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_memory?anvil_uuid=`,
uuid,
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_memory?anvil_uuid=${uuid}`,
);
const memoryData = isLoading || !data ? { total: 0, free: 0 } : data;

@ -3,10 +3,9 @@ import fetcher from './fetchJSON';
const PeriodicFetch = <T>(
url: string,
uuid: string,
refreshInterval = 2000,
refreshInterval = 5000,
): GetResponses => {
const { data, error } = useSWR<T>(`${url}${uuid}`, fetcher, {
const { data, error } = useSWR<T>(`${url}`, fetcher, {
refreshInterval,
});
return {

@ -48,8 +48,7 @@ const Home = (): JSX.Element => {
const classes = useStyles();
const { data } = PeriodicFetch<AnvilList>(
process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080',
'/anvils/get_anvils',
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_anvils`,
);
return (

Loading…
Cancel
Save