🚫 Adds stop function
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { isConnected, dataBuffer, status } from '../lib/socket';
|
||||
import { isConnected, status, socket } from '../lib/socket';
|
||||
import { Icon, Bars3, XMark, Power, Battery100, Signal, SignalSlash } from 'svelte-hero-icons';
|
||||
import { emulateModel } from '../lib/store';
|
||||
import { Link, useLocation } from 'svelte-routing'
|
||||
@@ -15,6 +15,12 @@
|
||||
|
||||
$: emulateModel.set(selected_view === views[0])
|
||||
$: settingOpen = $location.pathname.includes('/settings')
|
||||
|
||||
const stop = () => {
|
||||
if ($isConnected) {
|
||||
$socket.send(JSON.stringify({type:"system/stop"}))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -50,7 +56,7 @@
|
||||
<button class="action_button"><Icon src={$isConnected ? Signal : SignalSlash} size="24" /></button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="h-full w-20 bg-red-600 text-white">STOP</button>
|
||||
<button class="h-full w-20 bg-red-600 text-white" on:click={stop}>STOP</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
+3
-2
@@ -277,8 +277,9 @@ wss.on("connection", (ws) => {
|
||||
}
|
||||
break;
|
||||
case "system/stop":
|
||||
model.running = false;
|
||||
ws.send(JSON.stringify(settings));
|
||||
ws.clientState.model.running = false;
|
||||
ws.clientState.logs.push("[2024-02-05 19:10:00] [Warning] STOPPING SERVOS")
|
||||
ws.send(JSON.stringify({type:"log", log:ws.clientState.logs.last()}));
|
||||
break;
|
||||
default:
|
||||
ws.send(JSON.stringify({ error: "Unknown request type" }));
|
||||
|
||||
Reference in New Issue
Block a user