From 1d7171088841a9725b3e9e4064f29979b0b021e0 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Fri, 16 Apr 2021 00:55:18 +0300 Subject: [PATCH] read machines and set the result to state --- .env | 5 ++++- src/features/network/api.js | 10 ++++++++++ src/features/network/components/NetworkContainer.js | 9 +++------ src/state/initialState.js | 1 + 4 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 src/features/network/api.js diff --git a/.env b/.env index 4f29f9a..f4a2e96 100644 --- a/.env +++ b/.env @@ -1 +1,4 @@ -REACT_APP_IDENTITY_AUTHENTICATION_URL=http://localhost:5063/identity/authenticate?UserName={username}&Password={password} \ No newline at end of file +#REACT_APP_IDENTITY_AUTHENTICATION_URL=http://localhost:5063/identity/authenticate?UserName={username}&Password={password} + +REACT_APP_IDENTITY_AUTHENTICATION_URL=https://toodle.ddns.net/identity-server-api/identity/authenticate?UserName={username}&Password={password} +REACT_APP_NETWORK_RESURRECTOR_API_URL=http://localhost:5064 \ No newline at end of file diff --git a/src/features/network/api.js b/src/features/network/api.js new file mode 100644 index 0000000..38d1fb0 --- /dev/null +++ b/src/features/network/api.js @@ -0,0 +1,10 @@ +import { get } from "../../utils/axios"; + +const url = `${process.env.REACT_APP_NETWORK_RESURRECTOR_API_URL}/network`; + +const readMachines = () => { + const machinesPromise = get(`${url}/machines`); + return machinesPromise; +}; + +export { readMachines }; diff --git a/src/features/network/components/NetworkContainer.js b/src/features/network/components/NetworkContainer.js index 11e8477..99d5c13 100644 --- a/src/features/network/components/NetworkContainer.js +++ b/src/features/network/components/NetworkContainer.js @@ -4,7 +4,7 @@ import { ApplicationStateContext, ApplicationDispatchContext } from "../../../state/ApplicationContexts"; -import { get } from "../../../utils/axios"; +import { readMachines } from "../api"; const NetworkContainer = () => { const state = useContext(ApplicationStateContext); @@ -15,11 +15,8 @@ const NetworkContainer = () => { }; const handleReadMachines = async () => { - debugger; - const url = "http://localhost:5064/resurrector-agent/machines"; - const machines = await get(url); - - const status = "done"; + const machines = await readMachines(); + dispatchActions.onNetworkChange("machines", machines); }; return ( diff --git a/src/state/initialState.js b/src/state/initialState.js index 31c7e70..f0c99f2 100644 --- a/src/state/initialState.js +++ b/src/state/initialState.js @@ -15,6 +15,7 @@ export const initialState = { } }, network: { + machines: [], test: "" } };