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}