feat: Half working state
This commit is contained in:
@@ -1,52 +1,25 @@
|
||||
<script setup>
|
||||
// This starter template is using Vue 3 <script setup> SFCs
|
||||
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
|
||||
import Greet from "./components/Greet.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="container">
|
||||
<h1>Welcome to Tauri!</h1>
|
||||
|
||||
<div class="row">
|
||||
<a href="https://vitejs.dev" target="_blank">
|
||||
<img src="/vite.svg" class="logo vite" alt="Vite logo" />
|
||||
</a>
|
||||
<a href="https://tauri.app" target="_blank">
|
||||
<img src="/tauri.svg" class="logo tauri" alt="Tauri logo" />
|
||||
</a>
|
||||
<a href="https://vuejs.org/" target="_blank">
|
||||
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
|
||||
</a>
|
||||
<div class="w-full flex h-screen bg-neutral-950">
|
||||
<Sidebar @updateCurrentPage="setCurrentPage" />
|
||||
<div class="w-full">
|
||||
<Main v-if="currentPage === 0" />
|
||||
<Conf v-if="currentPage === 1" />
|
||||
<Test v-if="currentPage === 2" />
|
||||
</div>
|
||||
|
||||
<p>Click on the Tauri, Vite, and Vue logos to learn more.</p>
|
||||
|
||||
<p>
|
||||
Recommended IDE setup:
|
||||
<a href="https://code.visualstudio.com/" target="_blank">VS Code</a>
|
||||
+
|
||||
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
|
||||
+
|
||||
<a href="https://github.com/tauri-apps/tauri-vscode" target="_blank"
|
||||
>Tauri</a
|
||||
>
|
||||
+
|
||||
<a href="https://github.com/rust-lang/rust-analyzer" target="_blank"
|
||||
>rust-analyzer</a
|
||||
>
|
||||
</p>
|
||||
|
||||
<Greet />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.logo.vite:hover {
|
||||
filter: drop-shadow(0 0 2em #747bff);
|
||||
}
|
||||
<script setup>
|
||||
import Sidebar from "./components/Sidebar.vue";
|
||||
import Test from "./components/Test.vue";
|
||||
import Main from "./components/Main.vue";
|
||||
import Conf from "./components/Conf.vue";
|
||||
|
||||
.logo.vue:hover {
|
||||
filter: drop-shadow(0 0 2em #249b73);
|
||||
import { ref } from "vue";
|
||||
|
||||
const currentPage = ref(2);
|
||||
|
||||
const setCurrentPage = (x) => {
|
||||
currentPage.value = x;
|
||||
}
|
||||
</style>
|
||||
</script>
|
||||
|
10
toos-dashboard/src/components/Conf.vue
Normal file
10
toos-dashboard/src/components/Conf.vue
Normal file
@@ -0,0 +1,10 @@
|
||||
<template>
|
||||
<h1 class="text-white text-2xl w-full font-bold text-center my-24">Frankenstein Test</h1>
|
||||
<div class="flex w-full justify-center">
|
||||
<Serial />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import Serial from "./conf/Serial.vue"
|
||||
</script>
|
@@ -1,21 +0,0 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
|
||||
const greetMsg = ref("");
|
||||
const name = ref("");
|
||||
|
||||
async function greet() {
|
||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
||||
greetMsg.value = await invoke("greet", { name: name.value });
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<form class="row" @submit.prevent="greet">
|
||||
<input id="greet-input" v-model="name" placeholder="Enter a name..." />
|
||||
<button type="submit">Greet</button>
|
||||
</form>
|
||||
|
||||
<p>{{ greetMsg }}</p>
|
||||
</template>
|
3
toos-dashboard/src/components/Main.vue
Normal file
3
toos-dashboard/src/components/Main.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<h1 class="text-white text-2xl w-full font-bold text-center my-24">Frankenstein Dashboard</h1>
|
||||
</template>
|
17
toos-dashboard/src/components/Sidebar.vue
Normal file
17
toos-dashboard/src/components/Sidebar.vue
Normal file
@@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<div class="bg-neutral-800 text-white font-bold w-min px-2 flex flex-col gap-10 justify-center">
|
||||
<button @click="$emit('updateCurrentPage', 0)" class="text-center bg-neutral-900 w-16 h-16 rounded-xl">
|
||||
MAIN
|
||||
</button>
|
||||
<button @click="$emit('updateCurrentPage', 1)" class="text-center bg-neutral-900 w-16 h-16 rounded-xl">
|
||||
CONF
|
||||
</button>
|
||||
<button @click="$emit('updateCurrentPage', 2)" class="text-center bg-neutral-900 w-16 h-16 rounded-xl">
|
||||
TEST
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const emit = defineEmits(['updateCurrentPage'])
|
||||
</script>
|
53
toos-dashboard/src/components/Test.vue
Normal file
53
toos-dashboard/src/components/Test.vue
Normal file
@@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<h1 class="text-white text-2xl w-full font-bold text-center my-24">Frankenstein Test</h1>
|
||||
<div class="flex w-full justify-center gap-10">
|
||||
<div class="bg-neutral-800 rounded-2xl p-5 h-min">
|
||||
<h2 class="text-white font-bold text-lg text-center my-5">LED Strip Monster</h2>
|
||||
<div class="flex flex-col items-center">
|
||||
<color-input disable-alpha v-model="color" />
|
||||
<div class="space-x-3">
|
||||
<button @click="submitColor" class="px-5 py-2 bg-sky-400 rounded my-5">
|
||||
Submit Color
|
||||
</button>
|
||||
<button class="px-3 py-2 bg-red-700 rounded my-5">
|
||||
reset
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-neutral-800 rounded-2xl p-5">
|
||||
<h2 class="text-white font-bold text-lg text-center my-5">LED Strip Hallway</h2>
|
||||
<div class="flex flex-col items-center">
|
||||
<input v-model="brightness" type="range" min="0" max="100" class="w-40">
|
||||
<label class="text-white mt-2">BRIGHTNESS: {{ brightness }}% </label>
|
||||
<button @click="submitBrightness" class="px-5 py-2 bg-sky-400 w-full rounded my-5">
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue"
|
||||
import { useSerial } from "../composables/useSerial"
|
||||
|
||||
const color = ref({ r: 0, g: 128, b: 255, a: 1});
|
||||
const brightness = ref(100);
|
||||
|
||||
const submitColor = () => {
|
||||
useSerial("SET_STRIP_COLOR:" + `${color.value.r},${color.value.g},${color.value.b}`);
|
||||
}
|
||||
|
||||
const submitBrightness = () => {
|
||||
useSerial("SET_LIGHT:" + brightness.value * 2.55);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.color-input.user .box {
|
||||
/* make clickable box a 100x100 circle */
|
||||
width: 100px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
</style>
|
42
toos-dashboard/src/components/conf/Serial.vue
Normal file
42
toos-dashboard/src/components/conf/Serial.vue
Normal file
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<div class="bg-neutral-800 rounded-2xl p-5">
|
||||
<h2 class="text-white font-bold text-lg text-center mb-5">Serial</h2>
|
||||
<div class="flex flex-col gap-y-2 items-center">
|
||||
<div class="grid grid-cols-[70px_1fr] auto-cols-auto gap-y-2">
|
||||
<label class="text-white mr-2">PORT </label>
|
||||
<input type="text" v-model="serialConfig.port">
|
||||
<label class="text-white mr-2">BAUD</label>
|
||||
<input type="number" v-model="serialConfig.baud">
|
||||
</div>
|
||||
<span class="text-white mt-3">Available ports</span>
|
||||
<span v-for="port in ports" class="text-white hover:cursor-pointer" @click="serialConfig.port = port">
|
||||
{{ port }}
|
||||
</span>
|
||||
<button @click="readSerial">READ</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from "vue";
|
||||
import { invoke } from "@tauri-apps/api/tauri"
|
||||
import { useLocalStorage } from '@vueuse/core'
|
||||
|
||||
const ports = ref([])
|
||||
|
||||
const serialConfig = useLocalStorage('serialConfig', { port: '', baud: 9600 })
|
||||
|
||||
const getSerialPorts = async () => {
|
||||
return await invoke('get_serial_ports');
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
ports.value = await getSerialPorts()
|
||||
|
||||
invoke('open_port');
|
||||
})
|
||||
|
||||
const readSerial = async () => {
|
||||
return await invoke('read_serial', { portName: "/dev/ttyUSB0" });
|
||||
}
|
||||
</script>
|
9
toos-dashboard/src/composables/useSerial.js
Normal file
9
toos-dashboard/src/composables/useSerial.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { invoke } from "@tauri-apps/api/tauri"
|
||||
import { useLocalStorage } from '@vueuse/core'
|
||||
|
||||
const serialConfig = useLocalStorage('serialConfig', { port: '', baud: 9600 })
|
||||
|
||||
export function useSerial(input) {
|
||||
console.log(serialConfig.value)
|
||||
invoke('write_serial', { input: input + ";", portName: serialConfig.value.port, baud: serialConfig.value.baud });
|
||||
}
|
7
toos-dashboard/src/composables/useStore.js
Normal file
7
toos-dashboard/src/composables/useStore.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Store } from "tauri-plugin-store-api";
|
||||
|
||||
const store = new Store(".settings.dat");
|
||||
|
||||
export function useStore() {
|
||||
return store
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
import { createApp } from "vue";
|
||||
import "./styles.css";
|
||||
import App from "./App.vue";
|
||||
import ColorInput from 'vue-color-input'
|
||||
|
||||
createApp(App).mount("#app");
|
||||
createApp(App).use(ColorInput).mount("#app");
|
||||
|
@@ -1,109 +1,9 @@
|
||||
:root {
|
||||
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
font-weight: 400;
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
color: #0f0f0f;
|
||||
background-color: #f6f6f6;
|
||||
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: 0;
|
||||
padding-top: 10vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
transition: 0.75s;
|
||||
}
|
||||
|
||||
.logo.tauri:hover {
|
||||
filter: drop-shadow(0 0 2em #24c8db);
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: 500;
|
||||
color: #646cff;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #535bf2;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
input,
|
||||
button {
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
padding: 0.6em 1.2em;
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
color: #0f0f0f;
|
||||
background-color: #ffffff;
|
||||
transition: border-color 0.25s;
|
||||
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
border-color: #396cd8;
|
||||
}
|
||||
button:active {
|
||||
border-color: #396cd8;
|
||||
background-color: #e8e8e8;
|
||||
}
|
||||
|
||||
input,
|
||||
button {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
#greet-input {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
color: #f6f6f6;
|
||||
background-color: #2f2f2f;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #24c8db;
|
||||
}
|
||||
|
||||
input,
|
||||
button {
|
||||
color: #ffffff;
|
||||
background-color: #0f0f0f98;
|
||||
}
|
||||
button:active {
|
||||
background-color: #0f0f0f69;
|
||||
@layer components {
|
||||
input {
|
||||
@apply bg-neutral-700 rounded px-2 text-white
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user