Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ContextVariablesEditor.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ContextVariablesEditor.js?rev=1741609&r1=1741608&r2=1741609&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ContextVariablesEditor.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ContextVariablesEditor.js Fri Apr 29 11:04:40 2016 @@ -18,8 +18,7 @@ * under the License. * */ -define([ - "qpid/common/util", +define(["qpid/common/util", "dojo/_base/declare", "dojo/_base/array", "dojo/_base/connect", @@ -40,434 +39,501 @@ define([ "dojox/validate/us", "dojox/validate/web", "dojo/domReady!"], -function (util, declare, array, connect, lang, domConstruct, parser, query, Memory, ObjectStore, _WidgetBase, registry, template) - { + function (util, declare, array, connect, lang, domConstruct, parser, query, Memory, ObjectStore, _WidgetBase, registry, template) + { - return declare("qpid.common.ContextVariablesEditor", [_WidgetBase], { + return declare("qpid.common.ContextVariablesEditor", [_WidgetBase], { - value: null, - effectiveValues: null, - inheritedActualValues: null, - domNode: null, - _grid: null, - _addButton: null, - _deleteButton: null, - _filterBox: null, - _nextGridItemId: 0, - _dynamicInheritedContext: {}, - - constructor: function(args) - { - this._args = args; - }, - - buildRendering: function() - { - this.domNode = domConstruct.create("div", {innerHTML: template}); - parser.parse(this.domNode); - }, - - postCreate: function() - { - this.inherited(arguments); - var that = this; - var gridNode = query(".grid", this.domNode)[0]; - var addButtonNode = query(".addButton", this.domNode)[0]; - var deleteButtonNode = query(".deleteButton", this.domNode)[0]; - var addButton = registry.byNode(addButtonNode); - var deleteButton = registry.byNode(deleteButtonNode); - var layout = [[ - { name: "Name", field: "name", width: "40%", editable: true}, - { name: 'Actual Value', field: 'actualValue', width: '30%', editable: true}, - { name: 'Effective Value', field: 'effectiveValue', width: '30%', editable: false} - ]]; - var data = []; - var objectStore = new dojo.data.ObjectStore({objectStore: new Memory({data:data, idProperty: "id"})}); - var grid = new dojox.grid.EnhancedGrid({ - selectionMode: "multiple", - store: objectStore, - singleClickEdit: true, - structure: layout, - autoHeight: true, - sortFields: [{attribute: 'name', descending: false}], - plugins: {indirectSelection: true} - }, gridNode); - grid.canEdit = function(inCell, inRowIndex) - { - var item = grid.getItem(inRowIndex); - return inCell.field == "actualValue" || (inCell.field=="name" && item && item["inherited"] == false); - }; - - this._grid = grid; - this._deleteButton = deleteButton; - this._addButtonNode = addButtonNode; - - var toggleGridButtons = function(index) - { - var data = grid.selection.getSelected(); - deleteButton.set("disabled", !data || data.length==0); - }; - - connect.connect(grid.selection, 'onSelected', toggleGridButtons); - connect.connect(grid.selection, 'onDeselected', toggleGridButtons); - connect.connect(grid, 'onStyleRow' , this, function(row) { that._onStyleRow(row); }); - - deleteButton.set("disabled", true); - addButton.on("click", function(event) { that._newItem(); }); - deleteButton.on("click", function(event) { that._deleteSelected(); }); - grid.on("applyEdit", function(inRowIndex) { that._onEdit(inRowIndex); }); - grid.startup(); - this._filterBox = registry.byNode(query(".filter", this.domNode)[0]); - this._filterBox.on("change", function(value) { if (value) { that._filter(value); } }); - }, - resize: function() - { - this._grid.render(); - }, - setData: function(actualValues, allEffectiveValues, inheritedActualValues) - { - this.value = actualValues; - this.effectiveValues = allEffectiveValues; - this.inheritedActualValues = inheritedActualValues; - - var values = this._mergeValues(actualValues, allEffectiveValues, inheritedActualValues); - this._originalValues = values; - - var grid = this._grid; - if (grid) - { - // delete previous store data - grid.store.fetch({ - onComplete:function(items,request) - { - if(items.length) - { - array.forEach(items, function(item) - { - grid.store.deleteItem(item); - }); - } - } - }); - - // add new data into grid store - this._nextGridItemId = 0; - for(var i=0; i<values.length; i++) - { - var item = values[i]; - var storeItem = { - id: this._nextId(), - name: item.name, - actualValue: item.actualValue, - effectiveValue: item.effectiveValue, - "inherited": item["inherited"], - changed: false - }; - grid.store.newItem(storeItem); - } - grid.store.save(); - } - this._filter(this._filterBox.value); - this._handleOnChange(actualValues); - }, - addInheritedContext: function(object) - { - if (object) - { - var grid = this._grid; - for(key in object) - { - for(var i=0;i< this._originalValues.length;i++) - { - var varExists = false; - if (this._originalValues[i].name == key) - { - varExists = true; - break; - } - } - if (!varExists && !(key in this._dynamicInheritedContext)) - { - this._dynamicInheritedContext[key] = object[key]; - var storeItem = { - id: this._nextId(), - name: key, - actualValue: object[key], - effectiveValue: "", - "inherited": true, - changed: false - }; - grid.store.newItem(storeItem); - this._originalValues.push({name: key, - actualValue: object[key], - effectiveValue: "", - "inherited": true, - changed: false}); - } - } - grid.store.save(); - this._filter(this._filterBox.value); - } - }, - removeDynamicallyAddedInheritedContext: function() - { - if (this._dynamicInheritedContext) - { - var that = this; - var grid = this._grid; - grid.store.fetch({ - onComplete:function(items,request) - { - if(items.length) - { - for(key in that._dynamicInheritedContext) - { - var item = null; - for(var i=0;i<items.length;i++) - { - if (items[i].name == key) - { - item = items[i]; - break; - } - } - if (item && !item.changed) - { - grid.store.deleteItem(item); - that._deleteOriginalItem(item); - } - } - grid.store.save(); - that._dynamicInheritedContext = {}; - } - } - }); - } - }, - destroy: function() - { - if (this.domNode) - { - this.domNode.destroy(); - this.domNode = null; - } - if (this._grid != null) - { - this._grid.destroyRecursively(); - this._grid = null; - } - if (this._addButton != null) - { - this._addButton.destroyRecursively(); - this._addButton = null; - } - if (this._deleteButton != null) - { - this._deleteButton.destroyRecursively(); - this._deleteButton = null; - } - }, - onChange: function(newValue){}, - _newItem: function() - { - var newItem = { id: this._nextId(), name: "", actualValue: "", effectiveValue: "", "inherited": false, changed: true}; - var grid = this._grid; - grid.store.newItem(newItem); - grid.store.save(); - grid.store.fetch( - { - onComplete:function(items,request) + value: null, + effectiveValues: null, + inheritedActualValues: null, + domNode: null, + _grid: null, + _addButton: null, + _deleteButton: null, + _filterBox: null, + _nextGridItemId: 0, + _dynamicInheritedContext: {}, + + constructor: function (args) + { + this._args = args; + }, + + buildRendering: function () + { + this.domNode = domConstruct.create("div", {innerHTML: template}); + parser.parse(this.domNode); + }, + + postCreate: function () { - var rowIndex = items.length - 1; - window.setTimeout(function() + this.inherited(arguments); + var that = this; + var gridNode = query(".grid", this.domNode)[0]; + var addButtonNode = query(".addButton", this.domNode)[0]; + var deleteButtonNode = query(".deleteButton", this.domNode)[0]; + var addButton = registry.byNode(addButtonNode); + var deleteButton = registry.byNode(deleteButtonNode); + var layout = [[{ + name: "Name", + field: "name", + width: "40%", + editable: true + }, + { + name: 'Actual Value', + field: 'actualValue', + width: '30%', + editable: true + }, + { + name: 'Effective Value', + field: 'effectiveValue', + width: '30%', + editable: false + }]]; + var data = []; + var objectStore = new dojo.data.ObjectStore({ + objectStore: new Memory({ + data: data, + idProperty: "id" + }) + }); + var grid = new dojox.grid.EnhancedGrid({ + selectionMode: "multiple", + store: objectStore, + singleClickEdit: true, + structure: layout, + autoHeight: true, + sortFields: [{ + attribute: 'name', + descending: false + }], + plugins: {indirectSelection: true} + }, gridNode); + grid.canEdit = function (inCell, inRowIndex) { - grid.focus.setFocusIndex(rowIndex, 1 ); - },10); - } - }); - }, - _deleteSelected: function() - { - var that = this; - var grid = this._grid; - var data = grid.selection.getSelected(); - if(data.length > 0) - { - array.forEach(data, function(selectedItem) { - if (selectedItem !== null && !selectedItem["inherited"]) - { - grid.store.deleteItem(selectedItem); - that._deleteOriginalItem(selectedItem.name); - } - }); - grid.store.save(); - grid.selection.deselectAll(); - this._valueChanged(); - } - }, - _deleteOriginalItem: function(key) - { - for(var i=0;i< this._originalValues.length;i++) - { - if (this._originalValues[i].name == key) - { - this._originalValues = this._originalValues.splice(i, 1); - break; - } - } - }, - _onEdit:function(inRowIndex) - { - var grid = this._grid; - var item = grid.getItem(inRowIndex); - var previousItems = this._originalValues; - var previousItemActualValue = null; - for(var i=0;i<previousItems.length;i++) - { - if (previousItems[i].name == item.name) - { - previousItemActualValue = previousItems[i].actualValue; - break; - } - } - - if (item.actualValue != previousItemActualValue) - { - if (!item.changed) - { - grid.store.setValue(item, "changed", true); - grid.store.save(); - } - } - else - { - if (item["inherited"]== true && item.changed) - { - grid.store.setValue(item, "changed", false); - grid.store.save(); - } - } - this._valueChanged(); - }, - _onStyleRow: function(row) - { - var grid = this._grid; - var inRowIndex = row.index; - var item = grid.getItem(inRowIndex); - if (item && (item["inherited"] == false || item.changed)) - { - row.customClasses += " highlightedText"; - } - else - { - row.customClasses += " normalText"; - } - grid.focus.styleRow(row); - grid.edit.styleRow(row); - }, - _filter: function(value) - { - this._grid.filter({"inherited": value}); - }, - _nextId: function() - { - this._nextGridItemId = this._nextGridItemId + 1; - return this._nextGridItemId; - }, - _valueChanged: function() - { - if (this._grid) - { - var value ={}; - var grid = this._grid; - grid.store.fetch({ - onComplete:function(items,request) - { - if(items.length > 0) - { - array.forEach(items, function(item) - { - if (item !== null && item.name && ((item["inherited"] && item.changed) || !item["inherited"])) + var item = grid.getItem(inRowIndex); + return inCell.field == "actualValue" || (inCell.field == "name" && item && item["inherited"] + == false); + }; + + this._grid = grid; + this._deleteButton = deleteButton; + this._addButtonNode = addButtonNode; + + var toggleGridButtons = function (index) + { + var data = grid.selection.getSelected(); + deleteButton.set("disabled", !data || data.length == 0); + }; + + connect.connect(grid.selection, 'onSelected', toggleGridButtons); + connect.connect(grid.selection, 'onDeselected', toggleGridButtons); + connect.connect(grid, 'onStyleRow', this, function (row) + { + that._onStyleRow(row); + }); + + deleteButton.set("disabled", true); + addButton.on("click", function (event) + { + that._newItem(); + }); + deleteButton.on("click", function (event) + { + that._deleteSelected(); + }); + grid.on("applyEdit", function (inRowIndex) + { + that._onEdit(inRowIndex); + }); + grid.startup(); + this._filterBox = registry.byNode(query(".filter", this.domNode)[0]); + this._filterBox.on("change", function (value) + { + if (value) + { + that._filter(value); + } + }); + }, + resize: function () + { + this._grid.render(); + }, + setData: function (actualValues, allEffectiveValues, inheritedActualValues) + { + this.value = actualValues; + this.effectiveValues = allEffectiveValues; + this.inheritedActualValues = inheritedActualValues; + + var values = this._mergeValues(actualValues, allEffectiveValues, inheritedActualValues); + this._originalValues = values; + + var grid = this._grid; + if (grid) + { + // delete previous store data + grid.store.fetch({ + onComplete: function (items, request) + { + if (items.length) + { + array.forEach(items, function (item) + { + grid.store.deleteItem(item); + }); + } + } + }); + + // add new data into grid store + this._nextGridItemId = 0; + for (var i = 0; i < values.length; i++) + { + var item = values[i]; + var storeItem = { + id: this._nextId(), + name: item.name, + actualValue: item.actualValue, + effectiveValue: item.effectiveValue, + "inherited": item["inherited"], + changed: false + }; + grid.store.newItem(storeItem); + } + grid.store.save(); + } + this._filter(this._filterBox.value); + this._handleOnChange(actualValues); + }, + addInheritedContext: function (object) + { + if (object) + { + var grid = this._grid; + for (key in object) + { + for (var i = 0; i < this._originalValues.length; i++) + { + var varExists = false; + if (this._originalValues[i].name == key) { - value[item.name]=item.actualValue; + varExists = true; + break; } - }); - } - } - }); - if (!util.equals(this.value, value)) - { - this.value = value; - this._handleOnChange(value); - } - } - }, - _setValueAttr: function(actualValues) - { - this.value = actualValues; - if (this.inheritedActualValues!=null && this.effectiveValues != null) - { - this.setData(this.value, this.effectiveValues, this.inheritedActualValues); - } - }, - _setEffectiveValuesAttr: function(effectiveValues) - { - this.effectiveValues = effectiveValues; - if (this.value != null && this.inheritedActualValues !=null) - { - this.setData(this.value, this.effectiveValues, this.inheritedActualValues); - } - }, - _setInheritedActualValues: function(inheritedActualValues) - { - this.inheritedActualValues = inheritedActualValues; - if (this.value!= null && this.effectiveValues != null) - { - this.setData(this.value, this.effectiveValues, this.inheritedActualValues); - } - }, - _mergeValues: function(actualValues, allEffectiveValues, inheritedActualValues) - { - var fields = []; - - if (allEffectiveValues) - { - for(var key in allEffectiveValues) - { - if (!actualValues || !(key in actualValues)) - { - var actualValue = inheritedActualValues && key in inheritedActualValues ? inheritedActualValues[key] : allEffectiveValues[key]; - fields.push({name: key, actualValue: actualValue, effectiveValue: allEffectiveValues[key], "inherited": true}); - } - } - } - - if (actualValues) - { - for(var key in actualValues) - { - var effectiveValue = allEffectiveValues && key in allEffectiveValues ? allEffectiveValues[key]: actualValues[key]; - fields.push({name: key, actualValue: actualValues[key], effectiveValue: effectiveValue, "inherited": false}); - } - } - return fields; - }, - _handleOnChange: function(newValue) - { - if (!util.equals(this._lastValueReported, newValue)) - { - this._lastValueReported = newValue; - if(this._onChangeHandle) - { - this._onChangeHandle.remove(); - } - this._onChangeHandle = this.defer(function() - { - this._onChangeHandle = null; - this.onChange(newValue); - }); - } - } + } + if (!varExists && !(key in this._dynamicInheritedContext)) + { + this._dynamicInheritedContext[key] = object[key]; + var storeItem = { + id: this._nextId(), + name: key, + actualValue: object[key], + effectiveValue: "", + "inherited": true, + changed: false + }; + grid.store.newItem(storeItem); + this._originalValues.push({ + name: key, + actualValue: object[key], + effectiveValue: "", + "inherited": true, + changed: false + }); + } + } + grid.store.save(); + this._filter(this._filterBox.value); + } + }, + removeDynamicallyAddedInheritedContext: function () + { + if (this._dynamicInheritedContext) + { + var that = this; + var grid = this._grid; + grid.store.fetch({ + onComplete: function (items, request) + { + if (items.length) + { + for (key in that._dynamicInheritedContext) + { + var item = null; + for (var i = 0; i < items.length; i++) + { + if (items[i].name == key) + { + item = items[i]; + break; + } + } + if (item && !item.changed) + { + grid.store.deleteItem(item); + that._deleteOriginalItem(item); + } + } + grid.store.save(); + that._dynamicInheritedContext = {}; + } + } + }); + } + }, + destroy: function () + { + if (this.domNode) + { + this.domNode.destroy(); + this.domNode = null; + } + if (this._grid != null) + { + this._grid.destroyRecursively(); + this._grid = null; + } + if (this._addButton != null) + { + this._addButton.destroyRecursively(); + this._addButton = null; + } + if (this._deleteButton != null) + { + this._deleteButton.destroyRecursively(); + this._deleteButton = null; + } + }, + onChange: function (newValue) + { + }, + _newItem: function () + { + var newItem = { + id: this._nextId(), + name: "", + actualValue: "", + effectiveValue: "", + "inherited": false, + changed: true + }; + var grid = this._grid; + grid.store.newItem(newItem); + grid.store.save(); + grid.store.fetch({ + onComplete: function (items, request) + { + var rowIndex = items.length - 1; + window.setTimeout(function () + { + grid.focus.setFocusIndex(rowIndex, 1); + }, 10); + } + }); + }, + _deleteSelected: function () + { + var that = this; + var grid = this._grid; + var data = grid.selection.getSelected(); + if (data.length > 0) + { + array.forEach(data, function (selectedItem) + { + if (selectedItem !== null && !selectedItem["inherited"]) + { + grid.store.deleteItem(selectedItem); + that._deleteOriginalItem(selectedItem.name); + } + }); + grid.store.save(); + grid.selection.deselectAll(); + this._valueChanged(); + } + }, + _deleteOriginalItem: function (key) + { + for (var i = 0; i < this._originalValues.length; i++) + { + if (this._originalValues[i].name == key) + { + this._originalValues = this._originalValues.splice(i, 1); + break; + } + } + }, + _onEdit: function (inRowIndex) + { + var grid = this._grid; + var item = grid.getItem(inRowIndex); + var previousItems = this._originalValues; + var previousItemActualValue = null; + for (var i = 0; i < previousItems.length; i++) + { + if (previousItems[i].name == item.name) + { + previousItemActualValue = previousItems[i].actualValue; + break; + } + } + + if (item.actualValue != previousItemActualValue) + { + if (!item.changed) + { + grid.store.setValue(item, "changed", true); + grid.store.save(); + } + } + else + { + if (item["inherited"] == true && item.changed) + { + grid.store.setValue(item, "changed", false); + grid.store.save(); + } + } + this._valueChanged(); + }, + _onStyleRow: function (row) + { + var grid = this._grid; + var inRowIndex = row.index; + var item = grid.getItem(inRowIndex); + if (item && (item["inherited"] == false || item.changed)) + { + row.customClasses += " highlightedText"; + } + else + { + row.customClasses += " normalText"; + } + grid.focus.styleRow(row); + grid.edit.styleRow(row); + }, + _filter: function (value) + { + this._grid.filter({"inherited": value}); + }, + _nextId: function () + { + this._nextGridItemId = this._nextGridItemId + 1; + return this._nextGridItemId; + }, + _valueChanged: function () + { + if (this._grid) + { + var value = {}; + var grid = this._grid; + grid.store.fetch({ + onComplete: function (items, request) + { + if (items.length > 0) + { + array.forEach(items, function (item) + { + if (item !== null && item.name && ((item["inherited"] + && item.changed) + || !item["inherited"])) + { + value[item.name] = item.actualValue; + } + }); + } + } + }); + if (!util.equals(this.value, value)) + { + this.value = value; + this._handleOnChange(value); + } + } + }, + _setValueAttr: function (actualValues) + { + this.value = actualValues; + if (this.inheritedActualValues != null && this.effectiveValues != null) + { + this.setData(this.value, this.effectiveValues, this.inheritedActualValues); + } + }, + _setEffectiveValuesAttr: function (effectiveValues) + { + this.effectiveValues = effectiveValues; + if (this.value != null && this.inheritedActualValues != null) + { + this.setData(this.value, this.effectiveValues, this.inheritedActualValues); + } + }, + _setInheritedActualValues: function (inheritedActualValues) + { + this.inheritedActualValues = inheritedActualValues; + if (this.value != null && this.effectiveValues != null) + { + this.setData(this.value, this.effectiveValues, this.inheritedActualValues); + } + }, + _mergeValues: function (actualValues, allEffectiveValues, inheritedActualValues) + { + var fields = []; + + if (allEffectiveValues) + { + for (var key in allEffectiveValues) + { + if (!actualValues || !(key in actualValues)) + { + var actualValue = inheritedActualValues && key in inheritedActualValues + ? inheritedActualValues[key] + : allEffectiveValues[key]; + fields.push({ + name: key, + actualValue: actualValue, + effectiveValue: allEffectiveValues[key], + "inherited": true + }); + } + } + } + + if (actualValues) + { + for (var key in actualValues) + { + var effectiveValue = allEffectiveValues && key in allEffectiveValues + ? allEffectiveValues[key] + : actualValues[key]; + fields.push({ + name: key, + actualValue: actualValues[key], + effectiveValue: effectiveValue, + "inherited": false + }); + } + } + return fields; + }, + _handleOnChange: function (newValue) + { + if (!util.equals(this._lastValueReported, newValue)) + { + this._lastValueReported = newValue; + if (this._onChangeHandle) + { + this._onChangeHandle.remove(); + } + this._onChangeHandle = this.defer(function () + { + this._onChangeHandle = null; + this.onChange(newValue); + }); + } + } - }); -}); + }); + });
Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/FormWidgetMixin.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/FormWidgetMixin.js?rev=1741609&r1=1741608&r2=1741609&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/FormWidgetMixin.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/FormWidgetMixin.js Fri Apr 29 11:04:40 2016 @@ -18,25 +18,24 @@ * under the License. * */ -define(["dojo/_base/declare"], function(declare) +define(["dojo/_base/declare"], function (declare) { - return declare("qpid.common.FormWidgetMixin", null, - { + return declare("qpid.common.FormWidgetMixin", null, { name: "", value: "", _onChangeActive: false, - compare: function(val1, val2) + compare: function (val1, val2) { - if(typeof val1 == "number" && typeof val2 == "number") + if (typeof val1 == "number" && typeof val2 == "number") { return (isNaN(val1) && isNaN(val2)) ? 0 : val1 - val2; } - else if(val1 > val2) + else if (val1 > val2) { return 1; } - else if(val1 < val2) + else if (val1 < val2) { return -1; } @@ -45,55 +44,61 @@ define(["dojo/_base/declare"], function( return 0; } }, - onChange: function() + onChange: function () { }, - _setValueAttr: function(newValue, priorityChange) + _setValueAttr: function (newValue, priorityChange) { this._handleOnChange(newValue, priorityChange); }, - _handleOnChange: function(newValue, priorityChange) + _handleOnChange: function (newValue, priorityChange) { this._set("value", newValue); - if(this._lastValueReported == undefined && (priorityChange === null || !this._onChangeActive)) + 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._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._onChangeActive) { - if(this._onChangeHandle) + if (this._onChangeHandle) { this._onChangeHandle.remove(); } - this._onChangeHandle = this.defer(function() { this._onChangeHandle = null; this.onChange(newValue); }); + this._onChangeHandle = this.defer(function () + { + this._onChangeHandle = null; + this.onChange(newValue); + }); } } }, - create: function() + create: function () { - this.inherited(arguments); - this._onChangeActive = true; + this.inherited(arguments); + this._onChangeActive = true; }, - destroy: function() + destroy: function () { - if(this._onChangeHandle) + if (this._onChangeHandle) { this._onChangeHandle.remove(); this.onChange(this._lastValueReported); } this.inherited(arguments); }, - undo: function() + undo: function () { this._setValueAttr(this._lastValueReported, false); }, - reset: function() + reset: function () { this._hasBeenBlurred = false; this._setValueAttr(this._resetValue, true); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/JsonRest.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/JsonRest.js?rev=1741609&r1=1741608&r2=1741609&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/JsonRest.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/JsonRest.js Fri Apr 29 11:04:40 2016 @@ -19,67 +19,70 @@ * */ - define(["dojo/_base/lang", "dojo/json", "dojo/_base/declare", "dojo/store/util/QueryResults"], - function( lang, json, declare, QueryResults ) - { - return declare("qpid.common.JsonRest", null, - { - headers: {}, - idProperty: "id", - firstProperty: "first", - lastProperty: "last", - accepts: "application/javascript, application/json", - queryOperation: null, - modelObject: null, - management: null, - - constructor: function(options) - { - this.headers = {}; - this.management = options.management; - this.modelObject = options.modelObject; - this.queryOperation = options.queryOperation; - declare.safeMixin(this, options); - }, - - getIdentity: function(object) - { - return object[this.idProperty]; - }, - - query: function(query, options) - { - query = query || {}; - options = options || {}; - var headers = lang.mixin({ Accept: this.accepts }, this.headers, options.headers); - - query[this.firstProperty]= options.start >= 0 ? options.start : -1; - query[this.lastProperty] = options.count >= 0 && query.first >= 0 ? options.count + query.first : -1; - - if(options.start >= 0 || options.count >= 0) - { - headers["X-Range"] = "items=" + (options.start || '0') + '-' + - (("count" in options && options.count != Infinity) ? - (options.count + (options.start || 0) - 1) : ''); - headers.Range = headers["X-Range"]; - } - - var modelObj = {name: this.queryOperation, parent: this.modelObject, type: this.modelObject.type}; - var results = management.load(modelObj, - query, - {headers: headers}); - - results.total = results.response.then(function(response) - { - var range = response.getHeader("Content-Range"); - if (!range) - { - range = response.getHeader("X-Content-Range"); - } - return range && (range = range.match(/\/(.*)/)) && +range[1]; - }); - return QueryResults(results); - } - }); +define(["dojo/_base/lang", "dojo/json", "dojo/_base/declare", "dojo/store/util/QueryResults"], + function (lang, json, declare, QueryResults) + { + return declare("qpid.common.JsonRest", null, { + headers: {}, + idProperty: "id", + firstProperty: "first", + lastProperty: "last", + accepts: "application/javascript, application/json", + queryOperation: null, + modelObject: null, + management: null, + + constructor: function (options) + { + this.headers = {}; + this.management = options.management; + this.modelObject = options.modelObject; + this.queryOperation = options.queryOperation; + declare.safeMixin(this, options); + }, + + getIdentity: function (object) + { + return object[this.idProperty]; + }, + + query: function (query, options) + { + query = query || {}; + options = options || {}; + var headers = lang.mixin({Accept: this.accepts}, this.headers, options.headers); + + query[this.firstProperty] = options.start >= 0 ? options.start : -1; + query[this.lastProperty] = options.count >= 0 && query.first >= 0 ? options.count + query.first : -1; + + if (options.start >= 0 || options.count >= 0) + { + headers["X-Range"] = + "items=" + (options.start || '0') + '-' + (("count" in options && options.count != Infinity) + ? (options.count + (options.start || 0) - 1) + : ''); + headers.Range = headers["X-Range"]; + } + + var modelObj = { + name: this.queryOperation, + parent: this.modelObject, + type: this.modelObject.type + }; + var results = management.load(modelObj, query, {headers: headers}); + + results.total = results.response.then(function (response) + { + var range = response.getHeader("Content-Range"); + if (!range) + { + range = response.getHeader("X-Content-Range"); + } + return range && (range = range.match(/\/(.*)/)) + && +range[1]; + }); + return QueryResults(results); + } + }); - }); + }); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js?rev=1741609&r1=1741608&r2=1741609&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js Fri Apr 29 11:04:40 2016 @@ -18,8 +18,7 @@ * under the License. * */ -define([ - "dojo/_base/declare", +define(["dojo/_base/declare", "dojo/_base/array", "dojo/_base/lang", "qpid/common/util", @@ -35,170 +34,186 @@ define([ "dojox/validate/us", "dojox/validate/web", "dojo/domReady!"], -function (declare, array, lang, util, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, FormWidgetMixin, template, entities) -{ + 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, - uploaded: false, + return declare("qpid.common.ResourceWidget", + [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, FormWidgetMixin], + { + templateString: template, + fileReaderSupported: window.FileReader ? true : false, + displayWarningWhenFileReaderUnsupported: false, + isDebug: false, + uploaded: 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); + 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; - } + if (this._resetValue === undefined) + { + this._lastValueReported = this._resetValue = this.value; + } - var that = this; + 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 (this.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.resourceLocation.set("required", this.required ? true : false); - this.uploadData.style.display = "none"; - }, - startup: function() - { - if (this.fileReaderSupported) - { - this.uploader.startup(); - } - }, - destroy: function() - { - if (this.fileReaderSupported && this.fileReader) - { - util.abortReaderSafely(this.fileReader); - } - this.inherited(arguments); - }, - _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.uploaded = false; - this.uploader.reset(); - this.set("value", this._resetValue); - }, - _pathChanged: function() - { - var serverPathValue = this.resourceLocation.get("value") || this._resetValue; - this.set("value", serverPathValue); - if (this.uploaded ) - { - this.uploaded = !serverPathValue; - } - }, - _setValueAttr: function(newValue, priorityChange) - { - var isDataUrl = this.uploaded || ( newValue && newValue.indexOf("data:") == 0 ); - if (isDataUrl) - { - this._initUploaded(true); - } - else - { - this.resourceLocation.set("value", newValue); - this.selectedFileName = null; - this.selectedFileStatus.className = ""; - this.selectedFile.innerHTML = ""; - this.resourceLocation.set("required", this.required ? true : false); - 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); - } - }, - _setPlaceHolderAttr: function(newValue) - { - this.resourceLocation.set("placeHolder", newValue); - }, - _setUploadedAttr: function(uploaded) - { - this.uploaded = uploaded; - this._initUploaded(uploaded); - }, - _initUploaded: function(uploaded) - { - if (uploaded) - { - 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"; - } - } - } - ); -}); + 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 (this.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.resourceLocation.set("required", this.required ? true : false); + this.uploadData.style.display = "none"; + }, + startup: function () + { + if (this.fileReaderSupported) + { + this.uploader.startup(); + } + }, + destroy: function () + { + if (this.fileReaderSupported && this.fileReader) + { + util.abortReaderSafely(this.fileReader); + } + this.inherited(arguments); + }, + _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.uploaded = false; + this.uploader.reset(); + this.set("value", this._resetValue); + }, + _pathChanged: function () + { + var serverPathValue = this.resourceLocation.get("value") || this._resetValue; + this.set("value", serverPathValue); + if (this.uploaded) + { + this.uploaded = !serverPathValue; + } + }, + _setValueAttr: function (newValue, priorityChange) + { + var isDataUrl = this.uploaded || ( newValue && newValue.indexOf("data:") == 0 ); + if (isDataUrl) + { + this._initUploaded(true); + } + else + { + this.resourceLocation.set("value", newValue); + this.selectedFileName = null; + this.selectedFileStatus.className = ""; + this.selectedFile.innerHTML = ""; + this.resourceLocation.set("required", this.required ? true : false); + 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); + } + }, + _setPlaceHolderAttr: function (newValue) + { + this.resourceLocation.set("placeHolder", newValue); + }, + _setUploadedAttr: function (uploaded) + { + this.uploaded = uploaded; + this._initUploaded(uploaded); + }, + _initUploaded: function (uploaded) + { + if (uploaded) + { + 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"; + } + } + }); + }); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js?rev=1741609&r1=1741608&r2=1741609&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js Fri Apr 29 11:04:40 2016 @@ -18,8 +18,7 @@ * under the License. * */ -define([ - "dojo/_base/declare", +define(["dojo/_base/declare", "dojo/_base/array", "dojo/dom-construct", "dojo/parser", @@ -35,192 +34,216 @@ define([ "dojox/validate/us", "dojox/validate/web", "dojo/domReady!"], -function (declare, array, domConstruct, parser, query, domStyle, Memory, _WidgetBase, registry, template) { + function (declare, array, domConstruct, parser, query, domStyle, Memory, _WidgetBase, registry, template) + { - var preferencesRegions = ["Africa","America","Antarctica","Arctic","Asia","Atlantic","Australia","Europe","Indian","Pacific"]; + var preferencesRegions = ["Africa", + "America", + "Antarctica", + "Arctic", + "Asia", + "Atlantic", + "Australia", + "Europe", + "Indian", + "Pacific"]; + + function initSupportedRegions() + { + var supportedRegions = [{ + "id": "undefined", + "name": "Undefined" + }]; + for (var j = 0; j < preferencesRegions.length; j++) + { + supportedRegions.push({ + id: preferencesRegions[j], + name: preferencesRegions[j] + }); + } + return supportedRegions; + } + + return declare("qpid.common.TimeZoneSelector", [_WidgetBase], { + + value: null, + domNode: null, + _regionSelector: null, + _citySelector: null, + _utcSelector: null, + + constructor: function (args) + { + this._args = args; + this.timezones = args.timezones; + }, + + buildRendering: function () + { + this.domNode = domConstruct.create("div", {innerHTML: template}); + parser.parse(this.domNode); + }, + + postCreate: function () + { + this.inherited(arguments); + + var self = this; + if (this._args.labelStyle) + { + var nl = query(".labelClass", this.domNode); + array.forEach(nl, function (entry, i) + { + domStyle.set(entry, self._args.labelStyle) + }); + } + var supportedTimeZones = this.timezones; + + this._utcSelector = registry.byNode(query(".utcSelector", this.domNode)[0]); + this._citySelector = registry.byNode(query(".timezoneCity", this.domNode)[0]); + this._citySelector.set("searchAttr", "city"); + this._citySelector.set("query", {region: /.*/}); + this._citySelector.set("labelAttr", "city"); + if (this.timezones) + { + this._setTimezonesAttr(this.timezones); + } + + this._regionSelector = registry.byNode(query(".timezoneRegion", this.domNode)[0]); + var supportedRegions = initSupportedRegions(); + this._regionSelector.set("store", new Memory({data: supportedRegions})); + + this._utcSelector.on("change", function (value) + { + var checked = this.get("checked"); + if (checked) + { + self.value = "UTC"; + } + else + { + if (self._citySelector.value && self._regionSelector.value) + { + self.value = self._citySelector.value; + } + else + { + self.value = null; + } + } + self._citySelector.set("disabled", checked); + self._regionSelector.set("disabled", checked); + self._handleOnChange(self.value); + }); + this._regionSelector.on("change", function (value) + { + if (value == "undefined") + { + self._citySelector.set("disabled", true); + self._citySelector.query.region = /.*/; + self.value = null; + self._citySelector.set("value", null); + self._handleOnChange(self.value); + } + else + { + self._citySelector.set("disabled", false); + self._citySelector.query.region = value || /.*/; + if (this.timeZone) + { + self._citySelector.set("value", this.timeZone); + this.timeZone = null; + } + else + { + self._citySelector.set("value", null); + } + } + }); + + this._citySelector.on("change", function (value) + { + self.value = value; + self._handleOnChange(value); + }); + + this._setValueAttr(this._args.value); + }, + + _setTimezonesAttr: function (supportedTimeZones) + { + this._citySelector.set("store", new Memory({data: supportedTimeZones})); + if (this._args.name) + { + this._citySelector.set("name", this._args.name); + } + }, + + _setValueAttr: function (value) + { + if (value) + { + if (value == "UTC") + { + this._utcSelector.set("checked", true); + } + else + { + this._utcSelector.set("checked", false); + var elements = value.split("/"); + if (elements.length > 1) + { + this._regionSelector.timeZone = value; + this._regionSelector.set("value", elements[0]); + this._citySelector.set("value", value); + } + else + { + this._regionSelector.set("value", "undefined"); + } + } + } + else + { + this._utcSelector.set("checked", false); + this._regionSelector.set("value", "undefined"); + } + this.value = value; + this._handleOnChange(value); + }, + + destroy: function () + { + if (this.domNode) + { + this.domNode.destroy(); + this.domNode = null; + } + _regionSelector: null; + _citySelector: null; + _utcSelector: null; + }, + + onChange: function (newValue) + { + }, + + _handleOnChange: function (newValue) + { + if (this._lastValueReported != newValue) + { + this._lastValueReported = newValue; + if (this._onChangeHandle) + { + this._onChangeHandle.remove(); + } + this._onChangeHandle = this.defer(function () + { + this._onChangeHandle = null; + this.onChange(newValue); + }); + } + } - function initSupportedRegions() - { - var supportedRegions = [{"id": "undefined", "name": "Undefined"}]; - for(var j = 0; j<preferencesRegions.length; j++) - { - supportedRegions.push({id: preferencesRegions[j], name: preferencesRegions[j] }); - } - return supportedRegions; - } - - return declare("qpid.common.TimeZoneSelector", [_WidgetBase], { - - value: null, - domNode: null, - _regionSelector: null, - _citySelector: null, - _utcSelector: null, - - constructor: function(args) - { - this._args = args; - this.timezones = args.timezones; - }, - - buildRendering: function(){ - this.domNode = domConstruct.create("div", {innerHTML: template}); - parser.parse(this.domNode); - }, - - postCreate: function(){ - this.inherited(arguments); - - var self = this; - if (this._args.labelStyle) - { - var nl = query(".labelClass", this.domNode); - array.forEach(nl, function(entry, i){ - domStyle.set(entry, self._args.labelStyle) - }); - } - var supportedTimeZones = this.timezones; - - this._utcSelector = registry.byNode(query(".utcSelector", this.domNode)[0]); - this._citySelector = registry.byNode(query(".timezoneCity", this.domNode)[0]); - this._citySelector.set("searchAttr", "city"); - this._citySelector.set("query", {region: /.*/}); - this._citySelector.set("labelAttr", "city"); - if (this.timezones) - { - this._setTimezonesAttr(this.timezones); - } - - this._regionSelector = registry.byNode(query(".timezoneRegion", this.domNode)[0]); - var supportedRegions = initSupportedRegions(); - this._regionSelector.set("store", new Memory({ data: supportedRegions })); - - this._utcSelector.on("change", function(value){ - var checked = this.get("checked"); - if (checked) - { - self.value ="UTC"; - } - else - { - if (self._citySelector.value && self._regionSelector.value) - { - self.value = self._citySelector.value; - } - else - { - self.value = null; - } - } - self._citySelector.set("disabled", checked); - self._regionSelector.set("disabled", checked); - self._handleOnChange(self.value); - }); - this._regionSelector.on("change", function(value){ - if (value=="undefined") - { - self._citySelector.set("disabled", true); - self._citySelector.query.region = /.*/; - self.value = null; - self._citySelector.set("value", null); - self._handleOnChange(self.value); - } - else - { - self._citySelector.set("disabled", false); - self._citySelector.query.region = value || /.*/; - if (this.timeZone) - { - self._citySelector.set("value", this.timeZone); - this.timeZone = null; - } - else - { - self._citySelector.set("value", null); - } - } - }); - - this._citySelector.on("change", function(value){ - self.value = value; - self._handleOnChange(value); - }); - - this._setValueAttr(this._args.value); - }, - - _setTimezonesAttr: function(supportedTimeZones) - { - this._citySelector.set("store", new Memory({ data: supportedTimeZones })); - if (this._args.name) - { - this._citySelector.set("name", this._args.name); - } - }, - - _setValueAttr: function(value) - { - if (value) - { - if (value == "UTC") - { - this._utcSelector.set("checked", true); - } - else - { - this._utcSelector.set("checked", false); - var elements = value.split("/"); - if (elements.length > 1) - { - this._regionSelector.timeZone = value; - this._regionSelector.set("value", elements[0]); - this._citySelector.set("value", value); - } - else - { - this._regionSelector.set("value", "undefined"); - } - } - } - else - { - this._utcSelector.set("checked", false); - this._regionSelector.set("value", "undefined"); - } - this.value = value; - this._handleOnChange(value); - }, - - destroy: function() - { - if (this.domNode) - { - this.domNode.destroy(); - this.domNode = null; - } - _regionSelector: null; - _citySelector: null; - _utcSelector: null; - }, - - onChange: function(newValue){}, - - _handleOnChange: function(newValue) - { - if (this._lastValueReported != newValue) - { - this._lastValueReported = newValue; - if(this._onChangeHandle) - { - this._onChangeHandle.remove(); - } - this._onChangeHandle = this.defer(function() - { - this._onChangeHandle = null; - this.onChange(newValue); - }); - } - } - - }); -}); \ 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/common/TypeTabExtension.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TypeTabExtension.js?rev=1741609&r1=1741608&r2=1741609&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TypeTabExtension.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TypeTabExtension.js Fri Apr 29 11:04:40 2016 @@ -18,63 +18,57 @@ * under the License. * */ -define(["qpid/common/util", - "dojo/query", - "dojox/html/entities", - "dojo/domReady!"], - function (util, query, entities) - { +define(["qpid/common/util", "dojo/query", "dojox/html/entities", "dojo/domReady!"], function (util, query, entities) +{ - function TypeTabExtension(containerNode, template, category, type, metadata, data ) + function TypeTabExtension(containerNode, template, category, type, metadata, data) { - var that = this; - this.attributeContainers = {}; - if (template) - { - util.parse(containerNode, template, - function () - { - if (metadata && category && type) + var that = this; + this.attributeContainers = {}; + if (template) + { + util.parse(containerNode, template, function () { - var attributes = metadata.getMetaData(category, type).attributes; - for (var attrName in attributes) - { - var queryResult = query("." + attrName, containerNode); - if (queryResult && queryResult[0]) + if (metadata && category && type) { - var attr = attributes[attrName]; - that.attributeContainers[attrName] = { - containerNode: queryResult[0], - attributeType: attr.type - }; + var attributes = metadata.getMetaData(category, type).attributes; + for (var attrName in attributes) + { + var queryResult = query("." + attrName, containerNode); + if (queryResult && queryResult[0]) + { + var attr = attributes[attrName]; + that.attributeContainers[attrName] = { + containerNode: queryResult[0], + attributeType: attr.type + }; + } + } + that.update(data); } - } - that.update(data); - } - }); - } + }); + } } TypeTabExtension.prototype.update = function (restData) { - for (var attrName in this.attributeContainers) - { - if (attrName in restData) + for (var attrName in this.attributeContainers) { - var content = ""; - if (this.attributeContainers[attrName].attributeType == "Boolean") - { - content = util.buildCheckboxMarkup(restData[attrName]); - } - else - { - content = entities.encode(String(restData[attrName])); - } - this.attributeContainers[attrName].containerNode.innerHTML = content; + if (attrName in restData) + { + var content = ""; + if (this.attributeContainers[attrName].attributeType == "Boolean") + { + content = util.buildCheckboxMarkup(restData[attrName]); + } + else + { + content = entities.encode(String(restData[attrName])); + } + this.attributeContainers[attrName].containerNode.innerHTML = content; + } } - } } return TypeTabExtension; - } -); +}); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
