mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-26 15:02:21 +03:00
получение конфигурации
This commit is contained in:
@@ -4,12 +4,12 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
|
|
||||||
<title>IoT Manager 4.5.4</title>
|
<title>IoT Manager 4.5.5</title>
|
||||||
|
|
||||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||||
<link rel="stylesheet" href="/build/bundle.css?4541" />
|
<link rel="stylesheet" href="/build/bundle.css?4550" />
|
||||||
|
|
||||||
<script defer src="/build/bundle.js?4541"></script>
|
<script defer src="/build/bundle.js?4550"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body></body>
|
<body></body>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import CrossIcon from "../svg/Cross.svelte";
|
import CrossIcon from "../svg/Cross.svelte";
|
||||||
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 { onMount } from "svelte";
|
||||||
|
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
|
|
||||||
@@ -15,14 +16,21 @@
|
|||||||
export let show;
|
export let show;
|
||||||
|
|
||||||
let itemsJsonBind = 0;
|
let itemsJsonBind = 0;
|
||||||
|
let configsBind = 0;
|
||||||
let debug = false;
|
let debug = false;
|
||||||
|
|
||||||
|
let configurations = null;
|
||||||
|
|
||||||
export let saveConfig = () => {};
|
export let saveConfig = () => {};
|
||||||
export let rebootEsp = () => {};
|
export let rebootEsp = () => {};
|
||||||
//export let cleanLogs = () => {};
|
//export let cleanLogs = () => {};
|
||||||
|
|
||||||
let exportJson = {};
|
let exportJson = {};
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
await getConfigs();
|
||||||
|
});
|
||||||
|
|
||||||
function elementsDropdownChange() {
|
function elementsDropdownChange() {
|
||||||
for (let i = 0; i < itemsJson.length; i++) {
|
for (let i = 0; i < itemsJson.length; i++) {
|
||||||
let item = Object.assign({}, itemsJson[i]);
|
let item = Object.assign({}, itemsJson[i]);
|
||||||
@@ -229,7 +237,7 @@
|
|||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
console.log(content.result);
|
console.log(content.result);
|
||||||
if (content.result.acknowledged) {
|
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" }];
|
errors = [{ msg: "ok_success" }];
|
||||||
} else {
|
} else {
|
||||||
@@ -239,6 +247,34 @@
|
|||||||
console.log(e);
|
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;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if show}
|
{#if show}
|
||||||
@@ -258,7 +294,15 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
<select class="slct-lg"><option>{"Выберите пресет"}</option></select>
|
<select class="slct-lg" bind:value={configsBind} on:change={() => setConfScen()}>
|
||||||
|
{#if configurations}
|
||||||
|
{#each configurations as config, i}
|
||||||
|
<option value={i}>
|
||||||
|
{config.topic["ru"]}
|
||||||
|
</option>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<table class="tbl">
|
<table class="tbl">
|
||||||
<thead class="bg-gray-100">
|
<thead class="bg-gray-100">
|
||||||
@@ -341,7 +385,9 @@
|
|||||||
{"Импорт конфигурации"}
|
{"Импорт конфигурации"}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
{#if userdata}
|
||||||
<button class="btn-lg mt-4" on:click={() => makePost()}>{"Опубликовать конфигурацию на портале"}</button>
|
<button class="btn-lg mt-4" on:click={() => makePost()}>{"Опубликовать конфигурацию на портале"}</button>
|
||||||
|
{/if}
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
|
|||||||
Reference in New Issue
Block a user