frontend overhaul, minor backend bugfixes

This commit is contained in:
katsu 2025-07-02 16:29:09 +02:00
parent acc38950e7
commit c1325c0eda
28 changed files with 767 additions and 481 deletions

View file

@ -14,8 +14,11 @@ const topicstrs = [ //TODO everything else
props.room + '/projectors/' + props.position + '/status/power',
props.room + '/projectors/' + props.position + '/status/shutter',
props.room + '/projectors/' + props.position + '/status/freeze',
props.room + '/projectors/' + props.position + '/status',
]
const isUnreachable = ref(false)
const subscriptions =
topicstrs.map(topic => {
// console.log('subbing to', topic)
@ -27,10 +30,12 @@ const subscriptions =
function handleIncomingMQTT(topic: string, msg: string) {
console.log('Received on', topic, 'with message', msg)
if (topic.includes('status')) {
if (topic.includes('status') && !topic.endsWith('status')) {
//console.log(topic.split('/'))
let typ = topic.split('/')[4]
handleProjectorStatus(typ, msg)
} else {
isUnreachable.value = msg.length > 1
}
}
@ -51,7 +56,7 @@ onMounted(() => {
function publishMQTTMsg(topic: string, msg: string) {
//msg = msg.toString()
console.log('Sending to [', topic, '] with message [', msg, ']')
$mqtt.publish(topic, msg, 'Qr') //todo refactor to 1 or 0 maybe
$mqtt.publish(topic, msg, 'Fnr') //todo refactor to 1 or 0 maybe
console.log('sent')
}
@ -71,20 +76,21 @@ const projStatus = reactive({
<template>
<div>
<span v-if="isUnreachable">CONNECTION FAILED</span>
<!-- TODO lepš -->
<div>
<h5>Power: {{ (projStatus.power ? "ON" : "OFF") }}</h5>
<h4>Power</h4>
<button @click="publishMQTTMsg(publishPrefix + 'power', (!projStatus.power ? '1' : '0'))">
Turn {{ projStatus.power ? 'OFF' : 'ON' }}</button>
</div>
<div :class="{ disabled: !projStatus.power }">
<div>
<h5>Shutter: {{ (projStatus.shutter ? "ON" : "OFF") }}</h5>
<h4>Shutter</h4>
<button @click="publishMQTTMsg(publishPrefix + 'shutter', (!projStatus.shutter ? '1' : '0'))">
Turn {{ projStatus.shutter ? 'OFF' : 'ON' }}</button>
</div>
<div>
<h5>Freeze image: {{ (projStatus.freeze ? "ON" : "OFF") }}</h5>
<h4>Freeze image</h4>
<button @click="publishMQTTMsg(publishPrefix + 'freeze', (!projStatus.freeze ? '1' : '0'))">
Turn {{ projStatus.freeze ? 'OFF' : 'ON' }}</button>
</div>
@ -94,7 +100,7 @@ const projStatus = reactive({
<style scoped>
.disabled {
opacity: .8;
opacity: .5;
pointer-events: none;
}
button {