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 @@ -