Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3AC1B11235 for ; Tue, 15 Apr 2014 08:46:09 +0000 (UTC) Received: (qmail 72680 invoked by uid 500); 15 Apr 2014 08:45:53 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 71853 invoked by uid 500); 15 Apr 2014 08:45:12 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 70516 invoked by uid 99); 15 Apr 2014 08:44:40 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Apr 2014 08:44:40 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 90AAD8BC1CB; Tue, 15 Apr 2014 08:44:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: djc@apache.org To: commits@couchdb.apache.org Date: Tue, 15 Apr 2014 08:44:43 -0000 Message-Id: <2fb7e647607b4899887000edb0c57e13@git.apache.org> In-Reply-To: <31c6da2eede04e1aa317623feed7e60a@git.apache.org> References: <31c6da2eede04e1aa317623feed7e60a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [04/17] couchdb commit: updated refs/heads/1.6.x to 6f06749 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/1.6.x Commit: 11f9d8af5da693a6ff3f8f33aa538caab5892869 Parents: 198eb74 Author: Robert Kowalski Authored: Sun Apr 13 13:48:00 2014 +0200 Committer: Garren Smith 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())); + }); + }); + }); +});