couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject [07/50] couchdb commit: updated refs/heads/2200-feature-support-erlang-17.0 to c81eb6d
Date Mon, 28 Apr 2014 12:41:40 GMT
Fauxton: fix missing leading zeros in logs

This adds leading zeros to the times in the log view. Before that
the times were displayed like 1:5:3 (if it were 01:05:03)
because getHours() and friends are returning a Number and not
a String with a leading 0. In the case of 1:5:3 the corrected
time is now displayed as: 01:05:03. As d3 has a nice date formatter
we do not have to roll our own.


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

Branch: refs/heads/2200-feature-support-erlang-17.0
Commit: 11f9d8af5da693a6ff3f8f33aa538caab5892869
Parents: 198eb74
Author: Robert Kowalski <rok@kowalski.gd>
Authored: Sun Apr 13 13:48:00 2014 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Mon Apr 14 08:50:47 2014 +0200

----------------------------------------------------------------------
 src/Makefile.am                                 |  3 +-
 src/fauxton/app/addons/logs/resources.js        | 15 ++++----
 src/fauxton/app/addons/logs/tests/baseSpec.js   | 38 ++++++++++++++++++++
 src/fauxton/app/addons/logs/tests/logSpec.js    | 38 --------------------
 .../app/addons/logs/tests/resourcesSpec.js      | 38 ++++++++++++++++++++
 5 files changed, 85 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/11f9d8af/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 07ee5e1..ea1a11b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -84,7 +84,8 @@ FAUXTON_FILES = \
     fauxton/app/addons/logs/templates/dashboard.html \
     fauxton/app/addons/logs/templates/filterItem.html \
     fauxton/app/addons/logs/templates/sidebar.html \
-    fauxton/app/addons/logs/tests/logSpec.js \
+    fauxton/app/addons/logs/tests/baseSpec.js \
+    fauxton/app/addons/logs/tests/resourcesSpec.js \
     fauxton/app/addons/permissions/assets/less/permissions.less \
     fauxton/app/addons/permissions/base.js \
     fauxton/app/addons/permissions/resources.js \

http://git-wip-us.apache.org/repos/asf/couchdb/blob/11f9d8af/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 3a47b92..5cfa673 100644
--- a/src/fauxton/app/addons/logs/resources.js
+++ b/src/fauxton/app/addons/logs/resources.js
@@ -13,22 +13,21 @@
 define([
   "app",
   "api",
-  "backbone"
+  "backbone",
+  "d3"
 ],
 
-function (app, FauxtonAPI, Backbone) {
+function (app, FauxtonAPI, Backbone, d3) {
 
   var Log = FauxtonAPI.addon();
 
   Log.Model = Backbone.Model.extend({
 
     date: function () {
-      var date = new Date(this.get('date'));
+      var date = new Date(this.get('date')),
+          formatter = d3.time.format("%b %e %H:%M%:%S");
 
-      var formatted_time = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
-      var formatted_date = date.toDateString().slice(4, 10);
-
-      return formatted_date + ' ' + formatted_time;
+      return formatter(date);
     },
 
     logLevel: function () {
@@ -51,7 +50,7 @@ function (app, FauxtonAPI, Backbone) {
     initialize: function (options) {
       this.params = {bytes: 5000};
     },
-    
+
     documentation: "log",
 
     url: function () {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/11f9d8af/src/fauxton/app/addons/logs/tests/baseSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/tests/baseSpec.js b/src/fauxton/app/addons/logs/tests/baseSpec.js
new file mode 100644
index 0000000..621cc9b
--- /dev/null
+++ b/src/fauxton/app/addons/logs/tests/baseSpec.js
@@ -0,0 +1,38 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+define([
+       'addons/logs/base',
+       'chai'
+], function (Log, chai) {
+  var expect = chai.expect;
+
+  describe('Logs Addon', function(){
+
+    describe('Log Model', function () {
+      var log;
+
+      beforeEach(function () {
+        log = new Log.Model({
+          log_level: 'DEBUG',
+          pid: '1234',
+          args: 'testing 123',
+          date: (new Date()).toString()
+        });
+      });
+
+      it('should have a log level', function () {
+        expect(log.logLevel()).to.equal('DEBUG');
+      });
+
+    });
+  });
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/11f9d8af/src/fauxton/app/addons/logs/tests/logSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/tests/logSpec.js b/src/fauxton/app/addons/logs/tests/logSpec.js
deleted file mode 100644
index 621cc9b..0000000
--- a/src/fauxton/app/addons/logs/tests/logSpec.js
+++ /dev/null
@@ -1,38 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-define([
-       'addons/logs/base',
-       'chai'
-], function (Log, chai) {
-  var expect = chai.expect;
-
-  describe('Logs Addon', function(){
-
-    describe('Log Model', function () {
-      var log;
-
-      beforeEach(function () {
-        log = new Log.Model({
-          log_level: 'DEBUG',
-          pid: '1234',
-          args: 'testing 123',
-          date: (new Date()).toString()
-        });
-      });
-
-      it('should have a log level', function () {
-        expect(log.logLevel()).to.equal('DEBUG');
-      });
-
-    });
-  });
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/11f9d8af/src/fauxton/app/addons/logs/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/tests/resourcesSpec.js b/src/fauxton/app/addons/logs/tests/resourcesSpec.js
new file mode 100644
index 0000000..d67c677
--- /dev/null
+++ b/src/fauxton/app/addons/logs/tests/resourcesSpec.js
@@ -0,0 +1,38 @@
+// Licensed under the Apache License, Version 2.0 (the 'License'); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+       'addons/logs/resources',
+       'testUtils'
+], function (Log, testUtils) {
+  var assert = testUtils.assert;
+
+  describe('Log Resources', function () {
+
+    describe('Date Formatter', function () {
+      it('adds leading zeros to minutes', function () {
+        var model;
+
+        model = new Log.Model({
+                  date: 'Sat, 12 Apr 2014 15:04:01 GMT',
+                  log_level: 'info',
+                  pid: '123',
+                  args: 'ente ente'
+                });
+        // timezones with daylightsaving in JS are hard
+        // and we use the current local time here
+        // so do not test for hours and the exact day
+        assert.ok(/Apr \d\d \d\d:04:01/.test(model.date()));
+      });
+    });
+  });
+});


Mime
View raw message