Fix issue where unidentified mac's would not show up in device lists
This commit is contained in:
parent
877fbff2c1
commit
e558f1b97e
|
@ -1,24 +1,40 @@
|
|||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var fs = require('fs');
|
||||
var router = express.Router();
|
||||
|
||||
router.get('/', function(req, res, next) {
|
||||
router.get('/', function (req, res, next) {
|
||||
|
||||
var stat_data = {};
|
||||
var stat_data = {};
|
||||
|
||||
var count = 0;
|
||||
for (var key in dhcp_lease_data) {
|
||||
if((typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc') == "")
|
||||
continue;
|
||||
var count = 0;
|
||||
for (var key in dhcp_lease_data) {
|
||||
|
||||
if(typeof stat_data[(typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc')] === "undefined")
|
||||
stat_data[(typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc')] = 0;
|
||||
/**
|
||||
* If we don't have a vendor - set as N/A
|
||||
*/
|
||||
if (dhcp_lease_data[key].mac_oui_vendor === "") {
|
||||
dhcp_lease_data[key].mac_oui_vendor = "N/A";
|
||||
}
|
||||
|
||||
stat_data[(typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" && dhcp_lease_data[key].mac_oui_vendor != "" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc')]++;
|
||||
}
|
||||
/**
|
||||
* Init array
|
||||
*/
|
||||
if (typeof stat_data[(typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc')] === "undefined")
|
||||
stat_data[(typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc')] = 0;
|
||||
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(JSON.stringify(stat_data));
|
||||
let vendor_string = (typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" && dhcp_lease_data[key].mac_oui_vendor != "" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc');
|
||||
|
||||
/**
|
||||
* Increment vendor count
|
||||
*/
|
||||
stat_data[vendor_string]++;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return JSON response
|
||||
*/
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(JSON.stringify(stat_data));
|
||||
});
|
||||
|
||||
module.exports = router;
|
Loading…
Reference in New Issue