Merge pull request #491 from billz/dashboard-redesign

Dashboard redesign
This commit is contained in:
Bill Zimmerman 2020-02-03 12:52:35 +01:00 committed by GitHub
commit f4e8fbd6c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 548 additions and 300 deletions

View File

@ -6,8 +6,9 @@ body {
margin: 20px 0 20px;
}
.page-header .logo {
margin-right: 5px;
.navbar-logo {
margin-top: 0.5em;
margin-left: 0.5em;
}
/* Small devices (portrait phones, up to 576px) */
@ -100,6 +101,11 @@ i.fa.fa-bars:hover{
float: left;
}
.info-item-xs {
font-size: 0.7rem;
margin-left: 0.3rem;
}
.info-item-wifi {
width: 6rem;
float: left;
@ -125,11 +131,15 @@ i.fa.fa-bars:hover{
}
.service-status-up {
color: green;
color: #a1ec38;
}
.service-status-warn {
color: #f6f044;
}
.service-status-down {
color: red;
color: #f80107;
animation: flash 1s linear infinite;
}
@keyframes flash {
@ -191,3 +201,15 @@ pre.unstyled {
font-size: 0.9rem!important;
}
canvas#divDBChartBandwidthhourly {
height: 350px!important;
}
.chart-container {
height: 150px;
width: 200px;
}
.table {
margin-bottom: 0rem;
}

View File

@ -215,3 +215,14 @@ pre.unstyled {
font-size: 0.9rem!important;
}
canvas#divDBChartBandwidthhourly {
height: 350px!important;
}
.chart-container {
height: 150px;
width: 200px;
}
.table {
margin-bottom: 0rem;
}

View File

@ -394,3 +394,15 @@ pre {
font-size: 0.9rem!important;
}
canvas#divDBChartBandwidthhourly {
height: 350px!important;
}
.chart-container {
height: 150px;
width: 200px;
}
.table {
margin-bottom: 0rem;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 98 KiB

46
app/img/raspAP-logo.svg Normal file
View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 490.66666 487.11066"
height="487.11066"
width="490.66666"
xml:space="preserve"
id="svg2"
version="1.1"><metadata
id="metadata8"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs6"><clipPath
id="clipPath18"
clipPathUnits="userSpaceOnUse"><path
id="path16"
d="M 0,365.333 H 368 V 0 H 0 Z" /></clipPath></defs><g
transform="matrix(1.3333333,0,0,-1.3333333,0,487.11067)"
id="g10"><g
id="g12"><g
clip-path="url(#clipPath18)"
id="g14"><g
transform="translate(192.6768,123.4365)"
id="g20"><path
id="path22"
style="fill:#d8224c;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c 0,-37.169 -30.128,-67.3 -67.296,-67.3 -37.167,0 -67.294,30.131 -67.294,67.3 0,37.165 30.127,67.296 67.294,67.296 C -30.128,67.296 0,37.165 0,0" /></g><g
transform="translate(125.3823,219.0791)"
id="g24"><path
id="path26"
style="fill:#d8224c;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c -52.737,0 -95.641,-42.905 -95.641,-95.643 0,-52.74 42.904,-95.647 95.641,-95.647 52.737,0 95.642,42.907 95.642,95.647 C 95.642,-42.905 52.737,0 0,0 m 0,-217.29 c -67.073,0 -121.641,54.571 -121.641,121.647 C -121.641,-28.569 -67.073,26 0,26 67.074,26 121.642,-28.569 121.642,-95.643 121.642,-162.719 67.074,-217.29 0,-217.29" /></g><g
transform="translate(144.4277,271.9385)"
id="g28"><path
id="path30"
style="fill:#d8224c;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c 66.188,0 121.118,-49.055 130.392,-112.714 l 28.259,-1.874 C 150.044,-34.655 82.181,27.791 0,27.791 c -3.892,0 -7.75,-0.147 -11.571,-0.423 L -9.73,-0.397 C -6.513,-0.161 -3.275,0 0,0" /></g><g
transform="translate(144.4883,334.7588)"
id="g32"><path
id="path34"
style="fill:#d8224c;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 0,0 c 101.94,0 185.667,-79.438 192.56,-179.664 l 27.962,-1.857 C 214.513,-65.087 117.899,27.791 0,27.791 c -5.31,0 -10.576,-0.2 -15.792,-0.571 l 1.84,-27.728 C -9.343,-0.177 -4.691,0 0,0" /></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

106
app/js/dashboardchart.js Normal file
View File

@ -0,0 +1,106 @@
(function($, _t) {
"use strict";
/**
* Create a Chart.js barchart.
*/
function CreateChart(ctx, labels) {
var barchart = new Chart(ctx,{
type: 'line',
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
xAxes: [{
scaleLabel: {
display: true
},
ticks: {
maxRotation: 0,
minRotation: 0
}
}],
yAxes: [{
id: 'y-axis-1',
type: 'linear',
display: true,
position: 'left',
ticks: {
beginAtZero: true
}
}]
}
},
data: {
labels: labels,
datasets: []
}
});
return barchart;
}
function ShowBandwidthChartHandler(e) {
// Remove hourly chartjs chart
$('#divDBChartBandwidthhourly').empty();
// Construct ajax uri for getting the proper data
var timeunit = 'hourly';
var uri = 'ajax/bandwidth/get_bandwidth.php?';
uri += 'inet=';
uri += encodeURIComponent($('#divInterface').text());
uri += '&tu=';
uri += encodeURIComponent(timeunit.substr(0, 1));
var datasizeunits = 'mb';
uri += '&dsu='+encodeURIComponent(datasizeunits);
// Get data for chart
$.ajax({
url: uri,
dataType: 'json',
beforeSend: function() {}
}).done(function(jsondata) {
// Map json values to label array
var labels = jsondata.map(function(e) {
return e.date;
});
// Init. chart with label series
var barchart = CreateChart('divDBChartBandwidth'+timeunit, labels);
var dataRx = jsondata.map(function(e) {
return e.rx;
});
var dataTx = jsondata.map(function(e) {
return e.tx;
});
addData(barchart, dataTx, dataRx, datasizeunits);
}).fail(function(xhr, textStatus) {
if (window.console) {
console.error('server error');
} else {
alert("server error");
}
});
}
/**
* Add data array to datasets of current chart.
*/
function addData(chart, dataTx, dataRx, datasizeunits) {
chart.data.datasets.push({
label: 'Send'+' '+datasizeunits.toUpperCase(),
yAxisID: 'y-axis-1',
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
data: dataTx
});
chart.data.datasets.push({
label: 'Receive'+' '+datasizeunits.toUpperCase(),
yAxisID: 'y-axis-1',
borderColor: 'rgba(192, 192, 192, 1)',
backgroundColor: 'rgba(192, 192, 192, 0.2)',
data: dataRx
});
chart.update();
}
$(document).ready(function() {
ShowBandwidthChartHandler();
});
})(jQuery, t);

