From 244bafe3363113b315e82afb2cf786a5c5e48ff1 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 1 Feb 2015 22:02:12 +0100 Subject: [PATCH] Display create date and last activity in admin area --- public/js/vroom.js | 15 +++++++++++++++ templates/default/admin.html.ep | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/public/js/vroom.js b/public/js/vroom.js index 39d6b9a..6b29128 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -157,6 +157,15 @@ function timeStamp2Date(sec){ return d.toLocaleString(); } +// Convert dates from UTC to local TZ +function utc2Local(date) { + var newDate = new Date(date.getTime()+date.getTimezoneOffset()*60*1000); + var offset = date.getTimezoneOffset() / 60; + var hours = date.getHours(); + newDate.setHours(hours - offset); + return newDate; +} + // Temporarily suspend a button, prevent abuse function suspendButton(el){ $(el).attr('disabled', true); @@ -395,8 +404,14 @@ function initAdmin(){ if (filter === '' || obj.name.match(filterRe)){ matches++; if (i >= min && i < max){ + var t = obj.create_date.split(/[- :]/); + var create = utc2Local(new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5])).toLocaleString(); + t = obj.last_activity.split(/[- :]/); + var activity = utc2Local(new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5])).toLocaleString(); $('#roomList').append($('') .append($('').html(stringEscape(obj.name))) + .append($('').html(stringEscape(create)).addClass('hidden-xs')) + .append($('').html(stringEscape(activity)).addClass('hidden-xs')) .append($('') .append($('
').addClass('btn-group') .append($('').addClass('btn btn-default').attr('href',rootUrl + obj.name) diff --git a/templates/default/admin.html.ep b/templates/default/admin.html.ep index b014149..f5943be 100644 --- a/templates/default/admin.html.ep +++ b/templates/default/admin.html.ep @@ -28,6 +28,12 @@ <%=l 'ROOM_NAME' %> + + <%=l 'CREATION_DATE' %> + + + <%=l 'LAST_ACTIVITY' %> + <%=l 'MANAGE' %>