From fe5ce584bbcf5b822850c052c2ce1b0348416212 Mon Sep 17 00:00:00 2001 From: IoT Manager <67171972+IoTManagerProject@users.noreply.github.com> Date: Mon, 16 Oct 2023 17:03:53 +0200 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D1=83=D1=80?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 6 ++--- src/pages/Config.svelte | 52 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/public/index.html b/public/index.html index 4dc7d62..bbcd166 100644 --- a/public/index.html +++ b/public/index.html @@ -4,12 +4,12 @@ - IoT Manager 4.5.4 + IoT Manager 4.5.5 - + - + diff --git a/src/pages/Config.svelte b/src/pages/Config.svelte index 54c18e6..7862669 100644 --- a/src/pages/Config.svelte +++ b/src/pages/Config.svelte @@ -3,6 +3,7 @@ import CrossIcon from "../svg/Cross.svelte"; import OpenIcon from "../svg/Open.svelte"; import Alarm from "../components/Alarm.svelte"; + import { onMount } from "svelte"; import Cookies from "js-cookie"; @@ -15,14 +16,21 @@ export let show; let itemsJsonBind = 0; + let configsBind = 0; let debug = false; + let configurations = null; + export let saveConfig = () => {}; export let rebootEsp = () => {}; //export let cleanLogs = () => {}; let exportJson = {}; + onMount(async () => { + await getConfigs(); + }); + function elementsDropdownChange() { for (let i = 0; i < itemsJson.length; i++) { let item = Object.assign({}, itemsJson[i]); @@ -229,7 +237,7 @@ if (res.ok) { console.log(content.result); if (content.result.acknowledged) { - window.open("http://localhost:4000/configs?username=" + userdata.username + "&id=" + content.result.insertedId, "_blank"); + window.open("https://portal.iotmanager.org/configs?username=" + userdata.username + "&id=" + content.result.insertedId, "_blank"); } errors = [{ msg: "ok_success" }]; } else { @@ -239,6 +247,34 @@ console.log(e); } }; + + const getConfigs = async () => { + try { + const JWT = Cookies.get("token_iotm2"); + let res = await fetch("https://portal.iotmanager.org/api/configurations/get", { + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${JWT}`, + }, + mode: "cors", + method: "GET", + }); + if (res.ok) { + configurations = await res.json(); + //configurations.push({ topic: { ru: "123" } }); + console.log("error", configurations); + } else { + console.log("error", res.statusText); + } + } catch (e) { + console.log("error", e); + } + }; + + function setConfScen() { + configJson = configurations[configsBind].config; + scenarioTxt = configurations[configsBind].scenario; + } {#if show} @@ -258,7 +294,15 @@ {/if} {/each} - + @@ -341,7 +385,9 @@ {"Импорт конфигурации"} - + {#if userdata} + + {/if} {:else}