From 84f1fe631bfd9bd9f6b3e5c1b7628c4ad0b26d66 Mon Sep 17 00:00:00 2001 From: Justin Richer Date: Sat, 19 Apr 2014 08:42:26 -0400 Subject: [PATCH] clean up time display --- .../src/main/webapp/WEB-INF/views/approve.jsp | 23 ++++++++- .../src/main/webapp/resources/js/client.js | 22 ++++++++- .../src/main/webapp/resources/js/grant.js | 47 ++++++++++++++----- .../webapp/resources/template/client.html | 22 +++++++-- .../main/webapp/resources/template/grant.html | 8 ++-- 5 files changed, 95 insertions(+), 27 deletions(-) diff --git a/openid-connect-server-webapp/src/main/webapp/WEB-INF/views/approve.jsp b/openid-connect-server-webapp/src/main/webapp/WEB-INF/views/approve.jsp index 04c36f34f..2c97c143a 100644 --- a/openid-connect-server-webapp/src/main/webapp/WEB-INF/views/approve.jsp +++ b/openid-connect-server-webapp/src/main/webapp/WEB-INF/views/approve.jsp @@ -41,7 +41,7 @@ -

This client was dynamically registered.

+

This client was dynamically registered .

@@ -49,7 +49,8 @@

Caution:

