couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chewbra...@apache.org
Subject [3/50] git commit: improve logs date format
Date Fri, 15 Mar 2013 21:50:09 GMT
improve logs date format


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e1d5737e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e1d5737e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e1d5737e

Branch: refs/heads/fauxton-rebase
Commit: e1d5737e8d26e28362f9c81e2a65db476870f65b
Parents: 4182410
Author: Garren Smith <garren.smith@gmail.com>
Authored: Tue Feb 5 10:35:25 2013 +0200
Committer: Russell Branca <chewbranca@gmail.com>
Committed: Fri Mar 15 14:35:12 2013 -0700

----------------------------------------------------------------------
 src/fauxton/TODO.md                                |    2 +-
 src/fauxton/app/addons/logs/resources.js           |   27 +++++++++++++-
 .../app/addons/logs/templates/dashboard.html       |   12 +++---
 3 files changed, 32 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/e1d5737e/src/fauxton/TODO.md
----------------------------------------------------------------------
diff --git a/src/fauxton/TODO.md b/src/fauxton/TODO.md
index bb37113..31127e0 100644
--- a/src/fauxton/TODO.md
+++ b/src/fauxton/TODO.md
@@ -20,7 +20,7 @@ In no particular order
 - [ ] edit index button doesn't
 - [ ] replicate UI
 - [x] delete database
-- [ ] format dates better (e.g. in logs plugin)
+- [x] format dates better (e.g. in logs plugin)
 - [ ] format log entry better
 - [ ] filter logs by method
 - [ ] restore unfiltered data in logs UI

http://git-wip-us.apache.org/repos/asf/couchdb/blob/e1d5737e/src/fauxton/app/addons/logs/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/resources.js b/src/fauxton/app/addons/logs/resources.js
index a3339d0..982ad85 100644
--- a/src/fauxton/app/addons/logs/resources.js
+++ b/src/fauxton/app/addons/logs/resources.js
@@ -7,7 +7,30 @@ function (app, FauxtonAPI) {
 
   var Log = FauxtonAPI.addon();
 
-  Log.Model = Backbone.Model.extend({ });
+  Log.Model = Backbone.Model.extend({
+
+    date: function () {
+      var date = new Date(this.get('date'));
+
+      var formatted_time = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
+      var formatted_date = date.toDateString().slice(4, 10);
+
+      return formatted_date + ' ' + formatted_time;
+    },
+
+    logLevel: function () {
+      return this.get('log_level').replace(/ /g,'');
+    },
+
+    pid: function () {
+      return _.escape(this.get('pid'));
+    },
+
+    args: function () {
+      return _.escape(this.get('args'));
+    }
+
+  });
 
   Log.Collection = Backbone.Collection.extend({
     model: Log.Model,
@@ -69,7 +92,7 @@ function (app, FauxtonAPI) {
     },
 
     serialize: function () {
-      return { logs: this.filteredCollection.toJSON()};
+      return { logs: this.filteredCollection};
     },
 
     afterRender: function () {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/e1d5737e/src/fauxton/app/addons/logs/templates/dashboard.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/templates/dashboard.html b/src/fauxton/app/addons/logs/templates/dashboard.html
index 951e1ba..eafb857 100644
--- a/src/fauxton/app/addons/logs/templates/dashboard.html
+++ b/src/fauxton/app/addons/logs/templates/dashboard.html
@@ -10,21 +10,21 @@
   </thead>
 
   <tbody>
-    <% _.each(logs, function (log) { %>
-    <tr class="<%= log.log_level %>">
+    <% logs.each(function (log) { %>
+    <tr class="<%= log.logLevel() %>">
       <td>
         <!-- TODO: better format the date -->
-        <%= log.date.replace(/ /g,'') %>
+        <%= log.date() %>
       </td>
       <td>
-        <%= log.log_level.replace(/ /g,'') %>
+        <%= log.logLevel() %>
       </td>
       <td>
-        <%= _.escape(log.pid) %>
+        <%= log.pid() %>
       </td>
       <td>
         <!-- TODO: split the line, maybe put method in it's own column -->
-        <%= _.escape(log.args) %>
+        <%= log.args() %>
       </td>
     </tr>
     <% }); %>


Mime
View raw message