From d10ffd679ca60522d23388d6d206d14e63fb53bd Mon Sep 17 00:00:00 2001 From: IoT Manager <67171972+IoTManagerProject@users.noreply.github.com> Date: Sat, 14 Oct 2023 17:37:42 +0200 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=87=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F=20=D0=BF=D1=83=D0=B1=D0=BB?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BA=D0=BE=D0=BD=D1=84?= =?UTF-8?q?=D0=B8=D0=B3=D1=83=D1=80=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/App.svelte | 4 ++-- src/pages/Config.svelte | 46 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 1b4f49a..0b4e6e8 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "4.2.0", "private": true, "scripts": { - "build": "rollup -c", "dev": "rollup -c -w", + "build": "rollup -c", "start": "sirv public --no-clear" }, "devDependencies": { diff --git a/src/App.svelte b/src/App.svelte index 74ed7c3..0156a44 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -52,14 +52,14 @@ let preventMove = false; let screenSize; const blobDebug = false; - const devMode = false; + const devMode = true; let percent; //****************************************************variable section**********************************************************/ //******************************************************************************************************************************/ let myip = document.location.hostname; - if (devMode) myip = "192.168.1.228"; + if (devMode) myip = "192.168.1.247"; //Flags let firstDevListRequest = true; diff --git a/src/pages/Config.svelte b/src/pages/Config.svelte index 07dc846..91d86f4 100644 --- a/src/pages/Config.svelte +++ b/src/pages/Config.svelte @@ -4,6 +4,8 @@ import OpenIcon from "../svg/Open.svelte"; import Alarm from "../components/Alarm.svelte"; + import Cookies from "js-cookie"; + export let configJson; export let widgetsJson; export let itemsJson; @@ -193,6 +195,49 @@ } export let moduleOrder = (id, key, value) => {}; + + const makePost = async () => { + let iotmpostDefault = { + category: "", + topic: { + ru: "", + en: "", + }, + text: { + ru: "", + en: "", + }, + config: configJson, + scenario: scenarioTxt, + gallery: [], + type: "iotmpost", + }; + const JWT = Cookies.get("token_iotm2"); + try { + let res = await fetch("https://portal.iotmanager.org/api/configurations/add", { + mode: "cors", + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${JWT}`, + }, + body: JSON.stringify(iotmpostDefault), + }); + const content = await res.json(); + if (res.ok) { + console.log(content.result); + if (content.result.acknowledged) { + window.open("http://localhost:4000/configs", "_blank"); + //insertedId + } + errors = [{ msg: "ok_success" }]; + } else { + errors = content.message; + } + } catch (e) { + console.log(e); + } + }; {#if show} @@ -295,6 +340,7 @@ {"Импорт конфигурации"} + {:else}