View File

@ -3,84 +3,84 @@
// Support for dark terminal theme
theme = getCookie('theme');
if (theme == 'terminal.css') {
var bgColor1 = '#000';
var bgColor2 = '#000';
var borderColor = 'rgba(46, 230, 0, 1)';
var labelColor = 'rgba(46, 230, 0, 1)';
var bgColor1 = '#000';
var bgColor2 = '#000';
var borderColor = 'rgba(46, 230, 0, 1)';
var labelColor = 'rgba(46, 230, 0, 1)';
} else {
var bgColor1 = '#d4edda';
var bgColor2 = '#eaecf4';
var borderColor = 'rgba(147, 210, 162, 1)';
var labelColor = 'rgba(130, 130, 130, 1)';
var bgColor1 = '#d4edda';
var bgColor2 = '#eaecf4';
var borderColor = 'rgba(147, 210, 162, 1)';
var labelColor = 'rgba(130, 130, 130, 1)';
}
let data1 = {
datasets: [{
data: [linkQ, 100-linkQ],
backgroundColor: [bgColor1, bgColor2],
borderColor: borderColor,
}],
datasets: [{
data: [linkQ, 100-linkQ],
backgroundColor: [bgColor1, bgColor2],
borderColor: borderColor,
}],
};
let config = {
type: 'doughnut',
data: data1,
options: {
aspectRatio: 2,
responsive: true,
tooltips: {enabled: false},
hover: {mode: null},
legend: {
display: false,
},
rotation: (2/3)*Math.PI,//2+(1/3),
circumference: (1+(2/3)) * Math.PI, // * Math.PI,
cutoutPercentage: 80,
animation: {
animateScale: false,
animateRotate: true
},
tooltips: {
enabled: false
}
type: 'doughnut',
data: data1,
options: {
aspectRatio: 2,
responsive: true,
maintainAspectRatio: false,
tooltips: {enabled: false},
hover: {mode: null},
legend: {
display: false,
},
centerText: {
display: true,
text: linkQ + "%"
rotation: (2/3)*Math.PI,//2+(1/3),
circumference: (1+(2/3)) * Math.PI, // * Math.PI,
cutoutPercentage: 80,
animation: {
animateScale: false,
animateRotate: true
},
tooltips: {
enabled: false
}
};
Chart.Chart.pluginService.register({
},
centerText: {
display: true,
text: linkQ + "%"
},
plugins: [{
beforeDraw: function(chart) {
if (chart.config.centerText.display !== null &&
typeof chart.config.centerText.display !== 'undefined' &&
chart.config.centerText.display) {
drawLinkQ(chart);
}
if (chart.config.centerText.display !== null &&
typeof chart.config.centerText.display !== 'undefined' &&
chart.config.centerText.display) {
drawLinkQ(chart);
}
}
});
}]
};
function drawLinkQ(chart) {
let width = chart.chart.width;
let height = chart.chart.height;
let ctx = chart.chart.ctx;
let width = chart.chart.width;
let height = chart.chart.height;
let ctx = chart.chart.ctx;
ctx.restore();
let fontSize = (height / 100).toFixed(2);
ctx.font = fontSize + "em sans-serif";
ctx.fillStyle = labelColor;
ctx.textBaseline = "middle";
ctx.restore();
let fontSize = (height / 100).toFixed(2);
ctx.font = fontSize + "em sans-serif";
ctx.fillStyle = labelColor;
ctx.textBaseline = "middle";
let text = chart.config.centerText.text;
let textX = Math.round((width - ctx.measureText(text).width) * 0.5);
let textY = height / 2;
ctx.fillText(text, textX, textY);
ctx.save();
let text = chart.config.centerText.text;
let textX = Math.round((width - ctx.measureText(text).width) * 0.5);
let textY = height / 2;
ctx.fillText(text, textX, textY);
ctx.save();
}
window.onload = function() {
let ctx = document.getElementById("canvas").getContext("2d");
window.myDoughnut = new Chart(ctx, config);
let ctx = document.getElementById("divChartLinkQ").getContext("2d");
var chart = new Chart(ctx, config);
};

View File

@ -50,5 +50,10 @@ class System {
$cpuTemp = file_get_contents("/sys/class/thermal/thermal_zone0/temp");
return number_format($cpuTemp/1000, 1);
}
}
public function hostapdStatus() {
exec('pidof hostapd | wc -l', $status);
return $status;
}
}

