2021-09-16 02:00:52 +08:00
|
|
|
|
<script>
|
2021-12-14 20:55:53 +01:00
|
|
|
|
//==============================components import section====================================
|
2021-09-16 02:00:52 +08:00
|
|
|
|
import { onMount } from "svelte";
|
|
|
|
|
|
import { Route, router, active } from "tinro";
|
|
|
|
|
|
router.mode.hash(); // enables hash navigation method
|
|
|
|
|
|
//router.mode.memory(); // enables in-memory navigation method
|
2021-12-16 00:18:40 +01:00
|
|
|
|
|
2021-10-27 05:35:07 +07:00
|
|
|
|
//import Chart from "svelte-frappe-charts";
|
|
|
|
|
|
|
2021-10-17 17:48:59 +08:00
|
|
|
|
import Card from "./widgets/Card.svelte";
|
2021-10-17 19:31:38 +08:00
|
|
|
|
import Input from "./widgets/Input.svelte";
|
2021-10-19 21:59:48 +08:00
|
|
|
|
import Toggle from "./widgets/Toggle.svelte";
|
2021-10-25 20:05:21 +07:00
|
|
|
|
import Anydata from "./widgets/Anydata.svelte";
|
2021-09-16 02:00:52 +08:00
|
|
|
|
|
2021-12-14 20:55:53 +01:00
|
|
|
|
//==================================constants section========================================
|
2021-12-08 22:59:21 +01:00
|
|
|
|
let debug = true;
|
|
|
|
|
|
let LOG_MAX_MESSAGES = 10;
|
2021-12-21 00:48:44 +01:00
|
|
|
|
let reconnectTimeout = 10000;
|
2021-12-14 20:55:53 +01:00
|
|
|
|
|
|
|
|
|
|
//=================================variable section==========================================
|
2021-12-05 00:49:36 +01:00
|
|
|
|
let myip = document.location.hostname;
|
2021-12-14 20:55:53 +01:00
|
|
|
|
let showInput = false;
|
|
|
|
|
|
|
|
|
|
|
|
//dashboard
|
2021-09-16 02:00:52 +08:00
|
|
|
|
let wigets = [];
|
2021-12-14 20:55:53 +01:00
|
|
|
|
let pages = [];
|
|
|
|
|
|
|
2021-09-16 02:00:52 +08:00
|
|
|
|
wigets = [
|
2021-10-17 19:31:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
widget: "input",
|
|
|
|
|
|
type: "date",
|
|
|
|
|
|
status: "2021-10-17",
|
2021-10-19 21:59:48 +08:00
|
|
|
|
page: "Inputs",
|
2021-10-17 19:31:38 +08:00
|
|
|
|
order: "4",
|
|
|
|
|
|
descr: "Switch on boiler date",
|
|
|
|
|
|
topic: "/prefix/00000-00004/date1",
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws: 0,
|
2021-10-17 19:31:38 +08:00
|
|
|
|
},
|
2021-09-16 02:00:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
widget: "input",
|
|
|
|
|
|
type: "time",
|
|
|
|
|
|
status: "12:00",
|
2021-10-19 21:59:48 +08:00
|
|
|
|
page: "Inputs",
|
2021-10-10 23:26:55 +08:00
|
|
|
|
order: "1",
|
2021-09-16 02:00:52 +08:00
|
|
|
|
descr: "Switch on boiler time",
|
2021-10-17 19:31:38 +08:00
|
|
|
|
topic: "/prefix/00000-00001/time",
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws: 0,
|
2021-09-16 02:00:52 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
widget: "input",
|
|
|
|
|
|
type: "number",
|
|
|
|
|
|
status: "30.5",
|
|
|
|
|
|
after: "°С",
|
2021-10-19 21:59:48 +08:00
|
|
|
|
page: "Inputs",
|
2021-10-10 23:26:55 +08:00
|
|
|
|
order: "2",
|
2021-09-16 02:00:52 +08:00
|
|
|
|
descr: "Boiler temperature",
|
2021-10-17 19:31:38 +08:00
|
|
|
|
topic: "/prefix/00000-00002/temp",
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws: 0,
|
2021-09-16 02:00:52 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
widget: "input",
|
|
|
|
|
|
type: "text",
|
|
|
|
|
|
status: "Hello",
|
2021-10-19 21:59:48 +08:00
|
|
|
|
page: "Inputs",
|
2021-09-16 02:00:52 +08:00
|
|
|
|
order: "3",
|
2021-10-10 23:26:55 +08:00
|
|
|
|
descr: "Message to be send",
|
2021-10-17 19:31:38 +08:00
|
|
|
|
topic: "/prefix/00000-00003/text",
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws: 0,
|
2021-09-16 02:00:52 +08:00
|
|
|
|
},
|
2021-10-19 21:59:48 +08:00
|
|
|
|
{
|
|
|
|
|
|
widget: "toggle",
|
|
|
|
|
|
status: 0,
|
|
|
|
|
|
page: "Toggles",
|
|
|
|
|
|
order: "3",
|
|
|
|
|
|
descr: "Light in my room",
|
2021-10-19 22:26:09 +08:00
|
|
|
|
topic: "/prefix/00000-00003/btn1",
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws: 0,
|
2021-10-19 21:59:48 +08:00
|
|
|
|
},
|
2021-10-19 22:19:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
widget: "toggle",
|
|
|
|
|
|
status: 0,
|
|
|
|
|
|
page: "Toggles",
|
|
|
|
|
|
order: "3",
|
|
|
|
|
|
descr: "Light in my room",
|
2021-10-19 22:26:09 +08:00
|
|
|
|
topic: "/prefix/00000-00003/btn2",
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws: 0,
|
2021-10-19 22:19:21 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
widget: "toggle",
|
|
|
|
|
|
status: 0,
|
|
|
|
|
|
page: "Toggles",
|
|
|
|
|
|
order: "3",
|
|
|
|
|
|
descr: "Light in my room",
|
2021-10-19 22:26:09 +08:00
|
|
|
|
topic: "/prefix/00000-00003/btn3",
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws: 0,
|
2021-10-19 22:19:21 +08:00
|
|
|
|
},
|
2021-10-25 20:05:21 +07:00
|
|
|
|
{
|
|
|
|
|
|
widget: "anydata",
|
|
|
|
|
|
status: 30.5,
|
2021-10-27 05:11:28 +07:00
|
|
|
|
after: "°С",
|
2021-10-25 20:05:21 +07:00
|
|
|
|
page: "Any data",
|
|
|
|
|
|
order: "3",
|
|
|
|
|
|
descr: "Temperature",
|
|
|
|
|
|
topic: "/prefix/00000-00003/tmp10",
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws: 0,
|
2021-10-25 20:05:21 +07:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
widget: "anydata",
|
|
|
|
|
|
status: 1032,
|
|
|
|
|
|
after: "mm",
|
|
|
|
|
|
page: "Any data",
|
|
|
|
|
|
order: "3",
|
|
|
|
|
|
descr: "Pressure",
|
|
|
|
|
|
topic: "/prefix/00000-00003/tmp10",
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws: 0,
|
2021-10-25 20:05:21 +07:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
widget: "anydata",
|
|
|
|
|
|
status: 50,
|
|
|
|
|
|
after: "%",
|
|
|
|
|
|
page: "Any data",
|
|
|
|
|
|
order: "3",
|
|
|
|
|
|
descr: "Level",
|
|
|
|
|
|
topic: "/prefix/00000-00003/tmp10",
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws: 0,
|
2021-10-25 20:05:21 +07:00
|
|
|
|
},
|
2021-10-26 05:38:47 +07:00
|
|
|
|
{
|
|
|
|
|
|
widget: "anydata",
|
|
|
|
|
|
status: "opened",
|
|
|
|
|
|
page: "Any data",
|
|
|
|
|
|
order: "3",
|
|
|
|
|
|
descr: "Status",
|
|
|
|
|
|
topic: "/prefix/00000-00003/tmp10",
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws: 0,
|
2021-10-26 05:38:47 +07:00
|
|
|
|
},
|
2021-09-16 02:00:52 +08:00
|
|
|
|
];
|
2021-12-14 20:55:53 +01:00
|
|
|
|
|
|
|
|
|
|
//configuration
|
2021-12-05 00:49:36 +01:00
|
|
|
|
let config = [];
|
2021-12-14 20:55:53 +01:00
|
|
|
|
|
|
|
|
|
|
//web sockets
|
2021-12-05 00:49:36 +01:00
|
|
|
|
let socket = [];
|
|
|
|
|
|
let socketConnected = false;
|
2021-12-12 00:20:47 +01:00
|
|
|
|
let selectedDeviceData = {};
|
2021-12-08 22:59:21 +01:00
|
|
|
|
let deviceList = [];
|
2021-12-10 16:07:09 +01:00
|
|
|
|
let flag = true;
|
2021-12-14 20:55:53 +01:00
|
|
|
|
let newDevice = {};
|
|
|
|
|
|
let coreMessages = [];
|
2021-12-16 00:18:40 +01:00
|
|
|
|
let wsSelected = undefined;
|
2021-12-08 22:59:21 +01:00
|
|
|
|
|
2021-12-13 02:36:26 +01:00
|
|
|
|
deviceList = [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "Устройство 1",
|
|
|
|
|
|
id: "987654321",
|
2021-12-16 00:18:40 +01:00
|
|
|
|
ip: "192.168.88.235",
|
2021-12-13 02:36:26 +01:00
|
|
|
|
status: false,
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
2021-12-12 00:20:47 +01:00
|
|
|
|
|
2021-12-16 00:18:40 +01:00
|
|
|
|
//navigation
|
|
|
|
|
|
let currentPageName = undefined;
|
|
|
|
|
|
router.subscribe(handleNavigation);
|
|
|
|
|
|
|
2021-12-14 20:55:53 +01:00
|
|
|
|
//=================================functions section========================================
|
|
|
|
|
|
//web socket functions======================================================================
|
2021-12-08 22:59:21 +01:00
|
|
|
|
function connectToAllDevices() {
|
2021-12-13 00:01:21 +01:00
|
|
|
|
//closeAllConnection();
|
|
|
|
|
|
//socket = [];
|
2021-12-08 22:59:21 +01:00
|
|
|
|
let ws = 0;
|
|
|
|
|
|
deviceList.forEach((device) => {
|
2021-12-10 16:07:09 +01:00
|
|
|
|
//if (debug) console.log("[i]", device.name, ws, device.ip, device.id);
|
2021-12-09 00:10:10 +01:00
|
|
|
|
device.ws = ws;
|
2021-12-13 00:01:21 +01:00
|
|
|
|
if (!device.status) {
|
|
|
|
|
|
wsConnect(ws);
|
|
|
|
|
|
wsEventAdd(ws);
|
|
|
|
|
|
}
|
2021-12-08 22:59:21 +01:00
|
|
|
|
ws++;
|
2021-12-05 00:49:36 +01:00
|
|
|
|
});
|
2021-12-10 14:44:00 +01:00
|
|
|
|
deviceList = deviceList;
|
2021-12-10 17:37:37 +01:00
|
|
|
|
socketConnected = selectedDeviceData.status;
|
2021-12-05 00:49:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-13 00:01:21 +01:00
|
|
|
|
function closeAllConnection() {
|
|
|
|
|
|
let s;
|
|
|
|
|
|
for (s in socket) {
|
|
|
|
|
|
socket[s].close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-09 00:10:10 +01:00
|
|
|
|
function markDeviceStatus(ws, status) {
|
|
|
|
|
|
deviceList.forEach((device) => {
|
|
|
|
|
|
if (device.ws === ws) {
|
|
|
|
|
|
device.status = status;
|
2021-12-09 22:35:04 +01:00
|
|
|
|
if (debug) {
|
|
|
|
|
|
if (device.status) {
|
2021-12-10 16:07:55 +01:00
|
|
|
|
console.log("[i]", device.ip, "status online");
|
2021-12-09 22:35:04 +01:00
|
|
|
|
} else {
|
2021-12-10 16:07:55 +01:00
|
|
|
|
console.log("[i]", device.ip, "status offline");
|
2021-12-09 22:35:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-12-09 00:10:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2021-12-09 22:35:04 +01:00
|
|
|
|
deviceList = deviceList;
|
2021-12-10 17:37:37 +01:00
|
|
|
|
socketConnected = selectedDeviceData.status;
|
2021-12-09 00:10:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-10 16:07:09 +01:00
|
|
|
|
function getDeviceStatus(ws) {
|
|
|
|
|
|
let ret = false;
|
|
|
|
|
|
deviceList.forEach((device) => {
|
|
|
|
|
|
if (ws === device.ws) {
|
|
|
|
|
|
ret = device.status;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-10 14:44:00 +01:00
|
|
|
|
function wsConnect(ws) {
|
|
|
|
|
|
let ip = getIP(ws);
|
|
|
|
|
|
if (ip === "error") {
|
|
|
|
|
|
if (debug) console.log("[e]", "device list wrong");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
socket[ws] = new WebSocket("ws://" + ip + "/ws");
|
2021-12-10 20:27:45 +01:00
|
|
|
|
if (debug) console.log("[i]", ip, "started connecting...");
|
2021-12-10 14:44:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getIP(ws) {
|
|
|
|
|
|
let ret = "error";
|
|
|
|
|
|
deviceList.forEach((device) => {
|
|
|
|
|
|
if (ws === device.ws) {
|
|
|
|
|
|
ret = device.ip;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return ret;
|
2021-12-06 01:21:55 +01:00
|
|
|
|
}
|
2021-12-07 22:14:59 +01:00
|
|
|
|
|
2021-12-08 22:59:21 +01:00
|
|
|
|
function wsEventAdd(ws) {
|
|
|
|
|
|
if (socket[ws]) {
|
2021-12-11 13:54:28 +01:00
|
|
|
|
let ip = getIP(ws);
|
|
|
|
|
|
if (debug) console.log("[i]", ip, "web socket events added");
|
2021-12-08 22:59:21 +01:00
|
|
|
|
socket[ws].addEventListener("open", function (event) {
|
2021-12-11 13:54:28 +01:00
|
|
|
|
if (debug) console.log("[i]", ip, "completed connecting");
|
2021-12-09 00:10:10 +01:00
|
|
|
|
markDeviceStatus(ws, true);
|
2021-12-16 00:18:40 +01:00
|
|
|
|
sendCurrentPageName();
|
2021-12-08 22:59:21 +01:00
|
|
|
|
//socket[ws].send("HELLO");
|
|
|
|
|
|
});
|
|
|
|
|
|
socket[ws].addEventListener("message", function (event) {
|
|
|
|
|
|
let data = event.data.toString();
|
2021-12-21 00:48:44 +01:00
|
|
|
|
if (debug) console.log("[i]", "data:", data);
|
2021-12-16 00:18:40 +01:00
|
|
|
|
if (data.includes("[log]")) {
|
|
|
|
|
|
data = data.replace("[log]", "");
|
2021-12-08 22:59:21 +01:00
|
|
|
|
addCoreMsg(data);
|
2021-12-16 00:18:40 +01:00
|
|
|
|
//if (debug) console.log("[i]", "log data:", data);
|
|
|
|
|
|
} else if (data.includes("[config]")) {
|
2021-12-16 02:22:45 +01:00
|
|
|
|
if (debug) console.log("[i]", "config data:", data);
|
2021-12-16 00:18:40 +01:00
|
|
|
|
data = data.replace("[config]", "");
|
|
|
|
|
|
data = JSON.parse(data);
|
|
|
|
|
|
config.push(data);
|
|
|
|
|
|
config = config;
|
2021-12-08 22:59:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
socket[ws].addEventListener("close", (event) => {
|
2021-12-11 13:54:28 +01:00
|
|
|
|
if (debug) console.log("[e]", ip, "connection closed");
|
2021-12-09 00:10:10 +01:00
|
|
|
|
markDeviceStatus(ws, false);
|
2021-12-08 22:59:21 +01:00
|
|
|
|
});
|
|
|
|
|
|
socket[ws].addEventListener("error", function (event) {
|
2021-12-11 13:54:28 +01:00
|
|
|
|
if (debug) console.log("[e]", ip, "connection error");
|
2021-12-09 00:10:10 +01:00
|
|
|
|
markDeviceStatus(ws, false);
|
2021-12-08 22:59:21 +01:00
|
|
|
|
});
|
2021-12-10 14:44:00 +01:00
|
|
|
|
} else {
|
|
|
|
|
|
if (debug) console.log("[e]", "socket not exist");
|
2021-12-06 01:21:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-12-07 22:14:59 +01:00
|
|
|
|
|
2021-12-08 22:59:21 +01:00
|
|
|
|
function wsPush(ws, topic, status) {
|
|
|
|
|
|
let msg = topic + " " + status;
|
2021-12-09 22:35:04 +01:00
|
|
|
|
if (debug) console.log("[i]", "send to ws msg:", msg);
|
2021-12-08 22:59:21 +01:00
|
|
|
|
wsSendMsg(ws, msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-07 22:14:59 +01:00
|
|
|
|
function wsTestMsgTask() {
|
2021-12-21 00:48:44 +01:00
|
|
|
|
setTimeout(wsTestMsgTask, reconnectTimeout);
|
2021-12-10 20:27:45 +01:00
|
|
|
|
if (debug) console.log("[i]", "----timer tick----");
|
2021-12-10 16:07:09 +01:00
|
|
|
|
if (!flag) {
|
|
|
|
|
|
deviceList.forEach((device) => {
|
|
|
|
|
|
if (!getDeviceStatus(device.ws)) {
|
|
|
|
|
|
wsConnect(device.ws);
|
|
|
|
|
|
wsEventAdd(device.ws);
|
|
|
|
|
|
} else {
|
2021-12-13 02:36:26 +01:00
|
|
|
|
wsSendMsg(device.ws, "tst");
|
2021-12-10 16:07:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
flag = false;
|
2021-12-08 22:59:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function wsSendMsg(ws, msg) {
|
|
|
|
|
|
if (socket[ws] && socket[ws].readyState === 1) {
|
|
|
|
|
|
socket[ws].send(msg);
|
2021-12-10 16:07:09 +01:00
|
|
|
|
if (debug) console.log("[i]", getIP(ws), "msg send success", msg);
|
2021-12-08 22:59:21 +01:00
|
|
|
|
} else {
|
2021-12-10 16:07:09 +01:00
|
|
|
|
if (debug) console.log("[e]", getIP(ws), "msg not send", msg);
|
2021-12-07 22:14:59 +01:00
|
|
|
|
}
|
2021-12-06 01:21:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-14 20:55:53 +01:00
|
|
|
|
//dashboard functions====================================================================================
|
2021-10-17 07:09:55 +08:00
|
|
|
|
function findNewPage() {
|
|
|
|
|
|
pages = [];
|
2021-10-18 21:12:42 +08:00
|
|
|
|
const newPage = Array.from(new Set(Array.from(wigets, ({ page }) => page)));
|
2021-10-17 07:09:55 +08:00
|
|
|
|
newPage.forEach(function (item, i, arr) {
|
2021-10-18 21:12:42 +08:00
|
|
|
|
pages = [...pages, JSON.parse(JSON.stringify({ page: item }))];
|
2021-10-17 07:09:55 +08:00
|
|
|
|
});
|
|
|
|
|
|
pages.sort(function (a, b) {
|
|
|
|
|
|
if (a.page < b.page) {
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (a.page > b.page) {
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-12-05 00:49:36 +01:00
|
|
|
|
|
|
|
|
|
|
function wigetsUpdate() {
|
|
|
|
|
|
wigets = JSON.parse(document.getElementById("text1").value);
|
|
|
|
|
|
findNewPage();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-14 20:55:53 +01:00
|
|
|
|
//logging execution======================================================================================
|
2021-12-07 22:14:59 +01:00
|
|
|
|
const addCoreMsg = (msg) => {
|
|
|
|
|
|
if (coreMessages.length > Number(LOG_MAX_MESSAGES)) {
|
|
|
|
|
|
coreMessages = coreMessages.slice(0);
|
2021-12-05 00:49:36 +01:00
|
|
|
|
}
|
2021-12-07 22:14:59 +01:00
|
|
|
|
const time = new Date().getTime();
|
|
|
|
|
|
coreMessages = [...coreMessages, { time, msg }];
|
|
|
|
|
|
coreMessages.sort(function (a, b) {
|
2021-12-05 00:49:36 +01:00
|
|
|
|
if (a.time > b.time) {
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (a.time < b.time) {
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
2021-12-08 22:59:21 +01:00
|
|
|
|
|
2021-12-14 20:55:53 +01:00
|
|
|
|
//device list handle======================================================================================
|
2021-12-09 22:35:04 +01:00
|
|
|
|
function dropdownChange() {
|
|
|
|
|
|
socketConnected = selectedDeviceData.status;
|
2021-12-13 02:36:26 +01:00
|
|
|
|
wsSelected = selectedDeviceData.ws;
|
2021-12-11 13:54:28 +01:00
|
|
|
|
if (debug) console.log("[i]", "user selected device:", selectedDeviceData.name);
|
2021-12-13 00:01:21 +01:00
|
|
|
|
if (selectedDeviceData.ip === myip) {
|
|
|
|
|
|
if (debug) console.log("[i]", "user selected original device", selectedDeviceData.name);
|
|
|
|
|
|
}
|
2021-12-09 22:35:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-12 00:20:47 +01:00
|
|
|
|
function devListSave() {
|
|
|
|
|
|
if (!showInput) {
|
|
|
|
|
|
if (newDevice.name !== undefined && newDevice.ip !== undefined && newDevice.id !== undefined) {
|
|
|
|
|
|
newDevice.status = false;
|
|
|
|
|
|
deviceList.push(newDevice);
|
|
|
|
|
|
deviceList = deviceList;
|
|
|
|
|
|
newDevice = {};
|
|
|
|
|
|
connectToAllDevices();
|
2021-12-13 00:01:21 +01:00
|
|
|
|
if (debug) console.log("[i]", "selected device:", selectedDeviceData);
|
|
|
|
|
|
//socketConnected = selectedDeviceData.status;
|
|
|
|
|
|
//socketConnected = socketConnected;
|
2021-12-12 00:20:47 +01:00
|
|
|
|
} else {
|
|
|
|
|
|
if (debug) console.log("[e]", "wrong data");
|
|
|
|
|
|
}
|
2021-12-13 02:36:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-14 20:55:53 +01:00
|
|
|
|
//navigation===========================================================================================
|
2021-12-13 02:36:26 +01:00
|
|
|
|
function handleNavigation() {
|
2021-12-16 00:18:40 +01:00
|
|
|
|
config = [];
|
|
|
|
|
|
currentPageName = $router.path.toString();
|
|
|
|
|
|
console.log("[i]", "user on page:", currentPageName);
|
|
|
|
|
|
sendCurrentPageName();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function sendCurrentPageName() {
|
|
|
|
|
|
if (wsSelected !== undefined) {
|
|
|
|
|
|
wsSendMsg(wsSelected, currentPageName);
|
2021-12-12 00:20:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-14 20:55:53 +01:00
|
|
|
|
//json=================================================================================================
|
|
|
|
|
|
function getJsonObject(array, number) {
|
|
|
|
|
|
let num = 0;
|
|
|
|
|
|
let out = {};
|
|
|
|
|
|
array.forEach((object) => {
|
|
|
|
|
|
if (num === number) {
|
|
|
|
|
|
out = object;
|
|
|
|
|
|
}
|
|
|
|
|
|
num++;
|
|
|
|
|
|
});
|
|
|
|
|
|
return out;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const syntaxHighlight = (json) => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
json = JSON.stringify(JSON.parse(json), null, 4);
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
return json;
|
|
|
|
|
|
}
|
|
|
|
|
|
json = json.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
|
|
|
|
json = json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
|
|
|
|
|
|
return match;
|
|
|
|
|
|
});
|
|
|
|
|
|
return json;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//initialisation=======================================================================================
|
2021-12-08 22:59:21 +01:00
|
|
|
|
onMount(async () => {
|
2021-12-09 22:35:04 +01:00
|
|
|
|
console.log("[i]", "mounted");
|
2021-12-08 22:59:21 +01:00
|
|
|
|
connectToAllDevices();
|
2021-12-10 14:44:00 +01:00
|
|
|
|
wsTestMsgTask();
|
2021-12-10 17:37:37 +01:00
|
|
|
|
socketConnected = selectedDeviceData.status;
|
2021-12-13 00:01:21 +01:00
|
|
|
|
dropdownChange();
|
2021-12-08 22:59:21 +01:00
|
|
|
|
findNewPage();
|
|
|
|
|
|
});
|
2021-09-16 02:00:52 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<main>
|
|
|
|
|
|
<div class="fixed m-0 h-10 w-full bg-gray-100 shadow-md">
|
2021-12-09 00:10:10 +01:00
|
|
|
|
<div class="flex justify-end content-center">
|
|
|
|
|
|
<div class="px-15 py-2">
|
2021-12-09 22:35:04 +01:00
|
|
|
|
<select bind:value={selectedDeviceData} on:change={() => dropdownChange()}>
|
2021-12-09 00:10:10 +01:00
|
|
|
|
{#each deviceList as device}
|
|
|
|
|
|
<option value={device}>
|
|
|
|
|
|
{device.name}
|
|
|
|
|
|
</option>
|
|
|
|
|
|
{/each}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="px-10 py-1">
|
2021-12-09 22:35:04 +01:00
|
|
|
|
<svg class="h-8 w-8 {socketConnected === true ? 'text-green-500' : 'text-red-500'}" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" /> <path d="M7 18a4.6 4.4 0 0 1 0 -9h0a5 4.5 0 0 1 11 2h1a3.5 3.5 0 0 1 0 7h-12" /></svg>
|
2021-12-09 00:10:10 +01:00
|
|
|
|
</div>
|
2021-12-06 01:21:55 +01:00
|
|
|
|
</div>
|
2021-09-16 02:00:52 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2021-10-16 06:33:15 +08:00
|
|
|
|
<input id="menu__toggle" type="checkbox" />
|
|
|
|
|
|
<label class="menu__btn" for="menu__toggle">
|
|
|
|
|
|
<span />
|
|
|
|
|
|
</label>
|
2021-09-16 02:00:52 +08:00
|
|
|
|
|
2021-10-16 06:33:15 +08:00
|
|
|
|
<ul class="menu__box">
|
|
|
|
|
|
<li>
|
|
|
|
|
|
<a class="menu__item" href="/">{"Управление"}</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
<li>
|
2021-10-18 21:12:42 +08:00
|
|
|
|
<a class="menu__item" href="/config">{"Конфигуратор"}</a>
|
2021-10-16 06:33:15 +08:00
|
|
|
|
</li>
|
|
|
|
|
|
<li>
|
2021-10-18 21:12:42 +08:00
|
|
|
|
<a class="menu__item" href="/connection">{"Подключение"}</a>
|
2021-10-16 06:33:15 +08:00
|
|
|
|
</li>
|
|
|
|
|
|
<li>
|
2021-10-18 21:12:42 +08:00
|
|
|
|
<a class="menu__item" href="/utilities">{"Утилиты"}</a>
|
2021-10-16 06:33:15 +08:00
|
|
|
|
</li>
|
|
|
|
|
|
<li>
|
|
|
|
|
|
<a class="menu__item" href="/log">{"Лог"}</a>
|
|
|
|
|
|
</li>
|
2021-12-09 00:10:10 +01:00
|
|
|
|
<li>
|
|
|
|
|
|
<a class="menu__item" href="/list">{"Устройства"}</a>
|
|
|
|
|
|
</li>
|
2021-10-16 06:33:15 +08:00
|
|
|
|
<li>
|
|
|
|
|
|
<a class="menu__item" href="/about">{"О проекте"}</a>
|
|
|
|
|
|
</li>
|
2021-09-16 02:00:52 +08:00
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
<ul class="menu__main">
|
2021-10-18 20:42:01 +08:00
|
|
|
|
<div class="bg-cover bg-gray-50 pt-8 px-4">
|
2021-09-16 02:00:52 +08:00
|
|
|
|
<Route path="/">
|
2021-09-17 23:18:06 +08:00
|
|
|
|
<div class="cards-grid">
|
2021-10-17 07:09:55 +08:00
|
|
|
|
{#each pages as pagesName, i}
|
|
|
|
|
|
<Card title={pagesName.page}>
|
|
|
|
|
|
{#each wigets as widget, i}
|
2021-10-17 07:22:24 +08:00
|
|
|
|
{#if widget.page === pagesName.page}
|
|
|
|
|
|
{#if widget.widget === "input"}
|
2021-12-08 22:59:21 +01:00
|
|
|
|
<Input bind:value={widget.status} widget={widget} wsPushProp={(ws, topic, status) => wsPush(ws, topic, status)} />
|
2021-10-17 07:22:24 +08:00
|
|
|
|
{/if}
|
2021-10-19 21:59:48 +08:00
|
|
|
|
{#if widget.widget === "toggle"}
|
2021-12-08 22:59:21 +01:00
|
|
|
|
<Toggle bind:value={widget.status} widget={widget} wsPushProp={(ws, topic, status) => wsPush(ws, topic, status)} />
|
2021-10-19 21:59:48 +08:00
|
|
|
|
{/if}
|
2021-10-25 20:05:21 +07:00
|
|
|
|
{#if widget.widget === "anydata"}
|
|
|
|
|
|
<Anydata bind:value={widget.status} widget={widget} />
|
|
|
|
|
|
{/if}
|
2021-10-17 07:09:55 +08:00
|
|
|
|
{/if}
|
|
|
|
|
|
{/each}
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
{/each}
|
2021-10-17 19:31:38 +08:00
|
|
|
|
|
|
|
|
|
|
<Card title="Редактор JSON">
|
2021-10-18 21:12:42 +08:00
|
|
|
|
<textarea on:input={wigetsUpdate} rows="10" class="json-input w-full" id="text1">{syntaxHighlight(JSON.stringify(wigets))}</textarea>
|
2021-10-17 19:31:38 +08:00
|
|
|
|
</Card>
|
2021-09-17 23:18:06 +08:00
|
|
|
|
</div>
|
2021-09-16 02:00:52 +08:00
|
|
|
|
</Route>
|
|
|
|
|
|
|
|
|
|
|
|
<Route path="/config">
|
2021-10-16 20:49:17 +00:00
|
|
|
|
<div class="cards-grid-inline">
|
2021-12-16 00:18:40 +01:00
|
|
|
|
<Card title="Конфигуратор">
|
|
|
|
|
|
<table class="table-fixed w-full">
|
|
|
|
|
|
<thead>
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<th class="table-head-element">Тип</th>
|
|
|
|
|
|
<th class="table-head-element">Подтип</th>
|
|
|
|
|
|
<th class="table-head-element">Id</th>
|
|
|
|
|
|
<th class="table-head-element">4</th>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
{#each config as element}
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td class="table-body-element">{element.type}</td>
|
|
|
|
|
|
<td class="table-body-element">{element.subtype}</td>
|
|
|
|
|
|
<td class="table-body-element">{element.id}</td>
|
|
|
|
|
|
<td class="table-body-element">4</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
{/each}
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
<button class="long-button">{"Сохранить"}</button>
|
|
|
|
|
|
</Card>
|
2021-10-16 21:49:28 +08:00
|
|
|
|
</div>
|
2021-09-16 02:00:52 +08:00
|
|
|
|
</Route>
|
|
|
|
|
|
|
|
|
|
|
|
<Route path="/connection">
|
2021-10-17 07:09:55 +08:00
|
|
|
|
<div class="cards-grid">
|
2021-10-16 21:49:28 +08:00
|
|
|
|
<Card title="Подключение к WiFi роутеру" />
|
|
|
|
|
|
<Card title="Подключение к MQTT брокеру" />
|
|
|
|
|
|
</div>
|
2021-09-16 02:00:52 +08:00
|
|
|
|
</Route>
|
2021-10-27 05:27:55 +07:00
|
|
|
|
<Route path="/utilities" />
|
2021-12-05 00:49:36 +01:00
|
|
|
|
<Route path="/log">
|
2021-12-07 22:14:59 +01:00
|
|
|
|
<Card title={"Лог"}>
|
|
|
|
|
|
{#each coreMessages as message, i}
|
|
|
|
|
|
<div class={message.msg.toString().includes("[E]") ? "text-red-500" : "text-black"}>{message.msg}</div>
|
|
|
|
|
|
{/each}
|
|
|
|
|
|
</Card>
|
2021-12-05 00:49:36 +01:00
|
|
|
|
</Route>
|
2021-12-09 00:10:10 +01:00
|
|
|
|
<Route path="/list">
|
|
|
|
|
|
<Card title={"Список устройств"}>
|
2021-12-09 22:35:04 +01:00
|
|
|
|
<table class="table-fixed w-full">
|
|
|
|
|
|
<thead>
|
|
|
|
|
|
<tr>
|
2021-12-11 13:54:28 +01:00
|
|
|
|
<th class="table-head-element">Название устройства</th>
|
|
|
|
|
|
<th class="table-head-element">IP адрес</th>
|
|
|
|
|
|
<th class="table-head-element">Идентификатор</th>
|
|
|
|
|
|
<th class="table-head-element">Состояние</th>
|
2021-12-09 22:35:04 +01:00
|
|
|
|
</tr>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
{#each deviceList as device}
|
|
|
|
|
|
<tr>
|
2021-12-11 13:54:28 +01:00
|
|
|
|
<td class="table-body-element">{device.name}</td>
|
|
|
|
|
|
<td class="table-body-element"><a href={"http://" + device.ip}>{device.ip}</a></td>
|
|
|
|
|
|
<td class="table-body-element">{device.id}</td>
|
|
|
|
|
|
<td class="table-body-element {device.status ? 'bg-green-100' : 'bg-red-100'}">{device.status ? "online" : "offline"}</td>
|
2021-12-09 22:35:04 +01:00
|
|
|
|
</tr>
|
|
|
|
|
|
{/each}
|
2021-12-12 00:20:47 +01:00
|
|
|
|
{#if showInput}
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td class="table-body-element"><input bind:value={newDevice.name} class="table-input" type="text" /></td>
|
|
|
|
|
|
<td class="table-body-element"><input bind:value={newDevice.ip} class="table-input" type="text" /></td>
|
|
|
|
|
|
<td class="table-body-element"><input bind:value={newDevice.id} class="table-input" type="text" /></td>
|
|
|
|
|
|
<td class="table-body-element" />
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
{/if}
|
2021-12-09 22:35:04 +01:00
|
|
|
|
</tbody>
|
|
|
|
|
|
</table>
|
2021-12-12 00:20:47 +01:00
|
|
|
|
<button class="long-button" on:click={() => ((showInput = !showInput), devListSave())}>{showInput ? "Сохранить" : "Добавить устройство"}</button>
|
2021-12-09 00:10:10 +01:00
|
|
|
|
</Card>
|
|
|
|
|
|
</Route>
|
2021-12-05 00:49:36 +01:00
|
|
|
|
<Route path="/about" />
|
2021-09-16 02:00:52 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</main>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="postcss" global>
|
|
|
|
|
|
@tailwind base;
|
|
|
|
|
|
@tailwind components;
|
|
|
|
|
|
@tailwind utilities;
|
|
|
|
|
|
|
|
|
|
|
|
@layer components {
|
2021-10-25 16:50:31 +07:00
|
|
|
|
/*==================================================cards grid=====================================================*/
|
|
|
|
|
|
/* grid for cards */
|
2021-09-17 23:18:06 +08:00
|
|
|
|
.cards-grid {
|
2021-10-18 20:42:01 +08:00
|
|
|
|
@apply grid gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 2xl:grid-cols-3 justify-items-center;
|
2021-09-17 23:18:06 +08:00
|
|
|
|
}
|
2021-10-25 16:50:31 +07:00
|
|
|
|
/* grid for cards for full screen */
|
2021-10-16 20:49:17 +00:00
|
|
|
|
.cards-grid-inline {
|
|
|
|
|
|
@apply grid grid-cols-1 justify-items-center;
|
|
|
|
|
|
}
|
2021-10-20 20:53:07 +08:00
|
|
|
|
/*=============================================card and items inside===============================================*/
|
|
|
|
|
|
/* 1. paddig and style for card */
|
2021-09-17 23:18:06 +08:00
|
|
|
|
.card {
|
2021-10-18 20:42:01 +08:00
|
|
|
|
@apply w-full p-2 sm:p-2 md:p-2 lg:p-2 xl:px-8 xl:py-4 2xl:px-8 2xl:py-4 bg-white rounded-lg shadow-md lg:shadow-lg;
|
2021-09-17 23:18:06 +08:00
|
|
|
|
}
|
2021-10-20 20:53:07 +08:00
|
|
|
|
/* 2. style for card header */
|
2021-10-26 05:38:47 +07:00
|
|
|
|
.card-header {
|
2021-10-27 05:27:55 +07:00
|
|
|
|
@apply text-center text-lg text-gray-500 font-bold pb-4;
|
2021-09-16 02:00:52 +08:00
|
|
|
|
}
|
2021-10-20 20:53:07 +08:00
|
|
|
|
/* 3. card items positioning*/
|
2021-10-27 05:27:55 +07:00
|
|
|
|
.card-items-psn {
|
|
|
|
|
|
@apply flex mb-4 h-8 items-center;
|
2021-10-20 20:53:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
/* 4. widget description width*/
|
2021-10-27 05:27:55 +07:00
|
|
|
|
.widget-descr-width {
|
2021-10-20 20:53:07 +08:00
|
|
|
|
@apply w-2/3;
|
|
|
|
|
|
}
|
|
|
|
|
|
/* 5. widget descr style*/
|
|
|
|
|
|
.widget-descr-style {
|
|
|
|
|
|
@apply pr-4 text-gray-500 font-bold;
|
|
|
|
|
|
}
|
|
|
|
|
|
/* 6. widget width*/
|
2021-10-27 05:27:55 +07:00
|
|
|
|
.widget-width {
|
2021-10-25 16:50:31 +07:00
|
|
|
|
@apply flex justify-end w-1/3;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*====================================================others=====================================================*/
|
|
|
|
|
|
.btn-indigo {
|
|
|
|
|
|
@apply py-2 px-4 bg-indigo-500 text-white font-semibold rounded-lg shadow-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-400 focus:ring-opacity-75;
|
|
|
|
|
|
}
|
|
|
|
|
|
.widget-input {
|
|
|
|
|
|
@apply content-center pr-4 py-1 bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full text-gray-700 leading-tight focus:outline-none focus:bg-white text-right;
|
|
|
|
|
|
}
|
|
|
|
|
|
.json-input {
|
|
|
|
|
|
@apply content-center pr-4 py-1 bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-indigo-500;
|
2021-09-16 02:00:52 +08:00
|
|
|
|
}
|
2021-10-25 20:05:21 +07:00
|
|
|
|
.widget-anydata-style {
|
2021-10-27 05:11:28 +07:00
|
|
|
|
@apply text-center text-gray-500 font-bold;
|
2021-10-25 20:05:21 +07:00
|
|
|
|
}
|
2021-12-11 13:54:28 +01:00
|
|
|
|
/*====================================================table=====================================================*/
|
|
|
|
|
|
.table-head-element {
|
|
|
|
|
|
@apply border border-gray-300 text-center break-words w-1/4 text-gray-500 font-bold;
|
|
|
|
|
|
}
|
|
|
|
|
|
.table-body-element {
|
|
|
|
|
|
@apply border border-gray-300 text-center break-words w-1/4;
|
|
|
|
|
|
}
|
2021-12-12 00:20:47 +01:00
|
|
|
|
.table-input {
|
|
|
|
|
|
@apply content-center bg-gray-100 appearance-none border-2 border-gray-200 w-full text-gray-700 leading-tight focus:outline-none focus:bg-white text-center focus:border-indigo-500;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*====================================================buttons=====================================================*/
|
|
|
|
|
|
.long-button {
|
|
|
|
|
|
@apply flex justify-center break-words content-center bg-blue-100 hover:bg-blue-200 text-gray-500 font-bold h-8 w-full mt-4 border border-gray-300 rounded;
|
|
|
|
|
|
}
|
2021-09-16 02:00:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#menu__toggle {
|
|
|
|
|
|
opacity: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
#menu__toggle:checked ~ .menu__btn > span {
|
|
|
|
|
|
transform: rotate(45deg);
|
|
|
|
|
|
}
|
|
|
|
|
|
#menu__toggle:checked ~ .menu__btn > span::before {
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
transform: rotate(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
#menu__toggle:checked ~ .menu__btn > span::after {
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
transform: rotate(90deg);
|
|
|
|
|
|
}
|
|
|
|
|
|
#menu__toggle:checked ~ .menu__box {
|
|
|
|
|
|
visibility: visible;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#menu__toggle:checked ~ .menu__main {
|
2021-10-10 23:46:18 +08:00
|
|
|
|
margin-left: 150px; /* насколько сужать правую часть */
|
2021-10-16 06:33:15 +08:00
|
|
|
|
transition-duration: 0.25s;
|
2021-09-16 02:00:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.menu__btn {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
z-index: 1;
|
|
|
|
|
|
top: 10px;
|
|
|
|
|
|
left: 20px;
|
|
|
|
|
|
width: 20px;
|
|
|
|
|
|
height: 20px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.menu__btn > span,
|
|
|
|
|
|
.menu__btn > span::before,
|
|
|
|
|
|
.menu__btn > span::after {
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 2px;
|
|
|
|
|
|
background-color: #616161;
|
|
|
|
|
|
transition-duration: 0.25s;
|
|
|
|
|
|
}
|
|
|
|
|
|
.menu__btn > span::before {
|
|
|
|
|
|
content: "";
|
|
|
|
|
|
top: -8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.menu__btn > span::after {
|
|
|
|
|
|
content: "";
|
|
|
|
|
|
top: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.menu__box {
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
visibility: hidden;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: -100%;
|
|
|
|
|
|
width: 150px; /* размер выхода бокового меню */
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
padding: 80px 0;
|
|
|
|
|
|
list-style: none;
|
|
|
|
|
|
background-color: #eceff1;
|
|
|
|
|
|
box-shadow: 1px 0px 6px rgba(0, 0, 0, 0.2);
|
|
|
|
|
|
transition-duration: 0.25s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.menu__item {
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
padding: 12px 24px;
|
|
|
|
|
|
color: rgba(51, 51, 51, 0.788);
|
|
|
|
|
|
font-family: "Roboto", sans-serif;
|
|
|
|
|
|
font-size: 15px; /* размер шрифта бокового меню */
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
transition-duration: 0.25s;
|
|
|
|
|
|
}
|
|
|
|
|
|
.menu__item:hover {
|
|
|
|
|
|
background-color: #cfd8dc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.upper__bar {
|
|
|
|
|
|
background-color: rgba(51, 51, 51, 0.144);
|
|
|
|
|
|
height: 70px;
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
z-index: -1;
|
|
|
|
|
|
top: 0px;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
box-shadow: 1px 0px 3px rgba(0, 0, 0, 0.2);
|
|
|
|
|
|
}
|
2021-09-16 03:36:40 +08:00
|
|
|
|
|
|
|
|
|
|
input[type="date"]::-webkit-calendar-picker-indicator {
|
2021-09-17 03:35:49 +08:00
|
|
|
|
margin-left: 5px;
|
|
|
|
|
|
margin-right: -8px;
|
2021-09-16 03:36:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
input[type="time"]::-webkit-calendar-picker-indicator {
|
2021-09-17 03:35:49 +08:00
|
|
|
|
margin-left: 5px;
|
|
|
|
|
|
margin-right: -8px;
|
2021-09-16 03:36:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
input[type="number"]::-webkit-outer-spin-button,
|
|
|
|
|
|
input[type="number"]::-webkit-inner-spin-button {
|
2021-09-17 03:35:49 +08:00
|
|
|
|
margin-left: 7px;
|
|
|
|
|
|
margin-right: -6px;
|
2021-09-16 03:36:40 +08:00
|
|
|
|
width: 30px;
|
|
|
|
|
|
height: 30px;
|
|
|
|
|
|
opacity: 1;
|
|
|
|
|
|
}
|
2021-10-19 05:54:52 +08:00
|
|
|
|
|
2021-10-19 21:59:48 +08:00
|
|
|
|
/* Toggle */
|
2021-10-19 05:54:52 +08:00
|
|
|
|
input:checked ~ .dot {
|
|
|
|
|
|
transform: translateX(100%);
|
2021-10-25 16:50:31 +07:00
|
|
|
|
/* background-color: #48bb78;*/
|
2021-10-19 05:54:52 +08:00
|
|
|
|
}
|
2021-09-16 02:00:52 +08:00
|
|
|
|
</style>
|