1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2025-07-09 14:37:40 +02:00

Get installed plugins, add status checks for services

This commit is contained in:
billz 2025-03-16 03:33:10 -07:00
parent 1a964a283f
commit ef04678947
2 changed files with 28 additions and 15 deletions

View File

@ -9,10 +9,15 @@ require_once 'includes/functions.php';
*/
function DisplayDashboard()
{
// instantiate RaspAP objects
$status = new \RaspAP\Messages\StatusMessage;
$system = new \RaspAP\System\Sysinfo;
$pluginManager = \RaspAP\Plugins\PluginManager::getInstance();
$hostname = $system->hostname();
$revision = $system->rpiRevision();
$hostapd = $system->hostapdStatus();
$adblock = $system->adBlockStatus();
getWifiInterface();
@ -26,7 +31,7 @@ function DisplayDashboard()
$ipv4Addrs = '';
$ipv4Netmasks = '';
if (!preg_match_all('/inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\/([0-3][0-9])/i', $stdoutIpWRepeatedSpaces, $matchesIpv4AddrAndSubnet, PREG_SET_ORDER)) {
$ipv4Addrs = _('No IPv4 Address Found');
$ipv4Addrs = _('None');
} else {
foreach ($matchesIpv4AddrAndSubnet as $inet) {
$address = $inet[1];
@ -152,6 +157,15 @@ function DisplayDashboard()
exec('cat ' . RASPI_DNSMASQ_LEASES . '| grep -E $(iw dev ' . $apInterface . ' station dump | grep -oE ' . $MACPattern . ' | paste -sd "|")', $clients);
}
$ifaceStatus = $wlan0up ? "up" : "down";
$plugins = $pluginManager->getInstalledPlugins();
$bridgedStatus = ($bridgedEnable == 1) ? "active" : "";
$hostapdStatus = ($hostapd[0] == 1) ? "active" : "";
$adblockStatus = ($adblock == true) ? "active" : "";
$firewallInstalled = array_filter($plugins, fn($p) => str_ends_with($p, 'Firewall')) ? true : false;
if (!$firewallInstalled) {
$firewallStack = '<i class="fas fa-slash fa-stack-1x"></i>';
}
echo renderTemplate(
"dashboard", compact(
"clients",
@ -159,7 +173,10 @@ function DisplayDashboard()
"apInterface",
"clientInterface",
"ifaceStatus",
"bridgedEnable",
"bridgedStatus",
"hostapdStatus",
"adblockStatus",
"firewallStack",
"status",
"ipv4Addrs",
"ipv4Netmasks",

View File

@ -47,27 +47,29 @@
<img src="app/img/solid.php?joint&device-1&out&device-3" class="solid-lines" alt="">
</div>
<div class="center-device col-12 col-lg-4">
<div class="top" style="margin-bottom: 50px">
<div class="center-device-top">
<a href="/system_info"><img class="device-illustration" src="app/img/device.svg" alt="<?php echo htmlspecialchars($revision, ENT_QUOTES); ?>"></a>
<div class="device-label"><a href="/system_info"><?php echo htmlspecialchars($revision, ENT_QUOTES); ?></a></div>
<div class="mt-1">IP address: <a href="/dhcpd_conf"><?php echo htmlspecialchars($ipv4Addrs, ENT_QUOTES); ?></a></div>
<div>SSID: <a href="/hostapd_conf"><?php echo htmlspecialchars("RaspAP", ENT_QUOTES); ?></a></div>
</div>
<div class="bottom">
<div class="device-status">
<a href="/hostapd_conf">
<div class="status-item active">
<div class="status-item <?php echo $hostapdStatus; ?>">
<i class="fas fa-bullseye fa-2xl"></i>
<span><?php echo _('AP'); ?></span>
</div>
</a>
<a href="/hostapd_conf">
<div class="status-item">
<div class="status-item <?php echo $bridgedStatus; ?>">
<i class="fas fa-bridge fa-2xl"></i>
<span><?php echo _('Bridged'); ?></span>
</div>
</a>
<a href="/adblock_conf">
<div class="status-item active">
<div class="status-item <?php echo $adblockStatus; ?>">
<i class="far fa-hand-paper fa-2xl"></i>
<span><?php echo _('Adblock'); ?></span>
</div>
@ -76,10 +78,10 @@
<i class="fas fa-shield-alt fa-2xl"></i>
<span><?php echo _('VPN'); ?></span>
</div>
<div class="status-item disabled">
<div class="status-item <?php echo $firewallStatus; ?>">
<span class="fa-stack fa-2xl" style="line-height: 0!important;height: 100%!important;">
<i class="fas fa-fire-flame-curved fa-stack-1x"></i>
<i class="fas fa-slash fa-stack-1x"></i>
<?php echo $firewallStack; ?>
</span>
<span>
<?php echo _('Firewall'); ?>
@ -153,10 +155,4 @@
</div><!-- /.card -->
</div><!-- /.col-lg-12 -->
</div><!-- /.row -->
<script type="text/javascript"<?php //echo ' nonce="'.$csp_page_nonce.'"'; ?>>
// js translations:
var t = new Array();
t[' send'] = '<?php echo addslashes(_(' Send')); ?>';
t['receive'] = '
<? php echo addslashes(_('Receive')); ?> ';
</script>