From 3d7a51e7930e908a65a1fbe9565f4f7030756739 Mon Sep 17 00:00:00 2001 From: Dmitry Borisenko <49808844+DmitryBorisenko33@users.noreply.github.com> Date: Thu, 29 Sep 2022 15:14:37 +0200 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B5=D1=82=D0=BA=D0=B8=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Config.svelte | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/pages/Config.svelte b/src/pages/Config.svelte index 2323f7c..062d7a1 100644 --- a/src/pages/Config.svelte +++ b/src/pages/Config.svelte @@ -95,26 +95,40 @@ }; function createExportFile() { + exportJson.mark = "iotm"; exportJson.config = configJson; exportJson.scenario = scenarioJson; + //exportJson.settings = settingsJson; } let template = null; let files = null; + const alertErr = "Файл не является файлом конфигурации"; + const alertOk = "Применить конфигурацию?\nне забудьте нажать кнопку 'сохранить'"; + $: if (files) { const fileText = files[0].text(); fileText.then((text) => { template = text; if (IsJsonParse(template)) { let json = JSON.parse(template); - configJson = []; - scenarioJson = {}; - configJson = json.config; - scenarioJson = json.scenario; - configJson = configJson; - scenarioJson = scenarioJson; - console.log(JSON.stringify(configJson)); + if (json.mark === "iotm") { + if (window.confirm(alertOk)) { + configJson = []; + scenarioJson = {}; + configJson = json.config; + scenarioJson = json.scenario; + configJson = configJson; + scenarioJson = scenarioJson; + + console.log(JSON.stringify(configJson)); + } + } else { + window.alert(alertErr); + } + } else { + window.alert(alertErr); } }); files = null; @@ -217,8 +231,8 @@ -