mirror of
https://github.com/Akkadius/glass-isc-dhcp.git
synced 2025-07-27 23:54:32 +02:00
Syntax formatting
This commit is contained in:
parent
949740fc6b
commit
07e00ce72e
@ -1,6 +1,5 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var fs = require('fs');
|
||||
|
||||
router.get('/', function (req, res, next) {
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var fs = require('fs');
|
||||
|
||||
router.get('/', function (req, res, next) {
|
||||
|
||||
@ -15,7 +14,7 @@ router.get('/', function(req, res, next) {
|
||||
mac_oui = dhcp_lease_data[key].mac.split(":").join("").toUpperCase().slice(0, 6);
|
||||
}
|
||||
|
||||
if(mac_oui == "")
|
||||
if (mac_oui === "")
|
||||
continue;
|
||||
|
||||
if (typeof stat_data[mac_oui] === "undefined")
|
||||
|
@ -8,15 +8,13 @@ var router = express.Router();
|
||||
router.get('/', function (req, res, next) {
|
||||
|
||||
var json_file = require('jsonfile');
|
||||
glass_config = json_file.readFileSync('config/glass_config.json');
|
||||
let glass_config = json_file.readFileSync('config/glass_config.json');
|
||||
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
|
||||
const execSync = require('child_process').execSync;
|
||||
output = execSync('./bin/dhcpd-pools -c ' + glass_config.config_file + ' -l ' + glass_config.leases_file + ' -f j -A -s e');
|
||||
|
||||
// console.log(JSON.parse(output));
|
||||
|
||||
res.send(JSON.stringify(JSON.parse(output)));
|
||||
});
|
||||
|
||||
|
@ -27,9 +27,12 @@ function websockets_unsubscribe_all_events(){
|
||||
}
|
||||
|
||||
function connect_websocket() {
|
||||
$.getJSON("/api/get_websocket_config", function (data) {
|
||||
|
||||
var websocket_port = data.ws_port;
|
||||
|
||||
delete socket;
|
||||
socket = new WebSocket("ws://" + window.location.hostname + ":8080");
|
||||
socket = new WebSocket("ws://" + window.location.hostname + ":" + websocket_port);
|
||||
|
||||
socket.onopen = function (event) {
|
||||
console.log("[Websocket] socket is opened - readystate is " + socket.readyState);
|
||||
@ -47,13 +50,14 @@ function connect_websocket() {
|
||||
return false;
|
||||
|
||||
/* Event Hooks */
|
||||
if (event_data['event'] == 'dhcp_log_subscription')
|
||||
if (event_data['event'] === 'dhcp_log_subscription')
|
||||
parse_log_stream(event_data.data);
|
||||
|
||||
if (event_data['event'] == 'dhcp_statistics')
|
||||
if (event_data['event'] === 'dhcp_statistics')
|
||||
parse_statistics_stream(event_data.data);
|
||||
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
connect_websocket();
|
||||
|
@ -1,16 +1,13 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var fs = require('fs');
|
||||
var template_render = require('../lib/render_template.js');
|
||||
|
||||
/* GET home page. */
|
||||
router.get('/', function (req, res, next) {
|
||||
|
||||
var json_file = require('jsonfile');
|
||||
var glass_config = json_file.readFileSync('config/glass_config.json');
|
||||
|
||||
const execSync = require('child_process').execSync;
|
||||
output = execSync('./bin/dhcpd-pools -c ' + glass_config.config_file + ' -l ' + glass_config.leases_file + ' -f j -A -s e');
|
||||
let output = execSync('./bin/dhcpd-pools -c ' + glass_config.config_file + ' -l ' + glass_config.leases_file + ' -f j -A -s e');
|
||||
|
||||
var dhcp_data = JSON.parse(output);
|
||||
|
||||
@ -25,7 +22,7 @@ router.get('/', function(req, res, next) {
|
||||
return parseFloat(b.utilization) - parseFloat(a.utilization);
|
||||
});
|
||||
|
||||
shared_networks = '';
|
||||
let shared_networks = '';
|
||||
|
||||
for (var i = 0; i < dhcp_data['shared-networks'].length; i++) {
|
||||
|
||||
@ -92,7 +89,7 @@ router.get('/', function(req, res, next) {
|
||||
|
||||
total_leases = dhcp_data.summary.used.toLocaleString('en');
|
||||
|
||||
return_data = {
|
||||
let return_data = {
|
||||
"cpu_utilization": cpu_utilization,
|
||||
"leases_used": total_leases,
|
||||
"leases_per_second": current_leases_per_second,
|
||||
|
Loading…
x
Reference in New Issue
Block a user