diff --git a/manager/views.py b/manager/views.py index 35eb941..d904c5c 100644 --- a/manager/views.py +++ b/manager/views.py @@ -21,6 +21,7 @@ import tempfile import crypt import tarfile import datetime +import time def index(request): if request.user.is_authenticated: @@ -232,8 +233,8 @@ def ping(request, device_id): ajax += ',\n "serial": "%s"' % device[0].serial ajax += ',\n "name": "%s"' % device[0].name if device[0].name else "" ajax += ',\n "ip": "%s"' % device[0].curip - ajax += ',\n "time": "%s"' % device[0].lasttime - ajax += ',\n "lastbeat": "%s"' % device[0].lastbeat + ajax += ',\n "time": "%i"' % (int(time.mktime(timezone.make_naive(device[0].lasttime, timezone.get_current_timezone()).timetuple())) * 1000) + ajax += ',\n "lastbeat": "%s"' % (int(time.mktime(timezone.make_naive(device[0].lastbeat, timezone.get_current_timezone()).timetuple())) * 1000) ajax += ',\n "reboot": %i' % (1 if device[0].reboot else 0) ajax += ',\n "update": %i' % (1 if device[0].update else 0) diff --git a/static/js/devices.js b/static/js/devices.js index 2e7ae9c..d863a51 100644 --- a/static/js/devices.js +++ b/static/js/devices.js @@ -1,5 +1,5 @@ function timeSince(obj) { - last = new Date(obj) + last = new Date(Number(obj)); var seconds = Math.floor((new Date() - last) / 1000); interval = Math.floor(seconds / 3600); out = ""; @@ -12,7 +12,7 @@ function timeSince(obj) { if (seconds < 120) out = seconds + " seconds " else if (interval > 1 && interval < 120) out = out + interval + " minutes "; - return out + "ago" + return out + "ago"; } function styleStatus(msg, device) {