From 63ff4ddea0b11f4dec459d78bff46487ce361dcf Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 8 Jun 2023 07:08:02 -0400 Subject: [PATCH] refactored dashboards --- .../device-dashboard/web_root/components.js | 7 +- examples/wifi-router-dashboard/Makefile | 2 +- examples/wifi-router-dashboard/main.c | 2 +- .../wifi-router-dashboard/{web.c => net.c} | 2 +- .../wifi-router-dashboard/{web.h => net.h} | 0 .../wifi-router-dashboard/web_root/bundle.js | 2 +- .../web_root/components.js | 1 + .../web_root/history.min.js | 2 +- .../wifi-router-dashboard/web_root/index.html | 16 +- .../wifi-router-dashboard/web_root/main.js | 232 ++---------------- 10 files changed, 29 insertions(+), 237 deletions(-) rename examples/wifi-router-dashboard/{web.c => net.c} (99%) rename examples/wifi-router-dashboard/{web.h => net.h} (100%) mode change 100644 => 120000 examples/wifi-router-dashboard/web_root/bundle.js create mode 120000 examples/wifi-router-dashboard/web_root/components.js mode change 100644 => 120000 examples/wifi-router-dashboard/web_root/history.min.js mode change 100644 => 120000 examples/wifi-router-dashboard/web_root/index.html diff --git a/examples/device-dashboard/web_root/components.js b/examples/device-dashboard/web_root/components.js index 3e13df4d..119f3299 100644 --- a/examples/device-dashboard/web_root/components.js +++ b/examples/device-dashboard/web_root/components.js @@ -3,8 +3,12 @@ import { h, render, useState, useEffect, useRef, html, Router } from './bundle. export const Icons = { heart: props => html``, + downArrowBox: props => html` `, + upArrowBox: props => html` `, settings: props => html` `, + scan: props => html` `, desktop: props => html` `, + alert: props => html` `, bell: props => html` `, refresh: props => html` `, bars4: props => html` `, @@ -27,6 +31,7 @@ export const Icons = { arrowup: props => html` `, warn: props => html` `, info: props => html` `, + exclamationTriangle: props => html` ` }; export const tipColors = { @@ -130,7 +135,6 @@ export function Login({loginFn, logoIcon, title, tipText}) { `; }; - export function Colored({icon, text, colors}) { return html` @@ -200,3 +204,4 @@ export function Setting(props) { `; }; + diff --git a/examples/wifi-router-dashboard/Makefile b/examples/wifi-router-dashboard/Makefile index 4822690f..805aa6e3 100644 --- a/examples/wifi-router-dashboard/Makefile +++ b/examples/wifi-router-dashboard/Makefile @@ -2,7 +2,7 @@ PROG ?= ./example # Program we are building PACK ?= ./pack # Packing executable DELETE = rm -rf # Command to remove files OUT ?= -o $(PROG) # Compiler argument for output file -SOURCES = main.c mongoose.c web.c # Source code files +SOURCES = main.c mongoose.c net.c # Source code files CFLAGS = -W -Wall -Wextra -g -I. # Build options # Mongoose build options. See https://mongoose.ws/documentation/#build-options diff --git a/examples/wifi-router-dashboard/main.c b/examples/wifi-router-dashboard/main.c index 3a3a558b..6a6fcad3 100644 --- a/examples/wifi-router-dashboard/main.c +++ b/examples/wifi-router-dashboard/main.c @@ -1,7 +1,7 @@ // Copyright (c) 2020-2022 Cesanta Software Limited // All rights reserved -#include "web.h" +#include "net.h" static int s_sig_num; static void signal_handler(int sig_num) { diff --git a/examples/wifi-router-dashboard/web.c b/examples/wifi-router-dashboard/net.c similarity index 99% rename from examples/wifi-router-dashboard/web.c rename to examples/wifi-router-dashboard/net.c index 152039f0..759abd0f 100644 --- a/examples/wifi-router-dashboard/web.c +++ b/examples/wifi-router-dashboard/net.c @@ -1,7 +1,7 @@ // Copyright (c) 2023 Cesanta Software Limited // All rights reserved -#include "web.h" +#include "net.h" // Authenticated user. // A user can be authenticated by: diff --git a/examples/wifi-router-dashboard/web.h b/examples/wifi-router-dashboard/net.h similarity index 100% rename from examples/wifi-router-dashboard/web.h rename to examples/wifi-router-dashboard/net.h diff --git a/examples/wifi-router-dashboard/web_root/bundle.js b/examples/wifi-router-dashboard/web_root/bundle.js deleted file mode 100644 index 58426ace..00000000 --- a/examples/wifi-router-dashboard/web_root/bundle.js +++ /dev/null @@ -1 +0,0 @@ -var n,t,e,_,r,o,i,u,l,c={},a=[],s=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function f(n,t){for(var e in t)n[e]=t[e];return n}function p(n){var t=n.parentNode;t&&t.removeChild(n)}function h(t,e,_){var r,o,i,u={};for(i in e)"key"==i?r=e[i]:"ref"==i?o=e[i]:u[i]=e[i];if(arguments.length>2&&(u.children=arguments.length>3?n.call(arguments,2):_),"function"==typeof t&&null!=t.defaultProps)for(i in t.defaultProps)void 0===u[i]&&(u[i]=t.defaultProps[i]);return d(t,u,r,o,null)}function d(n,_,r,o,i){var u={type:n,props:_,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==i?++e:i};return null==i&&null!=t.vnode&&t.vnode(u),u}function v(){return{current:null}}function m(n){return n.children}function y(n,t){this.props=n,this.context=t}function g(n,t){if(null==t)return n.__?g(n.__,n.__.__k.indexOf(n)+1):null;for(var e;tt&&r.sort(u));C.__r=0}function x(n,t,e,_,r,o,i,u,l,s){var f,p,h,v,y,b,k,C=_&&_.__k||a,x=C.length;for(e.__k=[],f=0;f0?d(v.type,v.props,v.key,v.ref?v.ref:null,v.__v):v)){if(v.__=e,v.__b=e.__b+1,null===(h=C[f])||h&&v.key==h.key&&v.type===h.type)C[f]=void 0;else for(p=0;p=0;t--)if((e=n.__k[t])&&(_=A(e)))return _;return null}function P(n,t,e,_,r){var o;for(o in e)"children"===o||"key"===o||o in t||N(n,o,null,e[o],_);for(o in t)r&&"function"!=typeof t[o]||"children"===o||"key"===o||"value"===o||"checked"===o||e[o]===t[o]||N(n,o,t[o],e[o],_)}function S(n,t,e){"-"===t[0]?n.setProperty(t,null==e?"":e):n[t]=null==e?"":"number"!=typeof e||s.test(t)?e:e+"px"}function N(n,t,e,_,r){var o;n:if("style"===t)if("string"==typeof e)n.style.cssText=e;else{if("string"==typeof _&&(n.style.cssText=_=""),_)for(t in _)e&&t in e||S(n.style,t,"");if(e)for(t in e)_&&e[t]===_[t]||S(n.style,t,e[t])}else if("o"===t[0]&&"n"===t[1])o=t!==(t=t.replace(/Capture$/,"")),t=t.toLowerCase()in n?t.toLowerCase().slice(2):t.slice(2),n.l||(n.l={}),n.l[t+o]=e,e?_||n.addEventListener(t,o?D:w,o):n.removeEventListener(t,o?D:w,o);else if("dangerouslySetInnerHTML"!==t){if(r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&t in n)try{n[t]=null==e?"":e;break n}catch(n){}"function"==typeof e||(null==e||!1===e&&"-"!==t[4]?n.removeAttribute(t):n.setAttribute(t,e))}}function w(n){return this.l[n.type+!1](t.event?t.event(n):n)}function D(n){return this.l[n.type+!0](t.event?t.event(n):n)}function T(n,e,_,r,o,i,u,l,c){var a,s,p,h,d,v,g,b,k,C,E,H,U,A,P,S=e.type;if(void 0!==e.constructor)return null;null!=_.__h&&(c=_.__h,l=e.__e=_.__e,e.__h=null,i=[l]),(a=t.__b)&&a(e);try{n:if("function"==typeof S){if(b=e.props,k=(a=S.contextType)&&r[a.__c],C=a?k?k.props.value:a.__:r,_.__c?g=(s=e.__c=_.__c).__=s.__E:("prototype"in S&&S.prototype.render?e.__c=s=new S(b,C):(e.__c=s=new y(b,C),s.constructor=S,s.render=V),k&&k.sub(s),s.props=b,s.state||(s.state={}),s.context=C,s.__n=r,p=s.__d=!0,s.__h=[],s._sb=[]),null==s.__s&&(s.__s=s.state),null!=S.getDerivedStateFromProps&&(s.__s==s.state&&(s.__s=f({},s.__s)),f(s.__s,S.getDerivedStateFromProps(b,s.__s))),h=s.props,d=s.state,s.__v=e,p)null==S.getDerivedStateFromProps&&null!=s.componentWillMount&&s.componentWillMount(),null!=s.componentDidMount&&s.__h.push(s.componentDidMount);else{if(null==S.getDerivedStateFromProps&&b!==h&&null!=s.componentWillReceiveProps&&s.componentWillReceiveProps(b,C),!s.__e&&null!=s.shouldComponentUpdate&&!1===s.shouldComponentUpdate(b,s.__s,C)||e.__v===_.__v){for(e.__v!==_.__v&&(s.props=b,s.state=s.__s,s.__d=!1),s.__e=!1,e.__e=_.__e,e.__k=_.__k,e.__k.forEach((function(n){n&&(n.__=e)})),E=0;E2&&(u.children=arguments.length>3?n.call(arguments,2):_),d(t.type,u,r||t.key,o||t.ref,null)}function $(n,t){var e={__c:t="__cC"+l++,__:n,Consumer:function(n,t){return n.children(t)},Provider:function(n){var e,_;return this.getChildContext||(e=[],(_={})[t]=this,this.getChildContext=function(){return _},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&e.some((function(n){n.__e=!0,k(n)}))},this.sub=function(n){e.push(n);var t=n.componentWillUnmount;n.componentWillUnmount=function(){e.splice(e.indexOf(n),1),t&&t.call(n)}}),n.children}};return e.Provider.__=e.Consumer.contextType=e}n=a.slice,t={__e:function(n,t,e,_){for(var r,o,i;t=t.__;)if((r=t.__c)&&!r.__)try{if((o=r.constructor)&&null!=o.getDerivedStateFromError&&(r.setState(o.getDerivedStateFromError(n)),i=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(n,_||{}),i=r.__d),i)return r.__E=r}catch(t){n=t}throw n}},e=0,_=function(n){return null!=n&&void 0===n.constructor},y.prototype.setState=function(n,t){var e;e=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=f({},this.state),"function"==typeof n&&(n=n(f({},e),this.props)),n&&f(e,n),null!=n&&this.__v&&(t&&this._sb.push(t),k(this))},y.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),k(this))},y.prototype.render=m,r=[],i="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,u=function(n,t){return n.__v.__b-t.__v.__b},C.__r=0,l=0;var j,q,B,K,G=0,z=[],J=[],Q=t.__b,X=t.__r,Y=t.diffed,Z=t.__c,nn=t.unmount;function tn(n,e){t.__h&&t.__h(q,n,G||e),G=0;var _=q.__H||(q.__H={__:[],__h:[]});return n>=_.__.length&&_.__.push({__V:J}),_.__[n]}function en(n){return G=1,_n(kn,n)}function _n(n,t,e){var _=tn(j++,2);if(_.t=n,!_.__c&&(_.__=[e?e(t):kn(void 0,t),function(n){var t=_.__N?_.__N[0]:_.__[0],e=_.t(t,n);t!==e&&(_.__N=[e,_.__[1]],_.__c.setState({}))}],_.__c=q,!q.u)){var r=function(n,t,e){if(!_.__c.__H)return!0;var r=_.__c.__H.__.filter((function(n){return n.__c}));if(r.every((function(n){return!n.__N})))return!o||o.call(this,n,t,e);var i=!1;return r.forEach((function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}})),!(!i&&_.__c.props===n)&&(!o||o.call(this,n,t,e))};q.u=!0;var o=q.shouldComponentUpdate,i=q.componentWillUpdate;q.componentWillUpdate=function(n,t,e){if(this.__e){var _=o;o=void 0,r(n,t,e),o=_}i&&i.call(this,n,t,e)},q.shouldComponentUpdate=r}return _.__N||_.__}function rn(n,e){var _=tn(j++,3);!t.__s&&bn(_.__H,e)&&(_.__=n,_.i=e,q.__H.__h.push(_))}function on(n,e){var _=tn(j++,4);!t.__s&&bn(_.__H,e)&&(_.__=n,_.i=e,q.__h.push(_))}function un(n){return G=5,cn((function(){return{current:n}}),[])}function ln(n,t,e){G=6,on((function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0}),null==e?e:e.concat(n))}function cn(n,t){var e=tn(j++,7);return bn(e.__H,t)?(e.__V=n(),e.i=t,e.__h=n,e.__V):e.__}function an(n,t){return G=8,cn((function(){return n}),t)}function sn(n){var t=q.context[n.__c],e=tn(j++,9);return e.c=n,t?(null==e.__&&(e.__=!0,t.sub(q)),t.props.value):n.__}function fn(n,e){t.useDebugValue&&t.useDebugValue(e?e(n):n)}function pn(n){var t=tn(j++,10),e=en();return t.__=n,q.componentDidCatch||(q.componentDidCatch=function(n,_){t.__&&t.__(n,_),e[1](n)}),[e[0],function(){e[1](void 0)}]}function hn(){var n=tn(j++,11);if(!n.__){for(var t=q.__v;null!==t&&!t.__m&&null!==t.__;)t=t.__;var e=t.__m||(t.__m=[0,0]);n.__="P"+e[0]+"-"+e[1]++}return n.__}function dn(){for(var n;n=z.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(yn),n.__H.__h.forEach(gn),n.__H.__h=[]}catch(o){n.__H.__h=[],t.__e(o,n.__v)}}t.__b=function(n){q=null,Q&&Q(n)},t.__r=function(n){X&&X(n),j=0;var t=(q=n.__c).__H;t&&(B===q?(t.__h=[],q.__h=[],t.__.forEach((function(n){n.__N&&(n.__=n.__N),n.__V=J,n.__N=n.i=void 0}))):(t.__h.forEach(yn),t.__h.forEach(gn),t.__h=[])),B=q},t.diffed=function(n){Y&&Y(n);var e=n.__c;e&&e.__H&&(e.__H.__h.length&&(1!==z.push(e)&&K===t.requestAnimationFrame||((K=t.requestAnimationFrame)||mn)(dn)),e.__H.__.forEach((function(n){n.i&&(n.__H=n.i),n.__V!==J&&(n.__=n.__V),n.i=void 0,n.__V=J}))),B=q=null},t.__c=function(n,_){_.some((function(n){try{n.__h.forEach(yn),n.__h=n.__h.filter((function(n){return!n.__||gn(n)}))}catch(e){_.some((function(n){n.__h&&(n.__h=[])})),_=[],t.__e(e,n.__v)}})),Z&&Z(n,_)},t.unmount=function(n){nn&&nn(n);var e,_=n.__c;_&&_.__H&&(_.__H.__.forEach((function(n){try{yn(n)}catch(n){e=n}})),_.__H=void 0,e&&t.__e(e,_.__v))};var vn="function"==typeof requestAnimationFrame;function mn(n){var t,e=function(){clearTimeout(_),vn&&cancelAnimationFrame(t),setTimeout(n)},_=setTimeout(e,100);vn&&(t=requestAnimationFrame(e))}function yn(n){var t=q,e=n.__c;"function"==typeof e&&(n.__c=void 0,e()),q=t}function gn(n){var t=q;n.__c=n.__(),q=t}function bn(n,t){return!n||n.length!==t.length||t.some((function(t,e){return t!==n[e]}))}function kn(n,t){return"function"==typeof t?t(n):t}var Cn=function(n,t,e,_){var r;t[0]=0;for(var o=1;o=5&&((r||!n&&5===_)&&(i.push(_,0,r,e),_=6),n&&(i.push(_,n,0,e),_=6)),r=""},l=0;l"===t?(_=1,r=""):r=t+r[0]:o?t===o?o="":r+=t:'"'===t||"'"===t?o=t:">"===t?(u(),_=1):_&&("="===t?(_=5,e=r,r=""):"/"===t&&(_<5||">"===n[l][c+1])?(u(),3===_&&(i=i[0]),_=i,(i=i[0]).push(2,0,_),_=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(u(),_=2):r+=t),3===_&&"!--"===r&&(_=4,i=i[0])}return u(),i}(n)),t),arguments,[])).length>1?t:t[0]}var Hn=En.bind(h);var Un={};function An(n,t){for(var e in t)n[e]=t[e];return n}function Pn(n,t,e){var _,r=/(?:\?([^#]*))?(#.*)?$/,o=n.match(r),i={};if(o&&o[1])for(var u=o[1].split("&"),l=0;lt.rank?-1:n.index-t.index}function Nn(n,t){return n.index=t,n.rank=function(n){return n.props.default?0:wn(n.props.path).map(Dn).join("")}(n),n.props}function wn(n){return n.replace(/(^\/+|\/+$)/g,"").split("/")}function Dn(n){return":"==n.charAt(0)?1+"*+?".indexOf(n.charAt(n.length-1))||4:5}var Tn={},Rn=[],Ln=[],Mn=null,Wn={url:In()},Vn=$(Wn);function Fn(){var n=sn(Vn);if(n===Wn){var t=en()[1];rn((function(){return Ln.push(t),function(){return Ln.splice(Ln.indexOf(t),1)}}),[])}return[n,On]}function In(){var n;return""+((n=Mn&&Mn.location?Mn.location:Mn&&Mn.getCurrentLocation?Mn.getCurrentLocation():"undefined"!=typeof location?location:Tn).pathname||"")+(n.search||"")}function On(n,t){return void 0===t&&(t=!1),"string"!=typeof n&&n.url&&(t=n.replace,n=n.url),function(n){for(var t=Rn.length;t--;)if(Rn[t].canRoute(n))return!0;return!1}(n)&&function(n,t){void 0===t&&(t="push"),Mn&&Mn[t]?Mn[t](n):"undefined"!=typeof history&&history[t+"State"]&&history[t+"State"](null,null,n)}(n,t?"replace":"push"),$n(n)}function $n(n){for(var t=!1,e=0;e0&&void 0!==arguments[0]?arguments[0]:{};d.canUseDOM?void 0:(0,c.default)(!1);var n=window.history,e=(0,d.supportsHistory)(),o=!(0,d.supportsPopStateOnHashChange)(),i=t.forceRefresh,a=void 0!==i&&i,f=t.getUserConfirmation,y=void 0===f?d.getConfirmation:f,g=t.keyLength,m=void 0===g?6:g,w=t.basename?(0,s.stripTrailingSlash)((0,s.addLeadingSlash)(t.basename)):"",P=function(t){var n=t||{},e=n.key,o=n.state,i=window.location,a=i.pathname,c=i.search,u=i.hash,f=a+c+u;return w&&(f=(0,s.stripPrefix)(f,w)),r({},(0,s.parsePath)(f),{state:o,key:e})},b=function(){return Math.random().toString(36).substr(2,m)},O=(0,l.default)(),x=function(t){r(G,t),G.length=n.length,O.notifyListeners(G.location,G.action)},L=function(t){(0,d.isExtraneousPopstateEvent)(t)||A(P(t.state))},S=function(){A(P(p()))},E=!1,A=function(t){if(E)E=!1,x();else{var n="POP";O.confirmTransitionTo(t,n,y,function(e){e?x({action:n,location:t}):_(t)})}},_=function(t){var n=G.location,e=M.indexOf(n.key);e===-1&&(e=0);var o=M.indexOf(t.key);o===-1&&(o=0);var r=e-o;r&&(E=!0,C(r))},k=P(p()),M=[k.key],T=function(t){return w+(0,s.createPath)(t)},H=function(t,o){var r="PUSH",i=(0,u.createLocation)(t,o,b(),G.location);O.confirmTransitionTo(i,r,y,function(t){if(t){var o=T(i),c=i.key,u=i.state;if(e)if(n.pushState({key:c,state:u},null,o),a)window.location.href=o;else{var s=M.indexOf(G.location.key),f=M.slice(0,s===-1?0:s+1);f.push(i.key),M=f,x({action:r,location:i})}else window.location.href=o}})},j=function(t,o){var r="REPLACE",i=(0,u.createLocation)(t,o,b(),G.location);O.confirmTransitionTo(i,r,y,function(t){if(t){var o=T(i),c=i.key,u=i.state;if(e)if(n.replaceState({key:c,state:u},null,o),a)window.location.replace(o);else{var s=M.indexOf(G.location.key);s!==-1&&(M[s]=i.key),x({action:r,location:i})}else window.location.replace(o)}})},C=function(t){n.go(t)},U=function(){return C(-1)},R=function(){return C(1)},I=0,q=function(t){I+=t,1===I?((0,d.addEventListener)(window,h,L),o&&(0,d.addEventListener)(window,v,S)):0===I&&((0,d.removeEventListener)(window,h,L),o&&(0,d.removeEventListener)(window,v,S))},B=!1,F=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=O.setPrompt(t);return B||(q(1),B=!0),function(){return B&&(B=!1,q(-1)),n()}},D=function(t){var n=O.appendListener(t);return q(1),function(){q(-1),n()}},G={length:n.length,action:"POP",location:k,createHref:T,push:H,replace:j,go:C,goBack:U,goForward:R,block:F,listen:D};return G};n.default=y},function(t,n,e){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}n.__esModule=!0;var r=Object.assign||function(t){for(var n=1;n=0?n:0)+"#"+t)},m=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};d.canUseDOM?void 0:(0,c.default)(!1);var n=window.history,e=((0,d.supportsGoWithoutReloadUsingHash)(),t.getUserConfirmation),o=void 0===e?d.getConfirmation:e,i=t.hashType,a=void 0===i?"slash":i,f=t.basename?(0,s.stripTrailingSlash)((0,s.addLeadingSlash)(t.basename)):"",m=v[a],w=m.encodePath,P=m.decodePath,b=function(){var t=P(p());return f&&(t=(0,s.stripPrefix)(t,f)),(0,s.parsePath)(t)},O=(0,l.default)(),x=function(t){r(V,t),V.length=n.length,O.notifyListeners(V.location,V.action)},L=!1,S=null,E=function(){var t=p(),n=w(t);if(t!==n)g(n);else{var e=b(),o=V.location;if(!L&&(0,u.locationsAreEqual)(o,e))return;if(S===(0,s.createPath)(e))return;S=null,A(e)}},A=function(t){if(L)L=!1,x();else{var n="POP";O.confirmTransitionTo(t,n,o,function(e){e?x({action:n,location:t}):_(t)})}},_=function(t){var n=V.location,e=H.lastIndexOf((0,s.createPath)(n));e===-1&&(e=0);var o=H.lastIndexOf((0,s.createPath)(t));o===-1&&(o=0);var r=e-o;r&&(L=!0,R(r))},k=p(),M=w(k);k!==M&&g(M);var T=b(),H=[(0,s.createPath)(T)],j=function(t){return"#"+w(f+(0,s.createPath)(t))},C=function(t,n){var e="PUSH",r=(0,u.createLocation)(t,void 0,void 0,V.location);O.confirmTransitionTo(r,e,o,function(t){if(t){var n=(0,s.createPath)(r),o=w(f+n),i=p()!==o;if(i){S=n,y(o);var a=H.lastIndexOf((0,s.createPath)(V.location)),c=H.slice(0,a===-1?0:a+1);c.push(n),H=c,x({action:e,location:r})}else x()}})},U=function(t,n){var e="REPLACE",r=(0,u.createLocation)(t,void 0,void 0,V.location);O.confirmTransitionTo(r,e,o,function(t){if(t){var n=(0,s.createPath)(r),o=w(f+n),i=p()!==o;i&&(S=n,g(o));var a=H.indexOf((0,s.createPath)(V.location));a!==-1&&(H[a]=n),x({action:e,location:r})}})},R=function(t){n.go(t)},I=function(){return R(-1)},q=function(){return R(1)},B=0,F=function(t){B+=t,1===B?(0,d.addEventListener)(window,h,E):0===B&&(0,d.removeEventListener)(window,h,E)},D=!1,G=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=O.setPrompt(t);return D||(F(1),D=!0),function(){return D&&(D=!1,F(-1)),n()}},W=function(t){var n=O.appendListener(t);return F(1),function(){F(-1),n()}},V={length:n.length,action:"POP",location:T,createHref:j,push:C,replace:U,go:R,goBack:I,goForward:q,block:G,listen:W};return V};n.default=m},function(t,n,e){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}n.__esModule=!0;var r=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Object.assign||function(t){for(var n=1;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.getUserConfirmation,e=t.initialEntries,o=void 0===e?["/"]:e,i=t.initialIndex,u=void 0===i?0:i,l=t.keyLength,d=void 0===l?6:l,h=(0,s.default)(),v=function(t){r(A,t),A.length=A.entries.length,h.notifyListeners(A.location,A.action)},p=function(){return Math.random().toString(36).substr(2,d)},y=f(u,0,o.length-1),g=o.map(function(t){return"string"==typeof t?(0,c.createLocation)(t,void 0,p()):(0,c.createLocation)(t,void 0,t.key||p())}),m=a.createPath,w=function(t,e){var o="PUSH",r=(0,c.createLocation)(t,e,p(),A.location);h.confirmTransitionTo(r,o,n,function(t){if(t){var n=A.index,e=n+1,i=A.entries.slice(0);i.length>e?i.splice(e,i.length-e,r):i.push(r),v({action:o,location:r,index:e,entries:i})}})},P=function(t,e){var o="REPLACE",r=(0,c.createLocation)(t,e,p(),A.location);h.confirmTransitionTo(r,o,n,function(t){t&&(A.entries[A.index]=r,v({action:o,location:r}))})},b=function(t){var e=f(A.index+t,0,A.entries.length-1),o="POP",r=A.entries[e];h.confirmTransitionTo(r,o,n,function(t){t?v({action:o,location:r,index:e}):v()})},O=function(){return b(-1)},x=function(){return b(1)},L=function(t){var n=A.index+t;return n>=0&&n0&&void 0!==arguments[0]&&arguments[0];return h.setPrompt(t)},E=function(t){return h.appendListener(t)},A={length:g.length,action:"POP",location:g[y],index:y,entries:g,createHref:m,push:w,replace:P,go:b,goBack:O,goForward:x,canGo:L,block:S,listen:E};return A};n.default=l},function(t,n){"use strict";var e=function(t){return"/"===t.charAt(0)},o=function(t,n){for(var e=n,o=e+1,r=t.length;o=0;d--){var h=i[d];"."===h?o(i,d):".."===h?(o(i,d),l++):l&&(o(i,d),l--)}if(!u)for(;l--;l)i.unshift("..");!u||""===i[0]||i[0]&&e(i[0])||i.unshift("");var v=i.join("/");return s&&"/"!==v.substr(-1)&&(v+="/"),v};t.exports=r},function(t,n){"use strict";n.__esModule=!0;var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=function t(n,o){if(n===o)return!0;if(null==n||null==o)return!1;if(Array.isArray(n))return!(!Array.isArray(o)||n.length!==o.length)&&n.every(function(n,e){return t(n,o[e])});var r="undefined"==typeof n?"undefined":e(n),i="undefined"==typeof o?"undefined":e(o);if(r!==i)return!1;if("object"===r){var a=n.valueOf(),c=o.valueOf();if(a!==n||c!==o)return t(a,c);var u=Object.keys(n),s=Object.keys(o);return u.length===s.length&&u.every(function(e){return t(n[e],o[e])})}return!1};n.default=o}])}); \ No newline at end of file diff --git a/examples/wifi-router-dashboard/web_root/history.min.js b/examples/wifi-router-dashboard/web_root/history.min.js new file mode 120000 index 00000000..13552193 --- /dev/null +++ b/examples/wifi-router-dashboard/web_root/history.min.js @@ -0,0 +1 @@ +../../device-dashboard/web_root/history.min.js \ No newline at end of file diff --git a/examples/wifi-router-dashboard/web_root/index.html b/examples/wifi-router-dashboard/web_root/index.html deleted file mode 100644 index 7ad0821c..00000000 --- a/examples/wifi-router-dashboard/web_root/index.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/examples/wifi-router-dashboard/web_root/index.html b/examples/wifi-router-dashboard/web_root/index.html new file mode 120000 index 00000000..ee5c3157 --- /dev/null +++ b/examples/wifi-router-dashboard/web_root/index.html @@ -0,0 +1 @@ +../../device-dashboard/web_root/index.html \ No newline at end of file diff --git a/examples/wifi-router-dashboard/web_root/main.js b/examples/wifi-router-dashboard/web_root/main.js index 86988187..738491e8 100644 --- a/examples/wifi-router-dashboard/web_root/main.js +++ b/examples/wifi-router-dashboard/web_root/main.js @@ -1,152 +1,22 @@ 'use strict'; -import { h, render, useState, useEffect, useRef, html, Router } from './bundle.js'; +import { h, render, useState, useEffect, html, Router } from './bundle.js'; +import { Icons, Login, Setting, Button, Stat, tipColors, Colored, Notification } from './components.js'; const Logo = props => html``; -const IconHeart = props => html``; -const IconDownArrowBox = props => html` `; -const IconUpArrowBox = props => html` `; -const IconSettings = props => html` `; -const IconDesktop = props => html` `; -const IconScan = props => html` `; -const IconAlert = props => html` `; -const IconRefresh = props => html` `; -const IconBars4 = props => html` `; -const IconBars3 = props => html` `; -const IconLogout = props => html` `; -const IconSave = props => html` `; -const IconEmail = props => html` `; -const IconExpand = props => html` `; -const IconShrink = props => html` `; -const IconOk = props => html``; -const IconFailed = props => html` `; -const IconUpload = props => html` `; -const IconDownload = props => html` `; -const IconBolt = props => html` `; -const IconHome = props => html` `; -const IconLink = props => html` `; -const IconShield = props => html` `; -const IconBarsDown = props => html` `; -const IconArrowDown = props => html` `; -const IconArrowUp = props => html` `; -const IconExclamationTriangle = props => html` `; - -const tipColors = { - green: 'bg-green-100 text-green-900', - yellow: 'bg-yellow-100 text-yellow-900', - red: 'bg-red-100 text-red-900', -}; - -function Button({title, onclick, disabled, cls, icon, ref, colors, hovercolor, disabledcolor}) { - const [spin, setSpin] = useState(false); - const cb = function(ev) { - const res = onclick ? onclick() : null; - if (res && typeof (res.catch) === 'function') { - setSpin(true); - res.catch(() => false).then(() => setSpin(false)); - } - }; - if (!colors) colors = 'bg-blue-600 hover:bg-blue-500 disabled:bg-blue-400'; - return html` -