mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-25 00:50:29 +00:00
Merge branch 'master' into ui/escape-interface-settings
This commit is contained in:
commit
ff21343751
5 changed files with 128 additions and 8 deletions
10
dist/css/custom.css
vendored
10
dist/css/custom.css
vendored
|
@ -59,3 +59,13 @@ pre.unstyled {
|
|||
background-color: transparent;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.dhcp-static-leases {
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.dhcp-static-lease-row {
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,16 @@ function DisplayDHCPConfig()
|
|||
$config .= $_POST['RangeLeaseTime'];
|
||||
}
|
||||
|
||||
$config .= $_POST['RangeLeaseTimeUnits'];
|
||||
$config .= $_POST['RangeLeaseTimeUnits'].PHP_EOL;
|
||||
|
||||
for ($i=0; $i < count($_POST["static_leases"]["mac"]); $i++) {
|
||||
$mac = trim($_POST["static_leases"]["mac"][$i]);
|
||||
$ip = trim($_POST["static_leases"]["ip"][$i]);
|
||||
if ($mac != "" && $ip != "") {
|
||||
$config .= "dhcp-host=$mac,$ip".PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents("/tmp/dhcpddata", $config);
|
||||
system('sudo cp /tmp/dhcpddata '.RASPI_DNSMASQ_CONFIG, $return);
|
||||
} else {
|
||||
|
@ -114,6 +123,9 @@ function DisplayDHCPConfig()
|
|||
$RangeEnd = $arrRange[1];
|
||||
$RangeMask = $arrRange[2];
|
||||
$leaseTime = $arrRange[3];
|
||||
$dhcpHost = $conf["dhcp-host"];
|
||||
$dhcpHost = empty($dhcpHost) ? [] : $dhcpHost;
|
||||
$dhcpHost = is_array($dhcpHost) ? $dhcpHost : [ $dhcpHost ];
|
||||
|
||||
$hselected = '';
|
||||
$mselected = '';
|
||||
|
@ -144,10 +156,13 @@ function DisplayDHCPConfig()
|
|||
<!-- /.panel-heading -->
|
||||
<div class="panel-body">
|
||||
<p><?php $status->showMessages(); ?></p>
|
||||
<form method="POST" action="?page=dhcpd_conf" class="js-dhcp-settings-form">
|
||||
<?php CSRFToken() ?>
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="#server-settings" data-toggle="tab"><?php echo _("Server settings"); ?></a>
|
||||
</li>
|
||||
<li><a href="#static-leases" data-toggle="tab"><?php echo _("Static Leases") ?></a></li>
|
||||
<li><a href="#client-list" data-toggle="tab"><?php echo _("Client list"); ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -155,8 +170,6 @@ function DisplayDHCPConfig()
|
|||
<div class="tab-content">
|
||||
<div class="tab-pane fade in active" id="server-settings">
|
||||
<h4>DHCP server settings</h4>
|
||||
<form method="POST" action="?page=dhcpd_conf">
|
||||
<?php CSRFToken() ?>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="code">Interface</label>
|
||||
|
@ -216,7 +229,6 @@ foreach ($interfaces as $inet) {
|
|||
echo'<input type="submit" class="btn btn-success" value="' . _("Start dnsmasq") . '" name="startdhcpd" />';
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
</div><!-- /.tab-pane -->
|
||||
|
||||
<div class="tab-pane fade in" id="client-list">
|
||||
|
@ -256,7 +268,65 @@ foreach ($leases as $lease) {
|
|||
</div><!-- /.panel -->
|
||||
</div><!-- /.col-lg-6 -->
|
||||
</div><!-- /.tab-pane -->
|
||||
|
||||
<div class="tab-pane fade in" id="static-leases">
|
||||
<div class="dhcp-static-leases js-dhcp-static-lease-container">
|
||||
<?php foreach ($dhcpHost as $host): ?>
|
||||
<?php list($mac, $ip) = array_map("trim", explode(",", $host)); ?>
|
||||
<div class="row dhcp-static-lease-row js-dhcp-static-lease-row">
|
||||
<div class="col-md-5 col-xs-5">
|
||||
<input type="text" name="static_leases[mac][]" value="<?php echo htmlspecialchars($mac, ENT_QUOTES) ?>" placeholder="<?php echo _("MAC address") ?>" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-5 col-xs-4">
|
||||
<input type="text" name="static_leases[ip][]" value="<?php echo htmlspecialchars($ip, ENT_QUOTES) ?>" placeholder="<?php echo _("IP address") ?>" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-2 col-xs-3">
|
||||
<button type="button" class="btn btn-danger js-remove-dhcp-static-lease"><?php echo _("Remove") ?></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
<h5><?php echo _("Add static DHCP lease") ?></h5>
|
||||
<div class="row dhcp-static-lease-row js-new-dhcp-static-lease">
|
||||
<div class="col-md-5 col-xs-5">
|
||||
<input type="text" name="mac" value="" placeholder="<?php echo _("MAC address") ?>" class="form-control" autofocus="autofocus">
|
||||
</div>
|
||||
<div class="col-md-5 col-xs-4">
|
||||
<input type="text" name="ip" value="" placeholder="<?php echo _("IP address") ?>" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-2 col-xs-3">
|
||||
<button type="button" class="btn btn-success js-add-dhcp-static-lease"><?php echo _("Add") ?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template id="js-dhcp-static-lease-row">
|
||||
<div class="row dhcp-static-lease-row js-dhcp-static-lease-row">
|
||||
<div class="col-md-5 col-xs-5">
|
||||
<input type="text" name="static_leases[mac][]" value="{{ mac }}" placeholder="<?php echo _("MAC address") ?>" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-5 col-xs-4">
|
||||
<input type="text" name="static_leases[ip][]" value="{{ ip }}" placeholder="<?php echo _("IP address") ?>" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-2 col-xs-3">
|
||||
<button type="button" class="btn btn-warning js-remove-dhcp-static-lease"><?php echo _("Remove") ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" />
|
||||
<?php
|
||||
|
||||
if ($dnsmasq_state) {
|
||||
echo '<input type="submit" class="btn btn-warning" value="' . _("Stop dnsmasq") . '" name="stopdhcpd" />';
|
||||
} else {
|
||||
echo'<input type="submit" class="btn btn-success" value="' . _("Start dnsmasq") . '" name="startdhcpd" />';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
</div><!-- /.tab-content -->
|
||||
</form>
|
||||
</div><!-- ./ Panel body -->
|
||||
<div class="panel-footer"> <?php echo _("Information provided by Dnsmasq"); ?></div>
|
||||
</div><!-- /.panel-primary -->
|
||||
|
|
|
@ -145,9 +145,17 @@ function ParseConfig($arrConfig)
|
|||
$config = array();
|
||||
foreach ($arrConfig as $line) {
|
||||
$line = trim($line);
|
||||
if ($line != "" && $line[0] != "#") {
|
||||
$arrLine = explode("=", $line);
|
||||
$config[$arrLine[0]] = ( count($arrLine) > 1 ? $arrLine[1] : true );
|
||||
if ($line == "" || $line[0] == "#") { continue; }
|
||||
|
||||
list($option, $value) = array_map("trim", explode("=", $line, 2));
|
||||
|
||||
if (empty($config[$option])) {
|
||||
$config[$option] = $value ?: true;
|
||||
} else {
|
||||
if (!is_array($config[$option])) {
|
||||
$config[$option] = [ $config[$option] ];
|
||||
}
|
||||
$config[$option][] = $value;
|
||||
}
|
||||
}
|
||||
return $config;
|
||||
|
|
|
@ -11,7 +11,12 @@ function DisplayHostAPDConfig()
|
|||
$status = new StatusMessages();
|
||||
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
|
||||
$arrConfig = array();
|
||||
$arr80211Standard = array('a','b','g','n');
|
||||
$arr80211Standard = [
|
||||
'a' => '802.11a - 5 GHz',
|
||||
'b' => '802.11b - 2.4 GHz',
|
||||
'g' => '802.11g - 2.4 GHz',
|
||||
'n' => '802.11n - 2.4 GHz'
|
||||
];
|
||||
$arrSecurity = array(1 => 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
|
||||
$arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
|
||||
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
|
||||
|
|
27
js/custom.js
27
js/custom.js
|
@ -122,6 +122,33 @@ function applyNetworkSettings() {
|
|||
});
|
||||
}
|
||||
|
||||
$(document).on("click", ".js-add-dhcp-static-lease", function(e) {
|
||||
e.preventDefault();
|
||||
var container = $(".js-new-dhcp-static-lease");
|
||||
var mac = $("input[name=mac]", container).val().trim();
|
||||
var ip = $("input[name=ip]", container).val().trim();
|
||||
if (mac == "" || ip == "") {
|
||||
return;
|
||||
}
|
||||
|
||||
var row = $("#js-dhcp-static-lease-row").html()
|
||||
.replace("{{ mac }}", mac)
|
||||
.replace("{{ ip }}", ip);
|
||||
$(".js-dhcp-static-lease-container").append(row);
|
||||
|
||||
$("input[name=mac]", container).val("");
|
||||
$("input[name=ip]", container).val("");
|
||||
});
|
||||
|
||||
$(document).on("click", ".js-remove-dhcp-static-lease", function(e) {
|
||||
e.preventDefault();
|
||||
$(this).parents(".js-dhcp-static-lease-row").remove();
|
||||
});
|
||||
|
||||
$(document).on("submit", ".js-dhcp-settings-form", function(e) {
|
||||
$(".js-add-dhcp-static-lease").trigger("click");
|
||||
});
|
||||
|
||||
function setupBtns() {
|
||||
$('#btnSummaryRefresh').click(function(){getAllInterfaces();});
|
||||
|
||||
|
|
Loading…
Reference in a new issue