diff --git a/src/dashboard.py b/src/dashboard.py index b90a2b4..9be65f9 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -20,7 +20,7 @@ import bcrypt import ifcfg import psutil import pyotp -from flask import Flask, request, render_template, session, g +from flask import Flask, request, render_template, session, g, Blueprint from json import JSONEncoder from flask_cors import CORS @@ -44,14 +44,13 @@ WG_CONF_PATH = None # Upgrade Required UPDATE = None # Flask App Configuration + app = Flask("WGDashboard") app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 5206928 app.secret_key = secrets.token_urlsafe(32) -cors = CORS(app, resources={r"/api/*": { - "origins": "*", - "methods": "DELETE, POST, GET, OPTIONS", - "allow_headers": ["Content-Type", "wg-dashboard-apikey"] -}}) + + + class ModelEncoder(JSONEncoder): def default(self, o: Any) -> Any: @@ -139,8 +138,6 @@ class DashboardLogger: except Exception as e: print(e) return False - - class PeerJobLogger: def __init__(self): @@ -1028,8 +1025,7 @@ PersistentKeepalive = {str(self.keepalive)} except Exception as e: return False return True - - + # Regex Match def regex_match(regex, text): pattern = re.compile(regex) @@ -1067,6 +1063,7 @@ class DashboardConfig: }, "Server": { "wg_conf_path": "/etc/wireguard", + "app_prefix": "", "app_ip": "0.0.0.0", "app_port": "10086", "auth_req": "true", @@ -1344,11 +1341,25 @@ def _getWireguardConfigurationAvailableIP(configName: str) -> tuple[bool, list[s return False, None +sqldb = sqlite3.connect(os.path.join(CONFIGURATION_PATH, 'db', 'wgdashboard.db'), check_same_thread=False) +sqldb.row_factory = sqlite3.Row +cursor = sqldb.cursor() + +DashboardConfig = DashboardConfig() +_, APP_PREFIX = DashboardConfig.GetConfig("Server", "app_prefix") +cors = CORS(app, resources={rf"{APP_PREFIX}/api/*": { + "origins": "*", + "methods": "DELETE, POST, GET, OPTIONS", + "allow_headers": ["Content-Type", "wg-dashboard-apikey"] +}}) + ''' API Routes ''' + + @app.before_request def auth_req(): if request.method.lower() == 'options': @@ -1383,12 +1394,16 @@ def auth_req(): DashboardConfig.APIAccessed = True else: DashboardConfig.APIAccessed = False - if ('/static/' not in request.path and "username" not in session and "/" != request.path + if ('/static/' not in request.path and "username" not in session + and (f"{(APP_PREFIX if len(APP_PREFIX) > 0 else '')}/" != request.path + and f"{(APP_PREFIX if len(APP_PREFIX) > 0 else '')}" != request.path) and "validateAuthentication" not in request.path and "authenticate" not in request.path and "getDashboardConfiguration" not in request.path and "getDashboardTheme" not in request.path and "sharePeer/get" not in request.path and "isTotpEnabled" not in request.path ): + print(request.path) + print(f"{(APP_PREFIX if len(APP_PREFIX) > 0 else '')}") response = Flask.make_response(app, { "status": False, "message": "Unauthorized access.", @@ -1398,12 +1413,12 @@ def auth_req(): response.status_code = 401 return response -@app.route('/api/handshake', methods=["GET", "OPTIONS"]) +@app.route(f'{APP_PREFIX}/api/handshake', methods=["GET", "OPTIONS"]) def API_ValidateAPIKey(): return ResponseObject(True) -@app.route('/api/validateAuthentication', methods=["GET"]) +@app.route(f'{APP_PREFIX}/api/validateAuthentication', methods=["GET"]) def API_ValidateAuthentication(): token = request.cookies.get("authToken") + "" if token == "" or "username" not in session or session["username"] != token: @@ -1411,7 +1426,7 @@ def API_ValidateAuthentication(): return ResponseObject(True) -@app.route('/api/authenticate', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/authenticate', methods=['POST']) def API_AuthenticateLogin(): data = request.get_json() if DashboardConfig.APIAccessed: @@ -1452,20 +1467,20 @@ def API_AuthenticateLogin(): return ResponseObject(False, "Sorry, your username or password is incorrect.") -@app.route('/api/signout') +@app.route(f'{APP_PREFIX}/api/signout') def API_SignOut(): resp = ResponseObject(True, "") resp.delete_cookie("authToken") return resp -@app.route('/api/getWireguardConfigurations', methods=["GET"]) +@app.route(f'{APP_PREFIX}/api/getWireguardConfigurations', methods=["GET"]) def API_getWireguardConfigurations(): # WireguardConfigurations = _getConfigurationList() return ResponseObject(data=[wc for wc in WireguardConfigurations.values()]) -@app.route('/api/addWireguardConfiguration', methods=["POST"]) +@app.route(f'{APP_PREFIX}/api/addWireguardConfiguration', methods=["POST"]) def API_addWireguardConfiguration(): data = request.get_json() keys = [ @@ -1508,7 +1523,7 @@ def API_addWireguardConfiguration(): return ResponseObject() -@app.route('/api/toggleWireguardConfiguration/') +@app.route(f'{APP_PREFIX}/api/toggleWireguardConfiguration/') def API_toggleWireguardConfiguration(): configurationName = request.args.get('configurationName') @@ -1521,12 +1536,12 @@ def API_toggleWireguardConfiguration(): return ResponseObject(toggleStatus, msg, WireguardConfigurations[configurationName].Status) -@app.route('/api/getDashboardConfiguration', methods=["GET"]) +@app.route(f'{APP_PREFIX}/api/getDashboardConfiguration', methods=["GET"]) def API_getDashboardConfiguration(): return ResponseObject(data=DashboardConfig.toJson()) -@app.route('/api/updateDashboardConfiguration', methods=["POST"]) +@app.route(f'{APP_PREFIX}/api/updateDashboardConfiguration', methods=["POST"]) def API_updateDashboardConfiguration(): data = request.get_json() for section in data['DashboardConfiguration'].keys(): @@ -1536,7 +1551,7 @@ def API_updateDashboardConfiguration(): return ResponseObject() -@app.route('/api/updateDashboardConfigurationItem', methods=["POST"]) +@app.route(f'{APP_PREFIX}/api/updateDashboardConfigurationItem', methods=["POST"]) def API_updateDashboardConfigurationItem(): data = request.get_json() if "section" not in data.keys() or "key" not in data.keys() or "value" not in data.keys(): @@ -1550,13 +1565,13 @@ def API_updateDashboardConfigurationItem(): return ResponseObject() -@app.route('/api/getDashboardAPIKeys', methods=['GET']) +@app.route(f'{APP_PREFIX}/api/getDashboardAPIKeys', methods=['GET']) def API_getDashboardAPIKeys(): if DashboardConfig.GetConfig('Server', 'dashboard_api_key'): return ResponseObject(data=DashboardConfig.DashboardAPIKeys) return ResponseObject(False, "Dashboard API Keys function is disbaled") -@app.route('/api/newDashboardAPIKey', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/newDashboardAPIKey', methods=['POST']) def API_newDashboardAPIKey(): data = request.get_json() if DashboardConfig.GetConfig('Server', 'dashboard_api_key'): @@ -1571,7 +1586,7 @@ def API_newDashboardAPIKey(): return ResponseObject(False, str(e)) return ResponseObject(False, "Dashboard API Keys function is disbaled") -@app.route('/api/deleteDashboardAPIKey', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/deleteDashboardAPIKey', methods=['POST']) def API_deleteDashboardAPIKey(): data = request.get_json() if DashboardConfig.GetConfig('Server', 'dashboard_api_key'): @@ -1581,7 +1596,7 @@ def API_deleteDashboardAPIKey(): return ResponseObject(False, "Dashboard API Keys function is disbaled") -@app.route('/api/updatePeerSettings/', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/updatePeerSettings/', methods=['POST']) def API_updatePeerSettings(configName): data = request.get_json() id = data['id'] @@ -1601,7 +1616,7 @@ def API_updatePeerSettings(configName): allowed_ip, endpoint_allowed_ip, mtu, keepalive) return ResponseObject(False, "Peer does not exist") -@app.route('/api/resetPeerData/', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/resetPeerData/', methods=['POST']) def API_resetPeerData(configName): data = request.get_json() id = data['id'] @@ -1616,7 +1631,7 @@ def API_resetPeerData(configName): -@app.route('/api/deletePeers/', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/deletePeers/', methods=['POST']) def API_deletePeers(configName: str) -> ResponseObject: data = request.get_json() peers = data['peers'] @@ -1629,7 +1644,7 @@ def API_deletePeers(configName: str) -> ResponseObject: return ResponseObject(False, "Configuration does not exist") -@app.route('/api/restrictPeers/', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/restrictPeers/', methods=['POST']) def API_restrictPeers(configName: str) -> ResponseObject: data = request.get_json() peers = data['peers'] @@ -1640,7 +1655,7 @@ def API_restrictPeers(configName: str) -> ResponseObject: return configuration.restrictPeers(peers) return ResponseObject(False, "Configuration does not exist") -@app.route('/api/sharePeer/create', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/sharePeer/create', methods=['POST']) def API_sharePeer_create(): data: dict[str, str] = request.get_json() Configuration = data.get('Configuration') @@ -1656,7 +1671,7 @@ def API_sharePeer_create(): return ResponseObject(status, message) return ResponseObject(data=AllPeerShareLinks.getLinkByID(message)) -@app.route('/api/sharePeer/update', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/sharePeer/update', methods=['POST']) def API_sharePeer_update(): data: dict[str, str] = request.get_json() ShareID: str = data.get("ShareID") @@ -1675,7 +1690,7 @@ def API_sharePeer_update(): return ResponseObject(status, message) return ResponseObject(data=AllPeerShareLinks.getLinkByID(ShareID)) -@app.route('/api/sharePeer/get', methods=['GET']) +@app.route(f'{APP_PREFIX}/api/sharePeer/get', methods=['GET']) def API_sharePeer_get(): data = request.args ShareID = data.get("ShareID") @@ -1696,7 +1711,7 @@ def API_sharePeer_get(): -@app.route('/api/allowAccessPeers/', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/allowAccessPeers/', methods=['POST']) def API_allowAccessPeers(configName: str) -> ResponseObject: data = request.get_json() peers = data['peers'] @@ -1708,7 +1723,7 @@ def API_allowAccessPeers(configName: str) -> ResponseObject: return ResponseObject(False, "Configuration does not exist") -@app.route('/api/addPeers/', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/addPeers/', methods=['POST']) def API_addPeers(configName): data = request.get_json() bulkAdd = data['bulkAdd'] @@ -1817,7 +1832,7 @@ def API_getAvailableIPs(configName): return ResponseObject(status=status, data=ips) -@app.route('/api/getWireguardConfigurationInfo', methods=["GET"]) +@app.route(f'{APP_PREFIX}/api/getWireguardConfigurationInfo', methods=["GET"]) def API_getConfigurationInfo(): configurationName = request.args.get("configurationName") if not configurationName or configurationName not in WireguardConfigurations.keys(): @@ -1829,12 +1844,12 @@ def API_getConfigurationInfo(): }) -@app.route('/api/getDashboardTheme') +@app.route(f'{APP_PREFIX}/api/getDashboardTheme') def API_getDashboardTheme(): return ResponseObject(data=DashboardConfig.GetConfig("Server", "dashboard_theme")[1]) -@app.route('/api/savePeerScheduleJob/', methods=["POST"]) +@app.route(f'{APP_PREFIX}/api/savePeerScheduleJob/', methods=["POST"]) def API_savePeerScheduleJob(): data = request.json if "Job" not in data.keys() not in WireguardConfigurations.keys(): @@ -1855,7 +1870,7 @@ def API_savePeerScheduleJob(): return ResponseObject(s, message=p) -@app.route('/api/deletePeerScheduleJob/', methods=['POST']) +@app.route(f'{APP_PREFIX}/api/deletePeerScheduleJob/', methods=['POST']) def API_deletePeerScheduleJob(): data = request.json if "Job" not in data.keys() not in WireguardConfigurations.keys(): @@ -1875,7 +1890,7 @@ def API_deletePeerScheduleJob(): return ResponseObject(s, data=p) return ResponseObject(s, message=p) -@app.route('/api/getPeerScheduleJobLogs/', methods=['GET']) +@app.route(f'{APP_PREFIX}/api/getPeerScheduleJobLogs/', methods=['GET']) def API_getPeerScheduleJobLogs(configName): if configName not in WireguardConfigurations.keys(): return ResponseObject(False, "Configuration does not exist") @@ -1892,7 +1907,7 @@ Tools ''' -@app.route('/api/ping/getAllPeersIpAddress') +@app.route(f'{APP_PREFIX}/api/ping/getAllPeersIpAddress') def API_ping_getAllPeersIpAddress(): ips = {} for c in WireguardConfigurations.values(): @@ -1919,7 +1934,7 @@ def API_ping_getAllPeersIpAddress(): return ResponseObject(data=ips) -@app.route('/api/ping/execute') +@app.route(f'{APP_PREFIX}/api/ping/execute') def API_ping_execute(): if "ipAddress" in request.args.keys() and "count" in request.args.keys(): ip = request.args['ipAddress'] @@ -1945,7 +1960,7 @@ def API_ping_execute(): return ResponseObject(False, "Please provide ipAddress and count") -@app.route('/api/traceroute/execute') +@app.route(f'{APP_PREFIX}/api/traceroute/execute') def API_traceroute_execute(): if "ipAddress" in request.args.keys() and len(request.args.get("ipAddress")) > 0: ipAddress = request.args.get('ipAddress') @@ -1987,13 +2002,13 @@ Sign Up ''' -@app.route('/api/isTotpEnabled') +@app.route(f'{APP_PREFIX}/api/isTotpEnabled') def API_isTotpEnabled(): return ( ResponseObject(data=DashboardConfig.GetConfig("Account", "enable_totp")[1] and DashboardConfig.GetConfig("Account", "totp_verified")[1])) -@app.route('/api/Welcome_GetTotpLink') +@app.route(f'{APP_PREFIX}/api/Welcome_GetTotpLink') def API_Welcome_GetTotpLink(): if not DashboardConfig.GetConfig("Account", "totp_verified")[1]: DashboardConfig.SetConfig("Account", "totp_key", pyotp.random_base32()) @@ -2003,7 +2018,7 @@ def API_Welcome_GetTotpLink(): return ResponseObject(False) -@app.route('/api/Welcome_VerifyTotpLink', methods=["POST"]) +@app.route(f'{APP_PREFIX}/api/Welcome_VerifyTotpLink', methods=["POST"]) def API_Welcome_VerifyTotpLink(): data = request.get_json() totp = pyotp.TOTP(DashboardConfig.GetConfig("Account", "totp_key")[1]).now() @@ -2013,7 +2028,7 @@ def API_Welcome_VerifyTotpLink(): return ResponseObject(totp == data['totp']) -@app.route('/api/Welcome_Finish', methods=["POST"]) +@app.route(f'{APP_PREFIX}/api/Welcome_Finish', methods=["POST"]) def API_Welcome_Finish(): data = request.get_json() if DashboardConfig.GetConfig("Other", "welcome_session")[1]: @@ -2040,12 +2055,13 @@ def API_Welcome_Finish(): return ResponseObject() -@app.route('/', methods=['GET']) +@app.route(f'{APP_PREFIX}/', methods=['GET']) def index(): """ Index page related @return: Template """ + print(APP_PREFIX) return render_template('index.html') @@ -2086,10 +2102,7 @@ if sys.version_info < (3, 10): else: from typing import ParamSpec -sqldb = sqlite3.connect(os.path.join(CONFIGURATION_PATH, 'db', 'wgdashboard.db'), check_same_thread=False) -sqldb.row_factory = sqlite3.Row -cursor = sqldb.cursor() -DashboardConfig = DashboardConfig() + AllPeerShareLinks: PeerShareLinks = PeerShareLinks() AllPeerJobs: PeerJobs = PeerJobs() @@ -2099,10 +2112,11 @@ _, app_ip = DashboardConfig.GetConfig("Server", "app_ip") _, app_port = DashboardConfig.GetConfig("Server", "app_port") _, WG_CONF_PATH = DashboardConfig.GetConfig("Server", "wg_conf_path") + + WireguardConfigurations: dict[str, WireguardConfiguration] = {} WireguardConfigurations = _getConfigurationList() - def startThreads(): bgThread = threading.Thread(target=backGroundThread) bgThread.daemon = True diff --git a/src/static/app/dist/assets/index.js b/src/static/app/dist/assets/index.js index 6da2001..f3b6a7a 100644 --- a/src/static/app/dist/assets/index.js +++ b/src/static/app/dist/assets/index.js @@ -65,4 +65,4 @@ The chosen QR Code version cannot contain this amount of data. Minimum version required to store current data is: `+o+`. `);const r=tW(t,n,i),a=Cu.getSymbolSize(t),l=new zj(a);return Jj(l,t),Xj(l),Qj(l,t),Dd(l,n,0),t>=7&&Zj(l,t),eW(l,r),isNaN(s)&&(s=Th.getBestMask(l,Dd.bind(null,l,n))),Th.applyMask(s,l),Dd(l,n,s),{modules:l,version:t,errorCorrectionLevel:n,maskPattern:s,segments:i}}T1.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let s=Td.M,i,o;return typeof n<"u"&&(s=Td.from(n.errorCorrectionLevel,Td.M),i=Yc.from(n.version),o=Th.from(n.maskPattern),n.toSJISFunc&&Cu.setToSJISFunction(n.toSJISFunc)),sW(t,i,s,o)};var W1={},cp={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let s=n.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+n);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(o){return[o,o]}))),s.length===6&&s.push("F","F");const i=parseInt(s.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const i=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,o=s.width&&s.width>=21?s.width:void 0,r=s.scale||4;return{width:o,scale:o?4:r,margin:i,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,i){return i.width&&i.width>=s+i.margin*2?i.width/(s+i.margin*2):i.scale},e.getImageWidth=function(s,i){const o=e.getScale(s,i);return Math.floor((s+i.margin*2)*o)},e.qrToImageData=function(s,i,o){const r=i.modules.size,a=i.modules.data,l=e.getScale(r,o),c=Math.floor((r+o.margin*2)*l),u=o.margin*l,d=[o.color.light,o.color.dark];for(let f=0;f=u&&p>=u&&f"u"&&(!r||!r.getContext)&&(l=r,r=void 0),r||(c=s()),l=t.getOptions(l);const u=t.getImageWidth(o.modules.size,l),d=c.getContext("2d"),f=d.createImageData(u,u);return t.qrToImageData(f.data,o,l),n(d,c,u),d.putImageData(f,0,0),c},e.renderToDataURL=function(o,r,a){let l=a;typeof l>"u"&&(!r||!r.getContext)&&(l=r,r=void 0),l||(l={});const c=e.render(o,r,l),u=l.type||"image/png",d=l.rendererOpts||{};return c.toDataURL(u,d.quality)}})(W1);var z1={};const iW=cp;function mv(e,t){const n=e.a/255,s=t+'="'+e.hex+'"';return n<1?s+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':s}function Od(e,t,n){let s=e+t;return typeof n<"u"&&(s+=" "+n),s}function oW(e,t,n){let s="",i=0,o=!1,r=0;for(let a=0;a0&&l>0&&e[a-1]||(s+=o?Od("M",l+n,.5+c+n):Od("m",i,0),i=0,o=!1),l+1':"",c="',u='viewBox="0 0 '+a+" "+a+'"',f=''+l+c+` `;return typeof s=="function"&&s(null,f),f};const rW=bj,Dh=T1,Y1=W1,aW=z1;function up(e,t,n,s,i){const o=[].slice.call(arguments,1),r=o.length,a=typeof o[r-1]=="function";if(!a&&!rW())throw new Error("Callback required as last argument");if(a){if(r<2)throw new Error("Too few arguments provided");r===2?(i=n,n=t,t=s=void 0):r===3&&(t.getContext&&typeof i>"u"?(i=s,s=void 0):(i=s,s=n,n=t,t=void 0))}else{if(r<1)throw new Error("Too few arguments provided");return r===1?(n=t,t=s=void 0):r===2&&!t.getContext&&(s=n,n=t,t=void 0),new Promise(function(l,c){try{const u=Dh.create(n,s);l(e(u,t,s))}catch(u){c(u)}})}try{const l=Dh.create(n,s);i(null,e(l,t,s))}catch(l){i(l)}}Bo.create=Dh.create;Bo.toCanvas=up.bind(null,Y1.render);Bo.toDataURL=up.bind(null,Y1.renderToDataURL);Bo.toString=up.bind(null,function(e,t,n){return aW.render(e,n)});const lW={name:"peerQRCode",props:{peerConfigData:String},mounted(){Bo.toCanvas(document.querySelector("#qrcode"),this.peerConfigData,e=>{e&&console.error(e)})}},cW={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0"},uW={class:"container d-flex h-100 w-100"},dW={class:"m-auto modal-dialog-centered dashboardModal justify-content-center"},hW={class:"card rounded-3 shadow"},fW={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},pW=h("h4",{class:"mb-0"},"QR Code",-1),gW={class:"card-body"},mW={id:"qrcode",class:"rounded-3 shadow",ref:"qrcode"};function _W(e,t,n,s,i,o){return O(),F("div",cW,[h("div",uW,[h("div",dW,[h("div",hW,[h("div",fW,[pW,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=r=>this.$emit("close"))})]),h("div",gW,[h("canvas",mW,null,512)])])])])])}const vW=ze(lW,[["render",_W]]),bW={name:"nameInput",props:{bulk:Boolean,data:Object,saving:Boolean}},yW=h("label",{for:"peer_name_textbox",class:"form-label"},[h("small",{class:"text-muted"},"Name")],-1),wW=["disabled"];function xW(e,t,n,s,i,o){return O(),F("div",{class:Ee({inactiveField:this.bulk})},[yW,Re(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:this.saving||this.bulk,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.name=r),id:"peer_name_textbox",placeholder:""},null,8,wW),[[We,this.data.name]])],2)}const kW=ze(bW,[["render",xW]]),SW={name:"privatePublicKeyInput",props:{data:Object,saving:Boolean,bulk:Boolean},setup(){return{dashboardStore:et()}},data(){return{keypair:{publicKey:"",privateKey:"",presharedKey:""},editKey:!1,error:!1}},methods:{genKeyPair(){this.editKey=!1,this.keypair=window.wireguard.generateKeypair(),this.data.private_key=this.keypair.privateKey,this.data.public_key=this.keypair.publicKey},checkMatching(){try{window.wireguard.generatePublicKey(this.keypair.privateKey)!==this.keypair.publicKey&&(this.error=!0,this.dashboardStore.newMessage("WGDashboard","Private Key and Public Key does not match.","danger"))}catch{this.error=!0,this.data.private_key="",this.data.public_key=""}}},mounted(){this.genKeyPair()},watch:{keypair:{deep:!0,handler(){this.error=!1,this.checkMatching()}}}},AW=h("label",{for:"peer_private_key_textbox",class:"form-label"},[h("small",{class:"text-muted"},[ye("Private Key "),h("code",null,"(Required for QR Code and Download)")])],-1),$W={class:"input-group"},CW=["disabled"],EW=["disabled"],PW=h("i",{class:"bi bi-arrow-repeat"},null,-1),TW=[PW],MW={class:"d-flex"},DW=h("label",{for:"public_key",class:"form-label"},[h("small",{class:"text-muted"},[ye("Public Key "),h("code",null,"(Required)")])],-1),OW={class:"form-check form-switch ms-auto"},IW=["disabled"],RW=h("label",{class:"form-check-label",for:"enablePublicKeyEdit"},[h("small",null,"Edit")],-1),LW=["disabled"];function NW(e,t,n,s,i,o){return O(),F("div",{class:Ee(["d-flex gap-2 flex-column",{inactiveField:this.bulk}])},[h("div",null,[AW,h("div",$W,[Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-start-3",{"is-invalid":this.error}]),"onUpdate:modelValue":t[0]||(t[0]=r=>this.keypair.privateKey=r),disabled:!this.editKey||this.bulk,onBlur:t[1]||(t[1]=r=>this.checkMatching()),id:"peer_private_key_textbox"},null,42,CW),[[We,this.keypair.privateKey]]),h("button",{class:"btn btn-outline-info btn-sm rounded-end-3",onClick:t[2]||(t[2]=r=>this.genKeyPair()),disabled:this.bulk,type:"button",id:"button-addon2"},TW,8,EW)])]),h("div",null,[h("div",MW,[DW,h("div",OW,[Re(h("input",{class:"form-check-input",type:"checkbox",role:"switch",disabled:this.bulk,id:"enablePublicKeyEdit","onUpdate:modelValue":t[3]||(t[3]=r=>this.editKey=r)},null,8,IW),[[In,this.editKey]]),RW])]),Re(h("input",{class:Ee(["form-control-sm form-control rounded-3",{"is-invalid":this.error}]),"onUpdate:modelValue":t[4]||(t[4]=r=>this.keypair.publicKey=r),onBlur:t[5]||(t[5]=r=>this.checkMatching()),disabled:!this.editKey||this.bulk,type:"text",id:"public_key"},null,42,LW),[[We,this.keypair.publicKey]])])],2)}const FW=ze(SW,[["render",NW]]),BW={name:"allowedIPsInput",props:{data:Object,saving:Boolean,bulk:Boolean,availableIp:void 0},data(){return{allowedIp:[],availableIpSearchString:"",customAvailableIp:"",allowedIpFormatError:!1}},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},computed:{searchAvailableIps(){return this.availableIpSearchString?this.availableIp.filter(e=>e.includes(this.availableIpSearchString)&&!this.data.allowed_ips.includes(e)):this.availableIp.filter(e=>!this.data.allowed_ips.includes(e))}},methods:{addAllowedIp(e){return this.store.checkCIDR(e)?(this.data.allowed_ips.push(e),!0):!1}},watch:{customAvailableIp(){this.allowedIpFormatError=!1},availableIp(){this.availableIp!==void 0&&this.availableIp.length>0&&this.addAllowedIp(this.availableIp[0])}},mounted(){}},pl=e=>(en("data-v-2af3b91a"),e=e(),tn(),e),VW=pl(()=>h("label",{for:"peer_allowed_ip_textbox",class:"form-label"},[h("small",{class:"text-muted"},[ye("Allowed IPs "),h("code",null,"(Required)")])],-1)),HW=["onClick"],jW=pl(()=>h("i",{class:"bi bi-x-circle-fill ms-1"},null,-1)),WW=[jW],zW={class:"d-flex gap-2 align-items-center"},YW={class:"input-group"},UW=["disabled"],KW=["disabled"],qW=pl(()=>h("i",{class:"bi bi-plus-lg"},null,-1)),GW=[qW],JW=pl(()=>h("small",{class:"text-muted"},"or",-1)),XW={class:"dropdown flex-grow-1"},QW=["disabled"],ZW=pl(()=>h("i",{class:"bi bi-filter-circle me-2"},null,-1)),ez={key:0,class:"dropdown-menu mt-2 shadow w-100 dropdown-menu-end rounded-3",style:{"overflow-y":"scroll","max-height":"270px",width:"300px !important"}},tz={class:"px-3 pb-2 pt-1"},nz=["onClick"],sz={class:"me-auto"},iz={key:0},oz={class:"px-3 text-muted"};function rz(e,t,n,s,i,o){return O(),F("div",{class:Ee({inactiveField:this.bulk})},[VW,h("div",{class:Ee(["d-flex gap-2 flex-wrap",{"mb-2":this.data.allowed_ips.length>0}])},[$e(Wi,{name:"list"},{default:Te(()=>[(O(!0),F(Me,null,Ke(this.data.allowed_ips,(r,a)=>(O(),F("span",{class:"badge rounded-pill text-bg-success",key:r},[ye(ve(r)+" ",1),h("a",{role:"button",onClick:l=>this.data.allowed_ips.splice(a,1)},WW,8,HW)]))),128))]),_:1})],2),h("div",zW,[h("div",YW,[Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-start-3",{"is-invalid":this.allowedIpFormatError}]),placeholder:"Enter IP Address/CIDR","onUpdate:modelValue":t[0]||(t[0]=r=>i.customAvailableIp=r),disabled:n.bulk},null,10,UW),[[We,i.customAvailableIp]]),h("button",{class:"btn btn-outline-success btn-sm rounded-end-3",disabled:n.bulk||!this.customAvailableIp,onClick:t[1]||(t[1]=r=>{this.addAllowedIp(this.customAvailableIp)?this.customAvailableIp="":this.allowedIpFormatError=!0,this.dashboardStore.newMessage("WGDashboard","Allowed IP is invalid","danger")}),type:"button",id:"button-addon2"},GW,8,KW)]),JW,h("div",XW,[h("button",{class:"btn btn-outline-secondary btn-sm dropdown-toggle rounded-3 w-100",disabled:!n.availableIp||n.bulk,"data-bs-auto-close":"outside",type:"button","data-bs-toggle":"dropdown","aria-expanded":"false"},[ZW,ye(" Pick Available IP ")],8,QW),this.availableIp?(O(),F("ul",ez,[h("li",null,[h("div",tz,[Re(h("input",{class:"form-control form-control-sm rounded-3","onUpdate:modelValue":t[2]||(t[2]=r=>this.availableIpSearchString=r),placeholder:"Search..."},null,512),[[We,this.availableIpSearchString]])])]),(O(!0),F(Me,null,Ke(this.searchAvailableIps,r=>(O(),F("li",null,[h("a",{class:"dropdown-item d-flex",role:"button",onClick:a=>this.addAllowedIp(r)},[h("span",sz,[h("small",null,ve(r),1)])],8,nz)]))),256)),this.searchAvailableIps.length===0?(O(),F("li",iz,[h("small",oz,'No available IP containing "'+ve(this.availableIpSearchString)+'"',1)])):ae("",!0)])):ae("",!0)])])],2)}const az=ze(BW,[["render",rz],["__scopeId","data-v-2af3b91a"]]),lz={name:"dnsInput",props:{data:Object,saving:Boolean},data(){return{error:!1,dns:JSON.parse(JSON.stringify(this.data.DNS))}},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},methods:{checkDNS(){if(this.dns){let e=this.dns.split(",").map(t=>t.replaceAll(" ",""));for(let t in e)if(!this.store.regexCheckIP(e[t])){this.error||this.dashboardStore.newMessage("WGDashboard","DNS is invalid","danger"),this.error=!0,this.data.DNS="";return}this.error=!1,this.data.DNS=this.dns}}},watch:{dns(){this.checkDNS()}}},cz=h("label",{for:"peer_DNS_textbox",class:"form-label"},[h("small",{class:"text-muted"},"DNS")],-1),uz=["disabled"];function dz(e,t,n,s,i,o){return O(),F("div",null,[cz,Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-3",{"is-invalid":this.error}]),disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.dns=r),id:"peer_DNS_textbox"},null,10,uz),[[We,this.dns]])])}const hz=ze(lz,[["render",dz]]),fz={name:"endpointAllowedIps",props:{data:Object,saving:Boolean},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},data(){return{endpointAllowedIps:JSON.parse(JSON.stringify(this.data.endpoint_allowed_ip)),error:!1}},methods:{checkAllowedIP(){let e=this.endpointAllowedIps.split(",").map(t=>t.replaceAll(" ",""));for(let t in e)if(!this.store.checkCIDR(e[t])){this.error||this.dashboardStore.newMessage("WGDashboard","Endpoint Allowed IP is invalid.","danger"),this.data.endpoint_allowed_ip="",this.error=!0;return}this.error=!1,this.data.endpoint_allowed_ip=this.endpointAllowedIps}},watch:{endpointAllowedIps(){this.checkAllowedIP()}}},pz=h("label",{for:"peer_endpoint_allowed_ips",class:"form-label"},[h("small",{class:"text-muted"},[ye("Endpoint Allowed IPs "),h("code",null,"(Required)")])],-1),gz=["disabled"];function mz(e,t,n,s,i,o){return O(),F("div",null,[pz,Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-3",{"is-invalid":i.error}]),disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.endpointAllowedIps=r),onBlur:t[1]||(t[1]=r=>this.checkAllowedIP()),id:"peer_endpoint_allowed_ips"},null,42,gz),[[We,this.endpointAllowedIps]])])}const _z=ze(fz,[["render",mz]]),vz={name:"presharedKeyInput",props:{data:Object,saving:Boolean}},bz=h("label",{for:"peer_preshared_key_textbox",class:"form-label"},[h("small",{class:"text-muted"},"Pre-Shared Key")],-1),yz=["disabled"];function wz(e,t,n,s,i,o){return O(),F("div",null,[bz,Re(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.preshared_key=r),id:"peer_preshared_key_textbox"},null,8,yz),[[We,this.data.preshared_key]])])}const xz=ze(vz,[["render",wz]]),kz={name:"mtuInput",props:{data:Object,saving:Boolean}},Sz=h("label",{for:"peer_mtu",class:"form-label"},[h("small",{class:"text-muted"},"MTU")],-1),Az=["disabled"];function $z(e,t,n,s,i,o){return O(),F("div",null,[Sz,Re(h("input",{type:"number",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.mtu=r),id:"peer_mtu"},null,8,Az),[[We,this.data.mtu]])])}const Cz=ze(kz,[["render",$z]]),Ez={name:"persistentKeepAliveInput",props:{data:Object,saving:Boolean}},Pz=h("label",{for:"peer_keep_alive",class:"form-label"},[h("small",{class:"text-muted"},"Persistent Keepalive")],-1),Tz=["disabled"];function Mz(e,t,n,s,i,o){return O(),F("div",null,[Pz,Re(h("input",{type:"number",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.keepalive=r),id:"peer_keep_alive"},null,8,Tz),[[We,this.data.keepalive]])])}const Dz=ze(Ez,[["render",Mz]]),Oz={name:"bulkAdd",props:{saving:Boolean,data:Object,availableIp:void 0}},Iz={class:"form-check form-switch"},Rz=["disabled"],Lz=h("label",{class:"form-check-label me-2",for:"bulk_add"},[h("small",null,[h("strong",null,"Bulk Add")])],-1),Nz=h("small",{class:"text-muted d-block"}," By adding peers by bulk, each peer's name will be auto generated, and Allowed IP will be assign to the next available IP. ",-1),Fz=[Nz],Bz={key:0,class:"form-group"},Vz=["max"],Hz={class:"text-muted"};function jz(e,t,n,s,i,o){return O(),F("div",null,[h("div",Iz,[Re(h("input",{class:"form-check-input",type:"checkbox",role:"switch",disabled:!this.availableIp,id:"bulk_add","onUpdate:modelValue":t[0]||(t[0]=r=>this.data.bulkAdd=r)},null,8,Rz),[[In,this.data.bulkAdd]]),Lz]),h("p",{class:Ee({"mb-0":!this.data.bulkAdd})},Fz,2),this.data.bulkAdd?(O(),F("div",Bz,[Re(h("input",{class:"form-control form-control-sm rounded-3 mb-1",type:"number",min:"1",max:this.availableIp.length,"onUpdate:modelValue":t[1]||(t[1]=r=>this.data.bulkAddAmount=r),placeholder:"How many peers you want to add?"},null,8,Vz),[[We,this.data.bulkAddAmount]]),h("small",Hz,[ye(" You can add up to "),h("strong",null,ve(this.availableIp.length),1),ye(" peers ")])])):ae("",!0)])}const Wz=ze(Oz,[["render",jz]]),zz={name:"peerCreate",components:{BulkAdd:Wz,PersistentKeepAliveInput:Dz,MtuInput:Cz,PresharedKeyInput:xz,EndpointAllowedIps:_z,DnsInput:hz,AllowedIPsInput:az,PrivatePublicKeyInput:FW,NameInput:kW},data(){return{data:{bulkAdd:!1,bulkAddAmount:"",name:"",allowed_ips:[],private_key:"",public_key:"",DNS:this.dashboardStore.Configuration.Peers.peer_global_dns,endpoint_allowed_ip:this.dashboardStore.Configuration.Peers.peer_endpoint_allowed_ip,keepalive:parseInt(this.dashboardStore.Configuration.Peers.peer_keep_alive),mtu:parseInt(this.dashboardStore.Configuration.Peers.peer_mtu),preshared_key:""},availableIp:void 0,availableIpSearchString:"",saving:!1,allowedIpDropdown:void 0}},mounted(){Tt("/api/getAvailableIPs/"+this.$route.params.id,{},e=>{e.status&&(this.availableIp=e.data)})},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},methods:{peerCreate(){this.saving=!0,dt("/api/addPeers/"+this.$route.params.id,this.data,e=>{e.status?(this.$router.push(`/configuration/${this.$route.params.id}/peers`),this.dashboardStore.newMessage("Server","Peer create successfully","success")):this.dashboardStore.newMessage("Server",e.message,"danger"),this.saving=!1})}},computed:{allRequireFieldsFilled(){let e=!0;return this.data.bulkAdd?(this.data.bulkAddAmount.length===0||this.data.bulkAddAmount>this.availableIp.length)&&(e=!1):["allowed_ips","private_key","public_key","endpoint_allowed_ip","keepalive","mtu"].forEach(n=>{this.data[n].length===0&&(e=!1)}),e}},watch:{bulkAdd(e){e||(this.data.bulkAddAmount="")},"data.bulkAddAmount"(){this.data.bulkAddAmount>this.availableIp.length&&(this.data.bulkAddAmount=this.availableIp.length)}}},Eu=e=>(en("data-v-c3292318"),e=e(),tn(),e),Yz={class:"container"},Uz={class:"mb-4"},Kz=Eu(()=>h("h3",{class:"mb-0 text-body"},[h("i",{class:"bi bi-chevron-left"})],-1)),qz=Eu(()=>h("h3",{class:"text-body mb-0"},"Add Peers",-1)),Gz={class:"d-flex flex-column gap-2"},Jz=Eu(()=>h("hr",{class:"mb-0 mt-2"},null,-1)),Xz=Eu(()=>h("hr",{class:"mb-0 mt-2"},null,-1)),Qz={class:"row"},Zz={key:0,class:"col-sm"},eY={class:"col-sm"},tY={class:"col-sm"},nY={class:"d-flex mt-2"},sY=["disabled"],iY={key:0,class:"bi bi-plus-circle-fill me-2"};function oY(e,t,n,s,i,o){const r=je("RouterLink"),a=je("BulkAdd"),l=je("NameInput"),c=je("PrivatePublicKeyInput"),u=je("AllowedIPsInput"),d=je("EndpointAllowedIps"),f=je("DnsInput"),p=je("PresharedKeyInput"),m=je("MtuInput"),_=je("PersistentKeepAliveInput");return O(),F("div",Yz,[h("div",Uz,[$e(r,{to:"peers",is:"div",class:"d-flex align-items-center gap-4 text-decoration-none"},{default:Te(()=>[Kz,qz]),_:1})]),h("div",Gz,[$e(a,{saving:i.saving,data:this.data,availableIp:this.availableIp},null,8,["saving","data","availableIp"]),Jz,this.data.bulkAdd?ae("",!0):(O(),Ne(l,{key:0,saving:i.saving,data:this.data},null,8,["saving","data"])),this.data.bulkAdd?ae("",!0):(O(),Ne(c,{key:1,saving:i.saving,data:i.data},null,8,["saving","data"])),this.data.bulkAdd?ae("",!0):(O(),Ne(u,{key:2,availableIp:this.availableIp,saving:i.saving,data:i.data},null,8,["availableIp","saving","data"])),$e(d,{saving:i.saving,data:i.data},null,8,["saving","data"]),$e(f,{saving:i.saving,data:i.data},null,8,["saving","data"]),Xz,h("div",Qz,[this.data.bulkAdd?ae("",!0):(O(),F("div",Zz,[$e(p,{saving:i.saving,data:i.data,bulk:this.data.bulkAdd},null,8,["saving","data","bulk"])])),h("div",eY,[$e(m,{saving:i.saving,data:i.data},null,8,["saving","data"])]),h("div",tY,[$e(_,{saving:i.saving,data:i.data},null,8,["saving","data"])])]),h("div",nY,[h("button",{class:"ms-auto btn btn-dark btn-brand rounded-3 px-3 py-2 shadow",disabled:!this.allRequireFieldsFilled||this.saving,onClick:t[0]||(t[0]=b=>this.peerCreate())},[this.saving?ae("",!0):(O(),F("i",iY)),ye(" "+ve(this.saving?"Saving...":"Add"),1)],8,sY)])])])}const U1=ze(zz,[["render",oY],["__scopeId","data-v-c3292318"]]),rY={name:"scheduleDropdown",props:{options:Array,data:String,edit:!1},setup(e){e.data===void 0&&this.$emit("update",this.options[0].value)},computed:{currentSelection(){return this.options.find(e=>e.value===this.data)}}},aY={class:"dropdown scheduleDropdown"},lY={class:"dropdown-menu rounded-3 shadow",style:{"font-size":"0.875rem",width:"200px"}},cY=["onClick"],uY={key:0,class:"bi bi-check ms-auto"};function dY(e,t,n,s,i,o){return O(),F("div",aY,[h("button",{class:Ee(["btn btn-sm btn-outline-primary rounded-3",{"disabled border-transparent":!n.edit}]),type:"button","data-bs-toggle":"dropdown","aria-expanded":"false"},[h("samp",null,ve(this.currentSelection.display),1)],2),h("ul",lY,[n.edit?(O(!0),F(Me,{key:0},Ke(this.options,r=>(O(),F("li",null,[h("a",{class:"dropdown-item d-flex align-items-center",role:"button",onClick:a=>e.$emit("update",r.value)},[h("samp",null,ve(r.display),1),r.value===this.currentSelection.value?(O(),F("i",uY)):ae("",!0)],8,cY)]))),256)):ae("",!0)])])}const K1=ze(rY,[["render",dY],["__scopeId","data-v-6a5aba2a"]]),hY={name:"schedulePeerJob",components:{VueDatePicker:ll,ScheduleDropdown:K1},props:{dropdowns:Array[Object],pjob:Object,viewOnly:!1},setup(e){const t=be({}),n=be(!1),s=be(!1);t.value=JSON.parse(JSON.stringify(e.pjob)),t.value.CreationDate||(n.value=!0,s.value=!0);const i=et();return{job:t,edit:n,newJob:s,store:i}},data(){return{inputType:void 0}},watch:{pjob:{deep:!0,immediate:!0,handler(e){this.edit||(this.job=JSON.parse(JSON.stringify(e)))}}},methods:{save(){this.job.Field&&this.job.Operator&&this.job.Action&&this.job.Value?dt("/api/savePeerScheduleJob/",{Job:this.job},e=>{e.status?(this.edit=!1,this.store.newMessage("Server","Job Saved!","success"),console.log(e.data),this.$emit("refresh",e.data[0]),this.newJob=!1):this.store.newMessage("Server",e.message,"danger")}):this.alert()},alert(){let e="animate__flash",t=this.$el.querySelectorAll(".scheduleDropdown"),n=this.$el.querySelectorAll("input");t.forEach(s=>s.classList.add("animate__animated",e)),n.forEach(s=>s.classList.add("animate__animated",e)),setTimeout(()=>{t.forEach(s=>s.classList.remove("animate__animated",e)),n.forEach(s=>s.classList.remove("animate__animated",e))},2e3)},reset(){this.job.CreationDate?(this.job=JSON.parse(JSON.stringify(this.pjob)),this.edit=!1):this.$emit("delete")},delete(){this.job.CreationDate&&dt("/api/deletePeerScheduleJob/",{Job:this.job},e=>{e.status?this.store.newMessage("Server","Job Deleted!","success"):(this.store.newMessage("Server",e.message,"danger"),this.$emit("delete"))}),this.$emit("delete")},parseTime(e){e&&(this.job.Value=Cn(e).format("YYYY-MM-DD HH:mm:ss"))}}},jr=e=>(en("data-v-811b149e"),e=e(),tn(),e),fY={class:"card-header bg-transparent text-muted border-0"},pY={key:0,class:"d-flex"},gY=jr(()=>h("strong",{class:"me-auto"},"Job ID",-1)),mY={key:1},_Y=jr(()=>h("span",{class:"badge text-bg-warning"},"Unsaved Job",-1)),vY=[_Y],bY={class:"card-body pt-1",style:{"font-family":"var(--bs-font-monospace)"}},yY={class:"d-flex gap-2 align-items-center mb-2"},wY=jr(()=>h("samp",null," if ",-1)),xY=jr(()=>h("samp",null," is ",-1)),kY=["disabled"],SY={class:"px-5 d-flex gap-2 align-items-center"},AY=jr(()=>h("samp",null,"then",-1)),$Y={class:"d-flex gap-3"},CY=jr(()=>h("samp",null,"}",-1)),EY={key:0,class:"ms-auto d-flex gap-3"},PY={key:1,class:"ms-auto d-flex gap-3"};function TY(e,t,n,s,i,o){var l;const r=je("ScheduleDropdown"),a=je("VueDatePicker");return O(),F("div",{class:Ee(["card shadow-sm rounded-3 mb-2",{"border-warning-subtle":this.newJob}])},[h("div",fY,[this.newJob?(O(),F("small",mY,vY)):(O(),F("small",pY,[gY,h("samp",null,ve(this.job.JobID),1)]))]),h("div",bY,[h("div",yY,[wY,$e(r,{edit:s.edit,options:this.dropdowns.Field,data:this.job.Field,onUpdate:t[0]||(t[0]=c=>{this.job.Field=c})},null,8,["edit","options","data"]),xY,$e(r,{edit:s.edit,options:this.dropdowns.Operator,data:this.job.Operator,onUpdate:t[1]||(t[1]=c=>this.job.Operator=c)},null,8,["edit","options","data"]),this.job.Field==="date"?(O(),Ne(a,{key:0,is24:!0,"min-date":new Date,"model-value":this.job.Value,"onUpdate:modelValue":this.parseTime,"time-picker-inline":"",format:"yyyy-MM-dd HH:mm:ss","preview-format":"yyyy-MM-dd HH:mm:ss",clearable:!1,disabled:!s.edit,dark:this.store.Configuration.Server.dashboard_theme==="dark"},null,8,["min-date","model-value","onUpdate:modelValue","disabled","dark"])):Re((O(),F("input",{key:1,class:"form-control form-control-sm form-control-dark rounded-3 flex-grow-1",disabled:!s.edit,"onUpdate:modelValue":t[2]||(t[2]=c=>this.job.Value=c),style:{width:"auto"}},null,8,kY)),[[We,this.job.Value]]),h("samp",null,ve((l=this.dropdowns.Field.find(c=>c.value===this.job.Field))==null?void 0:l.unit)+" { ",1)]),h("div",SY,[AY,$e(r,{edit:s.edit,options:this.dropdowns.Action,data:this.job.Action,onUpdate:t[3]||(t[3]=c=>this.job.Action=c)},null,8,["edit","options","data"])]),h("div",$Y,[CY,this.edit?(O(),F("div",PY,[h("a",{role:"button",class:"text-secondary text-decoration-none",onClick:t[6]||(t[6]=c=>this.reset())},"[C] Cancel"),h("a",{role:"button",class:"text-primary ms-auto text-decoration-none",onClick:t[7]||(t[7]=c=>this.save())},"[S] Save")])):(O(),F("div",EY,[h("a",{role:"button",class:"ms-auto text-decoration-none",onClick:t[4]||(t[4]=c=>this.edit=!0)},"[E] Edit"),h("a",{role:"button",onClick:t[5]||(t[5]=c=>this.delete()),class:"text-danger text-decoration-none"},"[D] Delete")]))])])],2)}const q1=ze(hY,[["render",TY],["__scopeId","data-v-811b149e"]]),MY={name:"peerJobs",setup(){return{store:Bn()}},props:{selectedPeer:Object},components:{SchedulePeerJob:q1,ScheduleDropdown:K1},data(){return{}},methods:{deleteJob(e){this.selectedPeer.jobs=this.selectedPeer.jobs.filter(t=>t.JobID!==e.JobID)},addJob(){this.selectedPeer.jobs.unshift(JSON.parse(JSON.stringify({JobID:Ms().toString(),Configuration:this.selectedPeer.configuration.Name,Peer:this.selectedPeer.id,Field:this.store.PeerScheduleJobs.dropdowns.Field[0].value,Operator:this.store.PeerScheduleJobs.dropdowns.Operator[0].value,Value:"",CreationDate:"",ExpireDate:"",Action:this.store.PeerScheduleJobs.dropdowns.Action[0].value})))}}},dp=e=>(en("data-v-31a1606a"),e=e(),tn(),e),DY={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},OY={class:"container d-flex h-100 w-100"},IY={class:"m-auto modal-dialog-centered dashboardModal"},RY={class:"card rounded-3 shadow",style:{width:"700px"}},LY={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-2"},NY=dp(()=>h("h4",{class:"mb-0 fw-normal"},[ye("Schedule Jobs "),h("strong")],-1)),FY={class:"card-body px-4 pb-4 pt-2 position-relative"},BY={class:"d-flex align-items-center mb-3"},VY=dp(()=>h("i",{class:"bi bi-plus-lg me-2"},null,-1)),HY={class:"card shadow-sm",key:"none",style:{height:"153px"}},jY=dp(()=>h("div",{class:"card-body text-muted text-center d-flex"},[h("h6",{class:"m-auto"},"This peer does not have any job yet.")],-1)),WY=[jY];function zY(e,t,n,s,i,o){const r=je("SchedulePeerJob");return O(),F("div",DY,[h("div",OY,[h("div",IY,[h("div",RY,[h("div",LY,[NY,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=a=>this.$emit("close"))})]),h("div",FY,[h("div",BY,[h("button",{class:"btn bg-primary-subtle border-1 border-primary-subtle text-primary-emphasis rounded-3 shadow",onClick:t[1]||(t[1]=a=>this.addJob())},[VY,ye(" Job ")])]),$e(Wi,{name:"schedulePeerJobTransition",tag:"div",class:"position-relative"},{default:Te(()=>[(O(!0),F(Me,null,Ke(this.selectedPeer.jobs,(a,l)=>(O(),Ne(r,{onRefresh:t[2]||(t[2]=c=>this.$emit("refresh")),onDelete:c=>this.deleteJob(a),dropdowns:this.store.PeerScheduleJobs.dropdowns,key:a.JobID,pjob:a},null,8,["onDelete","dropdowns","pjob"]))),128)),this.selectedPeer.jobs.length===0?(O(),F("div",HY,WY)):ae("",!0)]),_:1})])])])])])}const YY=ze(MY,[["render",zY],["__scopeId","data-v-31a1606a"]]),UY={name:"peerJobsAllModal",setup(){return{store:Bn()}},components:{SchedulePeerJob:q1},props:{configurationPeers:Array[Object]},methods:{getuuid(){return Ms()}},computed:{getAllJobs(){return this.configurationPeers.filter(e=>e.jobs.length>0)}}},KY={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},qY={class:"container d-flex h-100 w-100"},GY={class:"m-auto modal-dialog-centered dashboardModal"},JY={class:"card rounded-3 shadow",style:{width:"700px"}},XY={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-2"},QY=h("h4",{class:"mb-0 fw-normal"},"All Active Jobs ",-1),ZY={class:"card-body px-4 pb-4 pt-2"},eU={key:0,class:"accordion",id:"peerJobsLogsModalAccordion"},tU={class:"accordion-header"},nU=["data-bs-target"],sU={key:0},iU={class:"text-muted"},oU=["id"],rU={class:"accordion-body"},aU={key:1,class:"card shadow-sm",style:{height:"153px"}},lU=h("div",{class:"card-body text-muted text-center d-flex"},[h("h6",{class:"m-auto"},"No active job at the moment.")],-1),cU=[lU];function uU(e,t,n,s,i,o){const r=je("SchedulePeerJob");return O(),F("div",KY,[h("div",qY,[h("div",GY,[h("div",JY,[h("div",XY,[QY,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=a=>this.$emit("close"))})]),h("div",ZY,[this.getAllJobs.length>0?(O(),F("div",eU,[(O(!0),F(Me,null,Ke(this.getAllJobs,(a,l)=>(O(),F("div",{class:"accordion-item",key:a.id},[h("h2",tU,[h("button",{class:"accordion-button collapsed",type:"button","data-bs-toggle":"collapse","data-bs-target":"#collapse_"+l},[h("small",null,[h("strong",null,[a.name?(O(),F("span",sU,ve(a.name)+" • ",1)):ae("",!0),h("samp",iU,ve(a.id),1)])])],8,nU)]),h("div",{id:"collapse_"+l,class:"accordion-collapse collapse","data-bs-parent":"#peerJobsLogsModalAccordion"},[h("div",rU,[(O(!0),F(Me,null,Ke(a.jobs,c=>(O(),Ne(r,{onDelete:t[1]||(t[1]=u=>this.$emit("refresh")),onRefresh:t[2]||(t[2]=u=>this.$emit("refresh")),dropdowns:this.store.PeerScheduleJobs.dropdowns,viewOnly:!0,key:c.JobID,pjob:c},null,8,["dropdowns","pjob"]))),128))])],8,oU)]))),128))])):(O(),F("div",aU,cU))])])])])])}const dU=ze(UY,[["render",uU]]),hU={name:"peerJobsLogsModal",props:{configurationInfo:Object},data(){return{dataLoading:!0,data:[],logFetchTime:void 0,showLogID:!1,showJobID:!0,showSuccessJob:!0,showFailedJob:!0,showLogAmount:10}},async mounted(){await this.fetchLog()},methods:{async fetchLog(){this.dataLoading=!0,await Tt(`/api/getPeerScheduleJobLogs/${this.configurationInfo.Name}`,{},e=>{this.data=e.data,this.logFetchTime=Cn().format("YYYY-MM-DD HH:mm:ss"),this.dataLoading=!1})}},computed:{getLogs(){return this.data.filter(e=>this.showSuccessJob&&e.Status==="1"||this.showFailedJob&&e.Status==="0")},showLogs(){return this.getLogs.slice(0,this.showLogAmount)}}},fU={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},pU={class:"container-fluid d-flex h-100 w-100"},gU={class:"m-auto mt-0 modal-dialog-centered dashboardModal",style:{width:"100%"}},mU={class:"card rounded-3 shadow w-100"},_U={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},vU=h("h4",{class:"mb-0"},"Jobs Logs",-1),bU={class:"card-body px-4 pb-4 pt-2"},yU={key:0},wU={class:"mb-2 d-flex gap-3"},xU=h("i",{class:"bi bi-arrow-clockwise me-2"},null,-1),kU={class:"d-flex gap-3 align-items-center"},SU=h("span",{class:"text-muted"},"Filter",-1),AU={class:"form-check"},$U=h("label",{class:"form-check-label",for:"jobLogsShowSuccessCheck"},[h("span",{class:"badge text-success-emphasis bg-success-subtle"},"Success")],-1),CU={class:"form-check"},EU=h("label",{class:"form-check-label",for:"jobLogsShowFailedCheck"},[h("span",{class:"badge text-danger-emphasis bg-danger-subtle"},"Failed")],-1),PU={class:"d-flex gap-3 align-items-center ms-auto"},TU=h("span",{class:"text-muted"},"Display",-1),MU={class:"form-check"},DU=h("label",{class:"form-check-label",for:"jobLogsShowJobIDCheck"}," Job ID ",-1),OU={class:"form-check"},IU=h("label",{class:"form-check-label",for:"jobLogsShowLogIDCheck"}," Log ID ",-1),RU={class:"table"},LU=h("th",{scope:"col"},"Date",-1),NU={key:0,scope:"col"},FU={key:1,scope:"col"},BU=h("th",{scope:"col"},"Status",-1),VU=h("th",{scope:"col"},"Message",-1),HU={style:{"font-size":"0.875rem"}},jU={scope:"row"},WU={key:0},zU={class:"text-muted"},YU={key:1},UU={class:"text-muted"},KU={class:"d-flex gap-2"},qU=h("i",{class:"bi bi-chevron-down me-2"},null,-1),GU=h("i",{class:"bi bi-chevron-up me-2"},null,-1),JU={key:1,class:"d-flex align-items-center flex-column"},XU=h("div",{class:"spinner-border text-body",role:"status"},[h("span",{class:"visually-hidden"},"Loading...")],-1),QU=[XU];function ZU(e,t,n,s,i,o){return O(),F("div",fU,[h("div",pU,[h("div",gU,[h("div",mU,[h("div",_U,[vU,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=r=>this.$emit("close"))})]),h("div",bU,[this.dataLoading?(O(),F("div",JU,QU)):(O(),F("div",yU,[h("p",null,"Updated at: "+ve(this.logFetchTime),1),h("div",wU,[h("button",{onClick:t[1]||(t[1]=r=>this.fetchLog()),class:"btn btn-sm rounded-3 shadow-sm text-info-emphasis bg-info-subtle border-1 border-info-subtle me-1"},[xU,ye(" Refresh ")]),h("div",kU,[SU,h("div",AU,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[2]||(t[2]=r=>this.showSuccessJob=r),id:"jobLogsShowSuccessCheck"},null,512),[[In,this.showSuccessJob]]),$U]),h("div",CU,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[3]||(t[3]=r=>this.showFailedJob=r),id:"jobLogsShowFailedCheck"},null,512),[[In,this.showFailedJob]]),EU])]),h("div",PU,[TU,h("div",MU,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[4]||(t[4]=r=>i.showJobID=r),id:"jobLogsShowJobIDCheck"},null,512),[[In,i.showJobID]]),DU]),h("div",OU,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[5]||(t[5]=r=>i.showLogID=r),id:"jobLogsShowLogIDCheck"},null,512),[[In,i.showLogID]]),IU])])]),h("table",RU,[h("thead",null,[h("tr",null,[LU,i.showLogID?(O(),F("th",NU,"Log ID")):ae("",!0),i.showJobID?(O(),F("th",FU,"Job ID")):ae("",!0),BU,VU])]),h("tbody",null,[(O(!0),F(Me,null,Ke(this.showLogs,r=>(O(),F("tr",HU,[h("th",jU,ve(r.LogDate),1),i.showLogID?(O(),F("td",WU,[h("samp",zU,ve(r.LogID),1)])):ae("",!0),i.showJobID?(O(),F("td",YU,[h("samp",UU,ve(r.JobID),1)])):ae("",!0),h("td",null,[h("span",{class:Ee(["badge",[r.Status==="1"?"text-success-emphasis bg-success-subtle":"text-danger-emphasis bg-danger-subtle"]])},ve(r.Status==="1"?"Success":"Failed"),3)]),h("td",null,ve(r.Message),1)]))),256))])]),h("div",KU,[this.getLogs.length>this.showLogAmount?(O(),F("button",{key:0,onClick:t[6]||(t[6]=r=>this.showLogAmount+=20),class:"btn btn-sm rounded-3 shadow-sm text-primary-emphasis bg-primary-subtle border-1 border-primary-subtle"},[qU,ye(" Show More ")])):ae("",!0),this.showLogAmount>20?(O(),F("button",{key:1,onClick:t[7]||(t[7]=r=>this.showLogAmount=20),class:"btn btn-sm rounded-3 shadow-sm text-primary-emphasis bg-primary-subtle border-1 border-primary-subtle"},[GU,ye(" Collapse ")])):ae("",!0)])]))])])])])])}const eK=ze(hU,[["render",ZU]]),tK={name:"peerShareLinkModal",props:{peer:Object},components:{VueDatePicker:ll},data(){return{dataCopy:void 0,loading:!1}},setup(){return{store:et()}},mounted(){this.dataCopy=JSON.parse(JSON.stringify(this.peer.ShareLink)).at(0)},watch:{"peer.ShareLink":{deep:!0,handler(e,t){t.length!==e.length&&(this.dataCopy=JSON.parse(JSON.stringify(this.peer.ShareLink)).at(0))}}},methods:{startSharing(){this.loading=!0,dt("/api/sharePeer/create",{Configuration:this.peer.configuration.Name,Peer:this.peer.id,ExpireDate:Cn().add(7,"d").format("YYYY-MM-DD HH:mm:ss")},e=>{e.status?(this.peer.ShareLink=e.data,this.dataCopy=e.data.at(0),this.store.newMessage("Server","Share link created successfully","success")):this.store.newMessage("Server","Share link failed to create. Reason: "+e.message,"danger"),this.loading=!1})},updateLinkExpireDate(){dt("/api/sharePeer/update",this.dataCopy,e=>{e.status?(this.dataCopy=e.data.at(0),this.peer.ShareLink=e.data,this.store.newMessage("Server","Link expire date updated","success")):this.store.newMessage("Server","Link expire date failed to update. Reason: "+e.message,"danger"),this.loading=!1})},stopSharing(){this.loading=!0,this.dataCopy.ExpireDate=Cn().format("YYYY-MM-DD HH:mm:ss"),this.updateLinkExpireDate()},parseTime(e){e?this.dataCopy.ExpireDate=Cn(e).format("YYYY-MM-DD HH:mm:ss"):this.dataCopy.ExpireDate=void 0,this.updateLinkExpireDate()}},computed:{getUrl(){const e=this.store.getActiveCrossServer();return e?`${e.host}/${this.$router.resolve({path:"/share",query:{ShareID:this.dataCopy.ShareID}}).href}`:window.location.origin+window.location.pathname+this.$router.resolve({path:"/share",query:{ShareID:this.dataCopy.ShareID}}).href}}},nK={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},sK={class:"container d-flex h-100 w-100"},iK={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"500px"}},oK={class:"card rounded-3 shadow flex-grow-1"},rK={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4"},aK=h("h4",{class:"mb-0"},"Share Peer",-1),lK={key:0,class:"card-body px-4 pb-4"},cK={key:0},uK=h("h6",{class:"mb-3 text-muted"}," Currently the peer is not sharing ",-1),dK=["disabled"],hK=h("i",{class:"bi bi-send-fill me-2"},null,-1),fK=[hK],pK={key:1},gK={class:"d-flex gap-2 mb-4"},mK=h("i",{class:"bi bi-link-45deg"},null,-1),_K=["href"],vK={class:"d-flex flex-column gap-2 mb-3"},bK=h("small",null,[h("i",{class:"bi bi-calendar me-2"}),ye(" Expire Date ")],-1),yK=["disabled"],wK=h("i",{class:"bi bi-send-slash-fill me-2"},null,-1),xK=[wK];function kK(e,t,n,s,i,o){const r=je("VueDatePicker");return O(),F("div",nK,[h("div",sK,[h("div",iK,[h("div",oK,[h("div",rK,[aK,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=a=>this.$emit("close"))})]),this.peer.ShareLink?(O(),F("div",lK,[this.dataCopy?(O(),F("div",pK,[h("div",gK,[mK,h("a",{href:this.getUrl,class:"text-decoration-none",target:"_blank"},ve(o.getUrl),9,_K)]),h("div",vK,[bK,$e(r,{is24:!0,"min-date":new Date,"model-value":this.dataCopy.ExpireDate,"onUpdate:modelValue":this.parseTime,"time-picker-inline":"",format:"yyyy-MM-dd HH:mm:ss","preview-format":"yyyy-MM-dd HH:mm:ss",dark:this.store.Configuration.Server.dashboard_theme==="dark"},null,8,["min-date","model-value","onUpdate:modelValue","dark"])]),h("button",{onClick:t[2]||(t[2]=a=>this.stopSharing()),disabled:this.loading,class:"w-100 btn bg-danger-subtle text-danger-emphasis border-1 border-danger-subtle rounded-3 shadow-sm"},[h("span",{class:Ee({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},xK,2),ye(" "+ve(this.loading?"Stop Sharing...":"Stop Sharing"),1)],8,yK)])):(O(),F("div",cK,[uK,h("button",{onClick:t[1]||(t[1]=a=>this.startSharing()),disabled:this.loading,class:"w-100 btn bg-success-subtle text-success-emphasis border-1 border-success-subtle rounded-3 shadow-sm"},[h("span",{class:Ee({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},fK,2),ye(" "+ve(this.loading?"Sharing...":"Start Sharing"),1)],8,dK)]))])):ae("",!0)])])])])}const SK=ze(tK,[["render",kK]]);xu.register(da,$i,wc,yc,Ta,pc,or,Ma,hh,gc,mc,_c,vh,bh,yh,fa,Za,xh,A6,Y6,X6,Z6,aH);const AK={name:"peerList",components:{PeerShareLinkModal:SK,PeerJobsLogsModal:eK,PeerJobsAllModal:dU,PeerJobs:YY,PeerCreate:U1,PeerQRCode:vW,PeerSettings:vj,PeerSearch:V5,Peer:LF,Line:FH,Bar:NH},setup(){const e=et(),t=Bn(),n=be(void 0);return{dashboardConfigurationStore:e,wireguardConfigurationStore:t,interval:n}},data(){return{configurationToggling:!1,loading:!1,error:null,configurationInfo:[],configurationPeers:[],historyDataSentDifference:[],historyDataReceivedDifference:[],historySentData:{labels:[],datasets:[{label:"Data Sent",data:[],fill:!1,borderColor:"#198754",tension:0}]},historyReceiveData:{labels:[],datasets:[{label:"Data Received",data:[],fill:!1,borderColor:"#0d6efd",tension:0}]},peerSetting:{modalOpen:!1,selectedPeer:void 0},peerScheduleJobs:{modalOpen:!1,selectedPeer:void 0},peerQRCode:{modalOpen:!1,peerConfigData:void 0},peerCreate:{modalOpen:!1},peerScheduleJobsAll:{modalOpen:!1},peerScheduleJobsLogs:{modalOpen:!1},peerShare:{modalOpen:!1,selectedPeer:void 0}}},mounted(){},watch:{$route:{immediate:!0,handler(){clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval),this.loading=!0;let e=this.$route.params.id;this.configurationInfo=[],this.configurationPeers=[],e&&(this.getPeers(e),this.setPeerInterval())}},"dashboardConfigurationStore.Configuration.Server.dashboard_refresh_interval"(){clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval),this.setPeerInterval()}},beforeRouteLeave(){clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval)},methods:{toggle(){this.configurationToggling=!0,Tt("/api/toggleWireguardConfiguration/",{configurationName:this.configurationInfo.Name},e=>{e.status?this.dashboardConfigurationStore.newMessage("Server",`${this.configurationInfo.Name} is - ${e.data?"is on":"is off"}`,"Success"):this.dashboardConfigurationStore.newMessage("Server",e.message,"danger"),this.configurationInfo.Status=e.data,this.configurationToggling=!1})},getPeers(e=this.$route.params.id){Tt("/api/getWireguardConfigurationInfo",{configurationName:e},t=>{if(this.configurationInfo=t.data.configurationInfo,this.configurationPeers=t.data.configurationPeers,this.configurationPeers.forEach(n=>{n.restricted=!1}),t.data.configurationRestrictedPeers.forEach(n=>{n.restricted=!0,this.configurationPeers.push(n)}),this.loading=!1,this.configurationPeers.length>0){const n=this.configurationPeers.map(i=>i.total_sent+i.cumu_sent).reduce((i,o)=>i+o).toFixed(4),s=this.configurationPeers.map(i=>i.total_receive+i.cumu_receive).reduce((i,o)=>i+o).toFixed(4);this.historyDataSentDifference[this.historyDataSentDifference.length-1]!==n&&(this.historyDataSentDifference.length>0&&(this.historySentData={labels:[...this.historySentData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Sent",data:[...this.historySentData.datasets[0].data,((n-this.historyDataSentDifference[this.historyDataSentDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#198754",tension:0}]}),this.historyDataSentDifference.push(n)),this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1]!==s&&(this.historyDataReceivedDifference.length>0&&(this.historyReceiveData={labels:[...this.historyReceiveData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Received",data:[...this.historyReceiveData.datasets[0].data,((s-this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#0d6efd",tension:0}]}),this.historyDataReceivedDifference.push(s))}})},setPeerInterval(){this.dashboardConfigurationStore.Peers.RefreshInterval=setInterval(()=>{this.getPeers()},parseInt(this.dashboardConfigurationStore.Configuration.Server.dashboard_refresh_interval))}},computed:{configurationSummary(){return{connectedPeers:this.configurationPeers.filter(t=>t.status==="running").length,totalUsage:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_data+t.cumu_data).reduce((t,n)=>t+n).toFixed(4):0,totalReceive:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_receive+t.cumu_receive).reduce((t,n)=>t+n).toFixed(4):0,totalSent:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_sent+t.cumu_sent).reduce((t,n)=>t+n).toFixed(4):0}},receiveData(){return this.historyReceiveData},sentData(){return this.historySentData},individualDataUsage(){return{labels:this.configurationPeers.map(e=>e.name?e.name:`Untitled Peer - ${e.id}`),datasets:[{label:"Total Data Usage",data:this.configurationPeers.map(e=>e.cumu_data+e.total_data),backgroundColor:this.configurationPeers.map(e=>"#0dcaf0"),tooltip:{callbacks:{label:e=>`${e.formattedValue} GB`}}}]}},individualDataUsageChartOption(){return{responsive:!0,plugins:{legend:{display:!1}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} GB`},grid:{display:!1}}}}},chartOptions(){return{responsive:!0,plugins:{legend:{display:!1},tooltip:{callbacks:{label:e=>`${e.formattedValue} MB/s`}}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} MB/s`},grid:{display:!1}}}}},searchPeers(){const e=new Hr(this.configurationPeers,{keys:["name","id","allowed_ip"]}),t=this.wireguardConfigurationStore.searchString?e.search(this.wireguardConfigurationStore.searchString).map(n=>n.item):this.configurationPeers;return this.dashboardConfigurationStore.Configuration.Server.dashboard_sort==="restricted"?t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?-1:0):t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?1:0)}}},pn=e=>(en("data-v-2a3b3231"),e=e(),tn(),e),$K={key:0},CK={class:"d-flex align-items-center"},EK=pn(()=>h("small",{CLASS:"text-muted"},"CONFIGURATION",-1)),PK={class:"d-flex align-items-center gap-3"},TK={class:"mb-0"},MK={class:"card rounded-3 bg-transparent shadow-sm ms-auto"},DK={class:"card-body py-2 d-flex align-items-center"},OK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Status")],-1)),IK={class:"form-check form-switch ms-auto"},RK=["for"],LK={key:0,class:"spinner-border spinner-border-sm","aria-hidden":"true"},NK=["disabled","id"],FK={class:"row mt-3 gy-2 gx-2 mb-2"},BK={class:"col-6 col-lg-3"},VK={class:"card rounded-3 bg-transparent shadow-sm"},HK={class:"card-body py-2"},jK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),WK={class:"col-6 col-lg-3"},zK={class:"card rounded-3 bg-transparent shadow-sm"},YK={class:"card-body py-2"},UK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Listen Port")],-1)),KK={style:{"word-break":"break-all"},class:"col-12 col-lg-6"},qK={class:"card rounded-3 bg-transparent shadow-sm"},GK={class:"card-body py-2"},JK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Public Key")],-1)),XK={class:"row gx-2 gy-2 mb-2"},QK={class:"col-6 col-lg-3"},ZK={class:"card rounded-3 bg-transparent shadow-sm"},e7={class:"card-body d-flex"},t7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Connected Peers")],-1)),n7={class:"h4"},s7=pn(()=>h("i",{class:"bi bi-ethernet ms-auto h2 text-muted"},null,-1)),i7={class:"col-6 col-lg-3"},o7={class:"card rounded-3 bg-transparent shadow-sm"},r7={class:"card-body d-flex"},a7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Usage")],-1)),l7={class:"h4"},c7=pn(()=>h("i",{class:"bi bi-arrow-down-up ms-auto h2 text-muted"},null,-1)),u7={class:"col-6 col-lg-3"},d7={class:"card rounded-3 bg-transparent shadow-sm"},h7={class:"card-body d-flex"},f7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Received")],-1)),p7={class:"h4 text-primary"},g7=pn(()=>h("i",{class:"bi bi-arrow-down ms-auto h2 text-muted"},null,-1)),m7={class:"col-6 col-lg-3"},_7={class:"card rounded-3 bg-transparent shadow-sm"},v7={class:"card-body d-flex"},b7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Sent")],-1)),y7={class:"h4 text-success"},w7=pn(()=>h("i",{class:"bi bi-arrow-up ms-auto h2 text-muted"},null,-1)),x7={class:"row gx-2 gy-2 mb-3"},k7={class:"col-12 col-lg-6"},S7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},A7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Peers Total Data Usage")],-1)),$7={class:"card-body pt-1"},C7={class:"col-sm col-lg-3"},E7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},P7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Received Data Usage")],-1)),T7={class:"card-body pt-1"},M7={class:"col-sm col-lg-3"},D7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},O7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Sent Data Usage")],-1)),I7={class:"card-body pt-1"},R7={class:"mb-4"};function L7(e,t,n,s,i,o){const r=je("Bar"),a=je("Line"),l=je("PeerSearch"),c=je("Peer"),u=je("PeerSettings"),d=je("PeerQRCode"),f=je("PeerJobs"),p=je("PeerJobsAllModal"),m=je("PeerJobsLogsModal"),_=je("PeerShareLinkModal");return this.loading?ae("",!0):(O(),F("div",$K,[h("div",CK,[h("div",null,[EK,h("div",PK,[h("h1",TK,[h("samp",null,ve(this.configurationInfo.Name),1)])])]),h("div",MK,[h("div",DK,[h("div",null,[OK,h("div",IK,[h("label",{class:"form-check-label",style:{cursor:"pointer"},for:"switch"+this.configurationInfo.id},[ye(ve(this.configurationToggling?"Turning ":"")+" "+ve(this.configurationInfo.Status?"On":"Off")+" ",1),this.configurationToggling?(O(),F("span",LK)):ae("",!0)],8,RK),Re(h("input",{class:"form-check-input",style:{cursor:"pointer"},disabled:this.configurationToggling,type:"checkbox",role:"switch",id:"switch"+this.configurationInfo.id,onChange:t[0]||(t[0]=b=>this.toggle()),"onUpdate:modelValue":t[1]||(t[1]=b=>this.configurationInfo.Status=b)},null,40,NK),[[In,this.configurationInfo.Status]])])]),h("div",{class:Ee(["dot ms-5",{active:this.configurationInfo.Status}])},null,2)])])]),h("div",FK,[h("div",BK,[h("div",VK,[h("div",HK,[jK,ye(" "+ve(this.configurationInfo.Address),1)])])]),h("div",WK,[h("div",zK,[h("div",YK,[UK,ye(" "+ve(this.configurationInfo.ListenPort),1)])])]),h("div",KK,[h("div",qK,[h("div",GK,[JK,h("samp",null,ve(this.configurationInfo.PublicKey),1)])])])]),h("div",XK,[h("div",QK,[h("div",ZK,[h("div",e7,[h("div",null,[t7,h("strong",n7,ve(o.configurationSummary.connectedPeers),1)]),s7])])]),h("div",i7,[h("div",o7,[h("div",r7,[h("div",null,[a7,h("strong",l7,ve(o.configurationSummary.totalUsage)+" GB",1)]),c7])])]),h("div",u7,[h("div",d7,[h("div",h7,[h("div",null,[f7,h("strong",p7,ve(o.configurationSummary.totalReceive)+" GB",1)]),g7])])]),h("div",m7,[h("div",_7,[h("div",v7,[h("div",null,[b7,h("strong",y7,ve(o.configurationSummary.totalSent)+" GB",1)]),w7])])])]),h("div",x7,[h("div",k7,[h("div",S7,[A7,h("div",$7,[$e(r,{data:o.individualDataUsage,options:o.individualDataUsageChartOption,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["data","options"])])])]),h("div",C7,[h("div",E7,[P7,h("div",T7,[$e(a,{options:o.chartOptions,data:o.receiveData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])]),h("div",M7,[h("div",D7,[O7,h("div",I7,[$e(a,{options:o.chartOptions,data:o.sentData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])])]),h("div",R7,[$e(l,{onJobsAll:t[2]||(t[2]=b=>this.peerScheduleJobsAll.modalOpen=!0),onJobLogs:t[3]||(t[3]=b=>this.peerScheduleJobsLogs.modalOpen=!0),configuration:this.configurationInfo},null,8,["configuration"]),$e(Wi,{name:"list",tag:"div",class:"row gx-2 gy-2 z-0"},{default:Te(()=>[(O(!0),F(Me,null,Ke(this.searchPeers,b=>(O(),F("div",{class:"col-12 col-lg-6 col-xl-4",key:b.id},[$e(c,{Peer:b,onShare:w=>{this.peerShare.selectedPeer=b.id,this.peerShare.modalOpen=!0},onRefresh:t[4]||(t[4]=w=>this.getPeers()),onJobs:w=>{i.peerScheduleJobs.modalOpen=!0,i.peerScheduleJobs.selectedPeer=this.configurationPeers.find(A=>A.id===b.id)},onSetting:w=>{i.peerSetting.modalOpen=!0,i.peerSetting.selectedPeer=this.configurationPeers.find(A=>A.id===b.id)},onQrcode:t[5]||(t[5]=w=>{this.peerQRCode.peerConfigData=w,this.peerQRCode.modalOpen=!0})},null,8,["Peer","onShare","onJobs","onSetting"])]))),128))]),_:1})]),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerSetting.modalOpen?(O(),Ne(u,{key:"settings",selectedPeer:this.peerSetting.selectedPeer,onRefresh:t[6]||(t[6]=b=>this.getPeers()),onClose:t[7]||(t[7]=b=>this.peerSetting.modalOpen=!1)},null,8,["selectedPeer"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[i.peerQRCode.modalOpen?(O(),Ne(d,{peerConfigData:this.peerQRCode.peerConfigData,key:"qrcode",onClose:t[8]||(t[8]=b=>this.peerQRCode.modalOpen=!1)},null,8,["peerConfigData"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobs.modalOpen?(O(),Ne(f,{key:0,onRefresh:t[9]||(t[9]=b=>this.getPeers()),selectedPeer:this.peerScheduleJobs.selectedPeer,onClose:t[10]||(t[10]=b=>this.peerScheduleJobs.modalOpen=!1)},null,8,["selectedPeer"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobsAll.modalOpen?(O(),Ne(p,{key:0,onRefresh:t[11]||(t[11]=b=>this.getPeers()),onClose:t[12]||(t[12]=b=>this.peerScheduleJobsAll.modalOpen=!1),configurationPeers:this.configurationPeers},null,8,["configurationPeers"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobsLogs.modalOpen?(O(),Ne(m,{key:0,onClose:t[13]||(t[13]=b=>this.peerScheduleJobsLogs.modalOpen=!1),configurationInfo:this.configurationInfo},null,8,["configurationInfo"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerShare.modalOpen?(O(),Ne(_,{key:0,onClose:t[14]||(t[14]=b=>{this.peerShare.modalOpen=!1,this.peerShare.selectedPeer=void 0}),peer:this.configurationPeers.find(b=>b.id===this.peerShare.selectedPeer)},null,8,["peer"])):ae("",!0)]),_:1})]))}const N7=ze(AK,[["render",L7],["__scopeId","data-v-2a3b3231"]]),F7={name:"ping",data(){return{loading:!1,cips:{},selectedConfiguration:void 0,selectedPeer:void 0,selectedIp:void 0,count:4,pingResult:void 0,pinging:!1}},setup(){return{store:et()}},mounted(){Tt("/api/ping/getAllPeersIpAddress",{},e=>{e.status&&(this.loading=!0,this.cips=e.data,console.log(this.cips))})},methods:{execute(){this.selectedIp&&(this.pinging=!0,this.pingResult=void 0,Tt("/api/ping/execute",{ipAddress:this.selectedIp,count:this.count},e=>{e.status?this.pingResult=e.data:this.store.newMessage("Server",e.message,"danger")}))}},watch:{selectedConfiguration(){this.selectedPeer=void 0,this.selectedIp=void 0},selectedPeer(){this.selectedIp=void 0}}},Hn=e=>(en("data-v-875f5a3c"),e=e(),tn(),e),B7={class:"mt-5 text-body"},V7={class:"container"},H7=Hn(()=>h("h3",{class:"mb-3 text-body"},"Ping",-1)),j7={class:"row"},W7={class:"col-sm-4 d-flex gap-2 flex-column"},z7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"configuration"},[h("small",null,"Configuration")],-1)),Y7=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Configuration...",-1)),U7=["value"],K7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"peer"},[h("small",null,"Peer")],-1)),q7=["disabled"],G7=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Peer...",-1)),J7=["value"],X7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"ip"},[h("small",null,"IP Address")],-1)),Q7=["disabled"],Z7=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a IP...",-1)),e9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"count"},[h("small",null,"Ping Count")],-1)),t9=["disabled"],n9=Hn(()=>h("i",{class:"bi bi-person-walking me-2"},null,-1)),s9={class:"col-sm-8"},i9={key:"pingPlaceholder"},o9={key:"pingResult",class:"d-flex flex-column gap-2 w-100"},r9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.15s"}},a9={class:"card-body"},l9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),c9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.3s"}},u9={class:"card-body"},d9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Is Alive")],-1)),h9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.45s"}},f9={class:"card-body"},p9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Average / Min / Max Round Trip Time")],-1)),g9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.6s"}},m9={class:"card-body"},_9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Sent / Received / Lost Package")],-1));function v9(e,t,n,s,i,o){return O(),F("div",B7,[h("div",V7,[H7,h("div",j7,[h("div",W7,[h("div",null,[z7,Re(h("select",{class:"form-select","onUpdate:modelValue":t[0]||(t[0]=r=>this.selectedConfiguration=r)},[Y7,(O(!0),F(Me,null,Ke(this.cips,(r,a)=>(O(),F("option",{value:a},ve(a),9,U7))),256))],512),[[hc,this.selectedConfiguration]])]),h("div",null,[K7,Re(h("select",{id:"peer",class:"form-select","onUpdate:modelValue":t[1]||(t[1]=r=>this.selectedPeer=r),disabled:this.selectedConfiguration===void 0},[G7,this.selectedConfiguration!==void 0?(O(!0),F(Me,{key:0},Ke(this.cips[this.selectedConfiguration],(r,a)=>(O(),F("option",{value:a},ve(a),9,J7))),256)):ae("",!0)],8,q7),[[hc,this.selectedPeer]])]),h("div",null,[X7,Re(h("select",{id:"ip",class:"form-select","onUpdate:modelValue":t[2]||(t[2]=r=>this.selectedIp=r),disabled:this.selectedPeer===void 0},[Z7,this.selectedPeer!==void 0?(O(!0),F(Me,{key:0},Ke(this.cips[this.selectedConfiguration][this.selectedPeer].allowed_ips,r=>(O(),F("option",null,ve(r),1))),256)):ae("",!0)],8,Q7),[[hc,this.selectedIp]])]),h("div",null,[e9,Re(h("input",{class:"form-control",type:"number","onUpdate:modelValue":t[3]||(t[3]=r=>this.count=r),min:"1",id:"count",placeholder:"How many times you want to ping?"},null,512),[[We,this.count]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.selectedIp,onClick:t[4]||(t[4]=r=>this.execute())},[n9,ye("Go! ")],8,t9)]),h("div",s9,[$e(Wi,{name:"ping"},{default:Te(()=>[this.pingResult?(O(),F("div",o9,[h("div",r9,[h("div",a9,[l9,ye(" "+ve(this.pingResult.address),1)])]),h("div",c9,[h("div",u9,[d9,h("span",{class:Ee([this.pingResult.is_alive?"text-success":"text-danger"])},[h("i",{class:Ee(["bi me-1",[this.pingResult.is_alive?"bi-check-circle-fill":"bi-x-circle-fill"]])},null,2),ye(" "+ve(this.pingResult.is_alive?"Yes":"No"),1)],2)])]),h("div",h9,[h("div",f9,[p9,h("samp",null,ve(this.pingResult.avg_rtt)+"ms / "+ve(this.pingResult.min_rtt)+"ms / "+ve(this.pingResult.max_rtt)+"ms ",1)])]),h("div",g9,[h("div",m9,[_9,h("samp",null,ve(this.pingResult.package_sent)+" / "+ve(this.pingResult.package_received)+" / "+ve(this.pingResult.package_loss),1)])])])):(O(),F("div",i9,[(O(),F(Me,null,Ke(4,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.pinging}]),style:Wt({"animation-delay":`${r*.15}s`})},null,6)),64))]))]),_:1})])])])])}const b9=ze(F7,[["render",v9],["__scopeId","data-v-875f5a3c"]]),y9={name:"traceroute",data(){return{tracing:!1,ipAddress:void 0,tracerouteResult:void 0}},setup(){return{store:Bn()}},methods:{execute(){this.ipAddress&&(this.tracing=!0,this.tracerouteResult=void 0,Tt("/api/traceroute/execute",{ipAddress:this.ipAddress},e=>{e.status?this.tracerouteResult=e.data:this.store.newMessage("Server",e.message,"danger"),this.tracing=!1}))}}},Pu=e=>(en("data-v-dda37ccf"),e=e(),tn(),e),w9={class:"mt-5 text-body"},x9={class:"container"},k9=Pu(()=>h("h3",{class:"mb-3 text-body"},"Traceroute",-1)),S9={class:"row"},A9={class:"col-sm-4 d-flex gap-2 flex-column"},$9=Pu(()=>h("label",{class:"mb-1 text-muted",for:"ipAddress"},[h("small",null,"IP Address")],-1)),C9=["disabled"],E9=Pu(()=>h("i",{class:"bi bi-bullseye me-2"},null,-1)),P9={class:"col-sm-8 position-relative"},T9={key:"pingPlaceholder"},M9={key:"table",class:"w-100"},D9={class:"table table-borderless rounded-3 w-100"},O9=Pu(()=>h("thead",null,[h("tr",null,[h("th",{scope:"col"},"Hop"),h("th",{scope:"col"},"IP Address"),h("th",{scope:"col"},"Average / Min / Max Round Trip Time")])],-1));function I9(e,t,n,s,i,o){return O(),F("div",w9,[h("div",x9,[k9,h("div",S9,[h("div",A9,[h("div",null,[$9,Re(h("input",{id:"ipAddress",class:"form-control","onUpdate:modelValue":t[0]||(t[0]=r=>this.ipAddress=r),type:"text",placeholder:"Enter an IP Address you want to trace :)"},null,512),[[We,this.ipAddress]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.store.regexCheckIP(this.ipAddress)||this.tracing,onClick:t[1]||(t[1]=r=>this.execute())},[E9,ye(" "+ve(this.tracing?"Tracing...":"Trace It!"),1)],8,C9)]),h("div",P9,[$e(Wi,{name:"ping"},{default:Te(()=>[this.tracerouteResult?(O(),F("div",M9,[h("table",D9,[O9,h("tbody",null,[(O(!0),F(Me,null,Ke(this.tracerouteResult,(r,a)=>(O(),F("tr",{class:"animate__fadeInUp animate__animated",style:Wt({"animation-delay":`${a*.05}s`})},[h("td",null,ve(r.hop),1),h("td",null,ve(r.ip),1),h("td",null,ve(r.avg_rtt)+" / "+ve(r.min_rtt)+" / "+ve(r.max_rtt),1)],4))),256))])])])):(O(),F("div",T9,[(O(),F(Me,null,Ke(10,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.tracing}]),style:Wt({"animation-delay":`${r*.05}s`})},null,6)),64))]))]),_:1})])])])])}const R9=ze(y9,[["render",I9],["__scopeId","data-v-dda37ccf"]]),L9={name:"totp",async setup(){const e=et();let t="";return await Tt("/api/Welcome_GetTotpLink",{},n=>{n.status&&(t=n.data)}),{l:t,store:e}},mounted(){this.l&&Bo.toCanvas(document.getElementById("qrcode"),this.l,function(e){})},data(){return{totp:"",totpInvalidMessage:"",verified:!1}},methods:{validateTotp(){}},watch:{totp(e){const t=document.querySelector("#totp");t.classList.remove("is-invalid","is-valid"),e.length===6&&(console.log(e),/[0-9]{6}/.test(e)?dt("/api/Welcome_VerifyTotpLink",{totp:e},n=>{n.status?(this.verified=!0,t.classList.add("is-valid"),this.$emit("verified")):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP does not match.")}):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP can only contain numbers"))}}},N9=["data-bs-theme"],F9={class:"m-auto text-body",style:{width:"500px"}},B9={class:"d-flex flex-column"},V9=h("h1",{class:"dashboardLogo display-4"},"Multi-Factor Authentication",-1),H9=h("p",{class:"mb-2"},[h("small",{class:"text-muted"},"1. Please scan the following QR Code to generate TOTP")],-1),j9=h("canvas",{id:"qrcode",class:"rounded-3 mb-2"},null,-1),W9={class:"p-3 bg-body-secondary rounded-3 border mb-3"},z9=h("p",{class:"text-muted mb-0"},[h("small",null,"Or you can click the link below:")],-1),Y9=["href"],U9={style:{"line-break":"anywhere"}},K9=h("label",{for:"totp",class:"mb-2"},[h("small",{class:"text-muted"},"2. Enter the TOTP generated by your authenticator to verify")],-1),q9={class:"form-group mb-2"},G9=["disabled"],J9={class:"invalid-feedback"},X9=h("div",{class:"valid-feedback"}," TOTP verified! ",-1),Q9=h("div",{class:"alert alert-warning rounded-3"},[h("i",{class:"bi bi-exclamation-triangle-fill me-2"}),ye(" If you ever lost your TOTP and can't login, please follow instruction on "),h("a",{href:"https://github.com/donaldzou/WGDashboard",target:"_blank"},"readme.md"),ye(" to reset. ")],-1),Z9=h("hr",null,null,-1),eq={class:"d-flex gap-3 mt-5 flex-column"},tq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1),nq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1);function sq(e,t,n,s,i,o){const r=je("RouterLink");return O(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.store.Configuration.Server.dashboard_theme},[h("div",F9,[h("div",B9,[h("div",null,[V9,H9,j9,h("div",W9,[z9,h("a",{href:this.l},[h("code",U9,ve(this.l),1)],8,Y9)]),K9,h("div",q9,[Re(h("input",{class:"form-control text-center totp",id:"totp",maxlength:"6",type:"text",inputmode:"numeric",autocomplete:"one-time-code","onUpdate:modelValue":t[0]||(t[0]=a=>this.totp=a),disabled:this.verified},null,8,G9),[[We,this.totp]]),h("div",J9,ve(this.totpInvalidMessage),1),X9]),Q9]),Z9,h("div",eq,[this.verified?(O(),Ne(r,{key:1,to:"/",class:"btn btn-dark btn-lg d-flex btn-brand shadow align-items-center flex-grow-1 rounded-3"},{default:Te(()=>[ye(" Complete "),nq]),_:1})):(O(),Ne(r,{key:0,to:"/",class:"btn bg-secondary-subtle text-secondary-emphasis rounded-3 flex-grow-1 btn-lg border-1 border-secondary-subtle shadow d-flex"},{default:Te(()=>[ye(" I don't need MFA "),tq]),_:1}))])])])],8,N9)}const iq=ze(L9,[["render",sq]]),oq={name:"share",async setup(){const e=eP(),t=be(!1),n=et(),s=be(""),i=be(""),o=be(new Blob);await Tt("/api/getDashboardTheme",{},a=>{s.value=a.data});const r=e.query.ShareID;return r===void 0||r.length===0?(i.value=void 0,t.value=!0):await Tt("/api/sharePeer/get",{ShareID:r},a=>{a.status?(i.value=a.data,o.value=new Blob([i.value.file],{type:"text/plain"})):i.value=void 0,t.value=!0}),{store:n,theme:s,peerConfiguration:i,blob:o}},mounted(){Bo.toCanvas(document.querySelector("#qrcode"),this.peerConfiguration.file,e=>{e&&console.error(e)})},methods:{download(){const e=new Blob([this.peerConfiguration.file],{type:"text/plain"}),t=URL.createObjectURL(e),n=`${this.peerConfiguration.fileName}.conf`,s=document.createElement("a");s.href=t,s.download=n,s.click()}},computed:{getBlob(){return URL.createObjectURL(this.blob)}}},hp=e=>(en("data-v-99d4b06a"),e=e(),tn(),e),rq=["data-bs-theme"],aq={class:"m-auto text-body",style:{width:"500px"}},lq={key:0,class:"text-center position-relative",style:{}},cq=X$('

