Standardize project directory structure, in line with gulp build

This commit is contained in:
billz 2019-10-08 18:58:46 +01:00
parent e78606f233
commit c26cb40a80
17 changed files with 1171 additions and 0 deletions

110
app/css/custom.css Normal file
View File

@ -0,0 +1,110 @@
.page-header {
margin: 20px 0 20px;
}
.page-header .logo {
margin-right: 5px;
}
.panel-primary {
border-color: #c61931;
}
.panel-primary>.panel-heading {
border-color: #d8224c;
background-color: #d8224c;
}
.panel-footer {
background-color: #f2f1f0;
}
.btn-primary.btn-outline {
color: #c61931;
border-color: #c61931;
}
.btn-primary:hover {
background-color: #c61931;
border-color: #c61931;
}
.info-item {
width: 140px;
float: left;
}
.webconsole {
width:100%;
height:100%;
border:1px solid;
}
#console {
height:500px;
}
.systemtabcontent {
height:100%;
min-height:500px;
}
.service-status-running,
.service-status-stopped {
background-color: #fff;
color: #333;
text-transform: uppercase;
line-height: inherit;
}
.service-status-running:before,
.service-status-stopped:before {
display: inline-block;
height: 16px;
width: 16px;
content: "\2022";
font-size: 3.5em;
color: green;
line-height: 16px;
vertical-align: bottom;
margin-right: 2px;
}
.service-status-stopped:before {
color: red;
animation: flash 1s linear infinite;
}
@keyframes flash {
50% {
opacity: 0;
}
}
.logoutput {
width:100%;
height:300px;
}
pre.unstyled {
border-width: 0;
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;
}
.loading-spinner {
background: url("../../img/loading-spinner.gif") no-repeat scroll center center transparent;
min-height: 150px;
width: 100%;
}
.js-wifi-stations .panel-body {
min-height: 256px;
}

112
app/css/hackernews.css Normal file
View File

@ -0,0 +1,112 @@
html * {
font-family: Verdana, Geneva, sans-serif;
font-size: 10pt;
color: #828282;
}
.nav>li>a {
font-size: 12pt;
}
a:focus, a:hover {
color: #666;
}
h4 {
font-size: 18px;
}
.panel {
border-radius: 1px;
}
.panel-primary {
border-color: #ff6600;
}
.panel-primary>.panel-heading {
border-color: #ff6600;
background-color: #ff6600;
color: #000;
font-size: 14pt;
font-weight: bold;
}
.panel-heading {
border-top-left-radius: 1px;
border-top-right-radius: 1px;
}
.panel-primary>.panel-heading .fa {
color: #fff;
}
.page-header {
font-size: 26pt;
margin: 10px 0 20px;
}
#wrapper,#page-wrapper,.panel-body,.nav>li>a,.navbar-default {
background-color: #f6f6ef;
}
.panel-footer {
background-color: #eee;
}
.btn-primary.btn-outline {
color: #c61931;
border-color: #c61931;
}
.btn-primary:hover {
background-color: #c61931;
border-color: #c61931;
}
.progress {
background-color: #eee;
}
.progress-bar {
color: #eee;
}
.info-item {
width: 140px;
float: left;
}
.logoutput {
width: 100%;
height: 300px;
}
.service-status-running,
.service-status-stopped {
background-color: #fff;
color: #333;
text-transform: uppercase;
line-height: inherit;
}
.service-status-running:before,
.service-status-stopped:before {
display: inline-block;
height: 18px;
width: 16px;
content: "\2022";
font-size: 1.5em;
color: green;
line-height: 16px;
vertical-align: bottom;
margin-right: 2px;
}
.service-status-stopped:before {
color: red;
animation: flash 1s linear infinite;
}
@keyframes flash {
50% {
opacity: 0;
}
}

301
app/css/terminal.css Normal file
View File

