Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js?rev=1741609&r1=1741608&r2=1741609&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js Fri Apr 29 11:04:40 2016 @@ -34,112 +34,132 @@ define(["dojo/parser", "dojox/grid/EnhancedGrid", "dojo/text!showVirtualHostNode.html", "dojo/domReady!"], - function (parser, query, connect, registry, entities, properties, updater, util, formatter, UpdatableStore, addQueue, addExchange, editVirtualHostNode, EnhancedGrid, template) { + function (parser, query, connect, registry, entities, properties, updater, util, formatter, UpdatableStore, addQueue, addExchange, editVirtualHostNode, EnhancedGrid, template) + { function VirtualHostNode(name, parent, controller) { this.name = name; this.controller = controller; this.management = controller.management; - this.modelObj = { type: "virtualhostnode", name: name, parent: parent}; + this.modelObj = { + type: "virtualhostnode", + name: name, + parent: parent + }; } - VirtualHostNode.prototype.getTitle = function() + VirtualHostNode.prototype.getTitle = function () { return "VirtualHostNode: " + this.name; }; - VirtualHostNode.prototype.open = function(contentPane) + VirtualHostNode.prototype.open = function (contentPane) { var that = this; this.contentPane = contentPane; contentPane.containerNode.innerHTML = template; - parser.parse(contentPane.containerNode).then(function(instances) - { - that.onOpen(contentPane.containerNode) - }); + parser.parse(contentPane.containerNode).then(function (instances) + { + that.onOpen(contentPane.containerNode) + }); }; - VirtualHostNode.prototype.onOpen = function(containerNode) + VirtualHostNode.prototype.onOpen = function (containerNode) { - var that = this; - this.stopNodeButton = registry.byNode(query(".stopNodeButton", containerNode)[0]); - this.startNodeButton = registry.byNode(query(".startNodeButton", containerNode)[0]); - this.editNodeButton = registry.byNode(query(".editNodeButton", containerNode)[0]); - this.deleteNodeButton = registry.byNode(query(".deleteNodeButton", containerNode)[0]); - this.virtualHostGridPanel = registry.byNode(query(".virtualHostGridPanel", containerNode)[0]); - this.deleteNodeButton.on("click", - function(e) - { + var that = this; + this.stopNodeButton = registry.byNode(query(".stopNodeButton", containerNode)[0]); + this.startNodeButton = registry.byNode(query(".startNodeButton", containerNode)[0]); + this.editNodeButton = registry.byNode(query(".editNodeButton", containerNode)[0]); + this.deleteNodeButton = registry.byNode(query(".deleteNodeButton", containerNode)[0]); + this.virtualHostGridPanel = registry.byNode(query(".virtualHostGridPanel", containerNode)[0]); + this.deleteNodeButton.on("click", function (e) + { if (confirm("Deletion of virtual host node will delete both configuration and message data.\n\n" - + "Are you sure you want to delete virtual host node '" + entities.encode(String(that.name)) + "'?")) + + "Are you sure you want to delete virtual host node '" + + entities.encode(String(that.name)) + "'?")) { - that.management.remove(that.modelObj).then( - function(x){that.destroy();}, util.xhrErrorHandler); + that.management.remove(that.modelObj).then(function (x) + { + that.destroy(); + }, util.xhrErrorHandler); } - } - ); - this.startNodeButton.on("click", - function(event) + }); + this.startNodeButton.on("click", function (event) { - that.startNodeButton.set("disabled", true); - that.management.update(that.modelObj, {desiredState: "ACTIVE"}).then(); + that.startNodeButton.set("disabled", true); + that.management.update(that.modelObj, {desiredState: "ACTIVE"}).then(); }); - this.stopNodeButton.on("click", - function(event) + this.stopNodeButton.on("click", function (event) { - if (confirm("Stopping the node will also shutdown the virtual host. " - + "Are you sure you want to stop virtual host node '" - + entities.encode(String(that.name)) +"'?")) - { - that.stopNodeButton.set("disabled", true); - that.management.update(that.modelObj, {desiredState: "STOPPED"}).then(); - } + if (confirm("Stopping the node will also shutdown the virtual host. " + + "Are you sure you want to stop virtual host node '" + + entities.encode(String(that.name)) + "'?")) + { + that.stopNodeButton.set("disabled", true); + that.management.update(that.modelObj, {desiredState: "STOPPED"}).then(); + } }); - this.editNodeButton.on("click", - function(event) - { - editVirtualHostNode.show(management, that.modelObj, that.vhostNodeUpdater.nodeData); - } - ); - - this.vhostsGrid = new UpdatableStore([], query(".virtualHost", containerNode)[0], - [ - { name: "Name", field: "name", width: "40%"}, - { name: "State", field: "state", width: "30%"}, - { name: "Type", field: "type", width: "30%"} - ], function(obj) { - connect.connect(obj.grid, "onRowDblClick", obj.grid, - function(evt){ - var idx = evt.rowIndex, - theItem = this.getItem(idx); - that.showVirtualHost(theItem); - }); - }, {height: 200, canSort : function(col) {return false;} }, EnhancedGrid); - - this.vhostNodeUpdater = new Updater(this); - this.vhostNodeUpdater.update(function(x){updater.add( that.vhostNodeUpdater );}); + this.editNodeButton.on("click", function (event) + { + editVirtualHostNode.show(management, that.modelObj, that.vhostNodeUpdater.nodeData); + }); + + this.vhostsGrid = new UpdatableStore([], query(".virtualHost", containerNode)[0], [{ + name: "Name", + field: "name", + width: "40%" + }, + { + name: "State", + field: "state", + width: "30%" + }, + { + name: "Type", + field: "type", + width: "30%" + }], function (obj) + { + connect.connect(obj.grid, "onRowDblClick", obj.grid, function (evt) + { + var idx = evt.rowIndex, theItem = this.getItem(idx); + that.showVirtualHost(theItem); + }); + }, { + height: 200, + canSort: function (col) + { + return false; + } + }, EnhancedGrid); + + this.vhostNodeUpdater = new Updater(this); + this.vhostNodeUpdater.update(function (x) + { + updater.add(that.vhostNodeUpdater); + }); } - VirtualHostNode.prototype.showVirtualHost=function(item) + VirtualHostNode.prototype.showVirtualHost = function (item) { - this.controller.show("virtualhost", item.name, this.modelObj, item.id); + this.controller.show("virtualhost", item.name, this.modelObj, item.id); } - VirtualHostNode.prototype.close = function() + VirtualHostNode.prototype.close = function () { - updater.remove( this.vhostNodeUpdater ); + updater.remove(this.vhostNodeUpdater); }; - VirtualHostNode.prototype.destroy = function() + VirtualHostNode.prototype.destroy = function () { - this.close(); - this.contentPane.onClose() - this.controller.tabContainer.removeChild(this.contentPane); - this.contentPane.destroyRecursive(); + this.close(); + this.contentPane.onClose() + this.controller.tabContainer.removeChild(this.contentPane); + this.contentPane.destroyRecursive(); } function Updater(virtualHostNode) @@ -156,7 +176,7 @@ define(["dojo/parser", function storeNodes(names) { - for(var i = 0; i < names.length; i++) + for (var i = 0; i < names.length; i++) { that[names[i]] = findNode(names[i]); } @@ -164,66 +184,67 @@ define(["dojo/parser", storeNodes(["name", "state", "type", "defaultVirtualHostNode"]); this.detailsDiv = findNode("virtualhostnodedetails"); - } + } - Updater.prototype.update = function(callback) + Updater.prototype.update = function (callback) { var that = this; - that.tabObject.management.load(this.modelObj).then( - function(data) - { - that.nodeData = data[0] || {}; - that.updateUI(that.nodeData); - - if (callback) - { - callback(); - } - }, - function(error) - { - util.tabErrorHandler(error,{updater:that, - contentPane: that.tabObject.contentPane, - tabContainer: that.tabObject.controller.tabContainer, - name: that.modelObj.name, - category: "Virtual Host Node"}); - }); + that.tabObject.management.load(this.modelObj).then(function (data) + { + that.nodeData = data[0] || {}; + that.updateUI(that.nodeData); + + if (callback) + { + callback(); + } + }, function (error) + { + util.tabErrorHandler(error, { + updater: that, + contentPane: that.tabObject.contentPane, + tabContainer: that.tabObject.controller.tabContainer, + name: that.modelObj.name, + category: "Virtual Host Node" + }); + }); }; - Updater.prototype.updateUI = function(data) + Updater.prototype.updateUI = function (data) { - function showBoolean(val) - { - return "<input type='checkbox' disabled='disabled' "+(val ? "checked='checked'": "")+" />" ; - } - - this.tabObject.startNodeButton.set("disabled", !(data.state == "STOPPED" || data.state == "ERRORED")); - this.tabObject.stopNodeButton.set("disabled", data.state != "ACTIVE"); - - this.name.innerHTML = entities.encode(String(data[ "name" ])); - this.state.innerHTML = entities.encode(String(data[ "state" ])); - this.type.innerHTML = entities.encode(String(data[ "type" ])); - this.defaultVirtualHostNode.innerHTML = showBoolean(data[ "defaultVirtualHostNode" ]); + function showBoolean(val) + { + return "<input type='checkbox' disabled='disabled' " + (val ? "checked='checked'" : "") + " />"; + } - if (!this.details) - { - var that = this; - require(["qpid/management/virtualhostnode/" + data.type.toLowerCase() + "/show"], - function(VirtualHostNodeDetails) - { - that.details = new VirtualHostNodeDetails({containerNode:that.detailsDiv, parent: that.tabObject}); - that.details.update(data); - } - ); - } - else - { - this.details.update(data); - } + this.tabObject.startNodeButton.set("disabled", !(data.state == "STOPPED" || data.state == "ERRORED")); + this.tabObject.stopNodeButton.set("disabled", data.state != "ACTIVE"); + + this.name.innerHTML = entities.encode(String(data["name"])); + this.state.innerHTML = entities.encode(String(data["state"])); + this.type.innerHTML = entities.encode(String(data["type"])); + this.defaultVirtualHostNode.innerHTML = showBoolean(data["defaultVirtualHostNode"]); + if (!this.details) + { + var that = this; + require(["qpid/management/virtualhostnode/" + data.type.toLowerCase() + "/show"], + function (VirtualHostNodeDetails) + { + that.details = new VirtualHostNodeDetails({ + containerNode: that.detailsDiv, + parent: that.tabObject + }); + that.details.update(data); + }); + } + else + { + this.details.update(data); + } - this.tabObject.virtualHostGridPanel.domNode.style.display = data.virtualhosts? "block" : "none"; - util.updateUpdatableStore(this.tabObject.vhostsGrid, data.virtualhosts); + this.tabObject.virtualHostGridPanel.domNode.style.display = data.virtualhosts ? "block" : "none"; + util.updateUpdatableStore(this.tabObject.vhostsGrid, data.virtualhosts); } return VirtualHostNode;
Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/AclFile.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/AclFile.js?rev=1741609&r1=1741608&r2=1741609&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/AclFile.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/AclFile.js Fri Apr 29 11:04:40 2016 @@ -36,74 +36,85 @@ define(["dojo/_base/xhr", "dojox/grid/EnhancedGrid", "dojox/grid/enhanced/plugins/Pagination", "dojox/grid/enhanced/plugins/IndirectSelection", - "dojox/validate/us", "dojox/validate/web", + "dojox/validate/us", + "dojox/validate/web", "dijit/Dialog", "dijit/form/TextBox", "dijit/form/ValidationTextBox", - "dijit/form/TimeTextBox", "dijit/form/Button", + "dijit/form/TimeTextBox", + "dijit/form/Button", "dijit/form/Form", "dijit/form/DateTextBox", "dojo/domReady!"], - function (xhr, dom, parser, query, construct, connect, win, event, json, registry, entities, util, properties, updater, UpdatableStore, EnhancedGrid) { - function AclFile(containerNode, aclProviderObj, controller, tabObject) { - var node = construct.create("div", null, containerNode, "last"); - this.modelObj = aclProviderObj; - var that = this; - this.name = aclProviderObj.name; - xhr.get({url: "accesscontrolprovider/showAclFile.html", - sync: true, - load: function(data) { - node.innerHTML = data; - parser.parse(node).then(function(instances) - { - that.groupDatabaseUpdater= new AclFileUpdater(node, tabObject); - - updater.add( that.groupDatabaseUpdater); - - that.groupDatabaseUpdater.update(); - }); - - }}); - } - - AclFile.prototype.close = function() { - updater.remove( this.groupDatabaseUpdater ); - }; - - function AclFileUpdater(node, tabObject) - { - this.tabObject = tabObject; - var aclProviderObj = tabObject.modelObj; - var controller = tabObject.controller; - this.controller = controller; - this.modelObj = aclProviderObj; - this.management = controller.management; - this.name = aclProviderObj.name; - this.path = query(".path", node)[0]; - } - - AclFileUpdater.prototype.update = function() - { - var that = this; - - this.management.load(this.modelObj) - .then(function(data) { - if (data[0]) - { - that.aclProviderData = data[0]; - that.path.innerHTML = entities.encode(String(that.aclProviderData.path)); - } - }, - function(error) - { - util.tabErrorHandler(error, {updater: that, - contentPane: that.tabObject.contentPane, - tabContainer: that.tabObject.controller.tabContainer, - name: that.modelObj.name, - category: "Access Control Provider"}); - }); + function (xhr, dom, parser, query, construct, connect, win, event, json, registry, entities, util, properties, updater, UpdatableStore, EnhancedGrid) + { + function AclFile(containerNode, aclProviderObj, controller, tabObject) + { + var node = construct.create("div", null, containerNode, "last"); + this.modelObj = aclProviderObj; + var that = this; + this.name = aclProviderObj.name; + xhr.get({ + url: "accesscontrolprovider/showAclFile.html", + sync: true, + load: function (data) + { + node.innerHTML = data; + parser.parse(node).then(function (instances) + { + that.groupDatabaseUpdater = + new AclFileUpdater(node, tabObject); + + updater.add(that.groupDatabaseUpdater); + + that.groupDatabaseUpdater.update(); + }); + + } + }); + } + + AclFile.prototype.close = function () + { + updater.remove(this.groupDatabaseUpdater); + }; + + function AclFileUpdater(node, tabObject) + { + this.tabObject = tabObject; + var aclProviderObj = tabObject.modelObj; + var controller = tabObject.controller; + this.controller = controller; + this.modelObj = aclProviderObj; + this.management = controller.management; + this.name = aclProviderObj.name; + this.path = query(".path", node)[0]; + } + + AclFileUpdater.prototype.update = function () + { + var that = this; + + this.management.load(this.modelObj) + .then(function (data) + { + if (data[0]) + { + that.aclProviderData = data[0]; + that.path.innerHTML = entities.encode(String(that.aclProviderData.path)); + } + }, function (error) + { + util.tabErrorHandler(error, { + updater: that, + contentPane: that.tabObject.contentPane, + tabContainer: that.tabObject.controller.tabContainer, + name: that.modelObj.name, + category: "Access Control Provider" + }); + }); - }; + }; - return AclFile; - }); + return AclFile; + }); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/aclfile/add.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/aclfile/add.js?rev=1741609&r1=1741608&r2=1741609&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/aclfile/add.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/aclfile/add.js Fri Apr 29 11:04:40 2016 @@ -18,108 +18,124 @@ * under the License. * */ -define(["dojo/dom","dojo/query","dijit/registry","qpid/common/util"], - function (dom, query, registry, util) - { - var addACLFileAccessControlProvider = +define(["dojo/dom", "dojo/query", "dijit/registry", "qpid/common/util"], function (dom, query, registry, util) +{ + var addACLFileAccessControlProvider = { + init: function () { - init: function() - { - // Readers are HTML5 - this.reader = window.FileReader ? new FileReader() : undefined; - }, - show: function(data) - { - var that=this; - util.parseHtmlIntoDiv(data.containerNode, "accesscontrolprovider/aclfile/add.html", function(){that._postParse(data);}); - }, - _postParse: function(data) + // Readers are HTML5 + this.reader = window.FileReader ? new FileReader() : undefined; + }, + show: function (data) + { + var that = this; + util.parseHtmlIntoDiv(data.containerNode, "accesscontrolprovider/aclfile/add.html", function () { - var that=this; - this.aclServerPath = registry.byId("addAccessControlProvider.serverPath"); - this.aclUploadFields = dom.byId("addAccessControlProvider.uploadFields"); - this.aclSelectedFileContainer = dom.byId("addAccessControlProvider.selectedFile"); - this.aclSelectedFileStatusContainer = dom.byId("addAccessControlProvider.selectedFileStatus"); - this.aclFile = registry.byId("addAccessControlProvider.file"); - this.aclFileClearButton = registry.byId("addAccessControlProvider.fileClearButton"); - this.aclFileOldBrowserWarning = dom.byId("addAccessControlProvider.oldBrowserWarning"); + that._postParse(data); + }); + }, + _postParse: function (data) + { + var that = this; + this.aclServerPath = registry.byId("addAccessControlProvider.serverPath"); + this.aclUploadFields = dom.byId("addAccessControlProvider.uploadFields"); + this.aclSelectedFileContainer = dom.byId("addAccessControlProvider.selectedFile"); + this.aclSelectedFileStatusContainer = dom.byId("addAccessControlProvider.selectedFileStatus"); + this.aclFile = registry.byId("addAccessControlProvider.file"); + this.aclFileClearButton = registry.byId("addAccessControlProvider.fileClearButton"); + this.aclFileOldBrowserWarning = dom.byId("addAccessControlProvider.oldBrowserWarning"); - //Only submitted field - this.aclPath = registry.byId("addAccessControlProvider.path"); + //Only submitted field + this.aclPath = registry.byId("addAccessControlProvider.path"); - this.addButton = data.parent.addButton; + this.addButton = data.parent.addButton; - if (this.reader) + if (this.reader) + { + this.reader.onload = function (evt) + { + that._aclUploadFileComplete(evt); + }; + this.reader.onerror = function (ex) + { + console.error("Failed to load ACL file", ex); + }; + this.aclFile.on("change", function (selected) { - this.reader.onload = function(evt) {that._aclUploadFileComplete(evt);}; - this.reader.onerror = function(ex) {console.error("Failed to load ACL file", ex);}; - this.aclFile.on("change", function(selected){that._aclFileChanged(selected)}); - this.aclFileClearButton.on("click", function(event){that._aclFileClearButtonClicked(event)}); - } - else + that._aclFileChanged(selected) + }); + this.aclFileClearButton.on("click", function (event) { - // Fall back for IE8/9 which do not support FileReader - this.aclUploadFields.style.display = "none"; - this.aclFileOldBrowserWarning.innerHTML = "File upload requires a more recent browser with HTML5 support"; - this.aclFileOldBrowserWarning.className = this.aclFileOldBrowserWarning.className.replace("hidden", ""); - } - - this.aclServerPath.on("blur", function(){that._aclServerPathChanged()}); - }, - _aclFileChanged: function (evt) + that._aclFileClearButtonClicked(event) + }); + } + else { - // We only ever expect a single file - var file = this.aclFile.domNode.children[0].files[0]; + // Fall back for IE8/9 which do not support FileReader + this.aclUploadFields.style.display = "none"; + this.aclFileOldBrowserWarning.innerHTML = + "File upload requires a more recent browser with HTML5 support"; + this.aclFileOldBrowserWarning.className = this.aclFileOldBrowserWarning.className.replace("hidden", ""); + } - this.addButton.setDisabled(true); - this.aclSelectedFileContainer.innerHTML = file.name; - this.aclSelectedFileStatusContainer.className = "loadingIcon"; - - console.log("Beginning to read ACL file " + file.name); - this.reader.readAsDataURL(file); - }, - _aclUploadFileComplete: function(evt) + this.aclServerPath.on("blur", function () { - var reader = evt.target; - var result = reader.result; - console.log("ACL file read complete, contents " + result); - this.addButton.setDisabled(false); - this.aclSelectedFileStatusContainer.className = "loadedIcon"; - - this.aclServerPath.set("value", ""); - this.aclServerPath.setDisabled(true); - this.aclServerPath.set("required", false); - - this.aclFileClearButton.setDisabled(false); - - this.aclPath.set("value", result); - }, - _aclFileClearButtonClicked: function(event) - { - this.aclFile.reset(); - this.aclSelectedFileStatusContainer.className = ""; - this.aclSelectedFileContainer.innerHTML = ""; - this.aclServerPath.set("required", true); - this.aclServerPath.setDisabled(false); - this.aclFileClearButton.setDisabled(true); - - this.aclPath.set("value", ""); - }, - _aclServerPathChanged: function() - { - var serverPathValue = this.aclServerPath.get("value"); - this.aclPath.set("value", serverPathValue); - } - }; + that._aclServerPathChanged() + }); + }, + _aclFileChanged: function (evt) + { + // We only ever expect a single file + var file = this.aclFile.domNode.children[0].files[0]; - try + this.addButton.setDisabled(true); + this.aclSelectedFileContainer.innerHTML = file.name; + this.aclSelectedFileStatusContainer.className = "loadingIcon"; + + console.log("Beginning to read ACL file " + file.name); + this.reader.readAsDataURL(file); + }, + _aclUploadFileComplete: function (evt) { - addACLFileAccessControlProvider.init(); - } - catch(e) + var reader = evt.target; + var result = reader.result; + console.log("ACL file read complete, contents " + result); + this.addButton.setDisabled(false); + this.aclSelectedFileStatusContainer.className = "loadedIcon"; + + this.aclServerPath.set("value", ""); + this.aclServerPath.setDisabled(true); + this.aclServerPath.set("required", false); + + this.aclFileClearButton.setDisabled(false); + + this.aclPath.set("value", result); + }, + _aclFileClearButtonClicked: function (event) { - console.warn(e); + this.aclFile.reset(); + this.aclSelectedFileStatusContainer.className = ""; + this.aclSelectedFileContainer.innerHTML = ""; + this.aclServerPath.set("required", true); + this.aclServerPath.setDisabled(false); + this.aclFileClearButton.setDisabled(true); + + this.aclPath.set("value", ""); + }, + _aclServerPathChanged: function () + { + var serverPathValue = this.aclServerPath.get("value"); + this.aclPath.set("value", serverPathValue); } - return addACLFileAccessControlProvider; + }; + + try + { + addACLFileAccessControlProvider.init(); + } + catch (e) + { + console.warn(e); } -); + return addACLFileAccessControlProvider; +}); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAccessControlProvider.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAccessControlProvider.js?rev=1741609&r1=1741608&r2=1741609&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAccessControlProvider.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAccessControlProvider.js Fri Apr 29 11:04:40 2016 @@ -41,110 +41,140 @@ define(["dojo/_base/lang", "dijit/form/Form", "dijit/layout/ContentPane", "dojox/layout/TableContainer", - "dojo/domReady!"], - function (lang, dom, construct, registry, parser, array, event, json, util, template) - { + "dojo/domReady!"], function (lang, dom, construct, registry, parser, array, event, json, util, template) + { - var addAccessControlProvider = - { - init: function() - { - var that=this; - this.containerNode = construct.create("div", {innerHTML: template}); - parser.parse(this.containerNode).then(function(instances){ that._postParse(); }); - }, - _postParse: function() - { - var that=this; - this.accessControlProviderName = registry.byId("addAccessControlProvider.name"); - this.accessControlProviderName.set("regExpGen", util.nameOrContextVarRegexp); + var addAccessControlProvider = { + init: function () + { + var that = this; + this.containerNode = construct.create("div", {innerHTML: template}); + parser.parse(this.containerNode).then(function (instances) + { + that._postParse(); + }); + }, + _postParse: function () + { + var that = this; + this.accessControlProviderName = registry.byId("addAccessControlProvider.name"); + this.accessControlProviderName.set("regExpGen", util.nameOrContextVarRegexp); - this.dialog = registry.byId("addAccessControlProvider"); - this.addButton = registry.byId("addAccessControlProvider.addButton"); - this.cancelButton = registry.byId("addAccessControlProvider.cancelButton"); - this.cancelButton.on("click", function(e){that._cancel(e);}); - this.addButton.on("click", function(e){that._add(e);}); + this.dialog = registry.byId("addAccessControlProvider"); + this.addButton = registry.byId("addAccessControlProvider.addButton"); + this.cancelButton = registry.byId("addAccessControlProvider.cancelButton"); + this.cancelButton.on("click", function (e) + { + that._cancel(e); + }); + this.addButton.on("click", function (e) + { + that._add(e); + }); - this.accessControlProviderTypeFieldsContainer = dom.byId("addAccessControlProvider.typeFields"); - this.accessControlProviderForm = registry.byId("addAccessControlProvider.form"); - this.accessControlProviderType = registry.byId("addAccessControlProvider.type"); - this.accessControlProviderType.on("change", function(type){that._accessControlProviderTypeChanged(type);}); - }, - show: function(management, modelObj, effectiveData) - { - this.management = management; - this.modelObj = modelObj; - this.accessControlProviderForm.reset(); - this.supportedAccessControlProviderTypes = management.metadata.getTypesForCategory("AccessControlProvider"); - this.supportedAccessControlProviderTypes.sort(); - var accessControlProviderTypeStore = util.makeTypeStore(this.supportedAccessControlProviderTypes); - this.accessControlProviderType.set("store", accessControlProviderTypeStore); - this.dialog.show(); - }, - _cancel: function(e) - { - event.stop(e); - this._destroyTypeFields(this.accessControlProviderTypeFieldsContainer); - this.dialog.hide(); - }, - _add: function(e) - { - event.stop(e); - this._submit(); - }, - _submit: function() - { - if (this.accessControlProviderForm.validate()) - { - var accessControlProviderData = util.getFormWidgetValues(this.accessControlProviderForm, this.initialData); - var that = this; - this.management.create("accesscontrolprovider", this.modelObj, accessControlProviderData).then(function(x){that.dialog.hide();}); - } - else - { - alert('Form contains invalid data. Please correct first'); - } - }, - _accessControlProviderTypeChanged: function(type) - { - this._typeChanged(type, this.accessControlProviderTypeFieldsContainer, "qpid/management/accesscontrolprovider/", "AccessControlProvider" ); - }, - _destroyTypeFields: function(typeFieldsContainer) - { - var widgets = registry.findWidgets(typeFieldsContainer); - array.forEach(widgets, function(item) { item.destroyRecursive();}); - construct.empty(typeFieldsContainer); - }, - _typeChanged: function(type, typeFieldsContainer, baseUrl, category ) - { - this._destroyTypeFields(typeFieldsContainer); + this.accessControlProviderTypeFieldsContainer = dom.byId("addAccessControlProvider.typeFields"); + this.accessControlProviderForm = registry.byId("addAccessControlProvider.form"); + this.accessControlProviderType = registry.byId("addAccessControlProvider.type"); + this.accessControlProviderType.on("change", function (type) + { + that._accessControlProviderTypeChanged(type); + }); + }, + show: function (management, modelObj, effectiveData) + { + this.management = management; + this.modelObj = modelObj; + this.accessControlProviderForm.reset(); + this.supportedAccessControlProviderTypes = + management.metadata.getTypesForCategory("AccessControlProvider"); + this.supportedAccessControlProviderTypes.sort(); + var accessControlProviderTypeStore = util.makeTypeStore(this.supportedAccessControlProviderTypes); + this.accessControlProviderType.set("store", accessControlProviderTypeStore); + this.dialog.show(); + }, + _cancel: function (e) + { + event.stop(e); + this._destroyTypeFields(this.accessControlProviderTypeFieldsContainer); + this.dialog.hide(); + }, + _add: function (e) + { + event.stop(e); + this._submit(); + }, + _submit: function () + { + if (this.accessControlProviderForm.validate()) + { + var accessControlProviderData = util.getFormWidgetValues(this.accessControlProviderForm, + this.initialData); + var that = this; + this.management.create("accesscontrolprovider", this.modelObj, accessControlProviderData) + .then(function (x) + { + that.dialog.hide(); + }); + } + else + { + alert('Form contains invalid data. Please correct first'); + } + }, + _accessControlProviderTypeChanged: function (type) + { + this._typeChanged(type, + this.accessControlProviderTypeFieldsContainer, + "qpid/management/accesscontrolprovider/", + "AccessControlProvider"); + }, + _destroyTypeFields: function (typeFieldsContainer) + { + var widgets = registry.findWidgets(typeFieldsContainer); + array.forEach(widgets, function (item) + { + item.destroyRecursive(); + }); + construct.empty(typeFieldsContainer); + }, + _typeChanged: function (type, typeFieldsContainer, baseUrl, category) + { + this._destroyTypeFields(typeFieldsContainer); - if (type) - { - var that = this; - require([ baseUrl + type.toLowerCase() + "/add"], function(typeUI) - { - try - { - typeUI.show({containerNode:typeFieldsContainer, parent: that, data: that.initialData, effectiveData: that.effectiveData}); - util.applyMetadataToWidgets(typeFieldsContainer, category, type, that.management.metadata); - } - catch(e) - { - console.warn(e); - } - }); - } - } - }; + if (type) + { + var that = this; + require([baseUrl + type.toLowerCase() + "/add"], function (typeUI) + { + try + { + typeUI.show({ + containerNode: typeFieldsContainer, + parent: that, + data: that.initialData, + effectiveData: that.effectiveData + }); + util.applyMetadataToWidgets(typeFieldsContainer, + category, + type, + that.management.metadata); + } + catch (e) + { + console.warn(e); + } + }); + } + } + }; - try - { - addAccessControlProvider.init(); - } - catch(e) - { - console.warn(e); - } - return addAccessControlProvider; - }); + try + { + addAccessControlProvider.init(); + } + catch (e) + { + console.warn(e); + } + return addAccessControlProvider; + }); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js?rev=1741609&r1=1741608&r2=1741609&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js Fri Apr 29 11:04:40 2016 @@ -33,229 +33,292 @@ define(["dojo/dom", "qpid/common/util", "dojo/text!addAuthenticationProvider.html", "qpid/management/preferencesprovider/PreferencesProviderForm", - /* dojox/ validate resources */ - "dojox/validate/us", "dojox/validate/web", - /* basic dijit classes */ + /* dojox/ validate resources */ + "dojox/validate/us", + "dojox/validate/web", + /* basic dijit classes */ "dijit/Dialog", - "dijit/form/CheckBox", "dijit/form/Textarea", + "dijit/form/CheckBox", + "dijit/form/Textarea", "dijit/form/TextBox", "dijit/form/ValidationTextBox", "dijit/form/Button", "dijit/form/Form", - /* basic dojox classes */ - "dojox/form/BusyButton", "dojox/form/CheckedMultiSelect", + /* basic dojox classes */ + "dojox/form/BusyButton", + "dojox/form/CheckedMultiSelect", "dojox/layout/TableContainer", "qpid/common/ContextVariablesEditor", "dojo/domReady!"], - function (dom, construct, win, registry, parser, array, event, json, Memory, FilteringSelect, connect, domStyle, util, template) - { - var addAuthenticationProvider = - { - init:function() - { - var that=this; - this.containerNode = construct.create("div", {innerHTML: template}); - parser.parse(this.containerNode).then(function(instances) { that._postParse(); }); - }, - _postParse: function() - { - var that = this; - this.authenticationProviderName = registry.byId("addAuthenticationProvider.name"); - this.authenticationProviderName.set("regExpGen", util.nameOrContextVarRegexp); - this.authenticationProviderName.on("change", function(newValue){ - that.preferencesProviderForm.setPreferencesProviderName(newValue); - }); - - this.dialog = registry.byId("addAuthenticationProvider"); - this.addButton = registry.byId("addAuthenticationProvider.addButton"); - this.cancelButton = registry.byId("addAuthenticationProvider.cancelButton"); - this.cancelButton.on("click", function(e){that._cancel(e);}); - this.addButton.on("click", function(e){that._add(e);}); - - this.authenticationProviderTypeFieldsContainer = dom.byId("addAuthenticationProvider.typeFields"); - this.authenticationProviderForm = registry.byId("addAuthenticationProvider.form"); - this.authenticationProviderType = registry.byId("addAuthenticationProvider.type"); - this.authenticationProviderType.on("change", function(type){that._authenticationProviderTypeChanged(type);}); - - this.preferencesProviderForm = new qpid.preferencesprovider.PreferencesProviderForm({disabled: true}); - this.preferencesProviderForm.placeAt(dom.byId("addPreferencesProvider.form")); - this.context = registry.byId("addAuthenticationProvider.context"); - }, - show:function(management, modelObj, effectiveData) - { - this.management = management; - this.modelObj = modelObj; - this.authenticationProviderForm.reset(); - this.preferencesProviderForm.setMetadata(management.metadata); - - this.supportedAuthenticationProviderTypes = management.metadata.getTypesForCategory("AuthenticationProvider"); - this.supportedAuthenticationProviderTypes.sort(); - var authenticationProviderTypeStore = util.makeTypeStore(this.supportedAuthenticationProviderTypes); - this.authenticationProviderType.set("store", authenticationProviderTypeStore); - - var that = this; - if (effectiveData) - { - // editing - management.load(modelObj, { actuals: true }).then( - function(data) - { - var actualData = data[0]; - that.initialData = actualData; - that.effectiveData = effectiveData; - that.authenticationProviderType.set("value", actualData.type); - - that.authenticationProviderType.set("disabled", true); - that.authenticationProviderName.set("disabled", true); - if (actualData.preferencesproviders && actualData.preferencesproviders[0]) - { - that.preferencesProviderForm.setData(actualData.preferencesproviders[0]); - } - else - { - that.preferencesProviderForm.reset(); - that.preferencesProviderForm.setPreferencesProviderName(actualData.name); - } - that.authenticationProviderName.set("value", actualData.name); - util.setContextData(that.context, - management, - modelObj, - actualData, - effectiveData, - function(){that._show();}); - }); - } - else - { - this.preferencesProviderForm.reset(); - this.authenticationProviderType.set("disabled", false); - this.authenticationProviderName.set("disabled", false); - this.initialData = {}; - this.effectiveData = {}; - util.setToBrokerEffectiveContext(this.context, management, function(){that._show();}); - } - }, - _show: function() - { - this.dialog.show(); - if (!this.resizeEventRegistered) - { - this.resizeEventRegistered = true; - util.resizeContentAreaAndRepositionDialog(dom.byId("addAuthenticationProvider.contentPane"), this.dialog); - } - }, - _cancel: function(e) - { - event.stop(e); - this.dialog.hide(); - }, - _add: function(e) - { - event.stop(e); - this._submit(); - }, - _submit: function() - { - if(this.authenticationProviderForm.validate() && this.preferencesProviderForm.validate()) - { - var authenticationProviderData = util.getFormWidgetValues(this.authenticationProviderForm, this.initialData); - var context = this.context.get("value"); - if (context && (!this.initialData || !util.equals(context, this.initialData.context))) - { - authenticationProviderData["context"] = context; - } - var that = this; - - var hideDialog = function(x) - { - that.dialog.hide(); - } - - var savePreferences = function(x) - { - that.preferencesProviderForm.submit( - function(preferencesProviderData) - { - if (that.preferencesProviderForm.data) - { - // update request - var name = that.preferencesProviderForm.getPreferencesProviderName(); - - var modelObj = {name: name, type: "preferencesprovider", parent: that.modelObj}; - that.management.update(modelObj, preferencesProviderData).then(hideDialog); - } - else - { - var authProviderModelObj = that.modelObj; - if (authProviderModelObj.type != "authenticationprovider") - { - authProviderModelObj = { name: authenticationProviderData.name, type: "authenticationprovider", parent: that.modelObj}; - } - that.management.create("preferencesprovider", authProviderModelObj, preferencesProviderData).then(hideDialog); - } - }, - hideDialog - ); - } - - if (this.initialData && this.initialData.id) - { - // update request - this.management.update(that.modelObj, authenticationProviderData).then(savePreferences); - } - else - { - this.management.create("authenticationprovider", that.modelObj, authenticationProviderData).then(savePreferences); - } - } - else - { - alert('Form contains invalid data. Please correct first'); - } - }, - _authenticationProviderTypeChanged: function(type) - { - this._typeChanged(type, this.authenticationProviderTypeFieldsContainer, "qpid/management/authenticationprovider/", "AuthenticationProvider" ); - }, - _typeChanged: function(type, typeFieldsContainer, baseUrl, category ) - { - var widgets = registry.findWidgets(typeFieldsContainer); - array.forEach(widgets, function(item) { item.destroyRecursive();}); - construct.empty(typeFieldsContainer); - var supportsPreferencesProvider = false; - if (type && this.management) - { - supportsPreferencesProvider = this.management.metadata.implementsManagedInterface("AuthenticationProvider", type, "PreferencesSupportingAuthenticationProvider"); - } - this.preferencesProviderForm.set("disabled", !type || !supportsPreferencesProvider); - if (type) - { - var that = this; - require([ baseUrl + type.toLowerCase() + "/add"], function(typeUI) - { - try - { - typeUI.show({containerNode:typeFieldsContainer, parent: that, category: category, type: type, data: that.initialData, effectiveData: that.effectiveData, metadata: that.management.metadata}); - util.applyMetadataToWidgets(typeFieldsContainer, category, type, that.management.metadata); - } - catch(e) - { - console.warn(e); - } - }); - } - } - }; - - try - { - addAuthenticationProvider.init(); - } - catch(e) - { - console.warn(e); - } - return addAuthenticationProvider; - } - -); + function (dom, construct, win, registry, parser, array, event, json, Memory, FilteringSelect, connect, domStyle, util, template) + { + var addAuthenticationProvider = { + init: function () + { + var that = this; + this.containerNode = construct.create("div", {innerHTML: template}); + parser.parse(this.containerNode).then(function (instances) + { + that._postParse(); + }); + }, + _postParse: function () + { + var that = this; + this.authenticationProviderName = registry.byId("addAuthenticationProvider.name"); + this.authenticationProviderName.set("regExpGen", util.nameOrContextVarRegexp); + this.authenticationProviderName.on("change", function (newValue) + { + that.preferencesProviderForm.setPreferencesProviderName(newValue); + }); + + this.dialog = registry.byId("addAuthenticationProvider"); + this.addButton = registry.byId("addAuthenticationProvider.addButton"); + this.cancelButton = registry.byId("addAuthenticationProvider.cancelButton"); + this.cancelButton.on("click", function (e) + { + that._cancel(e); + }); + this.addButton.on("click", function (e) + { + that._add(e); + }); + + this.authenticationProviderTypeFieldsContainer = dom.byId("addAuthenticationProvider.typeFields"); + this.authenticationProviderForm = registry.byId("addAuthenticationProvider.form"); + this.authenticationProviderType = registry.byId("addAuthenticationProvider.type"); + this.authenticationProviderType.on("change", function (type) + { + that._authenticationProviderTypeChanged(type); + }); + + this.preferencesProviderForm = + new qpid.preferencesprovider.PreferencesProviderForm({disabled: true}); + this.preferencesProviderForm.placeAt(dom.byId("addPreferencesProvider.form")); + this.context = registry.byId("addAuthenticationProvider.context"); + }, + show: function (management, modelObj, effectiveData) + { + this.management = management; + this.modelObj = modelObj; + this.authenticationProviderForm.reset(); + this.preferencesProviderForm.setMetadata(management.metadata); + + this.supportedAuthenticationProviderTypes = + management.metadata.getTypesForCategory("AuthenticationProvider"); + this.supportedAuthenticationProviderTypes.sort(); + var authenticationProviderTypeStore = util.makeTypeStore(this.supportedAuthenticationProviderTypes); + this.authenticationProviderType.set("store", authenticationProviderTypeStore); + + var that = this; + if (effectiveData) + { + // editing + management.load(modelObj, {actuals: true}).then(function (data) + { + var actualData = data[0]; + that.initialData = actualData; + that.effectiveData = effectiveData; + that.authenticationProviderType.set("value", + actualData.type); + + that.authenticationProviderType.set( + "disabled", + true); + that.authenticationProviderName.set( + "disabled", + true); + if (actualData.preferencesproviders + && actualData.preferencesproviders[0]) + { + that.preferencesProviderForm.setData( + actualData.preferencesproviders[0]); + } + else + { + that.preferencesProviderForm.reset(); + that.preferencesProviderForm.setPreferencesProviderName( + actualData.name); + } + that.authenticationProviderName.set("value", + actualData.name); + util.setContextData(that.context, + management, + modelObj, + actualData, + effectiveData, + function () + { + that._show(); + }); + }); + } + else + { + this.preferencesProviderForm.reset(); + this.authenticationProviderType.set("disabled", false); + this.authenticationProviderName.set("disabled", false); + this.initialData = {}; + this.effectiveData = {}; + util.setToBrokerEffectiveContext(this.context, management, function () + { + that._show(); + }); + } + }, + _show: function () + { + this.dialog.show(); + if (!this.resizeEventRegistered) + { + this.resizeEventRegistered = true; + util.resizeContentAreaAndRepositionDialog(dom.byId("addAuthenticationProvider.contentPane"), + this.dialog); + } + }, + _cancel: function (e) + { + event.stop(e); + this.dialog.hide(); + }, + _add: function (e) + { + event.stop(e); + this._submit(); + }, + _submit: function () + { + if (this.authenticationProviderForm.validate() && this.preferencesProviderForm.validate()) + { + var authenticationProviderData = util.getFormWidgetValues(this.authenticationProviderForm, + this.initialData); + var context = this.context.get("value"); + if (context && (!this.initialData || !util.equals(context, this.initialData.context))) + { + authenticationProviderData["context"] = context; + } + var that = this; + + var hideDialog = function (x) + { + that.dialog.hide(); + } + + var savePreferences = function (x) + { + that.preferencesProviderForm.submit(function (preferencesProviderData) + { + if (that.preferencesProviderForm.data) + { + // update request + var name = that.preferencesProviderForm.getPreferencesProviderName(); + + var modelObj = { + name: name, + type: "preferencesprovider", + parent: that.modelObj + }; + that.management.update(modelObj, + preferencesProviderData) + .then(hideDialog); + } + else + { + var authProviderModelObj = that.modelObj; + if (authProviderModelObj.type + != "authenticationprovider") + { + authProviderModelObj = { + name: authenticationProviderData.name, + type: "authenticationprovider", + parent: that.modelObj + }; + } + that.management.create("preferencesprovider", + authProviderModelObj, + preferencesProviderData) + .then(hideDialog); + } + }, hideDialog); + } + + if (this.initialData && this.initialData.id) + { + // update request + this.management.update(that.modelObj, authenticationProviderData).then(savePreferences); + } + else + { + this.management.create("authenticationprovider", that.modelObj, authenticationProviderData) + .then(savePreferences); + } + } + else + { + alert('Form contains invalid data. Please correct first'); + } + }, + _authenticationProviderTypeChanged: function (type) + { + this._typeChanged(type, + this.authenticationProviderTypeFieldsContainer, + "qpid/management/authenticationprovider/", + "AuthenticationProvider"); + }, + _typeChanged: function (type, typeFieldsContainer, baseUrl, category) + { + var widgets = registry.findWidgets(typeFieldsContainer); + array.forEach(widgets, function (item) + { + item.destroyRecursive(); + }); + construct.empty(typeFieldsContainer); + var supportsPreferencesProvider = false; + if (type && this.management) + { + supportsPreferencesProvider = this.management.metadata.implementsManagedInterface( + "AuthenticationProvider", + type, + "PreferencesSupportingAuthenticationProvider"); + } + this.preferencesProviderForm.set("disabled", !type || !supportsPreferencesProvider); + if (type) + { + var that = this; + require([baseUrl + type.toLowerCase() + "/add"], function (typeUI) + { + try + { + typeUI.show({ + containerNode: typeFieldsContainer, + parent: that, + category: category, + type: type, + data: that.initialData, + effectiveData: that.effectiveData, + metadata: that.management.metadata + }); + util.applyMetadataToWidgets(typeFieldsContainer, + category, + type, + that.management.metadata); + } + catch (e) + { + console.warn(e); + } + }); + } + } + }; + + try + { + addAuthenticationProvider.init(); + } + catch (e) + { + console.warn(e); + } + return addAuthenticationProvider; + }); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
