mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-26 15:02:21 +03:00
рабочая версия публикации конфигурации
This commit is contained in:
@@ -3,8 +3,8 @@
|
|||||||
"version": "4.2.0",
|
"version": "4.2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c",
|
|
||||||
"dev": "rollup -c -w",
|
"dev": "rollup -c -w",
|
||||||
|
"build": "rollup -c",
|
||||||
"start": "sirv public --no-clear"
|
"start": "sirv public --no-clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -52,14 +52,14 @@
|
|||||||
let preventMove = false;
|
let preventMove = false;
|
||||||
let screenSize;
|
let screenSize;
|
||||||
const blobDebug = false;
|
const blobDebug = false;
|
||||||
const devMode = false;
|
const devMode = true;
|
||||||
|
|
||||||
let percent;
|
let percent;
|
||||||
|
|
||||||
//****************************************************variable section**********************************************************/
|
//****************************************************variable section**********************************************************/
|
||||||
//******************************************************************************************************************************/
|
//******************************************************************************************************************************/
|
||||||
let myip = document.location.hostname;
|
let myip = document.location.hostname;
|
||||||
if (devMode) myip = "192.168.1.228";
|
if (devMode) myip = "192.168.1.247";
|
||||||
|
|
||||||
//Flags
|
//Flags
|
||||||
let firstDevListRequest = true;
|
let firstDevListRequest = true;
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
import OpenIcon from "../svg/Open.svelte";
|
import OpenIcon from "../svg/Open.svelte";
|
||||||
import Alarm from "../components/Alarm.svelte";
|
import Alarm from "../components/Alarm.svelte";
|
||||||
|
|
||||||
|
import Cookies from "js-cookie";
|
||||||
|
|
||||||
export let configJson;
|
export let configJson;
|
||||||
export let widgetsJson;
|
export let widgetsJson;
|
||||||
export let itemsJson;
|
export let itemsJson;
|
||||||
@@ -193,6 +195,49 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export let moduleOrder = (id, key, value) => {};
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if show}
|
{#if show}
|
||||||
@@ -295,6 +340,7 @@
|
|||||||
{"Импорт конфигурации"}
|
{"Импорт конфигурации"}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<button class="btn-lg mt-4" on:click={() => makePost()}>{"Опубликовать конфигурацию на портале"}</button>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
|
|||||||
Reference in New Issue
Block a user