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
|
2023-06-08 22:37:43 +02:00
|
|
|
|
Vienna, Austria 1030, Juchgasse 5/17
|
|
|
|
|
|
+43 67761588253
|
2022-02-22 20:20:59 +01:00
|
|
|
|
*/
|
2022-02-19 23:35:30 +01:00
|
|
|
|
|
2023-06-11 17:01:57 +02:00
|
|
|
|
//6+49 кб 09/06/2023
|
2023-10-02 17:25:05 +02:00
|
|
|
|
//6+51 кб 02/09/2023
|
|
|
|
|
|
//6+64 кб 02/10/2023 + axios
|
|
|
|
|
|
//6+53 кб 03/10/2023 + fetch
|
2023-06-11 17:01:57 +02: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";
|
2022-02-06 23:02:20 +01:00
|
|
|
|
router.mode.hash();
|
|
|
|
|
|
|
2022-02-07 02:08:21 +01:00
|
|
|
|
import Alarm from "./components/Alarm.svelte";
|
2022-02-08 16:47:26 +01:00
|
|
|
|
import Progress from "./components/Progress.svelte";
|
2023-10-04 18:56:24 +02:00
|
|
|
|
//import Card from "./components/Card.svelte";
|
2021-12-26 01:34:29 +01:00
|
|
|
|
|
2023-10-04 18:56:24 +02:00
|
|
|
|
//import ModalPass from "./components/ModalPass.svelte";
|
2022-02-06 23:02:20 +01:00
|
|
|
|
import DashboardPage from "./pages/Dashboard.svelte";
|
|
|
|
|
|
import ConfigPage from "./pages/Config.svelte";
|
|
|
|
|
|
import ConnectionPage from "./pages/Connection.svelte";
|
2022-02-08 21:42:40 +01:00
|
|
|
|
import ListPage from "./pages/List.svelte";
|
|
|
|
|
|
import SystemPage from "./pages/System.svelte";
|
2023-10-05 01:39:15 +02:00
|
|
|
|
import Login from "./pages/Login.svelte";
|
2023-10-04 18:56:24 +02:00
|
|
|
|
import Profile from "./pages/Profile.svelte";
|
2023-10-02 17:25:05 +02:00
|
|
|
|
import { t, locale, locales } from "./i18n";
|
2023-10-05 01:39:15 +02:00
|
|
|
|
import Cookies from "js-cookie";
|
2022-02-08 21:42:40 +01:00
|
|
|
|
|
2022-02-12 03:07:59 +01:00
|
|
|
|
//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
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
import * as portal from "./api/portal.js";
|
|
|
|
|
|
import * as firmware from "./api/firmware.js";
|
|
|
|
|
|
import * as deviceSocket from "./api/deviceSocket.js";
|
|
|
|
|
|
import * as deviceConnection from "./lib/deviceConnection.js";
|
|
|
|
|
|
import * as deviceListManager from "./lib/deviceListManager.js";
|
|
|
|
|
|
import * as blobProtocol from "./lib/blobProtocol.js";
|
|
|
|
|
|
import * as wsReconnect from "./lib/wsReconnect.js";
|
|
|
|
|
|
import AppHeader from "./components/layout/AppHeader.svelte";
|
|
|
|
|
|
import AppNav from "./components/layout/AppNav.svelte";
|
|
|
|
|
|
import AppFooter from "./components/layout/AppFooter.svelte";
|
2022-02-07 16:36:43 +01:00
|
|
|
|
|
2021-12-28 21:18:03 +01:00
|
|
|
|
//****************************************************constants section*********************************************************/
|
|
|
|
|
|
//******************************************************************************************************************************/
|
2022-10-09 17:03:41 +02:00
|
|
|
|
const debug = true;
|
|
|
|
|
|
const LOG_MAX_MESSAGES = 100;
|
2023-10-06 01:07:49 +02:00
|
|
|
|
let reconnectTimeout = 60; //период проверки соединения с устройством
|
|
|
|
|
|
let remainingTimeout = reconnectTimeout;
|
2023-06-13 21:06:04 +02:00
|
|
|
|
let preventReconnect = false;
|
2023-09-22 19:40:34 +02:00
|
|
|
|
const waitingAckTimeout = 18000; //время ожидания ответа от устройства
|
2023-10-06 01:36:13 +02:00
|
|
|
|
let rebootOrUpdateProcess = false;
|
2023-06-13 21:06:04 +02:00
|
|
|
|
let rebootTimer;
|
2023-10-05 14:38:57 +02:00
|
|
|
|
let opened = true;
|
2022-02-01 16:01:19 +01:00
|
|
|
|
let preventMove = false;
|
2023-10-05 14:38:57 +02:00
|
|
|
|
let screenSize;
|
2023-06-17 22:26:52 +02:00
|
|
|
|
const blobDebug = false;
|
2026-02-07 00:38:05 +01:00
|
|
|
|
const devMode = true;
|
2021-12-14 20:55:53 +01:00
|
|
|
|
|
2023-06-09 01:00:14 +02:00
|
|
|
|
let percent;
|
|
|
|
|
|
|
2021-12-28 21:18:03 +01:00
|
|
|
|
//****************************************************variable section**********************************************************/
|
|
|
|
|
|
//******************************************************************************************************************************/
|
2022-08-16 00:56:12 +02:00
|
|
|
|
let myip = document.location.hostname;
|
2026-02-07 00:38:05 +01:00
|
|
|
|
if (devMode) myip = "127.0.0.1";
|
2021-12-14 20:55:53 +01:00
|
|
|
|
|
2021-12-28 21:18:03 +01:00
|
|
|
|
//Flags
|
2022-02-13 23:13:08 +01:00
|
|
|
|
let firstDevListRequest = true;
|
2021-12-28 21:18:03 +01:00
|
|
|
|
let showInput = false;
|
2023-06-17 22:26:52 +02:00
|
|
|
|
let authorization = false;
|
2023-06-08 22:37:43 +02:00
|
|
|
|
let showDropdown = true;
|
2022-02-06 23:02:20 +01:00
|
|
|
|
|
2023-06-13 21:06:04 +02:00
|
|
|
|
let showAwaitingCircle = false;
|
2022-02-24 00:59:10 +01:00
|
|
|
|
|
2021-12-14 20:55:53 +01:00
|
|
|
|
//dashboard
|
|
|
|
|
|
let pages = [];
|
|
|
|
|
|
|
2022-09-25 17:49:24 +02:00
|
|
|
|
//ready
|
|
|
|
|
|
let pageReady = {
|
|
|
|
|
|
dash: false,
|
|
|
|
|
|
config: false,
|
|
|
|
|
|
connection: false,
|
|
|
|
|
|
list: false,
|
|
|
|
|
|
system: false,
|
|
|
|
|
|
dev: false,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2022-02-18 19:48:15 +01:00
|
|
|
|
//update esp
|
|
|
|
|
|
let versionsList = {};
|
|
|
|
|
|
let choosingVersion = undefined;
|
|
|
|
|
|
|
2022-08-23 15:13:50 +02:00
|
|
|
|
//JSON Files====================================
|
2022-02-01 16:01:19 +01:00
|
|
|
|
let itemsJson = [];
|
2022-10-09 14:31:07 +02:00
|
|
|
|
let widgetsJson = [];
|
|
|
|
|
|
let configJson = [];
|
2022-10-12 03:18:04 +02:00
|
|
|
|
let scenarioTxt = " ";
|
2022-02-02 23:37:15 +01:00
|
|
|
|
let settingsJson = {};
|
2022-02-05 02:13:46 +01:00
|
|
|
|
let ssidJson = {};
|
2022-10-09 14:31:07 +02:00
|
|
|
|
let errorsJson = {};
|
2023-10-11 01:50:08 +02:00
|
|
|
|
let flashProfileJson = {};
|
|
|
|
|
|
let otaJson = {};
|
2022-02-07 23:40:00 +01:00
|
|
|
|
let deviceList = [];
|
2021-12-13 02:36:26 +01:00
|
|
|
|
deviceList = [
|
|
|
|
|
|
{
|
2022-02-07 23:40:00 +01:00
|
|
|
|
name: "--",
|
|
|
|
|
|
id: "--",
|
|
|
|
|
|
ip: myip,
|
2022-02-13 23:13:08 +01:00
|
|
|
|
ws: 0,
|
2022-02-07 02:08:21 +01:00
|
|
|
|
status: false,
|
|
|
|
|
|
},
|
2021-12-13 02:36:26 +01:00
|
|
|
|
];
|
2022-10-09 14:31:07 +02:00
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
// ack state lives in wsReconnect.createAck
|
2023-10-06 01:07:49 +02:00
|
|
|
|
|
2022-10-09 21:29:56 +02:00
|
|
|
|
let incDeviceList = [];
|
2022-10-09 14:31:07 +02:00
|
|
|
|
let layoutJson = [];
|
|
|
|
|
|
let paramsJson = {};
|
|
|
|
|
|
|
2023-10-05 01:39:15 +02:00
|
|
|
|
let userdata = null;
|
2023-10-10 16:14:19 +02:00
|
|
|
|
let allmodeinfo = null;
|
|
|
|
|
|
let profile = null;
|
|
|
|
|
|
|
|
|
|
|
|
let serverOnline = false;
|
2023-10-05 01:39:15 +02:00
|
|
|
|
|
2022-10-09 14:31:07 +02:00
|
|
|
|
let parsed = {
|
|
|
|
|
|
itemsJson: false,
|
|
|
|
|
|
widgetsJson: false,
|
|
|
|
|
|
configJson: false,
|
|
|
|
|
|
scenarioTxt: false,
|
|
|
|
|
|
settingsJson: false,
|
|
|
|
|
|
ssidJson: false,
|
|
|
|
|
|
incDeviceList: false,
|
|
|
|
|
|
deviceListJson: false,
|
|
|
|
|
|
errorsJson: false,
|
|
|
|
|
|
statusJson: false,
|
|
|
|
|
|
paramsJson: false,
|
2023-10-11 01:50:08 +02:00
|
|
|
|
flashProfileJson: false,
|
|
|
|
|
|
otaJson: false,
|
2022-10-09 14:31:07 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//===============================================
|
2021-12-12 00:20:47 +01:00
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
// web sockets: pool in api/deviceSocket.js
|
2022-02-13 00:37:58 +01:00
|
|
|
|
let socketConnected = false;
|
|
|
|
|
|
let selectedDeviceData = undefined;
|
|
|
|
|
|
let selectedWs = 0;
|
2023-06-11 17:01:57 +02:00
|
|
|
|
let originalWs = 0;
|
2022-02-13 00:37:58 +01:00
|
|
|
|
|
|
|
|
|
|
let newDevice = {};
|
|
|
|
|
|
let coreMessages = [];
|
|
|
|
|
|
|
2022-01-30 17:44:53 +01:00
|
|
|
|
//***********************************************************navigation********************************************************/
|
2021-12-16 00:18:40 +01:00
|
|
|
|
let currentPageName = undefined;
|
2022-02-05 02:13:46 +01:00
|
|
|
|
|
2021-12-16 00:18:40 +01:00
|
|
|
|
router.subscribe(handleNavigation);
|
|
|
|
|
|
|
2022-01-30 17:44:53 +01:00
|
|
|
|
function handleNavigation() {
|
|
|
|
|
|
currentPageName = $router.path.toString();
|
2023-06-09 01:00:14 +02:00
|
|
|
|
currentPageName = currentPageName + "|";
|
2023-06-11 17:01:57 +02:00
|
|
|
|
|
2023-06-09 01:00:14 +02:00
|
|
|
|
console.log("[i]", "user on page:", currentPageName);
|
|
|
|
|
|
|
2023-10-02 17:25:05 +02:00
|
|
|
|
clearData();
|
2023-06-08 22:37:43 +02:00
|
|
|
|
|
2023-06-11 17:01:57 +02:00
|
|
|
|
//если мы на странице dashboard то рассылаем всем устройствам запрос данных
|
2022-02-26 01:09:17 +01:00
|
|
|
|
if (currentPageName === "/|") {
|
|
|
|
|
|
sendToAllDevices(currentPageName);
|
2023-06-11 17:01:57 +02:00
|
|
|
|
showDropdown = false;
|
|
|
|
|
|
//в остальных случаях шлем только выбранному устройству запрос данных
|
2022-02-26 01:09:17 +01:00
|
|
|
|
} else {
|
2023-06-11 17:01:57 +02:00
|
|
|
|
if (currentPageName === "/list|") {
|
2023-06-13 21:06:04 +02:00
|
|
|
|
//если мы перешли на страницу списка устройств отключаем выпадающий список
|
2023-06-11 17:01:57 +02:00
|
|
|
|
showDropdown = false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showDropdown = true;
|
|
|
|
|
|
}
|
2023-06-13 21:06:04 +02:00
|
|
|
|
//если мы на любой другой странице то запрашиваем данные
|
|
|
|
|
|
sendCurrentPageNameToSelectedWs();
|
2022-02-26 01:09:17 +01:00
|
|
|
|
}
|
2022-01-30 17:44:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-13 21:06:04 +02:00
|
|
|
|
function sendCurrentPageNameToSelectedWs() {
|
2022-02-07 23:40:00 +01:00
|
|
|
|
if (selectedWs !== undefined) {
|
|
|
|
|
|
wsSendMsg(selectedWs, currentPageName);
|
2022-01-30 17:44:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-12-28 21:18:03 +01:00
|
|
|
|
|
2022-02-23 22:56:17 +01:00
|
|
|
|
//*******************************************************initialisation********************************************************************/
|
|
|
|
|
|
onMount(async () => {
|
|
|
|
|
|
console.log("[i]", "mounted");
|
2023-10-05 01:39:15 +02:00
|
|
|
|
await getUser();
|
2023-10-05 14:38:57 +02:00
|
|
|
|
onCheck();
|
|
|
|
|
|
opened = screenSize > 900 ? true : false;
|
2023-06-11 17:01:57 +02:00
|
|
|
|
selectedDeviceDataRefresh();
|
2023-06-08 22:37:43 +02:00
|
|
|
|
//флаг первого запроса списка устройств
|
2022-02-23 22:56:17 +01:00
|
|
|
|
firstDevListRequest = true;
|
2023-06-08 22:37:43 +02:00
|
|
|
|
//вначале подключимся к известному нам ip этого устройства
|
2022-02-23 22:56:17 +01:00
|
|
|
|
connectToAllDevices();
|
|
|
|
|
|
wsTestMsgTask();
|
2022-10-07 22:29:04 +02:00
|
|
|
|
//sortingLayout();
|
2022-02-23 22:56:17 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
2023-10-05 01:39:15 +02:00
|
|
|
|
const getUser = async () => {
|
2026-02-08 22:41:16 +01:00
|
|
|
|
const JWT = Cookies.get("token_iotm2");
|
|
|
|
|
|
const res = await portal.getUser(JWT);
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
|
userdata = res.userdata;
|
|
|
|
|
|
serverOnline = true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (!res.serverOnline) serverOnline = false;
|
|
|
|
|
|
else {
|
|
|
|
|
|
console.log("error", "getUser");
|
2023-10-10 16:14:19 +02:00
|
|
|
|
serverOnline = true;
|
2023-10-05 01:39:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-12-28 21:18:03 +01:00
|
|
|
|
//****************************************************web sockets section******************************************************/
|
2026-02-08 22:41:16 +01:00
|
|
|
|
function getIP(ws) {
|
|
|
|
|
|
return deviceConnection.getIP(ws, deviceList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function wsSendMsg(ws, msg) {
|
|
|
|
|
|
if (deviceSocket.send(ws, msg)) {
|
|
|
|
|
|
if (debug) console.log("[i]", getIP(ws), ws, "msg send success", msg);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (debug) console.log("[e]", getIP(ws), ws, "msg not send");
|
2023-06-13 21:06:04 +02:00
|
|
|
|
}
|
2021-12-05 00:49:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
const openHandler = () =>
|
|
|
|
|
|
deviceConnection.createOpenHandler({
|
|
|
|
|
|
markDeviceStatus,
|
|
|
|
|
|
sendMsg: wsSendMsg,
|
|
|
|
|
|
firstDevListRequest,
|
|
|
|
|
|
currentPageName,
|
|
|
|
|
|
selectedWs,
|
|
|
|
|
|
sendCurrentPageNameToSelectedWs,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function messageHandler(ws, data) {
|
|
|
|
|
|
if (typeof data === "string") {
|
|
|
|
|
|
if (data === "/tstr|") ack(ws, true);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (data instanceof Blob) {
|
|
|
|
|
|
if (ws === selectedWs) parseBlob(data, ws);
|
|
|
|
|
|
if (currentPageName === "/|") parseAllBlob(data, ws);
|
2023-06-13 21:06:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
function createConnection(wsIndex, ip) {
|
|
|
|
|
|
if (ip === "error") {
|
|
|
|
|
|
if (debug) console.log("[e]", "device list wrong");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (debug) console.log("[i]", ip, wsIndex, "started connecting...");
|
|
|
|
|
|
deviceSocket.createConnection(wsIndex, ip, {
|
|
|
|
|
|
onOpen: (ws) => openHandler()(ws),
|
|
|
|
|
|
onMessage: messageHandler,
|
|
|
|
|
|
onClose: (ws) => markDeviceStatus(ws, false),
|
|
|
|
|
|
onError: (ws) => markDeviceStatus(ws, false),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function connectToAllDevices() {
|
|
|
|
|
|
deviceConnection.connectToAllDevices(deviceList, getSelectedDeviceData, selectedWs, createConnection);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function printAllCreatedWs() {
|
|
|
|
|
|
if (debug) console.log("[i]", "[ws]", "device count:", deviceList.length);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-09 00:10:10 +01:00
|
|
|
|
function markDeviceStatus(ws, status) {
|
|
|
|
|
|
deviceList.forEach((device) => {
|
|
|
|
|
|
if (device.ws === ws) {
|
|
|
|
|
|
device.status = status;
|
2022-10-29 01:42:51 +02:00
|
|
|
|
device.ping = 0;
|
2023-06-13 21:06:04 +02:00
|
|
|
|
if (device.status === true) {
|
2022-11-21 00:38:58 +01:00
|
|
|
|
console.log("[i]", device.ip, ws, "status online");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.log("[i]", device.ip, ws, "status offline");
|
|
|
|
|
|
deleteWidget(ws);
|
|
|
|
|
|
sortingLayout(ws);
|
2021-12-09 22:35:04 +01:00
|
|
|
|
}
|
2021-12-09 00:10:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2023-06-11 17:01:57 +02:00
|
|
|
|
selectedDeviceDataRefresh();
|
2021-12-09 22:35:04 +01:00
|
|
|
|
deviceList = deviceList;
|
2022-10-29 01:42:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-21 00:38:58 +01:00
|
|
|
|
function deleteWidget(ws) {
|
|
|
|
|
|
layoutJson = layoutJson.filter((item) => item.ws !== ws);
|
2021-12-09 00:10:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
const blobHandlers = {
|
|
|
|
|
|
setItemsJson: (v) => (itemsJson = v),
|
|
|
|
|
|
setParsedItemsJson: (v) => (parsed.itemsJson = v),
|
|
|
|
|
|
setWidgetsJson: (v) => (widgetsJson = v),
|
|
|
|
|
|
setParsedWidgetsJson: (v) => (parsed.widgetsJson = v),
|
|
|
|
|
|
setConfigJson: (v) => (configJson = v),
|
|
|
|
|
|
setParsedConfigJson: (v) => (parsed.configJson = v),
|
|
|
|
|
|
setScenarioTxt: (v) => (scenarioTxt = v),
|
|
|
|
|
|
setSettingsJson: (v) => (settingsJson = v),
|
|
|
|
|
|
setParsedSettingsJson: (v) => (parsed.settingsJson = v),
|
|
|
|
|
|
setSsidJson: (v) => (ssidJson = v),
|
|
|
|
|
|
setParsedSsidJson: (v) => (parsed.ssidJson = v),
|
|
|
|
|
|
setErrorsJson: (v) => (errorsJson = v),
|
|
|
|
|
|
setParsedErrorsJson: (v) => (parsed.errorsJson = v),
|
|
|
|
|
|
setParsedIncDeviceList: (v) => (parsed.incDeviceList = v),
|
|
|
|
|
|
onDevlis: async (json) => {
|
|
|
|
|
|
incDeviceList = json;
|
|
|
|
|
|
deviceConnection.handleDevListReceived(incDeviceList, deviceList, firstDevListRequest, {
|
|
|
|
|
|
setDeviceList: (list) => (deviceList = list),
|
|
|
|
|
|
setFirstDevListRequest: (v) => (firstDevListRequest = v),
|
|
|
|
|
|
setParsedDeviceListJson: (v) => (parsed.deviceListJson = v),
|
|
|
|
|
|
onParced,
|
|
|
|
|
|
selectedDeviceDataRefresh,
|
|
|
|
|
|
connectToAllDevices,
|
2021-12-08 22:59:21 +01:00
|
|
|
|
});
|
2026-02-08 22:41:16 +01:00
|
|
|
|
},
|
|
|
|
|
|
setFlashProfileJson: (v) => (flashProfileJson = v),
|
|
|
|
|
|
setParsedFlashProfileJson: (v) => (parsed.flashProfileJson = v),
|
|
|
|
|
|
setOtaJson: (v) => (otaJson = v),
|
|
|
|
|
|
setParsedOtaJson: (v) => (parsed.otaJson = v),
|
|
|
|
|
|
addCoreMsg: (msg) => addCoreMsg(msg),
|
|
|
|
|
|
onParced: () => onParced(),
|
|
|
|
|
|
};
|
2021-12-07 22:14:59 +01:00
|
|
|
|
|
2023-06-13 21:06:04 +02:00
|
|
|
|
async function parseBlob(blob, ws) {
|
2026-02-08 22:41:16 +01:00
|
|
|
|
await blobProtocol.parseBlob(blob, ws, blobHandlers);
|
2022-10-09 14:31:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
const allBlobHandlers = {
|
|
|
|
|
|
updateWidget: (v) => updateWidget(v),
|
|
|
|
|
|
combineLayoutsInOne: (ws, layout) => combineLayoutsInOne(ws, layout),
|
|
|
|
|
|
mergeParams: (devParams) => {
|
|
|
|
|
|
paramsJson = { ...paramsJson, ...devParams };
|
|
|
|
|
|
paramsJson = paramsJson;
|
|
|
|
|
|
},
|
|
|
|
|
|
updateAllStatuses: (ws) => updateAllStatuses(ws),
|
|
|
|
|
|
onParced: () => onParced(),
|
|
|
|
|
|
apdateWidgetByArray: (v) => apdateWidgetByArray(v),
|
|
|
|
|
|
};
|
2022-09-26 01:29:52 +02:00
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
async function parseAllBlob(blob, ws) {
|
|
|
|
|
|
await blobProtocol.parseAllBlob(blob, ws, allBlobHandlers);
|
2022-10-09 14:31:07 +02:00
|
|
|
|
}
|
2022-09-26 01:29:52 +02:00
|
|
|
|
|
2022-10-09 14:31:07 +02:00
|
|
|
|
async function onParced() {
|
2022-10-09 21:29:56 +02:00
|
|
|
|
if (currentPageName === "/|") {
|
|
|
|
|
|
pageReady.dash = true;
|
|
|
|
|
|
}
|
2022-09-26 01:29:52 +02:00
|
|
|
|
|
2022-10-09 14:31:07 +02:00
|
|
|
|
if (currentPageName === "/config|" && parsed.itemsJson && parsed.widgetsJson && parsed.configJson && parsed.settingsJson) {
|
|
|
|
|
|
clearParcedFlags();
|
|
|
|
|
|
pageReady.config = true;
|
2022-09-26 01:29:52 +02:00
|
|
|
|
if (debug) console.log("✔✔", "config page parced");
|
2022-09-25 17:49:24 +02:00
|
|
|
|
}
|
2023-10-07 02:04:52 +02:00
|
|
|
|
|
|
|
|
|
|
//&& parsed.widgetsJson && parsed.configJson - добавить когда 451 прошивка уйдет в прошлое
|
2022-10-09 14:31:07 +02:00
|
|
|
|
if (currentPageName === "/connection|" && parsed.ssidJson && parsed.settingsJson && parsed.errorsJson) {
|
2022-09-26 16:20:00 +02:00
|
|
|
|
clearParcedFlags();
|
|
|
|
|
|
if (debug) console.log("✔✔", "connection page parced");
|
|
|
|
|
|
pageReady.connection = true;
|
2022-09-25 17:49:24 +02:00
|
|
|
|
}
|
2022-10-09 14:31:07 +02:00
|
|
|
|
|
2023-06-13 21:06:04 +02:00
|
|
|
|
if (currentPageName === "/list|" && parsed.settingsJson) {
|
2022-09-26 16:20:00 +02:00
|
|
|
|
clearParcedFlags();
|
|
|
|
|
|
if (debug) console.log("✔✔", "list page parced");
|
|
|
|
|
|
pageReady.list = true;
|
2022-09-25 17:49:24 +02:00
|
|
|
|
}
|
2022-10-09 14:31:07 +02:00
|
|
|
|
|
|
|
|
|
|
if (currentPageName === "/system|" && parsed.errorsJson && parsed.settingsJson) {
|
2022-09-26 16:20:00 +02:00
|
|
|
|
clearParcedFlags();
|
|
|
|
|
|
getVersionsList();
|
|
|
|
|
|
if (debug) console.log("✔✔", "system page parced");
|
|
|
|
|
|
pageReady.system = true;
|
2022-09-25 17:49:24 +02:00
|
|
|
|
}
|
2023-10-04 18:56:24 +02:00
|
|
|
|
|
2023-10-11 01:50:08 +02:00
|
|
|
|
//&& parsed.otaJson
|
|
|
|
|
|
if (currentPageName === "/profile|" && parsed.flashProfileJson) {
|
2023-10-04 18:56:24 +02:00
|
|
|
|
clearParcedFlags();
|
|
|
|
|
|
if (debug) console.log("✔✔", "profile page parced");
|
|
|
|
|
|
pageReady.profile = true;
|
2023-10-10 16:14:19 +02:00
|
|
|
|
await getModInfo();
|
|
|
|
|
|
await getProfile();
|
2023-10-04 18:56:24 +02:00
|
|
|
|
}
|
2022-10-09 14:31:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-10 16:14:19 +02:00
|
|
|
|
const getModInfo = async () => {
|
2026-02-08 22:41:16 +01:00
|
|
|
|
const res = await portal.getModInfo();
|
|
|
|
|
|
if (res.ok) allmodeinfo = res.allmodeinfo;
|
|
|
|
|
|
else console.log("error", "getModInfo");
|
2023-10-10 16:14:19 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const getProfile = async () => {
|
2026-02-08 22:41:16 +01:00
|
|
|
|
const JWT = Cookies.get("token_iotm2");
|
|
|
|
|
|
const res = await portal.getProfile(JWT);
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
|
profile = res.profile;
|
|
|
|
|
|
await markProfileAsPerThisDevProfile();
|
|
|
|
|
|
} else console.log("error", "getProfile");
|
2023-10-10 16:14:19 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const markProfileAsPerThisDevProfile = async () => {
|
2023-10-11 01:50:08 +02:00
|
|
|
|
profile.projectProp.platformio.default_envs = flashProfileJson.projectProp.platformio.default_envs;
|
2023-10-10 16:14:19 +02:00
|
|
|
|
for (const [compilerCategory, compilerCategoryModules] of Object.entries(profile.modules)) {
|
2023-10-11 01:50:08 +02:00
|
|
|
|
let devCategoryModules = flashProfileJson.modules[compilerCategory];
|
2023-10-10 16:14:19 +02:00
|
|
|
|
compilerCategoryModules.forEach((compilerModule) => {
|
|
|
|
|
|
compilerModule.active = false;
|
|
|
|
|
|
if (devCategoryModules) {
|
|
|
|
|
|
devCategoryModules.forEach((devModule) => {
|
|
|
|
|
|
if (devModule.path === compilerModule.path) {
|
|
|
|
|
|
compilerModule.active = devModule.active;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
function devListOverride() {
|
|
|
|
|
|
deviceList = deviceListManager.devListOverride(incDeviceList);
|
2023-06-11 17:01:57 +02:00
|
|
|
|
console.log("[i]", "[devlist]", "devlist overrided");
|
|
|
|
|
|
}
|
2023-06-13 21:06:04 +02:00
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
function devListCombine() {
|
|
|
|
|
|
deviceList = deviceListManager.devListCombine(deviceList, incDeviceList);
|
2023-06-11 17:01:57 +02:00
|
|
|
|
console.log("[i]", "[devlist]", "devlist combined");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
function combineArrays(A, B) {
|
|
|
|
|
|
return deviceListManager.combineArrays(A, B);
|
2023-06-11 17:01:57 +02:00
|
|
|
|
}
|
2022-09-25 17:49:24 +02:00
|
|
|
|
|
2022-09-18 18:11:50 +02:00
|
|
|
|
//***********************************************************dashboard***************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
//слияние layout-ов всех устройств в общий layout
|
2022-10-09 21:29:56 +02:00
|
|
|
|
async function combineLayoutsInOne(ws, devLayout) {
|
|
|
|
|
|
for (let i = 0; i < devLayout.length; i++) {
|
|
|
|
|
|
devLayout[i].ws = ws;
|
|
|
|
|
|
}
|
|
|
|
|
|
layoutJson = layoutJson.concat(devLayout);
|
|
|
|
|
|
console.log("[2]", ws, "devLayout pushed to layout");
|
|
|
|
|
|
sortingLayout(ws);
|
2022-03-01 01:43:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-07 22:29:04 +02:00
|
|
|
|
function sortingLayout(ws) {
|
2022-09-18 18:11:50 +02:00
|
|
|
|
//сортируем весь layout по алфавиту
|
|
|
|
|
|
layoutJson.sort(function (a, b) {
|
|
|
|
|
|
if (a.descr < b.descr) {
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (a.descr > b.descr) {
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
});
|
|
|
|
|
|
//формируем json всех карточек
|
|
|
|
|
|
pages = [];
|
|
|
|
|
|
const newPage = Array.from(new Set(Array.from(layoutJson, ({ page }) => page)));
|
|
|
|
|
|
newPage.forEach(function (item, i, arr) {
|
|
|
|
|
|
pages = [
|
|
|
|
|
|
...pages,
|
|
|
|
|
|
JSON.parse(
|
|
|
|
|
|
JSON.stringify({
|
|
|
|
|
|
page: item,
|
|
|
|
|
|
})
|
|
|
|
|
|
),
|
|
|
|
|
|
];
|
|
|
|
|
|
});
|
|
|
|
|
|
//сортируем карточки по алфавиту
|
|
|
|
|
|
pages.sort(function (a, b) {
|
|
|
|
|
|
if (a.page < b.page) {
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (a.page > b.page) {
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
});
|
2022-09-25 17:49:24 +02:00
|
|
|
|
|
2022-09-18 18:11:50 +02:00
|
|
|
|
layoutJson = layoutJson;
|
2022-10-07 22:29:04 +02:00
|
|
|
|
console.log("[3]", ws, "layout sort, requested params...");
|
|
|
|
|
|
wsSendMsg(ws, "/params|");
|
2022-09-18 18:11:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function updateAllStatuses(ws) {
|
2022-03-01 01:43:55 +01:00
|
|
|
|
for (const [key, value] of Object.entries(paramsJson)) {
|
2022-09-18 18:11:50 +02:00
|
|
|
|
for (let i = 0; i < layoutJson.length; i++) {
|
|
|
|
|
|
let topic = layoutJson[i].topic;
|
2022-09-10 02:59:03 +02:00
|
|
|
|
if (topic) {
|
2022-09-19 05:03:43 +02:00
|
|
|
|
//layoutJson[i].ws = ws;
|
2022-09-10 02:59:03 +02:00
|
|
|
|
topic = topic.substring(topic.lastIndexOf("/") + 1, topic.length);
|
|
|
|
|
|
if (key === topic) {
|
2022-09-18 18:11:50 +02:00
|
|
|
|
console.log("[i]", "updated =>" + topic, value);
|
|
|
|
|
|
layoutJson[i].status = value;
|
2022-09-10 02:59:03 +02:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2022-02-27 01:49:03 +01:00
|
|
|
|
}
|
2022-03-01 01:43:55 +01:00
|
|
|
|
}
|
2022-02-25 17:57:47 +01:00
|
|
|
|
}
|
2022-09-25 21:59:50 +02:00
|
|
|
|
wsSendMsg(ws, "/charts|");
|
2022-02-26 01:09:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-18 18:11:50 +02:00
|
|
|
|
//обработка интервально прилетающих статусов
|
|
|
|
|
|
function updateWidget(newStatusJson) {
|
2022-02-26 01:09:17 +01:00
|
|
|
|
for (let i = 0; i < layoutJson.length; i++) {
|
|
|
|
|
|
let topic = layoutJson[i].topic;
|
|
|
|
|
|
if (topic === newStatusJson.topic) {
|
2022-09-11 01:30:38 +02:00
|
|
|
|
layoutJson[i] = jsonConcat(layoutJson[i], newStatusJson);
|
2022-08-16 00:54:14 +02:00
|
|
|
|
//получен ответ - выключаем красный цвет
|
|
|
|
|
|
layoutJson[i].sent = false;
|
2022-02-26 01:09:17 +01:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-02-25 17:57:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-18 18:11:50 +02:00
|
|
|
|
//если статус виджета это массив и его нужно накопить
|
2022-10-07 22:29:04 +02:00
|
|
|
|
//должна вызываться когда весь layout в сборе
|
|
|
|
|
|
async function apdateWidgetByArray(newStatusJson) {
|
2022-09-18 18:11:50 +02:00
|
|
|
|
console.log("[i]", "collecting arrays");
|
|
|
|
|
|
let error = true;
|
|
|
|
|
|
if (layoutJson.length > 0) {
|
|
|
|
|
|
for (let i = 0; i < layoutJson.length; i++) {
|
|
|
|
|
|
let topic = layoutJson[i].topic;
|
|
|
|
|
|
if (topic === newStatusJson.topic) {
|
|
|
|
|
|
error = false;
|
|
|
|
|
|
layoutJson[i] = jsonConcatEx(layoutJson[i], newStatusJson);
|
|
|
|
|
|
let prevArr = layoutJson[i].status; //который был в layout
|
|
|
|
|
|
let newArr = newStatusJson.status; //тот что получили
|
|
|
|
|
|
if (prevArr) {
|
|
|
|
|
|
//если что то было в layout то делаем слияние
|
|
|
|
|
|
prevArr = [...prevArr, ...newArr];
|
|
|
|
|
|
layoutJson[i].status = prevArr;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//если ничего не было то просто запишем новый
|
|
|
|
|
|
layoutJson[i].status = newArr;
|
|
|
|
|
|
}
|
|
|
|
|
|
//получен ответ - выключаем красный цвет
|
|
|
|
|
|
layoutJson[i].sent = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.log("[E]", "layoutJson missing");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (error) console.log("[E]", "topic not found ", newStatusJson.topic);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-11 01:30:38 +02:00
|
|
|
|
function jsonConcat(o1, o2) {
|
|
|
|
|
|
for (var key in o2) {
|
|
|
|
|
|
o1[key] = o2[key];
|
|
|
|
|
|
}
|
|
|
|
|
|
return o1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-18 18:11:50 +02:00
|
|
|
|
//объединяем исклчая статус так как статус в данном случае накопительная переменная
|
|
|
|
|
|
function jsonConcatEx(o1, o2) {
|
|
|
|
|
|
for (var key in o2) {
|
|
|
|
|
|
if (key !== "status") {
|
|
|
|
|
|
o1[key] = o2[key];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return o1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-31 01:45:42 +01:00
|
|
|
|
function saveConfig() {
|
2022-02-09 16:43:24 +01:00
|
|
|
|
wsSendMsg(selectedWs, "/tuoyal|" + JSON.stringify(generateLayout()));
|
2022-09-18 19:26:23 +02:00
|
|
|
|
modify();
|
2022-02-09 16:43:24 +01:00
|
|
|
|
wsSendMsg(selectedWs, "/gifnoc|" + JSON.stringify(configJson));
|
2022-09-29 23:34:21 +02:00
|
|
|
|
|
|
|
|
|
|
wsSendMsg(selectedWs, "/oiranecs|" + scenarioTxt);
|
2022-01-17 00:08:26 +01:00
|
|
|
|
clearData();
|
2023-06-13 21:06:04 +02:00
|
|
|
|
sendCurrentPageNameToSelectedWs();
|
2022-01-17 00:08:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-12 03:07:59 +01:00
|
|
|
|
function saveSett() {
|
|
|
|
|
|
var size = Object.keys(settingsJson).length;
|
2023-06-08 22:37:43 +02:00
|
|
|
|
console.log("[i]", "settingsJson length: " + size);
|
2022-02-12 03:07:59 +01:00
|
|
|
|
if (size > 5) {
|
2022-02-15 15:22:54 +01:00
|
|
|
|
jsonArrWrite(deviceList, "ip", getIP(selectedWs), "name", settingsJson.name);
|
|
|
|
|
|
deviceList = deviceList;
|
2022-02-12 03:07:59 +01:00
|
|
|
|
wsSendMsg(selectedWs, "/sgnittes|" + JSON.stringify(settingsJson));
|
|
|
|
|
|
} else {
|
2023-06-08 22:37:43 +02:00
|
|
|
|
window.alert("Ошибка размера settingsJson (возможно не был передан странице)");
|
2022-02-12 03:07:59 +01:00
|
|
|
|
}
|
2022-02-02 23:37:15 +01:00
|
|
|
|
clearData();
|
2023-06-13 21:06:04 +02:00
|
|
|
|
sendCurrentPageNameToSelectedWs();
|
2022-02-02 23:37:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-08 22:37:43 +02:00
|
|
|
|
function saveList() {
|
|
|
|
|
|
//при сохранении списка в память необходимо удалить все статусы
|
|
|
|
|
|
let devListForSave = Object.assign([], deviceList);
|
|
|
|
|
|
for (let i = 0; i < devListForSave.length; i++) {
|
2023-06-13 21:06:04 +02:00
|
|
|
|
//delete devListForSave[i].status;
|
|
|
|
|
|
devListForSave[i].status = false;
|
2023-06-08 22:37:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
wsSendMsg(selectedWs, "/tsil|" + JSON.stringify(devListForSave));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-08-26 00:01:29 +02:00
|
|
|
|
function cleanLogs() {
|
2022-09-15 12:22:39 +02:00
|
|
|
|
wsSendMsg(selectedWs, "/clean|");
|
2022-08-26 00:01:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-12 03:07:59 +01:00
|
|
|
|
function saveMqtt() {
|
|
|
|
|
|
var size = Object.keys(settingsJson).length;
|
2023-10-07 02:04:52 +02:00
|
|
|
|
wsSendMsg(selectedWs, "/tuoyal|" + JSON.stringify(generateLayout()));
|
2022-02-12 03:07:59 +01:00
|
|
|
|
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",
|
2022-09-13 22:44:37 +02:00
|
|
|
|
//descr: "Выберите дату",
|
2022-09-11 14:14:16 +02:00
|
|
|
|
widget: "input",
|
|
|
|
|
|
size: "small",
|
|
|
|
|
|
color: "orange",
|
|
|
|
|
|
type: "date",
|
|
|
|
|
|
};
|
|
|
|
|
|
return input;
|
|
|
|
|
|
}
|
2022-09-10 02:59:03 +02:00
|
|
|
|
|
2022-09-18 19:26:23 +02:00
|
|
|
|
function modify() {
|
2022-09-14 18:20:07 +02:00
|
|
|
|
for (let i = 0; i < configJson.length; i++) {
|
|
|
|
|
|
let config = configJson[i];
|
|
|
|
|
|
delete config["show"];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//по конфигу делаем виджеты
|
2022-01-31 01:45:42 +01:00
|
|
|
|
function generateLayout() {
|
|
|
|
|
|
let layout = [];
|
|
|
|
|
|
for (let i = 0; i < configJson.length; i++) {
|
2022-02-02 23:37:15 +01:00
|
|
|
|
let config = Object.assign({}, configJson[i]);
|
2022-01-31 01:45:42 +01:00
|
|
|
|
let setWidget = config.widget;
|
|
|
|
|
|
let error = true;
|
|
|
|
|
|
for (let w = 0; w < widgetsJson.length; w++) {
|
|
|
|
|
|
if (setWidget === widgetsJson[w].name) {
|
2022-02-02 23:37:15 +01:00
|
|
|
|
let widget = Object.assign({}, widgetsJson[w]);
|
2022-01-31 01:45:42 +01:00
|
|
|
|
widget.page = config.page;
|
|
|
|
|
|
widget.descr = config.descr;
|
2023-10-07 02:04:52 +02:00
|
|
|
|
widget.topic = settingsJson.mqttPrefix + "/" + settingsJson.id + "/" + config.id;
|
2022-09-27 01:24:37 +02:00
|
|
|
|
if (setWidget !== "nil") layout.push(widget);
|
2022-09-28 17:26:33 +02:00
|
|
|
|
//создаем графики с окнами ввода
|
|
|
|
|
|
if (widget.widget === "chart" && widget.type !== "bar") {
|
2022-09-11 14:14:16 +02:00
|
|
|
|
let input = getInput();
|
2022-09-10 02:59:03 +02:00
|
|
|
|
input.page = config.page;
|
2023-10-11 01:50:08 +02:00
|
|
|
|
input.topic = settingsJson.mqttPrefix + "/" + settingsJson.id + "/" + config.id + "-date";
|
2022-09-13 22:44:37 +02:00
|
|
|
|
input.descr = config.descr;
|
2022-09-18 18:11:50 +02:00
|
|
|
|
//console.log("[i]", "topic ", widget.topic);
|
2022-09-10 02:59:03 +02:00
|
|
|
|
layout.push(input);
|
|
|
|
|
|
}
|
2022-01-31 01:45:42 +01:00
|
|
|
|
error = false;
|
|
|
|
|
|
break;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
error = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-09-18 18:11:50 +02:00
|
|
|
|
if (error) console.log("[E]", "error, widget not found: " + setWidget);
|
2022-01-31 01:45:42 +01:00
|
|
|
|
}
|
2022-10-07 22:29:04 +02:00
|
|
|
|
|
|
|
|
|
|
//сортируем весь layout по алфавиту
|
|
|
|
|
|
layout.sort(function (a, b) {
|
|
|
|
|
|
if (a.descr < b.descr) {
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (a.descr > b.descr) {
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < layout.length; i++) {
|
|
|
|
|
|
layout[i].order = i;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-01 00:42:28 +01:00
|
|
|
|
return layout;
|
2022-01-31 01:45:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-17 00:08:26 +01:00
|
|
|
|
function clearData() {
|
2022-02-02 23:37:15 +01:00
|
|
|
|
itemsJson = [];
|
2022-10-10 00:16:36 +02:00
|
|
|
|
widgetsJson = [];
|
|
|
|
|
|
configJson = [];
|
2022-10-12 03:18:04 +02:00
|
|
|
|
scenarioTxt = " ";
|
2022-02-23 22:56:17 +01:00
|
|
|
|
settingsJson = {};
|
2022-10-10 00:16:36 +02:00
|
|
|
|
//ssidJson = {};
|
2022-02-08 16:47:26 +01:00
|
|
|
|
errorsJson = {};
|
2022-10-10 00:16:36 +02:00
|
|
|
|
layoutJson = [];
|
2023-10-12 00:17:27 +02:00
|
|
|
|
paramsJson = {};
|
|
|
|
|
|
otaJson = {};
|
|
|
|
|
|
flashProfileJson = {};
|
2022-02-19 23:35:30 +01:00
|
|
|
|
|
2023-06-11 17:01:57 +02:00
|
|
|
|
//incDeviceList = [];
|
2023-06-08 22:37:43 +02:00
|
|
|
|
|
2022-09-25 17:49:24 +02:00
|
|
|
|
for (const [key, value] of Object.entries(pageReady)) {
|
|
|
|
|
|
pageReady[key] = false;
|
|
|
|
|
|
}
|
2022-02-13 00:37:58 +01:00
|
|
|
|
|
|
|
|
|
|
clearParcedFlags();
|
|
|
|
|
|
|
2022-10-09 17:03:41 +02:00
|
|
|
|
if (debug) console.log("[i]", "all json files cleared");
|
2022-01-17 00:08:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-13 00:37:58 +01:00
|
|
|
|
function clearParcedFlags() {
|
2022-10-07 22:29:04 +02:00
|
|
|
|
console.log("[i]", "parced flags cleared");
|
2022-10-09 14:31:07 +02:00
|
|
|
|
for (const [key, value] of Object.entries(parsed)) {
|
|
|
|
|
|
parsed[key] = false;
|
2022-09-25 17:49:24 +02:00
|
|
|
|
}
|
2022-02-13 00:37:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
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-09-19 05:03:43 +02:00
|
|
|
|
//layoutJson = layoutJson;
|
2022-08-15 01:30:59 +02:00
|
|
|
|
let key = topic.substring(topic.lastIndexOf("/") + 1, topic.length);
|
|
|
|
|
|
wsSendMsg(ws, "/control|" + key + "/" + status);
|
2021-12-08 22:59:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
const ack = wsReconnect.createAck({
|
|
|
|
|
|
markDeviceStatus,
|
|
|
|
|
|
getDeviceList: () => deviceList,
|
|
|
|
|
|
setDeviceList: (list) => (deviceList = list),
|
|
|
|
|
|
waitingAckTimeout,
|
|
|
|
|
|
});
|
2023-10-06 01:07:49 +02:00
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
const wsTestMsgTask = wsReconnect.createWsTestMsgTask({
|
|
|
|
|
|
getDeviceList: () => deviceList,
|
|
|
|
|
|
send: wsSendMsg,
|
|
|
|
|
|
markDeviceStatus,
|
|
|
|
|
|
connectDevice: (ws) => createConnection(ws, getIP(ws)),
|
|
|
|
|
|
ack,
|
|
|
|
|
|
getRemainingTimeout: () => remainingTimeout,
|
|
|
|
|
|
setRemainingTimeout: (v) => (remainingTimeout = v),
|
|
|
|
|
|
reconnectTimeout,
|
|
|
|
|
|
getPreventReconnect: () => preventReconnect,
|
|
|
|
|
|
setPercent: (v) => (percent = v),
|
|
|
|
|
|
getRebootOrUpdateProcess: () => rebootOrUpdateProcess,
|
|
|
|
|
|
setRebootOrUpdateProcess: (v) => (rebootOrUpdateProcess = v),
|
|
|
|
|
|
getSocketConnected: () => socketConnected,
|
|
|
|
|
|
setShowAwaitingCircle: (v) => (showAwaitingCircle = v),
|
|
|
|
|
|
setReconnectTimeout: (v) => (reconnectTimeout = v),
|
|
|
|
|
|
printAllCreatedWs,
|
|
|
|
|
|
});
|
2021-12-06 01:21:55 +01:00
|
|
|
|
|
2022-02-15 00:02:30 +01:00
|
|
|
|
function sendToAllDevices(msg) {
|
|
|
|
|
|
deviceList.forEach((device) => {
|
2023-06-13 21:06:04 +02:00
|
|
|
|
if (device.status === true) {
|
2022-02-15 00:02:30 +01:00
|
|
|
|
wsSendMsg(device.ws, msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-01 16:01:19 +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
|
|
|
|
|
2022-02-01 16:01:19 +01:00
|
|
|
|
//***********************************************************dev list******************************************************************/
|
2022-02-07 23:40:00 +01:00
|
|
|
|
|
2023-06-11 17:01:57 +02:00
|
|
|
|
//всякий раз когда список устройств был обновлен
|
|
|
|
|
|
function selectedDeviceDataRefresh() {
|
|
|
|
|
|
//запишем в переменную selectedDeviceData выбранное устройство, что бы в коде было известно выбранное устройство
|
2022-02-07 23:40:00 +01:00
|
|
|
|
getSelectedDeviceData(selectedWs);
|
2021-12-09 22:35:04 +01:00
|
|
|
|
socketConnected = selectedDeviceData.status;
|
2022-02-07 23:40:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function devicesDropdownChange() {
|
2023-06-11 17:01:57 +02:00
|
|
|
|
if (currentPageName === "/list|") {
|
|
|
|
|
|
console.log("[i]", "user change dropdown on list page!!!");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
selectedDeviceDataRefresh();
|
|
|
|
|
|
clearData();
|
|
|
|
|
|
//запускаем навигацию что дать контроллеру запрос данных
|
|
|
|
|
|
handleNavigation();
|
|
|
|
|
|
if (debug) console.log("[i]", "user selected device:", selectedDeviceData.name);
|
|
|
|
|
|
if (selectedDeviceData.ip === myip) {
|
|
|
|
|
|
originalWs = selectedWs;
|
|
|
|
|
|
if (debug) console.log("[i]", "user selected original device", selectedDeviceData.name);
|
|
|
|
|
|
}
|
2021-12-13 00:01:21 +01:00
|
|
|
|
}
|
2021-12-09 22:35:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-08 22:37:43 +02: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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-12 03:07:59 +01:00
|
|
|
|
function addDevInList() {
|
2021-12-12 00:20:47 +01:00
|
|
|
|
if (!showInput) {
|
|
|
|
|
|
if (newDevice.name !== undefined && newDevice.ip !== undefined && newDevice.id !== undefined) {
|
|
|
|
|
|
newDevice.status = false;
|
2023-06-11 17:01:57 +02:00
|
|
|
|
newDevice.ws = deviceList.length;
|
|
|
|
|
|
incDeviceList.push(newDevice);
|
|
|
|
|
|
devListCombine();
|
|
|
|
|
|
//onParced();
|
|
|
|
|
|
//selectedDeviceDataRefresh();
|
2021-12-12 00:20:47 +01:00
|
|
|
|
connectToAllDevices();
|
2023-06-13 21:06:04 +02:00
|
|
|
|
if (debug) console.log("[i]", "selected device: ", selectedDeviceData);
|
2023-06-11 17:01:57 +02:00
|
|
|
|
return true;
|
2021-12-12 00:20:47 +01:00
|
|
|
|
} else {
|
|
|
|
|
|
if (debug) console.log("[e]", "wrong data");
|
2023-06-11 17:01:57 +02:00
|
|
|
|
return false;
|
2021-12-12 00:20:47 +01:00
|
|
|
|
}
|
2021-12-13 02:36:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-15 15:22:54 +01:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-01 16:01:19 +01:00
|
|
|
|
//**********************************************************modal*************************************************************************/
|
|
|
|
|
|
function onCheck() {
|
2023-10-05 14:38:57 +02:00
|
|
|
|
if (screenSize < 900) {
|
2022-02-01 16:01:19 +01:00
|
|
|
|
preventMove = true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
preventMove = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//************************************************elements and presets dropdown************************************************************/
|
|
|
|
|
|
|
2022-02-12 03:07:59 +01:00
|
|
|
|
function ssidClick() {
|
2022-02-09 16:43:24 +01:00
|
|
|
|
wsSendMsg(selectedWs, "/scan|");
|
2022-02-05 02:13:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-08 16:47:26 +01:00
|
|
|
|
function rebootEsp() {
|
2023-10-06 01:36:13 +02:00
|
|
|
|
rebootOrUpdateProcess = true;
|
2022-02-08 16:47:26 +01:00
|
|
|
|
if (debug) console.log("[i]", "reboot...");
|
2022-02-09 16:43:24 +01:00
|
|
|
|
wsSendMsg(selectedWs, "/reboot|");
|
2022-11-22 15:07:41 +01:00
|
|
|
|
markDeviceStatus(selectedWs, false);
|
2023-06-13 21:06:04 +02:00
|
|
|
|
showAwaitingCircle = true;
|
2023-10-06 01:07:49 +02:00
|
|
|
|
socketConnected = false;
|
|
|
|
|
|
reconnectTimeout = 10;
|
|
|
|
|
|
remainingTimeout = reconnectTimeout;
|
2023-06-13 21:06:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-06 01:36:13 +02:00
|
|
|
|
function updateBuild(path) {
|
|
|
|
|
|
rebootOrUpdateProcess = true;
|
|
|
|
|
|
console.log(path);
|
|
|
|
|
|
wsSendMsg(selectedWs, "/update|" + path);
|
|
|
|
|
|
showAwaitingCircle = true;
|
|
|
|
|
|
socketConnected = false;
|
|
|
|
|
|
reconnectTimeout = 20;
|
|
|
|
|
|
remainingTimeout = reconnectTimeout;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-13 21:06:04 +02:00
|
|
|
|
function applicationReboot() {
|
|
|
|
|
|
console.log("[i]", "reboot svelte...");
|
|
|
|
|
|
for (const [key, value] of Object.entries(pageReady)) {
|
|
|
|
|
|
pageReady[key] = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
showAwaitingCircle = true;
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
location.reload();
|
|
|
|
|
|
}, 1000);
|
2022-02-08 16:47:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-09 16:43:24 +01:00
|
|
|
|
function cancelAlarm(alarmKey) {
|
|
|
|
|
|
console.log("[x]", alarmKey);
|
2022-02-11 16:49:34 +01:00
|
|
|
|
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() {
|
2022-09-25 17:49:24 +02:00
|
|
|
|
versionsList = {};
|
2026-02-08 22:41:16 +01:00
|
|
|
|
const res = await firmware.getVersionsList(settingsJson.serverip);
|
|
|
|
|
|
if (res.ok && res.data) {
|
|
|
|
|
|
versionsList = res.data[errorsJson.bn];
|
|
|
|
|
|
choosingVersion = errorsJson.bver;
|
|
|
|
|
|
console.log(JSON.stringify(versionsList));
|
2022-09-25 17:49:24 +02:00
|
|
|
|
} else {
|
2026-02-08 22:41:16 +01:00
|
|
|
|
choosingVersion = undefined;
|
|
|
|
|
|
if (settingsJson.serverip) console.log("error, versions list not received");
|
2022-02-18 19:48:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-14 00:52:42 +01:00
|
|
|
|
function moduleOrder(id, key, value) {
|
|
|
|
|
|
console.log("order: ", id, key, value);
|
|
|
|
|
|
let json = {
|
|
|
|
|
|
id: id,
|
|
|
|
|
|
key: key,
|
|
|
|
|
|
value: value,
|
|
|
|
|
|
};
|
|
|
|
|
|
console.log(json);
|
|
|
|
|
|
wsSendMsg(selectedWs, "/order|" + JSON.stringify(json));
|
|
|
|
|
|
}
|
2021-09-16 02:00:52 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
2023-10-05 14:38:57 +02:00
|
|
|
|
<svelte:window bind:innerWidth={screenSize} />
|
|
|
|
|
|
|
2022-02-01 16:01:19 +01:00
|
|
|
|
<div class="flex flex-col h-screen bg-gray-50">
|
2023-06-13 21:06:04 +02:00
|
|
|
|
{#if showAwaitingCircle}
|
2022-02-08 16:47:26 +01:00
|
|
|
|
<Progress />
|
|
|
|
|
|
{/if}
|
2023-06-17 22:26:52 +02:00
|
|
|
|
|
|
|
|
|
|
<!--{#if authorization}
|
|
|
|
|
|
<ModalPass checkPassword={(pass) => checkPassword(pass)} />
|
|
|
|
|
|
{/if}-->
|
|
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
<AppHeader
|
|
|
|
|
|
{deviceList}
|
|
|
|
|
|
bind:selectedWs
|
|
|
|
|
|
{showDropdown}
|
|
|
|
|
|
{socketConnected}
|
|
|
|
|
|
{devicesDropdownChange}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<AppNav bind:opened onCheck={() => onCheck()} {userdata} />
|
2022-02-01 16:01:19 +01:00
|
|
|
|
|
|
|
|
|
|
<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">
|
2022-11-21 00:38:58 +01:00
|
|
|
|
{#if !socketConnected && currentPageName != "/|"}
|
2023-10-06 01:07:49 +02:00
|
|
|
|
<Alarm title="Подключение через {remainingTimeout} сек." />
|
2022-02-05 02:13:46 +01:00
|
|
|
|
{:else}
|
|
|
|
|
|
<Route path="/">
|
2022-09-25 17:49:24 +02:00
|
|
|
|
<DashboardPage show={pageReady.dash} layoutJson={layoutJson} pages={pages} wsPush={(ws, topic, status) => wsPush(ws, topic, status)} />
|
2022-02-05 02:13:46 +01:00
|
|
|
|
</Route>
|
|
|
|
|
|
<Route path="/config">
|
2023-10-15 02:28:10 +02:00
|
|
|
|
<ConfigPage show={pageReady.config} bind:configJson={configJson} bind:scenarioTxt={scenarioTxt} widgetsJson={widgetsJson} itemsJson={itemsJson} saveConfig={() => saveConfig()} cleanLogs={() => cleanLogs()} rebootEsp={() => rebootEsp()} moduleOrder={(id, key, value) => moduleOrder(id, key, value)} userdata={userdata} />
|
2022-02-05 02:13:46 +01:00
|
|
|
|
</Route>
|
|
|
|
|
|
<Route path="/connection">
|
2022-09-25 17:49:24 +02:00
|
|
|
|
<ConnectionPage show={pageReady.connection} rebootEsp={() => rebootEsp()} ssidClick={() => ssidClick()} saveSett={() => saveSett()} saveMqtt={() => saveMqtt()} settingsJson={settingsJson} errorsJson={errorsJson} ssidJson={ssidJson} />
|
2022-02-13 00:37:58 +01:00
|
|
|
|
</Route>
|
|
|
|
|
|
<Route path="/list">
|
2023-06-13 21:06:04 +02:00
|
|
|
|
<ListPage show={pageReady.list} deviceList={deviceList} settingsJson={settingsJson} saveSett={() => saveSett()} rebootEsp={() => rebootEsp()} showInput={showInput} addDevInList={() => addDevInList()} newDevice={newDevice} sendToAllDevices={(msg) => sendToAllDevices(msg)} saveList={() => saveList()} percent={percent} devListOverride={() => devListOverride()} applicationReboot={() => applicationReboot()} />
|
2022-02-05 02:13:46 +01:00
|
|
|
|
</Route>
|
2022-02-08 21:42:40 +01:00
|
|
|
|
<Route path="/system">
|
2023-10-06 01:07:49 +02:00
|
|
|
|
<SystemPage show={pageReady.system} errorsJson={errorsJson} settingsJson={settingsJson} saveSett={() => saveSett()} rebootEsp={() => rebootEsp()} cleanLogs={() => cleanLogs()} cancelAlarm={(alarmKey) => cancelAlarm(alarmKey)} versionsList={versionsList} bind:choosingVersion={choosingVersion} coreMessages={coreMessages} />
|
2022-02-05 02:13:46 +01:00
|
|
|
|
</Route>
|
2023-10-02 17:25:05 +02:00
|
|
|
|
|
2023-10-04 18:56:24 +02:00
|
|
|
|
<Route path="/profile">
|
2023-10-11 01:50:08 +02:00
|
|
|
|
<Profile show={pageReady.profile} flashProfileJson={flashProfileJson} userdata={userdata} updateBuild={(path) => updateBuild(path)} allmodeinfo={allmodeinfo} profile={profile} serverOnline={serverOnline} otaJson={otaJson} />
|
2023-10-05 01:39:15 +02:00
|
|
|
|
</Route>
|
|
|
|
|
|
<Route path="/login">
|
2023-10-10 16:14:19 +02:00
|
|
|
|
<Login show={true} serverOnline={serverOnline} />
|
2023-10-02 17:25:05 +02:00
|
|
|
|
</Route>
|
2022-02-05 02:13:46 +01:00
|
|
|
|
{/if}
|
2022-02-01 16:01:19 +01:00
|
|
|
|
</div>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</main>
|
2022-02-05 02:13:46 +01:00
|
|
|
|
|
2026-02-08 22:41:16 +01:00
|
|
|
|
<AppFooter />
|
2022-02-01 16:01:19 +01:00
|
|
|
|
</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 {
|
2022-02-08 16:47:26 +01:00
|
|
|
|
@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;
|
|
|
|
|
|
}
|
2023-06-02 15:29:45 +02:00
|
|
|
|
.grd-4col1 {
|
|
|
|
|
|
@apply grid gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-4 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 {
|
2023-06-02 15:29:45 +02:00
|
|
|
|
@apply flex mb-2 h-6 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 {
|
2022-11-22 15:07:41 +01:00
|
|
|
|
@apply text-center px-1 break-words text-gray-500 font-bold truncate;
|
2021-12-11 13:54:28 +01:00
|
|
|
|
}
|
2022-02-07 16:36:43 +01:00
|
|
|
|
.tbl-bdy-lg {
|
2022-11-22 15:07:41 +01:00
|
|
|
|
@apply text-center px-1 break-words truncate;
|
2021-12-11 13:54:28 +01:00
|
|
|
|
}
|
2022-02-07 16:36:43 +01:00
|
|
|
|
.tbl-bdy-sm {
|
2022-02-05 02:13:46 +01:00
|
|
|
|
@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;
|
2021-12-27 22:46:16 +01:00
|
|
|
|
}
|
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;
|
2021-12-12 00:20:47 +01:00
|
|
|
|
}
|
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
|
|
|
|
}
|
2021-12-12 00:20:47 +01:00
|
|
|
|
/*====================================================buttons=====================================================*/
|
2021-12-28 23:55:14 +01:00
|
|
|
|
.btn-lg {
|
2022-11-22 15:07:41 +01:00
|
|
|
|
@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 truncate;
|
2021-12-12 00:20:47 +01:00
|
|
|
|
}
|
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-25 23:13:15 +01:00
|
|
|
|
}
|
2021-12-28 01:06:01 +01:00
|
|
|
|
/*====================================================select=====================================================*/
|
2021-12-28 23:55:14 +01:00
|
|
|
|
.slct-lg {
|
2022-02-08 16:47:26 +01:00
|
|
|
|
@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 {
|
2022-02-01 16:01:19 +01:00
|
|
|
|
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;
|
2022-09-08 23:35:58 +02:00
|
|
|
|
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;
|
2022-09-08 23:35:58 +02:00
|
|
|
|
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
|
|
|
|
}
|
2022-09-29 00:56:22 +02:00
|
|
|
|
|
|
|
|
|
|
input[type="file"] {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
2023-09-22 19:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
/* width */
|
|
|
|
|
|
::-webkit-scrollbar {
|
|
|
|
|
|
width: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Track */
|
|
|
|
|
|
::-webkit-scrollbar-track {
|
|
|
|
|
|
background: #ebebeb;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Handle */
|
|
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
|
|
|
|
background: #cbcbcb;
|
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Handle on hover */
|
|
|
|
|
|
::-webkit-scrollbar-thumb:hover {
|
|
|
|
|
|
background: #aeaeae;
|
|
|
|
|
|
}
|
2021-09-16 02:00:52 +08:00
|
|
|
|
</style>
|