Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js Mon May 2 15:57:52 2016 @@ -29,10 +29,10 @@ define(["dojo/dom", "qpid/common/util", "dojo/text!addExchange.html", "dijit/form/NumberSpinner", // required by the form - /* dojox/ validate resources */ + /* dojox/ validate resources */ "dojox/validate/us", "dojox/validate/web", - /* basic dijit classes */ + /* basic dijit classes */ "dijit/Dialog", "dijit/form/CheckBox", "dijit/form/Textarea", @@ -45,80 +45,82 @@ define(["dojo/dom", "dijit/form/RadioButton", "dijit/form/Form", "dijit/form/DateTextBox", - /* basic dojox classes */ + /* basic dojox classes */ "dojox/form/BusyButton", "dojox/form/CheckedMultiSelect", "dojo/domReady!"], function (dom, construct, win, registry, parser, array, event, json, util, template) - { +{ - var addExchange = {}; + var addExchange = {}; - var node = construct.create("div", null, win.body(), "last"); + var node = construct.create("div", null, win.body(), "last"); - var theForm; - node.innerHTML = template; - addExchange.dialogNode = dom.byId("addExchange"); - parser.instantiate([addExchange.dialogNode]); - - theForm = registry.byId("formAddExchange"); - array.forEach(theForm.getDescendants(), function (widget) - { - if (widget.name === "type") - { - widget.on("change", function (isChecked) - { - - var obj = registry.byId(widget.id + ":fields"); - if (obj) - { - if (isChecked) - { - obj.domNode.style.display = "block"; - obj.resize(); - } - else - { - obj.domNode.style.display = "none"; - obj.resize(); - } - } - }) - } - - }); - - theForm.on("submit", function (e) - { - - event.stop(e); - if (theForm.validate()) - { - var newExchange = util.getFormWidgetValues(theForm, null); - var that = this; - addExchange.management.create("exchange", addExchange.modelObj, newExchange).then(function (x) - { - registry.byId( - "addExchange") - .hide(); - }); - return false; - - } - else - { - alert('Form contains invalid data. Please correct first'); - return false; - } - - }); - - addExchange.show = function (management, modelObj) - { - addExchange.management = management - addExchange.modelObj = modelObj; - registry.byId("formAddExchange").reset(); - registry.byId("addExchange").show(); - }; + var theForm; + node.innerHTML = template; + addExchange.dialogNode = dom.byId("addExchange"); + parser.instantiate([addExchange.dialogNode]); + + theForm = registry.byId("formAddExchange"); + array.forEach(theForm.getDescendants(), function (widget) + { + if (widget.name === "type") + { + widget.on("change", function (isChecked) + { + + var obj = registry.byId(widget.id + ":fields"); + if (obj) + { + if (isChecked) + { + obj.domNode.style.display = "block"; + obj.resize(); + } + else + { + obj.domNode.style.display = "none"; + obj.resize(); + } + } + }) + } + + }); + + theForm.on("submit", function (e) + { + + event.stop(e); + if (theForm.validate()) + { + var newExchange = util.getFormWidgetValues(theForm, null); + var that = this; + addExchange.management.create("exchange", addExchange.modelObj, newExchange) + .then(function (x) + { + registry.byId("addExchange") + .hide(); + }); + return false; + + } + else + { + alert('Form contains invalid data. Please correct first'); + return false; + } + + }); + + addExchange.show = function (management, modelObj) + { + addExchange.management = management + addExchange.modelObj = modelObj; + registry.byId("formAddExchange") + .reset(); + registry.byId("addExchange") + .show(); + }; - return addExchange; - }); \ No newline at end of file + return addExchange; +}); \ No newline at end of file
Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addGroupProvider.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addGroupProvider.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addGroupProvider.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addGroupProvider.js Mon May 2 15:57:52 2016 @@ -42,201 +42,196 @@ define(["dojo/dom", "dijit/layout/ContentPane", "dojox/layout/TableContainer", "dojo/domReady!"], function (dom, construct, registry, parser, array, event, lang, json, util, template) - { +{ - var addGroupProvider = { - 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.groupProviderName = registry.byId("addGroupProvider.name"); - this.groupProviderName.set("regExpGen", util.nameOrContextVarRegexp); - - this.dialog = registry.byId("addGroupProvider"); - this.addButton = registry.byId("addGroupProvider.addButton"); - this.cancelButton = registry.byId("addGroupProvider.cancelButton"); - this.cancelButton.on("click", function (e) - { - that._cancel(e); - }); - this.addButton.on("click", function (e) - { - that._add(e); - }); - - this.groupProviderTypeFieldsContainer = dom.byId("addGroupProvider.typeFields"); - this.groupProviderForm = registry.byId("addGroupProvider.form"); - - this.groupProviderType = registry.byId("addGroupProvider.type"); - this.groupProviderType.on("change", function (type) - { - that._groupProviderTypeChanged(type); - }); - this.context = registry.byId("addGroupProvider.context"); - }, - show: function (management, modelObj, effectiveData) - { - this.management = management; - this.modelObj = modelObj; - this.groupProviderForm.reset(); - - var supportedTypes = management.metadata.getTypesForCategory("GroupProvider"); - supportedTypes.sort(); - var supportedTypesStore = util.makeTypeStore(supportedTypes); - this.groupProviderType.set("store", supportedTypesStore); - - if (effectiveData) - { - this._destroyTypeFields(this.containerNode); - var that = this; - management.load(modelObj, - { - actuals: true, - depth: 0 - }).then(function (data) - { - var actualData = data[0]; - that.initialData = lang.clone(actualData); - that._initFields(actualData); - - that.groupProviderName.set("disabled", true); - that.groupProviderType.set("disabled", true); - that.dialog.set("title", - "Edit Group Provider - " + effectiveData.name); - - util.setContextData(that.context, - management, - modelObj, - actualData, - effectiveData, - function () - { - that.dialog.show(); - }); - }); - } - else - { - this.initialData = null; - this.groupProviderName.set("disabled", false); - this.groupProviderType.set("disabled", false); - this.dialog.set("title", "Add Group Provider"); - util.setToBrokerEffectiveContext(this.context, - management, - lang.hitch(this.dialog, this.dialog.show)); - } - - }, - _initFields: function (data) - { - var type = data["type"]; - var attributes = this.management.metadata.getMetaData("GroupProvider", type).attributes; - for (var name in attributes) - { - var widget = registry.byId("addGroupProvider." + name); - if (widget) - { - widget.set("value", data[name]); - } - } - }, - _cancel: function (e) - { - event.stop(e); - this.dialog.hide(); - }, - _add: function (e) - { - event.stop(e); - this._submit(); - }, - _submit: function () - { - if (this.groupProviderForm.validate()) - { - var groupProviderData = util.getFormWidgetValues(this.groupProviderForm, this.initialData); - var context = this.context.get("value"); - if (context && (!this.initialData || !util.equals(context, this.initialData.context))) - { - groupProviderData["context"] = context; - } - var that = this; - - if (this.initialData) - { - // update request - this.management.update(this.modelObj, groupProviderData).then(function (x) - { - that.dialog.hide(); - }); - } - else - { - this.management.create("groupprovider", this.modelObj, groupProviderData).then(function (x) - { - that.dialog.hide(); - }); - } - } - else - { - alert('Form contains invalid data. Please correct first'); - } - }, - _groupProviderTypeChanged: function (type) - { - this._destroyTypeFields(this.groupProviderTypeFieldsContainer); - if (type) - { - var that = this; - require(["qpid/management/groupprovider/" + type.toLowerCase() + "/add"], function (typeUI) - { - try - { - typeUI.show({ - containerNode: that.groupProviderTypeFieldsContainer, - parent: that, - data: that.initialData - }); - util.applyMetadataToWidgets(that.groupProviderTypeFieldsContainer, - "GroupProvider", - type, - that.management.metadata); - } - catch (e) - { - console.warn(e); - } - }); - } - }, - _destroyTypeFields: function (typeFieldsContainer) - { - var widgets = registry.findWidgets(typeFieldsContainer); - array.forEach(widgets, function (item) - { - item.destroyRecursive(); - }); - construct.empty(typeFieldsContainer); - } - }; - - try - { - addGroupProvider.init(); - } - catch (e) - { - console.warn(e); - } - return addGroupProvider; + var addGroupProvider = { + 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.groupProviderName = registry.byId("addGroupProvider.name"); + this.groupProviderName.set("regExpGen", util.nameOrContextVarRegexp); + + this.dialog = registry.byId("addGroupProvider"); + this.addButton = registry.byId("addGroupProvider.addButton"); + this.cancelButton = registry.byId("addGroupProvider.cancelButton"); + this.cancelButton.on("click", function (e) + { + that._cancel(e); + }); + this.addButton.on("click", function (e) + { + that._add(e); + }); + + this.groupProviderTypeFieldsContainer = dom.byId("addGroupProvider.typeFields"); + this.groupProviderForm = registry.byId("addGroupProvider.form"); + + this.groupProviderType = registry.byId("addGroupProvider.type"); + this.groupProviderType.on("change", function (type) + { + that._groupProviderTypeChanged(type); + }); + this.context = registry.byId("addGroupProvider.context"); + }, + show: function (management, modelObj, effectiveData) + { + this.management = management; + this.modelObj = modelObj; + this.groupProviderForm.reset(); + + var supportedTypes = management.metadata.getTypesForCategory("GroupProvider"); + supportedTypes.sort(); + var supportedTypesStore = util.makeTypeStore(supportedTypes); + this.groupProviderType.set("store", supportedTypesStore); + + if (effectiveData) + { + this._destroyTypeFields(this.containerNode); + var that = this; + management.load(modelObj, { + actuals: true, + depth: 0 + }) + .then(function (data) + { + var actualData = data[0]; + that.initialData = lang.clone(actualData); + that._initFields(actualData); + + that.groupProviderName.set("disabled", true); + that.groupProviderType.set("disabled", true); + that.dialog.set("title", "Edit Group Provider - " + effectiveData.name); + + util.setContextData(that.context, management, modelObj, actualData, effectiveData, function () + { + that.dialog.show(); + }); + }); + } + else + { + this.initialData = null; + this.groupProviderName.set("disabled", false); + this.groupProviderType.set("disabled", false); + this.dialog.set("title", "Add Group Provider"); + util.setToBrokerEffectiveContext(this.context, management, lang.hitch(this.dialog, this.dialog.show)); + } + + }, + _initFields: function (data) + { + var type = data["type"]; + var attributes = this.management.metadata.getMetaData("GroupProvider", type).attributes; + for (var name in attributes) + { + var widget = registry.byId("addGroupProvider." + name); + if (widget) + { + widget.set("value", data[name]); + } + } + }, + _cancel: function (e) + { + event.stop(e); + this.dialog.hide(); + }, + _add: function (e) + { + event.stop(e); + this._submit(); + }, + _submit: function () + { + if (this.groupProviderForm.validate()) + { + var groupProviderData = util.getFormWidgetValues(this.groupProviderForm, this.initialData); + var context = this.context.get("value"); + if (context && (!this.initialData || !util.equals(context, this.initialData.context))) + { + groupProviderData["context"] = context; + } + var that = this; + + if (this.initialData) + { + // update request + this.management.update(this.modelObj, groupProviderData) + .then(function (x) + { + that.dialog.hide(); + }); + } + else + { + this.management.create("groupprovider", this.modelObj, groupProviderData) + .then(function (x) + { + that.dialog.hide(); + }); + } + } + else + { + alert('Form contains invalid data. Please correct first'); + } + }, + _groupProviderTypeChanged: function (type) + { + this._destroyTypeFields(this.groupProviderTypeFieldsContainer); + if (type) + { + var that = this; + require(["qpid/management/groupprovider/" + type.toLowerCase() + "/add"], function (typeUI) + { + try + { + typeUI.show({ + containerNode: that.groupProviderTypeFieldsContainer, + parent: that, + data: that.initialData + }); + util.applyMetadataToWidgets(that.groupProviderTypeFieldsContainer, + "GroupProvider", + type, + that.management.metadata); + } + catch (e) + { + console.warn(e); + } + }); + } + }, + _destroyTypeFields: function (typeFieldsContainer) + { + var widgets = registry.findWidgets(typeFieldsContainer); + array.forEach(widgets, function (item) + { + item.destroyRecursive(); + }); + construct.empty(typeFieldsContainer); + } + }; + + try + { + addGroupProvider.init(); + } + catch (e) + { + console.warn(e); + } + return addGroupProvider; - }); \ No newline at end of file +}); \ No newline at end of file Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addLogInclusionRule.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addLogInclusionRule.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addLogInclusionRule.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addLogInclusionRule.js Mon May 2 15:57:52 2016 @@ -43,193 +43,194 @@ define(["dojo/_base/lang", "dijit/layout/ContentPane", "dojox/layout/TableContainer", "dojo/domReady!"], function (lang, dom, construct, registry, parser, memory, array, event, json, util, template) - { - var addLogInclusionRule = { - 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.name = registry.byId("addLogInclusionRule.name"); - this.name.set("regExpGen", util.nameOrContextVarRegexp); - - this.dialog = registry.byId("addLogInclusionRule"); - this.addButton = registry.byId("addLogInclusionRule.addButton"); - this.cancelButton = registry.byId("addLogInclusionRule.cancelButton"); - this.cancelButton.on("click", function (e) - { - that._cancel(e); - }); - this.addButton.on("click", function (e) - { - that._add(e); - }); - - this.typeFieldsContainer = dom.byId("addLogInclusionRule.typeFields"); - this.form = registry.byId("addLogInclusionRule.form"); - this.form.on("submit", function () - { - return false; - }); - - this.logInclusionRuleType = registry.byId("addLogInclusionRule.type"); - this.logInclusionRuleType.on("change", function (type) - { - that._typeChanged(type); - }); - - this.durable = registry.byId("addLogInclusionRule.durable"); - this.allFieldsContainer = dom.byId("addLogInclusionRule.contentPane"); - }, - show: function (management, modelObj, category, actualData) - { - this.management = management; - this.modelObj = modelObj; - var metadata = management.metadata; - this.category = category; - this.configured = false; - this._destroyTypeFields(this.typeFieldsContainer); - this.logInclusionRuleType.set("store", - util.makeTypeStoreFromMetadataByCategory(management.metadata, - category)); - this.form.reset(); - - this.initialData = actualData; - this.isNew = !actualData; - - this.name.set("disabled", !this.isNew); - this.logInclusionRuleType.set("disabled", !this.isNew); - this.durable.set("disabled", !this.isNew); - this.dialog.set("title", - this.isNew ? "Add Log Inclusion Rule" : "Edit Log Inclusion Rule - " - + actualData.name); - - if (actualData) - { - this._configure(actualData.type); - } - - this.dialog.show(); - }, - _cancel: function (e) - { - event.stop(e); - this._destroyTypeFields(this.typeFieldsContainer); - this.dialog.hide(); - }, - _add: function (e) - { - event.stop(e); - this._submit(); - }, - _submit: function () - { - if (this.form.validate()) - { - var that = this; - var formData = util.getFormWidgetValues(this.form, this.initialData); - - if (this.isNew) - { - this.management.create(this.category, this.modelObj, formData).then(function (x) - { - that.dialog.hide(); - }); - } - else - { - this.management.update(this.modelObj, formData).then(function (x) - { - that.dialog.hide(); - }); - } - } - else - { - alert('Form contains invalid data. Please correct first'); - } - }, - _destroyTypeFields: function (typeFieldsContainer) - { - var widgets = registry.findWidgets(typeFieldsContainer); - array.forEach(widgets, function (item) - { - item.destroyRecursive(); - }); - construct.empty(typeFieldsContainer); - }, - _typeChanged: function (type) - { - this._destroyTypeFields(this.typeFieldsContainer); - - if (type) - { - this._configure(type); - var that = this; - require(["qpid/management/loginclusionrule/" + this.category.toLowerCase() + "/" - + type.toLowerCase() + "/add"], function (typeUI) - { - try - { - var metadata = that.management.metadata; - var promise = typeUI.show({ - containerNode: that.typeFieldsContainer, - data: that.initialData, - metadata: metadata, - category: that.category, - type: type - }); - if (promise) - { - promise.then(function (instances) - { - util.applyToWidgets(that.typeFieldsContainer, - that.category, - type, - that.initialData, - metadata); - if (!that.isNew) - { - util.disableWidgetsForImmutableFields(that.allFieldsContainer, - that.category, - type, - metadata); - } - }); - } - } - catch (e) - { - console.warn(e); - } - }); - } - }, - _configure: function (type) - { - if (!this.configured) - { - var metadata = this.management.metadata; - util.applyToWidgets(this.allFieldsContainer, this.category, type, this.initialData, metadata); - this.configured = true; - } - } - }; - - try - { - addLogInclusionRule.init(); - } - catch (e) - { - console.warn(e); - } - return addLogInclusionRule; - }); +{ + var addLogInclusionRule = { + 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.name = registry.byId("addLogInclusionRule.name"); + this.name.set("regExpGen", util.nameOrContextVarRegexp); + + this.dialog = registry.byId("addLogInclusionRule"); + this.addButton = registry.byId("addLogInclusionRule.addButton"); + this.cancelButton = registry.byId("addLogInclusionRule.cancelButton"); + this.cancelButton.on("click", function (e) + { + that._cancel(e); + }); + this.addButton.on("click", function (e) + { + that._add(e); + }); + + this.typeFieldsContainer = dom.byId("addLogInclusionRule.typeFields"); + this.form = registry.byId("addLogInclusionRule.form"); + this.form.on("submit", function () + { + return false; + }); + + this.logInclusionRuleType = registry.byId("addLogInclusionRule.type"); + this.logInclusionRuleType.on("change", function (type) + { + that._typeChanged(type); + }); + + this.durable = registry.byId("addLogInclusionRule.durable"); + this.allFieldsContainer = dom.byId("addLogInclusionRule.contentPane"); + }, + show: function (management, modelObj, category, actualData) + { + this.management = management; + this.modelObj = modelObj; + var metadata = management.metadata; + this.category = category; + this.configured = false; + this._destroyTypeFields(this.typeFieldsContainer); + this.logInclusionRuleType.set("store", + util.makeTypeStoreFromMetadataByCategory(management.metadata, category)); + this.form.reset(); + + this.initialData = actualData; + this.isNew = !actualData; + + this.name.set("disabled", !this.isNew); + this.logInclusionRuleType.set("disabled", !this.isNew); + this.durable.set("disabled", !this.isNew); + this.dialog.set("title", + this.isNew ? "Add Log Inclusion Rule" : "Edit Log Inclusion Rule - " + actualData.name); + + if (actualData) + { + this._configure(actualData.type); + } + + this.dialog.show(); + }, + _cancel: function (e) + { + event.stop(e); + this._destroyTypeFields(this.typeFieldsContainer); + this.dialog.hide(); + }, + _add: function (e) + { + event.stop(e); + this._submit(); + }, + _submit: function () + { + if (this.form.validate()) + { + var that = this; + var formData = util.getFormWidgetValues(this.form, this.initialData); + + if (this.isNew) + { + this.management.create(this.category, this.modelObj, formData) + .then(function (x) + { + that.dialog.hide(); + }); + } + else + { + this.management.update(this.modelObj, formData) + .then(function (x) + { + that.dialog.hide(); + }); + } + } + else + { + alert('Form contains invalid data. Please correct first'); + } + }, + _destroyTypeFields: function (typeFieldsContainer) + { + var widgets = registry.findWidgets(typeFieldsContainer); + array.forEach(widgets, function (item) + { + item.destroyRecursive(); + }); + construct.empty(typeFieldsContainer); + }, + _typeChanged: function (type) + { + this._destroyTypeFields(this.typeFieldsContainer); + + if (type) + { + this._configure(type); + var that = this; + require(["qpid/management/loginclusionrule/" + this.category.toLowerCase() + "/" + type.toLowerCase() + + "/add"], function (typeUI) + { + try + { + var metadata = that.management.metadata; + var promise = typeUI.show({ + containerNode: that.typeFieldsContainer, + data: that.initialData, + metadata: metadata, + category: that.category, + type: type + }); + if (promise) + { + promise.then(function (instances) + { + util.applyToWidgets(that.typeFieldsContainer, + that.category, + type, + that.initialData, + metadata); + if (!that.isNew) + { + util.disableWidgetsForImmutableFields(that.allFieldsContainer, + that.category, + type, + metadata); + } + }); + } + } + catch (e) + { + console.warn(e); + } + }); + } + }, + _configure: function (type) + { + if (!this.configured) + { + var metadata = this.management.metadata; + util.applyToWidgets(this.allFieldsContainer, this.category, type, this.initialData, metadata); + this.configured = true; + } + } + }; + + try + { + addLogInclusionRule.init(); + } + catch (e) + { + console.warn(e); + } + return addLogInclusionRule; +}); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addLogger.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addLogger.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addLogger.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addLogger.js Mon May 2 15:57:52 2016 @@ -44,234 +44,236 @@ define(["dojo/_base/lang", "dijit/layout/ContentPane", "dojox/layout/TableContainer", "dojo/domReady!"], - function (lang, dom, construct, domStyle, registry, parser, memory, array, event, json, util, template) - { - var addLogger = { - 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.name = registry.byId("addLogger.name"); - this.name.set("regExpGen", util.nameOrContextVarRegexp); - - this.dialog = registry.byId("addLogger"); - this.addButton = registry.byId("addLogger.addButton"); - this.cancelButton = registry.byId("addLogger.cancelButton"); - this.cancelButton.on("click", function (e) - { - that._cancel(e); - }); - this.addButton.on("click", function (e) - { - that._add(e); - }); - - this.typeFieldsContainer = dom.byId("addLogger.typeFields"); - this.form = registry.byId("addLogger.form"); - this.form.on("submit", function () - { - return false; - }); - - this.loggerType = registry.byId("addLogger.type"); - this.loggerType.on("change", function (type) - { - that._typeChanged(type); - }); - - this.durable = registry.byId("addLogger.durable"); - - this.categoryFieldsContainer = dom.byId("addLogger.categoryFields"); - this.allFieldsContainer = dom.byId("addLogger.contentPane"); - }, - show: function (management, modelObj, category, actualData) - { - this.management = management; - this.modelObj = modelObj; - this.category = category; - this.configured = false; - this._destroyTypeFields(this.typeFieldsContainer); - this._destroyTypeFields(this.categoryFieldsContainer); - this.form.reset(); - this.loggerType.set("store", - util.makeTypeStoreFromMetadataByCategory(management.metadata, category)); - this.initialData = actualData; - this.isNew = !actualData; - this.name.set("disabled", !this.isNew); - this.loggerType.set("disabled", !this.isNew); - this.durable.set("disabled", !this.isNew); - this.dialog.set("title", this.isNew ? "Add Logger" : "Edit Logger - " + actualData.name); - - if (actualData) - { - this._configure(actualData.type); - } - - var brokerLoggerEditWarningNode = dom.byId("brokerLoggerEditWarning"); - var virtualHostlLoggerEditWarningNode = dom.byId("virtualHostlLoggerEditWarning"); - domStyle.set(brokerLoggerEditWarningNode, - "display", - !this.isNew && this.category == "BrokerLogger" ? "block" : "none"); - domStyle.set(virtualHostlLoggerEditWarningNode, - "display", - !this.isNew && this.category == "VirtualHostLogger" ? "block" : "none"); - - this._loadCategoryUserInterfacesAndShowDialog(actualData); - }, - hide: function () - { - this._destroyTypeFields(this.categoryFieldsContainer); - this._destroyTypeFields(this.typeFieldsContainer); - this.dialog.hide(); - }, - _cancel: function (e) - { - event.stop(e); - this.hide(); - }, - _add: function (e) - { - event.stop(e); - this._submit(); - }, - _submit: function () - { - if (this.form.validate()) - { - var excludedData = this.initialData - || this.management.metadata.getDefaultValueForType(this.category, - this.loggerType.get("value")); - var formData = util.getFormWidgetValues(this.form, excludedData); - var that = this; - if (this.isNew) - { - this.management.create(this.category, this.modelObj, formData).then(function () - { - that.hide(); - }); - } - else - { - this.management.update(this.modelObj, formData).then(function () - { - that.hide(); - }); - } - } - else - { - alert('Form contains invalid data. Please correct first'); - } - }, - _destroyTypeFields: function (typeFieldsContainer) - { - var widgets = registry.findWidgets(typeFieldsContainer); - array.forEach(widgets, function (item) - { - item.destroyRecursive(); - }); - construct.empty(typeFieldsContainer); - }, - _typeChanged: function (type) - { - this._destroyTypeFields(this.typeFieldsContainer); - - if (type) - { - this._configure(type); - var that = this; - require(["qpid/management/logger/" + this.category.toLowerCase() + "/" + type.toLowerCase() - + "/add"], function (typeUI) - { - try - { - var promise = typeUI.show({ - containerNode: that.typeFieldsContainer, - data: that.initialData, - metadata: that.management.metadata, - category: that.category, - type: type - }); - if (promise) - { - promise.then(function (instances) - { - util.applyToWidgets(that.typeFieldsContainer, - that.category, - type, - that.initialData, - that.management.metadata); - }); - } - } - catch (e) - { - console.warn(e); - } - }); - } - }, - _configure: function (type) - { - if (!this.configured) - { - var metadata = this.management.metadata; - util.applyToWidgets(this.allFieldsContainer, this.category, type, this.initialData, metadata); - this.configured = true; - } - }, - _loadCategoryUserInterfacesAndShowDialog: function (actualData) - { - var that = this; - var node = construct.create("div", {}, this.categoryFieldsContainer); - require(["qpid/management/logger/" + this.category.toLowerCase() + "/add"], function (categoryUI) - { - try - { - var promise = categoryUI.show({ - containerNode: node, - data: actualData - }); - if (actualData) - { - promise.then(function (instances) - { - util.applyToWidgets(node, - that.category, - actualData.type, - actualData, - that.management.metadata); - that.dialog.show(); - }); - } - else - { - that.dialog.show(); - } - } - catch (e) - { - console.error(e); - } - }); - } - }; - - try - { - addLogger.init(); - } - catch (e) - { - console.warn(e); - } - return addLogger; - }); + function (lang, dom, construct, domStyle, registry, parser, memory, array, event, json, util, template) + { + var addLogger = { + 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.name = registry.byId("addLogger.name"); + this.name.set("regExpGen", util.nameOrContextVarRegexp); + + this.dialog = registry.byId("addLogger"); + this.addButton = registry.byId("addLogger.addButton"); + this.cancelButton = registry.byId("addLogger.cancelButton"); + this.cancelButton.on("click", function (e) + { + that._cancel(e); + }); + this.addButton.on("click", function (e) + { + that._add(e); + }); + + this.typeFieldsContainer = dom.byId("addLogger.typeFields"); + this.form = registry.byId("addLogger.form"); + this.form.on("submit", function () + { + return false; + }); + + this.loggerType = registry.byId("addLogger.type"); + this.loggerType.on("change", function (type) + { + that._typeChanged(type); + }); + + this.durable = registry.byId("addLogger.durable"); + + this.categoryFieldsContainer = dom.byId("addLogger.categoryFields"); + this.allFieldsContainer = dom.byId("addLogger.contentPane"); + }, + show: function (management, modelObj, category, actualData) + { + this.management = management; + this.modelObj = modelObj; + this.category = category; + this.configured = false; + this._destroyTypeFields(this.typeFieldsContainer); + this._destroyTypeFields(this.categoryFieldsContainer); + this.form.reset(); + this.loggerType.set("store", util.makeTypeStoreFromMetadataByCategory(management.metadata, category)); + this.initialData = actualData; + this.isNew = !actualData; + this.name.set("disabled", !this.isNew); + this.loggerType.set("disabled", !this.isNew); + this.durable.set("disabled", !this.isNew); + this.dialog.set("title", this.isNew ? "Add Logger" : "Edit Logger - " + actualData.name); + + if (actualData) + { + this._configure(actualData.type); + } + + var brokerLoggerEditWarningNode = dom.byId("brokerLoggerEditWarning"); + var virtualHostlLoggerEditWarningNode = dom.byId("virtualHostlLoggerEditWarning"); + domStyle.set(brokerLoggerEditWarningNode, + "display", + !this.isNew && this.category == "BrokerLogger" ? "block" : "none"); + domStyle.set(virtualHostlLoggerEditWarningNode, + "display", + !this.isNew && this.category == "VirtualHostLogger" ? "block" : "none"); + + this._loadCategoryUserInterfacesAndShowDialog(actualData); + }, + hide: function () + { + this._destroyTypeFields(this.categoryFieldsContainer); + this._destroyTypeFields(this.typeFieldsContainer); + this.dialog.hide(); + }, + _cancel: function (e) + { + event.stop(e); + this.hide(); + }, + _add: function (e) + { + event.stop(e); + this._submit(); + }, + _submit: function () + { + if (this.form.validate()) + { + var excludedData = this.initialData + || this.management.metadata.getDefaultValueForType(this.category, + this.loggerType.get("value")); + var formData = util.getFormWidgetValues(this.form, excludedData); + var that = this; + if (this.isNew) + { + this.management.create(this.category, this.modelObj, formData) + .then(function () + { + that.hide(); + }); + } + else + { + this.management.update(this.modelObj, formData) + .then(function () + { + that.hide(); + }); + } + } + else + { + alert('Form contains invalid data. Please correct first'); + } + }, + _destroyTypeFields: function (typeFieldsContainer) + { + var widgets = registry.findWidgets(typeFieldsContainer); + array.forEach(widgets, function (item) + { + item.destroyRecursive(); + }); + construct.empty(typeFieldsContainer); + }, + _typeChanged: function (type) + { + this._destroyTypeFields(this.typeFieldsContainer); + + if (type) + { + this._configure(type); + var that = this; + require(["qpid/management/logger/" + this.category.toLowerCase() + "/" + type.toLowerCase() + + "/add"], function (typeUI) + { + try + { + var promise = typeUI.show({ + containerNode: that.typeFieldsContainer, + data: that.initialData, + metadata: that.management.metadata, + category: that.category, + type: type + }); + if (promise) + { + promise.then(function (instances) + { + util.applyToWidgets(that.typeFieldsContainer, + that.category, + type, + that.initialData, + that.management.metadata); + }); + } + } + catch (e) + { + console.warn(e); + } + }); + } + }, + _configure: function (type) + { + if (!this.configured) + { + var metadata = this.management.metadata; + util.applyToWidgets(this.allFieldsContainer, this.category, type, this.initialData, metadata); + this.configured = true; + } + }, + _loadCategoryUserInterfacesAndShowDialog: function (actualData) + { + var that = this; + var node = construct.create("div", {}, this.categoryFieldsContainer); + require(["qpid/management/logger/" + this.category.toLowerCase() + "/add"], function (categoryUI) + { + try + { + var promise = categoryUI.show({ + containerNode: node, + data: actualData + }); + if (actualData) + { + promise.then(function (instances) + { + util.applyToWidgets(node, + that.category, + actualData.type, + actualData, + that.management.metadata); + that.dialog.show(); + }); + } + else + { + that.dialog.show(); + } + } + catch (e) + { + console.error(e); + } + }); + } + }; + + try + { + addLogger.init(); + } + catch (e) + { + console.warn(e); + } + return addLogger; + }); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
