From 5b9d4ca8143fb691a560fb36c6e97bb031437c96 Mon Sep 17 00:00:00 2001 From: Christian Zeitnitz Date: Sat, 27 Mar 2021 17:43:15 +0100 Subject: [PATCH] Add unconfigured client state to dashboard.php Add tun device as client_udev_prototypes.json --- app/js/custom.js | 5 +++++ config/client_udev_prototypes.json | 7 +++++++ includes/dashboard.php | 3 ++- includes/get_clients.php | 7 ++++--- templates/dashboard.php | 6 +++--- templates/networking.php | 4 ++-- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/js/custom.js b/app/js/custom.js index 571e6404..f3627528 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -300,6 +300,11 @@ $('#ovpn-confirm-activate').on('shown.bs.modal', function (e) { $('.btn-activate', this).data('recordId', data.recordId); }); +// Add the following code if you want the name of the file appear on select +$(".custom-file-input").on("change", function() { + var fileName = $(this).val().split("\\").pop(); + $(this).siblings(".custom-file-label").addClass("selected").html(fileName); +}); /* Sets the wirelss channel select options based on hw_mode and country_code. diff --git a/config/client_udev_prototypes.json b/config/client_udev_prototypes.json index 9cbf32a8..fe4f5249 100644 --- a/config/client_udev_prototypes.json +++ b/config/client_udev_prototypes.json @@ -51,6 +51,13 @@ "comment": "ethernet access provided by tethering from phone via USB", "name_prefix": "phone", "udev_rule": "SUBSYSTEM==\"net\", ACTION==\"add\", SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"$IDVENDOR$\", ATTRS{idProduct}==\"$IDPRODUCT$\", NAME=\"$DEVNAME$\" " + }, + { + "type": "tun", + "type_info": "tunnel device", + "clientid": -1, + "comment": "tunneling device used by OpenVPN", + "name_prefix": "tun", } ] } diff --git a/includes/dashboard.php b/includes/dashboard.php index 0fd6a8a1..d2f06ee9 100755 --- a/includes/dashboard.php +++ b/includes/dashboard.php @@ -173,7 +173,8 @@ function DisplayDashboard(&$extraFooterScripts) break; default: $client_title = "No information for client available"; - $type_name = "No Client"; + $type_name = "Not configured"; + $ifaceStatus = "warn"; } echo renderTemplate( diff --git a/includes/get_clients.php b/includes/get_clients.php index 4c669f40..b30358ff 100644 --- a/includes/get_clients.php +++ b/includes/get_clients.php @@ -198,9 +198,10 @@ function findCurrentClientIndex($clients) $ncl=$clients["clients"]; if($ncl > 0) { $ty=-1; - foreach($clients["device"] as $i => $dev) { - if(($id=array_search($dev["type"], $_SESSION["net-device-types"])) > $ty && !$dev["isAP"]) { - $ty=$id; + foreach($clients["device"] as $i => $dev) { + $id=array_search($dev["type"],$_SESSION["net-device-types"]); + if($id >=0 && $_SESSION["udevrules"]["network_devices"][$id]["clientid"] > $ty && !$dev["isAP"]) { + $ty=$id; $devid=$i; } } diff --git a/templates/dashboard.php b/templates/dashboard.php index acadda95..ca2db13f 100755 --- a/templates/dashboard.php +++ b/templates/dashboard.php @@ -9,7 +9,7 @@
@@ -66,7 +66,7 @@
-
+
@@ -139,7 +139,7 @@ " name="ifup_wlan0" data-toggle="modal" data-target="#switchClientModal"/> - + " name="ifdown_wlan0" data-toggle="modal" data-target="#switchClientModal"/> diff --git a/templates/networking.php b/templates/networking.php index 0bcf5c54..9b93f08d 100755 --- a/templates/networking.php +++ b/templates/networking.php @@ -135,12 +135,12 @@ if(!empty($devname)) $devname=$devname[0]; } if(empty($devname)) $devname=""; - $isStatic = $isStatic || $dev["type"] === "ppp"; + $isStatic = $isStatic || in_array($dev["type"],array("ppp","tun")); $txtdisabled=$isStatic ? "disabled":""; echo '