Oh no... This link is either expired or invalid.

',2),uq=[cq],dq={key:1,class:"d-flex align-items-center flex-column gap-3"},hq=hp(()=>h("div",{class:"h1 dashboardLogo text-center animate__animated animate__fadeInUp"},[h("h6",null,"WGDashboard"),ye(" Scan QR Code from the WireGuard App ")],-1)),fq={id:"qrcode",class:"rounded-3 shadow animate__animated animate__fadeInUp mb-3",ref:"qrcode"},pq=hp(()=>h("p",{class:"text-muted animate__animated animate__fadeInUp mb-1",style:{"animation-delay":"0.2s"}},[ye("or click the button below to download the "),h("samp",null,".conf"),ye(" file")],-1)),gq=["download","href"],mq=hp(()=>h("i",{class:"bi bi-download"},null,-1)),_q=[mq];function vq(e,t,n,s,i,o){return O(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.theme},[h("div",aq,[this.peerConfiguration?(O(),F("div",dq,[hq,h("canvas",fq,null,512),pq,h("a",{download:this.peerConfiguration.fileName+".conf",href:o.getBlob,class:"btn btn-lg bg-primary-subtle text-primary-emphasis border-1 border-primary-subtle animate__animated animate__fadeInUp shadow-sm",style:{"animation-delay":"0.25s"}},_q,8,gq)])):(O(),F("div",lq,uq))])],8,rq)}const bq=ze(oq,[["render",vq],["__scopeId","data-v-99d4b06a"]]),yq=async()=>{let e=!1;return await Tt("/api/validateAuthentication",{},t=>{e=t.status}),e},gl=QE({history:gE(),routes:[{name:"Index",path:"/",component:YP,meta:{requiresAuth:!0},children:[{name:"Configuration List",path:"",component:EM,meta:{title:"WireGuard Configurations"}},{name:"Settings",path:"/settings",component:TN,meta:{title:"Settings"}},{path:"/ping",name:"Ping",component:b9},{path:"/traceroute",name:"Traceroute",component:R9},{name:"New Configuration",path:"/new_configuration",component:h5,meta:{title:"New Configuration"}},{name:"Configuration",path:"/configuration/:id",component:m5,meta:{title:"Configuration"},children:[{name:"Peers List",path:"peers",component:N7},{name:"Peers Create",path:"create",component:U1}]}]},{path:"/signin",component:qT,meta:{title:"Sign In"}},{path:"/welcome",component:QN,meta:{requiresAuth:!0,title:"Welcome to WGDashboard"}},{path:"/2FASetup",component:iq,meta:{requiresAuth:!0,title:"Multi-Factor Authentication Setup"}},{path:"/share",component:bq,meta:{title:"Share"}}]});gl.beforeEach(async(e,t,n)=>{const s=Bn(),i=et();e.meta.title?e.params.id?document.title=e.params.id+" | WGDashboard":document.title=e.meta.title+" | WGDashboard":document.title="WGDashboard",e.meta.requiresAuth?i.getActiveCrossServer()?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),n()):tP.getCookie("authToken")&&await yq()?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),i.Redirect=void 0,n()):(i.Redirect=e,n("/signin"),i.newMessage("WGDashboard","Session Ended","warning")):n()});const G1=()=>{let e={"content-type":"application/json"};const n=et().getActiveCrossServer();return n&&(e["wg-dashboard-apikey"]=n.apiKey),e},J1=e=>{const n=et().getActiveCrossServer();return n?`${n.host}${e}`:e},Tt=async(e,t=void 0,n=void 0)=>{const s=new URLSearchParams(t);await fetch(`${J1(e)}?${s.toString()}`,{headers:G1()}).then(i=>{const o=et();if(i.ok)return i.json();if(i.status!==200)throw i.status===401&&o.newMessage("WGDashboard","Session Ended","warning"),new Error(i.statusText)}).then(i=>n?n(i):void 0).catch(i=>{console.log(i),gl.push({path:"/signin"})})},dt=async(e,t,n)=>{await fetch(`${J1(e)}`,{headers:G1(),method:"POST",body:JSON.stringify(t)}).then(s=>{const i=et();if(s.ok)return s.json();if(s.status!==200)throw s.status===401&&i.newMessage("WGDashboard","Session Ended","warning"),new Error(s.statusText)}).then(s=>n?n(s):void 0).catch(s=>{console.log(s),gl.push({path:"/signin"})})},et=bf("DashboardConfigurationStore",{state:()=>({Redirect:void 0,Configuration:void 0,Messages:[],Peers:{Selecting:!1,RefreshInterval:void 0},CrossServerConfiguration:{Enable:!1,ServerList:{}},ActiveServerConfiguration:void 0,IsElectronApp:!1}),actions:{initCrossServerConfiguration(){const e=localStorage.getItem("CrossServerConfiguration");localStorage.getItem("ActiveCrossServerConfiguration")!==null&&(this.ActiveServerConfiguration=localStorage.getItem("ActiveCrossServerConfiguration")),e===null?localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration)):this.CrossServerConfiguration=JSON.parse(e)},syncCrossServerConfiguration(){localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration))},addCrossServerConfiguration(){this.CrossServerConfiguration.ServerList[Ms().toString()]={host:"",apiKey:"",active:!1}},deleteCrossServerConfiguration(e){delete this.CrossServerConfiguration.ServerList[e]},getActiveCrossServer(){const e=localStorage.getItem("ActiveCrossServerConfiguration");if(e!==null)return this.CrossServerConfiguration.ServerList[e]},setActiveCrossServer(e){this.ActiveServerConfiguration=e,localStorage.setItem("ActiveCrossServerConfiguration",e)},removeActiveCrossServer(){this.ActiveServerConfiguration=void 0,localStorage.removeItem("ActiveCrossServerConfiguration")},async getConfiguration(){await Tt("/api/getDashboardConfiguration",{},e=>{e.status&&(this.Configuration=e.data)})},async updateConfiguration(){await dt("/api/updateDashboardConfiguration",{DashboardConfiguration:this.Configuration},e=>{console.log(e)})},async signOut(){await Tt("/api/signout",{},e=>{this.removeActiveCrossServer(),this.$router.go("/signin")})},newMessage(e,t,n){this.Messages.push({id:Ms(),from:e,content:t,type:n,show:!0})}}}),fp=e=>(en("data-v-739a0103"),e=e(),tn(),e),wq={class:"navbar bg-dark sticky-top border-bottom border-secondary-subtle","data-bs-theme":"dark"},xq={class:"container-fluid d-flex text-body align-items-center"},kq=fp(()=>h("span",{class:"navbar-brand mb-0 h1"},"WGDashboard",-1)),Sq={key:0,class:"ms-auto text-muted"},Aq=fp(()=>h("i",{class:"bi bi-server me-2"},null,-1)),$q=fp(()=>h("a",{role:"button"},[h("i",{class:"bi bi-list"})],-1)),Cq={__name:"App",setup(e){const t=et();t.initCrossServerConfiguration(),window.IS_WGDASHBOARD_DESKTOP&&(t.IsElectronApp=!0,t.CrossServerConfiguration.Enable=!0),Vt(t.CrossServerConfiguration,()=>{t.syncCrossServerConfiguration()},{deep:!0});const n=_e(()=>{if(t.ActiveServerConfiguration)return t.CrossServerConfiguration.ServerList[t.ActiveServerConfiguration]});return(s,i)=>(O(),F(Me,null,[h("nav",wq,[h("div",xq,[kq,n.value!==void 0?(O(),F("small",Sq,[Aq,ye(ve(n.value.host),1)])):ae("",!0),$q])]),(O(),Ne(uf,null,{default:Te(()=>[$e(q(ky),null,{default:Te(({Component:o})=>[$e(Bt,{name:"app",mode:"out-in"},{default:Te(()=>[(O(),Ne(Io(o)))]),_:2},1024)]),_:1})]),_:1}))],64))}},Eq=ze(Cq,[["__scopeId","data-v-739a0103"]]),pp=HC(Eq);pp.use(gl);const X1=YC();X1.use(({store:e})=>{e.$router=tu(gl)});pp.use(X1);pp.mount("#app"); + ${e.data?"is on":"is off"}`,"Success"):this.dashboardConfigurationStore.newMessage("Server",e.message,"danger"),this.configurationInfo.Status=e.data,this.configurationToggling=!1})},getPeers(e=this.$route.params.id){Tt("/api/getWireguardConfigurationInfo",{configurationName:e},t=>{if(this.configurationInfo=t.data.configurationInfo,this.configurationPeers=t.data.configurationPeers,this.configurationPeers.forEach(n=>{n.restricted=!1}),t.data.configurationRestrictedPeers.forEach(n=>{n.restricted=!0,this.configurationPeers.push(n)}),this.loading=!1,this.configurationPeers.length>0){const n=this.configurationPeers.map(i=>i.total_sent+i.cumu_sent).reduce((i,o)=>i+o).toFixed(4),s=this.configurationPeers.map(i=>i.total_receive+i.cumu_receive).reduce((i,o)=>i+o).toFixed(4);this.historyDataSentDifference[this.historyDataSentDifference.length-1]!==n&&(this.historyDataSentDifference.length>0&&(this.historySentData={labels:[...this.historySentData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Sent",data:[...this.historySentData.datasets[0].data,((n-this.historyDataSentDifference[this.historyDataSentDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#198754",tension:0}]}),this.historyDataSentDifference.push(n)),this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1]!==s&&(this.historyDataReceivedDifference.length>0&&(this.historyReceiveData={labels:[...this.historyReceiveData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Received",data:[...this.historyReceiveData.datasets[0].data,((s-this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#0d6efd",tension:0}]}),this.historyDataReceivedDifference.push(s))}})},setPeerInterval(){this.dashboardConfigurationStore.Peers.RefreshInterval=setInterval(()=>{this.getPeers()},parseInt(this.dashboardConfigurationStore.Configuration.Server.dashboard_refresh_interval))}},computed:{configurationSummary(){return{connectedPeers:this.configurationPeers.filter(t=>t.status==="running").length,totalUsage:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_data+t.cumu_data).reduce((t,n)=>t+n).toFixed(4):0,totalReceive:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_receive+t.cumu_receive).reduce((t,n)=>t+n).toFixed(4):0,totalSent:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_sent+t.cumu_sent).reduce((t,n)=>t+n).toFixed(4):0}},receiveData(){return this.historyReceiveData},sentData(){return this.historySentData},individualDataUsage(){return{labels:this.configurationPeers.map(e=>e.name?e.name:`Untitled Peer - ${e.id}`),datasets:[{label:"Total Data Usage",data:this.configurationPeers.map(e=>e.cumu_data+e.total_data),backgroundColor:this.configurationPeers.map(e=>"#0dcaf0"),tooltip:{callbacks:{label:e=>`${e.formattedValue} GB`}}}]}},individualDataUsageChartOption(){return{responsive:!0,plugins:{legend:{display:!1}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} GB`},grid:{display:!1}}}}},chartOptions(){return{responsive:!0,plugins:{legend:{display:!1},tooltip:{callbacks:{label:e=>`${e.formattedValue} MB/s`}}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} MB/s`},grid:{display:!1}}}}},searchPeers(){const e=new Hr(this.configurationPeers,{keys:["name","id","allowed_ip"]}),t=this.wireguardConfigurationStore.searchString?e.search(this.wireguardConfigurationStore.searchString).map(n=>n.item):this.configurationPeers;return this.dashboardConfigurationStore.Configuration.Server.dashboard_sort==="restricted"?t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?-1:0):t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?1:0)}}},pn=e=>(en("data-v-2a3b3231"),e=e(),tn(),e),$K={key:0},CK={class:"d-flex align-items-center"},EK=pn(()=>h("small",{CLASS:"text-muted"},"CONFIGURATION",-1)),PK={class:"d-flex align-items-center gap-3"},TK={class:"mb-0"},MK={class:"card rounded-3 bg-transparent shadow-sm ms-auto"},DK={class:"card-body py-2 d-flex align-items-center"},OK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Status")],-1)),IK={class:"form-check form-switch ms-auto"},RK=["for"],LK={key:0,class:"spinner-border spinner-border-sm","aria-hidden":"true"},NK=["disabled","id"],FK={class:"row mt-3 gy-2 gx-2 mb-2"},BK={class:"col-6 col-lg-3"},VK={class:"card rounded-3 bg-transparent shadow-sm"},HK={class:"card-body py-2"},jK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),WK={class:"col-6 col-lg-3"},zK={class:"card rounded-3 bg-transparent shadow-sm"},YK={class:"card-body py-2"},UK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Listen Port")],-1)),KK={style:{"word-break":"break-all"},class:"col-12 col-lg-6"},qK={class:"card rounded-3 bg-transparent shadow-sm"},GK={class:"card-body py-2"},JK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Public Key")],-1)),XK={class:"row gx-2 gy-2 mb-2"},QK={class:"col-6 col-lg-3"},ZK={class:"card rounded-3 bg-transparent shadow-sm"},e7={class:"card-body d-flex"},t7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Connected Peers")],-1)),n7={class:"h4"},s7=pn(()=>h("i",{class:"bi bi-ethernet ms-auto h2 text-muted"},null,-1)),i7={class:"col-6 col-lg-3"},o7={class:"card rounded-3 bg-transparent shadow-sm"},r7={class:"card-body d-flex"},a7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Usage")],-1)),l7={class:"h4"},c7=pn(()=>h("i",{class:"bi bi-arrow-down-up ms-auto h2 text-muted"},null,-1)),u7={class:"col-6 col-lg-3"},d7={class:"card rounded-3 bg-transparent shadow-sm"},h7={class:"card-body d-flex"},f7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Received")],-1)),p7={class:"h4 text-primary"},g7=pn(()=>h("i",{class:"bi bi-arrow-down ms-auto h2 text-muted"},null,-1)),m7={class:"col-6 col-lg-3"},_7={class:"card rounded-3 bg-transparent shadow-sm"},v7={class:"card-body d-flex"},b7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Sent")],-1)),y7={class:"h4 text-success"},w7=pn(()=>h("i",{class:"bi bi-arrow-up ms-auto h2 text-muted"},null,-1)),x7={class:"row gx-2 gy-2 mb-3"},k7={class:"col-12 col-lg-6"},S7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},A7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Peers Total Data Usage")],-1)),$7={class:"card-body pt-1"},C7={class:"col-sm col-lg-3"},E7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},P7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Received Data Usage")],-1)),T7={class:"card-body pt-1"},M7={class:"col-sm col-lg-3"},D7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},O7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Sent Data Usage")],-1)),I7={class:"card-body pt-1"},R7={class:"mb-4"};function L7(e,t,n,s,i,o){const r=je("Bar"),a=je("Line"),l=je("PeerSearch"),c=je("Peer"),u=je("PeerSettings"),d=je("PeerQRCode"),f=je("PeerJobs"),p=je("PeerJobsAllModal"),m=je("PeerJobsLogsModal"),_=je("PeerShareLinkModal");return this.loading?ae("",!0):(O(),F("div",$K,[h("div",CK,[h("div",null,[EK,h("div",PK,[h("h1",TK,[h("samp",null,ve(this.configurationInfo.Name),1)])])]),h("div",MK,[h("div",DK,[h("div",null,[OK,h("div",IK,[h("label",{class:"form-check-label",style:{cursor:"pointer"},for:"switch"+this.configurationInfo.id},[ye(ve(this.configurationToggling?"Turning ":"")+" "+ve(this.configurationInfo.Status?"On":"Off")+" ",1),this.configurationToggling?(O(),F("span",LK)):ae("",!0)],8,RK),Re(h("input",{class:"form-check-input",style:{cursor:"pointer"},disabled:this.configurationToggling,type:"checkbox",role:"switch",id:"switch"+this.configurationInfo.id,onChange:t[0]||(t[0]=b=>this.toggle()),"onUpdate:modelValue":t[1]||(t[1]=b=>this.configurationInfo.Status=b)},null,40,NK),[[In,this.configurationInfo.Status]])])]),h("div",{class:Ee(["dot ms-5",{active:this.configurationInfo.Status}])},null,2)])])]),h("div",FK,[h("div",BK,[h("div",VK,[h("div",HK,[jK,ye(" "+ve(this.configurationInfo.Address),1)])])]),h("div",WK,[h("div",zK,[h("div",YK,[UK,ye(" "+ve(this.configurationInfo.ListenPort),1)])])]),h("div",KK,[h("div",qK,[h("div",GK,[JK,h("samp",null,ve(this.configurationInfo.PublicKey),1)])])])]),h("div",XK,[h("div",QK,[h("div",ZK,[h("div",e7,[h("div",null,[t7,h("strong",n7,ve(o.configurationSummary.connectedPeers),1)]),s7])])]),h("div",i7,[h("div",o7,[h("div",r7,[h("div",null,[a7,h("strong",l7,ve(o.configurationSummary.totalUsage)+" GB",1)]),c7])])]),h("div",u7,[h("div",d7,[h("div",h7,[h("div",null,[f7,h("strong",p7,ve(o.configurationSummary.totalReceive)+" GB",1)]),g7])])]),h("div",m7,[h("div",_7,[h("div",v7,[h("div",null,[b7,h("strong",y7,ve(o.configurationSummary.totalSent)+" GB",1)]),w7])])])]),h("div",x7,[h("div",k7,[h("div",S7,[A7,h("div",$7,[$e(r,{data:o.individualDataUsage,options:o.individualDataUsageChartOption,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["data","options"])])])]),h("div",C7,[h("div",E7,[P7,h("div",T7,[$e(a,{options:o.chartOptions,data:o.receiveData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])]),h("div",M7,[h("div",D7,[O7,h("div",I7,[$e(a,{options:o.chartOptions,data:o.sentData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])])]),h("div",R7,[$e(l,{onJobsAll:t[2]||(t[2]=b=>this.peerScheduleJobsAll.modalOpen=!0),onJobLogs:t[3]||(t[3]=b=>this.peerScheduleJobsLogs.modalOpen=!0),configuration:this.configurationInfo},null,8,["configuration"]),$e(Wi,{name:"list",tag:"div",class:"row gx-2 gy-2 z-0"},{default:Te(()=>[(O(!0),F(Me,null,Ke(this.searchPeers,b=>(O(),F("div",{class:"col-12 col-lg-6 col-xl-4",key:b.id},[$e(c,{Peer:b,onShare:w=>{this.peerShare.selectedPeer=b.id,this.peerShare.modalOpen=!0},onRefresh:t[4]||(t[4]=w=>this.getPeers()),onJobs:w=>{i.peerScheduleJobs.modalOpen=!0,i.peerScheduleJobs.selectedPeer=this.configurationPeers.find(A=>A.id===b.id)},onSetting:w=>{i.peerSetting.modalOpen=!0,i.peerSetting.selectedPeer=this.configurationPeers.find(A=>A.id===b.id)},onQrcode:t[5]||(t[5]=w=>{this.peerQRCode.peerConfigData=w,this.peerQRCode.modalOpen=!0})},null,8,["Peer","onShare","onJobs","onSetting"])]))),128))]),_:1})]),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerSetting.modalOpen?(O(),Ne(u,{key:"settings",selectedPeer:this.peerSetting.selectedPeer,onRefresh:t[6]||(t[6]=b=>this.getPeers()),onClose:t[7]||(t[7]=b=>this.peerSetting.modalOpen=!1)},null,8,["selectedPeer"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[i.peerQRCode.modalOpen?(O(),Ne(d,{peerConfigData:this.peerQRCode.peerConfigData,key:"qrcode",onClose:t[8]||(t[8]=b=>this.peerQRCode.modalOpen=!1)},null,8,["peerConfigData"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobs.modalOpen?(O(),Ne(f,{key:0,onRefresh:t[9]||(t[9]=b=>this.getPeers()),selectedPeer:this.peerScheduleJobs.selectedPeer,onClose:t[10]||(t[10]=b=>this.peerScheduleJobs.modalOpen=!1)},null,8,["selectedPeer"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobsAll.modalOpen?(O(),Ne(p,{key:0,onRefresh:t[11]||(t[11]=b=>this.getPeers()),onClose:t[12]||(t[12]=b=>this.peerScheduleJobsAll.modalOpen=!1),configurationPeers:this.configurationPeers},null,8,["configurationPeers"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobsLogs.modalOpen?(O(),Ne(m,{key:0,onClose:t[13]||(t[13]=b=>this.peerScheduleJobsLogs.modalOpen=!1),configurationInfo:this.configurationInfo},null,8,["configurationInfo"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerShare.modalOpen?(O(),Ne(_,{key:0,onClose:t[14]||(t[14]=b=>{this.peerShare.modalOpen=!1,this.peerShare.selectedPeer=void 0}),peer:this.configurationPeers.find(b=>b.id===this.peerShare.selectedPeer)},null,8,["peer"])):ae("",!0)]),_:1})]))}const N7=ze(AK,[["render",L7],["__scopeId","data-v-2a3b3231"]]),F7={name:"ping",data(){return{loading:!1,cips:{},selectedConfiguration:void 0,selectedPeer:void 0,selectedIp:void 0,count:4,pingResult:void 0,pinging:!1}},setup(){return{store:et()}},mounted(){Tt("/api/ping/getAllPeersIpAddress",{},e=>{e.status&&(this.loading=!0,this.cips=e.data,console.log(this.cips))})},methods:{execute(){this.selectedIp&&(this.pinging=!0,this.pingResult=void 0,Tt("/api/ping/execute",{ipAddress:this.selectedIp,count:this.count},e=>{e.status?this.pingResult=e.data:this.store.newMessage("Server",e.message,"danger")}))}},watch:{selectedConfiguration(){this.selectedPeer=void 0,this.selectedIp=void 0},selectedPeer(){this.selectedIp=void 0}}},Hn=e=>(en("data-v-875f5a3c"),e=e(),tn(),e),B7={class:"mt-5 text-body"},V7={class:"container"},H7=Hn(()=>h("h3",{class:"mb-3 text-body"},"Ping",-1)),j7={class:"row"},W7={class:"col-sm-4 d-flex gap-2 flex-column"},z7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"configuration"},[h("small",null,"Configuration")],-1)),Y7=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Configuration...",-1)),U7=["value"],K7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"peer"},[h("small",null,"Peer")],-1)),q7=["disabled"],G7=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Peer...",-1)),J7=["value"],X7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"ip"},[h("small",null,"IP Address")],-1)),Q7=["disabled"],Z7=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a IP...",-1)),e9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"count"},[h("small",null,"Ping Count")],-1)),t9=["disabled"],n9=Hn(()=>h("i",{class:"bi bi-person-walking me-2"},null,-1)),s9={class:"col-sm-8"},i9={key:"pingPlaceholder"},o9={key:"pingResult",class:"d-flex flex-column gap-2 w-100"},r9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.15s"}},a9={class:"card-body"},l9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),c9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.3s"}},u9={class:"card-body"},d9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Is Alive")],-1)),h9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.45s"}},f9={class:"card-body"},p9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Average / Min / Max Round Trip Time")],-1)),g9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.6s"}},m9={class:"card-body"},_9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Sent / Received / Lost Package")],-1));function v9(e,t,n,s,i,o){return O(),F("div",B7,[h("div",V7,[H7,h("div",j7,[h("div",W7,[h("div",null,[z7,Re(h("select",{class:"form-select","onUpdate:modelValue":t[0]||(t[0]=r=>this.selectedConfiguration=r)},[Y7,(O(!0),F(Me,null,Ke(this.cips,(r,a)=>(O(),F("option",{value:a},ve(a),9,U7))),256))],512),[[hc,this.selectedConfiguration]])]),h("div",null,[K7,Re(h("select",{id:"peer",class:"form-select","onUpdate:modelValue":t[1]||(t[1]=r=>this.selectedPeer=r),disabled:this.selectedConfiguration===void 0},[G7,this.selectedConfiguration!==void 0?(O(!0),F(Me,{key:0},Ke(this.cips[this.selectedConfiguration],(r,a)=>(O(),F("option",{value:a},ve(a),9,J7))),256)):ae("",!0)],8,q7),[[hc,this.selectedPeer]])]),h("div",null,[X7,Re(h("select",{id:"ip",class:"form-select","onUpdate:modelValue":t[2]||(t[2]=r=>this.selectedIp=r),disabled:this.selectedPeer===void 0},[Z7,this.selectedPeer!==void 0?(O(!0),F(Me,{key:0},Ke(this.cips[this.selectedConfiguration][this.selectedPeer].allowed_ips,r=>(O(),F("option",null,ve(r),1))),256)):ae("",!0)],8,Q7),[[hc,this.selectedIp]])]),h("div",null,[e9,Re(h("input",{class:"form-control",type:"number","onUpdate:modelValue":t[3]||(t[3]=r=>this.count=r),min:"1",id:"count",placeholder:"How many times you want to ping?"},null,512),[[We,this.count]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.selectedIp,onClick:t[4]||(t[4]=r=>this.execute())},[n9,ye("Go! ")],8,t9)]),h("div",s9,[$e(Wi,{name:"ping"},{default:Te(()=>[this.pingResult?(O(),F("div",o9,[h("div",r9,[h("div",a9,[l9,ye(" "+ve(this.pingResult.address),1)])]),h("div",c9,[h("div",u9,[d9,h("span",{class:Ee([this.pingResult.is_alive?"text-success":"text-danger"])},[h("i",{class:Ee(["bi me-1",[this.pingResult.is_alive?"bi-check-circle-fill":"bi-x-circle-fill"]])},null,2),ye(" "+ve(this.pingResult.is_alive?"Yes":"No"),1)],2)])]),h("div",h9,[h("div",f9,[p9,h("samp",null,ve(this.pingResult.avg_rtt)+"ms / "+ve(this.pingResult.min_rtt)+"ms / "+ve(this.pingResult.max_rtt)+"ms ",1)])]),h("div",g9,[h("div",m9,[_9,h("samp",null,ve(this.pingResult.package_sent)+" / "+ve(this.pingResult.package_received)+" / "+ve(this.pingResult.package_loss),1)])])])):(O(),F("div",i9,[(O(),F(Me,null,Ke(4,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.pinging}]),style:Wt({"animation-delay":`${r*.15}s`})},null,6)),64))]))]),_:1})])])])])}const b9=ze(F7,[["render",v9],["__scopeId","data-v-875f5a3c"]]),y9={name:"traceroute",data(){return{tracing:!1,ipAddress:void 0,tracerouteResult:void 0}},setup(){return{store:Bn()}},methods:{execute(){this.ipAddress&&(this.tracing=!0,this.tracerouteResult=void 0,Tt("/api/traceroute/execute",{ipAddress:this.ipAddress},e=>{e.status?this.tracerouteResult=e.data:this.store.newMessage("Server",e.message,"danger"),this.tracing=!1}))}}},Pu=e=>(en("data-v-dda37ccf"),e=e(),tn(),e),w9={class:"mt-5 text-body"},x9={class:"container"},k9=Pu(()=>h("h3",{class:"mb-3 text-body"},"Traceroute",-1)),S9={class:"row"},A9={class:"col-sm-4 d-flex gap-2 flex-column"},$9=Pu(()=>h("label",{class:"mb-1 text-muted",for:"ipAddress"},[h("small",null,"IP Address")],-1)),C9=["disabled"],E9=Pu(()=>h("i",{class:"bi bi-bullseye me-2"},null,-1)),P9={class:"col-sm-8 position-relative"},T9={key:"pingPlaceholder"},M9={key:"table",class:"w-100"},D9={class:"table table-borderless rounded-3 w-100"},O9=Pu(()=>h("thead",null,[h("tr",null,[h("th",{scope:"col"},"Hop"),h("th",{scope:"col"},"IP Address"),h("th",{scope:"col"},"Average / Min / Max Round Trip Time")])],-1));function I9(e,t,n,s,i,o){return O(),F("div",w9,[h("div",x9,[k9,h("div",S9,[h("div",A9,[h("div",null,[$9,Re(h("input",{id:"ipAddress",class:"form-control","onUpdate:modelValue":t[0]||(t[0]=r=>this.ipAddress=r),type:"text",placeholder:"Enter an IP Address you want to trace :)"},null,512),[[We,this.ipAddress]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.store.regexCheckIP(this.ipAddress)||this.tracing,onClick:t[1]||(t[1]=r=>this.execute())},[E9,ye(" "+ve(this.tracing?"Tracing...":"Trace It!"),1)],8,C9)]),h("div",P9,[$e(Wi,{name:"ping"},{default:Te(()=>[this.tracerouteResult?(O(),F("div",M9,[h("table",D9,[O9,h("tbody",null,[(O(!0),F(Me,null,Ke(this.tracerouteResult,(r,a)=>(O(),F("tr",{class:"animate__fadeInUp animate__animated",style:Wt({"animation-delay":`${a*.05}s`})},[h("td",null,ve(r.hop),1),h("td",null,ve(r.ip),1),h("td",null,ve(r.avg_rtt)+" / "+ve(r.min_rtt)+" / "+ve(r.max_rtt),1)],4))),256))])])])):(O(),F("div",T9,[(O(),F(Me,null,Ke(10,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.tracing}]),style:Wt({"animation-delay":`${r*.05}s`})},null,6)),64))]))]),_:1})])])])])}const R9=ze(y9,[["render",I9],["__scopeId","data-v-dda37ccf"]]),L9={name:"totp",async setup(){const e=et();let t="";return await Tt("/api/Welcome_GetTotpLink",{},n=>{n.status&&(t=n.data)}),{l:t,store:e}},mounted(){this.l&&Bo.toCanvas(document.getElementById("qrcode"),this.l,function(e){})},data(){return{totp:"",totpInvalidMessage:"",verified:!1}},methods:{validateTotp(){}},watch:{totp(e){const t=document.querySelector("#totp");t.classList.remove("is-invalid","is-valid"),e.length===6&&(console.log(e),/[0-9]{6}/.test(e)?dt("/api/Welcome_VerifyTotpLink",{totp:e},n=>{n.status?(this.verified=!0,t.classList.add("is-valid"),this.$emit("verified")):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP does not match.")}):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP can only contain numbers"))}}},N9=["data-bs-theme"],F9={class:"m-auto text-body",style:{width:"500px"}},B9={class:"d-flex flex-column"},V9=h("h1",{class:"dashboardLogo display-4"},"Multi-Factor Authentication",-1),H9=h("p",{class:"mb-2"},[h("small",{class:"text-muted"},"1. Please scan the following QR Code to generate TOTP")],-1),j9=h("canvas",{id:"qrcode",class:"rounded-3 mb-2"},null,-1),W9={class:"p-3 bg-body-secondary rounded-3 border mb-3"},z9=h("p",{class:"text-muted mb-0"},[h("small",null,"Or you can click the link below:")],-1),Y9=["href"],U9={style:{"line-break":"anywhere"}},K9=h("label",{for:"totp",class:"mb-2"},[h("small",{class:"text-muted"},"2. Enter the TOTP generated by your authenticator to verify")],-1),q9={class:"form-group mb-2"},G9=["disabled"],J9={class:"invalid-feedback"},X9=h("div",{class:"valid-feedback"}," TOTP verified! ",-1),Q9=h("div",{class:"alert alert-warning rounded-3"},[h("i",{class:"bi bi-exclamation-triangle-fill me-2"}),ye(" If you ever lost your TOTP and can't login, please follow instruction on "),h("a",{href:"https://github.com/donaldzou/WGDashboard",target:"_blank"},"readme.md"),ye(" to reset. ")],-1),Z9=h("hr",null,null,-1),eq={class:"d-flex gap-3 mt-5 flex-column"},tq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1),nq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1);function sq(e,t,n,s,i,o){const r=je("RouterLink");return O(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.store.Configuration.Server.dashboard_theme},[h("div",F9,[h("div",B9,[h("div",null,[V9,H9,j9,h("div",W9,[z9,h("a",{href:this.l},[h("code",U9,ve(this.l),1)],8,Y9)]),K9,h("div",q9,[Re(h("input",{class:"form-control text-center totp",id:"totp",maxlength:"6",type:"text",inputmode:"numeric",autocomplete:"one-time-code","onUpdate:modelValue":t[0]||(t[0]=a=>this.totp=a),disabled:this.verified},null,8,G9),[[We,this.totp]]),h("div",J9,ve(this.totpInvalidMessage),1),X9]),Q9]),Z9,h("div",eq,[this.verified?(O(),Ne(r,{key:1,to:"/",class:"btn btn-dark btn-lg d-flex btn-brand shadow align-items-center flex-grow-1 rounded-3"},{default:Te(()=>[ye(" Complete "),nq]),_:1})):(O(),Ne(r,{key:0,to:"/",class:"btn bg-secondary-subtle text-secondary-emphasis rounded-3 flex-grow-1 btn-lg border-1 border-secondary-subtle shadow d-flex"},{default:Te(()=>[ye(" I don't need MFA "),tq]),_:1}))])])])],8,N9)}const iq=ze(L9,[["render",sq]]),oq={name:"share",async setup(){const e=eP(),t=be(!1),n=et(),s=be(""),i=be(""),o=be(new Blob);await Tt("/api/getDashboardTheme",{},a=>{s.value=a.data});const r=e.query.ShareID;return r===void 0||r.length===0?(i.value=void 0,t.value=!0):await Tt("/api/sharePeer/get",{ShareID:r},a=>{a.status?(i.value=a.data,o.value=new Blob([i.value.file],{type:"text/plain"})):i.value=void 0,t.value=!0}),{store:n,theme:s,peerConfiguration:i,blob:o}},mounted(){Bo.toCanvas(document.querySelector("#qrcode"),this.peerConfiguration.file,e=>{e&&console.error(e)})},methods:{download(){const e=new Blob([this.peerConfiguration.file],{type:"text/plain"}),t=URL.createObjectURL(e),n=`${this.peerConfiguration.fileName}.conf`,s=document.createElement("a");s.href=t,s.download=n,s.click()}},computed:{getBlob(){return URL.createObjectURL(this.blob)}}},hp=e=>(en("data-v-99d4b06a"),e=e(),tn(),e),rq=["data-bs-theme"],aq={class:"m-auto text-body",style:{width:"500px"}},lq={key:0,class:"text-center position-relative",style:{}},cq=X$('

