Files
PhotonVision/chameleon-client/src/App.vue

113 lines
3.3 KiB
Vue
Raw Normal View History

<template>
2019-10-29 23:58:06 +02:00
<v-app>
<v-app-bar app dense clipped-left dark>
<img class="imgClass" src="./assets/logo.png">
<v-toolbar-title id="title">Chameleon Vision</v-toolbar-title>
<div class="flex-grow-1"></div>
<v-toolbar-items>
<v-tabs dark height="48" slider-color="#4baf62">
<v-tab to="vision">Vision</v-tab>
<v-tab to="settings">Settings</v-tab>
</v-tabs>
</v-toolbar-items>
</v-app-bar>
<v-content>
<v-container fluid fill-height>
<v-layout>
<v-flex>
<router-view @save="startTimer"/>
<v-snackbar :timeout="1000" v-model="saveSnackbar" top color="#4baf62">
<div style="text-align: center;width: 100%;">
<h4>Saved All changes</h4>
</div>
</v-snackbar>
2019-10-29 23:58:06 +02:00
</v-flex>
</v-layout>
</v-container>
</v-content>
</v-app>
2019-03-10 22:29:29 +02:00
</template>
2019-03-10 22:29:29 +02:00
<script>
2019-10-29 23:58:06 +02:00
export default {
name: 'App',
2019-08-30 21:52:48 +03:00
2019-10-29 23:58:06 +02:00
components: {},
methods: {
handleMessage(key, value) {
if (this.$store.state.hasOwnProperty(key)) {
this.$store.commit(key, value);
} else if (this.$store.state.pipeline.hasOwnProperty(key)) {
this.$store.commit('setPipeValues', {[key]: value});
} else {
switch (key) {
2019-08-30 21:52:48 +03:00
2019-10-29 23:58:06 +02:00
default: {
console.log(key + " : " + value);
}
}
}
},
saveSettings() {
clearInterval(this.timer);
this.saveSnackbar = true;
this.handleInput("command", "save");
},
startTimer() {
if (this.timer !== undefined) {
clearInterval(this.timer);
}
this.timer = setInterval(this.saveSettings, 4000);
2019-10-29 23:58:06 +02:00
}
},
data: () => ({
saveSnackbar: false,
timer: undefined
}),
2019-10-29 23:58:06 +02:00
created() {
this.$options.sockets.onmessage = async (data) => {
try {
var buffer = await data.data.arrayBuffer();
let message = this.$msgPack.decode(buffer);
for (let prop in message) {
if (message.hasOwnProperty(prop)) {
this.handleMessage(prop, message[prop]);
}
}
} catch (error) {
console.error('error: ' + data.data + " , " + error);
}
}
2019-09-16 23:54:31 +03:00
}
2019-10-29 23:58:06 +02:00
};
</script>
<style>
html {
overflow-y: hidden !important;
}
2019-10-29 23:58:06 +02:00
.imgClass {
width: auto;
height: 45px;
vertical-align: middle;
padding-right: 5px;
}
2019-10-29 23:58:06 +02:00
.tabClass {
color: #4baf62;
}
.container {
background-color: #212121;
padding: 0 !important;
}
#title {
color: #4baf62;
}
span {
color: white;
}
2019-03-16 21:47:34 +02:00
</style>