Skip to content

Commit

Permalink
ui:Use moment library to display dates
Browse files Browse the repository at this point in the history
This lib has the ability to display timestamps like in github:
"just now", "one minute ago", etc
You got the actual date with mouse over.

Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
  • Loading branch information
Pierre Tardy committed Nov 16, 2012
1 parent a6b2a17 commit 61b6208
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
11 changes: 8 additions & 3 deletions master/buildbot/scripts/update_js.py
Expand Up @@ -27,7 +27,8 @@
("https://github.com/kriszyp/put-selector/archive/v0.3.2.zip",
"put-selector-0.3.2/","put-selector"),
("https://github.com/SitePen/dgrid/archive/v0.3.3.zip",
"dgrid-0.3.3/","dgrid")
"dgrid-0.3.3/","dgrid"),
("https://github.com/timrwood/moment/archive/1.7.2.zip","moment-1.7.2/min/moment.min.js","moment.js")
]
def syncStatic(config,www, workdir, olddir):
"""Synchronize the static directory"""
Expand Down Expand Up @@ -80,8 +81,12 @@ def downloadJSDeps(config, workdir):
o.close()
z = zipfile.ZipFile(fn)
for member in z.infolist():
if not member.filename.startswith(archivedir):
continue
isdir = member.external_attr & 16
dest = os.path.join(workdir, "js", archivedest, member.filename[len(archivedir):])
dest = os.path.join(workdir, "js", archivedest)
if member.filename[len(archivedir):]:
dest = os.path.join(dest, member.filename[len(archivedir):])
if isdir:
if not os.path.exists(dest):
os.makedirs(dest)
Expand All @@ -93,7 +98,7 @@ def downloadJSDeps(config, workdir):
o.close()
build_js = """
dependencies = (function(){
var _packages = "dojox dijit put-selector lib dgrid xstyle %(extra_pkg)s".split(" ");
var _packages = "dojox dijit put-selector lib dgrid xstyle moment %(extra_pkg)s".split(" ");
var packages = [];
for (var i = 0;i<_packages.length; i+=1) {
if (_packages[i].length >1) {
Expand Down
11 changes: 5 additions & 6 deletions master/buildbot/www/static/js/lib/ui/dgridext/TypedColumns.js
@@ -1,5 +1,5 @@
define(["dojo/_base/declare", "dojo/_base/lang", "dojo/_base/array"],
function(declare, lang, array){
define(["dojo/_base/declare", "dojo/_base/lang", "dojo/_base/array","moment"],
function(declare, lang, array, moment){
/* implement basic types for columns to display them in a nice way
*/
return declare(null, {
Expand All @@ -25,12 +25,11 @@ function(declare, lang, array){
},
_configColumn_date: function(column, columnId, rowColumns, prefix){
column.formatter = function(s) {
var d = new Date(0);
d.setUTCSeconds(s);
return d.toLocaleDateString()+" "+ d.toLocaleTimeString();
var d = moment.unix(s);
return "<abbr title='"+ d.format('LLLL')+"'>"+d.fromNow()+"</abbr>" ;
};
if (column.style === undefined){
column.style="width:250px;";
column.style="width:110px;";
}
},
_configColumn_url: function(column, columnId, rowColumns, prefix){
Expand Down

0 comments on commit 61b6208

Please sign in to comment.