Oh no... This link is either expired or invalid.

',2),uq=[cq],dq={key:1,class:"d-flex align-items-center flex-column gap-3"},hq=hp(()=>h("div",{class:"h1 dashboardLogo text-center animate__animated animate__fadeInUp"},[h("h6",null,"WGDashboard"),ye(" Scan QR Code from the WireGuard App ")],-1)),fq={id:"qrcode",class:"rounded-3 shadow animate__animated animate__fadeInUp mb-3",ref:"qrcode"},pq=hp(()=>h("p",{class:"text-muted animate__animated animate__fadeInUp mb-1",style:{"animation-delay":"0.2s"}},[ye("or click the button below to download the "),h("samp",null,".conf"),ye(" file")],-1)),gq=["download","href"],mq=hp(()=>h("i",{class:"bi bi-download"},null,-1)),_q=[mq];function vq(e,t,n,s,i,o){return O(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.theme},[h("div",aq,[this.peerConfiguration?(O(),F("div",dq,[hq,h("canvas",fq,null,512),pq,h("a",{download:this.peerConfiguration.fileName+".conf",href:o.getBlob,class:"btn btn-lg bg-primary-subtle text-primary-emphasis border-1 border-primary-subtle animate__animated animate__fadeInUp shadow-sm",style:{"animation-delay":"0.25s"}},_q,8,gq)])):(O(),F("div",lq,uq))])],8,rq)}const bq=ze(oq,[["render",vq],["__scopeId","data-v-99d4b06a"]]),yq=async()=>{let e=!1;return await Tt("/api/validateAuthentication",{},t=>{e=t.status}),e},gl=QE({history:gE(),routes:[{name:"Index",path:"/",component:YP,meta:{requiresAuth:!0},children:[{name:"Configuration List",path:"",component:EM,meta:{title:"WireGuard Configurations"}},{name:"Settings",path:"/settings",component:TN,meta:{title:"Settings"}},{path:"/ping",name:"Ping",component:b9},{path:"/traceroute",name:"Traceroute",component:R9},{name:"New Configuration",path:"/new_configuration",component:h5,meta:{title:"New Configuration"}},{name:"Configuration",path:"/configuration/:id",component:m5,meta:{title:"Configuration"},children:[{name:"Peers List",path:"peers",component:N7},{name:"Peers Create",path:"create",component:U1}]}]},{path:"/signin",component:qT,meta:{title:"Sign In"}},{path:"/welcome",component:QN,meta:{requiresAuth:!0,title:"Welcome to WGDashboard"}},{path:"/2FASetup",component:iq,meta:{requiresAuth:!0,title:"Multi-Factor Authentication Setup"}},{path:"/share",component:bq,meta:{title:"Share"}}]});gl.beforeEach(async(e,t,n)=>{const s=Bn(),i=et();e.meta.title?e.params.id?document.title=e.params.id+" | WGDashboard":document.title=e.meta.title+" | WGDashboard":document.title="WGDashboard",e.meta.requiresAuth?i.getActiveCrossServer()?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),n()):tP.getCookie("authToken")&&await yq()?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),i.Redirect=void 0,n()):(i.Redirect=e,n("/signin"),i.newMessage("WGDashboard","Session Ended","warning")):n()});const G1=()=>{let e={"content-type":"application/json"};const n=et().getActiveCrossServer();return n&&(e["wg-dashboard-apikey"]=n.apiKey),e},J1=e=>{const n=et().getActiveCrossServer();return n?`${n.host}${e}`:`//${window.location.host}${window.location.pathname}${e}`},Tt=async(e,t=void 0,n=void 0)=>{const s=new URLSearchParams(t);await fetch(`${J1(e)}?${s.toString()}`,{headers:G1()}).then(i=>{const o=et();if(i.ok)return i.json();if(i.status!==200)throw i.status===401&&o.newMessage("WGDashboard","Session Ended","warning"),new Error(i.statusText)}).then(i=>n?n(i):void 0).catch(i=>{console.log(i),gl.push({path:"/signin"})})},dt=async(e,t,n)=>{await fetch(`${J1(e)}`,{headers:G1(),method:"POST",body:JSON.stringify(t)}).then(s=>{const i=et();if(s.ok)return s.json();if(s.status!==200)throw s.status===401&&i.newMessage("WGDashboard","Session Ended","warning"),new Error(s.statusText)}).then(s=>n?n(s):void 0).catch(s=>{console.log(s),gl.push({path:"/signin"})})},et=bf("DashboardConfigurationStore",{state:()=>({Redirect:void 0,Configuration:void 0,Messages:[],Peers:{Selecting:!1,RefreshInterval:void 0},CrossServerConfiguration:{Enable:!1,ServerList:{}},ActiveServerConfiguration:void 0,IsElectronApp:!1}),actions:{initCrossServerConfiguration(){const e=localStorage.getItem("CrossServerConfiguration");localStorage.getItem("ActiveCrossServerConfiguration")!==null&&(this.ActiveServerConfiguration=localStorage.getItem("ActiveCrossServerConfiguration")),e===null?localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration)):this.CrossServerConfiguration=JSON.parse(e)},syncCrossServerConfiguration(){localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration))},addCrossServerConfiguration(){this.CrossServerConfiguration.ServerList[Ms().toString()]={host:"",apiKey:"",active:!1}},deleteCrossServerConfiguration(e){delete this.CrossServerConfiguration.ServerList[e]},getActiveCrossServer(){const e=localStorage.getItem("ActiveCrossServerConfiguration");if(e!==null)return this.CrossServerConfiguration.ServerList[e]},setActiveCrossServer(e){this.ActiveServerConfiguration=e,localStorage.setItem("ActiveCrossServerConfiguration",e)},removeActiveCrossServer(){this.ActiveServerConfiguration=void 0,localStorage.removeItem("ActiveCrossServerConfiguration")},async getConfiguration(){await Tt("/api/getDashboardConfiguration",{},e=>{e.status&&(this.Configuration=e.data)})},async updateConfiguration(){await dt("/api/updateDashboardConfiguration",{DashboardConfiguration:this.Configuration},e=>{console.log(e)})},async signOut(){await Tt("/api/signout",{},e=>{this.removeActiveCrossServer(),this.$router.go("/signin")})},newMessage(e,t,n){this.Messages.push({id:Ms(),from:e,content:t,type:n,show:!0})}}}),fp=e=>(en("data-v-739a0103"),e=e(),tn(),e),wq={class:"navbar bg-dark sticky-top border-bottom border-secondary-subtle","data-bs-theme":"dark"},xq={class:"container-fluid d-flex text-body align-items-center"},kq=fp(()=>h("span",{class:"navbar-brand mb-0 h1"},"WGDashboard",-1)),Sq={key:0,class:"ms-auto text-muted"},Aq=fp(()=>h("i",{class:"bi bi-server me-2"},null,-1)),$q=fp(()=>h("a",{role:"button"},[h("i",{class:"bi bi-list"})],-1)),Cq={__name:"App",setup(e){const t=et();t.initCrossServerConfiguration(),window.IS_WGDASHBOARD_DESKTOP&&(t.IsElectronApp=!0,t.CrossServerConfiguration.Enable=!0),Vt(t.CrossServerConfiguration,()=>{t.syncCrossServerConfiguration()},{deep:!0});const n=_e(()=>{if(t.ActiveServerConfiguration)return t.CrossServerConfiguration.ServerList[t.ActiveServerConfiguration]});return(s,i)=>(O(),F(Me,null,[h("nav",wq,[h("div",xq,[kq,n.value!==void 0?(O(),F("small",Sq,[Aq,ye(ve(n.value.host),1)])):ae("",!0),$q])]),(O(),Ne(uf,null,{default:Te(()=>[$e(q(ky),null,{default:Te(({Component:o})=>[$e(Bt,{name:"app",mode:"out-in"},{default:Te(()=>[(O(),Ne(Io(o)))]),_:2},1024)]),_:1})]),_:1}))],64))}},Eq=ze(Cq,[["__scopeId","data-v-739a0103"]]),pp=HC(Eq);pp.use(gl);const X1=YC();X1.use(({store:e})=>{e.$router=tu(gl)});pp.use(X1);pp.mount("#app"); diff --git a/src/static/app/src/utilities/fetch.js b/src/static/app/src/utilities/fetch.js index f9ef191..bad0428 100644 --- a/src/static/app/src/utilities/fetch.js +++ b/src/static/app/src/utilities/fetch.js @@ -19,7 +19,7 @@ const getUrl = (url) => { if (apiKey){ return `${apiKey.host}${url}` } - return url + return `//${window.location.host}${window.location.pathname}${url}` } export const fetchGet = async (url, params=undefined, callback=undefined) => { diff --git a/src/templates/index.html b/src/templates/index.html index d777e65..6183d19 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -13,8 +13,8 @@ - - + +