Device discovery now sets the device type in the Mac class

Mac devices are now serialized/deserialized
This commit is contained in:
Luca Deri 2017-08-13 10:26:14 +02:00
parent 14af3b24aa
commit 6ab41bee36
13 changed files with 345 additions and 241 deletions

View file

@ -14,6 +14,7 @@ require "lua_utils"
require "graph_utils"
require "alert_utils"
require "historical_utils"
local discover = require "discover_utils"
local host_pools_utils = require "host_pools_utils"
local host_info = url2hostinfo(_GET)
@ -39,6 +40,8 @@ end
mac_info = interface.getMacInfo(mac, vlanId)
-- tprint(mac_info)
if(mac_info == nil) then
print('<div class=\"alert alert-danger\"><i class="fa fa-warning fa-lg"></i>'..' '..i18n("mac_details.mac_cannot_be_found_message",{mac=mac}))
print("</div>")
@ -74,8 +77,6 @@ if(_POST["custom_icon"] ~=nil) then
setHostIcon(mac, _POST["custom_icon"])
end
print(getHostIcon(mac))
local label = getHostAltName(mac)
if mac_info["num_hosts"] > 0 then
@ -132,6 +133,11 @@ if isAdministrator() then
end
end
if(mac_info.devtype ~= 0) then
-- This is a known device type
print("<tr><th>".. i18n("details.device_type") .. "</th><td>" .. discover.devtype2icon(mac_info.devtype) .. " " .. mac_info.device_type .. "</td><td></td></tr>\n")
end
print("<tr><th>".. i18n("details.first_last_seen") .. "</th><td nowrap><span id=first_seen>" .. formatEpoch(mac_info["seen.first"]) .. " [" .. secondsToTime(os.time()-mac_info["seen.first"]) .. " " .. i18n("details.ago").."]" .. "</span></td>\n")
print("<td width='35%'><span id=last_seen>" .. formatEpoch(mac_info["seen.last"]) .. " [" .. secondsToTime(os.time()-mac_info["seen.last"]) .. " " .. i18n("details.ago").."]" .. "</span></td></tr>\n")