diff options
| author | Alex Rudyy <orudyy@apache.org> | 2013-09-14 11:30:18 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2013-09-14 11:30:18 +0000 |
| commit | cb6a374621753f4a0c9cd65a64c77203a10ac27d (patch) | |
| tree | 1cc04974d0789aec964725650191fd026d454b2e /java | |
| parent | 6334fbadec3b3ec39507272509276b14dc986fef (diff) | |
| download | qpid-python-cb6a374621753f4a0c9cd65a64c77203a10ac27d.tar.gz | |
QPID-5138: Add preferences UI into web management console
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1523222 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
11 files changed, 479 insertions, 7 deletions
diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java index 4aebf90a75..d2e0c0dc6e 100644 --- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java +++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java @@ -330,6 +330,13 @@ public class HttpManagement extends AbstractPluginAdapter implements HttpManagem root.addServlet(new ServletHolder(new LogFileListingServlet()), "/rest/logfiles"); root.addServlet(new ServletHolder(new LogFileServlet()), "/rest/logfile"); + String[] timeZoneFiles = {"africa", "antarctica", "asia", "australasia", "backward", + "etcetera", "europe", "northamerica", "pacificnew", "southamerica"}; + for (String timeZoneFile : timeZoneFiles) + { + root.addServlet(new ServletHolder(FileServlet.INSTANCE), "/dojo/dojox/date/zoneinfo/" + timeZoneFile); + } + final SessionManager sessionManager = root.getSessionHandler().getSessionManager(); sessionManager.setSessionCookie(JSESSIONID_COOKIE_PREFIX + lastPort); sessionManager.setMaxInactiveInterval((Integer)getAttribute(TIME_OUT)); diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java index 5314cbaece..9ba36bb5c2 100644 --- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java +++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java @@ -41,6 +41,8 @@ import org.codehaus.jackson.map.SerializationConfig; public class HelperServlet extends AbstractServlet { + private static final long serialVersionUID = 1L; + private static final String PARAM_ACTION = "action"; private Map<String, Action> _actions; @@ -56,6 +58,7 @@ public class HelperServlet extends AbstractServlet new ListBrokerAttribute(Broker.SUPPORTED_VIRTUALHOST_STORE_TYPES, "ListMessageStoreTypes"), new ListBrokerAttribute(Broker.SUPPORTED_VIRTUALHOST_TYPES, "ListVirtualHostTypes"), new ListBrokerAttribute(Broker.SUPPORTED_PREFERENCES_PROVIDERS_TYPES, "ListPreferencesProvidersTypes"), + new ListBrokerAttribute(Broker.PRODUCT_VERSION, "version"), new ListGroupProviderAttributes(), new ListAccessControlProviderAttributes(), new PluginClassProviderAction() diff --git a/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html b/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html new file mode 100644 index 0000000000..0c60970f11 --- /dev/null +++ b/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html @@ -0,0 +1,35 @@ +<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>
\ No newline at end of file diff --git a/java/broker-plugins/management-http/src/main/java/resources/css/common.css b/java/broker-plugins/management-http/src/main/java/resources/css/common.css index e45c9cb463..d9064f40c9 100644 --- a/java/broker-plugins/management-http/src/main/java/resources/css/common.css +++ b/java/broker-plugins/management-http/src/main/java/resources/css/common.css @@ -148,4 +148,18 @@ div .messages { .grayBackground tr{background-color:#eeeeee !important; background-image: none !important;} .dojoxGridRowOdd.grayBackground tr{ background-color:#e9e9e9 !important; background-image: none !important;} .dojoxGridRowOdd.yellowBackground tr{background-color:#fafdd5 !important; background-image: none !important;} -.dojoxGridRowOdd.redBackground tr{background-color:#f4c1c1 !important; background-image: none !important;}
\ No newline at end of file +.dojoxGridRowOdd.redBackground tr{background-color:#f4c1c1 !important; background-image: none !important;} + +.preferencesIcon +{ + background: url("../images/gear.png") no-repeat; + width: 16px; + height: 16px; +} + +.helpIcon +{ + background: url("../images/help.png") no-repeat; + width: 16px; + height: 16px; +}
\ No newline at end of file diff --git a/java/broker-plugins/management-http/src/main/java/resources/images/gear.png b/java/broker-plugins/management-http/src/main/java/resources/images/gear.png Binary files differnew file mode 100644 index 0000000000..0bb4394b46 --- /dev/null +++ b/java/broker-plugins/management-http/src/main/java/resources/images/gear.png diff --git a/java/broker-plugins/management-http/src/main/java/resources/images/help.png b/java/broker-plugins/management-http/src/main/java/resources/images/help.png Binary files differnew file mode 100644 index 0000000000..f7d3698d25 --- /dev/null +++ b/java/broker-plugins/management-http/src/main/java/resources/images/help.png diff --git a/java/broker-plugins/management-http/src/main/java/resources/index.html b/java/broker-plugins/management-http/src/main/java/resources/index.html index 4b97c464ec..4fc961ec12 100644 --- a/java/broker-plugins/management-http/src/main/java/resources/index.html +++ b/java/broker-plugins/management-http/src/main/java/resources/index.html @@ -42,7 +42,6 @@ var dojoConfig = { tlmSiblingOfDojo:false, - parseOnLoad:true, async:true, baseUrl: getContextPath(), packages:[ @@ -58,7 +57,14 @@ </script> <script> - require(["dijit/layout/BorderContainer", + var qpidHelpLocation = "http://qpid.apache.org/releases/qpid-"; + var qpidHelpURL = null; + var qpidPreferences = null; + require([ + "dojo/_base/xhr", + "dojo/parser", + "qpid/management/Preferences", + "dijit/layout/BorderContainer", "dijit/layout/TabContainer", "dijit/layout/ContentPane", "dijit/TitlePane", @@ -66,7 +72,18 @@ "qpid/management/treeView", "qpid/management/controller", "qpid/common/footer", - "qpid/authorization/checkUser"]); + "qpid/authorization/checkUser"], function(xhr, parser, Preferences){ + parser.parse(); + qpidPreferences = new Preferences(); + xhr.get({ + sync: true, + url: "rest/helper?action=version", + handleAs: "json" + }).then(function(qpidVersion) { + qpidHelpURL = qpidHelpLocation + qpidVersion + "/java-broker/book/index.html"; + }); + + }); </script> </head> @@ -75,7 +92,27 @@ <div id="pageLayout" data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design: 'headline', gutters: false"> <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'"> <div id="header" class="header" style="float: left; width: 300px"></div> - <div id="login" style="float: right; display:none"><strong>User: </strong> <span id="authenticatedUser"></span><a href="logout">[logout]</a></div> + <div style="float: right;"> + <div id="login" style="display:none"><strong>User: </strong> <span id="authenticatedUser"></span><a href="logout">[logout]</a></div> + <div id="preferencesButton" style="float: right; margin-top: 0px;" data-dojo-type="dijit.form.DropDownButton" data-dojo-props="iconClass: 'preferencesIcon', title: 'Preferences', showLabel:false"> + <div data-dojo-type="dijit.Menu"> + <div data-dojo-type="dijit.MenuItem" data-dojo-props=" + iconClass: 'dijitIconFunction', + onClick: function(){ qpidPreferences.showDialog(); } "> + Preferences + </div> + <!-- + <div data-dojo-type="dijit.MenuItem" data-dojo-props="iconClass: 'dijitIconMail', onClick: function(){ console.log('TODO'); }"> + Contacts + </div> + --> + <div data-dojo-type="dijit.MenuItem" data-dojo-props="iconClass: 'helpIcon', onClick: function(){ + var newWindow = window.open(qpidHelpURL,'QpidHelp','height=600,width=600,scrollbars=1,location=1,resizable=1,status=0,toolbar=0,titlebar=1,menubar=0',true); newWindow.focus(); } "> + Help + </div> + </div> + </div> + </div> </div> <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'leading', splitter: true" style="width:20%"> <div qpid-type="treeView" qpid-props="query: 'rest/structure'" ></div> @@ -104,4 +141,4 @@ </div> </body> -</html>
\ No newline at end of file +</html> diff --git a/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/checkUser.js b/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/checkUser.js index 159c7458ed..d65e6c6e07 100644 --- a/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/checkUser.js +++ b/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/checkUser.js @@ -29,7 +29,7 @@ var updateUI = function updateUI(data) if(data.user) { dom.byId("authenticatedUser").innerHTML = entities.encode(String(data.user)); - dom.byId("login").style.display = "block"; + dom.byId("login").style.display = "inline"; } }; diff --git a/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js b/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js new file mode 100644 index 0000000000..287fbc9619 --- /dev/null +++ b/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js @@ -0,0 +1,176 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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([ + "dojo/_base/declare", + "dojo/_base/array", + "dojo/dom-construct", + "dojo/parser", + "dojo/query", + "dojo/store/Memory", + "dijit/_WidgetBase", + "dijit/registry", + "dojo/text!common/TimeZoneSelector.html", + "dijit/form/ComboBox", + "dijit/form/FilteringSelect", + "dojox/date/timezone", + "dojox/validate/us", + "dojox/validate/web", + "dojo/domReady!"], +function (declare, array, domConstruct, parser, query, Memory, _WidgetBase, registry, template) { + + var preferencesRegions = ["Africa","America","Antarctica","Arctic","Asia","Atlantic","Australia","Europe","Indian","Pacific"]; + + function initSupportedTimeZones() + { + var supportedTimeZones = []; + var allTimeZones = dojox.date.timezone.getAllZones(); + for(var i = 0; i < allTimeZones.length; i++) + { + var timeZone = allTimeZones[i]; + var elements = timeZone.split("/"); + if (elements.length > 1) + { + for(var j = 0; j<preferencesRegions.length; j++) + { + if (elements[0] == preferencesRegions[j]) + { + supportedTimeZones.push({id: timeZone, region: elements[0], city: elements.slice(1).join("/").replace("_", " ") }) + break; + } + } + } + } + return supportedTimeZones; + } + + function initSupportedRegions() + { + var supportedRegions = [{"id": "undefined", "name": "Undefined"}]; + for(var j = 0; j<preferencesRegions.length; j++) + { + supportedRegions.push({id: preferencesRegions[j], name: preferencesRegions[j] }); + } + return supportedRegions; + } + + return declare("qpid.common.TimeZoneSelector", [_WidgetBase], { + + value: null, + domNode: null, + _regionSelector: null, + _citySelector: null, + + constructor: function(args) + { + this._args = args; + }, + + buildRendering: function(){ + this.domNode = domConstruct.create("div", {innerHTML: template}); + parser.parse(this.domNode); + }, + + postCreate: function(){ + this.inherited(arguments); + + var supportedTimeZones = initSupportedTimeZones(); + + this._citySelector = registry.byNode(query(".timezoneCity", this.domNode)[0]); + this._citySelector.set("searchAttr", "city"); + this._citySelector.set("query", {region: /.*/}); + this._citySelector.set("labelAttr", "city"); + this._citySelector.set("store", new Memory({ data: supportedTimeZones })); + if (this._args.name) + { + this._citySelector.set("name", this._args.name); + } + this._regionSelector = registry.byNode(query(".timezoneRegion", this.domNode)[0]); + var supportedRegions = initSupportedRegions(); + this._regionSelector.set("store", new Memory({ data: supportedRegions })); + var self = this; + + this._regionSelector.on("change", function(value){ + if (value=="undefined") + { + self._citySelector.set("disabled", true); + self._citySelector.query.region = /.*/; + self.value = null; + self._citySelector.set("value", null); + } + else + { + self._citySelector.set("disabled", false); + self._citySelector.query.region = value || /.*/; + if (this.timeZone) + { + self._citySelector.set("value", this.timeZone); + this.timeZone = null; + } + else + { + self._citySelector.set("value", null); + } + } + }); + + this._citySelector.on("change", function(value){ + self.value = value; + }); + + this._setValueAttr(this._args.value); + }, + + _setValueAttr: function(value) + { + if (value) + { + 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._regionSelector.set("value", "undefined"); + } + this.value = value; + }, + + destroy: function() + { + if (this.domNode) + { + this.domNode.destroy(); + this.domNode = null; + } + _regionSelector: null; + _citySelector: null; + } + + }); +});
\ No newline at end of file diff --git a/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js b/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js new file mode 100644 index 0000000000..6d587b37d1 --- /dev/null +++ b/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js @@ -0,0 +1,149 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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([ + "dojo/_base/declare", + "dojo/_base/xhr", + "dojo/_base/event", + "dojo/dom", + "dojo/dom-construct", + "dojo/parser", + "dojo/query", + "dojo/json", + "dojox/html/entities", + "dijit/registry", + "qpid/common/TimeZoneSelector", + "dojo/text!../../showPreferences.html", + "dijit/Dialog", + "dijit/form/NumberSpinner", + "dijit/form/CheckBox", + "dijit/form/Textarea", + "dijit/form/FilteringSelect", + "dijit/form/TextBox", + "dijit/form/DropDownButton", + "dijit/form/Button", + "dijit/form/Form", + "dojox/validate/us", + "dojox/validate/web", + "dojo/domReady!"], +function (declare, xhr, event, dom, domConstruct, parser, query, json, entities, registry, TimeZoneSelector, markup) { + + var preferenceNames = ["timeZone", "updatePeriod", "saveTabs"]; + + return declare("qpid.management.Preferences", null, { + + preferencesDialog: null, + saveButton: null, + cancelButton: null, + + constructor: function() + { + var that = this; + + this.domNode = domConstruct.create("div", {innerHTML: markup}); + parser.parse(this.domNode); + + for(var i=0; i<preferenceNames.length; i++) + { + var name = preferenceNames[i]; + this[name] = registry.byNode(query("." + name, this.domNode)[0]); + } + + this.saveButton = registry.byNode(query(".saveButton", this.domNode)[0]); + this.cancelButton = registry.byNode(query(".cancelButton", this.domNode)[0]); + this.theForm = registry.byId("preferencesForm"); + + this.preferencesDialog = new dijit.Dialog({ + title:"Preferences", + style: "width: 600px", + content: this.domNode + }); + + this.cancelButton.on("click", function(){that.preferencesDialog.hide();}); + this.theForm.on("submit", function(e){ + event.stop(e); + if(that.theForm.validate()){ + var preferences = {}; + for(var i=0; i<preferenceNames.length; i++) + { + var name = preferenceNames[i]; + var preferenceWidget = that[name]; + if (preferenceWidget) + { + preferences[name] = preferenceWidget.get("value"); + } + } + xhr.post({ + url: "rest/preferences", + sync: true, + handleAs: "json", + headers: { "Content-Type": "application/json"}, + postData: json.stringify(preferences), + load: function(x) {that.success = true; }, + error: function(error) {that.success = false; that.failureReason = error;} + }); + if(that.success === true) + { + that.preferencesDialog.hide(); + } + else + { + alert("Error:" + that.failureReason); + } + } + return false; + }); + this.preferencesDialog.startup(); + }, + + showDialog: function(){ + var that = this; + xhr.get({ + url: "rest/preferences", + sync: true, + handleAs: "json" + }).then( + function(data) { + for(var preference in data) + { + if (that.hasOwnProperty(preference)) + { + var value = data[preference]; + if (typeof data[preference] == "string") + { + value = entities.encode(String(value)) + } + that[preference].set("value", value); + } + } + that.preferencesDialog.show(); + }); + }, + + destroy: function() + { + if (this.preferencesDialog) + { + this.preferencesDialog.destroyRecursevly(); + this.preferencesDialog = null; + } + } + }); +});
\ No newline at end of file diff --git a/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html b/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html new file mode 100644 index 0000000000..48997096db --- /dev/null +++ b/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html @@ -0,0 +1,51 @@ +<!-- + - + - Licensed to the Apache Software Foundation (ASF) under one + - or more contributor license agreements. See the NOTICE file + - distributed with this work for additional information + - regarding copyright ownership. The ASF licenses this file + - to you 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. + - + --> +<div> + <form method="post" data-dojo-type="dijit/form/Form" id="preferencesForm"> + <table cellpadding="0" cellspacing="2"> + <tr> + <td><strong>Time zone: </strong></td> + <td> + <span class="timeZone" data-dojo-type="qpid/common/TimeZoneSelector" data-dojo-props="name: 'timeZone'"></span> + </td> + </tr> + <tr> + <td><strong>Update period:</strong></td> + <td><input class="updatePeriod" name="updatePeriod" data-dojo-type="dijit/form/NumberSpinner" data-dojo-props=" + invalidMessage: 'Invalid value', + required: false, + smallDelta: 1, + value: 5, + constraints: {min:1,max:65535,places:0, pattern: '#####'}, + "/> + </td> + </tr> + <tr> + <td><strong>Save tabs:</strong></td> + <td><input class="saveTabs" type="checkbox" data-dojo-type="dijit/form/CheckBox" name="saveTabs"/></td> + </tr> + </table> + <div class="dijitDialogPaneActionBar"> + <input type="submit" value="Save Preferences" data-dojo-type="dijit/form/Button" data-dojo-props="label: 'Save Preferences'" class="saveButton"/> + <button value="Cancel" data-dojo-type="dijit/form/Button" data-dojo-props="label: 'Cancel'" class="cancelButton"></button> + </div> + </form> +</div> |
