Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c8b27813ae | ||
![]() |
802f1c71db | ||
![]() |
0a35ac49b9 | ||
![]() |
ce3de4c1e3 | ||
![]() |
1c7a8de4e1 | ||
![]() |
a5303ff232 |
@@ -7,10 +7,11 @@
|
|||||||
dense
|
dense
|
||||||
:nodes="dbmData"
|
:nodes="dbmData"
|
||||||
node-key="key"
|
node-key="key"
|
||||||
:default-expand-all="true"
|
:default-expand-all="false"
|
||||||
|
v-model:expanded="expanded"
|
||||||
>
|
>
|
||||||
<template v-slot:[`default-header`]="props">
|
<template v-slot:[`default-header`]="props">
|
||||||
<div class="row items-center text-blue">
|
<div class="row items-center text-blue" @click="ClickNode(props.node)">
|
||||||
<div
|
<div
|
||||||
class="row items-center text-blue"
|
class="row items-center text-blue"
|
||||||
@contextmenu.prevent="openContextMenu($event, props.node)"
|
@contextmenu.prevent="openContextMenu($event, props.node)"
|
||||||
@@ -25,12 +26,12 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<q-popup-edit
|
<q-popup-edit
|
||||||
v-if="props.node.value !== undefined"
|
v-if="props.node.value !== undefined && props.node.value !== ''"
|
||||||
v-model="props.node.value"
|
v-model="props.node.value"
|
||||||
class="q-ml-xl bg-grey text-white"
|
class="q-ml-xl bg-grey text-white"
|
||||||
@save="(val) => onValueEdit(val, props.node)"
|
@save="(val) => onValueEdit(val, props.node)"
|
||||||
>
|
>
|
||||||
<template v-if="props.node.value !== undefined" v-slot="scope">
|
<template v-slot="scope">
|
||||||
<q-input
|
<q-input
|
||||||
dark
|
dark
|
||||||
color="white"
|
color="white"
|
||||||
@@ -56,29 +57,34 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import type { TreeNode } from 'src/composables/dbmTree';
|
import type { TreeNode } from 'src/composables/dbmTree';
|
||||||
import { subs, dbmData, buildTree } from 'src/composables/dbmTree';
|
import {
|
||||||
|
dbmData,
|
||||||
|
buildTree,
|
||||||
|
// addChildrentoTree,
|
||||||
|
getSubscriptionsByUuid,
|
||||||
|
addChildrentoTree,
|
||||||
|
removeSubtreeByParentKey,
|
||||||
|
} from 'src/composables/dbmTree';
|
||||||
import { openContextMenu } from 'src/composables/useContextMenu';
|
import { openContextMenu } from 'src/composables/useContextMenu';
|
||||||
import SubMenu from 'src/components/SubMenu.vue';
|
import SubMenu from 'src/components/SubMenu.vue';
|
||||||
import { QCard } from 'quasar';
|
import { QCard } from 'quasar';
|
||||||
import { send } from 'src/services/websocket';
|
import { send } from 'src/services/websocket';
|
||||||
|
import { onBeforeRouteLeave } from 'vue-router';
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
send({
|
send({
|
||||||
subscribe: [
|
subscribe: [
|
||||||
{
|
{
|
||||||
path: '.*',
|
path: '.*',
|
||||||
depth: 2,
|
depth: 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response?.subscribe) {
|
if (response?.subscribe) {
|
||||||
subs.value = response.subscribe;
|
dbmData.value = buildTree(response.subscribe ?? []);
|
||||||
dbmData.value = buildTree(subs.value);
|
|
||||||
} else {
|
|
||||||
console.log('Response from server:', response);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@@ -86,16 +92,95 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// function updateValue(uuid: string, newValue: string) {
|
onBeforeRouteLeave((to, from, next) => {
|
||||||
// const target = subs.value.find((s) => s.uuid === uuid);
|
send({
|
||||||
// if (target) {
|
unsubscribe: [
|
||||||
// target.value = newValue;
|
{
|
||||||
// treeData.value = buildTree(subs.value);
|
path: '.*',
|
||||||
// }
|
depth: 0,
|
||||||
// }
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
if (response?.subscribe) {
|
||||||
|
dbmData.value = buildTree(response.subscribe ?? []);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('Error fetching data:', err);
|
||||||
|
});
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
|
const expanded = ref<string[]>([]);
|
||||||
|
|
||||||
|
function ClickNode(node: TreeNode) {
|
||||||
|
if (node.key === 'DBM') return;
|
||||||
|
|
||||||
|
const nodeKey = node.key as string;
|
||||||
|
|
||||||
|
const isExpanded = expanded.value.includes(nodeKey);
|
||||||
|
|
||||||
|
if (isExpanded) {
|
||||||
|
// Collapse the parent node and its children
|
||||||
|
//expanded.value = expanded.value.filter((k) => k !== nodeKey && !k.startsWith(nodeKey));
|
||||||
|
|
||||||
|
// 2. Send unsubscribe request
|
||||||
|
send({
|
||||||
|
unsubscribe: [
|
||||||
|
{
|
||||||
|
uuid: nodeKey,
|
||||||
|
path: '.*',
|
||||||
|
depth: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
if (response?.unsubscribe) {
|
||||||
|
removeSubtreeByParentKey(nodeKey);
|
||||||
|
}
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
expanded.value = expanded.value.filter((k) => k !== nodeKey && !k.startsWith(nodeKey));
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('Error during unsubscribe:', err);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. Do not continue further — important!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. If not expanded, send subscribe and expand
|
||||||
|
send({
|
||||||
|
subscribe: [
|
||||||
|
{
|
||||||
|
uuid: nodeKey,
|
||||||
|
path: '.*',
|
||||||
|
depth: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
if (response?.subscribe) {
|
||||||
|
addChildrentoTree(response.subscribe);
|
||||||
|
|
||||||
|
// Delay to ensure reactive updates apply cleanly
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
if (!expanded.value.includes(nodeKey)) {
|
||||||
|
expanded.value.push(nodeKey);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('Error during subscribe:', err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function onValueEdit(newValue: undefined, node: TreeNode) {
|
function onValueEdit(newValue: undefined, node: TreeNode) {
|
||||||
const sub = subs.value.find((s) => s.uuid === node.key);
|
console.log(node.value, node.value === undefined);
|
||||||
|
const sub = getSubscriptionsByUuid(node.key);
|
||||||
if (sub) {
|
if (sub) {
|
||||||
send({
|
send({
|
||||||
set: [
|
set: [
|
||||||
|
@@ -95,15 +95,22 @@
|
|||||||
color="purple"
|
color="purple"
|
||||||
style="opacity: 0.8"
|
style="opacity: 0.8"
|
||||||
/>
|
/>
|
||||||
|
<div class="colums q-ma-xl">
|
||||||
|
<q-btn color="secondary" @click="settings = !settings" icon="settings">Settings</q-btn>
|
||||||
|
<SettingDialog :settings-dialog="settings"></SettingDialog>
|
||||||
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { watch, reactive } from 'vue';
|
import { watch, reactive, ref } from 'vue';
|
||||||
import type { Light } from 'src/models/Light';
|
import type { Light } from 'src/models/Light';
|
||||||
import { send } from 'src/services/websocket';
|
import { send } from 'src/services/websocket';
|
||||||
|
import SettingDialog from 'src/components/SettingDomeLight.vue';
|
||||||
|
|
||||||
|
const settings = ref(false);
|
||||||
|
|
||||||
const light = reactive<Light>({
|
const light = reactive<Light>({
|
||||||
State: false,
|
State: false,
|
@@ -4,7 +4,7 @@
|
|||||||
<q-slider
|
<q-slider
|
||||||
class="q-mr-sm"
|
class="q-mr-sm"
|
||||||
vertical
|
vertical
|
||||||
reverse
|
:reverse="!props.reverseTilt"
|
||||||
v-model="tilt"
|
v-model="tilt"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="100"
|
:max="100"
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
touch-action: none;
|
||||||
"
|
"
|
||||||
@mousedown="startDrag"
|
@mousedown="startDrag"
|
||||||
@touchstart="startTouch"
|
@touchstart="startTouch"
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<q-item-label class="text-bold">Pan</q-item-label>
|
<q-item-label class="text-bold">Pan</q-item-label>
|
||||||
<q-slider
|
<q-slider
|
||||||
|
:reverse="props.reversePan"
|
||||||
class="q-ml-sm"
|
class="q-ml-sm"
|
||||||
v-model="pan"
|
v-model="pan"
|
||||||
:min="0"
|
:min="0"
|
||||||
@@ -46,18 +48,22 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed, defineModel } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
|
|
||||||
const pad = ref<HTMLElement | null>(null);
|
const pad = ref<HTMLElement | null>(null);
|
||||||
const dragging = ref(false);
|
const dragging = ref(false);
|
||||||
|
|
||||||
const pan = defineModel<number>('pan', { default: 0 });
|
const pan = defineModel<number>('pan', { default: 0 });
|
||||||
const tilt = defineModel<number>('tilt', { default: 0 });
|
const tilt = defineModel<number>('tilt', { default: 0 });
|
||||||
|
const props = defineProps<{
|
||||||
|
reversePan: boolean;
|
||||||
|
reverseTilt: boolean;
|
||||||
|
}>();
|
||||||
|
|
||||||
const markerStyle = computed(() => ({
|
const markerStyle = computed(() => ({
|
||||||
position: 'absolute' as const,
|
position: 'absolute' as const,
|
||||||
top: `${2 * (100 - tilt.value)}px`,
|
top: `${2 * (props.reverseTilt ? tilt.value : 100 - tilt.value)}px`,
|
||||||
left: `${2 * pan.value}px`,
|
left: `${2 * (props.reversePan ? 100 - pan.value : pan.value)}px`,
|
||||||
width: '12px',
|
width: '12px',
|
||||||
height: '12px',
|
height: '12px',
|
||||||
borderRadius: '50%',
|
borderRadius: '50%',
|
||||||
@@ -74,11 +80,6 @@ function startDrag(e: MouseEvent) {
|
|||||||
window.addEventListener('mouseup', stopDrag);
|
window.addEventListener('mouseup', stopDrag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDrag(e: MouseEvent) {
|
|
||||||
if (!dragging.value) return;
|
|
||||||
updatePosition(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopDrag() {
|
function stopDrag() {
|
||||||
dragging.value = false;
|
dragging.value = false;
|
||||||
window.removeEventListener('mousemove', onDrag);
|
window.removeEventListener('mousemove', onDrag);
|
||||||
@@ -86,21 +87,29 @@ function stopDrag() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startTouch(e: TouchEvent) {
|
function startTouch(e: TouchEvent) {
|
||||||
|
e.preventDefault(); // ✅ block scroll
|
||||||
const touch = e.touches[0];
|
const touch = e.touches[0];
|
||||||
if (!touch) return;
|
if (!touch) return;
|
||||||
dragging.value = true;
|
dragging.value = true;
|
||||||
updatePosition(touch);
|
updatePosition(touch);
|
||||||
window.addEventListener('touchmove', onTouch);
|
window.addEventListener('touchmove', onTouch, { passive: false });
|
||||||
window.addEventListener('touchend', stopTouch);
|
window.addEventListener('touchend', stopTouch);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTouch(e: TouchEvent) {
|
function onTouch(e: TouchEvent) {
|
||||||
|
e.preventDefault(); // ✅ block scroll
|
||||||
if (!dragging.value) return;
|
if (!dragging.value) return;
|
||||||
const touch = e.touches[0];
|
const touch = e.touches[0];
|
||||||
if (!touch) return;
|
if (!touch) return;
|
||||||
updatePosition(touch);
|
updatePosition(touch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onDrag(e: MouseEvent) {
|
||||||
|
e.preventDefault(); // optional, for extra safety
|
||||||
|
if (!dragging.value) return;
|
||||||
|
updatePosition(e);
|
||||||
|
}
|
||||||
|
|
||||||
function stopTouch() {
|
function stopTouch() {
|
||||||
dragging.value = false;
|
dragging.value = false;
|
||||||
window.removeEventListener('touchmove', onTouch);
|
window.removeEventListener('touchmove', onTouch);
|
||||||
@@ -109,11 +118,16 @@ function stopTouch() {
|
|||||||
|
|
||||||
function updatePosition(e: MouseEvent | Touch) {
|
function updatePosition(e: MouseEvent | Touch) {
|
||||||
if (!pad.value) return;
|
if (!pad.value) return;
|
||||||
|
|
||||||
const rect = pad.value.getBoundingClientRect();
|
const rect = pad.value.getBoundingClientRect();
|
||||||
const newX = Math.min(Math.max(0, e.clientX - rect.left), rect.width);
|
const newX = Math.min(Math.max(0, e.clientX - rect.left), rect.width);
|
||||||
const newY = Math.min(Math.max(0, e.clientY - rect.top), rect.height);
|
const newY = Math.min(Math.max(0, e.clientY - rect.top), rect.height);
|
||||||
|
|
||||||
pan.value = Math.round((newX / rect.width) * 100);
|
pan.value = props.reversePan
|
||||||
tilt.value = Math.round(100 - (newY / rect.height) * 100);
|
? Math.round((1 - newX / rect.width) * 100)
|
||||||
|
: Math.round((newX / rect.width) * 100);
|
||||||
|
tilt.value = props.reverseTilt
|
||||||
|
? Math.round((newY / rect.height) * 100)
|
||||||
|
: Math.round(100 - (newY / rect.height) * 100);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@@ -97,10 +97,21 @@ select
|
|||||||
color="black"
|
color="black"
|
||||||
style="opacity: 1"
|
style="opacity: 1"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="column items-center q-ml-sm">
|
<div class="column items-center q-ml-sm">
|
||||||
<DragPad v-model:pan="pan" v-model:tilt="tilt" />
|
<DragPad
|
||||||
{{ pan }} {{ tilt }}
|
v-model:pan="pan"
|
||||||
|
v-model:reverse-pan="reversePan"
|
||||||
|
v-model:tilt="tilt"
|
||||||
|
v-model:reverse-tilt="reverseTilt"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="colums q-ma-xl">
|
||||||
|
<q-btn color="secondary" @click="settings = !settings" icon="settings">Settings</q-btn>
|
||||||
|
<SettingDialog
|
||||||
|
:settings-dialog="settings"
|
||||||
|
v-model:reverse-pan="reversePan"
|
||||||
|
v-model:reverse-tilt="reverseTilt"
|
||||||
|
></SettingDialog>
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
@@ -108,10 +119,12 @@ select
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted } from 'vue';
|
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
||||||
import { send } from 'src/services/websocket';
|
import { send } from 'src/services/websocket';
|
||||||
import { subs, buildTree, dbmData } from 'src/composables/dbmTree';
|
import { LocalStorage } from 'quasar';
|
||||||
|
import { getSubscriptionsByPath, buildTree, dbmData } from 'src/composables/dbmTree';
|
||||||
import DragPad from './DragPad.vue';
|
import DragPad from './DragPad.vue';
|
||||||
|
import SettingDialog from './SettingMovingHead.vue';
|
||||||
|
|
||||||
const red = updateValue('MovingHead:Red', true);
|
const red = updateValue('MovingHead:Red', true);
|
||||||
const green = updateValue('MovingHead:Green', true);
|
const green = updateValue('MovingHead:Green', true);
|
||||||
@@ -122,20 +135,46 @@ const pan = updateValue('MovingHead:Pan', true);
|
|||||||
const tilt = updateValue('MovingHead:Tilt', true);
|
const tilt = updateValue('MovingHead:Tilt', true);
|
||||||
const zoom = updateValue('MovingHead:Zoom');
|
const zoom = updateValue('MovingHead:Zoom');
|
||||||
const state = updateValue('MovingHead:State');
|
const state = updateValue('MovingHead:State');
|
||||||
|
const settings = ref(false);
|
||||||
|
const reversePan = ref(false);
|
||||||
|
const reverseTilt = ref(false);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
reversePan.value = LocalStorage.getItem('reversePan') ?? false;
|
||||||
|
reverseTilt.value = LocalStorage.getItem('reverseTilt') ?? false;
|
||||||
|
|
||||||
send({
|
send({
|
||||||
subscribe: [
|
subscribe: [
|
||||||
{
|
{
|
||||||
path: '.*',
|
path: 'MovingHead:.*',
|
||||||
depth: 2,
|
depth: 0,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response?.subscribe) {
|
if (response?.subscribe) {
|
||||||
subs.value = response.subscribe;
|
dbmData.value = buildTree(response.subscribe ?? []);
|
||||||
dbmData.value = buildTree(subs.value);
|
} else {
|
||||||
|
console.log('Response from server:', response);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('Error fetching data:', err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
send({
|
||||||
|
unsubscribe: [
|
||||||
|
{
|
||||||
|
path: 'MovingHead:.*',
|
||||||
|
depth: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
if (response?.subscribe) {
|
||||||
|
dbmData.value = buildTree(response.subscribe ?? []);
|
||||||
} else {
|
} else {
|
||||||
console.log('Response from server:', response);
|
console.log('Response from server:', response);
|
||||||
}
|
}
|
||||||
@@ -161,7 +200,7 @@ function changeState() {
|
|||||||
function updateValue(path: string, isDouble = false) {
|
function updateValue(path: string, isDouble = false) {
|
||||||
return computed({
|
return computed({
|
||||||
get() {
|
get() {
|
||||||
const sub = subs.value.find((s) => s.path === path);
|
const sub = getSubscriptionsByPath(path);
|
||||||
const value = sub ? Number(sub.value ?? 0) : 0;
|
const value = sub ? Number(sub.value ?? 0) : 0;
|
||||||
return isDouble ? Math.round((100 / 255) * value) : Math.round((100 / 255) * value);
|
return isDouble ? Math.round((100 / 255) * value) : Math.round((100 / 255) * value);
|
||||||
},
|
},
|
||||||
@@ -183,7 +222,7 @@ function updateValue(path: string, isDouble = false) {
|
|||||||
function updateBrightnessValue(path: string) {
|
function updateBrightnessValue(path: string) {
|
||||||
return computed({
|
return computed({
|
||||||
get() {
|
get() {
|
||||||
const sub = subs.value.find((s) => s.path === path);
|
const sub = getSubscriptionsByPath(path);
|
||||||
const value = sub ? Number(sub.value ?? 0) : 0;
|
const value = sub ? Number(sub.value ?? 0) : 0;
|
||||||
return Math.round((100 / 255) * value);
|
return Math.round((100 / 255) * value);
|
||||||
},
|
},
|
||||||
|
27
src/components/SettingDomeLight.vue
Normal file
27
src/components/SettingDomeLight.vue
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<template>
|
||||||
|
<q-dialog v-model="settingsDialog">
|
||||||
|
<q-card style="min-width: 300px">
|
||||||
|
<q-card-section>
|
||||||
|
<div class="text-h6">Settings</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-card-section>
|
||||||
|
<q-btn>Normal</q-btn>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section> </q-card-section>
|
||||||
|
<q-card-actions align="right">
|
||||||
|
<q-btn flat label="Cancel" v-close-popup />
|
||||||
|
<q-btn flat label="Save" @click="saveSettings" />
|
||||||
|
</q-card-actions>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const settingsDialog = defineModel<boolean>('settingsDialog', { default: false, required: true });
|
||||||
|
|
||||||
|
function saveSettings() {
|
||||||
|
// Save logic here
|
||||||
|
settingsDialog.value = false;
|
||||||
|
}
|
||||||
|
</script>
|
50
src/components/SettingMovingHead.vue
Normal file
50
src/components/SettingMovingHead.vue
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<template>
|
||||||
|
<q-dialog v-model="settingsDialog">
|
||||||
|
<q-card style="min-width: 300px">
|
||||||
|
<q-card-section>
|
||||||
|
<div class="text-h6">Settings</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-card-section>
|
||||||
|
<q-btn
|
||||||
|
:icon="!reverseTilt ? 'swap_vert' : undefined"
|
||||||
|
:icon-right="reverseTilt ? 'swap_vert' : undefined"
|
||||||
|
@click="reverseTilt = !reverseTilt"
|
||||||
|
>{{ reverseTilt ? 'Reversed Tilt' : 'Normal Tilt' }}</q-btn
|
||||||
|
>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section>
|
||||||
|
<q-btn
|
||||||
|
:icon="!reversePan ? 'swap_vert' : undefined"
|
||||||
|
:icon-right="reversePan ? 'swap_vert' : undefined"
|
||||||
|
@click="reversePan = !reversePan"
|
||||||
|
>{{ reversePan ? 'Reversed Pan' : 'Normal Pan' }}</q-btn
|
||||||
|
>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section>
|
||||||
|
<q-input type="number" label="Start Address" v-model:model-value="startAddress"></q-input>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-actions align="right">
|
||||||
|
<q-btn flat label="Cancel" v-close-popup />
|
||||||
|
<q-btn flat label="Save" @click="saveSettings" />
|
||||||
|
</q-card-actions>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { LocalStorage } from 'quasar';
|
||||||
|
const settingsDialog = defineModel<boolean>('settingsDialog', { default: false, required: true });
|
||||||
|
const reversePan = defineModel<boolean>('reversePan', { default: false, required: true });
|
||||||
|
const reverseTilt = defineModel<boolean>('reverseTilt', { default: false, required: true });
|
||||||
|
const startAddress = defineModel<number>('startAddress', { default: 0 });
|
||||||
|
|
||||||
|
function saveSettings() {
|
||||||
|
LocalStorage.set('reversePan', reversePan.value);
|
||||||
|
LocalStorage.set('reverseTilt', reverseTilt.value);
|
||||||
|
|
||||||
|
console.log(88, startAddress.value);
|
||||||
|
|
||||||
|
settingsDialog.value = false;
|
||||||
|
}
|
||||||
|
</script>
|
@@ -17,6 +17,7 @@ import { send } from 'src/services/websocket';
|
|||||||
|
|
||||||
function handleAction(action: string) {
|
function handleAction(action: string) {
|
||||||
console.log(`Action '${action}' on node:`, contextMenu.value.node);
|
console.log(`Action '${action}' on node:`, contextMenu.value.node);
|
||||||
|
|
||||||
// Add your actual logic here
|
// Add your actual logic here
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'Add':
|
case 'Add':
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
import type { Subs } from 'src/models/Subscribe';
|
import type { Subs } from 'src/models/Subscribe';
|
||||||
import { ref } from 'vue';
|
import { ref, nextTick } from 'vue';
|
||||||
|
|
||||||
export const dbmData = ref<TreeNode[]>(buildTree([]));
|
const Subscriptions = ref<Subs>([]);
|
||||||
|
|
||||||
export const subs = ref<Subs>([]);
|
export const dbmData = ref<TreeNode[]>([]);
|
||||||
|
|
||||||
export interface TreeNode {
|
export interface TreeNode {
|
||||||
path: string;
|
path: string | undefined;
|
||||||
key?: string; // optional: useful for QTree's node-key
|
key?: string; // optional: useful for QTree's node-key
|
||||||
value?: string | undefined;
|
value?: string | number | boolean | undefined;
|
||||||
children?: TreeNode[];
|
children?: TreeNode[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,6 +23,8 @@ export function buildTree(subs: Subs): TreeNode[] {
|
|||||||
|
|
||||||
const root: TreeMap = {};
|
const root: TreeMap = {};
|
||||||
|
|
||||||
|
Subscriptions.value = subs;
|
||||||
|
|
||||||
for (const item of subs) {
|
for (const item of subs) {
|
||||||
const pathParts = item.path?.split(':') ?? [];
|
const pathParts = item.path?.split(':') ?? [];
|
||||||
let current = root;
|
let current = root;
|
||||||
@@ -63,3 +65,46 @@ export function buildTree(subs: Subs): TreeNode[] {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getTreeElementByPath(path: string) {
|
||||||
|
return dbmData.value.find((s) => s.path === path);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSubscriptionsByUuid(uid: string | undefined) {
|
||||||
|
return Subscriptions.value.find((s) => s.uuid === uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addChildrentoTree(subs: Subs) {
|
||||||
|
Subscriptions.value.push(...subs);
|
||||||
|
void nextTick(() => {
|
||||||
|
dbmData.value = buildTree(Subscriptions.value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeSubtreeByParentKey(parentKey: string) {
|
||||||
|
// Find the parent node using its uuid
|
||||||
|
const parent = Subscriptions.value.find((s) => s.uuid === parentKey);
|
||||||
|
if (!parent || !parent.path) return;
|
||||||
|
|
||||||
|
const parentPath = parent.path;
|
||||||
|
|
||||||
|
// Now filter out the children, but NOT the parent itself
|
||||||
|
Subscriptions.value = Subscriptions.value.filter((s) => {
|
||||||
|
// Keep the parent itself (don't remove it)
|
||||||
|
if (s.uuid === parentKey) return true;
|
||||||
|
|
||||||
|
// Remove any child whose path starts with parentPath + '/' (descendants)
|
||||||
|
return !s.path?.startsWith(parentPath + ':');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Rebuild the tree after removing children, but keeping the parent
|
||||||
|
dbmData.value = buildTree(Subscriptions.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSubscriptionsByPath(path: string) {
|
||||||
|
return Subscriptions.value.find((s) => s.path === path);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAllSubscriptions() {
|
||||||
|
return Subscriptions.value;
|
||||||
|
}
|
||||||
|
@@ -7,5 +7,6 @@ export type Response = {
|
|||||||
get?: Gets;
|
get?: Gets;
|
||||||
set?: Sets;
|
set?: Sets;
|
||||||
subscribe?: Subs;
|
subscribe?: Subs;
|
||||||
|
unsubscribe?: Subs;
|
||||||
publish?: Pubs;
|
publish?: Pubs;
|
||||||
};
|
};
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
export type Subscribe = {
|
export type Subscribe = {
|
||||||
uuid?: string;
|
uuid?: string | undefined;
|
||||||
path?: string;
|
path?: string | undefined;
|
||||||
depth?: number;
|
depth?: number;
|
||||||
value?: string | number | boolean | undefined;
|
value?: string | number | boolean | undefined;
|
||||||
};
|
};
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
<template>
|
<template>
|
||||||
<h1>Test Page</h1>
|
|
||||||
<DBMTree></DBMTree>
|
<DBMTree></DBMTree>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@@ -1,9 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<q-page>
|
<q-page>
|
||||||
<moving-head></moving-head>
|
<q-tabs v-model="tab">
|
||||||
|
<q-tab name="movingHead" label="Moving Head" />
|
||||||
|
<q-tab name="dome" label="Dome" />
|
||||||
|
</q-tabs>
|
||||||
|
<q-tab-panels v-model="tab" animated class="text-white">
|
||||||
|
<q-tab-panel name="movingHead">
|
||||||
|
<moving-head />
|
||||||
|
</q-tab-panel>
|
||||||
|
<q-tab-panel name="dome">
|
||||||
|
<Dome />
|
||||||
|
</q-tab-panel>
|
||||||
|
</q-tab-panels>
|
||||||
</q-page>
|
</q-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import MovingHead from 'src/components/MovingHead.vue';
|
import MovingHead from 'src/components/MovingHead.vue';
|
||||||
|
import Dome from 'src/components/DomeLight.vue';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
const tab = ref('movingHead');
|
||||||
</script>
|
</script>
|
||||||
|
@@ -2,10 +2,16 @@ import type { Response } from 'src/models/Response';
|
|||||||
import type { Publish } from 'src/models/Publish';
|
import type { Publish } from 'src/models/Publish';
|
||||||
import type { Request } from 'src/models/Request';
|
import type { Request } from 'src/models/Request';
|
||||||
import type { QVueGlobals } from 'quasar';
|
import type { QVueGlobals } from 'quasar';
|
||||||
import { subs, buildTree, dbmData } from 'src/composables/dbmTree';
|
import {
|
||||||
import { ref } from 'vue';
|
getAllSubscriptions,
|
||||||
|
getSubscriptionsByPath,
|
||||||
|
buildTree,
|
||||||
|
dbmData,
|
||||||
|
} from 'src/composables/dbmTree';
|
||||||
|
import { ref, reactive } from 'vue';
|
||||||
|
|
||||||
const pendingResponses = new Map<string, (data: Response | undefined) => void>();
|
const pendingResponses = new Map<string, (data: Response | undefined) => void>();
|
||||||
|
export const lastKnownValues = reactive(new Map<string, string>());
|
||||||
|
|
||||||
export let socket: WebSocket | null = null;
|
export let socket: WebSocket | null = null;
|
||||||
const isConnected = ref(false);
|
const isConnected = ref(false);
|
||||||
@@ -47,16 +53,38 @@ export function initWebSocket(url: string, $q?: QVueGlobals) {
|
|||||||
if (id && pendingResponses.has(id)) {
|
if (id && pendingResponses.has(id)) {
|
||||||
pendingResponses.get(id)?.(message); // resolve the promise
|
pendingResponses.get(id)?.(message); // resolve the promise
|
||||||
pendingResponses.delete(id);
|
pendingResponses.delete(id);
|
||||||
} else if (message.publish) {
|
return;
|
||||||
message.publish.forEach((pub: Publish) => {
|
}
|
||||||
const target = subs.value.find((s) => s.path === pub.path);
|
|
||||||
if (target) {
|
if (message.publish) {
|
||||||
target.value = pub.value ?? '';
|
let changed = false;
|
||||||
|
|
||||||
|
(message.publish as Publish[]).forEach((pub) => {
|
||||||
|
const path = pub.path;
|
||||||
|
const value = pub.value ?? '';
|
||||||
|
|
||||||
|
if (path === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const oldValue = lastKnownValues.get(path);
|
||||||
|
if (oldValue !== value) {
|
||||||
|
lastKnownValues.set(path, value); // this is now reactive
|
||||||
|
|
||||||
|
const existing = getSubscriptionsByPath(path);
|
||||||
|
if (existing) {
|
||||||
|
existing.value = value;
|
||||||
|
} else {
|
||||||
|
getAllSubscriptions().push({ path, value, uuid: pub.uuid });
|
||||||
|
}
|
||||||
|
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dbmData.value = buildTree(subs.value);
|
|
||||||
} else {
|
if (changed) {
|
||||||
console.warn('Unmatched message:', message);
|
dbmData.value = buildTree(getAllSubscriptions()); // rebuild reactive tree
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -67,10 +95,6 @@ export function initWebSocket(url: string, $q?: QVueGlobals) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// onBeforeUnmount(() => {
|
|
||||||
// close();
|
|
||||||
// });
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
connect,
|
connect,
|
||||||
close,
|
close,
|
||||||
@@ -107,7 +131,6 @@ export function send(data: Request): Promise<Response | undefined> {
|
|||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
pendingResponses.set(id, resolve);
|
pendingResponses.set(id, resolve);
|
||||||
|
|
||||||
waitForSocketConnection()
|
waitForSocketConnection()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
socket?.send(JSON.stringify(payload));
|
socket?.send(JSON.stringify(payload));
|
||||||
@@ -121,5 +144,5 @@ export function send(data: Request): Promise<Response | undefined> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateId(): string {
|
function generateId(): string {
|
||||||
return Math.random().toString(36).substr(2, 9); // simple unique ID
|
return Math.random().toString(36).substring(2, 9); // simple unique ID
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user