import{r as S,o as u,c as p,a as l,w as i,e as y,F as w,d as m,v,f as P,b as f,t as _,m as n,A as I,g as A}from"./index.js";import{d as C}from"./utils.js";const V={id:"NetworkIndex",class:"page-container"},b={class:"panel-group span-12"},W={class:"panel-container"},G=l("h3",{class:"panel-title"},"Server Network",-1),M={class:"panel-content"},E={class:"panel-container"},F=l("h3",{class:"panel-title"},"AP Mode Password",-1),D={class:"panel-content"},B={__name:"network",setup(H){const h=["NetworkConfiguredIface"],g=["--------","SWITCH_CODE","ETH_DHCP","WIFI","CELLULAR","WISUN","ETH_STATIC"],s=S({key:h[0],val:g[0],wifi_ssid:"",wifi_password:"",wisun_address:"",wisun_port:"",eth_static_address:"",eth_static_netmask:"",eth_static_gateway:""});function k(a){var t=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;return t.test(a)}function T(){let a=C(s.value),t=a.key,o=a.val;if(!t||!o)return n.warning("The inputs is empty");let e={},r="keySet";switch(o=="--------"&&(r="keyGet",o=""),o){case"WIFI":if(!a.wifi_ssid)return n.warning("Please input SSID");if(!a.wifi_password)return n.warning("Please input Password");e.NetworkWifiSsid=a.wifi_ssid,e.NetworkWifiPassword=a.wifi_password;break;case"WISUN":if(!a.wisun_address)return n.warning("Please input Address");if(!a.wisun_port)return n.warning("Please input Port");e.Udp6Websocket4TunnelIp=a.wisun_address,e.Udp6Websocket4TunnelPort=a.wisun_port;break;case"ETH_STATIC":if(!a.eth_static_address)return n.warning("Please input Address");if(!a.eth_static_netmask)return n.warning("Please input Netmask");if(!a.eth_static_gateway)return n.warning("Please input Gateway");if(!k(a.eth_static_gateway)||!k(a.eth_static_netmask)||!k(a.eth_static_gateway))return n.warning("The inputs ip format is not right");e.NetworkAddress=a.eth_static_address,e.NetworkNetmask=a.eth_static_netmask,e.NetworkGateway=a.eth_static_gateway;break}e[t]=o,I.Network[r](e).then(c=>{console.log("handleServerNetwork res:",c),n.success("Success"),r==="keyGet"&&(s.value.val=c.keys[0].value)}).catch(c=>{console.log("handleServerNetwork err:",c),n.error("Failure")})}const N=["ApWifiPassword"],d=S({key:N[0],val:""});function U(){let a=d.value.key,t=d.value.val;if(!a)return n.warning("The name is empty");let o=t?"keySet":"keyGet",e={};e[a]=t,I.Network[o](e).then(r=>{console.log("handleApModePassword res:",r),n.success("Success"),o==="keyGet"&&(d.value.val=r.keys[0].value)}).catch(r=>{console.log("handleApModePassword err:",r),n.error("Failure")})}return(a,t)=>{const o=A("a-input-password");return u(),p("div",V,[l("div",b,[l("div",W,[G,l("div",M,[i(l("select",{"onUpdate:modelValue":t[0]||(t[0]=e=>s.value.key=e),placeholder:"key"},[(u(),p(w,null,m(h,(e,r)=>l("option",{key:r},_(e),1)),64))],512),[[y,s.value.key]]),i(l("select",{"onUpdate:modelValue":t[1]||(t[1]=e=>s.value.val=e),placeholder:"value"},[(u(),p(w,null,m(g,(e,r)=>l("option",{key:r},_(e),1)),64))],512),[[y,s.value.val]]),s.value.val==="WIFI"?(u(),p(w,{key:0},[i(l("input",{"onUpdate:modelValue":t[2]||(t[2]=e=>s.value.wifi_ssid=e),placeholder:"SSID"},null,512),[[v,s.value.wifi_ssid]]),P(o,{value:s.value.wifi_password,"onUpdate:value":t[3]||(t[3]=e=>s.value.wifi_password=e),placeholder:"Password"},null,8,["value"])],64)):f("",!0),s.value.val==="WISUN"?(u(),p(w,{key:1},[i(l("input",{"onUpdate:modelValue":t[4]||(t[4]=e=>s.value.wisun_address=e),placeholder:"Address"},null,512),[[v,s.value.wisun_address]]),i(l("input",{"onUpdate:modelValue":t[5]||(t[5]=e=>s.value.wisun_port=e),placeholder:"Port"},null,512),[[v,s.value.wisun_port]])],64)):f("",!0),s.value.val==="ETH_STATIC"?(u(),p(w,{key:2},[i(l("input",{"onUpdate:modelValue":t[6]||(t[6]=e=>s.value.eth_static_address=e),placeholder:"Address"},null,512),[[v,s.value.eth_static_address]]),i(l("input",{"onUpdate:modelValue":t[7]||(t[7]=e=>s.value.eth_static_netmask=e),placeholder:"Netmask"},null,512),[[v,s.value.eth_static_netmask]]),i(l("input",{"onUpdate:modelValue":t[8]||(t[8]=e=>s.value.eth_static_gateway=e),placeholder:"Gateway"},null,512),[[v,s.value.eth_static_gateway]])],64)):f("",!0),l("button",{type:"button",class:"primary",onClick:T},_(s.value.val==="--------"?"Get":"Set"),1)])]),l("div",E,[F,l("div",D,[i(l("select",{"onUpdate:modelValue":t[9]||(t[9]=e=>d.value.key=e)},[(u(),p(w,null,m(N,(e,r)=>l("option",{key:r},_(e),1)),64))],512),[[y,d.value.key]]),P(o,{value:d.value.val,"onUpdate:value":t[10]||(t[10]=e=>d.value.val=e),placeholder:"Password"},null,8,["value"]),l("button",{type:"button",class:"primary",onClick:U},_(d.value.val?"Set":"Get"),1)])])])])}}};export{B as default};
