couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [38/50] [abbrv] git commit: improve logs date format
Date Mon, 11 Feb 2013 11:12:14 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/2c48183e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/2c48183e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/2c48183e

Branch: refs/heads/fauxton
Commit: 2c48183ed7f258cdb833865fb7ac944ce98f95cb
Parents: 827a1b5
Author: Garren Smith <garren.smith@gmail.com>
Authored: Tue Feb 5 10:35:25 2013 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Tue Feb 5 10:35:25 2013 +0200

----------------------------------------------------------------------
 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/2c48183e/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/2c48183e/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/2c48183e/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