removed network resurrector server dependency

master
Tudor Stanciu 2022-01-18 10:21:30 +02:00
parent b2aa4b3745
commit 0d611d2eb8
5 changed files with 19 additions and 16 deletions

2
.env
View File

@ -4,7 +4,7 @@ REACT_APP_IDENTITY_AUTHENTICATION_URL=https://toodle.ddns.net/identity-server-ap
REACT_APP_NETWORK_RESURRECTOR_API_URL=http://localhost:5064 REACT_APP_NETWORK_RESURRECTOR_API_URL=http://localhost:5064
#REACT_APP_NETWORK_RESURRECTOR_SERVER_URL=http://localhost:5062 #REACT_APP_NETWORK_RESURRECTOR_SERVER_URL=http://localhost:5062
REACT_APP_NETWORK_RESURRECTOR_SERVER_URL=https://toodle.ddns.net/network-resurrector-api #REACT_APP_NETWORK_RESURRECTOR_SERVER_URL=https://toodle.ddns.net/network-resurrector-server-api
#600000 milliseconds = 10 minutes #600000 milliseconds = 10 minutes
REACT_APP_MACHINE_PING_INTERVAL=600000 REACT_APP_MACHINE_PING_INTERVAL=600000

View File

@ -1,7 +1,7 @@
PUBLIC_URL=/network-resurrector/ PUBLIC_URL=/network-resurrector/
REACT_APP_IDENTITY_AUTHENTICATION_URL=https://toodle.ddns.net/identity-server-api/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=https://toodle.ddns.net/network-resurrector-api REACT_APP_NETWORK_RESURRECTOR_API_URL=https://toodle.ddns.net/network-resurrector-api
REACT_APP_NETWORK_RESURRECTOR_SERVER_URL=https://toodle.ddns.net/network-resurrector-server-api #REACT_APP_NETWORK_RESURRECTOR_SERVER_URL=https://toodle.ddns.net/network-resurrector-server-api
#900000 milliseconds = 15 minutes #900000 milliseconds = 15 minutes
REACT_APP_MACHINE_PING_INTERVAL=900000 REACT_APP_MACHINE_PING_INTERVAL=900000

View File

@ -1,20 +1,25 @@
import { get, post } from "../../utils/axios"; import { get, post } from "../../utils/axios";
const apiUrl = `${process.env.REACT_APP_NETWORK_RESURRECTOR_API_URL}/network`; const networkRoute = `${process.env.REACT_APP_NETWORK_RESURRECTOR_API_URL}/network`;
const serverUrl = `${process.env.REACT_APP_NETWORK_RESURRECTOR_SERVER_URL}/resurrector`; const powerActionsRoute = `${process.env.REACT_APP_NETWORK_RESURRECTOR_API_URL}/resurrector`;
const readMachines = () => { const readMachines = () => {
const machinesPromise = get(`${apiUrl}/machines`); const machinesPromise = get(`${networkRoute}/machines`);
return machinesPromise; return machinesPromise;
}; };
const wakeMachine = macAddress => { const wakeMachine = async machineId => {
const promise = post(`${serverUrl}/wake`, { macAddress }); try {
return promise; const promise = await post(`${powerActionsRoute}/wake`, { machineId });
return promise;
} catch (ex) {
debugger;
console.log(ex);
}
}; };
const pingMachine = ipAddressOrMachineName => { const pingMachine = machineId => {
const promise = post(`${serverUrl}/ping`, { ipAddressOrMachineName }); const promise = post(`${powerActionsRoute}/ping`, { machineId });
return promise; return promise;
}; };

View File

@ -20,9 +20,7 @@ const MachineContainer = ({ machine }) => {
const pingMachine = useCallback( const pingMachine = useCallback(
machine => async () => { machine => async () => {
const result = await api.pingMachine( const result = await api.pingMachine(machine.machineId);
machine.iPv4Address || machine.machineName
);
addLog(`Success: ${result.success}. Status: ${result.status}`); addLog(`Success: ${result.success}. Status: ${result.status}`);
if (result.success) { if (result.success) {
success(result.status); success(result.status);

View File

@ -37,7 +37,7 @@ const WakeComponent = ({ machine, addLog }) => {
); );
const wakeMachine = useCallback(async () => { const wakeMachine = useCallback(async () => {
const result = await api.wakeMachine(machine.macAddress); const result = await api.wakeMachine(machine.machineId);
setState(prev => ({ ...prev, on: result.success })); setState(prev => ({ ...prev, on: result.success }));
log(`[Wake]: Success: ${result.success}. Status: ${result.status}`); log(`[Wake]: Success: ${result.success}. Status: ${result.status}`);
if (result.success) { if (result.success) {
@ -55,10 +55,10 @@ const WakeComponent = ({ machine, addLog }) => {
} else { } else {
error(result.status); error(result.status);
} }
}, [log, success, error, startingTime, machine.macAddress]); }, [log, success, error, startingTime, machine.machineId]);
useEffect(() => { useEffect(() => {
api.pingMachine(machine.iPv4Address || machine.machineName).then(result => { api.pingMachine(machine.machineId).then(result => {
setState(prev => ({ ...prev, on: result.success })); setState(prev => ({ ...prev, on: result.success }));
log(`[Ping]: Success: ${result.success}. Status: ${result.status}`); log(`[Ping]: Success: ${result.success}. Status: ${result.status}`);