From b7430f87e89e2844e8a2d1209d710ce3e5bc9da6 Mon Sep 17 00:00:00 2001 From: avaksru Date: Mon, 13 Mar 2023 16:13:16 +0300 Subject: [PATCH] HttpGet --- myProfile.json | 4 ++ src/modules/exec/HttpGet/HttpGet.cpp | 100 ++++++++++++++++++++++++++ src/modules/exec/HttpGet/modinfo.json | 58 +++++++++++++++ webConfigMyProfile/build/bundle.css | 1 + webConfigMyProfile/build/bundle.js | 16 +++++ webConfigMyProfile/favicon.ico | Bin 0 -> 1150 bytes webConfigMyProfile/global.css | 63 ++++++++++++++++ webConfigMyProfile/index.html | 18 +++++ 8 files changed, 260 insertions(+) create mode 100644 src/modules/exec/HttpGet/HttpGet.cpp create mode 100644 src/modules/exec/HttpGet/modinfo.json create mode 100644 webConfigMyProfile/build/bundle.css create mode 100644 webConfigMyProfile/build/bundle.js create mode 100644 webConfigMyProfile/favicon.ico create mode 100644 webConfigMyProfile/global.css create mode 100644 webConfigMyProfile/index.html diff --git a/myProfile.json b/myProfile.json index b643f2d5..8bfe873d 100644 --- a/myProfile.json +++ b/myProfile.json @@ -202,6 +202,10 @@ "path": "src/modules/exec/EspCam", "active": false }, + { + "path": "src/modules/exec/HttpGet", + "active": false + }, { "path": "src/modules/exec/IoTServo", "active": true diff --git a/src/modules/exec/HttpGet/HttpGet.cpp b/src/modules/exec/HttpGet/HttpGet.cpp new file mode 100644 index 00000000..8c53c10c --- /dev/null +++ b/src/modules/exec/HttpGet/HttpGet.cpp @@ -0,0 +1,100 @@ +#include "Global.h" +#include "classes/IoTItem.h" + +class HttpGet : public IoTItem +{ +public: + HttpGet(String parameters) : IoTItem(parameters) + { + } + + void sendHttpPOST(String url, String msg) + { + if (WiFi.status() == WL_CONNECTED) + { + + WiFiClient client; + HTTPClient http; + http.begin(client, url); + http.addHeader("Content-Type", "application/x-www-form-urlencoded"); + String httpRequestData = msg; + int httpResponseCode = http.POST(httpRequestData); + String payload = http.getString(); + SerialPrint("<-", F("HttpPOST"), "URL: " + url + ", msg: " + msg); + SerialPrint("->", F("HttpPOST"), "URL: " + url + ", server: " + httpResponseCode); + + if (httpResponseCode > 0) + { + value.valS = payload; + SerialPrint("->", F("HttpPOST"), "msg from server: " + (String)payload.c_str()); + value.valS = payload; + regEvent(value.valS, "HttpGet"); + } + http.end(); + } + } + void sendHttpGET(String url) + { + WiFiClient client; + HTTPClient http; +#if defined ESP8266 + if (!http.begin(client, url)) + { +#elif defined ESP32 + if (!http.begin(url)) + { +#endif + + SerialPrint("I", F("HttpGet"), "connection failed "); + } + http.addHeader("Content-Type", "application/x-www-form-urlencoded"); + int httpResponseCode = http.GET(); + String payload = http.getString(); + SerialPrint("<-", F("HttpGET"), "URL: " + url); + SerialPrint("->", F("HttpGET"), "URL: " + url + ", server: " + httpResponseCode); + if (httpResponseCode > 0) + { + value.valS = payload; + SerialPrint("->", F("HttpGET"), "msg from server: " + (String)payload.c_str()); + value.valS = payload; + regEvent(value.valS, "HttpGet"); + } + http.end(); + } + + IoTValue execute(String command, std::vector ¶m) + { + if (param.size() > 0) + { + if (command == "get") + { + if (param.size()) + { + sendHttpGET(param[0].valS); + } + } + else if (command == "post") + { + if (param.size()) + { + sendHttpPOST(param[0].valS, param[1].valS); + } + } + } + return {}; + } + + ~HttpGet(){}; +}; + +void *getAPI_HttpGet(String subtype, String param) +{ + if (subtype == F("HttpGet")) + { + return new HttpGet(param); + } + else + { + return nullptr; + } +} \ No newline at end of file diff --git a/src/modules/exec/HttpGet/modinfo.json b/src/modules/exec/HttpGet/modinfo.json new file mode 100644 index 00000000..c48638a5 --- /dev/null +++ b/src/modules/exec/HttpGet/modinfo.json @@ -0,0 +1,58 @@ +{ + "menuSection": "Исполнительные устройства", + "configItem": [ + { + "global": 0, + "name": "HttpGet", + "type": "Writing", + "subtype": "HttpGet", + "id": "http", + "widget": "", + "page": "", + "descr": "", + "token": "", + "chatID": "" + } + ], + "about": { + "authorName": "AVAKS", + "authorContact": "https://t.me/@avaks_dev", + "authorGit": "https://github.com/avaksru", + "specialThanks": "", + "moduleName": "HttpGet", + "moduleVersion": "1", + "usedRam": { + "esp32_4mb": 15, + "esp8266_4mb": 15 + }, + "title": "Отправка запросов по http", + "moduleDesc": "Запросы по протоколу https НЕ РАБОТАЮТ!", + "propInfo": {}, + "retInfo": "", + "funcInfo": [ + { + "name": "get", + "descr": "Отправить http запрос методом GET.", + "params": [ + "http.get('URL')" + ] + }, + { + "name": "post", + "descr": "Отправить http запрос методом POST.", + "params": [ + "http.post('URL','message')" + ] + } + ] + }, + "defActive": false, + "usedLibs": { + "esp32_4mb": [], + "esp8266_4mb": [], + "esp8266_1mb": [], + "esp8266_1mb_ota": [], + "esp8285_1mb": [], + "esp8285_1mb_ota": [] + } +} \ No newline at end of file diff --git a/webConfigMyProfile/build/bundle.css b/webConfigMyProfile/build/bundle.css new file mode 100644 index 00000000..51bca0bd --- /dev/null +++ b/webConfigMyProfile/build/bundle.css @@ -0,0 +1 @@ +.board.svelte-185rejv.svelte-185rejv{max-width:36em;margin:0 auto}.left.svelte-185rejv.svelte-185rejv,.right.svelte-185rejv.svelte-185rejv{float:left;width:50%;padding:0 1em 0 0;box-sizing:border-box}h2.svelte-185rejv.svelte-185rejv{font-size:2em;font-weight:200;user-select:none}label.svelte-185rejv.svelte-185rejv{top:0;left:0;display:block;font-size:1em;line-height:1;padding:0.5em;margin:0 auto 0.5em auto;border-radius:2px;background-color:#eee;user-select:none}input.svelte-185rejv.svelte-185rejv{margin:0 }.right.svelte-185rejv label.svelte-185rejv{background-color:rgb(180,240,100)}button.svelte-185rejv.svelte-185rejv{float:right;height:1em;box-sizing:border-box;padding:0 0.5em;line-height:1;background-color:transparent;border:none;color:rgb(170,30,30);opacity:0;transition:opacity 0.2s}label.svelte-185rejv:hover button.svelte-185rejv{opacity:1}.gauge.svelte-1er7lpr{position:relative;width:4em;height:2em;box-sizing:border-box;display:inline-block}.gauge-fill.svelte-1er7lpr{position:absolute;z-index:2;width:100%;height:100%;border-radius:2em 2em 0 0;transition:transform 0.2s;transform-origin:50% 100%}.gauge-bg.svelte-1er7lpr{z-index:1;box-shadow:inset 0 0 20px -15px #000a}.gauge-overflow.svelte-1er7lpr{position:absolute;width:100%;height:100%;overflow:hidden}.gauge-value.svelte-1er7lpr{position:absolute;z-index:4;bottom:0;left:0;right:0;text-align:center;font-weight:bold;line-height:1em}.gauge-white.svelte-1er7lpr{position:absolute;z-index:3;top:15%;left:8%;width:85%;height:182%;border-radius:100%;background:white}.modal-background.svelte-5a6h72{position:fixed;z-index:6;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.3)}.modal.svelte-5a6h72{position:absolute;z-index:6;left:50%;top:50%;width:calc(100vw - 4em);max-width:32em;max-height:calc(100vh - 4em);overflow:auto;transform:translate(-50%,-50%);padding:1em;border-radius:0.2em;background:white}button.svelte-5a6h72{display:block}.box.svelte-1q88uwi{margin:0 auto;display:inline-block;vertical-align:top;width:auto;border:0px solid #aaa;border-radius:1px;box-shadow:1px 1px 4px rgba(0,0,0,0.1);padding:1em;margin:10 2em 1em 0;height:auto} \ No newline at end of file diff --git a/webConfigMyProfile/build/bundle.js b/webConfigMyProfile/build/bundle.js new file mode 100644 index 00000000..b0ced366 --- /dev/null +++ b/webConfigMyProfile/build/bundle.js @@ -0,0 +1,16 @@ +var app=function(){"use strict";function t(){}const e=t=>t;function n(t,e){for(const n in e)t[n]=e[n];return t}function o(t){return t()}function r(){return Object.create(null)}function l(t){t.forEach(o)}function i(t){return"function"==typeof t}function s(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function c(t,e,n,o){if(t){const r=a(t,e,n,o);return t[0](r)}}function a(t,e,o,r){return t[1]&&r?n(o.ctx.slice(),t[1](r(e))):o.ctx}function u(t,e,n,o){if(t[2]&&o){const r=t[2](o(n));if(void 0===e.dirty)return r;if("object"==typeof r){const t=[],n=Math.max(e.dirty.length,r.length);for(let o=0;o32){const e=[],n=t.ctx.length/32;for(let t=0;twindow.performance.now():()=>Date.now(),m=p?t=>requestAnimationFrame(t):t;const g=new Set;function v(t){g.forEach((e=>{e.c(t)||(g.delete(e),e.f())})),0!==g.size&&m(v)}function $(t){let e;return 0===g.size&&m(v),{promise:new Promise((n=>{g.add(e={c:t,f:n})})),abort(){g.delete(e)}}}function b(t,e){t.appendChild(e)}function y(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function x(t){const e=S("style");return function(t,e){b(t.head||t,e),e.sheet}(y(t),e),e.sheet}function _(t,e,n){t.insertBefore(e,n||null)}function w(t){t.parentNode.removeChild(t)}function k(t,e){for(let n=0;nt.removeEventListener(e,n,o)}function P(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function q(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function M(t,e){t.value=null==e?"":e}function I(t,e,n,o){null===n?t.style.removeProperty(e):t.style.setProperty(e,n,o?"important":"")}function T(t,e){for(let n=0;n>>0}(u)}_${s}`,d=y(t),{stylesheet:p,rules:h}=G.get(d)||function(t,e){const n={stylesheet:x(e),rules:{}};return G.set(t,n),n}(d,t);h[f]||(h[f]=!0,p.insertRule(`@keyframes ${f} ${u}`,p.cssRules.length));const m=t.style.animation||"";return t.style.animation=`${m?`${m}, `:""}${f} ${o}ms linear ${r}ms 1 both`,U+=1,f}function A(t,e){const n=(t.style.animation||"").split(", "),o=n.filter(e?t=>t.indexOf(e)<0:t=>-1===t.indexOf("__svelte")),r=n.length-o.length;r&&(t.style.animation=o.join(", "),U-=r,U||m((()=>{U||(G.forEach((t=>{const{ownerNode:e}=t.stylesheet;e&&w(e)})),G.clear())})))}function F(n,o,r,l){if(!o)return t;const i=n.getBoundingClientRect();if(o.left===i.left&&o.right===i.right&&o.top===i.top&&o.bottom===i.bottom)return t;const{delay:s=0,duration:c=300,easing:a=e,start:u=h()+s,end:f=u+c,tick:d=t,css:p}=r(n,{from:o,to:i},l);let m,g=!0,v=!1;function b(){p&&A(n,m),g=!1}return $((t=>{if(!v&&t>=u&&(v=!0),v&&t>=f&&(d(1,0),b()),!g)return!1;if(v){const e=0+1*a((t-u)/c);d(e,1-e)}return!0})),p&&(m=D(n,0,1,c,s,a,p)),s||(v=!0),d(0,1),b}function L(t){const e=getComputedStyle(t);if("absolute"!==e.position&&"fixed"!==e.position){const{width:n,height:o}=e,r=t.getBoundingClientRect();t.style.position="absolute",t.style.width=n,t.style.height=o,J(t,r)}}function J(t,e){const n=t.getBoundingClientRect();if(e.left!==n.left||e.top!==n.top){const o=getComputedStyle(t),r="none"===o.transform?"":o.transform;t.style.transform=`${r} translate(${e.left-n.left}px, ${e.top-n.top}px)`}}function V(t){B=t}function z(){if(!B)throw new Error("Function called outside component initialization");return B}const K=[],H=[],Q=[],W=[],X=Promise.resolve();let Y=!1;function Z(t){Q.push(t)}function tt(t){W.push(t)}const et=new Set;let nt,ot=0;function rt(){const t=B;do{for(;ot{nt=null}))),nt}function st(t,e,n){t.dispatchEvent(R(`${e?"intro":"outro"}${n}`))}const ct=new Set;let at;function ut(){at={r:0,c:[],p:at}}function ft(){at.r||l(at.c),at=at.p}function dt(t,e){t&&t.i&&(ct.delete(t),t.i(e))}function pt(t,e,n,o){if(t&&t.o){if(ct.has(t))return;ct.add(t),at.c.push((()=>{ct.delete(t),o&&(n&&t.d(1),o())})),t.o(e)}else o&&o()}const ht={duration:0};function mt(n,o,r){let l,s,c=o(n,r),a=!1,u=0;function f(){l&&A(n,l)}function d(){const{delay:o=0,duration:r=300,easing:i=e,tick:d=t,css:p}=c||ht;p&&(l=D(n,0,1,r,o,i,p,u++)),d(0,1);const m=h()+o,g=m+r;s&&s.abort(),a=!0,Z((()=>st(n,!0,"start"))),s=$((t=>{if(a){if(t>=g)return d(1,0),st(n,!0,"end"),f(),a=!1;if(t>=m){const e=i((t-m)/r);d(e,1-e)}}return a}))}let p=!1;return{start(){p||(p=!0,A(n),i(c)?(c=c(),it().then(d)):d())},invalidate(){p=!1},end(){a&&(f(),a=!1)}}}function gt(n,o,r){let s,c=o(n,r),a=!0;const u=at;function f(){const{delay:o=0,duration:r=300,easing:i=e,tick:f=t,css:d}=c||ht;d&&(s=D(n,1,0,r,o,i,d));const p=h()+o,m=p+r;Z((()=>st(n,!1,"start"))),$((t=>{if(a){if(t>=m)return f(0,1),st(n,!1,"end"),--u.r||l(u.c),!1;if(t>=p){const e=i((t-p)/r);f(1-e,e)}}return a}))}return u.r+=1,i(c)?it().then((()=>{c=c(),f()})):f(),{end(t){t&&c.tick&&c.tick(1,0),a&&(s&&A(n,s),a=!1)}}}function vt(t,e){t.f(),function(t,e){pt(t,1,1,(()=>{e.delete(t.key)}))}(t,e)}function $t(t,e,n,o,r,l,i,s,c,a,u,f){let d=t.length,p=l.length,h=d;const m={};for(;h--;)m[t[h].key]=h;const g=[],v=new Map,$=new Map;for(h=p;h--;){const t=f(r,l,h),s=n(t);let c=i.get(s);c?o&&c.p(t,e):(c=a(s,t),c.c()),v.set(s,g[h]=c),s in m&&$.set(s,Math.abs(h-m[s]))}const b=new Set,y=new Set;function x(t){dt(t,1),t.m(s,u),i.set(t.key,t),u=t.first,p--}for(;d&&p;){const e=g[p-1],n=t[d-1],o=e.key,r=n.key;e===n?(u=e.first,d--,p--):v.has(r)?!i.has(o)||b.has(o)?x(e):y.has(r)?d--:$.get(o)>$.get(r)?(y.add(o),x(e)):(b.add(r),d--):(c(n,i),d--)}for(;d--;){const e=t[d];v.has(e.key)||c(e,i)}for(;p;)x(g[p-1]);return g}function bt(t,e,n){const o=t.$$.props[e];void 0!==o&&(t.$$.bound[o]=n,n(t.$$.ctx[o]))}function yt(t){t&&t.c()}function xt(t,e,n,r){const{fragment:s,on_mount:c,on_destroy:a,after_update:u}=t.$$;s&&s.m(e,n),r||Z((()=>{const e=c.map(o).filter(i);a?a.push(...e):l(e),t.$$.on_mount=[]})),u.forEach(Z)}function _t(t,e){const n=t.$$;null!==n.fragment&&(l(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function wt(t,e){-1===t.$$.dirty[0]&&(K.push(t),Y||(Y=!0,X.then(rt)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const r=o.length?o[0]:n;return d.ctx&&s(d.ctx[t],d.ctx[t]=r)&&(!d.skip_bound&&d.bound[t]&&d.bound[t](r),p&&wt(e,t)),n})):[],d.update(),p=!0,l(d.before_update),d.fragment=!!i&&i(d.ctx),n.target){if(n.hydrate){const t=function(t){return Array.from(t.childNodes)}(n.target);d.fragment&&d.fragment.l(t),t.forEach(w)}else d.fragment&&d.fragment.c();n.intro&&dt(e.$$.fragment),xt(e,n.target,n.anchor,n.customElement),rt()}V(f)}class St{$destroy(){_t(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function jt(t){const e=t-1;return e*e*e+1}function Ot(t){return--t*t*t*t*t+1} +/*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */function Ct(t){var{fallback:e}=t,o=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r(t.set(c.key,{rect:s.getBoundingClientRect()}),()=>{if(r.has(c.key)){const{rect:t}=r.get(c.key);return r.delete(c.key),function(t,e,r){const{delay:l=0,duration:s=(t=>30*Math.sqrt(t)),easing:c=jt}=n(n({},o),r),a=e.getBoundingClientRect(),u=t.left-a.left,f=t.top-a.top,d=t.width/a.width,p=t.height/a.height,h=Math.sqrt(u*u+f*f),m=getComputedStyle(e),g="none"===m.transform?"":m.transform,v=+m.opacity;return{delay:l,duration:i(s)?s(h):s,easing:c,css:(t,e)=>`\n\t\t\t\topacity: ${t*v};\n\t\t\t\ttransform-origin: top left;\n\t\t\t\ttransform: ${g} translate(${e*u}px,${e*f}px) scale(${t+(1-t)*d}, ${t+(1-t)*p});\n\t\t\t`}}(t,s,c)}return t.delete(c.key),e&&e(s,c,l)})}return[s(l,r,!1),s(r,l,!0)]}function Nt(t,{from:e,to:n},o={}){const r=getComputedStyle(t),l="none"===r.transform?"":r.transform,[s,c]=r.transformOrigin.split(" ").map(parseFloat),a=e.left+e.width*s/n.width-(n.left+s),u=e.top+e.height*c/n.height-(n.top+c),{delay:f=0,duration:d=(t=>120*Math.sqrt(t)),easing:p=jt}=o;return{delay:f,duration:i(d)?d(Math.sqrt(a*a+u*u)):d,easing:p,css:(t,o)=>{const r=o*a,i=o*u,s=t+o*e.width/n.width,c=t+o*e.height/n.height;return`transform: ${l} translate(${r}px, ${i}px) scale(${s}, ${c});`}}}function Pt(e){let n,o,r,l,i,s,c,a,u,f,d;return{c(){n=S("div"),o=S("div"),r=S("div"),l=O(),i=S("div"),s=O(),c=S("div"),a=O(),u=S("div"),f=j(e[0]),d=j("%"),P(r,"class","gauge-fill gauge-bg svelte-1er7lpr"),P(i,"class","gauge-fill svelte-1er7lpr"),I(i,"transform","rotate(-"+e[2]+"deg)"),I(i,"box-shadow","inset 0 0 60px -5px "+e[1]),P(c,"class","gauge-white svelte-1er7lpr"),P(u,"class","gauge-value svelte-1er7lpr"),P(o,"class","gauge-overflow svelte-1er7lpr"),P(n,"class","gauge svelte-1er7lpr")},m(t,e){_(t,n,e),b(n,o),b(o,r),b(o,l),b(o,i),b(o,s),b(o,c),b(o,a),b(o,u),b(u,f),b(u,d)},p(t,[e]){4&e&&I(i,"transform","rotate(-"+t[2]+"deg)"),2&e&&I(i,"box-shadow","inset 0 0 60px -5px "+t[1]),1&e&&q(f,t[0])},i:t,o:t,d(t){t&&w(n)}}}function qt(t,e,n){let o,r,{title:l}=e,{value:i=l}=e,{thresholds:s="90,100"}=e,{colors:c="#7CFC00,#FFD700,#FF0000"}=e;return t.$$set=t=>{"title"in t&&n(3,l=t.title),"value"in t&&n(0,i=t.value),"thresholds"in t&&n(4,s=t.thresholds),"colors"in t&&n(5,c=t.colors)},t.$$.update=()=>{if(49&t.$$.dirty){const t=String(s).split(","),e=t.indexOf(t.find((t=>i({}),Tt=t=>({});function Et(t){let e,n,o,r,i,s,a,p,h,m,g,v,$;const y=t[4].header,x=c(y,t,t[3],Tt),k=t[4].default,j=c(k,t,t[3],null);return{c(){e=S("div"),n=O(),o=S("div"),x&&x.c(),r=O(),i=S("hr"),s=O(),j&&j.c(),a=O(),p=S("hr"),h=O(),m=S("button"),m.textContent="Close",P(e,"class","modal-background svelte-5a6h72"),I(m,"float","right"),I(m,"margin-right","2%"),I(m,"border","1px solid lightblue"),I(m,"border-radius","8px"),m.autofocus=!0,P(m,"class","svelte-5a6h72"),P(o,"class","modal svelte-5a6h72"),P(o,"role","dialog"),P(o,"aria-modal","true")},m(l,c){_(l,e,c),_(l,n,c),_(l,o,c),x&&x.m(o,null),b(o,r),b(o,i),b(o,s),j&&j.m(o,null),b(o,a),b(o,p),b(o,h),b(o,m),t[5](o),g=!0,m.focus(),v||($=[N(window,"keydown",t[2]),N(e,"click",t[1]),N(m,"click",t[1])],v=!0)},p(t,[e]){x&&x.p&&(!g||8&e)&&f(x,y,t,t[3],g?u(y,t[3],e,It):d(t[3]),Tt),j&&j.p&&(!g||8&e)&&f(j,k,t,t[3],g?u(k,t[3],e,null):d(t[3]),null)},i(t){g||(dt(x,t),dt(j,t),g=!0)},o(t){pt(x,t),pt(j,t),g=!1},d(r){r&&w(e),r&&w(n),r&&w(o),x&&x.d(r),j&&j.d(r),t[5](null),v=!1,l($)}}}function Rt(t,e,n){let{$$slots:o={},$$scope:r}=e;const l=function(){const t=z();return(e,n,{cancelable:o=!1}={})=>{const r=t.$$.callbacks[e];if(r){const l=R(e,n,{cancelable:o});return r.slice().forEach((e=>{e.call(t,l)})),!l.defaultPrevented}return!0}}(),i=()=>l("close");let s;const c="undefined"!=typeof document&&document.activeElement;var a;return c&&(a=()=>{c.focus()},z().$$.on_destroy.push(a)),t.$$set=t=>{"$$scope"in t&&n(3,r=t.$$scope)},[s,i,t=>{if("Escape"!==t.key){if("Tab"===t.key){const e=s.querySelectorAll("*"),n=Array.from(e).filter((t=>t.tabIndex>=0));let o=n.indexOf(document.activeElement);-1===o&&t.shiftKey&&(o=0),o+=n.length+(t.shiftKey?-1:1),o%=n.length,n[o].focus(),t.preventDefault()}}else i()},r,o,function(t){H[t?"unshift":"push"]((()=>{s=t,n(0,s)}))}]}class Gt extends St{constructor(t){super(),kt(this,t,Rt,Et,s,{})}}function Bt(t){let e,n;const o=t[1].default,r=c(o,t,t[0],null);return{c(){e=S("div"),r&&r.c(),P(e,"class","box svelte-1q88uwi")},m(t,o){_(t,e,o),r&&r.m(e,null),n=!0},p(t,[e]){r&&r.p&&(!n||1&e)&&f(r,o,t,t[0],n?u(o,t[0],e,null):d(t[0]),null)},i(t){n||(dt(r,t),n=!0)},o(t){pt(r,t),n=!1},d(t){t&&w(e),r&&r.d(t)}}}function Ut(t,e,n){let{$$slots:o={},$$scope:r}=e;return t.$$set=t=>{"$$scope"in t&&n(0,r=t.$$scope)},[r,o]}class Dt extends St{constructor(t){super(),kt(this,t,Ut,Bt,s,{})}}function At(t,e,n){const o=t.slice();return o[62]=e[n],o}function Ft(t,e,n){const o=t.slice();return o[65]=e[n],o}function Lt(t,e,n){const o=t.slice();return o[68]=e[n][0],o[69]=e[n][1],o}function Jt(t,e,n){const o=t.slice();return o[68]=e[n][0],o[69]=e[n][1],o}function Vt(t,e,n){const o=t.slice();return o[74]=e[n],o[75]=e,o[76]=n,o}function zt(t,e,n){const o=t.slice();return o[68]=e[n][0],o[69]=e[n][1],o}function Kt(t,e,n){const o=t.slice();return o[74]=e[n],o[79]=e,o[80]=n,o}function Ht(t,e,n){const o=t.slice();return o[81]=e[n],o}function Qt(t){let e,n,o,r;function l(e){t[19](e)}let i={};return void 0!==t[1]&&(i.value=t[1]),e=new Mt({props:i}),H.push((()=>bt(e,"value",l))),{c(){yt(e.$$.fragment),o=j("                   ")},m(t,n){xt(e,t,n),_(t,o,n),r=!0},p(t,o){const r={};!n&&2&o[0]&&(n=!0,r.value=t[1],tt((()=>n=!1))),e.$set(r)},i(t){r||(dt(e.$$.fragment,t),r=!0)},o(t){pt(e.$$.fragment,t),r=!1},d(t){_t(e,t),t&&w(o)}}}function Wt(t){let e,n,o,r;function l(e){t[20](e)}let i={};return void 0!==t[1]&&(i.value=t[1]),e=new Mt({props:i}),H.push((()=>bt(e,"value",l))),{c(){yt(e.$$.fragment),o=j("                   ")},m(t,n){xt(e,t,n),_(t,o,n),r=!0},p(t,o){const r={};!n&&2&o[0]&&(n=!0,r.value=t[1],tt((()=>n=!1))),e.$set(r)},i(t){r||(dt(e.$$.fragment,t),r=!0)},o(t){pt(e.$$.fragment,t),r=!1},d(t){_t(e,t),t&&w(o)}}}function Xt(t){let e,n,o,r;function l(e){t[21](e)}let i={};return void 0!==t[1]&&(i.value=t[1]),e=new Mt({props:i}),H.push((()=>bt(e,"value",l))),{c(){yt(e.$$.fragment),o=j("                   ")},m(t,n){xt(e,t,n),_(t,o,n),r=!0},p(t,o){const r={};!n&&2&o[0]&&(n=!0,r.value=t[1],tt((()=>n=!1))),e.$set(r)},i(t){r||(dt(e.$$.fragment,t),r=!0)},o(t){pt(e.$$.fragment,t),r=!1},d(t){_t(e,t),t&&w(o)}}}function Yt(t){let e,n,o,r;function l(e){t[22](e)}let i={};return void 0!==t[1]&&(i.value=t[1]),e=new Mt({props:i}),H.push((()=>bt(e,"value",l))),{c(){yt(e.$$.fragment),o=j("                   ")},m(t,n){xt(e,t,n),_(t,o,n),r=!0},p(t,o){const r={};!n&&2&o[0]&&(n=!0,r.value=t[1],tt((()=>n=!1))),e.$set(r)},i(t){r||(dt(e.$$.fragment,t),r=!0)},o(t){pt(e.$$.fragment,t),r=!1},d(t){_t(e,t),t&&w(o)}}}function Zt(e){let n,o,r,l=e[81].text+"";return{c(){n=S("option"),o=j(l),r=O(),n.__value=e[81],n.value=n.__value},m(t,e){_(t,n,e),b(n,o),b(n,r)},p:t,d(t){t&&w(n)}}}function te(e){let n,o,r,l=e[81].text+"";return{c(){n=S("option"),o=j(l),r=O(),n.__value=e[81],n.value=n.__value},m(t,e){_(t,n,e),b(n,o),b(n,r)},p:t,d(t){t&&w(n)}}}function ee(e){let n,o,r,l=e[81].text+"";return{c(){n=S("option"),o=j(l),r=O(),n.__value=e[81],n.value=n.__value},m(t,e){_(t,n,e),b(n,o),b(n,r)},p:t,d(t){t&&w(n)}}}function ne(t){let e;let n=function(t,e){return"esp8266_1mb"==t[81].text?ee:"esp8266_1mb_ota"==t[81].text?te:Zt}(t),o=n(t);return{c(){o.c(),e=C()},m(t,n){o.m(t,n),_(t,e,n)},p(t,e){o.p(t,e)},d(t){o.d(t),t&&w(e)}}}function oe(t){let e,n,o,r,i,s,c,a,u,f,d,p,h,m,g,v,$,y,x,k,C,q,T,E,R,G,B,U,D,A,F,L,J,V,z,K,H,Q;return{c(){e=S("p"),n=j("wifi сеть      "),o=S("input"),r=S("br"),i=O(),s=S("p"),c=j("пароль       "),a=S("input"),u=S("br"),f=O(),d=S("p"),p=j("MQTT сервер      "),h=S("input"),m=S("br"),g=O(),v=S("p"),$=j("порт       "),y=S("input"),x=S("br"),k=O(),C=S("p"),q=j("префикс      "),T=S("input"),E=S("br"),R=O(),G=S("p"),B=j("логин       "),U=S("input"),D=S("br"),A=O(),F=S("p"),L=j("пароль       "),J=S("input"),V=S("br"),z=O(),K=S("br"),I(o,"float","right"),P(o,"class","svelte-185rejv"),I(e,"color","#ccc"),I(a,"float","right"),P(a,"class","svelte-185rejv"),I(s,"color","#ccc"),I(h,"float","right"),P(h,"class","svelte-185rejv"),I(d,"color","#ccc"),I(y,"float","right"),P(y,"class","svelte-185rejv"),I(v,"color","#ccc"),I(T,"float","right"),P(T,"class","svelte-185rejv"),I(C,"color","#ccc"),I(U,"float","right"),P(U,"class","svelte-185rejv"),I(G,"color","#ccc"),I(J,"float","right"),P(J,"class","svelte-185rejv"),I(F,"color","#ccc")},m(l,w){_(l,e,w),b(e,n),b(e,o),M(o,t[0].iotmSettings.routerssid),b(e,r),_(l,i,w),_(l,s,w),b(s,c),b(s,a),M(a,t[0].iotmSettings.routerpass),b(s,u),_(l,f,w),_(l,d,w),b(d,p),b(d,h),M(h,t[0].iotmSettings.mqttServer),b(d,m),_(l,g,w),_(l,v,w),b(v,$),b(v,y),M(y,t[0].iotmSettings.mqttPort),b(v,x),_(l,k,w),_(l,C,w),b(C,q),b(C,T),M(T,t[0].iotmSettings.mqttPrefix),b(C,E),_(l,R,w),_(l,G,w),b(G,B),b(G,U),M(U,t[0].iotmSettings.mqttUser),b(G,D),_(l,A,w),_(l,F,w),b(F,L),b(F,J),M(J,t[0].iotmSettings.mqttPass),b(F,V),_(l,z,w),_(l,K,w),H||(Q=[N(o,"input",t[29]),N(a,"input",t[30]),N(h,"input",t[31]),N(y,"input",t[32]),N(T,"input",t[33]),N(U,"input",t[34]),N(J,"input",t[35])],H=!0)},p(t,e){1&e[0]&&o.value!==t[0].iotmSettings.routerssid&&M(o,t[0].iotmSettings.routerssid),1&e[0]&&a.value!==t[0].iotmSettings.routerpass&&M(a,t[0].iotmSettings.routerpass),1&e[0]&&h.value!==t[0].iotmSettings.mqttServer&&M(h,t[0].iotmSettings.mqttServer),1&e[0]&&y.value!==t[0].iotmSettings.mqttPort&&M(y,t[0].iotmSettings.mqttPort),1&e[0]&&T.value!==t[0].iotmSettings.mqttPrefix&&M(T,t[0].iotmSettings.mqttPrefix),1&e[0]&&U.value!==t[0].iotmSettings.mqttUser&&M(U,t[0].iotmSettings.mqttUser),1&e[0]&&J.value!==t[0].iotmSettings.mqttPass&&M(J,t[0].iotmSettings.mqttPass)},d(t){t&&w(e),t&&w(i),t&&w(s),t&&w(f),t&&w(d),t&&w(g),t&&w(v),t&&w(k),t&&w(C),t&&w(R),t&&w(G),t&&w(A),t&&w(F),t&&w(z),t&&w(K),H=!1,l(Q)}}}function re(t){let e,n,o,r,i,s,c,a,u,f,d,p,h,m,g,v,$,y,x,C,q,E,R,G,B,U,D,A,F,L="esp8266_4mb"==t[9].text&&Qt(t),J="esp32_4mb"==t[9].text&&Wt(t),V="esp8266_1mb"==t[9].text&&Xt(t),z="esp8266_1mb_ota"==t[9].text&&Yt(t),K=t[16],H=[];for(let e=0;et[23].call(s))),P(f,"align","right"),void 0===t[9]&&Z((()=>t[25].call(f))),P(e,"align","right"),I(m,"display",t[8]?"none":"inline"),I($,"display",t[8]?"inline":"none"),E.hidden=!0,P(E,"type","text"),P(E,"name","configpost"),P(E,"class","svelte-185rejv"),P(G,"align","center"),P(q,"action","index.php"),P(q,"method","post"),P(q,"name","fwbuilder"),P(U,"type","submit"),I(U,"border","1px solid lightblue"),I(U,"border-radius","8px"),P(U,"name","send"),U.value="Сохранить myProfile.json",P(U,"class","svelte-185rejv")},m(l,w){_(l,e,w),L&&L.m(e,null),b(e,n),J&&J.m(e,null),b(e,o),V&&V.m(e,null),b(e,r),z&&z.m(e,null),b(e,i),b(e,s),b(s,c),b(s,a),T(s,t[7]),b(e,u),b(e,f);for(let t=0;t{L=null})),ft()),"esp32_4mb"==t[9].text?J?(J.p(t,l),512&l[0]&&dt(J,1)):(J=Wt(t),J.c(),dt(J,1),J.m(e,o)):J&&(ut(),pt(J,1,1,(()=>{J=null})),ft()),"esp8266_1mb"==t[9].text?V?(V.p(t,l),512&l[0]&&dt(V,1)):(V=Xt(t),V.c(),dt(V,1),V.m(e,r)):V&&(ut(),pt(V,1,1,(()=>{V=null})),ft()),"esp8266_1mb_ota"==t[9].text?z?(z.p(t,l),512&l[0]&&dt(z,1)):(z=Yt(t),z.c(),dt(z,1),z.m(e,i)):z&&(ut(),pt(z,1,1,(()=>{z=null})),ft()),128&l[0]&&T(s,t[7]),65536&l[0]){let e;for(K=t[16],e=0;e{d&&d.end(1),f=mt(o,n[11],{key:n[74].path}),f.start()})),h=!0)},o(t){f&&f.invalidate(),d=gt(o,n[10],{key:n[74].path}),h=!1},d(t){t&&w(o),t&&d&&d.end(),m=!1,l(g)}}}function ie(t){let e,n,o,r,l,i,s=t[68]+"",c=[],a=new Map,u=t[0].modules[t[68]].filter($e);const f=t=>t[74].path;for(let e=0;e{d&&d.end(1),f=mt(o,n[11],{key:n[74].path}),f.start()})),h=!0)},o(t){f&&f.invalidate(),d=gt(o,n[10],{key:n[74].path}),h=!1},d(t){t&&w(o),t&&d&&d.end(),m=!1,l(g)}}}function ce(t){let e,n,o,r,l,i,s=t[68]+"",c=[],a=new Map,u=t[0].modules[t[68]].filter(be);const f=t=>t[74].path;for(let e=0;e2,d=f&&de(),p=t[62].params,h=[];for(let e=0;e2),f?d||(d=de(),d.c(),d.m(e,s)):d&&(d.d(1),d=null),16&n[0]){let o;for(p=t[62].params,o=0;opt(g[t],1,1,(()=>{g[t]=null}));let $=Object.entries(t[0].modules),y=[];for(let e=0;e<$.length;e+=1)y[e]=ce(Jt(t,$,e));const x=t=>pt(y[t],1,1,(()=>{y[t]=null}));let j=t[6]&&ae(t);return{c(){e=S("p"),yt(n.$$.fragment),o=O(),r=S("div"),l=S("div"),i=S("h2"),i.textContent="доступные модули",s=O();for(let t=0;t{j=null})),ft())},i(t){if(!h){dt(n.$$.fragment,t);for(let t=0;t!t.active,be=t=>t.active;function ye(t,e,n){let o="https://raw.githubusercontent.com/IoTManagerProject/IoTManager/ver4dev/myProfile.json?1",r={},l=0,i={},s=[],c=[],a=[],u=[],f=!1,d="dev",p={};async function h(t){try{let e=await fetch(t,{mode:"cors",method:"GET"});e.ok?n(0,r=await e.json()):console.log("error",e.statusText)}catch(t){console.log(t)}}r={iotmSettings:{},projectProp:{platformio:{}},modules:{"Виртуальные элементы":[],"Сенсоры":[],"Исполнительные устройства":[],"Экраны":[]}},h(o),async function(t){try{let e=await fetch(t,{mode:"cors",method:"GET"});e.ok?p=await e.json():console.log("error",e.statusText)}catch(t){console.log(t)}}("https://iotmanager.org/firmwarebuilder/moduleSize.json?1");const[m,g]=Ct({fallback(t,e){const n=getComputedStyle(t),o="none"===n.transform?"":n.transform;return{duration:600,easing:Ot,css:t=>`\n\t\t\t\t\ttransform: ${o} scale(${t});\n\t\t\t\t\topacity: ${t}\n\t\t\t\t`}}});function v(t){console.log(t.path),o="https://raw.githubusercontent.com/IoTManagerProject/IoTManager/ver4stable/"+JSON.parse(JSON.stringify(t.path).replace(/\\\\/g,"/"))+"/modinfo.json",i=[],n(2,s=[]),n(3,c=[]),n(3,c.name="Данные загружаются...",c),n(4,a=[]),n(5,u=[]),async function(t){i=[];try{let e=await fetch(t,{mode:"cors",method:"GET"});e.ok?(i=await e.json(),n(2,s=i),n(3,c=i.configItem[0]),n(4,a=i.about),n(5,u=a.propInfo)):console.log("error",e.statusText)}catch(t){console.log(t)}}(o),n(6,f=!0)}let $=!0;function b(t){n(8,$=t)}function y(){o="dev"==d?"https://raw.githubusercontent.com/IoTManagerProject/IoTManager/ver4dev/myProfile.json?1":"https://raw.githubusercontent.com/IoTManagerProject/IoTManager/ver4stable/myProfile.json?1",h(o)}function x(){n(1,l=0),n(0,r.projectProp.platformio.default_envs=_.text,r),k()}let _=[],w=[{id:1,text:"esp8266_4mb"},{id:2,text:"esp32_4mb"},{id:3,text:"esp8266_1mb"},{id:4,text:"esp8266_1mb_ota"}];function k(){n(1,l=0);for(const[t,e]of Object.entries(r.modules))for(const[e,o]of Object.entries(r.modules[t].filter((t=>t.active)))){let t=o.path.slice(o.path.lastIndexOf("/")+1,o.path.length);p[t]&&n(1,l+=Math.round(p[t][_.text]))}"esp8266_4mb"==_.text&&n(1,l=Math.round(l/6110)),"esp32_4mb"==_.text&&n(1,l=Math.round(l/3243)),"esp8266_1mb"==_.text&&n(1,l=Math.round(l/3237)),"esp8266_1mb_ota"==_.text&&n(1,l=Math.round(l/2601))}function S(){var t=document.createElement("a");t.href=window.URL.createObjectURL(new Blob([JSON.stringify(r)],{type:"text/plain"})),t.download="myProfile.json",console.log(JSON.stringify(r))}return[r,l,s,c,a,u,f,d,$,_,m,g,v,b,y,x,w,k,S,function(t){l=t,n(1,l)},function(t){l=t,n(1,l)},function(t){l=t,n(1,l)},function(t){l=t,n(1,l)},function(){d=E(this),n(7,d)},()=>y(),function(){_=E(this),n(9,_),n(16,w)},()=>x(),()=>b(!0),()=>b(!1),function(){r.iotmSettings.routerssid=this.value,n(0,r)},function(){r.iotmSettings.routerpass=this.value,n(0,r)},function(){r.iotmSettings.mqttServer=this.value,n(0,r)},function(){r.iotmSettings.mqttPort=this.value,n(0,r)},function(){r.iotmSettings.mqttPrefix=this.value,n(0,r)},function(){r.iotmSettings.mqttUser=this.value,n(0,r)},function(){r.iotmSettings.mqttPass=this.value,n(0,r)},function(){r=this.value,n(0,r)},()=>S(),function(t,e){t[e].active=this.checked,n(0,r)},t=>v(t),function(t,e){t[e].active=this.checked,n(0,r)},t=>v(t),()=>n(6,f=!1)]}return new class extends St{constructor(t){super(),kt(this,t,ye,ve,s,{},null,[-1,-1,-1])}}({target:document.body})}(); +//# sourceMappingURL=bundle.js.map diff --git a/webConfigMyProfile/favicon.ico b/webConfigMyProfile/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..50d908fa6d3f6f710e4d3d0f9fb3e96f3466895c GIT binary patch literal 1150 zcmbW1Yfy|)7{^~TzWHLtjL$y0jv2QSq6~#f#7e|agTf3mXcR503wx_}tj&marGz54 zp)gY^BiC^Wt!lJL)4EK`ZoB)w`*UPujO#dO{?9q*dFKC|=ltiKBS`~9A3RtRc9^to zpd<~IBx$&Sa0$;>zZfJ*#D)y|ioUfl{G$21UOX;0e!u@0(cimd!FyIyLs@Dnw)M$W zWSOWx{+QQIZWQ^?xfEHZ;dm*z5s_q04`x?j0BPgKvU5^6+K2)!nO@P=>HF>Gt+(%B zS`fpYX+i7`3KW=(I$$E|zzOUL4n`BQ7we`LoQ~d~a(G-W%F@!wnmwMJj9}N) z(SkpLjNoZxhlZdHn?vR-3q@NUq7Ls5IUEljVVoa^IcW?9DWf>FbtKkpQ^;STLNg@@ zZFo3Fajx9xc(UhS;fmRb?ES7seNizvag(v72T+(cp2OQlaqFUi_wDUilh=s-LoqE} zj9Ik=!+Zml_!l@HxcX|4eLl`;)Er5f$w}QDO0q&J%?!o)@=0IZ+15t>s+HtKMq!DK zMIV)mdC3cISU=!b{PgyG;zY^@%8V+`<;QW#FpsO&^~gR?{~4b*+(aL-2wh}0`sjO< ztn1*K{++lZ3hwS6$}_fbsW6GEV;eY=7e&K)v(QN9O|zTEnl36W?HFQikQZa8B&man z%}%Ow-{W;F_&h$Ui%nFQr&3$7gR}b=b70L;a#XGCjkJ>)*2KPf%^XnsnFYwabXMQrEL_f5PBv&r}|(Ez1?y@ zzo)B%`?VIq-^ay6%P_`gurtI?x`1YOGuo(T@>KW9PdLG4i;a)(I{Ud_CVszy!(L1M zc@33E*HWaOOWx}3=;L%4mTNGt-AKvqMDA7<;Och%!2PyR6d#?h8hKb}<@)LERM}Qh nS(rdwxtgZir|Ejz_D}E8uPAsuE6M9Ip6+){~bRA#ZfP9 literal 0 HcmV?d00001 diff --git a/webConfigMyProfile/global.css b/webConfigMyProfile/global.css new file mode 100644 index 00000000..bb28a941 --- /dev/null +++ b/webConfigMyProfile/global.css @@ -0,0 +1,63 @@ +html, body { + position: relative; + width: 100%; + height: 100%; +} + +body { + color: #333; + margin: 0; + padding: 8px; + box-sizing: border-box; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; +} + +a { + color: rgb(0,100,200); + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +a:visited { + color: rgb(0,80,160); +} + +label { + display: block; +} + +input, button, select, textarea { + font-family: inherit; + font-size: inherit; + -webkit-padding: 0.4em 0; + padding: 0.4em; + margin: 0 0 0.5em 0; + box-sizing: border-box; + border: 1px solid #ccc; + border-radius: 2px; +} + +input:disabled { + color: #ccc; +} + +button { + color: #333; + background-color: #f4f4f4; + outline: none; +} + +button:disabled { + color: #999; +} + +button:not(:disabled):active { + background-color: #ddd; +} + +button:focus { + border-color: #666; +} diff --git a/webConfigMyProfile/index.html b/webConfigMyProfile/index.html new file mode 100644 index 00000000..6ec2b8da --- /dev/null +++ b/webConfigMyProfile/index.html @@ -0,0 +1,18 @@ + + + + + + + + Конфигуратор прошивки + + + + + + + + + +