View File

@ -3,7 +3,7 @@
/**
* Show dashboard page.
*/
function DisplayDashboard()
function DisplayDashboard(&$extraFooterScripts)
{
$status = new StatusMessages();
@ -102,7 +102,7 @@ function DisplayDashboard()
if (!preg_match('/SSID: ([^ ]{1,'.SSIDMAXLEN.'})/', $stdoutIwWRepSpaces, $matchesSSID)) {
$wlanHasLink = false;
$matchesSSID[1] = 'Not connected';
$matchesSSID[1] = 'None';
}
$connectedSSID = $matchesSSID[1];
@ -194,6 +194,7 @@ function DisplayDashboard()
"strLinkQuality",
"wlan0up"
));
$extraFooterScripts[] = array('src'=>'app/js/dashboardchart.js', 'defer'=>false);
}

View File

@ -1,6 +1,7 @@
<?php
include_once('includes/status_messages.php');
include_once('app/lib/system.php');
/**
*
@ -9,6 +10,7 @@ include_once('includes/status_messages.php');
function DisplayHostAPDConfig()
{
$status = new StatusMessages();
$system = new System();
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
$arrConfig = array();
$arr80211Standard = [
@ -44,12 +46,11 @@ function DisplayHostAPDConfig()
}
exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
exec('pidof hostapd | wc -l', $hostapdstatus);
exec('iwgetid '. RASPI_WIFI_CLIENT_INTERFACE. ' -r', $wifiNetworkID);
if ( !empty($wifiNetworkID[0])) {
$managedModeEnabled = true;
}
$hostapdstatus = $system->hostapdStatus();
$serviceStatus = $hostapdstatus[0] == 0 ? "down" : "up";
foreach ($hostapdconfig as $hostapdconfigline) {

57
includes/sysstats.php Executable file
View File

@ -0,0 +1,57 @@
<?php
include_once('app/lib/system.php');
$system = new System();
$hostname = $system->hostname();
$uptime = $system->uptime();
$cores = $system->processorCount();
// mem used
$memused = $system->usedMemory();
$memused_status = "primary";
if ($memused > 90) {
$memused_status = "danger";
$memused_led = "service-status-down";
} elseif ($memused > 75) {
$memused_status = "warning";
$memused_led = "service-status-warn";
} elseif ($memused > 0) {
$memused_status = "success";
$memused_led = "service-status-up";
}
// cpu load
$cpuload = $system->systemLoadPercentage();
if ($cpuload > 90) {
$cpuload_status = "danger";
} elseif ($cpuload > 75) {
$cpuload_status = "warning";
} elseif ($cpuload > 0) {
$cpuload_status = "success";
}
// cpu temp
$cputemp = $system->systemTemperature();
if ($cputemp > 70) {
$cputemp_status = "danger";
$cputemp_led = "service-status-down";
} elseif ($cputemp > 50) {
$cputemp_status = "warning";
$cputemp_led = "service-status-warn";
} else {
$cputemp_status = "success";
$cputemp_led = "service-status-up";
}
// hostapd status
$hostapd = $system->hostapdStatus();
if ($hostapd[0] ==1) {
$hostapd_status = "active";
$hostapd_led = "service-status-up";
} else {
$hostapd_status = "inactive";
$hostapd_led = "service-status-down";
}

View File

@ -1,7 +1,6 @@
<?php
include_once('includes/status_messages.php');
include_once('app/lib/system.php');
/**
*
@ -65,7 +64,6 @@ function DisplaySystem()
{
$status = new StatusMessages();
$system = new System();
if (isset($_POST['SaveLanguage'])) {
if (isset($_POST['locale'])) {

327
index.php
View File

@ -1,7 +1,7 @@
<?php
/**
* Raspbian WiFi Configuration Portal
* Raspbian WiFi Configuration Portal (RaspAP)
*
* Enables use of simple web interface rather than SSH to control wifi and hostapd on the Raspberry Pi.
* Recommended distribution is Raspbian Buster Lite. Specific instructions to install the supported software are
@ -32,6 +32,7 @@ include_once('includes/admin.php');
include_once('includes/dhcp.php');
include_once('includes/hostapd.php');
include_once('includes/system.php');
include_once('includes/sysstats.php');
include_once('includes/configure_client.php');
include_once('includes/networking.php');
include_once('includes/themes.php');
@ -108,166 +109,174 @@ if ($_COOKIE['sidebarToggled'] == 'true' ) {
<ul class="navbar-nav sidebar sidebar-light d-none d-md-block accordion <?php echo $toggleState; ?>" id="accordionSidebar">
<!-- Sidebar - Brand -->
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.php?page=wlan0_info">
<div class="sidebar-brand-icon">
<img src="app/img/raspAP-logo64px.png" width="32" height="32">
</div>
<div class="sidebar-brand-text ml-1">RaspAP</div>
</a>
<div class="sidebar-brand-text ml-1">RaspAP</div>
</a>
<!-- Divider -->
<hr class="sidebar-divider my-0">
<li class="nav-item">
<a class="nav-link" href="index.php?page=wlan0_info"><i class="fas fa-tachometer-alt fa-fw mr-2"></i><span class="nav-label"><?php echo _("Dashboard"); ?></span></a>
</li>
<?php if (RASPI_WIFICLIENT_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=wpa_conf"><i class="fas fa-wifi fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure WiFi client"); ?></span></a>
</li>
<?php endif; ?>
<?php if (RASPI_HOTSPOT_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=hostapd_conf"><i class="far fa-dot-circle fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure hotspot"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_NETWORK_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=network_conf"><i class="fas fa-network-wired fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure networking"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_DHCP_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=dhcpd_conf"><i class="fas fa-exchange-alt fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure DHCP Server"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_OPENVPN_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=openvpn_conf"><i class="fas fa-key fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure OpenVPN"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_TORPROXY_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=torproxy_conf"><i class="fas fa-eye-slash fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure TOR proxy"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_CONFAUTH_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=auth_conf"><i class="fas fa-user-lock fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure Auth"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_CHANGETHEME_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=theme_conf"><i class="fas fa-paint-brush fa-fw mr-2"></i><span class="nav-label"><?php echo _("Change Theme"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_VNSTAT_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=data_use"><i class="fas fa-chart-bar fa-fw mr-2"></i><span class="nav-label"><?php echo _("Data usage"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_SYSTEM_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=system_info"><i class="fas fa-cube fa-fw mr-2"></i><span class="nav-label"><?php echo _("System"); ?></a>
</li>
<?php endif; ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=about"><i class="fas fa-info-circle fa-fw mr-2"></i><span class="nav-label"><?php echo _("About RaspAP"); ?></a>
</li>
<!-- Divider -->
<hr class="sidebar-divider d-none d-md-block">
<!-- Sidebar Toggler (Sidebar) -->
<div class="text-center d-none d-md-block">
<button class="rounded-circle border-0" id="sidebarToggle"></button>
</div>
</ul>
<!-- End of Sidebar -->
<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<!-- Topbar -->
<nav class="navbar navbar-expand navbar-light topbar mb-1 static-top">
<!-- Sidebar Toggle (Topbar) -->
<button id="sidebarToggleTopbar" class="btn btn-link d-md-none rounded-circle mr-3">
<i class="fa fa-bars"></i>
</button>
<!-- Topbar Navbar -->
<p class="text-left brand-title mt-3 ml-2"><?php //echo _("WiFi Configuration Portal"); ?></p>
<ul class="navbar-nav ml-auto">
<div class="topbar-divider d-none d-sm-block"></div>
<!-- Nav Item - User -->
<li class="nav-item dropdown no-arrow">
<a class="nav-link" href="index.php?page=auth_conf">
<span class="mr-2 d-none d-lg-inline small"><?php echo htmlspecialchars($config['admin_user'], ENT_QUOTES); ?></span>
<i class="fas fa-user-circle fa-3x"></i>
</a>
</li>
</ul>
</nav>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<?php
$extraFooterScripts = array();
// handle page actions
switch ($page) {
case "wlan0_info":
DisplayDashboard();
break;
case "dhcpd_conf":
DisplayDHCPConfig();
break;
case "wpa_conf":
DisplayWPAConfig();
break;
case "network_conf":
DisplayNetworkingConfig();
break;
case "hostapd_conf":
DisplayHostAPDConfig();
break;
case "openvpn_conf":
DisplayOpenVPNConfig();
break;
case "torproxy_conf":
DisplayTorProxyConfig();
break;
case "auth_conf":
DisplayAuthConfig($config['admin_user'], $config['admin_pass']);
break;
case "save_hostapd_conf":
SaveTORAndVPNConfig();
break;
case "theme_conf":
DisplayThemeConfig();
break;
case "data_use":
DisplayDataUsage($extraFooterScripts);
break;
case "system_info":
DisplaySystem();
break;
case "about":
DisplayAbout();
break;
default:
DisplayDashboard();
}
?>
</div><!-- /.container-fluid -->
</div><!-- End of Main Content -->
<!-- Footer -->
<footer class="sticky-footer bg-grey-100">
<div class="container my-auto">
<div class="copyright text-center my-auto">
<span></span>
</div>
<div class="row">
<div class="col-xs ml-3 sidebar-brand-icon">
<img src="app/img/raspAP-logo.svg" class="navbar-logo" width="64" height="64">
</div>
</footer>
<!-- End Footer -->
</div><!-- End of Content Wrapper -->
<div class="col-xs ml-2">
<div class="ml-1">Status</div>
<div class="info-item-xs"><span class="icon"><i class="fas fa-circle <?php echo ($hostapd_led); ?>"></i></span> Hotspot <?php echo _($hostapd_status); ?></div>
<div class="info-item-xs"><span class="icon"><i class="fas fa-circle <?php echo ($memused_led); ?>"></i></i></span> Memory Use: <?php echo htmlspecialchars($memused, ENT_QUOTES); ?>%</div>
<div class="info-item-xs"><span class="icon"><i class="fas fa-circle <?php echo ($cputemp_led); ?>"></i></span> CPU Temp: <?php echo htmlspecialchars($cputemp, ENT_QUOTES); ?>°C</div>
</div>
</div>
<li class="nav-item">
<a class="nav-link" href="index.php?page=wlan0_info"><i class="fas fa-tachometer-alt fa-fw mr-2"></i><span class="nav-label"><?php echo _("Dashboard"); ?></span></a>
</li>
<?php if (RASPI_WIFICLIENT_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=wpa_conf"><i class="fas fa-wifi fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure WiFi client"); ?></span></a>
</li>
<?php endif; ?>
<?php if (RASPI_HOTSPOT_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=hostapd_conf"><i class="far fa-dot-circle fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure hotspot"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_NETWORK_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=network_conf"><i class="fas fa-network-wired fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure networking"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_DHCP_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=dhcpd_conf"><i class="fas fa-exchange-alt fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure DHCP Server"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_OPENVPN_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=openvpn_conf"><i class="fas fa-key fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure OpenVPN"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_TORPROXY_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=torproxy_conf"><i class="fas fa-eye-slash fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure TOR proxy"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_CONFAUTH_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=auth_conf"><i class="fas fa-user-lock fa-fw mr-2"></i><span class="nav-label"><?php echo _("Configure Auth"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_CHANGETHEME_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=theme_conf"><i class="fas fa-paint-brush fa-fw mr-2"></i><span class="nav-label"><?php echo _("Change Theme"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_VNSTAT_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=data_use"><i class="fas fa-chart-bar fa-fw mr-2"></i><span class="nav-label"><?php echo _("Data usage"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_SYSTEM_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=system_info"><i class="fas fa-cube fa-fw mr-2"></i><span class="nav-label"><?php echo _("System"); ?></a>
</li>
<?php endif; ?>
<li class="nav-item">
<a class="nav-link" href="index.php?page=about"><i class="fas fa-info-circle fa-fw mr-2"></i><span class="nav-label"><?php echo _("About RaspAP"); ?></a>
</li>
<!-- Divider -->
<hr class="sidebar-divider d-none d-md-block">
<!-- Sidebar Toggler (Sidebar) -->
<div class="text-center d-none d-md-block">
<button class="rounded-circle border-0" id="sidebarToggle"></button>
</div>
</ul>
<!-- End of Sidebar -->
<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<!-- Topbar -->
<nav class="navbar navbar-expand navbar-light topbar mb-1 static-top">
<!-- Sidebar Toggle (Topbar) -->
<button id="sidebarToggleTopbar" class="btn btn-link d-md-none rounded-circle mr-3">
<i class="fa fa-bars"></i>
</button>
<!-- Topbar Navbar -->
<p class="text-left brand-title mt-3 ml-2"><?php //echo _("WiFi Configuration Portal"); ?></p>
<ul class="navbar-nav ml-auto">
<div class="topbar-divider d-none d-sm-block"></div>
<!-- Nav Item - User -->
<li class="nav-item dropdown no-arrow">
<a class="nav-link" href="index.php?page=auth_conf">
<span class="mr-2 d-none d-lg-inline small"><?php echo htmlspecialchars($config['admin_user'], ENT_QUOTES); ?></span>
<i class="fas fa-user-circle fa-3x"></i>
</a>
</li>
</ul>
</nav>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<?php
$extraFooterScripts = array();
// handle page actions
switch ($page) {
case "wlan0_info":
DisplayDashboard($extraFooterScripts);
break;
case "dhcpd_conf":
DisplayDHCPConfig();
break;
case "wpa_conf":
DisplayWPAConfig();
break;
case "network_conf":
DisplayNetworkingConfig();
break;
case "hostapd_conf":
DisplayHostAPDConfig();
break;
case "openvpn_conf":
DisplayOpenVPNConfig();
break;
case "torproxy_conf":
DisplayTorProxyConfig();
break;
case "auth_conf":
DisplayAuthConfig($config['admin_user'], $config['admin_pass']);
break;
case "save_hostapd_conf":
SaveTORAndVPNConfig();
break;
case "theme_conf":
DisplayThemeConfig();
break;
case "data_use":
DisplayDataUsage($extraFooterScripts);
break;
case "system_info":
DisplaySystem();
break;
case "about":
DisplayAbout();
break;
default:
DisplayDashboard($extraFooterScripts);
}
?>
</div><!-- /.container-fluid -->
</div><!-- End of Main Content -->
<!-- Footer -->
<footer class="sticky-footer bg-grey-100">
<div class="container my-auto">
<div class="copyright text-center my-auto">
<span></span>
</div>
</div>
</footer>
<!-- End Footer -->
</div><!-- End of Content Wrapper -->
</div><!-- End of Page Wrapper -->
<!-- Scroll to Top Button-->
<a class="scroll-to-top rounded" href="#page-top" style="display: inline;">
@ -304,7 +313,7 @@ if ($_COOKIE['sidebarToggled'] == 'true' ) {
foreach ($extraFooterScripts as $script) {
echo ' <script type="text/javascript" src="' , $script['src'] , '"';
if ($script['defer']) {
echo ' defer="defer"';
echo ' defer="defer"';
}
echo '></script>' , PHP_EOL;
}

View File

@ -13,59 +13,59 @@ $ifaceStatus = $wlan0up ? "up" : "down";
<div class="card">
<div class="card-header">
<div class="row">
<div class="col">
<i class="fas fa-tachometer-alt fa-fw mr-2"></i><?php echo _("Dashboard"); ?>
</div>
<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 strtolower($client_iface) .' '. _($ifaceStatus) ?></span>
</button>
</div>
<div class="col">
<i class="fas fa-tachometer-alt fa-fw mr-2"></i><?php echo _("Dashboard"); ?>
</div>
<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 strtolower($client_iface) .' '. _($ifaceStatus) ?></span>
</button>
</div>
</div><!-- /.row -->
</div><!-- /.card-header -->
<div class="card-body">
<div class="row">
<div class="col-md-6 mb-3">
<div class="col-lg-12">
<div class="card mb-3">
<div class="card-body">
<h4><?php echo _("Hourly traffic amount"); ?></h4>
<div id="divInterface" class="d-none"><?php echo RASPI_WIFI_CLIENT_INTERFACE; ?></div>
<div class="col-md-12">
<canvas id="divDBChartBandwidthhourly"></canvas>
</div>
</div><!-- /.card-body -->
</div><!-- /.card-->
</div>
<div class="col-sm-6 align-items-stretch">
<div class="card h-100">
<div class="card-body wireless">
<h4><?php echo _("Wireless Information"); ?></h4>
<h4><?php echo _("Wireless Client"); ?></h4>
<div class="row justify-content-md-center">
<div class="col-md">
<div class="info-item"><?php echo _("Connected To"); ?></div><div><?php echo htmlspecialchars($connectedSSID, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("AP Mac Address"); ?></div><div><?php echo htmlspecialchars($connectedBSSID, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("Bitrate"); ?></div><div><?php echo htmlspecialchars($bitrate, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("Signal Level"); ?></div><div><?php echo htmlspecialchars($signalLevel, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("Transmit Power"); ?></div><div><?php echo htmlspecialchars($txPower, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("Frequency"); ?></div><div><?php echo htmlspecialchars($frequency, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("Link Quality"); ?></div>
</div>
<div class="col-md mt-2 d-flex justify-content-center">
<script>var linkQ = <?php echo json_encode($strLinkQuality); ?>;</script>
<div class="chart-container">
<canvas id="canvas" class="chartjs-render-monitor"></canvas>
<canvas id="divChartLinkQ"></canvas>
</div>
</div><!--row-->
</div>
</div><!-- /.card-body -->
</div><!-- /.card -->
</div><!-- /.col-md-6 -->
<div class="col-md-6">
<div class="card mb-3">
<div class="col-sm-6">
<div class="card h-100 mb-3">
<div class="card-body">
<h4><?php echo _("Interface Information"); ?></h4>
<div class="info-item"><?php echo _("Interface Name"); ?></div><div><?php echo RASPI_WIFI_CLIENT_INTERFACE; ?></div>
<div class="info-item"><?php echo _("IPv4 Address"); ?></div><div><?php echo htmlspecialchars($ipv4Addrs, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("Subnet Mask"); ?></div><div><?php echo htmlspecialchars($ipv4Netmasks, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("IPv6 Address"); ?></div><div><?php echo htmlspecialchars($ipv6Addrs, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("Mac Address"); ?></div><div><?php echo htmlspecialchars($macAddr, ENT_QUOTES); ?></div>
</div><!-- /.card-body -->
</div><!-- /.card-->
<div class="card mb-3">
<div class="card-body">
<h4><?php echo _("Interface Statistics"); ?></h4>
<div class="info-item"><?php echo _("Received Packets"); ?></div><div><?php echo number_format($strRxPackets); ?></div>
<div class="info-item"><?php echo _("Received Bytes"); ?></div><div><?php echo number_format($strRxBytes); ?></div>
<div class="info-item"><?php echo _("Transferred Packets"); ?></div><div><?php echo number_format($strTxPackets); ?></div>
<div class="info-item"><?php echo _("Transferred Bytes"); ?></div><div><?php echo number_format($strTxBytes); ?></div>
</div><!-- /.card-body -->
</div><!-- /.card -->
<div class="card mb-3">
<div class="card-body wireless">
<h4><?php echo _("Connected Devices"); ?></h4>
<div class="table-responsive">
<table class="table table-hover">
@ -77,7 +77,7 @@ $ifaceStatus = $wlan0up ? "up" : "down";
</tr>
</thead>
<tbody>
<?php foreach ($clients as $client) : ?>
<?php foreach (array_slice($clients,0, 2) as $client) : ?>
<?php $props = explode(' ', $client) ?>
<tr>
<td><?php echo htmlspecialchars($props[3], ENT_QUOTES) ?></td>
@ -87,13 +87,20 @@ $ifaceStatus = $wlan0up ? "up" : "down";
<?php endforeach ?>
</tbody>
</table>
<?php if (sizeof($clients) >2) : ?>
<div class="col-lg-12 float-right">
<a class="btn btn-outline-info" role="button" href="index.php?page=dhcpd_conf"><?php echo _("More");?> <i class="fas fa-chevron-right"></i></a>
</div>
<?php elseif (sizeof($clients) ==0) : ?>
<div class="col-lg-12 mt-3"><?php echo _("No connected devices");?></div>
<?php endif; ?>
</div><!-- /.table-responsive -->
</div><!-- /.card-body -->
</div><!-- /.card -->
</div><!-- /.col-md-6 -->
</div><!-- /.row -->
<div class="col-lg-12">
<div class="col-lg-12 mt-3">
<div class="row">
<form action="?page=wlan0_info" method="POST">
<?php echo CSRFTokenFieldTag() ?>
@ -114,3 +121,9 @@ $ifaceStatus = $wlan0up ? "up" : "down";
</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>

View File

@ -1,39 +1,6 @@
<?php
$hostname = $system->hostname();
$uptime = $system->uptime();
$cores = $system->processorCount();
// mem used
$memused = $system->usedMemory();
$memused_status = "primary";
if ($memused > 90) {
$memused_status = "danger";
} elseif ($memused > 75) {
$memused_status = "warning";
} elseif ($memused > 0) {
$memused_status = "success";
}
// cpu load
$cpuload = $system->systemLoadPercentage();
if ($cpuload > 90) {
$cpuload_status = "danger";
} elseif ($cpuload > 75) {
$cpuload_status = "warning";
} elseif ($cpuload > 0) {
$cpuload_status = "success";
}
// cpu temp
$cputemp = $system->systemTemperature();
if ($cputemp > 70) {
$cputemp_status = "danger";
} elseif ($cputemp > 50) {
$cputemp_status = "warning";
} else {
$cputemp_status = "success";
}
include('includes/sysstats.php');
?>
<div class="row">