Add unconfigured client state to dashboard.php

Add tun device as client_udev_prototypes.json
This commit is contained in:
Christian Zeitnitz 2021-03-27 17:43:15 +01:00
parent 43043d48e4
commit 5b9d4ca814
6 changed files with 23 additions and 9 deletions

View File

@ -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.

View File

@ -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",
}
]
}

View File

@ -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(

View File

@ -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;
}
}

View File

@ -9,7 +9,7 @@
<div class="col">
<button class="btn btn-light btn-icon-split btn-sm service-status float-right">
<span class="icon"><i class="fas fa-circle service-status-<?php echo $ifaceStatus ?>"></i></span>
<span class="text service-status"><?php echo $type_name .' '. _($ifaceStatus) ?></span>
<span class="text service-status"><?php echo $type_name . ($ifaceStatus!="warn") echo ' '. _($ifaceStatus) ?></span>
</button>
</div>
</div><!-- /.row -->
@ -66,7 +66,7 @@
<div class="info-item"><?php echo _("Device"); ?></div><div><?php $valEcho($clientinfo,"vendor")." ".$valEcho($clientinfo,"model"); ?></div>
<div class="info-item"><?php echo _("IP Address"); ?></div><div><?php echo $valEcho($clientinfo,"ipaddress"); ?></div>
<?php else : // NO CLIENT ?>
<div class="info-item"><?php echo _("No Client device found"); ?></div>
<div class="info-item"><?php echo _("No Client foudn or client is not unconfigured yet"); ?></div>
<?php endif; ?>
</div>
<div class="col-md mt-2 d-flex justify-content-center">
@ -139,7 +139,7 @@
<?php if (!RASPI_MONITOR_ENABLED) : ?>
<?php if ($ifaceStatus == "down") : ?>
<input type="submit" class="btn btn-success" value="<?php echo _("Start").' '.$type_name ?>" name="ifup_wlan0" data-toggle="modal" data-target="#switchClientModal"/>
<?php else : ?>
<?php elseif ($ifaceStatus == "up") : ?>
<input type="submit" class="btn btn-warning" value="<?php echo _("Stop").' '.$type_name ?>" name="ifdown_wlan0" data-toggle="modal" data-target="#switchClientModal"/>
<?php endif ?>
<?php endif ?>

View File

@ -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 '<td><select '.$txtdisabled.' class="selectpicker" id="int-new-type-'.$dev["name"].'">';
foreach($_SESSION["net-device-types"] as $i => $type) {
$txt=$_SESSION["net-device-types-info"][$i];
$txtdisabled = $type == "ppp" ? "disabled":"";
$txtdisabled = in_array($type,array("ppp","tun")) ? "disabled":"";
if(preg_match("/^".$_SESSION["net-device-name-prefix"][$i]."[0-9]*$/",$dev["name"])===1) echo '<option '.$txtdisabled.' selected value="'.$type.'">'.$txt.'</option>';
else echo '<option '.$txtdisabled.' value="'.$type.'">'.$txt.'</option>';
}