diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx b/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx index 15281362f..8936cc077 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx @@ -54,8 +54,7 @@ const IslandResetModal = (props: Props) => { @@ -91,15 +93,30 @@ const IslandResetModal = (props: Props) => { } } - function resetIsland(url: string, callback: () => void) { - auth.authFetch(url) - .then(res => res.json()) + function clearSimulationData(callback: () => void) { + auth.authFetch('/api/clear-simulation-data', {method: 'POST'}) .then(res => { - if (res['status'] === 'OK') { - callback() + if (res.status === 200) { + callback(); } }) } + function resetAll() { + auth.authFetch('/api/reset-agent-configuration', {method: 'POST'}) + .then(res => { + if (res.status === 200) { + return auth.authFetch('/api/clear-simulation-data', {method: 'POST'}) + }) + .then(res => { + if (res.status === 200) { + return auth.authFetch('/api/island-mode', {method: 'POST', body: '{"mode": "unset"}'}) + }) + .then(res => { + if (res.status !== 200) { + throw 'Error resetting the simulation' + } + }) +} function showModalButtons() { return (