Perform version update check in ajax to avoid footer delay

This commit is contained in:
emanuele-f 2017-05-31 23:02:42 +02:00
parent 86d2ad35a6
commit 3b23fc0859
3 changed files with 67 additions and 23 deletions

View file

@ -1787,28 +1787,16 @@ function version2int(v)
end
end
function ntop_version_check()
_rsp = ntop.getCache("ntopng.cache.version")
function get_version_update_msg(info, latest_version)
version_elems = split(info["version"], " ")
new_version = version2int(latest_version)
this_version = version2int(version_elems[1])
if((_rsp == nil) or (_rsp == "")) then
_rsp = ntop.httpGet("http://www.ntop.org/ntopng.version", "", "", 10)
if((_rsp == nil) or (_rsp["CONTENT"] == nil)) then rsp = "0.0.0" else rsp = _rsp["CONTENT"] end
ntop.setCache("ntopng.cache.version", rsp, 86400)
else
rsp = _rsp
end
if(rsp ~= nil) then
info = ntop.getInfo(false)
new_version = version2int(rsp)
version_elems = split(info["version"], " ");
this_version = version2int(version_elems[1])
if(new_version > this_version) then
print("<p><div class=\"alert alert-warning\"><font color=red><i class=\"fa fa-cloud-download fa-lg\"></i> A new "..info["product"].." (v." .. rsp .. ") is available for <A HREF=\"http://www.ntop.org/get-started/download/\">download</A>: please upgrade.</font></div></p>")
end
end
if(new_version > this_version) then
return [[<div class='alert alert-warning'><font color=red><i class='fa fa-cloud-download fa-lg'></i> A new ]]..info["product"]..[[ (v.]]..(latest_version)..[[) is available for <A HREF='http://www.ntop.org/get-started/download/'>download</A>: please upgrade.</font></div>]]
else
return ""
end
end