From e1056637abe84ef3381a9d33a785360cfd78465b Mon Sep 17 00:00:00 2001 From: GHOSCHT <31184695+GHOSCHT@users.noreply.github.com> Date: Mon, 14 Mar 2022 23:43:31 +0100 Subject: [PATCH] Add functional settings menu --- Dashboard/package.json | 2 + Dashboard/src/App.tsx | 90 ++------------ Dashboard/src/Components/Settings.tsx | 122 +++++++++++++------ Dashboard/src/electron.js | 3 +- Dashboard/yarn.lock | 164 ++++++++++++++++++++++++++ 5 files changed, 267 insertions(+), 114 deletions(-) diff --git a/Dashboard/package.json b/Dashboard/package.json index 6127fd8..7573eeb 100644 --- a/Dashboard/package.json +++ b/Dashboard/package.json @@ -51,6 +51,8 @@ }, "license": "ISC", "dependencies": { + "@fluentui/react": "^8.61.0", + "@fluentui/react-icons-mdl2": "^1.3.4", "@reduxjs/toolkit": "^1.7.1", "@types/jest": "^27.0.2", "@types/node": "^15.14.9", diff --git a/Dashboard/src/App.tsx b/Dashboard/src/App.tsx index d3c89de..4d914dd 100644 --- a/Dashboard/src/App.tsx +++ b/Dashboard/src/App.tsx @@ -1,11 +1,8 @@ -import React, { useState } from "react"; +import React from "react"; import { createGlobalStyle } from "styled-components"; -import Select from "react-select"; -import SerialPort from "serialport"; -import electron from "electron"; +import { registerIcons } from "@fluentui/react/lib/Styling"; +import { ChevronDownIcon, CancelIcon } from "@fluentui/react-icons-mdl2"; import KnobSection from "./Components/KnobSection"; -import { useAppDispatch } from "./redux/hooks"; -import { connect, disconnect, setSerialPort } from "./redux/slices/serialConnectionSlice"; import Settings from "./Components/Settings"; const GlobalStyle = createGlobalStyle` @@ -20,84 +17,19 @@ const GlobalStyle = createGlobalStyle` } `; -const options: [{value: string, label:string}] = [{ value: "placeholder", label: "Select Port" }]; - -const fetchPorts = async () => { - const data = await SerialPort.list(); - options.shift(); - data.forEach((comPort) => { options.push({ value: comPort.path, label: comPort.path }); }); -}; - const App = () => { - const dispatch = useAppDispatch(); - - fetchPorts(); - - const [portSelectionValue, setPortSelectionValue] = useState(options[0]); - const handlePortChange = async (selectedOption: any) => { - setPortSelectionValue(selectedOption); - dispatch(setSerialPort(selectedOption.value)); - }; - + registerIcons({ + icons: { + ChevronDown: , + Cancel: , + }, + }); return ( -
+ <> - - - - - - -