diff options
| author | Alex Rudyy <orudyy@apache.org> | 2013-09-19 15:36:14 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2013-09-19 15:36:14 +0000 |
| commit | e955421b3d626d150a80591bd07fa83a1aac58f7 (patch) | |
| tree | d4c460044651914860ae437302465b0b3108018b /qpid/java | |
| parent | 578564d5a5787848d8795afa01a5d77264370957 (diff) | |
| download | qpid-python-e955421b3d626d150a80591bd07fa83a1aac58f7.tar.gz | |
QPID-5138: Add functionality to delete user preferences from web management console
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1524771 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
4 files changed, 148 insertions, 42 deletions
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 0c60970f11..7027a4555c 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 @@ -1,3 +1,23 @@ +<!-- + - + - 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. + - + --> <table cellpadding="0" cellspacing="2"> <tr> <td>Region</td> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js index 86fda92cb5..3d349830ac 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js @@ -77,10 +77,10 @@ define(["dojo/_base/xhr", return exchangeName == null || exchangeName == "" || "<<default>>" == exchangeName || exchangeName.indexOf("amq.") == 0 || exchangeName.indexOf("qpid.") == 0; }; - util.deleteGridSelections = function(updater, grid, url, confirmationMessageStart) + util.deleteGridSelections = function(updater, grid, url, confirmationMessageStart, idParam) { var data = grid.selection.getSelected(); - + var success = false; if(data.length) { var confirmationMessage = null; @@ -114,18 +114,19 @@ define(["dojo/_base/xhr", { queryParam = "?"; } - queryParam += "id=" + data[i].id; + queryParam += ( idParam || "id" ) + "=" + encodeURIComponent(data[i].id); } var query = url + queryParam; - var success = true var failureReason = ""; xhr.del({url: query, sync: true, handleAs: "json"}).then( function(data) { - // TODO why query *?? - //grid.setQuery({id: "*"}); + success = true; grid.selection.deselectAll(); - updater.update(); + if (updater) + { + updater.update(); + } }, function(error) {success = false; failureReason = error;}); if(!success ) @@ -134,6 +135,7 @@ define(["dojo/_base/xhr", } } } + return success; } util.isProviderManagingUsers = function(type) diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js index b83c1e477b..735a657c61 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js @@ -22,15 +22,18 @@ define([ "dojo/_base/declare", "dojo/_base/xhr", "dojo/_base/event", + "dojo/_base/connect", "dojo/dom", "dojo/dom-construct", "dojo/parser", - "dojo/query", "dojo/json", + "dojo/store/Memory", + "dojo/data/ObjectStore", "dojox/html/entities", "dijit/registry", "qpid/common/TimeZoneSelector", "dojo/text!../../showPreferences.html", + "qpid/common/util", "dijit/Dialog", "dijit/form/NumberSpinner", "dijit/form/CheckBox", @@ -40,10 +43,13 @@ define([ "dijit/form/DropDownButton", "dijit/form/Button", "dijit/form/Form", + "dijit/layout/TabContainer", + "dijit/layout/ContentPane", + "dojox/grid/EnhancedGrid", "dojox/validate/us", "dojox/validate/web", "dojo/domReady!"], -function (declare, xhr, event, dom, domConstruct, parser, query, json, entities, registry, TimeZoneSelector, markup) { +function (declare, xhr, event, connect, dom, domConstruct, parser, json, Memory, ObjectStore, entities, registry, TimeZoneSelector, markup, util) { var preferenceNames = ["timeZone", "updatePeriod", "saveTabs"]; @@ -58,25 +64,39 @@ function (declare, xhr, event, dom, domConstruct, parser, query, json, entities, var that = this; this.domNode = domConstruct.create("div", {innerHTML: markup}); - parser.parse(this.domNode); + this.preferencesDialog = parser.parse(this.domNode)[0]; for(var i=0; i<preferenceNames.length; i++) { var name = preferenceNames[i]; - this[name] = registry.byNode(query("." + name, this.domNode)[0]); + this[name] = registry.byId("preferences." + name); } - 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.saveButton = registry.byId("preferences.saveButton"); + this.cancelButton = registry.byId("preferences.cancelButton"); + this.theForm = registry.byId("preferences.preferencesForm"); + this.users = registry.byId("preferences.users"); + this.users.set("structure", [ { name: "User", field: "name", width: "50%"}, + { name: "Authentication Provider", field: "authenticationProvider", width: "50%"}]); this.cancelButton.on("click", function(){that.preferencesDialog.hide();}); + this.deletePreferencesButton = registry.byId("preferences.deletePreeferencesButton"); + this.deletePreferencesButton.on("click", function(){ + if (util.deleteGridSelections( + null, + that.users, + "rest/userpreferences", + "Are you sure you want to delete preferences for user", + "user")) + { + that._updateUsersWithPreferences(); + } + }); + var deletePreferencesButtonToggler = function(rowIndex){ + var data = that.users.selection.getSelected(); + that.deletePreferencesButton.set("disabled",!data.length ); + }; + connect.connect(this.users.selection, 'onSelected', deletePreferencesButtonToggler); + connect.connect(this.users.selection, 'onDeselected', deletePreferencesButtonToggler); this.theForm.on("submit", function(e){ event.stop(e); if(that.theForm.validate()){ @@ -120,18 +140,8 @@ function (declare, xhr, event, dom, domConstruct, parser, query, json, entities, sync: true, handleAs: "json", load: 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._updatePreferencesWidgets(data); + that._updateUsersWithPreferences(); that.preferencesDialog.show(); }, error: function(error){ @@ -147,6 +157,48 @@ function (declare, xhr, event, dom, domConstruct, parser, query, json, entities, this.preferencesDialog.destroyRecursevly(); this.preferencesDialog = null; } + }, + + _updatePreferencesWidgets: function(data) + { + for(var i=0; i<preferenceNames.length; i++) + { + var preference = preferenceNames[i]; + if (this.hasOwnProperty(preference)) + { + var value = data ? data[preference] : null; + if (typeof value == "string") + { + value = entities.encode(String(value)) + } + this[preference].set("value", value); + } + } + }, + + _updateUsersWithPreferences: function() + { + var that = this; + xhr.get({ + url: "rest/userpreferences", + sync: false, + handleAs: "json" + }).then( + function(users) { + for(var i=0; i<users.length; i++) + { + users[i].id = users[i].authenticationProvider + "/" + users[i].name; + } + var usersStore = new Memory({data: users, idProperty: "id"}); + var usersDataStore = new ObjectStore({objectStore: usersStore}); + if (that.users.store) + { + that.users.store.close(); + } + that.users.set("store", usersDataStore); + that.users._refresh(); + }); } + }); });
\ No newline at end of file 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 48997096db..ede111272a 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 @@ -18,18 +18,20 @@ - under the License. - --> -<div> - <form method="post" data-dojo-type="dijit/form/Form" id="preferencesForm"> - <table cellpadding="0" cellspacing="2"> +<div data-dojo-type="dijit/Dialog" data-dojo-props="title:'Preferences'" id="preferences.preferencesDialog"> + <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;"> <tr> <td><strong>Time zone: </strong></td> <td> - <span class="timeZone" data-dojo-type="qpid/common/TimeZoneSelector" data-dojo-props="name: 'timeZone'"></span> + <span id="preferences.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=" + <td><input id="preferences.updatePeriod" name="updatePeriod" data-dojo-type="dijit/form/NumberSpinner" data-dojo-props=" invalidMessage: 'Invalid value', required: false, smallDelta: 1, @@ -40,12 +42,42 @@ </tr> <tr> <td><strong>Save tabs:</strong></td> - <td><input class="saveTabs" type="checkbox" data-dojo-type="dijit/form/CheckBox" name="saveTabs"/></td> + <td><input id="preferences.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> + <input type="submit" value="Save Preferences" data-dojo-type="dijit/form/Button" data-dojo-props="label: 'Save Preferences'" id="preferences.saveButton"/> + <button value="Cancel" data-dojo-type="dijit/form/Button" data-dojo-props="label: 'Cancel'" id="preferences.cancelButton"></button> </div> - </form> + </form> + </div> + <div data-dojo-type="dijit/layout/ContentPane" title="Users with Preferences" id="preferences.usersTab"> + <table id="preferences.users" data-dojo-type="dojox/grid/EnhancedGrid" data-dojo-props=" + label:'Trust Stores:', + plugins:{ + indirectSelection: true, + pagination: { + pageSizes: [10, 25, 50, 100], + description: true, + sizeSwitch: true, + pageStepper: true, + gotoButton: true, + maxPageStep: 4, + position: 'bottom' + } + }, + rowSelector:'0px' + " style="height: 300px;"> + <thead> + <tr> + <th field="name" style="width:50%">User</th> + <th field="authenticationProvider" style="width:50%">Authentication Provider</th> + </tr> + </thead> + </table> + <div class="dijitDialogPaneActionBar"> + <button id="preferences.deletePreeferencesButton" data-dojo-type="dijit/form/Button" data-dojo-props="label:'Delete Preferences', title:'Delete preferences for selected users'">Delete Preferences</button> + </div> + </div> + </div> </div> |
