More dashboard adjustments
This commit is contained in:
parent
8a5c16ade2
commit
8f3c5ae9f2
1
app.js
1
app.js
|
@ -24,7 +24,6 @@ app.use(express.static(path.join(__dirname, 'public')));
|
||||||
/* Normal Web Routes */
|
/* Normal Web Routes */
|
||||||
app.use('/', require('./routes/index'));
|
app.use('/', require('./routes/index'));
|
||||||
app.use('/users', require('./routes/users'));
|
app.use('/users', require('./routes/users'));
|
||||||
app.use('/get_dashboard', require('./routes/dashboard'));
|
|
||||||
app.use('/get_stats', require('./routes/get_stats'));
|
app.use('/get_stats', require('./routes/get_stats'));
|
||||||
app.use('/dhcp_leases', require('./routes/dhcp_leases'));
|
app.use('/dhcp_leases', require('./routes/dhcp_leases'));
|
||||||
app.use('/dhcp_log', require('./routes/dhcp_log'));
|
app.use('/dhcp_log', require('./routes/dhcp_log'));
|
||||||
|
|
|
@ -3,22 +3,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$( document ).ajaxComplete(function( event, request, settings ) {
|
$( document ).ajaxComplete(function( event, request, settings ) {
|
||||||
|
|
||||||
/*
|
|
||||||
* Properly check pjax requests to see if we are in the dashboard or not
|
|
||||||
*/
|
|
||||||
if(/v_ajax/.test(settings.url)){
|
|
||||||
request = settings.url;
|
|
||||||
request = request.replace("\?v_ajax", "").trim();
|
|
||||||
|
|
||||||
if(request == "/" && in_dashboard != 1) {
|
|
||||||
in_dashboard = 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
in_dashboard = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Form input focus event
|
* Form input focus event
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -218,15 +218,6 @@
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var in_dashboard = 0;
|
|
||||||
|
|
||||||
function get_dashboard() {
|
|
||||||
$.get( "/get_dashboard", function( data ) {
|
|
||||||
$('#body-content').html(data);
|
|
||||||
$('#shared-networks').fadeOut(300).fadeIn(300);
|
|
||||||
$('#display-subnets').fadeOut(300).fadeIn(300);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function get_stats() {
|
function get_stats() {
|
||||||
$.get( "/get_stats", function( data ) {
|
$.get( "/get_stats", function( data ) {
|
||||||
$('#cpu-utilization').html(data.cpu_utilization + "%");
|
$('#cpu-utilization').html(data.cpu_utilization + "%");
|
||||||
|
@ -256,26 +247,17 @@
|
||||||
"aaSorting": []
|
"aaSorting": []
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#shared-networks').fadeOut(100).fadeIn(100);
|
||||||
|
$('#display-subnets').fadeOut(100).fadeIn(100);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get_stats_timer = setInterval(function () {
|
get_stats_timer = setInterval(function () {
|
||||||
console.log("get_stats_timer");
|
if (window_focus && $('#total-leases').length) {
|
||||||
if (window_focus && $('#total-leases').length && in_dashboard == 1) {
|
|
||||||
console.log("get_stats_timer trigger");
|
|
||||||
get_stats();
|
get_stats();
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
if(window.location.pathname == "/") {
|
|
||||||
get_stats();
|
|
||||||
in_dashboard = 1;
|
|
||||||
console.log("in dash");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
in_dashboard = 0;
|
|
||||||
console.log("out dash");
|
|
||||||
}
|
|
||||||
|
|
||||||
var window_focus = true;
|
var window_focus = true;
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
var express = require('express');
|
|
||||||
var router = express.Router();
|
|
||||||
var fs = require('fs');
|
|
||||||
var template_render = require('../lib/render_template.js');
|
|
||||||
|
|
||||||
var json_file = require('jsonfile');
|
|
||||||
glass_config = json_file.readFileSync('config/glass_config.json');
|
|
||||||
|
|
||||||
router.get('/', function(req, res, next) {
|
|
||||||
|
|
||||||
/* Display Counters Row */
|
|
||||||
counters = template_render.get_template("counters");
|
|
||||||
|
|
||||||
/* Display Shared Networks Row */
|
|
||||||
content_shared_networks = template_render.get_template("shared_networks");
|
|
||||||
|
|
||||||
/* Display Subnets Row */
|
|
||||||
content_subnets = template_render.get_template("display_subnets");
|
|
||||||
|
|
||||||
res.send(
|
|
||||||
counters +
|
|
||||||
'<div class="row clearfix">' +
|
|
||||||
content_shared_networks + content_subnets +
|
|
||||||
'</div>' + '<script type="text/javascript">get_stats();</script>'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = router;
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ router.get('/', function(req, res, next) {
|
||||||
content_shared_networks + content_subnets +
|
content_shared_networks + content_subnets +
|
||||||
'</div>',
|
'</div>',
|
||||||
req.url
|
req.url
|
||||||
) + '<script type="text/javascript">get_stats();</script>'
|
) + '<script type="text/javascript">get_stats(); </script>'
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue