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=1741993&r1=1741992&r2=1741993&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 Mon May 2 15:57:52 2016 @@ -34,216 +34,216 @@ define(["dojo/_base/declare", "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"]; - - 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); - }); - } - } + 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); + }); + } + } - }); - }); \ 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/UpdatableStore.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js Mon May 2 15:57:52 2016 @@ -24,181 +24,182 @@ define(["dojo/json", "dojox/grid/DataGrid", "dojo/data/ObjectStore", "dojo/store/Observable"], function (json, util, Memory, DataGrid, ObjectStore, Observable) - { +{ - function UpdatableStore(data, divName, structure, func, props, Grid, notObservable) - { + function UpdatableStore(data, divName, structure, func, props, Grid, notObservable) + { - var that = this; - var GridType = DataGrid; + var that = this; + var GridType = DataGrid; - that.memoryStore = new Memory({ - data: data, - idProperty: "id" - }); - that.store = notObservable ? that.memoryStore : new Observable(that.memoryStore); - that.dataStore = ObjectStore({objectStore: that.store}); - - var gridProperties = { - store: that.dataStore, - structure: structure, - autoHeight: true - }; - if (props) - { - for (var prop in props) - { - if (props.hasOwnProperty(prop)) - { - gridProperties[prop] = props[prop]; - } - } - } - - if (Grid) - { - GridType = Grid; - } - - that.grid = new GridType(gridProperties, divName); - - // since we created this grid programmatically, call startup to render it - that.grid.startup(); - - if (func) - { - func(that); - } - - } - - UpdatableStore.prototype.update = function (data) - { - var changed = false; - var store = this.store; - var theItem; - - // handle deletes - // iterate over existing store... if not in new data then remove - store.query({}).forEach(function (object) - { - if (data) - { - for (var i = 0; i < data.length; i++) - { - if (data[i].id == object.id) - { - return; - } - } - } - store.remove(object.id); - changed = true; - }); - - // iterate over data... - if (data) - { - for (var i = 0; i < data.length; i++) - { - if (theItem = store.get(data[i].id)) - { - var modified = !util.equals(theItem, data[i]); - if (modified) - { - if (store.notify) - { - // Seems that we are required to update the item that the store already holds - for (var propName in data[i]) - { - if (data[i].hasOwnProperty(propName)) - { - if (theItem[propName] != data[i][propName]) - { - theItem[propName] = data[i][propName]; - } - } - } - // and tell it we have done so - store.notify(theItem, data[i].id); - } - else - { - store.put(data[i], {overwrite: true}); - } - changed = true; - } - } - else - { - // if not in the store then add - store.put(data[i]); - changed = true; - } - } - } - - return changed; - }; - - function removeItemsFromArray(items, numberToRemove) - { - if (items) - { - if (numberToRemove > 0 && items.length > 0) - { - if (numberToRemove >= items.length) - { - numberToRemove = numberToRemove - items.length; - items.length = 0 - } - else - { - items.splice(0, numberToRemove); - numberToRemove = 0; - } - } - } - return numberToRemove; - }; - - UpdatableStore.prototype.append = function (data, limit) - { - var changed = false; - var items = this.memoryStore.data; - - if (limit) - { - var totalSize = items.length + (data ? data.length : 0); - var numberToRemove = totalSize - limit; - - if (numberToRemove > 0) - { - changed = true; - numberToRemove = removeItemsFromArray(items, numberToRemove); - if (numberToRemove > 0) - { - removeItemsFromArray(data, numberToRemove); - } - } - } - - if (data && data.length > 0) - { - changed = true; - items.push.apply(items, data); - } - - this.memoryStore.setData(items); - return changed; - }; - - UpdatableStore.prototype.close = function () - { - this.dataStore.close(); - this.dataStore = null; - this.store = null; - this.memoryStore = null; - }; - return UpdatableStore; - }); + that.memoryStore = new Memory({ + data: data, + idProperty: "id" + }); + that.store = notObservable ? that.memoryStore : new Observable(that.memoryStore); + that.dataStore = ObjectStore({objectStore: that.store}); + + var gridProperties = { + store: that.dataStore, + structure: structure, + autoHeight: true + }; + if (props) + { + for (var prop in props) + { + if (props.hasOwnProperty(prop)) + { + gridProperties[prop] = props[prop]; + } + } + } + + if (Grid) + { + GridType = Grid; + } + + that.grid = new GridType(gridProperties, divName); + + // since we created this grid programmatically, call startup to render it + that.grid.startup(); + + if (func) + { + func(that); + } + + } + + UpdatableStore.prototype.update = function (data) + { + var changed = false; + var store = this.store; + var theItem; + + // handle deletes + // iterate over existing store... if not in new data then remove + store.query({}) + .forEach(function (object) + { + if (data) + { + for (var i = 0; i < data.length; i++) + { + if (data[i].id == object.id) + { + return; + } + } + } + store.remove(object.id); + changed = true; + }); + + // iterate over data... + if (data) + { + for (var i = 0; i < data.length; i++) + { + if (theItem = store.get(data[i].id)) + { + var modified = !util.equals(theItem, data[i]); + if (modified) + { + if (store.notify) + { + // Seems that we are required to update the item that the store already holds + for (var propName in data[i]) + { + if (data[i].hasOwnProperty(propName)) + { + if (theItem[propName] != data[i][propName]) + { + theItem[propName] = data[i][propName]; + } + } + } + // and tell it we have done so + store.notify(theItem, data[i].id); + } + else + { + store.put(data[i], {overwrite: true}); + } + changed = true; + } + } + else + { + // if not in the store then add + store.put(data[i]); + changed = true; + } + } + } + + return changed; + }; + + function removeItemsFromArray(items, numberToRemove) + { + if (items) + { + if (numberToRemove > 0 && items.length > 0) + { + if (numberToRemove >= items.length) + { + numberToRemove = numberToRemove - items.length; + items.length = 0 + } + else + { + items.splice(0, numberToRemove); + numberToRemove = 0; + } + } + } + return numberToRemove; + }; + + UpdatableStore.prototype.append = function (data, limit) + { + var changed = false; + var items = this.memoryStore.data; + + if (limit) + { + var totalSize = items.length + (data ? data.length : 0); + var numberToRemove = totalSize - limit; + + if (numberToRemove > 0) + { + changed = true; + numberToRemove = removeItemsFromArray(items, numberToRemove); + if (numberToRemove > 0) + { + removeItemsFromArray(data, numberToRemove); + } + } + } + + if (data && data.length > 0) + { + changed = true; + items.push.apply(items, data); + } + + this.memoryStore.setData(items); + return changed; + }; + + UpdatableStore.prototype.close = function () + { + this.dataStore.close(); + this.dataStore = null; + this.store = null; + this.memoryStore = null; + }; + return UpdatableStore; +}); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/WarningPane.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/WarningPane.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/WarningPane.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/WarningPane.js Mon May 2 15:57:52 2016 @@ -29,45 +29,45 @@ define(["dojo/_base/declare", "dojox/html/entities", "dijit/form/Button", "dojo/domReady!"], - function (declare, array, lang, event, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, template, entities) - { + function (declare, array, lang, event, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, template, entities) + { - return declare("qpid.common.WarningPane", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], { - templateString: template, - message: "Not Found", + return declare("qpid.common.WarningPane", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], { + templateString: template, + message: "Not Found", - 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); - this._renderMessage(); - var that = this; - this.closeButton.on("click", function (e) - { - that._onButtonClick(e) - }); - }, - _onButtonClick: function (/*Event*/ e) - { - this.onClick(e); - }, - onClick: function (/*Event*/ e) - { - // extention point - }, - _setMessageAttr: function (message) - { - this.message = message; - this._renderMessage(); - }, - _renderMessage: function () - { - this.warningMessage.innerHTML = entities.encode(String(this.message)); - } - }); - }); + 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); + this._renderMessage(); + var that = this; + this.closeButton.on("click", function (e) + { + that._onButtonClick(e) + }); + }, + _onButtonClick: function (/*Event*/ e) + { + this.onClick(e); + }, + onClick: function (/*Event*/ e) + { + // extention point + }, + _setMessageAttr: function (message) + { + this.message = message; + this._renderMessage(); + }, + _renderMessage: function () + { + this.warningMessage.innerHTML = entities.encode(String(this.message)); + } + }); + }); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/footer.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/footer.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/footer.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/footer.js Mon May 2 15:57:52 2016 @@ -20,16 +20,17 @@ */ define(["dojo/_base/xhr", "dojo/query", "dojo/domReady!"], function (xhr, query) { - query('div[qpid-type="footer"]').forEach(function (node, index, arr) - { - xhr.get({ - url: "footer.html", - sync: true, - load: function (data) - { - node.innerHTML = data; - } - }); - }); + query('div[qpid-type="footer"]') + .forEach(function (node, index, arr) + { + xhr.get({ + url: "footer.html", + sync: true, + load: function (data) + { + node.innerHTML = data; + } + }); + }); }); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/formatter.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/formatter.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/formatter.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/formatter.js Mon May 2 15:57:52 2016 @@ -20,85 +20,85 @@ */ define(function () - { - return { +{ + return { - formatBytes: function formatBytes(amount) - { - var returnVal = { - units: "B", - value: "0" - }; - - if (amount < 1000) - { - returnVal.value = amount.toPrecision(3); - ; - } - else if (amount < 1000 * 1024) - { - returnVal.units = "KB"; - returnVal.value = (amount / 1024).toPrecision(3); - } - else if (amount < 1000 * 1024 * 1024) - { - returnVal.units = "MB"; - returnVal.value = (amount / (1024 * 1024)).toPrecision(3); - } - else if (amount < 1000 * 1024 * 1024 * 1024) - { - returnVal.units = "GB"; - returnVal.value = (amount / (1024 * 1024 * 1024)).toPrecision(3); - } - - return returnVal; - - }, - - formatTime: function formatTime(amount) - { - var returnVal = { - units: "ms", - value: "0" - }; - - if (amount < 1000) - { - returnVal.units = "ms"; - returnVal.value = amount.toString(); - } - else if (amount < 1000 * 60) - { - returnVal.units = "s"; - returnVal.value = (amount / 1000).toPrecision(3); - } - else if (amount < 1000 * 60 * 60) - { - returnVal.units = "min"; - returnVal.value = (amount / (1000 * 60)).toPrecision(3); - } - else if (amount < 1000 * 60 * 60 * 24) - { - returnVal.units = "hr"; - returnVal.value = (amount / (1000 * 60 * 60)).toPrecision(3); - } - else if (amount < 1000 * 60 * 60 * 24 * 7) - { - returnVal.units = "d"; - returnVal.value = (amount / (1000 * 60 * 60 * 24)).toPrecision(3); - } - else if (amount < 1000 * 60 * 60 * 24 * 365) - { - returnVal.units = "wk"; - returnVal.value = (amount / (1000 * 60 * 60 * 24 * 7)).toPrecision(3); - } - else - { - returnVal.units = "yr"; - returnVal.value = (amount / (1000 * 60 * 60 * 24 * 365)).toPrecision(3); - } - - return returnVal; - } - }; - }); \ No newline at end of file + formatBytes: function formatBytes(amount) + { + var returnVal = { + units: "B", + value: "0" + }; + + if (amount < 1000) + { + returnVal.value = amount.toPrecision(3); + ; + } + else if (amount < 1000 * 1024) + { + returnVal.units = "KB"; + returnVal.value = (amount / 1024).toPrecision(3); + } + else if (amount < 1000 * 1024 * 1024) + { + returnVal.units = "MB"; + returnVal.value = (amount / (1024 * 1024)).toPrecision(3); + } + else if (amount < 1000 * 1024 * 1024 * 1024) + { + returnVal.units = "GB"; + returnVal.value = (amount / (1024 * 1024 * 1024)).toPrecision(3); + } + + return returnVal; + + }, + + formatTime: function formatTime(amount) + { + var returnVal = { + units: "ms", + value: "0" + }; + + if (amount < 1000) + { + returnVal.units = "ms"; + returnVal.value = amount.toString(); + } + else if (amount < 1000 * 60) + { + returnVal.units = "s"; + returnVal.value = (amount / 1000).toPrecision(3); + } + else if (amount < 1000 * 60 * 60) + { + returnVal.units = "min"; + returnVal.value = (amount / (1000 * 60)).toPrecision(3); + } + else if (amount < 1000 * 60 * 60 * 24) + { + returnVal.units = "hr"; + returnVal.value = (amount / (1000 * 60 * 60)).toPrecision(3); + } + else if (amount < 1000 * 60 * 60 * 24 * 7) + { + returnVal.units = "d"; + returnVal.value = (amount / (1000 * 60 * 60 * 24)).toPrecision(3); + } + else if (amount < 1000 * 60 * 60 * 24 * 365) + { + returnVal.units = "wk"; + returnVal.value = (amount / (1000 * 60 * 60 * 24 * 7)).toPrecision(3); + } + else + { + returnVal.units = "yr"; + returnVal.value = (amount / (1000 * 60 * 60 * 24 * 365)).toPrecision(3); + } + + return returnVal; + } + }; +}); \ No newline at end of file Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/ColumnDefDialog.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/ColumnDefDialog.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/ColumnDefDialog.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/ColumnDefDialog.js Mon May 2 15:57:52 2016 @@ -32,123 +32,124 @@ define(["dojo/_base/declare", "dojox/grid/enhanced/plugins/Dialog", "dojo/text!../../../grid/showColumnDefDialog.html", "dojo/domReady!"], - function (declare, event, array, lang, parser, dom, query, registry, Button, CheckBox, Dialog, template) - { + function (declare, event, array, lang, parser, dom, query, registry, Button, CheckBox, Dialog, template) + { - return declare("qpid.common.grid.ColumnDefDialog", null, { + return declare("qpid.common.grid.ColumnDefDialog", null, { - grid: null, - containerNode: null, - _columns: [], - _dialog: null, - - constructor: function (args) - { - var grid = this.grid = args.grid; - var that = this; - this.containerNode = dom.create("div", {innerHTML: template}); - parser.parse(this.containerNode).then(function (instances) - { - that._postParse(); - }); - }, - _postParse: function () - { - var submitButton = registry.byNode(query(".displayButton", this.containerNode)[0]); - this.closeButton = registry.byNode(query(".cancelButton", this.containerNode)[0]); - var columnsContainer = query(".columnList", this.containerNode)[0]; - - this._buildColumnWidgets(columnsContainer); - - this._dialog = new Dialog({ - "refNode": this.grid.domNode, - "title": "Grid Columns", - "content": this.containerNode - }); - - var self = this; - submitButton.on("click", function (e) - { - self._onColumnsSelect(e); - }); - this.closeButton.on("click", function (e) - { - self._dialog.hide(); - }); - - this._dialog.startup(); - }, - - destroy: function () - { - this._dialog.destroyRecursive(); - this._dialog = null; - this.grid = null; - this.containerNode = null; - this._columns = null; - }, - - showDialog: function () - { - this._initColumnWidgets(); - this._dialog.show(); - }, - - _initColumnWidgets: function () - { - var cells = this.grid.layout.cells; - for (var i in cells) - { - var cell = cells[i]; - this._columns[cell.name].checked = !cell.hidden; - } - }, - - _onColumnsSelect: function (evt) - { - event.stop(evt); - var grid = this.grid; - grid.beginUpdate(); - var cells = grid.layout.cells; - try - { - for (var i in cells) - { - var cell = cells[i]; - var widget = this._columns[cell.name]; - grid.layout.setColumnVisibility(i, widget.checked); - } - } - finally - { - grid.endUpdate(); - this._dialog.hide(); - } - }, - - _buildColumnWidgets: function (columnsContainer) - { - var cells = this.grid.layout.cells; - for (var i in cells) - { - var cell = cells[i]; - var widget = new dijit.form.CheckBox({ - required: false, - checked: !cell.hidden, - label: cell.name, - name: this.grid.id + "_cchb_ " + i - }); - - this._columns[cell.name] = widget; - - var div = dom.create("div"); - div.appendChild(widget.domNode); - div.appendChild(dom.create("span", {innerHTML: cell.name})); - - columnsContainer.appendChild(div); - } - } + grid: null, + containerNode: null, + _columns: [], + _dialog: null, + + constructor: function (args) + { + var grid = this.grid = args.grid; + var that = this; + this.containerNode = dom.create("div", {innerHTML: template}); + parser.parse(this.containerNode) + .then(function (instances) + { + that._postParse(); + }); + }, + _postParse: function () + { + var submitButton = registry.byNode(query(".displayButton", this.containerNode)[0]); + this.closeButton = registry.byNode(query(".cancelButton", this.containerNode)[0]); + var columnsContainer = query(".columnList", this.containerNode)[0]; + + this._buildColumnWidgets(columnsContainer); + + this._dialog = new Dialog({ + "refNode": this.grid.domNode, + "title": "Grid Columns", + "content": this.containerNode + }); + + var self = this; + submitButton.on("click", function (e) + { + self._onColumnsSelect(e); + }); + this.closeButton.on("click", function (e) + { + self._dialog.hide(); + }); + + this._dialog.startup(); + }, + + destroy: function () + { + this._dialog.destroyRecursive(); + this._dialog = null; + this.grid = null; + this.containerNode = null; + this._columns = null; + }, + + showDialog: function () + { + this._initColumnWidgets(); + this._dialog.show(); + }, + + _initColumnWidgets: function () + { + var cells = this.grid.layout.cells; + for (var i in cells) + { + var cell = cells[i]; + this._columns[cell.name].checked = !cell.hidden; + } + }, + + _onColumnsSelect: function (evt) + { + event.stop(evt); + var grid = this.grid; + grid.beginUpdate(); + var cells = grid.layout.cells; + try + { + for (var i in cells) + { + var cell = cells[i]; + var widget = this._columns[cell.name]; + grid.layout.setColumnVisibility(i, widget.checked); + } + } + finally + { + grid.endUpdate(); + this._dialog.hide(); + } + }, + + _buildColumnWidgets: function (columnsContainer) + { + var cells = this.grid.layout.cells; + for (var i in cells) + { + var cell = cells[i]; + var widget = new dijit.form.CheckBox({ + required: false, + checked: !cell.hidden, + label: cell.name, + name: this.grid.id + "_cchb_ " + i + }); + + this._columns[cell.name] = widget; + + var div = dom.create("div"); + div.appendChild(widget.domNode); + div.appendChild(dom.create("span", {innerHTML: cell.name})); + + columnsContainer.appendChild(div); + } + } - }); + }); - }); + }); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/EnhancedFilter.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/EnhancedFilter.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/EnhancedFilter.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/EnhancedFilter.js Mon May 2 15:57:52 2016 @@ -32,222 +32,234 @@ define(["dojo/_base/declare", "dojox/grid/EnhancedGrid", "dojo/i18n!dojox/grid/enhanced/nls/Filter", "qpid/common/grid/EnhancedFilterTools"], - function (declare, lang, array, Toolbar, _Plugin, Dialog, FilterLayer, FilterDefDialog, FilterStatusTip, ClearFilterConfirm, EnhancedGrid, nls, EnhancedFilterTools) - { + function (declare, + lang, + array, + Toolbar, + _Plugin, + Dialog, + FilterLayer, + FilterDefDialog, + FilterStatusTip, + ClearFilterConfirm, + EnhancedGrid, + nls, + EnhancedFilterTools) + { + + // override CriteriaBox#_getColumnOptions to show criteria for hidden columns with EnhancedFilter + dojo.extend(dojox.grid.enhanced.plugins.filter.CriteriaBox, { + _getColumnOptions: function () + { + var colIdx = this.dlg.curColIdx >= 0 ? String(this.dlg.curColIdx) : "anycolumn"; + var filterHidden = this.plugin.filterHidden; + return array.map(array.filter(this.plugin.grid.layout.cells, function (cell) + { + return !(cell.filterable === false || (!filterHidden && cell.hidden)); + }), function (cell) + { + return { + label: cell.name || cell.field, + value: String(cell.index), + selected: colIdx == String(cell.index) + }; + }); + } + }); + + // Enhanced filter has extra functionality for refreshing, limiting rows, displaying/hiding columns in the grid + var EnhancedFilter = declare("qpid.common.grid.EnhancedFilter", _Plugin, { + // summary: + // Accept the same plugin parameters as dojox.grid.enhanced.plugins.Filter and the following: + // + // filterHidden: boolean: + // Whether to display filtering criteria for hidden columns. Default to true. + // + // defaulGridRowLimit: int: + // Default limit for numbers of items to cache in the gris dtore + // + // disableFiltering: boolean: + // Whether to disable a filtering including filter button, clear filter button and filter summary. + // + // toolbar: dijit.Toolbar: + // An instance of toolbar to add the enhanced filter widgets. + + // name: String + // plugin name + name: "enhancedFilter", + + // filterHidden: Boolean + // whether to filter hidden columns + filterHidden: true, + + constructor: function (grid, args) + { + // summary: + // See constructor of dojox.grid.enhanced._Plugin. + this.grid = grid; + this.nls = nls; + this.userPreferences = args.userPreferences; + args = this.args = lang.isObject(args) ? args : {}; + if (typeof args.ruleCount != 'number' || args.ruleCount < 0) + { + args.ruleCount = 0; + } + this.ruleCountToConfirmClearFilter = args.ruleCountToConfirmClearFilter || 5; + + if (args.filterHidden) + { + this.filterHidden = args.filterHidden; + } + this.defaulGridRowLimit = args.defaulGridRowLimit; + this.disableFiltering = args.disableFiltering; + this.displayLastUpdateTime = args.displayLastUpdateTime; + + //Install UI components + var obj = {"plugin": this}; + + this.filterBar = + ( args.toolbar && args.toolbar instanceof dijit.Toolbar) ? args.toolbar : new Toolbar(); + + if (!this.disableFiltering) + { + //Install filter layer + this._wrapStore(); + + this.clearFilterDialog = new Dialog({ + refNode: this.grid.domNode, + title: this.nls["clearFilterDialogTitle"], + content: new ClearFilterConfirm(obj) + }); + + this.filterDefDialog = new FilterDefDialog(obj); + this.filterDefDialog.filterDefPane._clearFilterBtn.set("label", "Clear Filter"); + + nls["statusTipTitleNoFilter"] = "Filter is not set"; + nls["statusTipMsg"] = "Click on 'Set Filter' button to specify filtering conditions"; + this.filterStatusTip = new FilterStatusTip(obj); + + var self = this; + var toggleClearFilterBtn = function (arg) + { + self.enhancedFilterTools.toggleClearFilterBtn(arg); + }; + + this.filterBar.toggleClearFilterBtn = toggleClearFilterBtn; + + this.grid.isFilterBarShown = function () + { + return true + }; + + this.connect(this.grid.layer("filter"), "onFilterDefined", function (filter) + { + toggleClearFilterBtn(true); + }); + + //Expose the layer event to grid. + grid.onFilterDefined = function () + { + }; + this.connect(grid.layer("filter"), "onFilterDefined", function (filter) + { + grid.onFilterDefined(grid.getFilter(), grid.getFilterRelation()); + }); + } + + // add extra buttons into toolbar + this.enhancedFilterTools = new EnhancedFilterTools({ + grid: grid, + toolbar: this.filterBar, + filterStatusTip: this.filterStatusTip, + clearFilterDialog: this.clearFilterDialog, + filterDefDialog: this.filterDefDialog, + defaulGridRowLimit: this.defaulGridRowLimit, + disableFiltering: this.disableFiltering, + displayLastUpdateTime: this.displayLastUpdateTime, + nls: nls, + ruleCountToConfirmClearFilter: this.ruleCountToConfirmClearFilter, + userPreferences: this.userPreferences + }); + + this.filterBar.placeAt(this.grid.viewsHeaderNode, "before"); + this.filterBar.startup(); + + }, + + destroy: function () + { + this.inherited(arguments); + try + { + if (this.filterDefDialog) + { + this.filterDefDialog.destroy(); + this.filterDefDialog = null; + } + if (this.grid) + { + this.grid.unwrap("filter"); + this.grid = null; + } + if (this.filterBar) + { + this.filterBar.destroyRecursive(); + this.filterBar = null; + } + if (this.enhancedFilterTools) + { + this.enhancedFilterTools.destroy(); + this.enhancedFilterTools = null; + } + if (this.clearFilterDialog) + { + this.clearFilterDialog.destroyRecursive(); + this.clearFilterDialog = null; + } + if (this.filterStatusTip) + { + this.filterStatusTip.destroy(); + this.filterStatusTip = null; + } + this.args = null; + + } + catch (e) + { + console.warn("Filter.destroy() error:", e); + } + }, + + _wrapStore: function () + { + var g = this.grid; + var args = this.args; + var filterLayer = args.isServerSide + ? new FilterLayer.ServerSideFilterLayer(args) + : new FilterLayer.ClientSideFilterLayer({ + cacheSize: args.filterCacheSize, + fetchAll: args.fetchAllOnFirstFilter, + getter: this._clientFilterGetter + }); + FilterLayer.wrap(g, "_storeLayerFetch", filterLayer); + + this.connect(g, "_onDelete", lang.hitch(filterLayer, "invalidate")); + }, + + onSetStore: function (store) + { + this.filterDefDialog.clearFilter(true); + }, + + _clientFilterGetter: function (/* data item */ datarow, /* cell */cell, /* int */rowIndex) + { + return cell.get(rowIndex, datarow); + } - // override CriteriaBox#_getColumnOptions to show criteria for hidden columns with EnhancedFilter - dojo.extend(dojox.grid.enhanced.plugins.filter.CriteriaBox, { - _getColumnOptions: function () - { - var colIdx = this.dlg.curColIdx >= 0 ? String(this.dlg.curColIdx) : "anycolumn"; - var filterHidden = this.plugin.filterHidden; - return array.map(array.filter(this.plugin.grid.layout.cells, function (cell) - { - return !(cell.filterable === false || (!filterHidden && cell.hidden)); - }), function (cell) - { - return { - label: cell.name || cell.field, - value: String(cell.index), - selected: colIdx == String(cell.index) - }; - }); - } - }); - - // Enhanced filter has extra functionality for refreshing, limiting rows, displaying/hiding columns in the grid - var EnhancedFilter = declare("qpid.common.grid.EnhancedFilter", _Plugin, { - // summary: - // Accept the same plugin parameters as dojox.grid.enhanced.plugins.Filter and the following: - // - // filterHidden: boolean: - // Whether to display filtering criteria for hidden columns. Default to true. - // - // defaulGridRowLimit: int: - // Default limit for numbers of items to cache in the gris dtore - // - // disableFiltering: boolean: - // Whether to disable a filtering including filter button, clear filter button and filter summary. - // - // toolbar: dijit.Toolbar: - // An instance of toolbar to add the enhanced filter widgets. - - // name: String - // plugin name - name: "enhancedFilter", - - // filterHidden: Boolean - // whether to filter hidden columns - filterHidden: true, - - constructor: function (grid, args) - { - // summary: - // See constructor of dojox.grid.enhanced._Plugin. - this.grid = grid; - this.nls = nls; - this.userPreferences = args.userPreferences; - args = this.args = lang.isObject(args) ? args : {}; - if (typeof args.ruleCount != 'number' || args.ruleCount < 0) - { - args.ruleCount = 0; - } - this.ruleCountToConfirmClearFilter = args.ruleCountToConfirmClearFilter || 5; - - if (args.filterHidden) - { - this.filterHidden = args.filterHidden; - } - this.defaulGridRowLimit = args.defaulGridRowLimit; - this.disableFiltering = args.disableFiltering; - this.displayLastUpdateTime = args.displayLastUpdateTime; - - //Install UI components - var obj = {"plugin": this}; - - this.filterBar = - ( args.toolbar && args.toolbar instanceof dijit.Toolbar) ? args.toolbar : new Toolbar(); - - if (!this.disableFiltering) - { - //Install filter layer - this._wrapStore(); - - this.clearFilterDialog = new Dialog({ - refNode: this.grid.domNode, - title: this.nls["clearFilterDialogTitle"], - content: new ClearFilterConfirm(obj) - }); - - this.filterDefDialog = new FilterDefDialog(obj); - this.filterDefDialog.filterDefPane._clearFilterBtn.set("label", "Clear Filter"); - - nls["statusTipTitleNoFilter"] = "Filter is not set"; - nls["statusTipMsg"] = "Click on 'Set Filter' button to specify filtering conditions"; - this.filterStatusTip = new FilterStatusTip(obj); - - var self = this; - var toggleClearFilterBtn = function (arg) - { - self.enhancedFilterTools.toggleClearFilterBtn(arg); - }; - - this.filterBar.toggleClearFilterBtn = toggleClearFilterBtn; - - this.grid.isFilterBarShown = function () - { - return true - }; - - this.connect(this.grid.layer("filter"), "onFilterDefined", function (filter) - { - toggleClearFilterBtn(true); - }); - - //Expose the layer event to grid. - grid.onFilterDefined = function () - { - }; - this.connect(grid.layer("filter"), "onFilterDefined", function (filter) - { - grid.onFilterDefined(grid.getFilter(), grid.getFilterRelation()); - }); - } - - // add extra buttons into toolbar - this.enhancedFilterTools = new EnhancedFilterTools({ - grid: grid, - toolbar: this.filterBar, - filterStatusTip: this.filterStatusTip, - clearFilterDialog: this.clearFilterDialog, - filterDefDialog: this.filterDefDialog, - defaulGridRowLimit: this.defaulGridRowLimit, - disableFiltering: this.disableFiltering, - displayLastUpdateTime: this.displayLastUpdateTime, - nls: nls, - ruleCountToConfirmClearFilter: this.ruleCountToConfirmClearFilter, - userPreferences: this.userPreferences - }); - - this.filterBar.placeAt(this.grid.viewsHeaderNode, "before"); - this.filterBar.startup(); - - }, - - destroy: function () - { - this.inherited(arguments); - try - { - if (this.filterDefDialog) - { - this.filterDefDialog.destroy(); - this.filterDefDialog = null; - } - if (this.grid) - { - this.grid.unwrap("filter"); - this.grid = null; - } - if (this.filterBar) - { - this.filterBar.destroyRecursive(); - this.filterBar = null; - } - if (this.enhancedFilterTools) - { - this.enhancedFilterTools.destroy(); - this.enhancedFilterTools = null; - } - if (this.clearFilterDialog) - { - this.clearFilterDialog.destroyRecursive(); - this.clearFilterDialog = null; - } - if (this.filterStatusTip) - { - this.filterStatusTip.destroy(); - this.filterStatusTip = null; - } - this.args = null; - - } - catch (e) - { - console.warn("Filter.destroy() error:", e); - } - }, - - _wrapStore: function () - { - var g = this.grid; - var args = this.args; - var filterLayer = args.isServerSide - ? new FilterLayer.ServerSideFilterLayer(args) - : new FilterLayer.ClientSideFilterLayer({ - cacheSize: args.filterCacheSize, - fetchAll: args.fetchAllOnFirstFilter, - getter: this._clientFilterGetter - }); - FilterLayer.wrap(g, "_storeLayerFetch", filterLayer); - - this.connect(g, "_onDelete", lang.hitch(filterLayer, "invalidate")); - }, - - onSetStore: function (store) - { - this.filterDefDialog.clearFilter(true); - }, - - _clientFilterGetter: function (/* data item */ datarow, /* cell */cell, /* int */rowIndex) - { - return cell.get(rowIndex, datarow); - } + }); - }); + EnhancedGrid.registerPlugin(EnhancedFilter); - EnhancedGrid.registerPlugin(EnhancedFilter); + return EnhancedFilter; - return EnhancedFilter; - - }); + }); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
