Files
IoTManagerWeb/src/App.svelte

1398 lines
44 KiB
Svelte
Raw Normal View History

2021-09-16 02:00:52 +08:00
<script>
2022-02-22 20:20:59 +01:00
/*
Svelte IoT Manager app
created by Dmitry Borisenko
Sandgasse 46/4, Vienna 1190, Austria
*/
2022-02-19 23:35:30 +01:00
2021-12-28 21:18:03 +01:00
//******************************************************import section*********************************************************/
//*****************************************************************************************************************************/
2021-09-16 02:00:52 +08:00
import { onMount } from "svelte";
import { Route, router, active } from "tinro";
router.mode.hash();
2022-02-07 02:08:21 +01:00
import Alarm from "./components/Alarm.svelte";
import Progress from "./components/Progress.svelte";
2021-12-26 01:34:29 +01:00
//import Modal from "./components/Modal.svelte";
import DashboardPage from "./pages/Dashboard.svelte";
import ConfigPage from "./pages/Config.svelte";
import ConnectionPage from "./pages/Connection.svelte";
import ListPage from "./pages/List.svelte";
import SystemPage from "./pages/System.svelte";
2022-09-10 02:59:03 +02:00
import DevPage from "./pages/Dev.svelte";
//import UtilitiesPage from "./pages/Utilities.svelte";
//import LogPage from "./pages/Log.svelte";
//import AboutPage from "./pages/About.svelte";
2021-12-26 01:34:29 +01:00
2022-02-07 16:36:43 +01:00
import CloudIcon from "./svg/Cloud.svelte";
2022-08-31 22:25:22 +02:00
import BookIcon from "./svg/Book.svelte";
2022-02-07 16:36:43 +01:00
2021-12-28 21:18:03 +01:00
//****************************************************constants section*********************************************************/
//******************************************************************************************************************************/
2021-12-08 22:59:21 +01:00
let debug = true;
2022-02-19 23:35:30 +01:00
let LOG_MAX_MESSAGES = 100;
2022-02-11 00:22:41 +01:00
let reconnectTimeout = 20000;
let rebootingTimeout = 18000;
2022-02-18 22:53:39 +01:00
let updatingTimeout = 80000;
let opened = false;
let preventMove = false;
2022-09-12 23:32:52 +02:00
let devMode = false;
2021-12-14 20:55:53 +01:00
2021-12-28 21:18:03 +01:00
//****************************************************variable section**********************************************************/
//******************************************************************************************************************************/
2022-08-16 00:56:12 +02:00
let myip = document.location.hostname;
if (devMode) myip = "192.168.1.101";
2021-12-14 20:55:53 +01:00
2021-12-28 21:18:03 +01:00
//Flags
let firstDevListRequest = true;
2021-12-28 21:18:03 +01:00
let showInput = false;
2021-12-27 02:46:05 +01:00
let showModalFlag = false;
let rebootingUpdatingInProgress = false;
const myTimeout = undefined;
2021-12-28 21:18:03 +01:00
let additionalParams = false;
2021-12-28 01:06:01 +01:00
2021-12-14 20:55:53 +01:00
//dashboard
let pages = [];
//ready flags
let dashReady = false;
let configReady = false;
let connectionReady = false;
let listReady = false;
let systemReady = false;
2022-02-18 19:48:15 +01:00
//update esp
let versionsList = {};
let choosingVersion = undefined;
//JSON Files====================================
2021-12-30 23:58:35 +01:00
let configJson = [];
let configJsonFlag = false;
let configJsonParced = false;
let widgetsJson = [];
let widgetsJsonFlag = false;
let widgetsJsonParced = false;
let itemsJson = [];
let itemsJsonFlag = false;
let itemsJsonParced = false;
let scenarioJson = {};
let scenarioJsonFlag = false;
let scenarioJsonParced = false;
//===============================================
let layoutJson = [];
2022-02-26 01:09:17 +01:00
let layoutJsonArrayParced = false;
let settingsJson = {};
let settingsJsonParced = false;
let errorsJson = {};
let errorsJsonParced = false;
let ssidJson = {};
let ssidJsonParced = false;
let paramsJson = {};
let paramsJsonParced = false;
2022-02-07 23:40:00 +01:00
let incDeviceList = [];
2022-02-23 22:56:17 +01:00
let deviceListParced = false;
let statusJsonParced = false;
2022-02-23 01:38:43 +01:00
2022-02-07 23:40:00 +01:00
let deviceList = [];
deviceList = [
{
2022-02-07 23:40:00 +01:00
name: "--",
id: "--",
ip: myip,
ws: 0,
2022-02-07 02:08:21 +01:00
status: false,
},
];
//web sockets
let socket = [];
let socketConnected = false;
let selectedDeviceData = undefined;
let selectedWs = 0;
let firstTime = true;
let newDevice = {};
let coreMessages = [];
//***********************************************************blob**************************************************************/
var MyBlobBuilder = function () {
this.parts = [];
};
MyBlobBuilder.prototype.append = function (part) {
this.parts.push(part);
this.blob = undefined; // Invalidate the blob
};
MyBlobBuilder.prototype.getBlob = function () {
if (!this.blob) {
2022-02-07 16:36:43 +01:00
this.blob = new Blob(this.parts, {
type: "binary",
});
}
return this.blob;
};
MyBlobBuilder.prototype.clear = function () {
this.parts = [];
};
//***********************************************************navigation********************************************************/
2021-12-16 00:18:40 +01:00
let currentPageName = undefined;
var configJsonBlob = new MyBlobBuilder();
var widgetsJsonBlob = new MyBlobBuilder();
var itemsJsonBlob = new MyBlobBuilder();
2022-02-23 01:38:43 +01:00
var scenarioTxtBlob = new MyBlobBuilder();
var layoutJsonArray = [];
2021-12-16 00:18:40 +01:00
router.subscribe(handleNavigation);
function handleNavigation() {
2022-02-23 22:56:17 +01:00
console.log("[i]", "handle navigation");
2022-09-10 02:59:03 +02:00
currentPageName = $router.path.toString();
2022-09-10 02:59:03 +02:00
//не нужно очищать переменные когда переходим на страницу разработчика
if (currentPageName != "/dev") {
clearData();
}
2022-02-09 16:43:24 +01:00
currentPageName = currentPageName + "|";
console.log("[i]", "user on page:", currentPageName);
2022-02-26 01:09:17 +01:00
if (currentPageName === "/|") {
sendToAllDevices(currentPageName);
} else {
sendCurrentPageName();
}
}
function sendCurrentPageName() {
2022-02-07 23:40:00 +01:00
if (selectedWs !== undefined) {
wsSendMsg(selectedWs, currentPageName);
}
}
2021-12-28 21:18:03 +01:00
2022-02-23 22:56:17 +01:00
//*******************************************************initialisation********************************************************************/
onMount(async () => {
console.log("[i]", "mounted");
whenDeviceListWasUpdated();
firstDevListRequest = true;
connectToAllDevices();
wsTestMsgTask();
2022-02-26 01:09:17 +01:00
sortingLayout();
2022-02-23 22:56:17 +01:00
});
2021-12-28 21:18:03 +01:00
//****************************************************web sockets section******************************************************/
2021-12-08 22:59:21 +01:00
function connectToAllDevices() {
2021-12-13 00:01:21 +01:00
//closeAllConnection();
//socket = [];
2022-02-07 23:40:00 +01:00
getSelectedDeviceData(selectedWs);
2021-12-08 22:59:21 +01:00
let ws = 0;
deviceList.forEach((device) => {
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-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;
2022-02-07 23:40:00 +01:00
getSelectedDeviceData(selectedWs);
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 + ":81");
2022-01-24 00:57:27 +01:00
socket.binaryType = "blob";
if (debug) console.log("[i]", ip, ws, "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, ws, "web socket events added");
2021-12-08 22:59:21 +01:00
socket[ws].addEventListener("open", function (event) {
if (debug) console.log("[i]", ip, ws, "completed connecting");
2021-12-09 00:10:10 +01:00
markDeviceStatus(ws, true);
if (firstDevListRequest) wsSendMsg(0, "/list|");
2022-02-26 01:09:17 +01:00
//при подключении отправляем название страницы
if (currentPageName === "/|") {
2022-02-26 01:09:17 +01:00
//всем устройствам
wsSendMsg(ws, currentPageName);
} else {
2022-02-26 01:09:17 +01:00
//только выбранному
if (ws === selectedWs) {
sendCurrentPageName();
}
}
2021-12-08 22:59:21 +01:00
});
//события веб сокетов
2021-12-08 22:59:21 +01:00
socket[ws].addEventListener("message", function (event) {
//сообщения типа String-----------------------------------------------------------------------------------//
2022-01-24 00:57:27 +01:00
if (typeof event.data === "string") {
2022-01-25 01:41:29 +01:00
let data = event.data;
if (ws === selectedWs) {
//сборщик deviceList сообщений
2022-02-27 01:49:03 +01:00
if (data.includes('devicelist":"')) {
if (IsJsonParse(data)) {
incDeviceList = JSON.parse(data);
incDeviceList = incDeviceList;
if (firstDevListRequest) {
deviceList = incDeviceList;
deviceList[0].status = true;
} else {
deviceList = combineArrays(deviceList, incDeviceList);
}
firstDevListRequest = false;
2022-02-23 22:56:17 +01:00
deviceList = deviceList;
2022-02-23 22:56:17 +01:00
deviceListParced = true;
if (debug) console.log("✔", "deviceList json parced");
onParced();
whenDeviceListWasUpdated();
connectToAllDevices();
}
}
2022-02-26 01:09:17 +01:00
//сборщик ssidJson сообщений
2022-02-27 01:49:03 +01:00
if (data.includes('ssid":"')) {
if (IsJsonParse(data)) {
ssidJson = JSON.parse(data);
ssidJson = ssidJson;
if (debug) console.log("✔", "ssidJson parced");
ssidJsonParced = true;
2022-02-23 22:56:17 +01:00
onParced();
}
}
//сборщик errorsJson сообщений
2022-02-27 01:49:03 +01:00
if (data.includes('errors":"')) {
if (IsJsonParse(data)) {
errorsJson = JSON.parse(data);
errorsJson = errorsJson;
errorsJsonParced = true;
if (debug) console.log("✔", "errorsJson json parced");
2022-02-23 22:56:17 +01:00
onParced();
}
}
//сборщик settingsJson сообщений
2022-02-27 01:49:03 +01:00
if (data.includes('settings":"')) {
2022-02-16 00:11:57 +01:00
if (IsJsonParse(data)) {
settingsJson = JSON.parse(data);
settingsJson = settingsJson;
2022-02-26 01:09:17 +01:00
//sortingLayout();
2022-02-16 00:11:57 +01:00
settingsJsonParced = true;
if (debug) console.log("✔", "settingsJson json parced");
2022-02-23 22:56:17 +01:00
onParced();
2022-02-16 00:11:57 +01:00
}
}
//сборщик log сообщений
2022-02-19 23:35:30 +01:00
if (data.includes("/log|")) {
data = data.replace("/log|", "");
//let msg = data.toString();
if (debug) console.log("", data);
addCoreMsg(data);
}
//метки начала конца пакетов для Blob--------------------------------------------------------------------------//
//сборщик scenarioJson пакетов
if (data === "/st/scenario.json") {
scenarioJsonFlag = true;
2022-02-23 01:38:43 +01:00
}
if (data === "/end/scenario.json") {
scenarioJsonFlag = false;
2022-02-23 01:38:43 +01:00
var bb = scenarioTxtBlob.getBlob();
let scenarioJsonReader = new FileReader();
scenarioJsonReader.readAsText(bb);
scenarioJsonReader.onload = () => {
let scenarioJsonResult = scenarioJsonReader.result;
if (IsJsonParse(scenarioJsonResult)) {
scenarioJson = JSON.parse(scenarioJsonResult);
scenarioJson = scenarioJson;
scenarioJsonParced = true;
if (debug) console.log("✔", "scenarioJson parced", scenarioJson);
onParced();
}
2022-02-23 01:38:43 +01:00
};
}
//сборщик configJson пакетов
if (data === "/st/config.json") {
configJsonFlag = true;
}
if (data === "/end/config.json") {
configJsonFlag = false;
var bb = configJsonBlob.getBlob();
let configJsonReader = new FileReader();
configJsonReader.readAsText(bb);
configJsonReader.onload = () => {
let configJsonResult = configJsonReader.result;
if (IsJsonParse(configJsonResult)) {
configJson = JSON.parse(configJsonResult);
configJson = configJson;
configJsonParced = true;
if (debug) console.log("✔", "configJson parced");
2022-02-23 22:56:17 +01:00
onParced();
}
};
}
//сборщик widgetsJson пакетов
if (data === "/st/widgets.json") {
widgetsJsonFlag = true;
}
if (data === "/end/widgets.json") {
widgetsJsonFlag = false;
var bb = widgetsJsonBlob.getBlob();
let widgetsJsonReader = new FileReader();
widgetsJsonReader.readAsText(bb);
widgetsJsonReader.onload = () => {
let widgetsJsonResult = widgetsJsonReader.result;
if (IsJsonParse(widgetsJsonResult)) {
widgetsJson = JSON.parse(widgetsJsonResult);
widgetsJson = widgetsJson;
widgetsJsonParced = true;
if (debug) console.log("✔", "widgetsJson parced");
2022-02-23 22:56:17 +01:00
onParced();
}
};
}
//сборщик itemsJson пакетов
if (data === "/st/items.json") {
itemsJsonFlag = true;
}
if (data === "/end/items.json") {
itemsJsonFlag = false;
var bb = itemsJsonBlob.getBlob();
let itemsJsonReader = new FileReader();
itemsJsonReader.readAsText(bb);
itemsJsonReader.onload = () => {
let itemsJsonResult = itemsJsonReader.result;
if (IsJsonParse(itemsJsonResult)) {
itemsJson = JSON.parse(itemsJsonResult);
itemsJson = itemsJson;
itemsJsonParced = true;
if (debug) console.log("✔", "itemsJson parced");
2022-02-23 22:56:17 +01:00
onParced();
}
};
}
}
//сборщик layoutJson пакетов
if (data === "/st/layout.json") {
}
if (data === "/end/layout.json") {
2022-09-11 14:14:16 +02:00
//createLayoutUnderLoading(ws);
2022-02-26 01:09:17 +01:00
}
//сборщик paramsJson сообщений
2022-02-27 01:49:03 +01:00
if (data.includes('"params":"')) {
2022-02-26 01:09:17 +01:00
if (IsJsonParse(data)) {
2022-03-02 00:42:55 +01:00
//как добавить в объект json новый объект
2022-02-26 01:09:17 +01:00
paramsJson = {
...paramsJson,
...JSON.parse(data),
};
paramsJson = paramsJson;
2022-09-11 14:14:16 +02:00
console.log("[i] paramsJson:", paramsJson);
createLayoutUnderLoading(ws);
2022-02-26 01:09:17 +01:00
onParced();
}
}
//сборщик statusJson сообщений
if (data.includes('"status":')) {
2022-02-26 01:09:17 +01:00
if (IsJsonParse(data)) {
let statusJson = JSON.parse(data);
udateStatusOfWidget(statusJson);
if (debug) console.log("[i] status:", statusJson);
2022-02-26 01:09:17 +01:00
}
}
}
//сообщения типа Blob-------------------------------------------------------------------------------------//
if (event.data instanceof Blob) {
//принимаем данные только для выбранного устройства
if (ws === selectedWs) {
if (configJsonFlag) configJsonBlob.append(event.data);
if (widgetsJsonFlag) widgetsJsonBlob.append(event.data);
if (itemsJsonFlag) itemsJsonBlob.append(event.data);
if (scenarioJsonFlag) scenarioTxtBlob.append(event.data);
}
2022-02-26 01:09:17 +01:00
//принимаем данные от всех устройств
if (!layoutJsonArray[ws]) layoutJsonArray[ws] = new MyBlobBuilder();
layoutJsonArray[ws].append(event.data);
2022-01-24 00:57:27 +01:00
}
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
//функция создающая общий json всех виджетов под загрузкой (не имеющая события завершения)
2022-03-01 01:43:55 +01:00
async function createLayoutUnderLoading(ws) {
var bb = layoutJsonArray[ws].getBlob();
let reader = new FileReader();
reader.readAsText(bb);
reader.onload = () => {
let devLayout = JSON.parse(reader.result);
2022-08-14 17:13:49 +02:00
udateStatusOfDevWidgets(devLayout, ws);
2022-03-01 01:43:55 +01:00
layoutJson = layoutJson.concat(devLayout);
sortingLayout();
};
}
//данная функция обновляет статусы виджетов одного устройства при загрузке страницы dashboard
2022-08-14 17:13:49 +02:00
function udateStatusOfDevWidgets(devLayout, ws) {
2022-03-01 01:43:55 +01:00
for (const [key, value] of Object.entries(paramsJson)) {
for (let i = 0; i < devLayout.length; i++) {
let topic = devLayout[i].topic;
2022-09-10 02:59:03 +02:00
if (topic) {
devLayout[i].ws = ws;
topic = topic.substring(topic.lastIndexOf("/") + 1, topic.length);
if (key === topic) {
2022-09-11 14:14:16 +02:00
console.log("[i]", "updated " + topic, value);
2022-09-10 02:59:03 +02:00
devLayout[i].status = value;
break;
}
2022-02-27 01:49:03 +01:00
}
2022-03-01 01:43:55 +01:00
}
}
2022-02-26 01:09:17 +01:00
}
//данная функция обновляет статусы всех виджетов хранящихся в layoutJson
2022-02-26 01:09:17 +01:00
function udateStatusOfWidget(newStatusJson) {
for (let i = 0; i < layoutJson.length; i++) {
let topic = layoutJson[i].topic;
if (topic === newStatusJson.topic) {
layoutJson[i] = jsonConcat(layoutJson[i], newStatusJson);
//layoutJson[i].status = newStatusJson.status;
//получен ответ - выключаем красный цвет
layoutJson[i].sent = false;
2022-02-26 01:09:17 +01:00
break;
}
}
}
function jsonConcat(o1, o2) {
for (var key in o2) {
o1[key] = o2[key];
}
return o1;
}
2022-02-26 01:09:17 +01:00
async function onParced() {
2022-03-02 00:42:55 +01:00
if (currentPageName === "/|") {
clearParcedFlags();
2022-03-02 00:42:55 +01:00
if (debug) console.log("✔", "dashboard packet received");
dashReady = true;
}
if (currentPageName === "/config|" && itemsJsonParced && widgetsJsonParced && configJsonParced && settingsJsonParced && scenarioJsonParced) {
clearParcedFlags();
if (debug) console.log("✔✔", "config data parced");
configReady = true;
}
if (currentPageName === "/connection|" && ssidJsonParced && settingsJsonParced && errorsJsonParced) {
clearParcedFlags();
if (debug) console.log("✔✔", "connection data parced");
connectionReady = true;
}
2022-02-23 22:56:17 +01:00
if (currentPageName === "/list|" && deviceListParced) {
clearParcedFlags();
if (debug) console.log("✔✔", "list data parced");
listReady = true;
}
2022-02-18 19:48:15 +01:00
if (currentPageName === "/system|" && errorsJsonParced && settingsJsonParced) {
clearParcedFlags();
2022-02-18 19:48:15 +01:00
getVersionsList();
if (debug) console.log("✔✔", "system data parced");
systemReady = true;
}
}
function saveConfig() {
2022-02-09 16:43:24 +01:00
wsSendMsg(selectedWs, "/tuoyal|" + JSON.stringify(generateLayout()));
wsSendMsg(selectedWs, "/gifnoc|" + JSON.stringify(configJson));
wsSendMsg(selectedWs, "/oiranecs|" + JSON.stringify(scenarioJson));
clearData();
sendCurrentPageName();
}
function saveSett() {
var size = Object.keys(settingsJson).length;
console.log("[i]", "settingsJson length: " + size);
if (size > 5) {
jsonArrWrite(deviceList, "ip", getIP(selectedWs), "name", settingsJson.name);
deviceList = deviceList;
wsSendMsg(selectedWs, "/sgnittes|" + JSON.stringify(settingsJson));
} else {
window.alert("Ошибка");
}
clearData();
sendCurrentPageName();
}
2022-08-26 00:01:29 +02:00
function cleanLogs() {
wsSendMsg(selectedWs, "/clean|");
}
function saveMqtt() {
var size = Object.keys(settingsJson).length;
console.log("[i]", "settingsJson length: " + size);
if (size > 5) {
wsSendMsg(selectedWs, "/sgnittes|" + JSON.stringify(settingsJson));
} else {
window.alert("Ошибка");
}
clearData();
wsSendMsg(selectedWs, "/mqtt|");
}
2022-09-11 14:14:16 +02:00
function getInput() {
let input = {
name: "inputDate",
descr: "Выберите дату",
widget: "input",
size: "small",
color: "orange",
type: "date",
};
return input;
}
2022-09-10 02:59:03 +02:00
function generateLayout() {
let layout = [];
for (let i = 0; i < configJson.length; i++) {
let config = Object.assign({}, configJson[i]);
let setWidget = config.widget;
let error = true;
for (let w = 0; w < widgetsJson.length; w++) {
if (setWidget === widgetsJson[w].name) {
let widget = Object.assign({}, widgetsJson[w]);
widget.page = config.page;
widget.descr = config.descr;
//widget.id = config.id;
2022-02-07 23:40:00 +01:00
//widget.ws = selectedWs;
2022-09-11 14:14:16 +02:00
widget.topic = settingsJson.root + "/" + config.id;
layout.push(widget);
2022-09-10 02:59:03 +02:00
if (widget.widget === "chart") {
2022-09-11 14:14:16 +02:00
let input = getInput();
2022-09-10 02:59:03 +02:00
input.page = config.page;
2022-09-11 14:14:16 +02:00
let topic = settingsJson.root + "/" + config.id + "-date";
input.topic = topic;
console.log("[i]", "topic ", topic);
2022-09-10 02:59:03 +02:00
layout.push(input);
}
error = false;
break;
} else {
error = true;
}
}
if (error) console.log("[e]", "error, widget not found: " + setWidget);
}
if (debug) console.log("[i] layout:", JSON.stringify(layout));
return layout;
}
function clearData() {
configJson = [];
configJsonBlob.clear();
widgetsJson = [];
widgetsJsonBlob.clear();
itemsJson = [];
itemsJsonBlob.clear();
layoutJson = [];
2022-02-26 01:09:17 +01:00
layoutJsonArray = [];
scenarioJson = "";
2022-02-23 22:56:17 +01:00
scenarioTxtBlob.clear();
2022-02-23 22:56:17 +01:00
settingsJson = {};
errorsJson = {};
2022-09-10 02:59:03 +02:00
//coreMessages = [];
2022-02-19 23:35:30 +01:00
dashReady = false;
configReady = false;
connectionReady = false;
listReady = false;
systemReady = false;
clearParcedFlags();
if (debug) console.log("[i]", "all app data cleared");
}
function clearParcedFlags() {
configJsonParced = false;
widgetsJsonParced = false;
itemsJsonParced = false;
2022-02-26 01:09:17 +01:00
layoutJsonArrayParced = false;
settingsJsonParced = false;
errorsJsonParced = false;
ssidJsonParced = false;
paramsJsonParced = false;
statusJsonParced = false;
2022-02-23 22:56:17 +01:00
deviceListParced = false;
scenarioJsonParced = false;
2022-02-26 01:09:17 +01:00
clearFlags();
}
function clearFlags() {
for (let i = 0; i < deviceList.length; i++) {
deviceList[i].pp = false;
deviceList[i].lp = false;
}
}
2021-12-08 22:59:21 +01:00
function wsPush(ws, topic, status) {
let msg = topic + " " + status;
2022-08-14 17:13:49 +02:00
if (debug) console.log("[i]", "ws: ", ws, msg);
2022-08-15 01:30:59 +02:00
layoutJson = layoutJson;
let key = topic.substring(topic.lastIndexOf("/") + 1, topic.length);
wsSendMsg(ws, "/control|" + key + "/" + status);
2021-12-08 22:59:21 +01:00
}
2021-12-07 22:14:59 +01:00
function wsTestMsgTask() {
2021-12-21 00:48:44 +01:00
setTimeout(wsTestMsgTask, reconnectTimeout);
if (!rebootingUpdatingInProgress) {
if (debug) console.log("[i]", "----timer tick----");
if (!firstTime) {
deviceList.forEach((device) => {
if (!getDeviceStatus(device.ws)) {
wsConnect(device.ws);
wsEventAdd(device.ws);
} else {
wsSendMsg(device.ws, "/tst|");
}
});
}
firstTime = false;
} else {
if (debug) console.log("[i]", "----timer skipped----");
2021-12-10 16:07:09 +01:00
}
2021-12-08 22:59:21 +01:00
}
function wsSendMsg(ws, msg) {
if (socket[ws] && socket[ws].readyState === 1) {
socket[ws].send(msg);
if (debug) console.log("[i]", getIP(ws), ws, "msg send success", msg);
2021-12-08 22:59:21 +01:00
} else {
if (debug) console.log("[e]", getIP(ws), ws, "msg not send", msg);
2021-12-07 22:14:59 +01:00
}
2021-12-06 01:21:55 +01:00
}
function sendToAllDevices(msg) {
deviceList.forEach((device) => {
if (device.status) {
wsSendMsg(device.ws, msg);
}
});
}
//***********************************************************dashboard***************************************************************/
2022-02-26 01:09:17 +01:00
function sortingLayout() {
2022-03-02 00:42:55 +01:00
//сортируем весь layout по алфавиту
layoutJson.sort(function (a, b) {
if (a.descr < b.descr) {
return -1;
}
if (a.descr > b.descr) {
return 1;
}
return 0;
});
//формируем json всех карточек
2021-10-17 07:09:55 +08:00
pages = [];
const newPage = Array.from(new Set(Array.from(layoutJson, ({ page }) => page)));
2021-10-17 07:09:55 +08:00
newPage.forEach(function (item, i, arr) {
2022-02-07 16:36:43 +01:00
pages = [
...pages,
JSON.parse(
JSON.stringify({
page: item,
})
),
];
2021-10-17 07:09:55 +08:00
});
2022-03-02 00:42:55 +01:00
//сортируем карточки по алфавиту
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
//***********************************************************logging******************************************************************/
2021-12-07 22:14:59 +01:00
const addCoreMsg = (msg) => {
2022-02-19 23:35:30 +01:00
if (coreMessages.length >= LOG_MAX_MESSAGES) {
coreMessages.shift();
2021-12-05 00:49:36 +01:00
}
2022-02-19 23:35:30 +01:00
//const time = new Date().getTime();
2022-02-07 16:36:43 +01:00
coreMessages = [
...coreMessages,
{
msg,
},
];
2021-12-07 22:14:59 +01:00
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
//***********************************************************dev list******************************************************************/
2022-02-07 23:40:00 +01:00
function combineArrays(A, B) {
var ids = new Set(A.map((d) => d.ip));
let output = [...A, ...B.filter((d) => !ids.has(d.ip))];
return output;
2022-02-07 16:36:43 +01:00
}
2022-02-07 23:40:00 +01:00
function whenDeviceListWasUpdated() {
getSelectedDeviceData(selectedWs);
2021-12-09 22:35:04 +01:00
socketConnected = selectedDeviceData.status;
2022-02-07 23:40:00 +01:00
}
function devicesDropdownChange() {
whenDeviceListWasUpdated();
clearData();
handleNavigation();
//sendCurrentPageName();
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
}
2022-02-07 23:40:00 +01:00
function getSelectedDeviceData(ws) {
for (let i = 0; i < deviceList.length; i++) {
let device = deviceList[i];
if (device.ws === ws) {
selectedDeviceData = device;
break;
}
}
}
function addDevInList() {
2022-02-07 16:36:43 +01:00
//createDefaultDevice();
if (!showInput) {
if (newDevice.name !== undefined && newDevice.ip !== undefined && newDevice.id !== undefined) {
newDevice.status = false;
deviceList.push(newDevice);
deviceList = deviceList;
newDevice = {};
2022-02-07 23:40:00 +01:00
whenDeviceListWasUpdated();
connectToAllDevices();
2021-12-13 00:01:21 +01:00
if (debug) console.log("[i]", "selected device:", selectedDeviceData);
} else {
if (debug) console.log("[e]", "wrong data");
}
}
}
2022-02-07 23:40:00 +01:00
function updateThisDeviceInList() {
for (let i = 0; i < deviceList.length; i++) {
let device = deviceList[i];
if (device.ip === myip) {
device.name = settingsJson.name;
device.id = settingsJson.id;
settingsJson = settingsJson;
break;
}
}
}
//****************************************************************json******************************************************************/
2021-12-14 20:55:53 +01:00
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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
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;
};
function IsJsonParse(str) {
try {
JSON.parse(str);
} catch (e) {
2022-02-27 01:49:03 +01:00
if (debug) console.log("[e]", "json parce error: ", str);
return false;
}
return true;
}
//пример как формировать массив json
function createWidgetsDropdown() {
let widgetsDropdown = [];
widgetsJson.forEach((widget) => {
widgetsDropdown.push({
id: widget.name,
val: widget.rus,
});
});
widgetsDropdown = widgetsDropdown;
if (debug) console.log("[i]", widgetsDropdown);
}
function jsonArrWrite(jsonArr, idKey, idValue, paramKey, paramValue) {
for (let i = 0; i < jsonArr.length; i++) {
let obj = jsonArr[i];
for (const [key, value] of Object.entries(obj)) {
if (key == idKey && value == idValue) {
obj[paramKey] = paramValue;
break;
}
}
}
}
//**********************************************************post and get*****************************************************************/
//editRequest("192.168.88.235", "data data data data", "file.json")
function editRequest(url, data, filename) {
if (debug) console.log("[i]", "request for edit file");
var xmlHttp = new XMLHttpRequest();
var formData = new FormData();
2022-02-07 16:36:43 +01:00
formData.append(
"data",
new Blob([data], {
type: "text/json",
}),
"/" + filename
);
xmlHttp.open("POST", "http://" + url + "/edit");
xmlHttp.onload = function () {
//во время загрузки
};
xmlHttp.send(formData);
}
async function handleSubmit(url) {
try {
console.log(url);
let res = await fetch(url, {
mode: "no-cors",
method: "GET",
});
if (res.ok) {
console.log("OK", res.status);
//console.log(url);
} else {
console.log("error", res.status);
//console.log(url);
}
} catch (e) {
console.log(e);
}
}
async function getRequestJson(url) {
2022-02-18 19:48:15 +01:00
try {
let res = await fetch(url, {
mode: "no-cors",
method: "GET",
});
if (res.ok) {
configSetupJson = await res.json();
} else {
console.log("error", res.status);
}
} catch (e) {
console.log(e);
}
}
2021-12-26 00:04:34 +01:00
function showAdditionalParams(id) {
2021-12-26 01:34:29 +01:00
additionalParams = true;
2021-12-26 00:04:34 +01:00
if (debug) console.log("[i]", "user open add params ", id);
}
//**********************************************************modal*************************************************************************/
2021-12-27 02:46:05 +01:00
function showModal() {
showModalFlag = !showModalFlag;
}
function onCheck() {
let width = screen.width;
console.log("width", width);
if (width < 900) {
preventMove = true;
} else {
preventMove = false;
}
}
//************************************************elements and presets dropdown************************************************************/
function ssidClick() {
2022-02-09 16:43:24 +01:00
wsSendMsg(selectedWs, "/scan|");
}
function rebootEsp() {
if (debug) console.log("[i]", "reboot...");
2022-02-09 16:43:24 +01:00
wsSendMsg(selectedWs, "/reboot|");
rebootingUpdatingInProgress = true;
myTimeout = setTimeout(rebootingTask, rebootingTimeout);
}
function rebootingTask() {
clearTimeout(myTimeout);
2022-02-23 22:56:17 +01:00
clearData();
connectToAllDevices();
rebootingUpdatingInProgress = false;
}
2022-02-09 16:43:24 +01:00
function cancelAlarm(alarmKey) {
console.log("[x]", alarmKey);
errorsJson[alarmKey] = 0;
wsSendMsg(selectedWs, '/rorre|{"' + alarmKey + '":0}');
2022-02-09 16:43:24 +01:00
}
2022-02-11 19:32:05 +01:00
2022-02-18 19:48:15 +01:00
//************************************************update esp firm************************************************************//
async function getVersionsList() {
try {
let url = settingsJson.serverip + "/iotm/ver.json";
console.log("url", url);
let res = await fetch(url, {
mode: "cors",
method: "GET",
});
if (res.ok) {
versionsList = await res.json();
versionsList = versionsList[errorsJson.bn];
choosingVersion = errorsJson.bver;
console.log(JSON.stringify(versionsList));
} else {
choosingVersion = undefined;
console.log("error, versions list not received", res.statusText);
}
} catch (e) {
choosingVersion = undefined;
console.log("error, versions list not received");
console.log(e);
}
}
function startUpdate() {
if (choosingVersion !== undefined) {
if (choosingVersion === errorsJson.bver) {
window.alert("Эта версия уже установленна");
} else {
if (confirm("Запустить обновление?")) {
console.log("start update...");
//запишем выбранную версию в файл на esp
wsSendMsg(selectedWs, '/rorre|{"chver":' + choosingVersion + "}");
//начнем обновление
wsSendMsg(selectedWs, "/update|");
rebootingUpdatingInProgress = true;
2022-02-18 22:53:39 +01:00
myTimeout = setTimeout(rebootingTask, updatingTimeout);
2022-02-18 19:48:15 +01:00
} else {
console.log("update canceled");
}
}
} else {
window.alert("Версия не выбрана или сервер недоступен");
}
}
2021-09-16 02:00:52 +08:00
</script>
<div class="flex flex-col h-screen bg-gray-50">
{#if rebootingUpdatingInProgress}
<Progress />
{/if}
<header class="h-10 w-full bg-gray-100 overflow-auto shadow-md">
2022-02-07 16:36:43 +01:00
<div class="flex content-center items-center justify-end">
<div class="px-15 py-1">
2022-02-07 23:40:00 +01:00
<select class="border border-indigo-500 border-4" bind:value={selectedWs} on:change={() => devicesDropdownChange()}>
2021-12-09 00:10:10 +01:00
{#each deviceList as device}
2022-02-07 23:40:00 +01:00
<option value={device.ws}>
2021-12-09 00:10:10 +01:00
{device.name}
</option>
{/each}
</select>
</div>
2022-08-31 22:25:22 +02:00
<!--<div class="pl-4 pr-1 py-1">-->
<!--<BookIcon color={socketConnected === true ? "text-green-500" : "text-red-500"} />-->
<!--</div>-->
2022-02-07 16:36:43 +01:00
<div class="pl-4 pr-4 py-1">
<CloudIcon color={socketConnected === true ? "text-green-500" : "text-red-500"} />
2021-12-09 00:10:10 +01:00
</div>
2021-12-06 01:21:55 +01:00
</div>
</header>
<nav class="flex">
<input class="w-0 h-0" bind:checked={opened} on:change={() => onCheck()} id="menu__toggle" type="checkbox" />
<label class="menu__btn" for="menu__toggle">
<span />
</label>
<ul class="menu__box">
<li>
<a class="menu__item" href="/">{"Управление"}</a>
</li>
<li>
<a class="menu__item" href="/config">{"Конфигуратор"}</a>
</li>
<li>
<a class="menu__item" href="/connection">{"Подключение"}</a>
</li>
<li>
<a class="menu__item" href="/list">{"Устройства"}</a>
</li>
<li>
<a class="menu__item" href="/system">{"Системные"}</a>
</li>
2022-09-10 02:59:03 +02:00
{#if devMode}
<li>
<a class="menu__item" href="/dev">{"Разработчик"}</a>
</li>
{/if}
</ul>
</nav>
<main class="flex-1 overflow-y-auto p-0 {opened === true && !preventMove ? 'ml-36' : 'ml-0'}">
<ul class="menu__main">
<div class="bg-cover pt-0 px-4">
{#if !socketConnected}
2022-02-07 02:08:21 +01:00
<Alarm title="Нет соединения" />
{:else}
<Route path="/">
<DashboardPage show={dashReady} layoutJson={layoutJson} pages={pages} wsPush={(ws, topic, status) => wsPush(ws, topic, status)} />
</Route>
<Route path="/config">
<ConfigPage show={configReady} configJson={configJson} widgetsJson={widgetsJson} itemsJson={itemsJson} saveConfig={() => saveConfig()} cleanLogs={() => cleanLogs()} rebootEsp={() => rebootEsp()} scenarioJson={scenarioJson} />
</Route>
<Route path="/connection">
<ConnectionPage show={connectionReady} rebootEsp={() => rebootEsp()} ssidClick={() => ssidClick()} saveSett={() => saveSett()} saveMqtt={() => saveMqtt()} settingsJson={settingsJson} errorsJson={errorsJson} ssidJson={ssidJson} />
</Route>
<Route path="/list">
<ListPage show={listReady} deviceList={deviceList} showInput={showInput} addDevInList={() => addDevInList()} newDevice={newDevice} sendToAllDevices={(msg) => sendToAllDevices(msg)} />
</Route>
<Route path="/system">
2022-08-26 00:01:29 +02:00
<SystemPage show={systemReady} errorsJson={errorsJson} settingsJson={settingsJson} saveSett={() => saveSett()} cleanLogs={() => cleanLogs()} cancelAlarm={(alarmKey) => cancelAlarm(alarmKey)} versionsList={versionsList} bind:choosingVersion startUpdate={() => startUpdate()} coreMessages={coreMessages} />
</Route>
2022-09-10 02:59:03 +02:00
{#if devMode}
<Route path="/dev">
<DevPage show={systemReady} layoutJson={layoutJson} errorsJson={errorsJson} settingsJson={settingsJson} configJson={configJson} itemsJson={itemsJson} />
</Route>
{/if}
{/if}
</div>
</ul>
</main>
2022-02-07 16:36:43 +01:00
<footer class="h-4 bg-gray-100 border-gray-200 shadow-lg">
<div class="flex justify-center content-center text-xxs text-gray-500">Developed by Dmitry Borisenko</div>
</footer>
</div>
2021-09-16 02:00:52 +08:00
<style lang="postcss" global>
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer components {
2022-02-07 16:36:43 +01:00
/*==================================================grids=====================================================*/
.grd-1col1 {
2021-10-16 20:49:17 +00:00
@apply grid grid-cols-1 justify-items-center;
}
2022-02-07 16:36:43 +01:00
.grd-2col1 {
@apply grid gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 xl:grid-cols-2 2xl:grid-cols-2 justify-items-center;
2022-02-07 16:36:43 +01:00
}
.grd-2col2 {
@apply grid gap-4 grid-cols-2 justify-items-center;
}
.grd-3col1 {
@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-10-20 20:53:07 +08:00
/*=============================================card and items inside===============================================*/
2021-12-28 23:55:14 +01:00
.crd-itm-psn {
2022-02-16 00:11:57 +01:00
@apply flex mb-2 h-8 items-center;
2021-10-20 20:53:07 +08:00
}
2021-12-28 23:55:14 +01:00
.wgt-dscr-stl {
2021-10-20 20:53:07 +08:00
@apply pr-4 text-gray-500 font-bold;
}
2021-10-25 16:50:31 +07:00
/*====================================================others=====================================================*/
2021-12-28 23:55:14 +01:00
.btn-i {
2021-10-25 16:50:31 +07:00
@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;
}
2021-12-28 23:55:14 +01:00
.wgt-adt-stl {
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=====================================================*/
2022-02-07 02:08:21 +01:00
.tbl {
@apply table-fixed w-full select-none my-2;
}
2021-12-28 23:55:14 +01:00
.tbl-hd {
@apply text-center px-1 break-words text-gray-500 font-bold;
2021-12-11 13:54:28 +01:00
}
2022-02-07 16:36:43 +01:00
.tbl-bdy-lg {
@apply text-center px-1 break-words;
2021-12-11 13:54:28 +01:00
}
2022-02-07 16:36:43 +01:00
.tbl-bdy-sm {
@apply px-1 break-words;
2021-12-28 01:06:01 +01:00
}
2022-02-07 16:36:43 +01:00
/*====================================================inputs=====================================================*/
.ipt-lg {
@apply h-4 sm:h-7 md:h-7 lg:h-7 xl:h-7 2xl:h-7 content-center mt-2 bg-gray-50 focus:bg-white border-2 border-gray-100 text-gray-700 leading-tight focus:outline-none text-center focus:border-indigo-500;
}
.ipt-sm {
@apply h-3 sm:h-6 md:h-6 lg:h-6 xl:h-6 2xl:h-6 content-center bg-gray-50 focus:bg-white border-2 border-gray-100 text-gray-700 leading-tight focus:outline-none text-center focus:border-indigo-500 rounded-sm;
}
2022-02-07 16:36:43 +01:00
.ipt-rnd {
@apply content-center px-2 h-8 bg-gray-50 border-2 border-gray-200 rounded w-full text-gray-700 leading-tight focus:outline-none focus:bg-white;
}
.ipt-big {
@apply content-center px-2 h-8 bg-gray-50 border-2 border-gray-200 rounded w-full text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-indigo-500;
2021-12-29 01:21:28 +01:00
}
2022-02-07 16:36:43 +01:00
/*====================================================text=====================================================*/
.txt-ita {
2021-12-29 01:21:28 +01:00
@apply inline-block italic align-top text-right text-gray-500;
}
2022-02-07 16:36:43 +01:00
.txt-pad {
2021-12-28 22:09:44 +01:00
@apply px-2 py-0 sm:py-0 md:py-0 lg:py-1 xl:py-2 2xl:py-2;
}
2022-02-07 16:36:43 +01:00
.txt-sz {
2021-12-29 01:21:28 +01:00
@apply text-xxs sm:text-base md:text-base lg:text-base xl:text-base 2xl:text-base;
2021-12-28 22:09:44 +01:00
}
/*====================================================buttons=====================================================*/
2021-12-28 23:55:14 +01:00
.btn-lg {
@apply flex justify-center break-words content-center bg-blue-100 hover:bg-blue-200 text-gray-500 font-bold text-sm sm:text-base md:text-base lg:text-base xl:text-base 2xl:text-base h-6 sm:h-8 md:h-8 lg:h-8 xl:h-8 2xl:h-8 w-full mt-0 border border-gray-300 rounded;
}
2021-12-28 23:55:14 +01:00
.btn-tbl {
2021-12-29 01:21:28 +01:00
@apply flex justify-center content-center text-gray-500 font-bold w-6 h-auto border border-gray-300;
}
2021-12-28 01:06:01 +01:00
/*====================================================select=====================================================*/
2021-12-28 23:55:14 +01:00
.slct-lg {
@apply flex w-full justify-center break-words content-center bg-blue-100 hover:bg-blue-200 text-gray-500 font-bold text-sm sm:text-base md:text-base lg:text-base xl:text-base 2xl:text-base h-6 sm:h-8 md:h-8 lg:h-8 xl:h-8 2xl:h-8 mb-0 border border-gray-300 rounded;
2021-12-28 01:06:01 +01:00
}
2021-09-16 02:00:52 +08:00
}
#menu__toggle {
position: relative;
2021-09-16 02:00:52 +08:00
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: 2;
2021-09-16 02:00:52 +08:00
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;
z-index: 1;
2021-09-16 02:00:52 +08:00
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>