From f6c6725d36cc6f72af1c5b1219462bda696603d3 Mon Sep 17 00:00:00 2001 From: bogdan Date: Sun, 20 Aug 2023 15:01:01 +0200 Subject: [PATCH] newtwork and herpers modules moved to webguicomp --- WEBUI_SRC/src/boot/helpers.js | 37 ----------------- WEBUI_SRC/src/boot/network.js | 64 ----------------------------- WEBUI_SRC/src/components/webguicomp | 2 +- WEBUI_SRC/src/pages/IndexPage2.vue | 21 ---------- 4 files changed, 1 insertion(+), 123 deletions(-) delete mode 100644 WEBUI_SRC/src/boot/helpers.js delete mode 100644 WEBUI_SRC/src/boot/network.js diff --git a/WEBUI_SRC/src/boot/helpers.js b/WEBUI_SRC/src/boot/helpers.js deleted file mode 100644 index 54ab76f..0000000 --- a/WEBUI_SRC/src/boot/helpers.js +++ /dev/null @@ -1,37 +0,0 @@ -import { Dialog } from "quasar"; - -function secondsToHms(d) { - d = Number(d); - var dd = Math.floor(d / 86400); - var h = Math.floor(d % 86400 / 3600); - var m = Math.floor(d % 3600 / 60); - var s = Math.floor(d % 3600 % 60); - return (' ' + dd + 'd ' + (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s); -} - -function ShowDelayDialog(mess, time, onexpire) { - const dialog = Dialog.create({ - message: '', - progress: true, - persistent: true, // we want the user to not be able to close it - ok: false // we want the user to not be able to close it - }) - - let percentage = 0 - const interval = setInterval(() => { - percentage = Math.min(100, percentage + 10000 / time); - dialog.update({ message: `${mess} ${percentage}%` }) - - - // if we are done, we're gonna close it - if (percentage === 100) { - clearInterval(interval) - setTimeout(() => { - dialog.hide(); - onexpire(); - }, 350) - } - }, 100) -} - -export { secondsToHms, ShowDelayDialog } diff --git a/WEBUI_SRC/src/boot/network.js b/WEBUI_SRC/src/boot/network.js deleted file mode 100644 index 50ed1bb..0000000 --- a/WEBUI_SRC/src/boot/network.js +++ /dev/null @@ -1,64 +0,0 @@ -import { api } from "boot/axios"; -import { sha256 } from "js-sha256"; -import { Notify, Dialog } from "quasar"; - -const API_URL = "/api"; -const SHA256_HMAC_KEY = "mykey"; - -function ShowSaveDialog(apltype) { - const opername = ['Data applying...', 'Data saving...', 'Data saving and reboot...']; - let step = (apltype == 2) ? 1 : 10; - let percentage = 0; - const dialog = Dialog.create({ message: opername[apltype], progress: true, persistent: true, ok: false }) - const interval = setInterval(() => { - percentage = Math.min(100, percentage + step); - dialog.update({ - message: `${opername[apltype]} ${percentage}%` - }) - if (percentage === 100) { - clearInterval(interval); - setTimeout(() => { dialog.hide() }, 350) - } - }, 100) -} - - - -function PostData(varlist, messtype, applytype, onfinished) { - var pld = {}; - var data = {}; - data.msgid = Math.floor(Date.now() / 1000); - data.time = new Date().toISOString(); - data.msgtype = messtype; - data.payloadtype = 1; - data.payload = {}; - data.payload.applytype = applytype; - data.payload.variables = varlist; - pld.data = data; - pld.signature = sha256.hmac(SHA256_HMAC_KEY, JSON.stringify(data)); - - api - .post(API_URL, JSON.stringify(pld), { - headers: { "Content-Type": "application/json" }, - }) - .then((response) => { - var resp = response.data.data.payload.variables; - for (var k in resp) varlist[k] = resp[k]; - if (onfinished) onfinished(); - }) - .catch((err) => { - Notify.create({ color: "negative", position: "top", message: err.message, icon: "report_problem", }); - }); - -} - -function SendAndRequest(varlist, mstp, apltp, shakey, okreport) { - var onfinish = (okreport) ? () => { ShowSaveDialog(apltp) } : null; - PostData(varlist, mstp, apltp, onfinish); -} - -export { SendAndRequest, PostData }; - - - - diff --git a/WEBUI_SRC/src/components/webguicomp b/WEBUI_SRC/src/components/webguicomp index a299fd7..b89a78c 160000 --- a/WEBUI_SRC/src/components/webguicomp +++ b/WEBUI_SRC/src/components/webguicomp @@ -1 +1 @@ -Subproject commit a299fd729873fad89c611db9b5d1081e842a8e31 +Subproject commit b89a78c0a4e6674a25572a36f14c3bf89a3b2b4f diff --git a/WEBUI_SRC/src/pages/IndexPage2.vue b/WEBUI_SRC/src/pages/IndexPage2.vue index 334c590..b77f912 100644 --- a/WEBUI_SRC/src/pages/IndexPage2.vue +++ b/WEBUI_SRC/src/pages/IndexPage2.vue @@ -1,28 +1,7 @@