diff options
author | Alex Rudyy <orudyy@apache.org> | 2015-01-30 10:12:07 +0000 |
---|---|---|
committer | Alex Rudyy <orudyy@apache.org> | 2015-01-30 10:12:07 +0000 |
commit | b4d09a6ec40150e13ecb116c24a68150077a325a (patch) | |
tree | 3a0bf22ae36eed8c57527e07b0622372118fc520 /qpid | |
parent | 54b214dc8fd8087466cec5ee2dadaa60e797a49c (diff) | |
download | qpid-python-b4d09a6ec40150e13ecb116c24a68150077a325a.tar.gz |
QPID-6346: [Java Broker] Encapsulate duplicate UI for uploading of broker resources into widget and use the widget in keystores and truststore UI
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1655974 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid')
12 files changed, 371 insertions, 549 deletions
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/common/ResourceWidget.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/common/ResourceWidget.html new file mode 100644 index 0000000000..e47fa6ca6d --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/common/ResourceWidget.html @@ -0,0 +1,48 @@ +<!-- + - + - 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 class="dijit dijitReset dijitInline dijitLeft" id="widget_${id}" role="presentation"> + <input type="text" name="${name}_resourceLocation" + data-dojo-attach-point="resourceLocation,textbox,focusNode" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props="required:true,disabled:false"/> + + <div data-dojo-attach-point="uploadFields"> + <div data-dojo-attach-point="uploadData" style="width:auto;overflow:hidden;text-align:right"> + <span data-dojo-attach-point="selectedFile" class="infoMessage"></span> + <span data-dojo-attach-point="selectedFileStatus"></span> + </div> + <div style="text-align:right"> + <span data-dojo-attach-point="blah"></span> + <input name="${name}_uploadedFile" multiple="false" type="file" id="uploader_${id}" + data-dojo-attach-point="uploader" + data-dojo-type="dojox/form/Uploader" + data-dojo-props="label: 'Upload'"/> + <button data-dojo-attach-point="clearButton" data-dojo-type="dijit/form/Button" + data-dojo-props="label: 'Clear', disabled: true"/>Clear</button> + + </div> + <div class="clear"></div> + </div> + <div data-dojo-attach-point="unsupportedWarning" class="infoMessage hidden clear" style="overflow:scroll;"> + File upload requires a more recent browser with HTML5 support + </div> +</div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/FormWidgetMixin.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/FormWidgetMixin.js new file mode 100644 index 0000000000..11160e9608 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/FormWidgetMixin.js @@ -0,0 +1,102 @@ +/* + * + * 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"], function(declare) +{ + return declare("qpid.common.FormWidgetMixin", null, + { + name: "", + value: "", + _onChangeActive: false, + + compare: function(val1, val2) + { + if(typeof val1 == "number" && typeof val2 == "number") + { + return (isNaN(val1) && isNaN(val2)) ? 0 : val1 - val2; + } + else if(val1 > val2) + { + return 1; + } + else if(val1 < val2) + { + return -1; + } + else + { + return 0; + } + }, + onChange: function() + { + }, + _setValueAttr: function(newValue, priorityChange) + { + this._handleOnChange(newValue, priorityChange); + }, + _handleOnChange: function(newValue, priorityChange) + { + this._set("value", newValue); + if(this._lastValueReported == undefined && (priorityChange === null || !this._onChangeActive)) + { + this._resetValue = this._lastValueReported = newValue; + } + this._pendingOnChange = this._pendingOnChange || (typeof newValue != typeof this._lastValueReported) + || (this.compare(newValue, this._lastValueReported) != 0); + if(( priorityChange || priorityChange === undefined) && this._pendingOnChange) + { + this._lastValueReported = newValue; + this._pendingOnChange = false; + if(this._onChangeActive) + { + if(this._onChangeHandle) + { + this._onChangeHandle.remove(); + } + this._onChangeHandle = this.defer(function() { this._onChangeHandle = null; this.onChange(newValue); }); + } + } + }, + create: function() + { + this.inherited(arguments); + this._onChangeActive = true; + }, + destroy: function() + { + if(this._onChangeHandle) + { + this._onChangeHandle.remove(); + this.onChange(this._lastValueReported); + } + this.inherited(arguments); + }, + undo: function() + { + this._setValueAttr(this._lastValueReported, false); + }, + reset: function() + { + this._hasBeenBlurred = false; + this._setValueAttr(this._resetValue, true); + } + }); +});
\ No newline at end of file diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js new file mode 100644 index 0000000000..0082c7524f --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js @@ -0,0 +1,173 @@ +/* + * + * 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/_base/lang", + "qpid/common/util", + "dijit/_Widget", + "dijit/_TemplatedMixin", + "dijit/_WidgetsInTemplateMixin", + "qpid/common/FormWidgetMixin", + "dojo/text!common/ResourceWidget.html", + "dojox/html/entities", + "dojox/form/Uploader", + "dijit/form/Button", + "dijit/form/ValidationTextBox", + "dojox/validate/us", + "dojox/validate/web", + "dojo/domReady!"], +function (declare, array, lang, util, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, FormWidgetMixin, template, entities) +{ + + return declare("qpid.common.ResourceWidget", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, FormWidgetMixin], + { + templateString: template, + fileReaderSupported: window.FileReader ? true : false, + displayWarningWhenFileReaderUnsupported: false, + isDebug: false, + + buildRendering: function() + { + //Strip out the apache comment header from the template html as comments unsupported. + this.templateString = this.templateString.replace(/<!--[\s\S]*?-->/g, ""); + this.inherited(arguments); + }, + postCreate: function() + { + this.inherited(arguments); + + if(this._resetValue === undefined) + { + this._lastValueReported = this._resetValue = this.value; + } + + var that = this; + + if (this.fileReaderSupported) + { + this.fileReader= new FileReader(); + this.fileReader.onload = function(evt) {that._uploadFileComplete(evt);}; + this.fileReader.onerror = function(ex) {console.error("Failed to load file for " + this.name, ex);}; + this.uploader.on("change", function(selected){that._fileChanged(selected)}); + this.clearButton.on("click", function(event){that._fileClearButtonClicked(event)}); + } + else + { + // Fall back for IE8/9 which do not support FileReader + this.uploadFields.style.display = "none"; + if (displayWarningWhenFileReaderUnsupported) + { + this.unsupportedWarning.className = this.unsupportedWarning.className.replace("hidden", ""); + } + } + this.resourceLocation.on("blur", function(){that._pathChanged()}); + this._originalValue = arguments.value; + if (this.placeHolder) + { + this.resourceLocation.set("placeHolder", this.placeHolder); + } + if (this.promptMessage) + { + this.resourceLocation.set("promptMessage", this.promptMessage); + } + if (this.title) + { + this.resourceLocation.set("title", this.title); + } + this.uploadData.style.display = "none"; + }, + startup: function() + { + if (this.fileReaderSupported) + { + this.uploader.startup(); + } + }, + _fileChanged: function (evt) + { + var file = this.uploader.domNode.children[0].files[0]; + this.selectedFileName = file.name; + this.selectedFile.innerHTML = file.name; + this.selectedFileStatus.className = "loadingIcon"; + if (this.isDebug) + { + this._log("Beginning to read file " + file.name + " for " + this.name); + } + this.fileReader.readAsDataURL(file); + }, + _uploadFileComplete: function(evt) + { + var reader = evt.target; + var result = reader.result; + if (this.isDebug) + { + this._log(this.name + " file read complete, contents " + result); + } + this.set("value", result); + }, + _fileClearButtonClicked: function(event) + { + this.uploader.reset(); + this.set("value", this._resetValue); + }, + _pathChanged: function() + { + var serverPathValue = this.resourceLocation.get("value") || this._resetValue; + this.set("value", serverPathValue); + }, + _setValueAttr: function(newValue, priorityChange) + { + var isDataUrl = newValue && newValue.indexOf("data:") == 0; + if (isDataUrl) + { + this.uploadData.style.display = "block"; + this.selectedFileStatus.className = "loadedIcon"; + this.selectedFile.innerHTML = this.selectedFileName || "uploaded data"; + this.resourceLocation.set("value", ""); + this.resourceLocation.setDisabled(true); + this.resourceLocation.set("required", false); + this.clearButton.setDisabled(false); + this.selectedFileStatus.className = "loadedIcon"; + } + else + { + this.resourceLocation.set("value", newValue); + this.selectedFileName = null; + this.selectedFileStatus.className = ""; + this.selectedFile.innerHTML = ""; + this.resourceLocation.set("required", true); + this.resourceLocation.setDisabled(false); + this.clearButton.setDisabled(true); + this.uploadData.style.display = "none"; + } + this.inherited(arguments); + }, + _log: function(message) + { + if (this.isDebug) + { + console.log(message); + } + } + } + ); +}); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js index c6ce218530..5a42f12870 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js @@ -80,11 +80,11 @@ define(["dojo/_base/lang", }, show: function(effectiveData) { + this.effectiveData = effectiveData; this.storeForm.reset(); if (effectiveData) { - this.effectiveData = effectiveData; this._destroyTypeFields(this.containerNode); this._initFields(effectiveData); } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filekeystore/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filekeystore/add.js index b158b9e051..feb7da1864 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filekeystore/add.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filekeystore/add.js @@ -25,8 +25,6 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm { init: function() { - // Readers are HTML5 - this.reader = window.FileReader ? new FileReader() : undefined; }, show: function(data) { @@ -34,79 +32,16 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm util.parseHtmlIntoDiv(data.containerNode, "store/filekeystore/add.html"); this.containerNode = data.containerNode; - this.keyStoreServerPath = registry.byId("addStore.serverPath"); - this.keyStoreUploadFields = dom.byId("addStore.uploadFields"); - this.keyStoreSelectedFileContainer = dom.byId("addStore.selectedFile"); - this.keyStoreSelectedFileStatusContainer = dom.byId("addStore.selectedFileStatus"); - this.keyStoreFile = registry.byId("addStore.file"); - this.keyStoreFileClearButton = registry.byId("addStore.fileClearButton"); - this.keyStoreOldBrowserWarning = dom.byId("addStore.oldBrowserWarning"); - //Only submitted field - this.keyStorePath = registry.byId("addStore.path"); + this.keyStoreOldBrowserWarning = dom.byId("addStore.oldBrowserWarning"); this.addButton = data.parent.addButton; - if (this.reader) - { - this.reader.onload = function(evt) {that._keyStoreUploadFileComplete(evt);}; - this.reader.onerror = function(ex) {console.error("Failed to load key store file", ex);}; - this.keyStoreFile.on("change", function(selected){that._keyStoreFileChanged(selected)}); - this.keyStoreFileClearButton.on("click", function(event){that._keyStoreFileClearButtonClicked(event)}); - } - else + if (!window.FileReader) { - // Fall back for IE8/9 which do not support FileReader - this.keyStoreUploadFields.style.display = "none"; this.keyStoreOldBrowserWarning.innerHTML = "File upload requires a more recent browser with HTML5 support"; this.keyStoreOldBrowserWarning.className = this.keyStoreOldBrowserWarning.className.replace("hidden", ""); } - - this.keyStoreServerPath.on("blur", function(){that._keyStoreServerPathChanged()}); - }, - _keyStoreFileChanged: function (evt) - { - // We only ever expect a single file - var file = this.keyStoreFile.domNode.children[0].files[0]; - - this.addButton.setDisabled(true); - this.keyStoreSelectedFileContainer.innerHTML = file.name; - this.keyStoreSelectedFileStatusContainer.className = "loadingIcon"; - - console.log("Beginning to read key store file " + file.name); - this.reader.readAsDataURL(file); - }, - _keyStoreUploadFileComplete: function(evt) - { - var reader = evt.target; - var result = reader.result; - console.log("Key store file read complete, contents " + result); - this.addButton.setDisabled(false); - this.keyStoreSelectedFileStatusContainer.className = "loadedIcon"; - - this.keyStoreServerPath.set("value", ""); - this.keyStoreServerPath.setDisabled(true); - this.keyStoreServerPath.set("required", false); - - this.keyStoreFileClearButton.setDisabled(false); - - this.keyStorePath.set("value", result); - }, - _keyStoreFileClearButtonClicked: function(event) - { - this.keyStoreFile.reset(); - this.keyStoreSelectedFileStatusContainer.className = ""; - this.keyStoreSelectedFileContainer.innerHTML = ""; - this.keyStoreServerPath.set("required", true); - this.keyStoreServerPath.setDisabled(false); - this.keyStoreFileClearButton.setDisabled(true); - - this.keyStorePath.set("value", ""); - }, - _keyStoreServerPathChanged: function() - { - var serverPathValue = this.keyStoreServerPath.get("value"); - this.keyStorePath.set("value", serverPathValue); }, update: function(effectiveData) { @@ -115,27 +50,18 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm array.forEach(widgets, function(item) { var name = item.id.replace("addStore.",""); - if (name in attributes && item.type != "password") + if (name in attributes ) { - item.set("value", effectiveData[name]); + if (item.type != "password") + { + item.set("value", effectiveData[name]); + } + else + { + item.set("required", effectiveData?false:true); + } } }); - - var keyStorePathValue = effectiveData["path"]; - var isDataUrl = keyStorePathValue.indexOf("data:") == 0; - - if (isDataUrl) - { - this.keyStoreSelectedFileStatusContainer.className = "loadedIcon"; - this.keyStoreSelectedFileContainer.innerHTML = "uploaded.jks"; - this.keyStoreServerPath.setDisabled(true); - this.keyStoreServerPath.set("required", false); - this.keyStoreFileClearButton.setDisabled(false); - } - else - { - this.keyStoreServerPath.set("value", keyStorePathValue); - } } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filetruststore/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filetruststore/add.js index 9d113a9d9e..b55affb33b 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filetruststore/add.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filetruststore/add.js @@ -25,8 +25,6 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm { init: function() { - // Readers are HTML5 - this.reader = window.FileReader ? new FileReader() : undefined; }, show: function(data) { @@ -34,79 +32,17 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm util.parseHtmlIntoDiv(data.containerNode, "store/filetruststore/add.html"); this.containerNode = data.containerNode; - this.keyStoreServerPath = registry.byId("addStore.serverPath"); - this.keyStoreUploadFields = dom.byId("addStore.uploadFields"); - this.keyStoreSelectedFileContainer = dom.byId("addStore.selectedFile"); - this.keyStoreSelectedFileStatusContainer = dom.byId("addStore.selectedFileStatus"); - this.keyStoreFile = registry.byId("addStore.file"); - this.keyStoreFileClearButton = registry.byId("addStore.fileClearButton"); - this.keyStoreOldBrowserWarning = dom.byId("addStore.oldBrowserWarning"); - //Only submitted field - this.keyStorePath = registry.byId("addStore.path"); + this.keyStoreOldBrowserWarning = dom.byId("addStore.oldBrowserWarning"); this.addButton = data.parent.addButton; - if (this.reader) - { - this.reader.onload = function(evt) {that._keyStoreUploadFileComplete(evt);}; - this.reader.onerror = function(ex) {console.error("Failed to load trust store file", ex);}; - this.keyStoreFile.on("change", function(selected){that._keyStoreFileChanged(selected)}); - this.keyStoreFileClearButton.on("click", function(event){that._keyStoreFileClearButtonClicked(event)}); - } - else + if (!window.FileReader) { // Fall back for IE8/9 which do not support FileReader - this.keyStoreUploadFields.style.display = "none"; this.keyStoreOldBrowserWarning.innerHTML = "File upload requires a more recent browser with HTML5 support"; this.keyStoreOldBrowserWarning.className = this.keyStoreOldBrowserWarning.className.replace("hidden", ""); } - - this.keyStoreServerPath.on("blur", function(){that._keyStoreServerPathChanged()}); - }, - _keyStoreFileChanged: function (evt) - { - // We only ever expect a single file - var file = this.keyStoreFile.domNode.children[0].files[0]; - - this.addButton.setDisabled(true); - this.keyStoreSelectedFileContainer.innerHTML = file.name; - this.keyStoreSelectedFileStatusContainer.className = "loadingIcon"; - - console.log("Beginning to read trust store file " + file.name); - this.reader.readAsDataURL(file); - }, - _keyStoreUploadFileComplete: function(evt) - { - var reader = evt.target; - var result = reader.result; - console.log("Trust store file read complete, contents " + result); - this.addButton.setDisabled(false); - this.keyStoreSelectedFileStatusContainer.className = "loadedIcon"; - - this.keyStoreServerPath.set("value", ""); - this.keyStoreServerPath.setDisabled(true); - this.keyStoreServerPath.set("required", false); - - this.keyStoreFileClearButton.setDisabled(false); - - this.keyStorePath.set("value", result); - }, - _keyStoreFileClearButtonClicked: function(event) - { - this.keyStoreFile.reset(); - this.keyStoreSelectedFileStatusContainer.className = ""; - this.keyStoreSelectedFileContainer.innerHTML = ""; - this.keyStoreServerPath.set("required", true); - this.keyStoreServerPath.setDisabled(false); - this.keyStoreFileClearButton.setDisabled(true); - - this.keyStorePath.set("value", ""); - }, - _keyStoreServerPathChanged: function() - { - var serverPathValue = this.keyStoreServerPath.get("value"); - this.keyStorePath.set("value", serverPathValue); }, update: function(effectiveData) { @@ -115,27 +51,19 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm array.forEach(widgets, function(item) { var name = item.id.replace("addStore.",""); - if (name in attributes && item.type != "password") + if (name in attributes ) { - item.set("value", effectiveData[name]); + if (item.type != "password") + { + item.set("value", effectiveData[name]); + } + else + { + item.set("required", effectiveData?false:true); + } } }); - var keyStorePathValue = effectiveData["path"]; - var isDataUrl = keyStorePathValue.indexOf("data:") == 0; - - if (isDataUrl) - { - this.keyStoreSelectedFileStatusContainer.className = "loadedIcon"; - this.keyStoreSelectedFileContainer.innerHTML = "uploaded.jks"; - this.keyStoreServerPath.setDisabled(true); - this.keyStoreServerPath.set("required", false); - this.keyStoreFileClearButton.setDisabled(false); - } - else - { - this.keyStoreServerPath.set("value", keyStorePathValue); - } } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavakeystore/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavakeystore/add.js index 7488ad93d6..989af03832 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavakeystore/add.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavakeystore/add.js @@ -18,7 +18,7 @@ * under the License. * */ -define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/common/util", "qpid/common/metadata"], +define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/common/util", "qpid/common/metadata", "qpid/common/ResourceWidget"], function (dom, query, array, registry, util, metadata) { var addKeyStore = @@ -40,81 +40,6 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm this.keyStoreOldBrowserWarning.innerHTML = "File upload requires a more recent browser with HTML5 support"; this.keyStoreOldBrowserWarning.className = this.keyStoreOldBrowserWarning.className.replace("hidden", ""); } - - this._initUploadFields("privateKey", "private key"); - this._initUploadFields("certificate", "certificate"); - this._initUploadFields("intermediateCertificate", "intermediate certificate"); - }, - _initUploadFields: function(fieldName, description) - { - var that=this; - this[fieldName] = registry.byId("addStore." + fieldName); - this[fieldName + "UploadFields"] = dom.byId("addStore." + fieldName +"UploadFields"); - this[fieldName + "UploadContainer"] = dom.byId("addStore." + fieldName + "UploadContainer"); - this[fieldName + "UploadStatusContainer"] = dom.byId("addStore." + fieldName + "UploadStatusContainer"); - this[fieldName + "File"] = registry.byId("addStore." + fieldName + "File"); - this[fieldName + "FileClearButton"] = registry.byId("addStore." + fieldName + "FileClearButton"); - - // field to submit - this[fieldName + "Url"] = registry.byId("addStore." + fieldName + "Url"); - - if (window.FileReader) - { - this[fieldName + "Reader"] = new FileReader(); - this[fieldName + "Reader"].onload = function(evt) {that._uploadFileComplete(evt, fieldName);}; - this[fieldName + "Reader"].onerror = function(ex) {console.error("Failed to load " + description + " file", ex);}; - this[fieldName + "File"].on("change", function(selected){that._fileChanged(selected, fieldName)}); - this[fieldName + "FileClearButton"].on("click", function(event){that._fileClearButtonClicked(event, fieldName)}); - } - else - { - // Fall back for IE8/9 which do not support FileReader - this[fieldName + "UploadFields"].style.display = "none"; - } - - this[fieldName].on("blur", function(){that._pathChanged(fieldName)}); - }, - _fileChanged: function (evt, fieldName) - { - var file = this[fieldName + "File"].domNode.children[0].files[0]; - - this[fieldName + "UploadContainer"].innerHTML = file.name; - this[fieldName + "UploadStatusContainer"].className = "loadingIcon"; - - console.log("Beginning to read file " + file.name + " for " + fieldName ); - this[fieldName + "Reader"].readAsDataURL(file); - }, - _uploadFileComplete: function(evt, fieldName) - { - var reader = evt.target; - var result = reader.result; - console.log(fieldName + " file read complete, contents " + result); - - this[fieldName + "UploadStatusContainer"].className = "loadedIcon"; - - this[fieldName].set("value", ""); - this[fieldName].setDisabled(true); - this[fieldName].set("required", false); - - this[fieldName + "FileClearButton"].setDisabled(false); - - this[fieldName + "Url"].set("value", result); - }, - _fileClearButtonClicked: function(event, fieldName) - { - this[fieldName + "File"].reset(); - this[fieldName + "UploadStatusContainer"].className = ""; - this[fieldName + "UploadContainer"].innerHTML = ""; - this[fieldName].set("required", true); - this[fieldName].setDisabled(false); - this[fieldName + "FileClearButton"].setDisabled(true); - - this[fieldName + "Url"].set("value", ""); - }, - _pathChanged: function(fieldName) - { - var serverPathValue = this[fieldName].get("value"); - this[fieldName + "Url"].set("value", serverPathValue); }, update: function(effectiveData) { @@ -126,26 +51,7 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm var name = item.id.replace("addStore.",""); var val = effectiveData[name]; item.set("value", val); - - if (name.indexOf("Url") != -1) - { - var isDataUrl = val && val.indexOf("data:") == 0; - var fieldName = name.substring(0, name.length - 3); - if (isDataUrl) - { - that[fieldName + "UploadStatusContainer"].className = "loadedIcon"; - that[fieldName + "UploadContainer"].innerHTML = "uploaded.jks"; - that[fieldName].setDisabled(true); - that[fieldName].set("required", false); - that[fieldName + "FileClearButton"].setDisabled(false); - } - else - { - that[fieldName].set("value", val); - } - } }); - } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavatruststore/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavatruststore/add.js index 2cff365f60..15926d1832 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavatruststore/add.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavatruststore/add.js @@ -40,81 +40,6 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm this.keyStoreOldBrowserWarning.innerHTML = "File upload requires a more recent browser with HTML5 support"; this.keyStoreOldBrowserWarning.className = this.keyStoreOldBrowserWarning.className.replace("hidden", ""); } - - this._initUploadFields("certificates", "certificates"); - }, - _initUploadFields: function(fieldName, description) - { - var that=this; - this[fieldName] = registry.byId("addStore." + fieldName); - this[fieldName + "UploadFields"] = dom.byId("addStore." + fieldName +"UploadFields"); - this[fieldName + "UploadContainer"] = dom.byId("addStore." + fieldName + "UploadContainer"); - this[fieldName + "UploadStatusContainer"] = dom.byId("addStore." + fieldName + "UploadStatusContainer"); - this[fieldName + "File"] = registry.byId("addStore." + fieldName + "File"); - this[fieldName + "FileClearButton"] = registry.byId("addStore." + fieldName + "FileClearButton"); - - // field to submit - this[fieldName + "Url"] = registry.byId("addStore." + fieldName + "Url"); - - if (window.FileReader) - { - this[fieldName + "Reader"] = new FileReader(); - this[fieldName + "Reader"].onload = function(evt) {that._uploadFileComplete(evt, fieldName);}; - this[fieldName + "Reader"].onerror = function(ex) {console.error("Failed to load " + description + " file", ex);}; - this[fieldName + "File"].on("change", function(selected){that._fileChanged(selected, fieldName)}); - this[fieldName + "FileClearButton"].on("click", function(event){that._fileClearButtonClicked(event, fieldName)}); - } - else - { - // Fall back for IE8/9 which do not support FileReader - this[fieldName + "UploadFields"].style.display = "none"; - } - - this[fieldName].on("blur", function(){that._pathChanged(fieldName)}); - }, - _fileChanged: function (evt, fieldName) - { - var file = this[fieldName + "File"].domNode.children[0].files[0]; - - this[fieldName + "UploadContainer"].innerHTML = file.name; - this[fieldName + "UploadStatusContainer"].className = "loadingIcon"; - - console.log("Beginning to read file " + file.name + " for " + fieldName ); - this[fieldName + "Reader"].readAsDataURL(file); - }, - _uploadFileComplete: function(evt, fieldName) - { - var reader = evt.target; - var result = reader.result; - console.log(fieldName + " file read complete, contents " + result); - - // it is not clear the purpose of this operation - //this.addButton.setDisabled(false); - this[fieldName + "UploadStatusContainer"].className = "loadedIcon"; - - this[fieldName].set("value", ""); - this[fieldName].setDisabled(true); - this[fieldName].set("required", false); - - this[fieldName + "FileClearButton"].setDisabled(false); - - this[fieldName + "Url"].set("value", result); - }, - _fileClearButtonClicked: function(event, fieldName) - { - this[fieldName + "File"].reset(); - this[fieldName + "UploadStatusContainer"].className = ""; - this[fieldName + "UploadContainer"].innerHTML = ""; - this[fieldName].set("required", true); - this[fieldName].setDisabled(false); - this[fieldName + "FileClearButton"].setDisabled(true); - - this[fieldName + "Url"].set("value", ""); - }, - _pathChanged: function(fieldName) - { - var serverPathValue = this[fieldName].get("value"); - this[fieldName + "Url"].set("value", serverPathValue); }, update: function(effectiveData) { @@ -127,23 +52,6 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm var val = effectiveData[name]; item.set("value", val); - if (name.indexOf("Url") != -1) - { - var isDataUrl = val && val.indexOf("data:") == 0; - var fieldName = name.substring(0, name.length - 3); - if (isDataUrl) - { - that[fieldName + "UploadStatusContainer"].className = "loadedIcon"; - that[fieldName + "UploadContainer"].innerHTML = "uploaded.jks"; - that[fieldName].setDisabled(true); - that[fieldName].set("required", false); - that[fieldName + "FileClearButton"].setDisabled(false); - } - else - { - that[fieldName].set("value", val); - } - } }); } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filekeystore/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filekeystore/add.html index 1732688ba7..2356accbd4 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filekeystore/add.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filekeystore/add.html @@ -22,42 +22,14 @@ <div class="clear"> <div id="addStore.serverPathLabel" class="formLabel-labelCell tableContainer-labelCell">Server path or upload*:</div> <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addStore.serverPath" - data-dojo-type="dijit/form/ValidationTextBox" + <input type="text" id="addStore.path" + data-dojo-type="qpid/common/ResourceWidget" data-dojo-props=" - name: 'serverPath', + name: 'path', placeHolder: 'key store file server path', required: true, - excluded: true, promptMessage: 'Location of the key store file on the server', title: 'Enter the key store file path'" /> - - <!-- Hidden and used purely for form submission --> - <input type="hidden" id="addStore.path" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'path', - required: true" /> - </div> - - <div id="addStore.uploadFields"> - <div id="addStore.fileLabel" class="formLabel-labelCell tableContainer-labelCell"></div> - <div class="fileUpload clear"> - <span id="addStore.selectedFile" class="infoMessage"></span> - <span id="addStore.selectedFileStatus"></span> - </div> - - <div class="fileUpload clear"> - <input type="file" id="addStore.file" - multiple="false" - data-dojo-type="dojox/form/Uploader" - data-dojo-props="label: 'Upload'"/> - <button id="addStore.fileClearButton" - data-dojo-type="dijit/form/Button" - data-dojo-props="label: 'Clear', - disabled: true"> - </button> - </div> </div> <div class="clear"> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html index 36180d8a39..4fbf9f953a 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html @@ -22,39 +22,14 @@ <div class="clear"> <div id="addStore.serverPathLabel" class="formLabel-labelCell tableContainer-labelCell">Server path or upload*:</div> <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addStore.serverPath" - data-dojo-type="dijit/form/ValidationTextBox" + <input type="text" id="addStore.path" + data-dojo-type="qpid/common/ResourceWidget" data-dojo-props=" - name: 'serverPath', + name: 'path', placeHolder: 'trust store file server path', required: true, - excluded: true, promptMessage: 'Location of the trust store file on the server', title: 'Enter the store file path'" /> - <!-- Hidden and used purely for form submission --> - <input type="hidden" id="addStore.path" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'path', - required: true" /> - </div> - <div id="addStore.uploadFields"> - <div id="addStore.fileLabel" class="formLabel-labelCell tableContainer-labelCell"></div> - <div class="fileUpload clear"> - <span id="addStore.selectedFile" class="infoMessage"></span> - <span id="addStore.selectedFileStatus"></span> - </div> - <div class="fileUpload clear"> - <input type="file" id="addStore.file" - multiple="false" - data-dojo-type="dojox/form/Uploader" - data-dojo-props="label: 'Upload'"/> - <button id="addStore.fileClearButton" - data-dojo-type="dijit/form/Button" - data-dojo-props="label: 'Clear', - disabled: true"> - </button> - </div> </div> <div class="clear"> <div class="formLabel-labelCell tableContainer-labelCell">Password*:</div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavakeystore/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavakeystore/add.html index 5272537bdf..f7ae4d3f76 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavakeystore/add.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavakeystore/add.html @@ -22,132 +22,45 @@ <div id="addStore.oldBrowserWarning" class="infoMessage hidden clear"></div> <div class="clear"> - <div id="addStore.privateKeyLabel" class="formLabel-labelCell tableContainer-labelCell">Private Key URL or Path*:</div> + <div id="addStore.privateKeyLabel" class="formLabel-labelCell tableContainer-labelCell">Private Key*:</div> <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addStore.privateKey" - data-dojo-type="dijit/form/ValidationTextBox" + <input type="text" id="addStore.privateKeyUrl" + data-dojo-type="qpid/common/ResourceWidget" data-dojo-props=" - name: 'privateKey', + name: 'privateKeyUrl', placeHolder: 'Private key URL or path to file on server', required: true, - excluded: true, promptMessage: 'Location of the private key', title: 'Enter private key URL or path to file containing private key in DER or PEM format'" /> - <!-- Hidden and used purely for form submission --> - <input type="hidden" id="addStore.privateKeyUrl" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'privateKeyUrl', - required: true" /> - - - <div id="addStore.privateKeyUploadFields" class="clear"> - - <div class="alignLeft" > - <span id="addStore.privateKeyUploadContainer" class="infoMessage"></span> - <span id="addStore.privateKeyUploadStatusContainer"></span> - </div> - - <div class="alignRight"> - <input type="file" id="addStore.privateKeyFile" - multiple="false" - data-dojo-type="dojox/form/Uploader" - data-dojo-props="label: 'Upload'"/> - <button id="addStore.privateKeyFileClearButton" - data-dojo-type="dijit/form/Button" - data-dojo-props="label: 'Clear', - disabled: true"> - </button> - </div> - <div class="clear"></div> - </div> </div> </div> <div class="clear"> - <div id="addStore.serverPathLabel" class="formLabel-labelCell tableContainer-labelCell">Certificate URL or Path*:</div> + <div id="addStore.serverPathLabel" class="formLabel-labelCell tableContainer-labelCell">Certificate*:</div> <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addStore.certificate" - data-dojo-type="dijit/form/ValidationTextBox" + <input type="text" id="addStore.certificateUrl" + data-dojo-type="qpid/common/ResourceWidget" data-dojo-props=" - name: 'certificate', + name: 'certificateUrl', placeHolder: 'Certificate URL or path to certificate file on server', required: true, - excluded: true, promptMessage: 'Location of the certificate', title: 'Enter certificate URL or path to file containing certificate in DER or PEM format'" /> - - <!-- Hidden and used purely for form submission --> - <input type="hidden" id="addStore.certificateUrl" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'certificateUrl', - required: true" /> - - - <div id="addStore.certificateUploadFields"> - <div class="alignLeft"> - <span id="addStore.certificateUploadContainer" class="infoMessage"></span> - <span id="addStore.certificateUploadStatusContainer"></span> - </div> - - <div class="alignRight"> - <input type="file" id="addStore.certificateFile" - multiple="false" - data-dojo-type="dojox/form/Uploader" - data-dojo-props="label: 'Upload'"/> - <button id="addStore.certificateFileClearButton" - data-dojo-type="dijit/form/Button" - data-dojo-props="label: 'Clear', - disabled: true"> - </button> - </div> - <div class="clear"></div> - </div> </div> </div> <div class="clear"> - <div id="addStore.intermediateCertificateLabel" class="formLabel-labelCell tableContainer-labelCell">Intermediate Certificate URL or Path:</div> + <div id="addStore.intermediateCertificateLabel" class="formLabel-labelCell tableContainer-labelCell">Intermediate Certificate(s):</div> <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addStore.intermediateCertificate" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'intermediateCertificate', - placeHolder: 'Intermediate certificate URL or path to file on server', - required: false, - excluded: true, - promptMessage: 'Location of the intermediate certificate', - title: 'Enter intermediate certificate URL or path to file containing certificate in format DER or PEM'" /> - - <!-- Hidden and used purely for form submission --> - <input type="hidden" id="addStore.intermediateCertificateUrl" - data-dojo-type="dijit/form/ValidationTextBox" + <input type="text" id="addStore.intermediateCertificateUrl" + data-dojo-type="qpid/common/ResourceWidget" data-dojo-props=" name: 'intermediateCertificateUrl', - required: false" /> - </div> - - <div id="addStore.intermediateCertificateUploadFields"> - <div class="alignLeft"> - <span id="addStore.intermediateCertificateUploadContainer" class="infoMessage"></span> - <span id="addStore.intermediateCertificateUploadStatusContainer"></span> - </div> - - <div class="alignRight"> - <input type="file" id="addStore.intermediateCertificateFile" - multiple="false" - data-dojo-type="dojox/form/Uploader" - data-dojo-props="label: 'Upload'"/> - <button id="addStore.intermediateCertificateFileClearButton" - data-dojo-type="dijit/form/Button" - data-dojo-props="label: 'Clear', - disabled: true"> - </button> - </div> - <div class="clear"></div> + placeHolder: 'Intermediate certificates URL or path to file on server', + required: false, + promptMessage: 'Location of the intermediate certificates', + title: 'Enter URL containing intermediate certificates or path to file with certificates in format DER or PEM'" /> </div> </div> - </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavatruststore/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavatruststore/add.html index 9de25877cb..ba5aee0444 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavatruststore/add.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavatruststore/add.html @@ -24,43 +24,14 @@ <div class="clear"> <div id="addStore.certificatesLabel" class="formLabel-labelCell tableContainer-labelCell">Certificate URL or Path*:</div> <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addStore.certificates" - data-dojo-type="dijit/form/ValidationTextBox" + <input type="text" id="addStore.certificatesUrl" + data-dojo-type="qpid/common/ResourceWidget" data-dojo-props=" - name: 'certificates', + name: 'certificatesUrl', placeHolder: 'Certificate URL or path to certificate file on server', required: true, - excluded: true, promptMessage: 'Location of the certificate', title: 'Enter certificate URL or path to file containing certificate in DER or PEM format'" /> - - <!-- Hidden and used purely for form submission --> - <input type="hidden" id="addStore.certificatesUrl" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'certificatesUrl', - required: true" /> - - - <div id="addStore.certificatesUploadFields"> - <div class="alignLeft"> - <span id="addStore.certificatesUploadContainer" class="infoMessage"></span> - <span id="addStore.certificatesUploadStatusContainer"></span> - </div> - - <div class="alignRight"> - <input type="file" id="addStore.certificatesFile" - multiple="false" - data-dojo-type="dojox/form/Uploader" - data-dojo-props="label: 'Upload'"/> - <button id="addStore.certificatesFileClearButton" - data-dojo-type="dijit/form/Button" - data-dojo-props="label: 'Clear', - disabled: true"> - </button> - </div> - <div class="clear"></div> - </div> </div> </div> |