mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-30 20:09:24 +03:00
последний на сегодня
This commit is contained in:
@@ -4,12 +4,12 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
|
|
||||||
<title>IoT Manager 4.3.6</title>
|
<title>IoT Manager 4.3.8</title>
|
||||||
|
|
||||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||||
<link rel="stylesheet" href="/build/bundle.css?436" />
|
<link rel="stylesheet" href="/build/bundle.css?438" />
|
||||||
|
|
||||||
<script defer src="/build/bundle.js?436"></script>
|
<script defer src="/build/bundle.js?438"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body></body>
|
<body></body>
|
||||||
|
|||||||
@@ -37,12 +37,12 @@
|
|||||||
let updatingTimeout = 120000;
|
let updatingTimeout = 120000;
|
||||||
let opened = false;
|
let opened = false;
|
||||||
let preventMove = false;
|
let preventMove = false;
|
||||||
let devMode = true;
|
let devMode = false;
|
||||||
|
|
||||||
//****************************************************variable section**********************************************************/
|
//****************************************************variable section**********************************************************/
|
||||||
//******************************************************************************************************************************/
|
//******************************************************************************************************************************/
|
||||||
let myip = document.location.hostname;
|
let myip = document.location.hostname;
|
||||||
if (devMode) myip = "192.168.88.242";
|
if (devMode) myip = "192.168.88.238";
|
||||||
|
|
||||||
//Flags
|
//Flags
|
||||||
let firstDevListRequest = true;
|
let firstDevListRequest = true;
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
let configJson = [];
|
let configJson = [];
|
||||||
let widgetsJson = [];
|
let widgetsJson = [];
|
||||||
let itemsJson = [];
|
let itemsJson = [];
|
||||||
let scenarioJson = {};
|
let scenarioTxt = "";
|
||||||
|
|
||||||
let chartJsonFlag = {};
|
let chartJsonFlag = {};
|
||||||
let layoutJsonFlag = {};
|
let layoutJsonFlag = {};
|
||||||
@@ -149,7 +149,7 @@
|
|||||||
var layoutJsonBlobArray = [];
|
var layoutJsonBlobArray = [];
|
||||||
|
|
||||||
class blobToJson {
|
class blobToJson {
|
||||||
constructor(st, end, logMsg) {
|
constructor(st, end, logMsg, jsonMode) {
|
||||||
this.st = st;
|
this.st = st;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
this.logMsg = logMsg;
|
this.logMsg = logMsg;
|
||||||
@@ -158,6 +158,7 @@
|
|||||||
this.blob = new MyBlobBuilder();
|
this.blob = new MyBlobBuilder();
|
||||||
this.out;
|
this.out;
|
||||||
this.ws = 0;
|
this.ws = 0;
|
||||||
|
this.jsonMode = jsonMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle(data) {
|
handle(data) {
|
||||||
@@ -180,12 +181,19 @@
|
|||||||
reader.readAsText(bb);
|
reader.readAsText(bb);
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
let result = reader.result;
|
let result = reader.result;
|
||||||
|
if (this.jsonMode) {
|
||||||
if (IsJsonParse(result)) {
|
if (IsJsonParse(result)) {
|
||||||
this.parced = true;
|
this.parced = true;
|
||||||
this.out = JSON.parse(result);
|
this.out = JSON.parse(result);
|
||||||
if (debug) console.log("✔ B", this.logMsg + " blob parced");
|
if (debug) console.log("✔ B", this.logMsg + " blob parced");
|
||||||
onParced();
|
onParced();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.parced = true;
|
||||||
|
this.out = result;
|
||||||
|
if (debug) console.log("✔ S", this.logMsg + " text parced", this.out);
|
||||||
|
onParced();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
this.blob.clear();
|
this.blob.clear();
|
||||||
}
|
}
|
||||||
@@ -210,10 +218,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let configJsonPacket = new blobToJson("/st/config.json", "/end/config.json", "config.json");
|
let configJsonPacket = new blobToJson("/st/config.json", "/end/config.json", "config.json", true);
|
||||||
let itemsJsonPacket = new blobToJson("/st/items.json", "/end/items.json", "items.json");
|
let itemsJsonPacket = new blobToJson("/st/items.json", "/end/items.json", "items.json", true);
|
||||||
let widgetsJsonPacket = new blobToJson("/st/widgets.json", "/end/widgets.json", "widgets.json");
|
let widgetsJsonPacket = new blobToJson("/st/widgets.json", "/end/widgets.json", "widgets.json", true);
|
||||||
let scenarioJsonPacket = new blobToJson("/st/scenario.json", "/end/scenario.json", "scenario.json");
|
let scenarioJsonPacket = new blobToJson("/st/scenario.txt", "/end/scenario.txt", "scenario.json.txt", false);
|
||||||
|
|
||||||
router.subscribe(handleNavigation);
|
router.subscribe(handleNavigation);
|
||||||
|
|
||||||
@@ -527,7 +535,7 @@
|
|||||||
itemsJson = itemsJsonPacket.getData;
|
itemsJson = itemsJsonPacket.getData;
|
||||||
widgetsJson = widgetsJsonPacket.getData;
|
widgetsJson = widgetsJsonPacket.getData;
|
||||||
configJson = configJsonPacket.getData;
|
configJson = configJsonPacket.getData;
|
||||||
scenarioJson = scenarioJsonPacket.getData;
|
scenarioTxt = scenarioJsonPacket.getData;
|
||||||
|
|
||||||
pageReady.config = true;
|
pageReady.config = true;
|
||||||
|
|
||||||
@@ -698,7 +706,8 @@
|
|||||||
wsSendMsg(selectedWs, "/tuoyal|" + JSON.stringify(generateLayout()));
|
wsSendMsg(selectedWs, "/tuoyal|" + JSON.stringify(generateLayout()));
|
||||||
modify();
|
modify();
|
||||||
wsSendMsg(selectedWs, "/gifnoc|" + JSON.stringify(configJson));
|
wsSendMsg(selectedWs, "/gifnoc|" + JSON.stringify(configJson));
|
||||||
wsSendMsg(selectedWs, "/oiranecs|" + JSON.stringify(scenarioJson));
|
|
||||||
|
wsSendMsg(selectedWs, "/oiranecs|" + scenarioTxt);
|
||||||
clearData();
|
clearData();
|
||||||
sendCurrentPageName();
|
sendCurrentPageName();
|
||||||
}
|
}
|
||||||
@@ -797,7 +806,7 @@
|
|||||||
layoutJson = [];
|
layoutJson = [];
|
||||||
layoutJsonBlobArray = [];
|
layoutJsonBlobArray = [];
|
||||||
|
|
||||||
scenarioJson = {};
|
scenarioTxt = "";
|
||||||
|
|
||||||
settingsJson = {};
|
settingsJson = {};
|
||||||
errorsJson = {};
|
errorsJson = {};
|
||||||
@@ -1249,7 +1258,7 @@
|
|||||||
<DashboardPage show={pageReady.dash} layoutJson={layoutJson} pages={pages} wsPush={(ws, topic, status) => wsPush(ws, topic, status)} />
|
<DashboardPage show={pageReady.dash} layoutJson={layoutJson} pages={pages} wsPush={(ws, topic, status) => wsPush(ws, topic, status)} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/config">
|
<Route path="/config">
|
||||||
<ConfigPage show={pageReady.config} configJson={configJson} widgetsJson={widgetsJson} itemsJson={itemsJson} saveConfig={() => saveConfig()} cleanLogs={() => cleanLogs()} rebootEsp={() => rebootEsp()} scenarioJson={scenarioJson} />
|
<ConfigPage show={pageReady.config} bind:configJson bind:scenarioTxt widgetsJson={widgetsJson} itemsJson={itemsJson} saveConfig={() => saveConfig()} cleanLogs={() => cleanLogs()} rebootEsp={() => rebootEsp()} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/connection">
|
<Route path="/connection">
|
||||||
<ConnectionPage show={pageReady.connection} rebootEsp={() => rebootEsp()} ssidClick={() => ssidClick()} saveSett={() => saveSett()} saveMqtt={() => saveMqtt()} settingsJson={settingsJson} errorsJson={errorsJson} ssidJson={ssidJson} />
|
<ConnectionPage show={pageReady.connection} rebootEsp={() => rebootEsp()} ssidClick={() => ssidClick()} saveSett={() => saveSett()} saveMqtt={() => saveMqtt()} settingsJson={settingsJson} errorsJson={errorsJson} ssidJson={ssidJson} />
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
export let configJson;
|
export let configJson;
|
||||||
export let widgetsJson;
|
export let widgetsJson;
|
||||||
export let itemsJson;
|
export let itemsJson;
|
||||||
export let scenarioJson;
|
export let scenarioTxt;
|
||||||
|
|
||||||
export let show;
|
export let show;
|
||||||
|
|
||||||
@@ -53,11 +53,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: scenarioJson, windowHeight();
|
$: scenarioTxt, windowHeight();
|
||||||
|
|
||||||
let height;
|
let height;
|
||||||
|
|
||||||
function windowHeight() {
|
function windowHeight() {
|
||||||
let scenStr = JSON.stringify(scenarioJson);
|
console.log("test", scenarioTxt);
|
||||||
height = scenStr.split("\\n").length;
|
let scenStr = scenarioTxt;
|
||||||
|
height = scenStr.split("\n").length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to download data to a file
|
// Function to download data to a file
|
||||||
@@ -97,15 +100,14 @@
|
|||||||
function createExportFile() {
|
function createExportFile() {
|
||||||
exportJson.mark = "iotm";
|
exportJson.mark = "iotm";
|
||||||
exportJson.config = configJson;
|
exportJson.config = configJson;
|
||||||
exportJson.scenario = scenarioJson;
|
exportJson.scenario = scenarioTxt;
|
||||||
//exportJson.settings = settingsJson;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let template = null;
|
let template = null;
|
||||||
let files = null;
|
let files = null;
|
||||||
|
|
||||||
const alertErr = "Файл не является файлом конфигурации";
|
const alertErr = "Файл не является файлом конфигурации";
|
||||||
const alertOk = "Применить конфигурацию?\nне забудьте нажать кнопку 'сохранить'";
|
const alertOk = "Применить конфигурацию?\nне забудьте нажать кнопку 'сохранить на устройстве'";
|
||||||
|
|
||||||
$: if (files) {
|
$: if (files) {
|
||||||
const fileText = files[0].text();
|
const fileText = files[0].text();
|
||||||
@@ -116,13 +118,12 @@
|
|||||||
if (json.mark === "iotm") {
|
if (json.mark === "iotm") {
|
||||||
if (window.confirm(alertOk)) {
|
if (window.confirm(alertOk)) {
|
||||||
configJson = [];
|
configJson = [];
|
||||||
scenarioJson = {};
|
scenarioTxt = "";
|
||||||
configJson = json.config;
|
|
||||||
scenarioJson = json.scenario;
|
|
||||||
configJson = configJson;
|
|
||||||
scenarioJson = scenarioJson;
|
|
||||||
|
|
||||||
console.log(JSON.stringify(configJson));
|
configJson = json.config;
|
||||||
|
scenarioTxt = json.scenario;
|
||||||
|
|
||||||
|
console.log("config updated");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
window.alert(alertErr);
|
window.alert(alertErr);
|
||||||
@@ -222,18 +223,18 @@
|
|||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="Сценарии">
|
<Card title="Сценарии">
|
||||||
<textarea bind:value={scenarioJson.scen} rows={height} class="px-2 bg-gray-50 border-2 border-gray-200 rounded text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-indigo-500 w-full" />
|
<textarea bind:value={scenarioTxt} rows={height} class="px-2 bg-gray-50 border-2 border-gray-200 rounded text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-indigo-500 w-full" />
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
<div class="grd-1col1">
|
<div class="grd-1col1">
|
||||||
<Card>
|
<Card>
|
||||||
<div class="grd-2col1">
|
<div class="grd-2col1">
|
||||||
<button class="btn-lg" on:click={() => saveConfig()}>{"Сохранить"}</button>
|
<button class="btn-lg" on:click={() => saveConfig()}>{"Сохранить на устройстве"}</button>
|
||||||
<button class="btn-lg" on:click={() => rebootEsp()}>{"Перезагрузить"}</button>
|
<button class="btn-lg" on:click={() => rebootEsp()}>{"Перезагрузить устройство"}</button>
|
||||||
<button class="btn-lg" on:click={() => (createExportFile(), download(syntaxHighlight(JSON.stringify(exportJson)), "export.json", "application/json"))}>{"Сохранить конфигурацию"}</button>
|
<button class="btn-lg" on:click={() => (createExportFile(), download(syntaxHighlight(JSON.stringify(exportJson)), "export.json", "application/json"))}>{"Экспорт конфигурации"}</button>
|
||||||
<label on:click={() => reset()} class="btn-lg cursor-pointer select-none">
|
<label on:click={() => reset()} class="btn-lg cursor-pointer select-none">
|
||||||
<input bind:files accept="application/JSON" type="file" id="formFile" />
|
<input bind:files accept="application/JSON" type="file" id="formFile" />
|
||||||
{"Загрузить конфигурацию"}
|
{"Импорт конфигурации"}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Reference in New Issue
Block a user