removed network resurrector server dependency
parent
b2aa4b3745
commit
0d611d2eb8
2
.env
2
.env
|
@ -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_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
|
||||
REACT_APP_MACHINE_PING_INTERVAL=600000
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PUBLIC_URL=/network-resurrector/
|
||||
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_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
|
||||
REACT_APP_MACHINE_PING_INTERVAL=900000
|
||||
|
|
|
@ -1,20 +1,25 @@
|
|||
import { get, post } from "../../utils/axios";
|
||||
|
||||
const apiUrl = `${process.env.REACT_APP_NETWORK_RESURRECTOR_API_URL}/network`;
|
||||
const serverUrl = `${process.env.REACT_APP_NETWORK_RESURRECTOR_SERVER_URL}/resurrector`;
|
||||
const networkRoute = `${process.env.REACT_APP_NETWORK_RESURRECTOR_API_URL}/network`;
|
||||
const powerActionsRoute = `${process.env.REACT_APP_NETWORK_RESURRECTOR_API_URL}/resurrector`;
|
||||
|
||||
const readMachines = () => {
|
||||
const machinesPromise = get(`${apiUrl}/machines`);
|
||||
const machinesPromise = get(`${networkRoute}/machines`);
|
||||
return machinesPromise;
|
||||
};
|
||||
|
||||
const wakeMachine = macAddress => {
|
||||
const promise = post(`${serverUrl}/wake`, { macAddress });
|
||||
return promise;
|
||||
const wakeMachine = async machineId => {
|
||||
try {
|
||||
const promise = await post(`${powerActionsRoute}/wake`, { machineId });
|
||||
return promise;
|
||||
} catch (ex) {
|
||||
debugger;
|
||||
console.log(ex);
|
||||
}
|
||||
};
|
||||
|
||||
const pingMachine = ipAddressOrMachineName => {
|
||||
const promise = post(`${serverUrl}/ping`, { ipAddressOrMachineName });
|
||||
const pingMachine = machineId => {
|
||||
const promise = post(`${powerActionsRoute}/ping`, { machineId });
|
||||
return promise;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,9 +20,7 @@ const MachineContainer = ({ machine }) => {
|
|||
|
||||
const pingMachine = useCallback(
|
||||
machine => async () => {
|
||||
const result = await api.pingMachine(
|
||||
machine.iPv4Address || machine.machineName
|
||||
);
|
||||
const result = await api.pingMachine(machine.machineId);
|
||||
addLog(`Success: ${result.success}. Status: ${result.status}`);
|
||||
if (result.success) {
|
||||
success(result.status);
|
||||
|
|
|
@ -37,7 +37,7 @@ const WakeComponent = ({ machine, addLog }) => {
|
|||
);
|
||||
|
||||
const wakeMachine = useCallback(async () => {
|
||||
const result = await api.wakeMachine(machine.macAddress);
|
||||
const result = await api.wakeMachine(machine.machineId);
|
||||
setState(prev => ({ ...prev, on: result.success }));
|
||||
log(`[Wake]: Success: ${result.success}. Status: ${result.status}`);
|
||||
if (result.success) {
|
||||
|
@ -55,10 +55,10 @@ const WakeComponent = ({ machine, addLog }) => {
|
|||
} else {
|
||||
error(result.status);
|
||||
}
|
||||
}, [log, success, error, startingTime, machine.macAddress]);
|
||||
}, [log, success, error, startingTime, machine.machineId]);
|
||||
|
||||
useEffect(() => {
|
||||
api.pingMachine(machine.iPv4Address || machine.machineName).then(result => {
|
||||
api.pingMachine(machine.machineId).then(result => {
|
||||
setState(prev => ({ ...prev, on: result.success }));
|
||||
log(`[Ping]: Success: ${result.success}. Status: ${result.status}`);
|
||||
|
||||
|
|
Loading…
Reference in New Issue