diff --git a/app/admin_panel/src/lib/CodeBox.svelte b/app/admin_panel/src/lib/CodeBox.svelte index 4a13ec16..5456a29b 100644 --- a/app/admin_panel/src/lib/CodeBox.svelte +++ b/app/admin_panel/src/lib/CodeBox.svelte @@ -4,102 +4,15 @@ import { xml } from "@codemirror/lang-xml"; import { oneDark } from "@codemirror/theme-one-dark"; - import xmlFormat from "xml-formatter"; import { xml_schema } from "./CodeBox_Constants"; import { node_hover } from "./CodeBox_Constants"; import { behaviour_tree_xml_code } from "../store/behaviour_tree_code_store"; - import { selected_raspberry_pi_uuid } from "../store/raspberry_pi_store"; - - /** @type {string} */ - let send_behaviour_tree_text = "Send Behaviour Tree"; - - /** @type {string} */ - let send_behaviour_tree_color = "#50AA34"; - - /** @type {boolean} */ - let send_behaviour_tree_debounce = false; - - /** @type {string} */ - let start_behaviour_tree_text = "Start Behaviour Tree"; - - /** @type {string} */ - let start_behaviour_tree_color = "#89AAFF"; - - /** @type {boolean} */ - let start_behaviour_tree_debounce = false; - - async function sendBehaviourTree() { - if (send_behaviour_tree_debounce) { - return; - } - send_behaviour_tree_debounce = true; - try { - await api.sendBehaviourTree({ - data: xmlFormat.minify($behaviour_tree_xml_code), - }); - send_behaviour_tree_text = "Sent Behaviour Tree!"; - send_behaviour_tree_color = "#3457AA"; - } catch (error) { - send_behaviour_tree_text = "Unable to send Behaviour Tree!"; - send_behaviour_tree_color = "#AA3434"; - } - setTimeout(() => { - send_behaviour_tree_text = "Send Behaviour Tree"; - send_behaviour_tree_color = "#50AA34"; - send_behaviour_tree_debounce = false; - }, 1000); - } - - async function startBehaviourTree() { - if (start_behaviour_tree_debounce) { - return; - } - start_behaviour_tree_debounce = true; - try { - await api.startBehaviourTree(); - start_behaviour_tree_text = "Started Behaviour Tree!"; - start_behaviour_tree_color = "#4277FF"; - } catch (error) { - start_behaviour_tree_text = "Unable to start Behaviour Tree!"; - start_behaviour_tree_color = "#AA3434"; - } - setTimeout(() => { - start_behaviour_tree_text = "Start Behaviour Tree"; - start_behaviour_tree_color = "#89AAFF"; - start_behaviour_tree_debounce = false; - }, 1000); - } - - async function stopBehaviourTree() { - await api.stopBehaviourTree(); - } + import CodeMessagingBar from "./CodeMessagingBar.svelte";