Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js Mon May 2 15:57:52 2016 @@ -37,98 +37,111 @@ define(["dojo/dom", "dijit/form/CheckBox", "dijit/form/NumberSpinner", "dojo/domReady!"], - function (dom, parser, query, construct, connect, win, event, json, registry, util, properties, updater, template, editor) - { + function (dom, + parser, + query, + construct, + connect, + win, + event, + json, + registry, + util, + properties, + updater, + template, + editor) + { + + function ManagementHttp(containerNode, pluginObject, controller, contentPane) + { + var node = construct.create("div", null, containerNode, "last"); + var that = this; + this.name = pluginObject.name; + this.modelObj = pluginObject; + this.management = controller.management; + node.innerHTML = template; + parser.parse(node) + .then(function (instances) + { + that.managementHttpUpdater = new ManagementHttpUpdater(node, pluginObject, controller, contentPane); + that.managementHttpUpdater.update(function () + { + updater.add(that.managementHttpUpdater) + }); + + var editButton = query(".editPluginButton", node)[0]; + connect.connect(registry.byNode(editButton), "onClick", function (evt) + { + that.edit(); + }); + }); + } + + ManagementHttp.prototype.close = function () + { + updater.remove(this.managementHttpUpdater); + }; + + ManagementHttp.prototype.edit = function () + { + editor.show(this.management, this.modelObj, this.managementHttpUpdater.pluginData); + }; + + function ManagementHttpUpdater(node, pluginObject, controller, contentPane) + { + this.contentPane = contentPane; + this.controller = controller; + this.modelObj = pluginObject; + this.name = pluginObject.name; + this.httpBasicAuthenticationEnabled = query(".httpBasicAuthenticationEnabled", node)[0]; + this.httpsBasicAuthenticationEnabled = query(".httpsBasicAuthenticationEnabled", node)[0]; + this.sessionTimeout = query(".sessionTimeout", node)[0]; + this.httpsSaslAuthenticationEnabled = query(".httpsSaslAuthenticationEnabled", node)[0]; + this.httpSaslAuthenticationEnabled = query(".httpSaslAuthenticationEnabled", node)[0]; + this.compressResponses = query(".compressResponses", node)[0]; + this.management = controller.management; + } + + ManagementHttpUpdater.prototype.update = function (callback) + { + var that = this; + + function showBoolean(val) + { + return "<input type='checkbox' disabled='disabled' " + (val ? "checked='checked'" : "") + " />"; + } + + this.management.load(this.modelObj) + .then(function (data) + { + that.pluginData = data[0]; + that.httpBasicAuthenticationEnabled.innerHTML = + showBoolean(that.pluginData.httpBasicAuthenticationEnabled); + that.httpsBasicAuthenticationEnabled.innerHTML = + showBoolean(that.pluginData.httpsBasicAuthenticationEnabled); + that.httpsSaslAuthenticationEnabled.innerHTML = + showBoolean(that.pluginData.httpsSaslAuthenticationEnabled); + that.httpSaslAuthenticationEnabled.innerHTML = + showBoolean(that.pluginData.httpSaslAuthenticationEnabled); + that.compressResponses.innerHTML = showBoolean(that.pluginData.compressResponses); + that.sessionTimeout.innerHTML = that.pluginData.sessionTimeout; + if (callback) + { + callback(); + } + }, function (error) + { + util.tabErrorHandler(error, { + updater: that, + contentPane: that.contentPane, + tabContainer: that.controller.tabContainer, + name: that.modelObj.name, + category: "Plugin HTTP Management" + }); + }); - function ManagementHttp(containerNode, pluginObject, controller, contentPane) - { - var node = construct.create("div", null, containerNode, "last"); - var that = this; - this.name = pluginObject.name; - this.modelObj = pluginObject; - this.management = controller.management; - node.innerHTML = template; - parser.parse(node).then(function (instances) - { - that.managementHttpUpdater = - new ManagementHttpUpdater(node, pluginObject, controller, contentPane); - that.managementHttpUpdater.update(function () - { - updater.add(that.managementHttpUpdater) - }); - - var editButton = query(".editPluginButton", node)[0]; - connect.connect(registry.byNode(editButton), "onClick", function (evt) - { - that.edit(); - }); - }); - } - - ManagementHttp.prototype.close = function () - { - updater.remove(this.managementHttpUpdater); - }; - - ManagementHttp.prototype.edit = function () - { - editor.show(this.management, this.modelObj, this.managementHttpUpdater.pluginData); - }; - - function ManagementHttpUpdater(node, pluginObject, controller, contentPane) - { - this.contentPane = contentPane; - this.controller = controller; - this.modelObj = pluginObject; - this.name = pluginObject.name; - this.httpBasicAuthenticationEnabled = query(".httpBasicAuthenticationEnabled", node)[0]; - this.httpsBasicAuthenticationEnabled = query(".httpsBasicAuthenticationEnabled", node)[0]; - this.sessionTimeout = query(".sessionTimeout", node)[0]; - this.httpsSaslAuthenticationEnabled = query(".httpsSaslAuthenticationEnabled", node)[0]; - this.httpSaslAuthenticationEnabled = query(".httpSaslAuthenticationEnabled", node)[0]; - this.compressResponses = query(".compressResponses", node)[0]; - this.management = controller.management; - } - - ManagementHttpUpdater.prototype.update = function (callback) - { - var that = this; - - function showBoolean(val) - { - return "<input type='checkbox' disabled='disabled' " + (val ? "checked='checked'" : "") + " />"; - } - - this.management.load(this.modelObj) - .then(function (data) - { - that.pluginData = data[0]; - that.httpBasicAuthenticationEnabled.innerHTML = - showBoolean(that.pluginData.httpBasicAuthenticationEnabled); - that.httpsBasicAuthenticationEnabled.innerHTML = - showBoolean(that.pluginData.httpsBasicAuthenticationEnabled); - that.httpsSaslAuthenticationEnabled.innerHTML = - showBoolean(that.pluginData.httpsSaslAuthenticationEnabled); - that.httpSaslAuthenticationEnabled.innerHTML = - showBoolean(that.pluginData.httpSaslAuthenticationEnabled); - that.compressResponses.innerHTML = showBoolean(that.pluginData.compressResponses); - that.sessionTimeout.innerHTML = that.pluginData.sessionTimeout; - if (callback) - { - callback(); - } - }, function (error) - { - util.tabErrorHandler(error, { - updater: that, - contentPane: that.contentPane, - tabContainer: that.controller.tabContainer, - name: that.modelObj.name, - category: "Plugin HTTP Management" - }); - }); + }; - }; - - return ManagementHttp; - }); + return ManagementHttp; + });
Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp/edit.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp/edit.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp/edit.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp/edit.js Mon May 2 15:57:52 2016 @@ -37,104 +37,106 @@ define(["dojo/_base/event", "dojox/validate/us", "dojox/validate/web", "dojo/domReady!"], function (event, dom, domConstruct, json, query, parser, registry, util, template, entities) - { +{ - var httpManagementEditor = { - init: function () - { - var that = this; - this.containerNode = domConstruct.create("div", {innerHTML: template}); - parser.parse(this.containerNode).then(function (instances) - { - that._postParse(); - }); - }, - _postParse: function () - { - var that = this; - this.allFieldsContainer = dom.byId("editHttpManagement.contentPane"); - this.dialog = registry.byId("editHttpManagementDialog"); - this.saveButton = registry.byId("editHttpManagement.saveButton"); - this.cancelButton = registry.byId("editHttpManagement.cancelButton"); - this.cancelButton.on("click", function (e) - { - that._cancel(e); - }); - this.saveButton.on("click", function (e) - { - that._save(e); - }); - this.form = registry.byId("editHttpManagementForm"); - this.form.on("submit", function () - { - return false; - }); - }, - show: function (management, modelObj, data) - { - this.management = management; - this.modelObj = modelObj; - var that = this; - management.load(modelObj, {actuals: true}).then(function (actualData) - { - that._show(actualData[0]); - }); - }, - destroy: function () - { - if (this.dialog) - { - this.dialog.destroyRecursive(); - this.dialog = null; - } + var httpManagementEditor = { + init: function () + { + var that = this; + this.containerNode = domConstruct.create("div", {innerHTML: template}); + parser.parse(this.containerNode) + .then(function (instances) + { + that._postParse(); + }); + }, + _postParse: function () + { + var that = this; + this.allFieldsContainer = dom.byId("editHttpManagement.contentPane"); + this.dialog = registry.byId("editHttpManagementDialog"); + this.saveButton = registry.byId("editHttpManagement.saveButton"); + this.cancelButton = registry.byId("editHttpManagement.cancelButton"); + this.cancelButton.on("click", function (e) + { + that._cancel(e); + }); + this.saveButton.on("click", function (e) + { + that._save(e); + }); + this.form = registry.byId("editHttpManagementForm"); + this.form.on("submit", function () + { + return false; + }); + }, + show: function (management, modelObj, data) + { + this.management = management; + this.modelObj = modelObj; + var that = this; + management.load(modelObj, {actuals: true}) + .then(function (actualData) + { + that._show(actualData[0]); + }); + }, + destroy: function () + { + if (this.dialog) + { + this.dialog.destroyRecursive(); + this.dialog = null; + } - if (this.containerNode) - { - domConstruct.destroy(this.containerNode); - this.containerNode = null; - } - }, - _cancel: function (e) - { - this.dialog.hide(); - }, - _save: function (e) - { - event.stop(e); - if (this.form.validate()) - { - var data = util.getFormWidgetValues(this.form, this.initialData); - var that = this; - this.management.update(this.modelObj, data).then(function (x) - { - that.dialog.hide(); - }); - } - else - { - alert('Form contains invalid data. Please correct first'); - } - }, - _show: function (actualData) - { - this.initialData = actualData; - util.applyToWidgets(this.allFieldsContainer, - "Plugin", - "MANAGEMENT-HTTP", - actualData, - this.management.metadata); - this.dialog.startup(); - this.dialog.show(); - if (!this.resizeEventRegistered) - { - this.resizeEventRegistered = true; - util.resizeContentAreaAndRepositionDialog(dom.byId("editHttpManagement.contentPane"), - this.dialog); - } - } - }; + if (this.containerNode) + { + domConstruct.destroy(this.containerNode); + this.containerNode = null; + } + }, + _cancel: function (e) + { + this.dialog.hide(); + }, + _save: function (e) + { + event.stop(e); + if (this.form.validate()) + { + var data = util.getFormWidgetValues(this.form, this.initialData); + var that = this; + this.management.update(this.modelObj, data) + .then(function (x) + { + that.dialog.hide(); + }); + } + else + { + alert('Form contains invalid data. Please correct first'); + } + }, + _show: function (actualData) + { + this.initialData = actualData; + util.applyToWidgets(this.allFieldsContainer, + "Plugin", + "MANAGEMENT-HTTP", + actualData, + this.management.metadata); + this.dialog.startup(); + this.dialog.show(); + if (!this.resizeEventRegistered) + { + this.resizeEventRegistered = true; + util.resizeContentAreaAndRepositionDialog(dom.byId("editHttpManagement.contentPane"), this.dialog); + } + } + }; - httpManagementEditor.init(); + httpManagementEditor.init(); - return httpManagementEditor; - }); + return httpManagementEditor; +}); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/port/amqp/show.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/port/amqp/show.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/port/amqp/show.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/port/amqp/show.js Mon May 2 15:57:52 2016 @@ -26,113 +26,109 @@ define(["dojo/query", "qpid/common/UpdatableStore", "qpid/management/addVirtualHostAlias", "dojo/domReady!"], function (query, template, EnhancedGrid, registry, util, UpdatableStore, addVirtualHostAlias) - { - function AmqpPort(params) - { - var that = this; - util.parse(params.typeSpecificDetailsNode, template, function () - { - that.postParse(params); - }); - this.modelObj = params.modelObj; - this.portUpdater = params.portUpdater; - this.management = params.management; - } +{ + function AmqpPort(params) + { + var that = this; + util.parse(params.typeSpecificDetailsNode, template, function () + { + that.postParse(params); + }); + this.modelObj = params.modelObj; + this.portUpdater = params.portUpdater; + this.management = params.management; + } - AmqpPort.prototype.postParse = function (params) - { - var that = this; - var gridProperties = { - height: 400, - sortInfo: 2, /* - canSort: function(column) { return false; }, - */ - plugins: { - indirectSelection: true, // KW TODO checkme - pagination: { - pageSizes: [10, 25, 50, 100], - description: true, - sizeSwitch: true, - pageStepper: true, - gotoButton: true, - maxPageStep: 4, - position: "bottom" - } - } - }; + AmqpPort.prototype.postParse = function (params) + { + var that = this; + var gridProperties = { + height: 400, + sortInfo: 2, /* + canSort: function(column) { return false; }, + */ + plugins: { + indirectSelection: true, // KW TODO checkme + pagination: { + pageSizes: [10, 25, 50, 100], + description: true, + sizeSwitch: true, + pageStepper: true, + gotoButton: true, + maxPageStep: 4, + position: "bottom" + } + } + }; - this.addButton = registry.byNode(query(".addButton", params.typeSpecificDetailsNode)[0]); - this.addButton.on("click", function (e) - { - addVirtualHostAlias.show(that.management, that.modelObj); - }); - this.deleteButton = registry.byNode(query(".deleteButton", params.typeSpecificDetailsNode)[0]); - this.deleteButton.on("click", function (e) - { - util.deleteSelectedObjects(that.virtualHostAliasesGrid.grid, - "Are you sure you want to delete virtual host alias", - that.management, - { - type: "virtualhostalias", - parent: that.modelObj - }, - that.portUpdater); - }); + this.addButton = registry.byNode(query(".addButton", params.typeSpecificDetailsNode)[0]); + this.addButton.on("click", function (e) + { + addVirtualHostAlias.show(that.management, that.modelObj); + }); + this.deleteButton = registry.byNode(query(".deleteButton", params.typeSpecificDetailsNode)[0]); + this.deleteButton.on("click", function (e) + { + util.deleteSelectedObjects(that.virtualHostAliasesGrid.grid, + "Are you sure you want to delete virtual host alias", + that.management, + { + type: "virtualhostalias", + parent: that.modelObj + }, + that.portUpdater); + }); - this.virtualHostAliasesGrid = new UpdatableStore(params.data.virtualhostaliases, query( - ".virtualHostAliasesGrid", - params.typeSpecificDetailsNode)[0], [{ - name: "Priority", - field: "priority", - width: "20%" - }, - { - name: "Name", - field: "name", - width: "40%" - }, - { - name: "Type", - field: "type", - width: "40%" - }], function (obj) - { - obj.grid.on("rowDblClick", function (evt) - { - var idx = evt.rowIndex; - var theItem = this.getItem(idx); - var aliasModelObj = { - name: theItem.name, - type: "virtualhostalias", - parent: that.modelObj - }; - that.management.load(aliasModelObj, - { - actuals: true, - depth: 0 - }).then(function (data) - { - addVirtualHostAlias.show(that.management, - aliasModelObj, - data[0]); - }); - }); - }, gridProperties, EnhancedGrid); - } + this.virtualHostAliasesGrid = + new UpdatableStore(params.data.virtualhostaliases, query(".virtualHostAliasesGrid", + params.typeSpecificDetailsNode)[0], [{ + name: "Priority", + field: "priority", + width: "20%" + }, { + name: "Name", + field: "name", + width: "40%" + }, { + name: "Type", + field: "type", + width: "40%" + }], function (obj) + { + obj.grid.on("rowDblClick", function (evt) + { + var idx = evt.rowIndex; + var theItem = this.getItem(idx); + var aliasModelObj = { + name: theItem.name, + type: "virtualhostalias", + parent: that.modelObj + }; + that.management.load(aliasModelObj, { + actuals: true, + depth: 0 + }) + .then(function (data) + { + addVirtualHostAlias.show(that.management, aliasModelObj, data[0]); + }); + }); + }, gridProperties, EnhancedGrid); + } - AmqpPort.prototype.update = function (restData) - { - if (this.virtualHostAliasesGrid) - { - if (this.virtualHostAliasesGrid.update(restData.virtualhostaliases)) - { - /* - this.virtualHostAliasesGrid.grid.sort(); - this.virtualHostAliasesGrid.grid.update(); - */ - } - } - } + AmqpPort.prototype.update = function (restData) + { + if (this.virtualHostAliasesGrid) + { + if (this.virtualHostAliasesGrid.update(restData.virtualhostaliases)) + { + /* + this.virtualHostAliasesGrid.grid.sort(); + this.virtualHostAliasesGrid.grid.update(); + */ + } + } + } - return AmqpPort; - }); + return AmqpPort; +}); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/port/http/show.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/port/http/show.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/port/http/show.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/port/http/show.js Mon May 2 15:57:52 2016 @@ -19,25 +19,25 @@ * */ define(["qpid/common/util", "dojo/text!port/http/show.html", "qpid/common/TypeTabExtension", "dojo/domReady!"], - function (util, template, TypeTabExtension) - { - function HttpPort(params) - { - TypeTabExtension.call(this, - params.containerNode, - template, - "Port", - params.data.type, - params.metadata, - params.data); - } + function (util, template, TypeTabExtension) + { + function HttpPort(params) + { + TypeTabExtension.call(this, + params.containerNode, + template, + "Port", + params.data.type, + params.metadata, + params.data); + } - util.extend(HttpPort, TypeTabExtension); + util.extend(HttpPort, TypeTabExtension); - HttpPort.prototype.update = function (restData) - { - TypeTabExtension.prototype.update.call(this, restData); - } + HttpPort.prototype.update = function (restData) + { + TypeTabExtension.prototype.update.call(this, restData); + } - return HttpPort; - }); + return HttpPort; + }); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js Mon May 2 15:57:52 2016 @@ -37,190 +37,200 @@ define(["qpid/common/util", "dojox/validate/us", "dojox/validate/web", "dojo/domReady!"], - function (util, declare, array, domConstruct, win, query, json, _WidgetBase, _OnDijitClickMixin, _TemplatedMixin, _WidgetsInTemplateMixin, registry, template, entities) - { + function (util, + declare, + array, + domConstruct, + win, + query, + json, + _WidgetBase, + _OnDijitClickMixin, + _TemplatedMixin, + _WidgetsInTemplateMixin, + registry, + template, + entities) + { - return declare("qpid.preferencesprovider.PreferencesProviderForm", - [_WidgetBase, _OnDijitClickMixin, _TemplatedMixin, _WidgetsInTemplateMixin], - { + return declare("qpid.preferencesprovider.PreferencesProviderForm", + [_WidgetBase, _OnDijitClickMixin, _TemplatedMixin, _WidgetsInTemplateMixin], + { - templateString: template, - domNode: null, - preferencesProviderForm: null, - preferencesProviderNameWidget: null, - preferencesProviderTypeWidget: null, - preferencesProviderTypeFieldsContainer: null, - metadata: null, + templateString: template, + domNode: null, + preferencesProviderForm: null, + preferencesProviderNameWidget: null, + preferencesProviderTypeWidget: null, + preferencesProviderTypeFieldsContainer: null, + metadata: null, - 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); - var that = this; + 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); + var that = this; - this.preferencesProviderNameWidget.set("regExpGen", util.nameOrContextVarRegexp); + this.preferencesProviderNameWidget.set("regExpGen", util.nameOrContextVarRegexp); - if (this.metadata) - { - setMetadata(this.metadata); - } - this.preferencesProviderTypeWidget.on("change", function (type) - { - that._preferencesProviderTypeChanged(type); - }); - this.preferencesProviderForm.on("submit", function () - { - return false; - }) - }, - reset: function () - { - this.data = null; - this.preferencesProviderForm.reset(); - this.preferencesProviderTypeWidget.set("value", "None"); - }, - submit: function (submitFunction, providerNotDefinedCallback) - { - if (this.preferencesProviderTypeWidget.get("value") != "None") - { - var preferencesProviderData = util.getFormWidgetValues(this.preferencesProviderForm, - this.data) - submitFunction(preferencesProviderData); - } - else - { - providerNotDefinedCallback(); - } - }, - getPreferencesProviderName: function () - { - return this.preferencesProviderNameWidget.get("value"); - }, - setPreferencesProviderName: function (name) - { - if (!(this.data && this.data.name)) - { - this.preferencesProviderNameWidget.set("value", name); - } - }, - setMetadata: function (metadata) - { - this.metadata = metadata; - var supportedPreferencesProviderTypes = metadata.getTypesForCategory( - "PreferencesProvider"); - supportedPreferencesProviderTypes.sort(); - supportedPreferencesProviderTypes.splice(0, 0, "None"); - var preferencesProviderTypeStore = util.makeTypeStore( - supportedPreferencesProviderTypes); - this.preferencesProviderTypeWidget.set("store", preferencesProviderTypeStore); - }, - validate: function () - { - return this.preferencesProviderForm.validate(); - }, - setData: function (data) - { - this._load(data); - }, - _load: function (data) - { - data = data || {} - this.data = data; - this.preferencesProviderNameWidget.set("value", data.name); - if (data.type == this.preferencesProviderTypeWidget.get("value")) - { - // re-create UI anyway - this._preferencesProviderTypeChanged(data.type); - } - else - { - this.preferencesProviderTypeWidget.set("value", data.type); - } - }, - _preferencesProviderTypeChanged: function (type) - { - var typeFieldsContainer = this.preferencesProviderTypeFieldsContainer; - var widgets = registry.findWidgets(typeFieldsContainer); - array.forEach(widgets, function (item) - { - item.destroyRecursive(); - }); - domConstruct.empty(typeFieldsContainer); - this._toggleWidgets(type); - if (type) - { - if (type == "None") - { - this.preferencesProviderNameWidget.set("value", ""); - } - else - { - var that = this; - require(["qpid/management/preferencesprovider/" + type.toLowerCase() - + "/add"], function (typeUI) - { - try - { - typeUI.show({ - containerNode: typeFieldsContainer, - parent: that, - data: that.data - }); - if (that.metadata) - { - util.applyMetadataToWidgets(typeFieldsContainer, - "PreferencesProvider", - type, - that.metadata); - } - } - catch (e) - { - console.warn(e); - } - }); - } - } - }, - _toggleWidgets: function (type) - { - if (this.disabled) - { - this.preferencesProviderNameWidget.set("disabled", true); - this.preferencesProviderTypeWidget.set("disabled", true); - } - else - { - if (this.data) - { - // editing - this.preferencesProviderNameWidget.set("disabled", true); - this.preferencesProviderTypeWidget.set("disabled", true); - } - else - { - this.preferencesProviderNameWidget.set("disabled", !type || type == "None"); - this.preferencesProviderTypeWidget.set("disabled", false); - } - } - }, - _setDisabledAttr: function (disabled) - { - this.inherited(arguments); - this.disabled = disabled; - if (disabled) - { - this.reset(); - } - else - { - this._toggleWidgets(this.preferencesProviderTypeWidget.value); - } - } - }); - }); + if (this.metadata) + { + setMetadata(this.metadata); + } + this.preferencesProviderTypeWidget.on("change", function (type) + { + that._preferencesProviderTypeChanged(type); + }); + this.preferencesProviderForm.on("submit", function () + { + return false; + }) + }, + reset: function () + { + this.data = null; + this.preferencesProviderForm.reset(); + this.preferencesProviderTypeWidget.set("value", "None"); + }, + submit: function (submitFunction, providerNotDefinedCallback) + { + if (this.preferencesProviderTypeWidget.get("value") != "None") + { + var preferencesProviderData = util.getFormWidgetValues(this.preferencesProviderForm, this.data) + submitFunction(preferencesProviderData); + } + else + { + providerNotDefinedCallback(); + } + }, + getPreferencesProviderName: function () + { + return this.preferencesProviderNameWidget.get("value"); + }, + setPreferencesProviderName: function (name) + { + if (!(this.data && this.data.name)) + { + this.preferencesProviderNameWidget.set("value", name); + } + }, + setMetadata: function (metadata) + { + this.metadata = metadata; + var supportedPreferencesProviderTypes = metadata.getTypesForCategory("PreferencesProvider"); + supportedPreferencesProviderTypes.sort(); + supportedPreferencesProviderTypes.splice(0, 0, "None"); + var preferencesProviderTypeStore = util.makeTypeStore(supportedPreferencesProviderTypes); + this.preferencesProviderTypeWidget.set("store", preferencesProviderTypeStore); + }, + validate: function () + { + return this.preferencesProviderForm.validate(); + }, + setData: function (data) + { + this._load(data); + }, + _load: function (data) + { + data = data || {} + this.data = data; + this.preferencesProviderNameWidget.set("value", data.name); + if (data.type == this.preferencesProviderTypeWidget.get("value")) + { + // re-create UI anyway + this._preferencesProviderTypeChanged(data.type); + } + else + { + this.preferencesProviderTypeWidget.set("value", data.type); + } + }, + _preferencesProviderTypeChanged: function (type) + { + var typeFieldsContainer = this.preferencesProviderTypeFieldsContainer; + var widgets = registry.findWidgets(typeFieldsContainer); + array.forEach(widgets, function (item) + { + item.destroyRecursive(); + }); + domConstruct.empty(typeFieldsContainer); + this._toggleWidgets(type); + if (type) + { + if (type == "None") + { + this.preferencesProviderNameWidget.set("value", ""); + } + else + { + var that = this; + require(["qpid/management/preferencesprovider/" + type.toLowerCase() + "/add"], + function (typeUI) + { + try + { + typeUI.show({ + containerNode: typeFieldsContainer, + parent: that, + data: that.data + }); + if (that.metadata) + { + util.applyMetadataToWidgets(typeFieldsContainer, + "PreferencesProvider", + type, + that.metadata); + } + } + catch (e) + { + console.warn(e); + } + }); + } + } + }, + _toggleWidgets: function (type) + { + if (this.disabled) + { + this.preferencesProviderNameWidget.set("disabled", true); + this.preferencesProviderTypeWidget.set("disabled", true); + } + else + { + if (this.data) + { + // editing + this.preferencesProviderNameWidget.set("disabled", true); + this.preferencesProviderTypeWidget.set("disabled", true); + } + else + { + this.preferencesProviderNameWidget.set("disabled", !type || type == "None"); + this.preferencesProviderTypeWidget.set("disabled", false); + } + } + }, + _setDisabledAttr: function (disabled) + { + this.inherited(arguments); + this.disabled = disabled; + if (disabled) + { + this.reset(); + } + else + { + this._toggleWidgets(this.preferencesProviderTypeWidget.value); + } + } + }); + }); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/filesystempreferences/show.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/filesystempreferences/show.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/filesystempreferences/show.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/filesystempreferences/show.js Mon May 2 15:57:52 2016 @@ -19,32 +19,32 @@ * */ define(["dojo/_base/xhr", "dojo/parser", "dojo/string", "dojox/html/entities", "dojo/query", "dojo/domReady!"], - function (xhr, parser, json, entities, query) - { + function (xhr, parser, json, entities, query) + { - function FileSystemPreferences(containerNode) - { - var that = this; - xhr.get({ - url: "preferencesprovider/filesystempreferences/show.html", - sync: true, - load: function (template) - { - containerNode.innerHTML = template; - parser.parse(containerNode).then(function (instances) - { - that.preferencesProviderPath = query( - ".fileSystemPreferencesProviderPath", - containerNode)[0]; - }); - } - }); - } + function FileSystemPreferences(containerNode) + { + var that = this; + xhr.get({ + url: "preferencesprovider/filesystempreferences/show.html", + sync: true, + load: function (template) + { + containerNode.innerHTML = template; + parser.parse(containerNode) + .then(function (instances) + { + that.preferencesProviderPath = + query(".fileSystemPreferencesProviderPath", containerNode)[0]; + }); + } + }); + } - FileSystemPreferences.prototype.update = function (data) - { - this.preferencesProviderPath.innerHTML = entities.encode(String(data["path"])); - }; + FileSystemPreferences.prototype.update = function (data) + { + this.preferencesProviderPath.innerHTML = entities.encode(String(data["path"])); + }; - return FileSystemPreferences; - }); + return FileSystemPreferences; + }); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
