mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-26 15:02:21 +03:00
последний на сегодня
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
<meta charset="utf-8" />
|
||||
<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="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>
|
||||
|
||||
<body></body>
|
||||
|
||||
@@ -37,12 +37,12 @@
|
||||
let updatingTimeout = 120000;
|
||||
let opened = false;
|
||||
let preventMove = false;
|
||||
let devMode = true;
|
||||
let devMode = false;
|
||||
|
||||
//****************************************************variable section**********************************************************/
|
||||
//******************************************************************************************************************************/
|
||||
let myip = document.location.hostname;
|
||||
if (devMode) myip = "192.168.88.242";
|
||||
if (devMode) myip = "192.168.88.238";
|
||||
|
||||
//Flags
|
||||
let firstDevListRequest = true;
|
||||
@@ -84,7 +84,7 @@
|
||||
let configJson = [];
|
||||
let widgetsJson = [];
|
||||
let itemsJson = [];
|
||||
let scenarioJson = {};
|
||||
let scenarioTxt = "";
|
||||
|
||||
let chartJsonFlag = {};
|
||||
let layoutJsonFlag = {};
|
||||
@@ -149,7 +149,7 @@
|
||||
var layoutJsonBlobArray = [];
|
||||
|
||||
class blobToJson {
|
||||
constructor(st, end, logMsg) {
|
||||
constructor(st, end, logMsg, jsonMode) {
|
||||
this.st = st;
|
||||
this.end = end;
|
||||
this.logMsg = logMsg;
|
||||
@@ -158,6 +158,7 @@
|
||||
this.blob = new MyBlobBuilder();
|
||||
this.out;
|
||||
this.ws = 0;
|
||||
this.jsonMode = jsonMode;
|
||||
}
|
||||
|
||||
handle(data) {
|
||||
@@ -180,10 +181,17 @@
|
||||
reader.readAsText(bb);
|
||||
reader.onload = () => {
|
||||
let result = reader.result;
|
||||
if (IsJsonParse(result)) {
|
||||
if (this.jsonMode) {
|
||||
if (IsJsonParse(result)) {
|
||||
this.parced = true;
|
||||
this.out = JSON.parse(result);
|
||||
if (debug) console.log("✔ B", this.logMsg + " blob parced");
|
||||
onParced();
|
||||
}
|
||||
} else {
|
||||
this.parced = true;
|
||||
this.out = JSON.parse(result);
|
||||
if (debug) console.log("✔ B", this.logMsg + " blob parced");
|
||||
this.out = result;
|
||||
if (debug) console.log("✔ S", this.logMsg + " text parced", this.out);
|
||||
onParced();
|
||||
}
|
||||
};
|
||||
@@ -210,10 +218,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
let configJsonPacket = new blobToJson("/st/config.json", "/end/config.json", "config.json");
|
||||
let itemsJsonPacket = new blobToJson("/st/items.json", "/end/items.json", "items.json");
|
||||
let widgetsJsonPacket = new blobToJson("/st/widgets.json", "/end/widgets.json", "widgets.json");
|
||||
let scenarioJsonPacket = new blobToJson("/st/scenario.json", "/end/scenario.json", "scenario.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", true);
|
||||
let widgetsJsonPacket = new blobToJson("/st/widgets.json", "/end/widgets.json", "widgets.json", true);
|
||||
let scenarioJsonPacket = new blobToJson("/st/scenario.txt", "/end/scenario.txt", "scenario.json.txt", false);
|
||||
|
||||
router.subscribe(handleNavigation);
|
||||
|
||||
@@ -527,7 +535,7 @@
|
||||
itemsJson = itemsJsonPacket.getData;
|
||||
widgetsJson = widgetsJsonPacket.getData;
|
||||
configJson = configJsonPacket.getData;
|
||||
scenarioJson = scenarioJsonPacket.getData;
|
||||
scenarioTxt = scenarioJsonPacket.getData;
|
||||
|
||||
pageReady.config = true;
|
||||
|
||||
@@ -698,7 +706,8 @@
|
||||
wsSendMsg(selectedWs, "/tuoyal|" + JSON.stringify(generateLayout()));
|
||||
modify();
|
||||
wsSendMsg(selectedWs, "/gifnoc|" + JSON.stringify(configJson));
|
||||
wsSendMsg(selectedWs, "/oiranecs|" + JSON.stringify(scenarioJson));
|
||||
|
||||
wsSendMsg(selectedWs, "/oiranecs|" + scenarioTxt);
|
||||
clearData();
|
||||
sendCurrentPageName();
|
||||
}
|
||||
@@ -797,7 +806,7 @@
|
||||
layoutJson = [];
|
||||
layoutJsonBlobArray = [];
|
||||
|
||||
scenarioJson = {};
|
||||
scenarioTxt = "";
|
||||
|
||||
settingsJson = {};
|
||||
errorsJson = {};
|
||||
@@ -1249,7 +1258,7 @@
|
||||
<DashboardPage show={pageReady.dash} layoutJson={layoutJson} pages={pages} wsPush={(ws, topic, status) => wsPush(ws, topic, status)} />
|
||||
</Route>
|
||||
<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 path="/connection">
|
||||
<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 widgetsJson;
|
||||
export let itemsJson;
|
||||
export let scenarioJson;
|
||||
export let scenarioTxt;
|
||||
|
||||
export let show;
|
||||
|
||||
@@ -53,11 +53,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: scenarioJson, windowHeight();
|
||||
$: scenarioTxt, windowHeight();
|
||||
|
||||
let height;
|
||||
|
||||
function windowHeight() {
|
||||
let scenStr = JSON.stringify(scenarioJson);
|
||||
height = scenStr.split("\\n").length;
|
||||
console.log("test", scenarioTxt);
|
||||
let scenStr = scenarioTxt;
|
||||
height = scenStr.split("\n").length;
|
||||
}
|
||||
|
||||
// Function to download data to a file
|
||||
@@ -97,15 +100,14 @@
|
||||
function createExportFile() {
|
||||
exportJson.mark = "iotm";
|
||||
exportJson.config = configJson;
|
||||
exportJson.scenario = scenarioJson;
|
||||
//exportJson.settings = settingsJson;
|
||||
exportJson.scenario = scenarioTxt;
|
||||
}
|
||||
|
||||
let template = null;
|
||||
let files = null;
|
||||
|
||||
const alertErr = "Файл не является файлом конфигурации";
|
||||
const alertOk = "Применить конфигурацию?\nне забудьте нажать кнопку 'сохранить'";
|
||||
const alertOk = "Применить конфигурацию?\nне забудьте нажать кнопку 'сохранить на устройстве'";
|
||||
|
||||
$: if (files) {
|
||||
const fileText = files[0].text();
|
||||
@@ -116,13 +118,12 @@
|
||||
if (json.mark === "iotm") {
|
||||
if (window.confirm(alertOk)) {
|
||||
configJson = [];
|
||||
scenarioJson = {};
|
||||
configJson = json.config;
|
||||
scenarioJson = json.scenario;
|
||||
configJson = configJson;
|
||||
scenarioJson = scenarioJson;
|
||||
scenarioTxt = "";
|
||||
|
||||
console.log(JSON.stringify(configJson));
|
||||
configJson = json.config;
|
||||
scenarioTxt = json.scenario;
|
||||
|
||||
console.log("config updated");
|
||||
}
|
||||
} else {
|
||||
window.alert(alertErr);
|
||||
@@ -222,18 +223,18 @@
|
||||
</Card>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
<div class="grd-1col1">
|
||||
<Card>
|
||||
<div class="grd-2col1">
|
||||
<button class="btn-lg" on:click={() => saveConfig()}>{"Сохранить"}</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={() => saveConfig()}>{"Сохранить на устройстве"}</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>
|
||||
<label on:click={() => reset()} class="btn-lg cursor-pointer select-none">
|
||||
<input bind:files accept="application/JSON" type="file" id="formFile" />
|
||||
{"Загрузить конфигурацию"}
|
||||
{"Импорт конфигурации"}
|
||||
</label>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user