mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-30 20:09:24 +03:00
добавил обратную связь для навигации
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
import { Route, router, active } from "tinro";
|
import { Route, router, active } from "tinro";
|
||||||
router.mode.hash(); // enables hash navigation method
|
router.mode.hash(); // enables hash navigation method
|
||||||
//router.mode.memory(); // enables in-memory navigation method
|
//router.mode.memory(); // enables in-memory navigation method
|
||||||
|
let wsSelected = undefined;
|
||||||
|
router.subscribe(handleNavigation);
|
||||||
//import Chart from "svelte-frappe-charts";
|
//import Chart from "svelte-frappe-charts";
|
||||||
|
|
||||||
//import components
|
//import components
|
||||||
@@ -134,20 +136,20 @@
|
|||||||
let deviceList = [];
|
let deviceList = [];
|
||||||
let flag = true;
|
let flag = true;
|
||||||
|
|
||||||
//deviceList = [
|
deviceList = [
|
||||||
// {
|
{
|
||||||
// name: "Устройство 1",
|
name: "Устройство 1",
|
||||||
// id: "987654321",
|
id: "987654321",
|
||||||
// ip: "192.168.88.230",
|
ip: "192.168.88.230",
|
||||||
// status: false,
|
status: false,
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// name: "Устройство 2",
|
name: "Устройство 2",
|
||||||
// id: "987654321",
|
id: "987654321",
|
||||||
// ip: "192.168.88.231",
|
ip: "192.168.88.231",
|
||||||
// status: false,
|
status: false,
|
||||||
// },
|
},
|
||||||
//];
|
];
|
||||||
|
|
||||||
let newDevice = {};
|
let newDevice = {};
|
||||||
|
|
||||||
@@ -249,7 +251,7 @@
|
|||||||
});
|
});
|
||||||
socket[ws].addEventListener("message", function (event) {
|
socket[ws].addEventListener("message", function (event) {
|
||||||
let data = event.data.toString();
|
let data = event.data.toString();
|
||||||
//if (debug) console.log("[i]", "new data:", event.data);
|
if (debug) console.log("[i]", "new data:", event.data);
|
||||||
if (data.includes("/core/")) {
|
if (data.includes("/core/")) {
|
||||||
data = data.replace("/core/", "");
|
data = data.replace("/core/", "");
|
||||||
addCoreMsg(data);
|
addCoreMsg(data);
|
||||||
@@ -275,7 +277,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function wsTestMsgTask() {
|
function wsTestMsgTask() {
|
||||||
setTimeout(wsTestMsgTask, 20000);
|
setTimeout(wsTestMsgTask, 60000);
|
||||||
if (debug) console.log("[i]", "----timer tick----");
|
if (debug) console.log("[i]", "----timer tick----");
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
deviceList.forEach((device) => {
|
deviceList.forEach((device) => {
|
||||||
@@ -283,7 +285,7 @@
|
|||||||
wsConnect(device.ws);
|
wsConnect(device.ws);
|
||||||
wsEventAdd(device.ws);
|
wsEventAdd(device.ws);
|
||||||
} else {
|
} else {
|
||||||
//wsSendMsg(device.ws, "");
|
wsSendMsg(device.ws, "tst");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -353,6 +355,7 @@
|
|||||||
|
|
||||||
function dropdownChange() {
|
function dropdownChange() {
|
||||||
socketConnected = selectedDeviceData.status;
|
socketConnected = selectedDeviceData.status;
|
||||||
|
wsSelected = selectedDeviceData.ws;
|
||||||
if (debug) console.log("[i]", "user selected device:", selectedDeviceData.name);
|
if (debug) console.log("[i]", "user selected device:", selectedDeviceData.name);
|
||||||
if (selectedDeviceData.ip === myip) {
|
if (selectedDeviceData.ip === myip) {
|
||||||
if (debug) console.log("[i]", "user selected original device", selectedDeviceData.name);
|
if (debug) console.log("[i]", "user selected original device", selectedDeviceData.name);
|
||||||
@@ -376,6 +379,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleNavigation() {
|
||||||
|
let page = $router.path.toString();
|
||||||
|
console.log("[i]", "user on page:", page);
|
||||||
|
if (page === "/config") {
|
||||||
|
if (wsSelected !== undefined) {
|
||||||
|
wsSendMsg(wsSelected, "config");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
console.log("[i]", "mounted");
|
console.log("[i]", "mounted");
|
||||||
connectToAllDevices();
|
connectToAllDevices();
|
||||||
|
|||||||
Reference in New Issue
Block a user