From c236320166d90ba90331a730d95063fe6b4fd95f Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Sat, 5 Oct 2013 00:33:04 +0000 Subject: QPID-5138: Add ability into web management console to display time in UTC git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1529365 13f79535-47bb-0310-9956-ffa450edef68 --- .../servlet/rest/UserPreferencesServlet.java | 2 +- .../plugin/servlet/rest/action/ListTimeZones.java | 2 +- .../java/resources/common/TimeZoneSelector.html | 67 +++++++++++++--------- .../resources/js/qpid/common/TimeZoneSelector.js | 57 +++++++++++++++--- .../main/java/resources/js/qpid/common/timezone.js | 21 +++++++ .../src/main/java/resources/showPreferences.html | 11 ++-- 6 files changed, 116 insertions(+), 44 deletions(-) (limited to 'qpid/java') diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/UserPreferencesServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/UserPreferencesServlet.java index 36949e22e1..355b5df177 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/UserPreferencesServlet.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/UserPreferencesServlet.java @@ -66,7 +66,7 @@ public class UserPreferencesServlet extends AbstractServlet { if (!userPreferencesOperationAuthorized(userId)) { - response.sendError(HttpServletResponse.SC_FORBIDDEN, "Vieweing of preferences is not allowed"); + response.sendError(HttpServletResponse.SC_FORBIDDEN, "Viewing of preferences is not allowed"); return; } Map preferences = null; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListTimeZones.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListTimeZones.java index 008018dba4..d46e90f2bd 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListTimeZones.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListTimeZones.java @@ -60,7 +60,7 @@ public class ListTimeZones implements Action TimeZone tz = TimeZone.getTimeZone(id); int offset = tz.getOffset(currentTime)/60000; String city = id.substring(cityPos + 1).replace('_', ' '); - timeZoneDetails.add(new TimeZoneDetails(id, tz.getDisplayName(), offset, city, region)); + timeZoneDetails.add(new TimeZoneDetails(id, tz.getDisplayName(true, TimeZone.SHORT), offset, city, region)); break; } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html index 7027a4555c..2b2fca7d8a 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html @@ -20,36 +20,47 @@ --> - + - + + + +
RegionUse UTC time: - + City
Time Zone: - -
+ + + + + + +
RegionCity
+ \ No newline at end of file diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js index ddeba188e0..7d0a02afca 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js @@ -24,6 +24,7 @@ define([ "dojo/dom-construct", "dojo/parser", "dojo/query", + "dojo/dom-style", "dojo/store/Memory", "dijit/_WidgetBase", "dijit/registry", @@ -31,10 +32,11 @@ define([ "qpid/common/timezone", "dijit/form/ComboBox", "dijit/form/FilteringSelect", + "dijit/form/CheckBox", "dojox/validate/us", "dojox/validate/web", "dojo/domReady!"], -function (declare, array, domConstruct, parser, query, Memory, _WidgetBase, registry, template, timezone) { +function (declare, array, domConstruct, parser, query, domStyle, Memory, _WidgetBase, registry, template, timezone) { var preferencesRegions = ["Africa","America","Antarctica","Arctic","Asia","Atlantic","Australia","Europe","Indian","Pacific"]; @@ -54,6 +56,7 @@ function (declare, array, domConstruct, parser, query, Memory, _WidgetBase, regi domNode: null, _regionSelector: null, _citySelector: null, + _utcSelector: null, constructor: function(args) { @@ -68,8 +71,17 @@ function (declare, array, domConstruct, parser, query, Memory, _WidgetBase, regi postCreate: function(){ this.inherited(arguments); + var self = this; + if (this._args.labelStyle) + { + var nl = query(".labelClass", this.domNode); + array.forEach(nl, function(entry, i){ + domStyle.set(entry, self._args.labelStyle) + }); + } var supportedTimeZones = timezone.getAllTimeZones(); + this._utcSelector = registry.byNode(query(".utcSelector", this.domNode)[0]); this._citySelector = registry.byNode(query(".timezoneCity", this.domNode)[0]); this._citySelector.set("searchAttr", "city"); this._citySelector.set("query", {region: /.*/}); @@ -82,8 +94,27 @@ function (declare, array, domConstruct, parser, query, Memory, _WidgetBase, regi this._regionSelector = registry.byNode(query(".timezoneRegion", this.domNode)[0]); var supportedRegions = initSupportedRegions(); this._regionSelector.set("store", new Memory({ data: supportedRegions })); - var self = this; + this._utcSelector.on("change", function(value){ + var checked = this.get("checked"); + if (checked) + { + self.value ="UTC"; + } + else + { + if (self._citySelector.value && self._regionSelector.value) + { + self.value = self._citySelector.value; + } + else + { + self.value = null; + } + } + self._citySelector.set("disabled", checked); + self._regionSelector.set("disabled", checked); + }); this._regionSelector.on("change", function(value){ if (value=="undefined") { @@ -119,20 +150,29 @@ function (declare, array, domConstruct, parser, query, Memory, _WidgetBase, regi { if (value) { - var elements = value.split("/"); - if (elements.length > 1) + if (value == "UTC") { - this._regionSelector.timeZone = value; - this._regionSelector.set("value", elements[0]); - this._citySelector.set("value", value); + this._utcSelector.set("checked", true); } else { - this._regionSelector.set("value", "undefined"); + this._utcSelector.set("checked", false); + var elements = value.split("/"); + if (elements.length > 1) + { + this._regionSelector.timeZone = value; + this._regionSelector.set("value", elements[0]); + this._citySelector.set("value", value); + } + else + { + this._regionSelector.set("value", "undefined"); + } } } else { + this._utcSelector.set("checked", false); this._regionSelector.set("value", "undefined"); } this.value = value; @@ -147,6 +187,7 @@ function (declare, array, domConstruct, parser, query, Memory, _WidgetBase, regi } _regionSelector: null; _citySelector: null; + _utcSelector: null; } }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/timezone.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/timezone.js index bbec4f587b..d03b44843a 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/timezone.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/timezone.js @@ -23,6 +23,18 @@ define(["dojo/_base/xhr"], function (xhr) { var timezones = {}; + var timeZoneSortFunction = function(a, b){ + if (a.region == b.region) + { + if (a.city == b.city) + { + return 0; + } + return a.city < b.city ? -1 : 1; + } + return a.region < b.region ? -1 : 1; + } + function loadTimezones() { xhr.get({ @@ -31,6 +43,7 @@ define(["dojo/_base/xhr"], function (xhr) { handleAs: "json", load: function(zones) { + zones.sort(timeZoneSortFunction); timezones.data = zones; }, error: function(error) @@ -53,6 +66,14 @@ define(["dojo/_base/xhr"], function (xhr) { return timezones.data; }, getTimeZoneInfo: function(timeZone) { + if (timeZone == "UTC") + { + return { + "id" : "UTC", + "name" : "UTC", + "offset" : 0 + } + } var tzi = timezones[timeZone]; if (!tzi) { diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html index 35a489474f..ada919f5a5 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html @@ -22,15 +22,13 @@
- +
+
- - + - +
Time zone: - -
Update period:Update period: -- cgit v1.2.1