diff --git a/server/SHServ/config.php b/server/SHServ/config.php
index 71bf239..08e78b2 100644
--- a/server/SHServ/config.php
+++ b/server/SHServ/config.php
@@ -2,16 +2,16 @@
return [
"app_name" => "SHServ",
- "version" => "0.2 dev",
+ "version" => "0.3 dev",
"debug" => true,
"default_db_wrap" => false,
"db" => [
"dblib" => "mysql",
"host" => "localhost",
- "dbname" => "shome",
+ "dbname" => "eugene",
"charset" => "utf8",
- "user" => "u_shome",
- "password" => "halloween"
+ "user" => "smart-home-server",
+ "password" => "root"
],
"app_file" => "App.php",
"templates_folder" => "Templates",
diff --git a/webclient/dist/js/main.js b/webclient/dist/js/main.js
index ae9a7e3..ef99890 100644
--- a/webclient/dist/js/main.js
+++ b/webclient/dist/js/main.js
@@ -1,4 +1,4 @@
-(()=>{var Oe=Object.defineProperty,Ce=Object.defineProperties;var ke=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable;var te=(a,e,t)=>e in a?Oe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,v=(a,e)=>{for(var t in e||(e={}))Ie.call(e,t)&&te(a,t,e[t]);if(ee)for(var t of ee(e))Re.call(e,t)&&te(a,t,e[t]);return a},ae=(a,e)=>Ce(a,ke(e));var ne=(a,e,t)=>new Promise((n,s)=>{var r=o=>{try{i(t.next(o))}catch(l){s(l)}},c=o=>{try{i(t.throw(o))}catch(l){s(l)}},i=o=>o.done?n(o.value):Promise.resolve(o.value).then(r,c);i((t=t.apply(a,e)).next())});var h,$,A;function Ne(){h.dataset.navState="displayed",h.classList.remove("state-off"),h.classList.add("state-on"),$.classList.add("a-show")}function x(){h.dataset.navState="hidden",h.classList.remove("state-on"),h.classList.add("state-off"),$.classList.add("a-hide"),$.classList.remove("a-show"),setTimeout(()=>{$.classList.remove("a-hide")},300)}function se(){console.log("HUD init"),h=document.querySelector(".hud .nav-toggle"),$=document.querySelector(".hud .navigation"),A=document.querySelector(".hud .reload-screen"),h==null||h.addEventListener("click",a=>{a.currentTarget.dataset.navState!="displayed"?Ne():x()}),A==null||A.addEventListener("click",a=>{Screens.reload()})}var D=class{constructor(e,t,n){this.screens={},this.routesMap={},this.currentScreen=null,this.eventsHandlers={switch:[],reload:[],reinit:[],errorScreen:[]},this.screensContainer=document.querySelector(e),this.loader=document.querySelector(t),this.errorScreen=document.querySelector(n),console.log("Screens Init")}add(e,t){if(typeof t!="object")return console.error("Screens: screens must be object");if(typeof(t==null?void 0:t.alias)=="undefined")return console.error("Screens: undefined alias");if(typeof(t==null?void 0:t.renderer)!="function")return console.error("Screens: renderer must be function");this.screens[t.alias]=v({route:e},t),this.routesMap[e]=t.alias}switch(e){var n;if(this.runSwitchHandlers(e),this.hideErrorScreen(),this.showLoader(),(n=this.currentScreen)==null||n.DOMObject.remove(),typeof this.screens[e]=="undefined"){console.error(`Screens: "${e}" not found`);return}this.currentScreen=this.screens[e];let t=document.createElement("div");t.classList.add("screen"),t.id=e,t.dataset.alias=e,t.innerHTML=this.currentScreen.renderer(),this.currentScreen.DOMObject=t,this.screensContainer.append(this.currentScreen.DOMObject),this.currentScreen.initer(this)}reload(){this.currentScreen&&(this.runReloadHandlers(this.currentScreen.alias),this.switch(this.currentScreen.alias))}reinit(){this.currentScreen&&(this.currentScreen.initer(this),this.runReinitHandlers())}routing(){setInterval(()=>{let e=document.location.hash.split("#!")[1];if(typeof e=="undefined"||e=="")return;let t=typeof this.routesMap[e]=="undefined"?"not-found-screen":this.routesMap[e];(!this.currentScreen||this.currentScreen.alias!=t)&&this.switch(t)},50)}ready(){this.currentScreen!=null&&(this.currentScreen.DOMObject||(this.currentScreen.DOMObject=document.getElementsById(this.currentScreen.alias)),this.hideLoader(),this.currentScreen.DOMObject.classList.add("a-show"))}error(e,t){var n;(n=this.currentScreen)==null||n.DOMObject.remove(),this.errorScreen.querySelector(".error-title").innerHTML=e,this.errorScreen.querySelector(".error-text").innerHTML=t,this.showErrorScreen(),this.runErrorScreenHandlers()}hideLoader(){this.loader.classList.remove("a-show")}showLoader(){this.loader.classList.add("a-show")}showErrorScreen(){this.errorScreen.classList.add("a-show")}hideErrorScreen(){this.errorScreen.classList.remove("a-show")}getScreens(){return this.screens}getRoutesMap(){return this.routesMap}onSwitch(e){this.eventsHandlers.switch.push(e)}onReaload(e){this.eventsHandlers.reload.push(e)}onReinit(e){this.eventsHandlers.reinit.push(e)}onErrorScreen(e){this.eventsHandlers.errorScreen.push(e)}runSwitchHandlers(e){let t=Object.keys(this.routesMap).filter(n=>this.routesMap[n]==e);for(let n of this.eventsHandlers.switch)n(this,e,t.length?t[0]:void 0)}runReloadHandlers(e){for(let t of this.eventsHandlers.reload)t(this,e)}runReinitHandlers(){for(let e of this.eventsHandlers.reinit)e(this)}runErrorScreenHandlers(){for(let e of this.eventsHandlers.errorScreen)e(this)}};function xe(a,e,t,n){return`
+(()=>{var Oe=Object.defineProperty,Ce=Object.defineProperties;var ke=Object.getOwnPropertyDescriptors;var te=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable;var ae=(a,e,t)=>e in a?Oe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,b=(a,e)=>{for(var t in e||(e={}))Ie.call(e,t)&&ae(a,t,e[t]);if(te)for(var t of te(e))Ne.call(e,t)&&ae(a,t,e[t]);return a},ne=(a,e)=>Ce(a,ke(e));var se=(a,e,t)=>new Promise((n,s)=>{var i=o=>{try{r(t.next(o))}catch(l){s(l)}},c=o=>{try{r(t.throw(o))}catch(l){s(l)}},r=o=>o.done?n(o.value):Promise.resolve(o.value).then(i,c);r((t=t.apply(a,e)).next())});var h,T,D;function Re(){h.dataset.navState="displayed",h.classList.remove("state-off"),h.classList.add("state-on"),T.classList.add("a-show")}function F(){h.dataset.navState="hidden",h.classList.remove("state-on"),h.classList.add("state-off"),T.classList.add("a-hide"),T.classList.remove("a-show"),setTimeout(()=>{T.classList.remove("a-hide")},300)}function ie(){console.log("HUD init"),h=document.querySelector(".hud .nav-toggle"),T=document.querySelector(".hud .navigation"),D=document.querySelector(".hud .reload-screen"),h==null||h.addEventListener("click",a=>{a.currentTarget.dataset.navState!="displayed"?Re():F()}),D==null||D.addEventListener("click",a=>{Screens.reload()})}var M=class{constructor(e,t,n){this.screens={},this.routesMap={},this.currentScreen=null,this.eventsHandlers={switch:[],reload:[],reinit:[],errorScreen:[]},this.screensContainer=document.querySelector(e),this.loader=document.querySelector(t),this.errorScreen=document.querySelector(n),console.log("Screens Init")}add(e,t){if(typeof t!="object")return console.error("Screens: screens must be object");if(typeof(t==null?void 0:t.alias)=="undefined")return console.error("Screens: undefined alias");if(typeof(t==null?void 0:t.renderer)!="function")return console.error("Screens: renderer must be function");this.screens[t.alias]=b({route:e},t),this.routesMap[e]=t.alias}switch(e){var n;if(this.runSwitchHandlers(e),this.hideErrorScreen(),this.showLoader(),(n=this.currentScreen)==null||n.DOMObject.remove(),typeof this.screens[e]=="undefined"){console.error(`Screens: "${e}" not found`);return}this.currentScreen=this.screens[e];let t=document.createElement("div");t.classList.add("screen"),t.id=e,t.dataset.alias=e,t.innerHTML=this.currentScreen.renderer(),this.currentScreen.DOMObject=t,this.screensContainer.append(this.currentScreen.DOMObject),this.currentScreen.initer(this)}reload(){this.currentScreen&&(this.runReloadHandlers(this.currentScreen.alias),this.switch(this.currentScreen.alias))}reinit(){this.currentScreen&&(this.currentScreen.initer(this),this.runReinitHandlers())}routing(){setInterval(()=>{let e=document.location.hash.split("#!")[1];if(typeof e=="undefined"||e=="")return;let t=typeof this.routesMap[e]=="undefined"?"not-found-screen":this.routesMap[e];(!this.currentScreen||this.currentScreen.alias!=t)&&this.switch(t)},50)}ready(){this.currentScreen!=null&&(this.currentScreen.DOMObject||(this.currentScreen.DOMObject=document.getElementsById(this.currentScreen.alias)),this.hideLoader(),this.currentScreen.DOMObject.classList.add("a-show"))}error(e,t){var n;(n=this.currentScreen)==null||n.DOMObject.remove(),this.errorScreen.querySelector(".error-title").innerHTML=e,this.errorScreen.querySelector(".error-text").innerHTML=t,this.showErrorScreen(),this.runErrorScreenHandlers()}hideLoader(){this.loader.classList.remove("a-show")}showLoader(){this.loader.classList.add("a-show")}showErrorScreen(){this.errorScreen.classList.add("a-show")}hideErrorScreen(){this.errorScreen.classList.remove("a-show")}getScreens(){return this.screens}getRoutesMap(){return this.routesMap}onSwitch(e){this.eventsHandlers.switch.push(e)}onReaload(e){this.eventsHandlers.reload.push(e)}onReinit(e){this.eventsHandlers.reinit.push(e)}onErrorScreen(e){this.eventsHandlers.errorScreen.push(e)}runSwitchHandlers(e){let t=Object.keys(this.routesMap).filter(n=>this.routesMap[n]==e);for(let n of this.eventsHandlers.switch)n(this,e,t.length?t[0]:void 0)}runReloadHandlers(e){for(let t of this.eventsHandlers.reload)t(this,e)}runReinitHandlers(){for(let e of this.eventsHandlers.reinit)e(this)}runErrorScreenHandlers(){for(let e of this.eventsHandlers.errorScreen)e(this)}};function xe(a,e,t,n){return`
${e} ${t}
@@ -6,7 +6,7 @@
- `}function je(a,e){if(e!=null&&e.alone&&document.querySelectorAll(".toast").forEach(t=>t.close()),a.close=function(){this.classList.add("a-hide"),setTimeout(()=>{this.remove()},300)},a.querySelector(".toast-close").addEventListener("click",t=>{a.close()}),a.show=function(){document.querySelector("body").append(a),setTimeout(()=>{a.classList.add("a-show")},10)},typeof Screens!="undefined"&&Screens.onSwitch((t,n)=>{setTimeout(()=>{a==null||a.close()},1e4)}),a.addEventListener("mouseover",t=>a.ishovered=!0),a.addEventListener("mouseout",t=>a.ishovered=!1),e!=null&&e.lifetime){console.log(e);let t=setInterval(()=>{a.ishovered||(a.close(),clearInterval(t))},e==null?void 0:e.lifetime)}return a}function T(a,e,t,n,s){let r=document.createElement("div");return r.innerHTML=xe(a,e,t,n),je(r.childNodes[1],s)}function Fe(a,e,t){return typeof t=="undefined"&&(t={}),typeof t.lifetime=="undefined"&&(t.lifetime=4e3),typeof t.alone=="undefined"&&(t.alone=!0),T("success",'',a,e,t)}function Pe(a,e,t){return T("info",'',a,e,t)}function Ue(a,e,t){return T("warning",'',a,e,t)}function re(a,e,t){return T("danger",'',a,e,t)}var ie={create:T,createInfo:Pe,createSuccess:Fe,createWarning:Ue,createError:re,createDanger:re};function Be(a){let e="";for(let t of a){let n="",s="";t.route&&(n=``,s=""),e+=`
+ `}function je(a,e){if(e!=null&&e.alone&&document.querySelectorAll(".toast").forEach(t=>t.close()),a.close=function(){this.classList.add("a-hide"),setTimeout(()=>{this.remove()},300)},a.querySelector(".toast-close").addEventListener("click",t=>{a.close()}),a.show=function(){document.querySelector("body").append(a),setTimeout(()=>{a.classList.add("a-show")},10)},typeof Screens!="undefined"&&Screens.onSwitch((t,n)=>{setTimeout(()=>{a==null||a.close()},1e4)}),a.addEventListener("mouseover",t=>a.ishovered=!0),a.addEventListener("mouseout",t=>a.ishovered=!1),e!=null&&e.lifetime){console.log(e);let t=setInterval(()=>{a.ishovered||(a.close(),clearInterval(t))},e==null?void 0:e.lifetime)}return a}function H(a,e,t,n,s){let i=document.createElement("div");return i.innerHTML=xe(a,e,t,n),je(i.childNodes[1],s)}function Fe(a,e,t){return typeof t=="undefined"&&(t={}),typeof t.lifetime=="undefined"&&(t.lifetime=4e3),typeof t.alone=="undefined"&&(t.alone=!0),H("success",'',a,e,t)}function Pe(a,e,t){return H("info",'',a,e,t)}function Ue(a,e,t){return H("warning",'',a,e,t)}function re(a,e,t){return H("danger",'',a,e,t)}var oe={create:H,createInfo:Pe,createSuccess:Fe,createWarning:Ue,createError:re,createDanger:re};function Be(a){let e="";for(let t of a){let n="",s="";t.route&&(n=``,s=""),e+=`
${n}${t.content}${s}
@@ -16,10 +16,10 @@
${e}
- `}function Ve(a,e,t,n){let s='',r=0;for(let u in e)s+=`| ${e[u]} | `,r++;s+="
";let c="";for(let u of t){c+='';for(let m in e)c+=`| ${u[m]} | `;c+="
"}let i="";typeof n!="undefined"&&(i=`
+ `}function ze(a,e,t,n){let s='',i=0;for(let u in e)s+=`| ${e[u]} | `,i++;s+="
";let c="";for(let u of t){c+='';for(let m in e)c+=`| ${u[m]} | `;c+="
"}let r="";typeof n!="undefined"&&(r=`
${c}
- ${i}
+ ${r}
- `}function oe(a,e,t){let n=document.createElement(a);for(let[s,r]of Object.entries(e))s==="class"?n.className=r:s==="dataset"?Object.assign(n.dataset,r):n.setAttribute(s,r);return n.innerHTML=typeof t!="undefined"?t:"",n}function ze(a,e){return["primary","success","secondary","info","warning","error","danger"].indexOf(a)<0?console.error("createAlert()","Error of type: "+a):oe("div",{class:`alert alert-${a}`},e)}function Je(a){let e={device_name:"name",device_hard_id:"device_id",device_ip:"ip",device_type:"type",ip_address:"ip",mac_address:"mac",device_mac:"mac",core_version:"firmware_core_version"},t={};for(let n in a){if(typeof e[n]!="undefined"){t[e[n]]=a[n];continue}t[n]=a[n]}return t}function We(a,e){if((a==null?void 0:a.isLoading)==e)return!1;if(e)a.isLoading=!0,a.originalContent=a.innerHTML,a.classList.contains("with-icon")?a.originalWithIcon=!0:a.classList.add("with-icon"),a.classList.add("loading-state"),a.setAttribute("disabled","disabled"),a.innerHTML=' Loading';else{if(a.isLoading=!1,!a.originalContent)return!1;a.removeAttribute("disabled"),a.classList.remove("loading-state"),a.originalWithIcon||a.classList.remove("with-icon"),a.innerHTML=a.originalContent}return a}function Ye(a,e){if((a==null?void 0:a.isLoading)==e)return!1;let t=a.querySelector(".device-icon");if(e)a.isLoading=!0,a.originalContent=t.innerHTML,a.classList.add("loading-state"),a.setAttribute("disabled","disabled"),t.innerHTML='';else{if(a.isLoading=!1,!a.originalContent)return!1;a.removeAttribute("disabled"),a.classList.remove("loading-state"),t.innerHTML=a.originalContent}return a}function Ge(a,e){return e=e!=null?e:"",`
+ `}function ce(a,e,t){let n=document.createElement(a);for(let[s,i]of Object.entries(e))s==="class"?n.className=i:s==="dataset"?Object.assign(n.dataset,i):n.setAttribute(s,i);return n.innerHTML=typeof t!="undefined"?t:"",n}function Ve(a,e){return["primary","success","secondary","info","warning","error","danger"].indexOf(a)<0?console.error("createAlert()","Error of type: "+a):ce("div",{class:`alert alert-${a}`},e)}function Je(a){let e={device_name:"name",device_hard_id:"device_id",device_ip:"ip",device_type:"type",ip_address:"ip",mac_address:"mac",device_mac:"mac",core_version:"firmware_core_version"},t={};for(let n in a){if(typeof e[n]!="undefined"){t[e[n]]=a[n];continue}t[n]=a[n]}return t}function We(a,e){if((a==null?void 0:a.isLoading)==e)return!1;if(e)a.isLoading=!0,a.originalContent=a.innerHTML,a.classList.contains("with-icon")?a.originalWithIcon=!0:a.classList.add("with-icon"),a.classList.add("loading-state"),a.setAttribute("disabled","disabled"),a.innerHTML=' Loading';else{if(a.isLoading=!1,!a.originalContent)return!1;a.removeAttribute("disabled"),a.classList.remove("loading-state"),a.originalWithIcon||a.classList.remove("with-icon"),a.innerHTML=a.originalContent}return a}function Ye(a,e){if((a==null?void 0:a.isLoading)==e)return!1;let t=a.querySelector(".device-icon");if(e)a.isLoading=!0,a.originalContent=t.innerHTML,a.classList.add("loading-state"),a.setAttribute("disabled","disabled"),t.innerHTML='';else{if(a.isLoading=!1,!a.originalContent)return!1;a.removeAttribute("disabled"),a.classList.remove("loading-state"),t.innerHTML=a.originalContent}return a}function Ge(a,e){return e=e!=null?e:"",`
- `}function Ke(a){return a=="active"?'Online':'Offline'}function Qe(a){return a=="enabled"?'Enabled':'Disabled'}function Xe(a){let e=new Date(a.replace(" ","T")),n=Math.floor((new Date-e)/1e3);if(n<60)return"less than a minute ago";let s=Math.floor(n/60),r=Math.floor(s/60),c=Math.floor(r/24);if(s<60)return`${s} minute${s!==1?"s":""} ago`;if(r<24){let i=s%60;return`${r} hour${r!==1?"s":""} ${i} minute${i!==1?"s":""} ago`}return`${c} day${c!==1?"s":""} ago`}function Ze(a){let e=new Date(a.replace(" ","T")),t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),s=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=Math.floor((n-s)/864e5),c=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0");if(r===0)return`Today at ${c}:${i}`;if(r===1)return`Yesterday at ${c}:${i}`;let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return`${e.getDate()} ${o[e.getMonth()]} ${e.getFullYear()} at ${c}:${i}`}function et(){return`
+ `}function Ke(a){return a=="active"?'Online':'Offline'}function Qe(a){return a=="enabled"?'Enabled':'Disabled'}function Xe(a){let e=new Date(a.replace(" ","T")),n=Math.floor((new Date-e)/1e3);if(n<60)return"less than a minute ago";let s=Math.floor(n/60),i=Math.floor(s/60),c=Math.floor(i/24);if(s<60)return`${s} minute${s!==1?"s":""} ago`;if(i<24){let r=s%60;return`${i} hour${i!==1?"s":""} ${r} minute${r!==1?"s":""} ago`}return`${c} day${c!==1?"s":""} ago`}function Ze(a){let e=new Date(a.replace(" ","T")),t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),s=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=Math.floor((n-s)/864e5),c=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0");if(i===0)return`Today at ${c}:${r}`;if(i===1)return`Yesterday at ${c}:${r}`;let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return`${e.getDate()} ${o[e.getMonth()]} ${e.getFullYear()} at ${c}:${r}`}function et(){return`
Loading
@@ -54,9 +54,9 @@
It's empty here yet
- `}var ce={template:{sidebarNav:Be,table:Ve,createElement:oe,createAlert:ze,mainTemplate:Ge,connectionStatusBadge:Ke,toogleStateBadge:Qe,circleLoaderHTML:et,emptyHereHTML:tt},unification:{deviceFieldsUnification:Je,timeAgo:Xe,formatDate:Ze},states:{btnLoadingState:We,cardScriptActionLoadingState:Ye}};var M=class{constructor(e){this.core=e}actions_list(e){return this.core.api_get("/api/v1/scripts/actions/list",e)}scopes_list(e){return this.core.api_get("/api/v1/scripts/scopes/list",e)}regular_list(e){return this.core.api_get("/api/v1/scripts/regular/list",e)}scope_get_by_filename(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}`,t,{})}scope_create(e,t){return this.core.api_post("/api/v1/scripts/scopes/new",e,t)}scope_update(e,t){return this.core.api_post("/api/v1/scripts/scopes/update",e,t)}action_enable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/actions/alias/${n}/enable`,t)}action_disable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/actions/alias/${n}/disable`,t)}regular_enable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/regular/alias/${n}/enable`,t)}regular_disable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/regular/alias/${n}/disable`,t)}scope_enable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}/enable`,t)}scope_disable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}/disable`,t)}scope_remove(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}/remove`,t)}run(e,t){return this.core.api_post("/api/v1/scripts/actions/run",e,t)}place_in_area(e,t){return this.core.api_post("/api/v1/scripts/place-in-area",e,t)}unassign_from_area(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/scripts/id/${n}/unassign-from-area`,t)}};var q=class{constructor(e){this.core=e}list(e){return this.core.api_get("/api/v1/devices/list",e)}scanning_setup(e){return this.core.api_get("/api/v1/devices/scanning/setup",e)}scanning_all(e){return this.core.api_get("/api/v1/devices/scanning/all",e)}setup_new_device(e,t){return this.core.api_post("/api/v1/devices/setup/new-device",e,t)}info(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/info`,t)}get(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}`,t)}status(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/status`,t)}action(e,t){return this.core.api_post("/api/v1/devices/action",e,t)}remove(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/remove`,t)}reboot(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/reboot`,t)}place_in_area(e,t){return this.core.api_post("/api/v1/devices/place-in-area",e,t)}unassign_from_area(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/unassign-from-area`,t)}update_name(e,t){return this.core.api_post("/api/v1/devices/update-name",e,t)}update_description(e,t){return this.core.api_post("/api/v1/devices/update-description",e,t)}update_alias(e,t){return this.core.api_post("/api/v1/devices/update-alias",e,t)}};var O=class{constructor(e){this.core=e}list(e){return this.core.api_get("/api/v1/areas/list",e)}inner_list(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/list`,t)}new_area(e,t){return this.core.api_post("/api/v1/areas/new-area",e,t)}remove(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/remove`,t)}place_in_area(e,t){return this.core.api_post("/api/v1/areas/place-in-area",e,t)}update_display_name(e,t){return this.core.api_post("/api/v1/areas/update-display-name",e,t)}update_alias(e,t){return this.core.api_post("/api/v1/areas/update-alias",e,t)}devices(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/devices`,t)}scripts(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/scripts`,t)}unassign_from_area(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/unassign-from-area`,t)}types_list(e){return this.core.api_get("/api/v1/areas/types/list",e)}reboot_devices(e,t){if(e==null)return this.core.api_get("/api/v1/areas/reboot_devices",t);let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/reboot_devices`,t)}};function le(a){if(!a||typeof a!="object")return"";let e=new URLSearchParams;Object.entries(a).forEach(([n,s])=>{s!=null&&e.append(n,String(s))});let t=e.toString();return t?`?${t}`:""}function at(a,e){let t=String(a||"").replace(/\/+$/,""),n=String(e||"").replace(/^\/+/,"");return`${t}/${n}`}function nt(a){try{return{ok:!0,data:JSON.parse(a)}}catch(e){return{ok:!1,error:e}}}var C=class{constructor(e){this.base_url=(e==null?void 0:e.base_url)||"",this.token=(e==null?void 0:e.token)||"",this.timeout_ms=Number.isFinite(e==null?void 0:e.timeout_ms)?e.timeout_ms:15e3,this.default_headers=(e==null?void 0:e.default_headers)||{},this.on_unauthorized=typeof(e==null?void 0:e.on_unauthorized)=="function"?e.on_unauthorized:null,this.proxy_path=(e==null?void 0:e.proxy_path)||"",this.scripts=new M(this),this.devices=new q(this),this.areas=new O(this)}set_base_url(e){this.base_url=e||""}set_token(e){this.token=e||""}set_proxy_path(e){this.proxy_path=e||""}_wrap_path(e,t){if(!this.proxy_path)return t?`${e}${le(t)}`:e;let n=v({path:e},t||{});return`${this.proxy_path}${le(n)}`}request(e,t,n,s,r){let c=typeof s=="function"?s:()=>{},i=at(this.base_url,t),o=new AbortController,l=Number.isFinite(r==null?void 0:r.timeout_ms)?r.timeout_ms:this.timeout_ms,d=setTimeout(()=>o.abort(),l),u=v(v({},this.default_headers),(r==null?void 0:r.headers)||{});this.token&&(u.Authorization=`Bearer ${this.token}`);let m;n!=null&&(u["Content-Type"]="application/json",m=JSON.stringify(n)),fetch(i,{method:e,headers:u,body:m,signal:o.signal}).then(p=>ne(this,null,function*(){clearTimeout(d);let g={url:i,method:e,status_code:p.status,headers:p.headers},b=yield p.text(),N=nt(b),S=N.ok?N.data:b;if(!p.ok){let E={type:"http_error",message:`HTTP ${p.status}`,status_code:p.status,raw:S};if((p.status===401||p.status===403)&&this.on_unauthorized)try{this.on_unauthorized({error:E,meta:g})}catch(Z){}return c(E,null,g)}if(N.ok&&S&&typeof S=="object"){let E=S.status;if(E===!1||E==="error"){let Z={type:"api_error",message:S.message||"API error",status_code:p.status,raw:S,field:S.field};return c(Z,null,g)}}return c(null,S,g)})).catch(p=>{clearTimeout(d);let b=p&&(p.name==="AbortError"||String(p).includes("AbortError"))?{type:"timeout",message:`Timeout after ${l}ms`}:{type:"network_error",message:(p==null?void 0:p.message)||"Network error",details:p};return c(b,null,{url:i,method:e,status_code:0,headers:null})})}get(e,t,n){return this.request("GET",e,null,t,n)}post(e,t,n,s){return this.request("POST",e,t,n,s)}api_get(e,t,n,s){return this.get(this._wrap_path(e,n),t,s)}api_post(e,t,n,s,r){return this.post(this._wrap_path(e,s),t,n,r)}};function k(a){return Helper.template.sidebarNav([{content:' Devices',route:"/#!/devices",is_active:a=="devices"},{content:' Scanning',route:"/#!/devices/scanning",is_active:a=="scanning"}])}function y(a,e,t){Helper.states.btnLoadingState(e,!0);let n=e.dataset.deviceId,s=e.dataset.deviceName,r=e.dataset.deviceAlias;a.devices.reboot(n,(c,i,o)=>{Helper.states.btnLoadingState(e,!1),console.log("Reboot done",c,i,o),t==null||t.close(),i?(setTimeout(()=>Screens.reinit(),8e3),Toasts.createSuccess("Reboot successful",`Device: ${s}
- Alias: ${r}`).show()):Toasts.createError("Reboot failed",`Device: ${s}
- Alias: ${r}`).show()})}var f,j,de,_,I,H,F={area:"areas",device:"devices",action:"scripts"};function P(){let a=f.querySelector(".current-area");for(let e of de)if(e.id==_)return a.innerHTML=`${e.display_name}`;a.innerHTML=`Area ID ${_}`,ot()}function st(a){I[F[H]].unassign_from_area(a,(e,t,n)=>{if(console.log(`sh_api[${F[H]}].unassign_from_area`,e,t,n),!t||t.data.status)return Toasts.createError("Error of unassigning",t?t.data.error_alias:"Error of request").show();_=0,P(),U(),Toasts.createSuccess("Successfully unassigning","Successfully unassigning").show(),Screens.reinit()})}function rt(a,e){a[F[H]].place_in_area(e,(t,n,s)=>{if(console.log("sh_api.areas.place_in_area",t,n,s),!n||!n.status)return console.error("Component placeInArea",t,n,s);let r=f.querySelector(".current-area");Toasts.createSuccess("Successfully applied","Successfully applied").show(),_=e.place_in_area_id,P(),U(),Screens.reinit(),console.log("Success",n)})}function it(a,e){I.areas.list((t,n,s)=>{if(console.log("sh_api.areas.list",t,n,s),!n)return console.error("sh_api.areas.list",t);de=n.data.areas,P();let r={};for(let i of n.data.areas)H=="area"&&i.id==a||(r[i.id]=i.display_name);let c=advancedSelect(f.querySelector(".select-area"),r,"Nothing found");f.querySelector(".advanced-select-container").append(c),c.advancedSelect.addEventListener("changed",i=>{e(i,n.data.areas)}),j.innerHTML="",j.append(f)})}function U(){let a=f.querySelector(".form-container");a.classList.remove("a-show"),a.classList.add("a-hide"),setTimeout(()=>a.classList.remove("a-hide"),300)}function ot(){let a=f.querySelector(".remove-parent-id");_==0?a.classList.add("d-none"):a.classList.remove("d-none")}function w(a,e,t,n,s){I=a,j=e,_=s,H=t,f=document.createElement("div"),f.classList.add("component"),f.classList.add("place-in-area-component"),f.innerHTML=`
+ `}var le={template:{sidebarNav:Be,table:ze,createElement:ce,createAlert:Ve,mainTemplate:Ge,connectionStatusBadge:Ke,toogleStateBadge:Qe,circleLoaderHTML:et,emptyHereHTML:tt},unification:{deviceFieldsUnification:Je,timeAgo:Xe,formatDate:Ze},states:{btnLoadingState:We,cardScriptActionLoadingState:Ye}};var q=class{constructor(e){this.core=e}actions_list(e){return this.core.api_get("/api/v1/scripts/actions/list",e)}scopes_list(e){return this.core.api_get("/api/v1/scripts/scopes/list",e)}regular_list(e){return this.core.api_get("/api/v1/scripts/regular/list",e)}scope_get_by_filename(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}`,t,{})}scope_create(e,t){return this.core.api_post("/api/v1/scripts/scopes/new",e,t)}scope_update(e,t){return this.core.api_post("/api/v1/scripts/scopes/update",e,t)}action_enable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/actions/alias/${n}/enable`,t)}action_disable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/actions/alias/${n}/disable`,t)}regular_enable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/regular/alias/${n}/enable`,t)}regular_disable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/regular/alias/${n}/disable`,t)}scope_enable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}/enable`,t)}scope_disable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}/disable`,t)}scope_remove(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}/remove`,t)}run(e,t){return this.core.api_post("/api/v1/scripts/actions/run",e,t)}place_in_area(e,t){return this.core.api_post("/api/v1/scripts/place-in-area",e,t)}unassign_from_area(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/scripts/id/${n}/unassign-from-area`,t)}};var O=class{constructor(e){this.core=e}list(e){return this.core.api_get("/api/v1/devices/list",e)}scanning_setup(e){return this.core.api_get("/api/v1/devices/scanning/setup",e)}scanning_all(e){return this.core.api_get("/api/v1/devices/scanning/all",e)}setup_new_device(e,t){return this.core.api_post("/api/v1/devices/setup/new-device",e,t)}info(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/info`,t)}get(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}`,t)}status(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/status`,t)}action(e,t){return this.core.api_post("/api/v1/devices/action",e,t)}remove(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/remove`,t)}reboot(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/reboot`,t)}place_in_area(e,t){return this.core.api_post("/api/v1/devices/place-in-area",e,t)}unassign_from_area(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/unassign-from-area`,t)}update_name(e,t){return this.core.api_post("/api/v1/devices/update-name",e,t)}update_description(e,t){return this.core.api_post("/api/v1/devices/update-description",e,t)}update_alias(e,t){return this.core.api_post("/api/v1/devices/update-alias",e,t)}};var C=class{constructor(e){this.core=e}list(e){return this.core.api_get("/api/v1/areas/list",e)}inner_list(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/list`,t)}new_area(e,t){return this.core.api_post("/api/v1/areas/new-area",e,t)}remove(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/remove`,t)}place_in_area(e,t){return this.core.api_post("/api/v1/areas/place-in-area",e,t)}update_display_name(e,t){return this.core.api_post("/api/v1/areas/update-display-name",e,t)}update_alias(e,t){return this.core.api_post("/api/v1/areas/update-alias",e,t)}devices(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/devices`,t)}scripts(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/scripts`,t)}unassign_from_area(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/unassign-from-area`,t)}types_list(e){return this.core.api_get("/api/v1/areas/types/list",e)}reboot_devices(e,t){if(e==null)return this.core.api_get("/api/v1/areas/reboot_devices",t);let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/reboot_devices`,t)}};function de(a){if(!a||typeof a!="object")return"";let e=new URLSearchParams;Object.entries(a).forEach(([n,s])=>{s!=null&&e.append(n,String(s))});let t=e.toString();return t?`?${t}`:""}function at(a,e){let t=String(a||"").replace(/\/+$/,""),n=String(e||"").replace(/^\/+/,"");return`${t}/${n}`}function nt(a){try{return{ok:!0,data:JSON.parse(a)}}catch(e){return{ok:!1,error:e}}}var k=class{constructor(e){this.base_url=(e==null?void 0:e.base_url)||"",this.token=(e==null?void 0:e.token)||"",this.timeout_ms=Number.isFinite(e==null?void 0:e.timeout_ms)?e.timeout_ms:15e3,this.default_headers=(e==null?void 0:e.default_headers)||{},this.on_unauthorized=typeof(e==null?void 0:e.on_unauthorized)=="function"?e.on_unauthorized:null,this.proxy_path=(e==null?void 0:e.proxy_path)||"",this.scripts=new q(this),this.devices=new O(this),this.areas=new C(this)}set_base_url(e){this.base_url=e||""}set_token(e){this.token=e||""}set_proxy_path(e){this.proxy_path=e||""}_wrap_path(e,t){if(!this.proxy_path)return t?`${e}${de(t)}`:e;let n=b({path:e},t||{});return`${this.proxy_path}${de(n)}`}request(e,t,n,s,i){let c=typeof s=="function"?s:()=>{},r=at(this.base_url,t),o=new AbortController,l=Number.isFinite(i==null?void 0:i.timeout_ms)?i.timeout_ms:this.timeout_ms,d=setTimeout(()=>o.abort(),l),u=b(b({},this.default_headers),(i==null?void 0:i.headers)||{});this.token&&(u.Authorization=`Bearer ${this.token}`);let m;n!=null&&(u["Content-Type"]="application/json",m=JSON.stringify(n)),fetch(r,{method:e,headers:u,body:m,signal:o.signal}).then(p=>se(this,null,function*(){clearTimeout(d);let g={url:r,method:e,status_code:p.status,headers:p.headers},v=yield p.text(),j=nt(v),S=j.ok?j.data:v;if(!p.ok){let $={type:"http_error",message:`HTTP ${p.status}`,status_code:p.status,raw:S};if((p.status===401||p.status===403)&&this.on_unauthorized)try{this.on_unauthorized({error:$,meta:g})}catch(ee){}return c($,null,g)}if(j.ok&&S&&typeof S=="object"){let $=S.status;if($===!1||$==="error"){let ee={type:"api_error",message:S.message||"API error",status_code:p.status,raw:S,field:S.field};return c(ee,null,g)}}return c(null,S,g)})).catch(p=>{clearTimeout(d);let v=p&&(p.name==="AbortError"||String(p).includes("AbortError"))?{type:"timeout",message:`Timeout after ${l}ms`}:{type:"network_error",message:(p==null?void 0:p.message)||"Network error",details:p};return c(v,null,{url:r,method:e,status_code:0,headers:null})})}get(e,t,n){return this.request("GET",e,null,t,n)}post(e,t,n,s){return this.request("POST",e,t,n,s)}api_get(e,t,n,s){return this.get(this._wrap_path(e,n),t,s)}api_post(e,t,n,s,i){return this.post(this._wrap_path(e,s),t,n,i)}};function I(a){return Helper.template.sidebarNav([{content:' Devices',route:"/#!/devices",is_active:a=="devices"},{content:' Scanning',route:"/#!/devices/scanning",is_active:a=="scanning"}])}function _(a,e,t){Helper.states.btnLoadingState(e,!0);let n=e.dataset.deviceId,s=e.dataset.deviceName,i=e.dataset.deviceAlias;a.devices.reboot(n,(c,r,o)=>{Helper.states.btnLoadingState(e,!1),console.log("Reboot done",c,r,o),t==null||t.close(),r?(setTimeout(()=>Screens.reinit(),8e3),Toasts.createSuccess("Reboot successful",`Device: ${s}
+ Alias: ${i}`).show()):Toasts.createError("Reboot failed",`Device: ${s}
+ Alias: ${i}`).show()})}var f,P,ue,w,N,A,U={area:"areas",device:"devices",action:"scripts"};function B(){let a=f.querySelector(".current-area");for(let e of ue)if(e.id==w)return a.innerHTML=`${e.display_name}`;a.innerHTML=`Area ID ${w}`,ot()}function st(a){N[U[A]].unassign_from_area(a,(e,t,n)=>{if(console.log(`sh_api[${U[A]}].unassign_from_area`,e,t,n),!t||t.data.status)return Toasts.createError("Error of unassigning",t?t.data.error_alias:"Error of request").show();w=0,B(),z(),Toasts.createSuccess("Successfully unassigning","Successfully unassigning").show(),Screens.reinit()})}function it(a,e){a[U[A]].place_in_area(e,(t,n,s)=>{if(console.log("sh_api.areas.place_in_area",t,n,s),!n||!n.status)return console.error("Component placeInArea",t,n,s);let i=f.querySelector(".current-area");Toasts.createSuccess("Successfully applied","Successfully applied").show(),w=e.place_in_area_id,B(),z(),Screens.reinit(),console.log("Success",n)})}function rt(a,e){N.areas.list((t,n,s)=>{if(console.log("sh_api.areas.list",t,n,s),!n)return console.error("sh_api.areas.list",t);ue=n.data.areas,B();let i={};for(let r of n.data.areas)A=="area"&&r.id==a||(i[r.id]=r.display_name);let c=advancedSelect(f.querySelector(".select-area"),i,"Nothing found");f.querySelector(".advanced-select-container").append(c),c.advancedSelect.addEventListener("changed",r=>{e(r,n.data.areas)}),P.innerHTML="",P.append(f)})}function z(){let a=f.querySelector(".form-container");a.classList.remove("a-show"),a.classList.add("a-hide"),setTimeout(()=>a.classList.remove("a-hide"),300)}function ot(){let a=f.querySelector(".remove-parent-id");w==0?a.classList.add("d-none"):a.classList.remove("d-none")}function L(a,e,t,n,s){N=a,P=e,w=s,A=t,f=document.createElement("div"),f.classList.add("component"),f.classList.add("place-in-area-component"),f.innerHTML=`