@ -0,0 +1,301 @@
html * {
font-family: Courier New, Andale Mono, monospace;
font-size: 10pt;
color: #33ff00;
}
#page-wrapper {
padding: 0 20px;
border-left: 1px solid #33ff00;
}
.nav>li>a {
font-size: 10pt;
}
.nav>li>a:focus, .nav>li>a:hover {
background-color: #000;
}
.nav-tabs>li.active>a, .nav-tabs>li.active>a:focus, .nav-tabs>li.active>a:hover, .input-group-addon {
color: #33ff00;
cursor: default;
background-color: #000;
border: 1px solid #33ff00;
border-bottom-color: #33ff00;
}
.nav-tabs>li>a,.nav-tabs>li>a:hover {
border: 1px solid #33ff00;
}
.nav-tabs {
border-bottom: 1px solid #33ff00;
}
.navbar-default {
border-color: #33ff00;
}
.navbar-default .navbar-brand, .navbar-default .navbar-brand:hover {
color: #33ff00;
}
.navbar-default .navbar-toggle {
border-color: #33ff00;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #33ff00;
}
.navbar-default .navbar-toggle:focus, .navbar-default .navbar-toggle:hover {
background-color: #000;
}
.logo {
visibility: collapse;
width: 0px;
}
a:focus, a:hover {
color: #33ff00;
}
.panel-primary {
border-color: #33ff00;
}
.panel-primary>.panel-heading, .panel-default>.panel-heading {
border-color: #33ff00;
background-color: #33ff00;
color: #000;
font-size: 12pt;
}
.panel-primary>.panel-heading .fa {
color: #000;
}
.panel {
margin-bottom: 20px;
border: 1px solid #33ff00;
border-radius: 0px;
background-color: #000;
}
hr {
border-top: 1px solid #33ff00;
}
.page-header {
font-size: 24pt;
margin: 10px 0 20px;
border-bottom: 1px solid #33ff00;
}
#wrapper,#page-wrapper,.panel-body,.nav>li>a,.navbar-default {
background-color: #000;
}
.panel-footer {
background-color: #000;
border-top: 1px solid #33ff00;
}
.panel-primary>.panel-heading::before, .navbar-default::before {
content: " ";
display: block;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
z-index: 2;
background-size: 100% 2px, 3px 100%;
pointer-events: none;
}
.sidebar ul li a.active,.sidebar ul li a.hover {
background-color: #000;
}
.sidebar ul li {
border-bottom: 1px solid #33ff00;
}
.btn-default.active, .btn-default.active:focus, .btn-default.active:hover {
color: #33ff00;
background-color: #000;
}
.btn-primary.btn-outline,.btn-warning,.btn-default,.btn-danger {
color: #33ff00;
border-color: #33ff00;
}
.btn-primary:hover,.btn-primary:focus,.btn-warning:hover,.btn-warning:focus,.btn-primary:active,.btn-default:hover,.btn-danger:hover,.btn-default:active,.btn-default:focus {
color: #33ff00;
background-color: #000;
border-color: #33ff00;
}
.btn-primary.btn-outline:hover,.btn-success, .btn-success.btn-outline:hover, .btn-info.btn-outline:hover, .btn-warning.btn-outline:hover, .btn-danger.btn-outline:hover {
color: #33ff00;
}
label.btn.btn-primary {
color: #33ff00;
}
label.btn.btn-primary.active, label.btn.btn-warning.active {
background-color: #33ff00;
border-color: #33ff00;
color: #000;
}
.label-warning {
background-color: #33ff00;
}
span.label.label-warning {
color: #000;
}
.btn.btn-primary {
border-color: #33ff00;
}
.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th {
background-color: #000;
border-top: 1px solid #000;
}
.table>thead>tr>th {
vertical-align: bottom;
border-bottom: 1px solid #33ff00;
}
.btn-info, .btn-info:hover, .btn-info[disabled], .btn-danger.disabled, .btn-danger.disabled.active, .btn-danger.disabled.focus, .btn-danger.disabled:active, .btn-danger.disabled:focus, .btn-danger.disabled:hover, .btn-danger[disabled], .btn-danger[disabled].active, .btn-danger[disabled].focus, .btn-danger[disabled]:active, .btn-danger[disabled]:focus, .btn-danger[disabled]:hover, fieldset[disabled] .btn-danger, fieldset[disabled] .btn-danger.active, fieldset[disabled] .btn-danger.focus, fieldset[disabled] .btn-danger:active, fieldset[disabled] .btn-danger:focus, fieldset[disabled] .btn-danger:hover, .btn-info:hover {
background-color: #000;
border-color: #33ff00;
color: #33ff00;
}
.btn {
background-color: #000;
border-radius: 0px;
}
.alert {
border-radius: 0px;
}
.alert-success,.alert-warning,.alert-info,.alert-dismissable,.alert-danger {
color: #33ff00;
background-color: #000;
border-color: #33ff00;
border: 1px dashed;
}
.close {
font-size: 18px;
font-weight: normal;
text-shadow: 0 0px 0 #000;
opacity: 1;
}
.form-control, .form-control:focus {
color: #33ff00;
background-color: #000;
border: 1px solid #33ff00;
border-radius: 0px;
transition: unset;
}
input[type="text"]{
color: #33ff00 !important
}
.form-control::-webkit-input-placeholder { color: #33ff00; }
.form-control:-moz-placeholder { color: #33ff00; }
.form-control::-moz-placeholder { color: #33ff00; }
.form-control:-ms-input-placeholder { color: #33ff00; }
.form-control::-ms-input-placeholder { color: #33ff00; }
.progress {
background-color: #000;
border-radius: 0px;
}
.progress-bar {
color: #000;
}
.progress-bar.progress-bar-info.progress-bar-striped.active {
background-color: #33ff00;
}
.info-item {
width: 140px;
float: left;
}
.logoutput {
width: 100%;
height: 300px;
background-color: #000;
border-color: #33ff00;
}
.webconsole {
width: 100%;
height: 100%;
border-color: #33ff00;
border-bottom: 1px solid;
border-left: 1px solid;
border-top: 0px;
border-right: 1px solid;
}
#console {
height: 500px;
}
.systemtabcontent {
height: 100%;
min-height: 500px;
}
tspan, rect {
fill: #33ff00;
}
.morris-hover.morris-default-style {
background: none;
border-radius: 0px;
border-color: #33ff00;
border: dashed 1px #33ff00;
}
.morris-hover-point {
color: #33ff00 !important;
}
path {
stroke: #33ff00;
}
span.service-status-running {
color: #000;
font-size: 10pt;
text-transform: uppercase;
line-height: inherit;
}
pre {
background-color: #000;
border: #000;
}

180
app/css/timeline.css Executable file
View File

@ -0,0 +1,180 @@
.timeline {
position: relative;
padding: 20px 0 20px;
list-style: none;
}
.timeline:before {
content: " ";
position: absolute;
top: 0;
bottom: 0;
left: 50%;
width: 3px;
margin-left: -1.5px;
background-color: #eeeeee;
}
.timeline > li {
position: relative;
margin-bottom: 20px;
}
.timeline > li:before,
.timeline > li:after {
content: " ";
display: table;
}
.timeline > li:after {
clear: both;
}
.timeline > li:before,
.timeline > li:after {
content: " ";
display: table;
}
.timeline > li:after {
clear: both;
}
.timeline > li > .timeline-panel {
float: left;
position: relative;
width: 46%;
padding: 20px;
border: 1px solid #d4d4d4;
border-radius: 2px;
-webkit-box-shadow: 0 1px 6px rgba(0,0,0,0.175);
box-shadow: 0 1px 6px rgba(0,0,0,0.175);
}
.timeline > li > .timeline-panel:before {
content: " ";
display: inline-block;
position: absolute;
top: 26px;
right: -15px;
border-top: 15px solid transparent;
border-right: 0 solid #ccc;
border-bottom: 15px solid transparent;
border-left: 15px solid #ccc;
}
.timeline > li > .timeline-panel:after {
content: " ";
display: inline-block;
position: absolute;
top: 27px;
right: -14px;
border-top: 14px solid transparent;
border-right: 0 solid #fff;
border-bottom: 14px solid transparent;
border-left: 14px solid #fff;
}
.timeline > li > .timeline-badge {
z-index: 100;
position: absolute;
top: 16px;
left: 50%;
width: 50px;
height: 50px;
margin-left: -25px;
border-radius: 50% 50% 50% 50%;
text-align: center;
font-size: 1.4em;
line-height: 50px;
color: #fff;
background-color: #999999;
}
.timeline > li.timeline-inverted > .timeline-panel {
float: right;
}
.timeline > li.timeline-inverted > .timeline-panel:before {
right: auto;
left: -15px;
border-right-width: 15px;
border-left-width: 0;
}
.timeline > li.timeline-inverted > .timeline-panel:after {
right: auto;
left: -14px;
border-right-width: 14px;
border-left-width: 0;
}
.timeline-badge.primary {
background-color: #2e6da4 !important;
}
.timeline-badge.success {
background-color: #3f903f !important;
}
.timeline-badge.warning {
background-color: #f0ad4e !important;
}
.timeline-badge.danger {
background-color: #d9534f !important;
}
.timeline-badge.info {
background-color: #5bc0de !important;
}
.timeline-title {
margin-top: 0;
color: inherit;
}
.timeline-body > p,
.timeline-body > ul {
margin-bottom: 0;
}
.timeline-body > p + p {
margin-top: 5px;
}
@media(max-width:767px) {
ul.timeline:before {
left: 40px;
}
ul.timeline > li > .timeline-panel {
width: calc(100% - 90px);
width: -moz-calc(100% - 90px);
width: -webkit-calc(100% - 90px);
}
ul.timeline > li > .timeline-badge {
top: 16px;
left: 15px;
margin-left: 0;
}
ul.timeline > li > .timeline-panel {
float: right;
}
ul.timeline > li > .timeline-panel:before {
right: auto;
left: -15px;
border-right-width: 15px;
border-left-width: 0;
}
ul.timeline > li > .timeline-panel:after {
right: auto;
left: -14px;
border-right-width: 14px;
border-left-width: 0;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/dist/icons/mstile-150x150.png"/>
<TileColor>#b91d47</TileColor>
</tile>
</msapplication>
</browserconfig>

BIN
app/icons/favicon-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
app/icons/favicon-32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
app/icons/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -0,0 +1,48 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="240.000000pt" height="240.000000pt" viewBox="0 0 240.000000 240.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.11, written by Peter Selinger 2001-2013
</metadata>
<g transform="translate(0.000000,240.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M867 2334 c-3 -3 -3 -20 -1 -37 2 -18 6 -54 8 -82 2 -27 5 -53 5 -56
1 -4 31 -6 69 -6 63 0 162 -9 207 -19 11 -2 31 -6 45 -8 14 -2 59 -14 100 -27
41 -13 80 -23 85 -24 6 0 12 -2 15 -5 3 -3 37 -20 75 -38 161 -78 335 -219
436 -357 55 -74 121 -175 115 -175 -3 0 10 -30 28 -67 18 -38 37 -81 41 -98 5
-16 9 -34 11 -40 27 -94 44 -173 48 -237 2 -15 19 -20 99 -23 95 -5 101 -1 86
60 -4 17 -10 48 -13 70 -27 197 -131 443 -258 613 -52 69 -252 272 -269 272
-5 0 -18 8 -28 18 -37 32 -50 42 -61 42 -5 0 -10 4 -10 8 0 4 -15 15 -32 23
-18 9 -53 27 -78 41 -95 52 -303 123 -390 133 -19 2 -46 7 -60 10 -34 8 -266
15 -273 9z"/>
<path d="M895 1867 c3 -50 6 -92 8 -93 1 -1 40 -4 87 -8 114 -8 139 -12 212
-37 272 -91 470 -300 547 -578 11 -39 17 -71 13 -71 -3 0 -2 -4 4 -10 5 -5 50
-12 100 -15 l91 -6 -3 26 c-15 141 -91 333 -182 460 -47 65 -152 170 -222 222
-164 122 -367 191 -582 198 l-79 2 6 -90z"/>
<path d="M747 1604 c-1 -2 -14 -5 -27 -7 -245 -47 -453 -199 -562 -412 -47
-91 -81 -232 -81 -340 -1 -88 19 -215 34 -215 5 0 6 -7 3 -15 -4 -8 -2 -21 3
-28 5 -6 20 -38 33 -70 12 -31 26 -57 31 -57 5 0 9 -6 9 -13 0 -7 9 -23 20
-35 11 -12 20 -25 20 -29 0 -12 80 -93 91 -93 6 0 8 -4 5 -8 -11 -18 215 -159
235 -147 5 4 9 2 9 -4 0 -20 189 -58 280 -56 87 2 213 25 245 44 6 3 12 6 15
6 21 3 50 18 50 26 0 6 5 7 10 4 13 -8 128 67 193 125 67 60 164 196 159 223
-1 4 1 7 6 7 8 0 31 47 36 76 3 11 9 32 15 47 24 62 33 251 17 344 -21 123
-93 271 -181 371 -49 54 -156 142 -174 142 -6 0 -11 4 -11 9 0 18 -180 85
-260 97 -43 7 -218 13 -223 8z m243 -199 c30 -9 62 -17 70 -18 8 -1 20 -5 25
-10 6 -4 37 -25 70 -46 71 -45 165 -135 174 -166 1 -5 15 -33 31 -61 78 -136
85 -368 15 -504 -8 -16 -15 -33 -14 -36 0 -4 -3 -10 -8 -13 -5 -3 -23 -26 -40
-51 -25 -37 -102 -113 -148 -148 -15 -12 -117 -59 -145 -68 -97 -31 -220 -35
-310 -11 -8 2 -28 7 -45 12 -16 4 -51 19 -77 32 -27 13 -51 24 -55 26 -4 1
-18 12 -31 24 -14 13 -30 20 -36 16 -6 -3 -8 -3 -4 1 9 10 -34 55 -46 48 -5
-3 -6 0 -2 6 3 6 -2 17 -12 24 -10 7 -27 28 -37 46 -11 17 -24 32 -29 32 -5 0
-6 3 -3 7 4 3 -2 20 -12 37 -27 43 -49 111 -56 176 -8 60 -7 158 0 170 3 4 7
25 10 46 5 45 56 152 97 205 15 20 28 42 28 48 0 6 4 10 8 8 4 -1 26 16 48 38
22 22 49 45 60 51 55 32 123 65 140 69 10 2 42 10 69 18 63 17 193 13 265 -8z"/>
<path d="M717 1231 c-299 -97 -383 -476 -154 -691 23 -22 48 -40 54 -40 7 0
13 -4 13 -9 0 -17 116 -53 185 -57 130 -8 228 29 320 121 49 49 66 75 89 135
33 89 38 197 11 270 -9 25 -17 50 -19 57 -6 30 -85 124 -133 157 -104 73 -248
95 -366 57z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,14 @@
{
"name": "RaspAP",
"short_name": "RaspAP",
"icons": [
{
"src": "/dist/icons/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}

92
app/js/bandwidthcharts.js Normal file
View File

@ -0,0 +1,92 @@
(function($, _t) {
"use strict";
/**
* Create a Morris.js barchart.
*/
function CreateBarChart(placeholder, datasizeunits) {
var barchart = new Morris.Bar({
element: placeholder,
xkey: 'date',
ykeys: ['rx', 'tx'],
labels: [_t['receive']+' '+datasizeunits.toUpperCase(),
_t['send']+' '+datasizeunits.toUpperCase()]
});
return barchart;
}
/**
* Create a jquery bootstrap datatable.
*/
function CreateDataTable(placeholder, timeunits) {
$("#"+placeholder).append('<table id="tableBandwidth'+timeunits+
'" class="table table-responsive table-striped container-fluid"><thead>'+
'<tr><th>date</th><th>rx</th><th>tx</th></tr></thead><tbody></tbody></table>');
}
/**
* Figure out which tab is selected and remove all existing charts and then
* construct the proper barchart.
*/
function ShowBandwidthChartHandler(e) {
// Remove all morrisjs charts
$('#divChartBandwidthhourly').empty();
$('#divChartBandwidthdaily').empty();
$('#divChartBandwidthmonthly').empty();
// Remove all datatables
$('#divTableBandwidthhourly').empty();
$('#divTableBandwidthdaily').empty();
$('#divTableBandwidthmonthly').empty();
// Construct ajax uri for getting the proper data.
var timeunit = $('ul#tabbarBandwidth li.active a').attr('href').substr(1);
var uri = 'ajax/bandwidth/get_bandwidth.php?';
uri += 'inet=';
uri += encodeURIComponent($('#cbxInterface'+timeunit+' option:selected').text());
uri += '&tu=';
uri += encodeURIComponent(timeunit.substr(0, 1));
var datasizeunits = 'mb';
uri += '&dsu='+encodeURIComponent(datasizeunits);
// Init. chart
var barchart = CreateBarChart('divChartBandwidth'+timeunit, datasizeunits);
// Init. datatable html
var datatable = CreateDataTable('divTableBandwidth'+timeunit, timeunit);
// Get data for chart
$.ajax({
url: uri,
dataType: 'json',
beforeSend: function() {
$('#divLoaderBandwidth'+timeunit).removeClass('hidden');
}
}).done(function(jsondata) {
$('#divLoaderBandwidth'+timeunit).addClass('hidden');
barchart.setData(jsondata);
$('#tableBandwidth'+timeunit).DataTable({
'searching': false,
'paging': false,
'data': jsondata,
'order': [[ 0, 'ASC' ]],
'columns': [
{ 'data': 'date' },
{ 'data': 'rx', "title": _t['receive']+' '+datasizeunits.toUpperCase() },
{ 'data': 'tx', "title": _t['send']+' '+datasizeunits.toUpperCase() }]
});
}).fail(function(xhr, textStatus) {
if (window.console) {
console.error('server error');
} else {
alert("server error");
}
});
}
$(document).ready(function() {
$('#tabbarBandwidth a[data-toggle="tab"]').on('shown.bs.tab', ShowBandwidthChartHandler);
$('#cbxInterfacehourly').on('change', ShowBandwidthChartHandler);
$('#cbxInterfacedaily').on('change', ShowBandwidthChartHandler);
$('#cbxInterfacemonthly').on('change', ShowBandwidthChartHandler);
ShowBandwidthChartHandler();
});
})(jQuery, t);

7
app/js/bandwidthcharts.min.js vendored Normal file
View File

@ -0,0 +1,7 @@
/*!
* RaspAP - RaspAP WiFi Configuration Portal v1.6.1 (https://github.com/billz/raspap-webgui)
* Copyright 2013-2019 RaspAP Developers
* Licensed under MIT (https://github.com/raspap-webgui/raspap-webgui/blob/master/LICENSE)
*/
!function(r,i){"use strict";function t(t){r("#divChartBandwidthhourly").empty(),r("#divChartBandwidthdaily").empty(),r("#divChartBandwidthmonthly").empty(),r("#divTableBandwidthhourly").empty(),r("#divTableBandwidthdaily").empty(),r("#divTableBandwidthmonthly").empty();var e=r("ul#tabbarBandwidth li.active a").attr("href").substr(1),a="ajax/bandwidth/get_bandwidth.php?";a+="inet=",a+=encodeURIComponent(r("#cbxInterface"+e+" option:selected").text()),a+="&tu=",a+=encodeURIComponent(e.substr(0,1));var d="mb";a+="&dsu="+encodeURIComponent(d);var n=function(t,e){return new Morris.Bar({element:t,xkey:"date",ykeys:["rx","tx"],labels:[i.receive+" "+e.toUpperCase(),i.send+" "+e.toUpperCase()]})}("divChartBandwidth"+e,d);!function(t,e){r("#"+t).append('<table id="tableBandwidth'+e+'" class="table table-responsive table-striped container-fluid"><thead><tr><th>date</th><th>rx</th><th>tx</th></tr></thead><tbody></tbody></table>')}("divTableBandwidth"+e,e);r.ajax({url:a,dataType:"json",beforeSend:function(){r("#divLoaderBandwidth"+e).removeClass("hidden")}}).done(function(t){r("#divLoaderBandwidth"+e).addClass("hidden"),n.setData(t),r("#tableBandwidth"+e).DataTable({searching:!1,paging:!1,data:t,order:[[0,"ASC"]],columns:[{data:"date"},{data:"rx",title:i.receive+" "+d.toUpperCase()},{data:"tx",title:i.send+" "+d.toUpperCase()}]})}).fail(function(t,e){window.console?console.error("server error"):alert("server error")})}r(document).ready(function(){r('#tabbarBandwidth a[data-toggle="tab"]').on("shown.bs.tab",t),r("#cbxInterfacehourly").on("change",t),r("#cbxInterfacedaily").on("change",t),r("#cbxInterfacemonthly").on("change",t),t()})}(jQuery,t);

291
app/js/custom.js Normal file
View File

@ -0,0 +1,291 @@
function msgShow(retcode,msg) {
if(retcode == 0) {
var alertType = 'success';
} else if(retcode == 2 || retcode == 1) {
var alertType = 'danger';
}
var htmlMsg = '<div class="alert alert-'+alertType+' alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+msg+'</div>';
return htmlMsg;
}
function createNetmaskAddr(bitCount) {
var mask=[];
for(i=0;i<4;i++) {
var n = Math.min(bitCount, 8);
mask.push(256 - Math.pow(2, 8-n));
bitCount -= n;
}
return mask.join('.');
}
function loadSummary(strInterface) {
$.post('/ajax/networking/get_ip_summary.php',{interface:strInterface},function(data){
jsonData = JSON.parse(data);
console.log(jsonData);
if(jsonData['return'] == 0) {
$('#'+strInterface+'-summary').html(jsonData['output'].join('<br />'));
} else if(jsonData['return'] == 2) {
$('#'+strInterface+'-summary').append('<div class="alert alert-danger alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+jsonData['output'].join('<br />')+'</div>');
}
});
}
function getAllInterfaces() {
$.get('/ajax/networking/get_all_interfaces.php',function(data){
jsonData = JSON.parse(data);
$.each(jsonData,function(ind,value){
loadSummary(value)
});
});
}
function setupTabs() {
$('a[data-toggle="tab"]').on('shown.bs.tab',function(e){
var target = $(e.target).attr('href');
if(!target.match('summary')) {
var int = target.replace("#","");
loadCurrentSettings(int);
}
});
}
function loadCurrentSettings(strInterface) {
$.post('/ajax/networking/get_int_config.php',{interface:strInterface},function(data){
jsonData = JSON.parse(data);
$.each(jsonData['output'],function(i,v) {
var int = v['interface'];
$.each(v,function(i2,v2) {
switch(i2) {
case "static":
if(v2 == 'true') {
$('#'+int+'-static').click();
$('#'+int+'-nofailover').click();
} else {
$('#'+int+'-dhcp').click();
}
break;
case "failover":
if(v2 === 'true') {
$('#'+int+'-failover').click();
} else {
$('#'+int+'-nofailover').click();
}
break;
case "ip_address":
var arrIPNetmask = v2.split('/');
$('#'+int+'-ipaddress').val(arrIPNetmask[0]);
$('#'+int+'-netmask').val(createNetmaskAddr(arrIPNetmask[1]));
break;
case "routers":
$('#'+int+'-gateway').val(v2);
break;
case "domain_name_server":
svrsDNS = v2.split(" ");
$('#'+int+'-dnssvr').val(svrsDNS[0]);
$('#'+int+'-dnssvralt').val(svrsDNS[1]);
break;
}
});
});
});
}
function saveNetworkSettings(int) {
var frmInt = $('#frm-'+int).find(':input');
var arrFormData = {};
$.each(frmInt,function(i3,v3){
if($(v3).attr('type') == 'radio') {
arrFormData[$(v3).attr('id')] = $(v3).prop('checked');
} else {
arrFormData[$(v3).attr('id')] = $(v3).val();
}
});
arrFormData['interface'] = int;
$.post('/ajax/networking/save_int_config.php',arrFormData,function(data){
//console.log(data);
var jsonData = JSON.parse(data);
$('#msgNetworking').html(msgShow(jsonData['return'],jsonData['output']));
});
}
function applyNetworkSettings() {
var int = $(this).data('int');
arrFormData = {};
arrFormData['generate'] = '';
$.post('/ajax/networking/gen_int_config.php',arrFormData,function(data){
console.log(data);
var jsonData = JSON.parse(data);
$('#msgNetworking').html(msgShow(jsonData['return'],jsonData['output']));
});
}
$(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();});
$('.intsave').click(function(){
var int = $(this).data('int');
saveNetworkSettings(int);
});
$('.intapply').click(function(){
applyNetworkSettings();
});
}
function setCSRFTokenHeader(event, xhr, settings) {
var csrfToken = $('meta[name=csrf_token]').attr('content');
if (/^(POST|PATCH|PUT|DELETE)$/i.test(settings.type)) {
xhr.setRequestHeader("X-CSRF-Token", csrfToken);
}
}
function contentLoaded() {
pageCurrent = window.location.href.split("?")[1].split("=")[1];
pageCurrent = pageCurrent.replace("#","");
$('#side-menu').metisMenu();
switch(pageCurrent) {
case "network_conf":
getAllInterfaces();
setupTabs();
setupBtns();
break;
}
}
function loadWifiStations(refresh) {
return function() {
var complete = function() { $(this).removeClass('loading-spinner'); }
var qs = refresh === true ? '?refresh' : '';
$('.js-wifi-stations')
.addClass('loading-spinner')
.empty()
.load('/ajax/networking/wifi_stations.php'+qs, complete);
};
}
$(".js-reload-wifi-stations").on("click", loadWifiStations(true));
$(document).on("click", ".js-toggle-password", function(e) {
var button = $(e.target)
var field = $(button.data("target"));
if (field.is(":input")) {
e.preventDefault();
if (!button.data("__toggle-with-initial")) {
button.data("__toggle-with-initial", button.text())
}
if (field.attr("type") === "password") {
button.text(button.data("toggle-with"));
field.attr("type", "text");
} else {
button.text(button.data("__toggle-with-initial"));
field.attr("type", "password");
}
}
});
$(document).on("keyup", ".js-validate-psk", function(e) {
var field = $(e.target);
var colors = field.data("colors").split(",");
var target = $(field.data("target"));
if (field.val().length < 8 || field.val().length > 63) {
field.css("backgroundColor", colors[0]);
target.attr("disabled", true);
} else {
field.css("backgroundColor", colors[1]);
target.attr("disabled", false);
}
});
$(function() {
$('#theme-select').change(function() {
var theme = themes[$( "#theme-select" ).val() ];
set_theme(theme);
});
});
function set_theme(theme) {
$('link[title="main"]').attr('href', 'app/css/' + theme);
// persist selected theme in cookie
setCookie('theme',theme,90);
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
var themes = {
"default": "custom.css",
"hackernews" : "hackernews.css",
"terminal" : "terminal.css",
}
//Loads the correct sidebar on window load,
//collapses the sidebar on window resize.
// Sets the min-height of #page-wrapper to window size
$(function() {
$(window).bind("load resize", function() {
topOffset = 50;
width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
if (width < 768) {
$('div.navbar-collapse').addClass('collapse');
topOffset = 100; // 2-row-menu
} else {
$('div.navbar-collapse').removeClass('collapse');
}
height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
height = height - topOffset;
if (height < 1) height = 1;
if (height > topOffset) {
$("#page-wrapper").css("min-height", (height) + "px");
}
});
var url = window.location;
var element = $('ul.nav a').filter(function() {
return this.href == url || url.href.indexOf(this.href) == 0;
}).addClass('active').parent().parent().addClass('in').parent();
if (element.is('li')) {
element.addClass('active');
}
});
$(document)
.ajaxSend(setCSRFTokenHeader)
.ready(contentLoaded)
.ready(loadWifiStations());

7
app/js/custom.min.js vendored Normal file
View File

@ -0,0 +1,7 @@
/*!
* RaspAP - RaspAP WiFi Configuration Portal v1.6.1 (https://github.com/billz/raspap-webgui)
* Copyright 2013-2019 RaspAP Developers
* Licensed under MIT (https://github.com/raspap-webgui/raspap-webgui/blob/master/LICENSE)
*/
function msgShow(t,a){if(0==t)var e="success";else if(2==t||1==t)e="danger";return'<div class="alert alert-'+e+' alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+a+"</div>"}function createNetmaskAddr(t){var a=[];for(i=0;i<4;i++){var e=Math.min(t,8);a.push(256-Math.pow(2,8-e)),t-=e}return a.join(".")}function loadSummary(a){$.post("/ajax/networking/get_ip_summary.php",{interface:a},function(t){jsonData=JSON.parse(t),console.log(jsonData),0==jsonData.return?$("#"+a+"-summary").html(jsonData.output.join("<br />")):2==jsonData.return&&$("#"+a+"-summary").append('<div class="alert alert-danger alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+jsonData.output.join("<br />")+"</div>")})}function getAllInterfaces(){$.get("/ajax/networking/get_all_interfaces.php",function(t){jsonData=JSON.parse(t),$.each(jsonData,function(t,a){loadSummary(a)})})}function setupTabs(){$('a[data-toggle="tab"]').on("shown.bs.tab",function(t){var a=$(t.target).attr("href");a.match("summary")||loadCurrentSettings(a.replace("#",""))})}function loadCurrentSettings(t){$.post("/ajax/networking/get_int_config.php",{interface:t},function(t){jsonData=JSON.parse(t),$.each(jsonData.output,function(t,a){var n=a.interface;$.each(a,function(t,a){switch(t){case"static":"true"==a?($("#"+n+"-static").click(),$("#"+n+"-nofailover").click()):$("#"+n+"-dhcp").click();break;case"failover":"true"===a?$("#"+n+"-failover").click():$("#"+n+"-nofailover").click();break;case"ip_address":var e=a.split("/");$("#"+n+"-ipaddress").val(e[0]),$("#"+n+"-netmask").val(createNetmaskAddr(e[1]));break;case"routers":$("#"+n+"-gateway").val(a);break;case"domain_name_server":svrsDNS=a.split(" "),$("#"+n+"-dnssvr").val(svrsDNS[0]),$("#"+n+"-dnssvralt").val(svrsDNS[1])}})})})}function saveNetworkSettings(t){var a=$("#frm-"+t).find(":input"),e={};$.each(a,function(t,a){"radio"==$(a).attr("type")?e[$(a).attr("id")]=$(a).prop("checked"):e[$(a).attr("id")]=$(a).val()}),e.interface=t,$.post("/ajax/networking/save_int_config.php",e,function(t){var a=JSON.parse(t);$("#msgNetworking").html(msgShow(a.return,a.output))})}function applyNetworkSettings(){$(this).data("int");arrFormData={generate:""},$.post("/ajax/networking/gen_int_config.php",arrFormData,function(t){console.log(t);var a=JSON.parse(t);$("#msgNetworking").html(msgShow(a.return,a.output))})}function setupBtns(){$("#btnSummaryRefresh").click(function(){getAllInterfaces()}),$(".intsave").click(function(){saveNetworkSettings($(this).data("int"))}),$(".intapply").click(function(){applyNetworkSettings()})}function setCSRFTokenHeader(t,a,e){var n=$("meta[name=csrf_token]").attr("content");/^(POST|PATCH|PUT|DELETE)$/i.test(e.type)&&a.setRequestHeader("X-CSRF-Token",n)}function contentLoaded(){switch(pageCurrent=window.location.href.split("?")[1].split("=")[1],pageCurrent=pageCurrent.replace("#",""),$("#side-menu").metisMenu(),pageCurrent){case"network_conf":getAllInterfaces(),setupTabs(),setupBtns()}}function loadWifiStations(a){return function(){var t=!0===a?"?refresh":"";$(".js-wifi-stations").addClass("loading-spinner").empty().load("/ajax/networking/wifi_stations.php"+t,function(){$(this).removeClass("loading-spinner")})}}$(document).on("click",".js-add-dhcp-static-lease",function(t){t.preventDefault();var a=$(".js-new-dhcp-static-lease"),e=$("input[name=mac]",a).val().trim(),n=$("input[name=ip]",a).val().trim();if(""!=e&&""!=n){var i=$("#js-dhcp-static-lease-row").html().replace("{{ mac }}",e).replace("{{ ip }}",n);$(".js-dhcp-static-lease-container").append(i),$("input[name=mac]",a).val(""),$("input[name=ip]",a).val("")}}),$(document).on("click",".js-remove-dhcp-static-lease",function(t){t.preventDefault(),$(this).parents(".js-dhcp-static-lease-row").remove()}),$(document).on("submit",".js-dhcp-settings-form",function(t){$(".js-add-dhcp-static-lease").trigger("click")}),$(".js-reload-wifi-stations").on("click",loadWifiStations(!0)),$(document).on("click",".js-toggle-password",function(t){var a=$(t.target),e=$(a.data("target"));e.is(":input")&&(t.preventDefault(),a.data("__toggle-with-initial")||a.data("__toggle-with-initial",a.text()),"password"===e.attr("type")?(a.text(a.data("toggle-with")),e.attr("type","text")):(a.text(a.data("__toggle-with-initial")),e.attr("type","password")))}),$(document).on("keyup",".js-validate-psk",function(t){var a=$(t.target),e=a.data("colors").split(","),n=$(a.data("target"));a.val().length<8||63<a.val().length?(a.css("backgroundColor",e[0]),n.attr("disabled",!0)):(a.css("backgroundColor",e[1]),n.attr("disabled",!1))}),$(document).ajaxSend(setCSRFTokenHeader).ready(contentLoaded).ready(loadWifiStations());