Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ConsoleHelper.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ConsoleHelper.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ConsoleHelper.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ConsoleHelper.js Mon May 2 15:57:52 2016 @@ -32,10 +32,10 @@ define(["dojo/domReady!"], function () require(["qpid/management/Preferences", "dojo/ready"], function (PreferencesDialog, ready) { ready(function () - { - preferencesDialog = new PreferencesDialog(this.management); - preferencesDialog.showDialog(); - }); + { + preferencesDialog = new PreferencesDialog(this.management); + preferencesDialog.showDialog(); + }); }); } else @@ -45,32 +45,32 @@ define(["dojo/domReady!"], function () }, getHelpUrl: function (callback) { - this.management.load({type: "broker"}, {depth: 1}).then(function (data) - { - var broker = data[0]; - if ("context" in broker && "qpid.helpURL" - in broker["context"]) - { - helpURL = broker["context"]["qpid.helpURL"]; - } - else - { - helpURL = "http://qpid.apache.org/"; - } - if (callback) - { - callback(helpURL); - } - }); + this.management.load({type: "broker"}, {depth: 1}) + .then(function (data) + { + var broker = data[0]; + if ("context" in broker && "qpid.helpURL" in broker["context"]) + { + helpURL = broker["context"]["qpid.helpURL"]; + } + else + { + helpURL = "http://qpid.apache.org/"; + } + if (callback) + { + callback(helpURL); + } + }); }, showHelp: function () { var openWindow = function (url) { var newWindow = window.open(url, - 'QpidHelp', - 'height=600,width=600,scrollbars=1,location=1,resizable=1,status=0,toolbar=0,titlebar=1,menubar=0', - true); + 'QpidHelp', + 'height=600,width=600,scrollbars=1,location=1,resizable=1,status=0,toolbar=0,titlebar=1,menubar=0', + true); newWindow.focus(); } @@ -88,9 +88,9 @@ define(["dojo/domReady!"], function () var openWindow = function (url) { var newWindow = window.open(url, - 'Qpid REST API', - 'height=800,width=800,scrollbars=1,location=1,resizable=1,status=0,toolbar=1,titlebar=1,menubar=1', - true); + 'Qpid REST API', + 'height=800,width=800,scrollbars=1,location=1,resizable=1,status=0,toolbar=1,titlebar=1,menubar=1', + true); newWindow.focus(); }
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=1741993&r1=1741992&r2=1741993&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 Mon May 2 15:57:52 2016 @@ -39,501 +39,510 @@ define(["qpid/common/util", "dojox/validate/us", "dojox/validate/web", "dojo/domReady!"], - function (util, declare, array, connect, lang, domConstruct, parser, query, Memory, ObjectStore, _WidgetBase, registry, template) - { - - 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) + function (util, + declare, + array, + connect, + lang, + domConstruct, + parser, + query, + Memory, + ObjectStore, + _WidgetBase, + registry, + template) + { + + 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) { - var rowIndex = items.length - 1; - window.setTimeout(function () - { - grid.focus.setFocusIndex(rowIndex, 1); - }, 10); + item = items[i]; + break; } - }); - }, - _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); - }); - } - } + } + 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=1741993&r1=1741992&r2=1741993&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 Mon May 2 15:57:52 2016 @@ -60,8 +60,7 @@ define(["dojo/_base/declare"], function } this._pendingOnChange = this._pendingOnChange || (typeof newValue != typeof this._lastValueReported) || (this.compare(newValue, - this._lastValueReported) - != 0); + this._lastValueReported) != 0); if (( priorityChange || priorityChange === undefined) && this._pendingOnChange) { this._lastValueReported = newValue; @@ -73,10 +72,10 @@ define(["dojo/_base/declare"], function this._onChangeHandle.remove(); } this._onChangeHandle = this.defer(function () - { - this._onChangeHandle = null; - this.onChange(newValue); - }); + { + this._onChangeHandle = null; + this.onChange(newValue); + }); } } }, 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=1741993&r1=1741992&r2=1741993&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 Mon May 2 15:57:52 2016 @@ -20,69 +20,68 @@ */ 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); - } - }); + 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=1741993&r1=1741992&r2=1741993&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 Mon May 2 15:57:52 2016 @@ -34,186 +34,194 @@ define(["dojo/_base/declare", "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"; + } + } + }); + }); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
