summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorAlex Rudyy <orudyy@apache.org>2013-10-05 00:33:04 +0000
committerAlex Rudyy <orudyy@apache.org>2013-10-05 00:33:04 +0000
commitc236320166d90ba90331a730d95063fe6b4fd95f (patch)
treecc2917a4fa60e7919d991bc39c26bc5db420c460 /qpid/java
parente036c68dc92df9385e6994f9c20372c9851f2ed1 (diff)
downloadqpid-python-c236320166d90ba90331a730d95063fe6b4fd95f.tar.gz
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
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/UserPreferencesServlet.java2
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListTimeZones.java2
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html67
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js57
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/timezone.js21
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html11
6 files changed, 116 insertions, 44 deletions
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<String, Object> 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 @@
-->
<table cellpadding="0" cellspacing="2">
<tr>
- <td>Region</td>
+ <td class="labelClass"><strong>Use UTC time:</strong></td>
<td>
- <select class='timezoneRegion' name="region" data-dojo-type="dijit/form/FilteringSelect" data-dojo-props="
- placeholder: 'Select region',
- required: true,
- missingMessage: 'A region must be supplied',
- title: 'Select region',
- autoComplete: true,
- value:'undefined'">
- <option value="undefined">Undefined</option>
- <option value="Africa">Africa</option>
- <option value="America">America</option>
- <option value="Antarctica">Antarctica</option>
- <option value="Arctic">Arctic</option>
- <option value="Asia">Asia</option>
- <option value="Atlantic">Atlantic</option>
- <option value="Australia">Australia</option>
- <option value="Europe">Europe</option>
- <option value="Indian">Indian</option>
- <option value="Pacific">Pacific</option>
- </select>
+ <input type="checkbox" class='utcSelector' name="utc" data-dojo-type="dijit/form/CheckBox" value="UTC"></input>
</td>
- <td>City</td>
+ </tr>
+ <tr>
+ <td class="labelClass"><strong>Time Zone:</strong></td>
<td>
- <select class='timezoneCity' name="city" data-dojo-type="dijit/form/FilteringSelect" data-dojo-props="
- placeholder: 'Select city',
- required: true,
- missingMessage: 'A city must be supplied',
- title: 'Select city'">
- </select>
- </td>
+ <table cellpadding="0" cellspacing="2">
+ <tr>
+ <td>Region</td>
+ <td><select class='timezoneRegion' name="region" data-dojo-type="dijit/form/FilteringSelect"
+ data-dojo-props="
+ placeholder: 'Select region',
+ required: true,
+ missingMessage: 'A region must be supplied',
+ title: 'Select region',
+ autoComplete: true,
+ value:'undefined'">
+ <option value="undefined">Undefined</option>
+ <option value="Africa">Africa</option>
+ <option value="America">America</option>
+ <option value="Antarctica">Antarctica</option>
+ <option value="Arctic">Arctic</option>
+ <option value="Asia">Asia</option>
+ <option value="Atlantic">Atlantic</option>
+ <option value="Australia">Australia</option>
+ <option value="Europe">Europe</option>
+ <option value="Indian">Indian</option>
+ <option value="Pacific">Pacific</option>
+ </select></td>
+ <td>City</td>
+ <td><select class='timezoneCity' name="city" data-dojo-type="dijit/form/FilteringSelect"
+ data-dojo-props="
+ placeholder: 'Select city',
+ required: true,
+ missingMessage: 'A city must be supplied',
+ title: 'Select city'">
+ </select></td>
+ </tr>
+ </table>
+ </td>
</tr>
</table> \ 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 @@
<div data-dojo-type="dijit/layout/TabContainer" style="width: 600px; height: 400px">
<div data-dojo-type="dijit/layout/ContentPane" title="Own Preferences" data-dojo-props="selected:true" id="preferences.preferencesTab">
<form method="post" data-dojo-type="dijit/form/Form" id="preferences.preferencesForm">
- <table cellpadding="0" cellspacing="2" style="overflow: auto; height: 300px;">
+ <div style="height:300px">
+ <table cellpadding="0" cellspacing="2">
<tr>
- <td><strong>Time zone: </strong></td>
- <td>
- <span id="preferences.timeZone" data-dojo-type="qpid/common/TimeZoneSelector" data-dojo-props="name: 'timeZone'"></span>
- </td>
+ <td colspan="2"><span id="preferences.timeZone" data-dojo-type="qpid/common/TimeZoneSelector" data-dojo-props="name: 'timeZone', labelStyle: {width: '105px'}"></span></td>
</tr>
<tr>
- <td><strong>Update period:</strong></td>
+ <td style="width: 105px"><strong>Update period:</strong></td>
<td><input id="preferences.updatePeriod" name="updatePeriod" data-dojo-type="dijit/form/NumberSpinner" data-dojo-props="
invalidMessage: 'Invalid value',
required: false,
@@ -41,6 +39,7 @@
</td>
</tr>
</table>
+ </div>
<div class="dijitDialogPaneActionBar">
<button data-dojo-type="dijit/form/Button" data-dojo-props="label: 'Set'" id="preferences.setButton">Set</button>
<button data-dojo-type="dijit/form/Button" data-dojo-props="label: 'Set and Close'" id="preferences.setAndCloseButton">Set and Close</button>