- This software was dynamically registered and it has been approved + This software was dynamically registered + and it has been approved time previously. @@ -268,6 +269,24 @@ $(document).ready(function() { } }); + var creationDate = ""; + var displayCreationDate = "Unknown"; + var hoverCreationDate = ""; + if (creationDate == null || !moment(creationDate).isValid()) { + displayCreationDate = "Unknown"; + hoverCreationDate = ""; + } else { + creationDate = moment(creationDate); + if (moment().diff(creationDate, 'months') < 6) { + displayCreationDate = creationDate.fromNow(); + } else { + displayCreationDate = "on " + creationDate.format("MMMM Do, YYYY"); + } + hoverCreationDate = creationDate.format("MMMM Do, YYYY [at] h:mmA") + } + + $('#registrationTime').html(displayCreationDate); + $('#registrationTime').attr('title', hoverCreationDate); }); //--> diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/client.js b/openid-connect-server-webapp/src/main/webapp/resources/js/client.js index 4c0302666..c06c806d5 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/js/client.js +++ b/openid-connect-server-webapp/src/main/webapp/resources/js/client.js @@ -169,7 +169,26 @@ var ClientView = Backbone.View.extend({ }, render:function (eventName) { - var json = {client: this.model.toJSON(), count: this.options.count, whiteList: this.options.whiteList}; + + var creationDate = this.model.get('createdAt'); + var displayCreationDate = "Unknown"; + var hoverCreationDate = ""; + if (creationDate == null || !moment(creationDate).isValid()) { + displayCreationDate = "Unknown"; + hoverCreationDate = ""; + } else { + creationDate = moment(creationDate); + if (moment().diff(creationDate, 'months') < 6) { + displayCreationDate = creationDate.fromNow(); + } else { + displayCreationDate = "on " + creationDate.format("MMMM Do, YYYY"); + } + hoverCreationDate = creationDate.format("MMMM Do, YYYY [at] h:mmA"); + } + + + var json = {client: this.model.toJSON(), count: this.options.count, whiteList: this.options.whiteList, + displayCreationDate: displayCreationDate, hoverCreationDate: hoverCreationDate}; this.$el.html(this.template(json)); $('.scope-list', this.el).html(this.scopeTemplate({scopes: this.model.get('scope'), systemScopes: this.options.systemScopeList})); @@ -769,7 +788,6 @@ var ClientFormView = Backbone.View.extend({ render:function (eventName) { $(this.el).html(this.template(this.model.toJSON())); - var _self = this; diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/grant.js b/openid-connect-server-webapp/src/main/webapp/resources/js/grant.js index 7a3a22726..416af5b60 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/js/grant.js +++ b/openid-connect-server-webapp/src/main/webapp/resources/js/grant.js @@ -158,37 +158,58 @@ var ApprovedSiteView = Backbone.View.extend({ var accessDate = this.model.get("accessDate"); var timeoutDate = this.model.get("timeoutDate"); + var displayCreationDate = "Unknown"; + var hoverCreationDate = ""; if (creationDate == null || !moment(creationDate).isValid()) { - creationDate = "Unknown"; + displayCreationDate = "Unknown"; + hoverCreationDate = ""; } else { creationDate = moment(creationDate); if (moment().diff(creationDate, 'months') < 6) { - creationDate = creationDate.fromNow(); + displayCreationDate = creationDate.fromNow(); } else { - creationDate = creationDate.format("MMMM Do, YYYY"); + displayCreationDate = creationDate.format("MMMM Do, YYYY"); } + hoverCreationDate = creationDate.format("MMMM Do, YYYY [at] h:mmA"); } - + + var displayAccessDate = "Unknown"; + var hoverAccessDate = ""; if (accessDate == null || !moment(accessDate).isValid()) { - accessDate = "Unknown"; + displayAccessDate = "Unknown"; + hoverAccessDate = ""; } else { accessDate = moment(accessDate); if (moment().diff(accessDate, 'months') < 6) { - accessDate = accessDate.fromNow(); + displayAccessDate = accessDate.fromNow(); } else { - accessDate = accessDate.format("MMMM Do, YYYY"); + displayAccessDate = accessDate.format("MMMM Do, YYYY"); } + hoverAccessDate = accessDate.format("MMMM Do, YYYY [at] h:mmA"); } - + + var displayTimeoutDate = "Unknown"; + var hoverTimeoutDate = ""; if (timeoutDate == null) { - timeoutDate = "Never"; - } else if (!moment(timeoutDate).isValid()) { - timeoutDate = "Unknown"; + displayTimeoutDate = "Never"; + hoverTimeoutDate = ""; + } else if(!moment(timeoutDate).isValid()) { + displayTimeoutDate = "Unknown"; + hoverTimeoutDate = ""; } else { - timeoutDate = moment(timeoutDate).calendar(); + timeoutDate = moment(timeoutDate); + if (moment().diff(timeoutDate, 'months') < 6) { + displayTimeoutDate = timeoutDate.fromNow(); + } else { + displayTimeoutDate = timeoutDate.format("MMMM Do, YYYY"); + } + hoverTimeoutDate = timeoutDate.format("MMMM Do, YYYY [at] h:mmA"); } + - var formattedDate = {creationDate: creationDate, accessDate: accessDate, timeoutDate: timeoutDate}; + var formattedDate = {displayCreationDate: displayCreationDate, hoverCreationDate: hoverCreationDate, + displayAccessDate: displayAccessDate, hoverAccessDate: hoverAccessDate, + displayTimeoutDate: displayTimeoutDate, hoverTimeoutDate: hoverTimeoutDate}; var json = {grant: this.model.toJSON(), client: this.options.client.toJSON(), formattedDate: formattedDate}; diff --git a/openid-connect-server-webapp/src/main/webapp/resources/template/client.html b/openid-connect-server-webapp/src/main/webapp/resources/template/client.html index a4590b18c..e4b7ca3bd 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/template/client.html +++ b/openid-connect-server-webapp/src/main/webapp/resources/template/client.html @@ -23,15 +23,20 @@ <% } else if (count != null) { %> <%= count %> <% } else { %> - - <% } %> - <% if (client.dynamicallyRegistered) { %> - + ? <% } %> - <%= client.clientName != null ? client.clientName : ( client.clientId.substr(0,8) + '...' ) %> +
+ <%= client.clientName != null ? client.clientName : ( client.clientId.substr(0,8) + '...' ) %> +
+
+ <% if (client.dynamicallyRegistered) { %> + + <% } %> + Registered <%= displayCreationDate %> +
@@ -149,6 +154,13 @@
+
+ +
+ <%=createdAt%> +
+
+
diff --git a/openid-connect-server-webapp/src/main/webapp/resources/template/grant.html b/openid-connect-server-webapp/src/main/webapp/resources/template/grant.html index c0a794dfc..681c39ab2 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/template/grant.html +++ b/openid-connect-server-webapp/src/main/webapp/resources/template/grant.html @@ -88,19 +88,17 @@ - -
- Authorized: <%= formattedDate.creationDate %> + Authorized: <%= formattedDate.displayCreationDate %>
- Last accessed: <%= formattedDate.accessDate %> + Last accessed: <%= formattedDate.displayAccessDate %>
- Expires: <%= formattedDate.timeoutDate %> + Expires: <%= formattedDate.displayTimeoutDate %>