From 4f9930fc53eaa73909038d2dd86bbda0d2d6e302 Mon Sep 17 00:00:00 2001 From: Philip Kirkbride Date: Tue, 11 Jul 2017 15:52:50 -0400 Subject: [PATCH 1/3] Fix bug breaking date/time sort --- puppetboard/static/js/tables.js | 3 ++- puppetboard/templates/index.html | 2 +- puppetboard/templates/nodes.html | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/puppetboard/static/js/tables.js b/puppetboard/static/js/tables.js index 25c4434..ed99bb5 100644 --- a/puppetboard/static/js/tables.js +++ b/puppetboard/static/js/tables.js @@ -11,7 +11,8 @@ } $('thead th.date').data('sortBy', function(th, td, tablesort) { - return moment.utc(td.text()).unix(); + var tdTime = td.text().replace("-", ""); + return moment.utc(tdTime).unix(); }); $('input.filter-table').parent('div').removeClass('hide'); diff --git a/puppetboard/templates/index.html b/puppetboard/templates/index.html index 7e59e26..ec8f49b 100644 --- a/puppetboard/templates/index.html +++ b/puppetboard/templates/index.html @@ -87,7 +87,7 @@ Status Certname - Report + Report diff --git a/puppetboard/templates/nodes.html b/puppetboard/templates/nodes.html index aefea6a..5301005 100644 --- a/puppetboard/templates/nodes.html +++ b/puppetboard/templates/nodes.html @@ -9,8 +9,8 @@ Status Certname - Catalog - Report + Catalog + Report   From a555611cc61e170731af449dfd695b64af469cb0 Mon Sep 17 00:00:00 2001 From: Philip Kirkbride Date: Thu, 13 Jul 2017 11:44:22 -0400 Subject: [PATCH 2/3] Use js instead of moment to parse date to avoid warning --- puppetboard/static/js/tables.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/puppetboard/static/js/tables.js b/puppetboard/static/js/tables.js index ed99bb5..c44a71b 100644 --- a/puppetboard/static/js/tables.js +++ b/puppetboard/static/js/tables.js @@ -12,7 +12,7 @@ $('thead th.date').data('sortBy', function(th, td, tablesort) { var tdTime = td.text().replace("-", ""); - return moment.utc(tdTime).unix(); + return moment.utc(new Date(tdTime)).unix(); }); $('input.filter-table').parent('div').removeClass('hide'); From 18df71924acef8ae169b621c64b07704a258d963 Mon Sep 17 00:00:00 2001 From: Philip Kirkbride Date: Thu, 13 Jul 2017 11:56:50 -0400 Subject: [PATCH 3/3] modify date sort to handle failed #405 --- puppetboard/static/js/tables.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/puppetboard/static/js/tables.js b/puppetboard/static/js/tables.js index c44a71b..a91d23b 100644 --- a/puppetboard/static/js/tables.js +++ b/puppetboard/static/js/tables.js @@ -11,8 +11,9 @@ } $('thead th.date').data('sortBy', function(th, td, tablesort) { - var tdTime = td.text().replace("-", ""); - return moment.utc(new Date(tdTime)).unix(); + var tdTime = new Date(td.text().replace("-", "")); + if(isNaN(tdTime)) return 0; + else return tdTime; }); $('input.filter-table').parent('div').removeClass('hide');