Added: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBuilder.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBuilder.js?rev=1738933&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBuilder.js (added) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBuilder.js Wed Apr 13 12:58:41 2016 @@ -0,0 +1,618 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +define(["dojo/_base/declare", + "dojo/_base/lang", + "dojo/parser", + "dojo/dom-construct", + "dojo/json", + "dojo/text!query/QueryBuilder.html", + "dojox/html/entities", + "dgrid/Grid", + "dgrid/Keyboard", + "dgrid/Selection", + "dgrid/extensions/Pagination", + "dgrid/Selector", + "dstore/Memory", + 'dstore/legacy/DstoreAdapter', + "qpid/management/query/DropDownSelect", + "qpid/management/query/WhereExpression", + "dojo/Evented", + "dijit/_WidgetBase", + "dijit/_TemplatedMixin", + "dijit/_WidgetsInTemplateMixin", + "dijit/form/FilteringSelect", + "dijit/form/ComboBox", + "dijit/form/Button", + "dijit/form/ComboButton", + "dijit/form/CheckBox", + "dijit/form/DropDownButton", + "dijit/form/NumberTextBox", + "dijit/form/ValidationTextBox", + "dijit/form/Select", + "dijit/form/SimpleTextarea", + "dijit/Menu", + "dijit/MenuItem", + "dijit/Toolbar", + "dijit/TooltipDialog", + "dijit/Dialog", + "dojo/Deferred", + "dojo/json" + ], + function(declare, + lang, + parser, + domConstruct, + json, + template, + entities, + Grid, + Keyboard, + Selection, + Pagination, + Selector, + Memory, + DstoreAdapter, + DropDownSelect, + WhereExpression + ) + { + var selectExpressionToArray = function(value) + { + var columns = []; + if (value) + { + var attributes = value.split(","); + for (var i in attributes) + { + var attribute = attributes[i].replace(/^\s+|\s+$/gm,''); + columns.push(attribute); + } + } + return columns; + }; + + var arrayToSelectExpression = function(value) + { + var expression = ""; + if (lang.isArray(value)) + { + for(var i=0; i<value.length ;i++) + { + var selection = value[i] && value[i].hasOwnProperty("attributeName") ? + value[i].attributeName : value[i]; + expression = expression + (i > 0 ? "," : "") + selection; + } + } + return expression; + }; + var predefinedCategories = [ {id: "queue", name: "queue"}, {id: "connection", name: "connection"} ]; + + return declare( "qpid.management.query.QueryBuilder", + [dijit._Widget, dijit._TemplatedMixin, dijit._WidgetsInTemplateMixin], + { + //Strip out the apache comment header from the template html as comments unsupported. + templateString: template.replace(/<!--[\s\S]*?-->/g, ""), + + /** + * Fields from template + **/ + scope:null, + categoryName: null, + advancedSearch: null, + selectExpression: null, + whereExpression: null, + standardSearch: null, + selectColumnsButton: null, + selectWhereButton: null, + searchButton: null, + modeButton: null, + whereExpressionBuilder: null, + queryResultGrid: null, + + /** + * constructor parameter + */ + _management: null, + + /** + * Inner fields + */ + _standardMode: true, + _standardModeLastWhereExpression: null, + _standardModeLastSelectExpression: null, + _scopeModelObjects: {}, + _categorySelector: null, + _searchScopeSelector: null, + _lastCategory: null, + _lastSearchQuery: null, + + constructor: function(args) + { + this._management = args.management; + this.inherited(arguments); + }, + postCreate: function() + { + this.inherited(arguments); + this._postCreate(); + }, + _postCreate: function() + { + var promise = this._createScopeList(); + promise.then(lang.hitch(this, this. _postCreateScope)); + }, + _postCreateScope: function() + { + this._createCategoryList(); + + // advanced mode widgets + this.selectExpression.on("change", lang.hitch(this, this._advancedModeSelectChanged)); + this.whereExpression.on("change", lang.hitch(this, this._advancedModeWhereChanged)); + this.selectExpression.on("keyUp", lang.hitch(this, this._advancedModeKeyPressed)); + this.whereExpression.on("keyUp", lang.hitch(this, this._advancedModeKeyPressed)); + + // standard mode widgets + this.selectColumnsButton.on("change", lang.hitch(this, this._standardModeSelectChanged)); + this.selectColumnsButton.startup(); + this.selectWhereButton.startup(); + this.whereExpressionBuilder.set("whereFieldsSelector", this.selectWhereButton ); + this.whereExpressionBuilder.startup(); + this.whereExpressionBuilder.on("change", lang.hitch(this, this._standardModeWhereChanged)); + + // search & mode buttons + this.searchButton.on("click", lang.hitch(this, this.search)); + this.modeButton.on("click", lang.hitch(this, this._modeChanged)); + + this._categoryChanged(); + this._toggleSearchButton(); + }, + search: function() + { + var select, where; + if (this._standardMode) + { + select = this._standardModeLastSelectExpression; + where = this._standardModeLastWhereExpression; + } + else + { + select = this.selectExpression.value; + where = this.whereExpression.value; + this._resetStandardSearchWidgetsIfAdvancedChanged(); + } + + var category = this._categorySelector.value.toLowerCase(); + if (select && category) + { + var scope = this._searchScopeSelector.value; + this._lastSearchQuery = {scope:scope, select: select, where: where, category: category}; + var modelObj = this._scopeModelObjects[scope]; + this._doSearch( modelObj, category, select, where); + } + }, + _doSearch: function(modelObj, category, select, where) + { + var that = this; + var result = this._management.query({select: select, + where: where, + parent: modelObj, + category: category, + transformIntoObjects: true}); + result.then(function(data) + { + that._showResults(data, select); + }, + function(error) + { + if (error && error.response && error.response.status == 404) + { + that._showResults([], select); + } + else + { + alert(error.message ? error.message: error); + } + }); + }, + _advancedModeWhereChanged: function() + { + if (this._standardModeLastWhereExpression && !this._standardMode) + { + dijit.showTooltip("On switching into Standard Mode where expression" + + " will be erased. Copying of where expression from " + + " Advanced Mode into Standard Mode is unsupported!", + this.whereExpression.domNode, + this.whereExpression.get("tooltipPosition"), + !this.whereExpression.isLeftToRight()); + } + }, + _advancedModeSelectChanged: function() + { + this._toggleSearchButton(this.selectExpression.value); + }, + _toggleSearchButton: function(select) + { + var criteriaNotSet = !select; + this.searchButton.set("disabled",criteriaNotSet); + this.searchButton.set("title", criteriaNotSet?"Please, choose fields to display in order to enable search":"Search"); + }, + _standardModeSelectChanged: function(result) + { + this._standardModeLastSelectExpression = arrayToSelectExpression(result); + this.selectExpression.set("value", this._standardModeLastSelectExpression); + this.search(); + }, + _standardModeWhereChanged: function(result) + { + this._standardModeLastWhereExpression = result; + this.whereExpression.set("value", result); + this.search(); + }, + _resetStandardSearchWidgetsIfAdvancedChanged: function() + { + if (this._standardModeLastWhereExpression && this._standardModeLastWhereExpression != this.whereExpression.value) + { + this._standardModeLastWhereExpression = ""; + this.whereExpressionBuilder.clearWhereCriteria(); + } + + if (this._standardModeLastSelectExpression != this.selectExpression.value) + { + this._standardModeLastSelectExpression = this.selectExpression.value; + this.selectColumnsButton.set("data", {selected: selectExpressionToArray(this.selectExpression.value)}); + var promise = this.selectColumnsButton.get("selectedItems"); + dojo.when(promise, + lang.hitch(this, + function(selectedItems) + { + var val = arrayToSelectExpression(selectedItems); + this._standardModeLastSelectExpression = val; + })); + } + }, + _showResults:function(data, select) + { + var store = new Memory({data: data, idProperty: 'id'}); + if (!this._resultsGrid) + { + if (select) + { + this._buildGrid(store, select); + } + } + else + { + this._resultsGrid.set("collection", store); + this._resultsGrid.set("columns", this._getColumns(select)); + this._resultsGrid.refresh(); + } + }, + _buildGrid: function(store, select) + { + var CustomGrid = declare([ Grid, Keyboard, Selection, Pagination ]); + var grid = new CustomGrid({ + columns: this._getColumns(select), + collection: store, + rowsPerPage: 100, + selectionMode: 'single', + cellNavigation: false, + className: 'dgrid-autoheight' + }, + this.queryResultGrid); + this._resultsGrid = grid; + this._resultsGrid.startup(); + this._resultsGrid.on('.dgrid-row:dblclick', lang.hitch(this, this._onRowClick)); + }, + _onRowClick: function (event) + { + var row = this._resultsGrid.row(event); + var promise = this._management.get({url:"service/structure"}); + var that = this; + promise.then(function (data) + { + var findObject = function findObject(structure, parent, type) + { + var item = {id:structure.id, + name: structure.name, + type: type, + parent: parent}; + if (item.id == row.id) + { + return item; + } + else + { + for(var fieldName in structure) + { + var fieldValue = structure[fieldName]; + if (lang.isArray(fieldValue)) + { + var fieldType = fieldName.substring(0, fieldName.length - 1); + for (var i = 0; i < fieldValue.length; i++) + { + var object = fieldValue[i]; + var result = findObject(object, item, fieldType); + if (result != null) + { + return result; + } + } + } + } + return null; + } + }; + + var item = findObject(data, null, "broker"); + if (item != null) + { + that.controller.show(item.type, item.name, item.parent, item.id); + } + }); + }, + _getColumns: function(select) + { + var columns = {}; + if (select) + { + var attributes = select.split(","); + for (var i in attributes) + { + var attribute = attributes[i].replace(/^\s+|\s+$/gm,''); + columns[attribute] = attribute; + } + } + return columns; + }, + _createScopeList: function() + { + var that = this; + var result = this._management.query({select: "$parent.name, name, id", + category : "virtualhost", + transformIntoObjects: true}); + var deferred = new dojo.Deferred(); + result.then(function(data) + { + try + { + that._scopeDataReceived(data); + } + finally + { + deferred.resolve(that._searchScopeSelector); + } + }, + function(error) + { + deferred.reject(null); + console.error(error.message ? error.message : error); + }); + return deferred.promise; + }, + _scopeDataReceived: function(data) + { + this._scopeModelObjects = {}; + var defaultValue = undefined; + var items = [{id:undefined, name: "Broker"}]; + for(var i =0 ; i<data.length;i++) + { + var name = data[i].name; + var parentName = data[i]["$parent.name"]; + items.push({id: data[i].id, name: "VH:" + parentName + "/" + name}); + this._scopeModelObjects[data[i].id] = {name: name, + type: "virtualhost", + parent: {name: parentName, + type: "virtualhostnode", + parent: {type: "broker"} + } + }; + if (this.parentModelObj && + this.parentModelObj.type == "virtualhost" && + this.parentModelObj.name == name && + this.parentModelObj.parent && + this.parentModelObj.parent.name == parentName) + { + defaultValue = data[i].id; + } + } + + var scopeStore = new DstoreAdapter (new Memory({data: items, + idProperty: 'id'})); + this._searchScopeSelector = new dijit.form.FilteringSelect({ name: "scope", + placeHolder: "Select search scope", + store: scopeStore, + value: defaultValue, + required: false, + "class": "queryDefaultField" + }, + this.scope); + this._searchScopeSelector.startup(); + }, + _createCategoryList: function() + { + var categoryStore = new DstoreAdapter(new Memory({idProperty: "id", + data: predefinedCategories})); + var categoryList = new dijit.form.ComboBox({name: "category", + placeHolder: "Select Category", + store: categoryStore, + value: this._category || "queue", + required: true, + invalidMessage: "Invalid category specified", + "class": "queryDefaultField" + }, + this.categoryName); + categoryList.startup(); + categoryList.on("change", lang.hitch(this, this._categoryChanged)); + this._categorySelector = categoryList; + }, + _categoryChanged: function() + { + var metadata = this._getCategoryMetadata(this._categorySelector.value); + var disableMetadataDependant = !metadata; + this.selectWhereButton.set("disabled", disableMetadataDependant); + this.selectColumnsButton.set("disabled", disableMetadataDependant); + this.searchButton.set("disabled", disableMetadataDependant); + if (disableMetadataDependant) + { + dijit.showTooltip( + this._categorySelector.get("invalidMessage"), + this._categorySelector.domNode, + this._categorySelector.get("tooltipPosition"), + !this._categorySelector.isLeftToRight() + ); + } + else + { + if (this._lastCategory != this._categorySelector.value) + { + this._standardModeLastWhereExpression = ""; + this._lastCategory = this._categorySelector.value; + this.selectExpression.set("value", ""); + this.whereExpression.set("value", ""); + this.whereExpressionBuilder.clearWhereCriteria(); + var columns = this._extractFieldsFromMetadata(metadata); + this.selectColumnsButton.set("data", {items: columns, + idProperty: "id", + selected:[], + nameProperty: "attributeName"}); + this.selectWhereButton.set("data", {items: columns, + selected:[], + idProperty: "id", + nameProperty: "attributeName"}); + this._showResults([], ""); + } + } + }, + _advancedModeKeyPressed:function(evt) + { + var key = evt.keyCode; + if (key == dojo.keys.ENTER && this.selectExpression.value) + { + this.search(); + } + }, + _modeChanged: function() + { + this._standardMode = !this._standardMode + if (!this._standardMode) + { + this.modeButton.set("label", "Standard"); + this.modeButton.set("title", "Switch to 'Standard' search"); + this.selectExpression.set("disabled", false); + this.whereExpression.set("disabled", false); + this.standardSearch.style.display = "none"; + this.whereExpressionBuilder.domNode.style.display = "none"; + this.advancedSearch.style.display = ""; + if (this._lastSearchQuery && + (this._lastSearchQuery.select != this.selectExpression.value || + this._lastSearchQuery.where != this.whereExpression.value || + this._lastSearchQuery.category != this._categorySelector.value || + this._lastSearchQuery.scope != this._searchScopeSelector.value)) + { + this.search(); + } + } + else + { + this.modeButton.set("label", "Advanced"); + this.modeButton.set("title", "Switch to 'Advanced' search using SQL-like expressions"); + this.selectExpression.set("disabled", true); + this.whereExpression.set("disabled", true); + this.standardSearch.style.display = ""; + this.whereExpressionBuilder.domNode.style.display = ""; + this.advancedSearch.style.display = "none"; + + if (this._lastSearchQuery && + (this._lastSearchQuery.select != this._standardModeLastSelectExpression || + this._lastSearchQuery.where != this._standardModeLastWhereExpression || + this._lastSearchQuery.category != this._categorySelector.value || + this._lastSearchQuery.scope != this._searchScopeSelector.value)) + { + this.search(); + } + } + }, + _getCategoryMetadata: function(value) + { + if (value) + { + var category = value.charAt(0).toUpperCase() + value.substring(1); + return this._management.metadata.metadata[category]; + } + else + { + return undefined; + } + }, + _extractFieldsFromMetadata: function(metadata) + { + var columns = []; + var helper = {}; + var validTypes = []; + var typeAttribute = null; + for(var i in metadata) + { + validTypes.push(i); + var categoryType = metadata[i]; + var attributes = categoryType.attributes; + for(var name in attributes) + { + var attribute = attributes[name]; + if (!(name in helper)) + { + helper[name] = true; + var attributeData = {id: name, + attributeName: name, + type: attribute.type, + validValues: attribute.validValues, + description: attribute.description, + columnType: "attribute"}; + if (name === "type") + { + typeAttribute = attributeData; + } + columns.push(attributeData ); + } + } + + var statistics = categoryType.statistics; + for(var name in statistics) + { + var statistic = statistics[name]; + if (!(name in helper)) + { + helper[name] = true; + columns.push( {id: name, + attributeName: name, + type: statistic.type, + description: statistic.description, + columnType: "statistics"}); + } + } + } + if (typeAttribute != null && !typeAttribute.validValues) + { + typeAttribute.validValues = validTypes; + } + return columns; + } + }); + });
Added: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereCriteria.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereCriteria.js?rev=1738933&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereCriteria.js (added) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereCriteria.js Wed Apr 13 12:58:41 2016 @@ -0,0 +1,262 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +define([ + "dojo/_base/declare", + "dojo/_base/array", + "dojo/_base/lang", + "dojo/string", + "dojo/text!query/WhereCriteria.html", + "dojox/html/entities", + "dijit/popup", + "qpid/management/query/CriteriaPane", + "dojo/Evented", + "dijit/_WidgetBase", + "dijit/_TemplatedMixin", + "dijit/_WidgetsInTemplateMixin", + "dijit/layout/ContentPane", + "dijit/form/Button", + "dijit/form/ValidationTextBox", + "dijit/form/TextBox", + "dijit/form/Select", + "dijit/form/Form", + "dijit/_Container", + "dijit/form/SimpleTextarea", + "dijit/InlineEditBox", + "dojo/domReady!" +], +function(declare, array, lang, string, template, entities, popup, CriteriaPane, Evented) +{ + return declare("qpid.management.query.WhereCriteria", + [dijit._WidgetBase, dijit._TemplatedMixin, dijit._WidgetsInTemplateMixin, Evented], + { + //Strip out the apache comment header from the template html as comments unsupported. + templateString: template.replace(/<!--[\s\S]*?-->/g, ""), + + /** + * template attach points + */ + removeCriteria: null, + doneButton: null, + cancelButton: null, + addButton: null, + criteriaMatchCondition: null, + editDialog: null, + conditionDialogContent: null, + criteriaContainer: null, + newColumnCondition: null, + + /** + * constructor arguments + */ + attributeDetails: null, + + /** + * inner fields + */ + _deleted: false, + + constructor: function(args) + { + this.attributeDetails = args.attributeDetails; + this.inherited(arguments); + }, + postCreate: function() + { + this.inherited(arguments); + this._postCreate(); + }, + _getDeletedAttr() + { + return this._deleted; + }, + _postCreate: function() + { + this.removeCriteria.on("click", lang.hitch(this, this._destroy)); + this.doneButton.on("click", lang.hitch(this, this._criteriaSet)); + this.cancelButton.on("click", lang.hitch(this, this._dialogCancelled)); + this.addButton.on("click", lang.hitch(this, this._addCriteria)); + this.criteriaMatchCondition.on("change", lang.hitch(this, this._criteriaConditionChanged)); + var criteriaPane = this._addCriteria({_stored:true}); + criteriaPane.submitted(); + this._displayExpression(); + this._criteriaConditionChanged(); + this.editDialog.on("hide", lang.hitch(this, this._dialogHidden)); + }, + _addCriteria:function() + { + var criteriaPane = new CriteriaPane({criteriaName: this.attributeDetails.attributeName, + typeName: this.attributeDetails.type, + typeValidValues: this.attributeDetails.validValues}); + this.criteriaContainer.addChild(criteriaPane); + criteriaPane.on("change", lang.hitch(this, this._criteriaConditionChanged)); + this._updateRemovable(); + this.conditionDialogContent.connectChildren(); + return criteriaPane; + }, + _getNumberOfCriteria : function() + { + var counter = 0; + var criteriaArray = this.criteriaContainer.getChildren(); + for(var i = 0;i<criteriaArray.length;i++) + { + if (!criteriaArray[i]._removed) + { + counter = counter + 1; + } + } + return counter; + }, + _updateRemovable: function() + { + var counter = this._getNumberOfCriteria(); + var singleCriteria = counter == 1; + var criteriaArray = this.criteriaContainer.getChildren(); + for(var i = 0;i<criteriaArray.length;i++) + { + if (!criteriaArray[i]._removed) + { + criteriaArray[i].setRemovable(!singleCriteria); + } + } + this.criteriaMatchCondition.set("disabled", singleCriteria); + }, + _getUserFriendlyExpression: function() + { + var expression = this.getConditionExpression(); + if (!expression) + { + expression = this.attributeDetails.attributeName + ": any"; + } + return expression; + }, + _displayExpression: function() + { + var expression = this._getUserFriendlyExpression(); + this.criteria.set("label", expression); + }, + _criteriaConditionChanged: function() + { + this.conditionDialogContent.connectChildren(); + var isValid = this._validateCriteria(); + if (isValid) + { + var expression = this._getUserFriendlyExpression(); + this.newColumnCondition.set("value", expression); + this._updateRemovable(); + } + this.doneButton.set("disabled", !isValid); + }, + _validateCriteria:function() + { + var isValid = true; + var criteriaArray = this.criteriaContainer.getChildren(); + for(var i = 0;i<criteriaArray.length;i++) + { + if (!criteriaArray[i].validate()) + { + isValid = false; + } + } + return isValid; + }, + _getAttributeDetailsAttr: function() + { + return this.attributeDetails; + }, + getConditionExpression:function() + { + if (this._deleted) + { + return undefined; + } + + var expression = ""; + var criteriaArray = this.criteriaContainer.getChildren(); + var criteriaCounter = 0; + for(var i = 0;i<criteriaArray.length;i++) + { + var criteria = criteriaArray[i].getExpression(); + if (criteria) + { + if (expression) + { + expression = expression + " " + this.criteriaMatchCondition.value; + } + expression = expression + " " + criteria; + criteriaCounter = criteriaCounter + 1; + } + } + if (criteriaCounter>0 && this.criteriaMatchCondition.value == "or") + { + expression = "( " + expression + " )" + } + return expression; + }, + _destroy: function() + { + this._deleted = true; + try + { + // notify listeners which are listening for onChange events + this.emit("change", this); + } + finally + { + this.destroyRecursive(false); + } + }, + _criteriaSet: function() + { + var isValid = this._validateCriteria(); + if (isValid) + { + this._displayExpression(); + var criteriaArray = this.criteriaContainer.getChildren(); + for(var i = 0;i<criteriaArray.length;i++) + { + criteriaArray[i].submitted(); + } + popup.close(this.editDialog); + + // notify listeners which are listening for onChange events + this.emit("change", this); + } + }, + _dialogCancelled: function() + { + popup.close(this.editDialog); + this._dialogHidden(); + }, + _dialogHidden: function() + { + var criteriaArray = this.criteriaContainer.getChildren(); + for(var i = 0;i<criteriaArray.length;i++) + { + if (criteriaArray[i].cancelled) + { + criteriaArray[i].cancelled(); + } + } + this._updateRemovable(); + } + }); +}); \ No newline at end of file Added: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereExpression.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereExpression.js?rev=1738933&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereExpression.js (added) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereExpression.js Wed Apr 13 12:58:41 2016 @@ -0,0 +1,148 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +define([ + "dojo/_base/declare", + "dojo/_base/array", + "dojo/_base/lang", + "dojo/dom-construct", + "dojo/Evented", + "dijit/layout/ContentPane", + "qpid/management/query/WhereCriteria", + "dojo/domReady!" +], +function(declare, array, lang, domConstruct, Evented, ContentPane, WhereCriteria) +{ + return declare("qpid.management.query.WhereExpression", + [ContentPane, Evented], + { + whereExpression: "", + whereFieldsSelector: null, + _whereItems: {}, + + postCreate: function() + { + this.inherited(arguments); + if (this.whereFieldsSelector) + { + this.whereFieldsSelector.on("change", lang.hitch(this, this._whereExpressionChanged)); + var promise = this.whereFieldsSelector.get("selectedItems"); + dojo.when(promise, + lang.hitch(this, + function(selectedItems) + { + this._whereExpressionChanged(selectedItems); + })); + + } + }, + _setWhereFieldsSelectorAttr: function(whereFieldsSelector) + { + this.whereFieldsSelector = whereFieldsSelector; + this.whereFieldsSelector.on("change", lang.hitch(this, this._whereExpressionChanged)); + var promise = this.whereFieldsSelector.get("selectedItems"); + dojo.when(promise, lang.hitch(this, function(items){this._whereExpressionChanged(items);})); + }, + _whereExpressionChanged: function(items) + { + this._buildWhereCriteriaWidgets(items); + this._notifyChanged(); + }, + _buildWhereCriteriaWidgets: function(items) + { + for(var i =0; i< items.length; i++) + { + var name = items[i].attributeName; + if (!(name in this._whereItems)) + { + this._whereItems[name] = this._createWhereCriteriaWidget(items[i]); + } + } + }, + _createWhereCriteriaWidget: function(item) + { + var whereCriteria = new WhereCriteria({attributeDetails: item}, + domConstruct.create("div")); + this.addChild(whereCriteria); + whereCriteria.startup(); + whereCriteria.on("change", lang.hitch(this, this._whereCriteriaChanged)); + return whereCriteria; + }, + _notifyChanged:function() + { + this.whereExpression = this._getWhereExpression(); + this.emit("change", this.whereExpression); + }, + _whereCriteriaChanged: function(whereCriteria) + { + if (whereCriteria.get("deleted")) + { + delete this._whereItems[whereCriteria.get("attributeDetails").attributeName]; + this.removeChild(whereCriteria); + } + this._notifyChanged(); + }, + _getWhereExpressionAttr: function() + { + if (!this.whereExpression) + { + this.whereExpression = this._getWhereExpression(); + } + return this.whereExpression; + }, + _getWhereExpression: function() + { + var columnsAfterChange = []; + var whereExpression = ""; + var children = this.getChildren(); + var selected = []; + for(var i=0;i<children.length;i++) + { + if (!children[i].get("deleted")) + { + var details = children[i].get("attributeDetails"); + columnsAfterChange.push(details); + selected.push(details.id); + var expression = children[i].getConditionExpression(); + if (expression) + { + whereExpression = whereExpression + (whereExpression ? " and " : "") + expression; + } + } + } + this.whereFieldsSelector.set("data",{selected: selected}); + return whereExpression; + }, + clearWhereCriteria: function() + { + this._whereItems = {}; + var children = this.getChildren(); + for(var i=children.length-1;i>=0;i--) + { + children[i].destroyRecursive(false); + } + if (this.whereFieldsSelector) + { + this.whereFieldsSelector.set("data", {selected:[]}); + } + } + }); +}); \ No newline at end of file Added: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/CriteriaPane.html URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/CriteriaPane.html?rev=1738933&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/CriteriaPane.html (added) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/CriteriaPane.html Wed Apr 13 12:58:41 2016 @@ -0,0 +1,42 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<div class="criteriaControl"> + <div data-dojo-attach-point="contentPane" class="dijitTitlePane"> + <div data-dojo-attach-point="titleNode" class="dijitReset dijitTitlePaneTitle dijitTitlePaneTitleOpen criteriaPanelTitle"> + <div> + <div data-dojo-attach-point="conditionExpression" class="dijitInline alignLeft dijitTitlePaneTextNode criteriaPanelTitleText"></div> + <span data-dojo-attach-point="removeCriteria" + data-dojo-type="dijit/form/Button" + data-dojo-props="iconClass:'dijitIconDelete', + showLabel:false, + title: 'Remove'" class="dijitInline alignRight criteriaPanelTitleButton">Remove</span> + </div> + <div class="clear"></div> + </div> + <div class="dijitTitlePaneContentOuter dijitTitlePaneContentInner"> + <select data-dojo-attach-point="criteriaCondition" + data-dojo-type="dijit/form/Select" + data-dojo-props="value: 'any', + placeHolder: 'Select Condition', + required: true" class="dijitInline"> + </select> + <span data-dojo-attach-point="criteriaValueInputContainer" class="dijitInline"></span> + </div> + </div> +</div> Added: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/OptionsPanel.html URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/OptionsPanel.html?rev=1738933&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/OptionsPanel.html (added) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/OptionsPanel.html Wed Apr 13 12:58:41 2016 @@ -0,0 +1,51 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<div id="${id}_contentPanel" + data-dojo-type="dijit/layout/ContentPane"> + <div class="dijitDialogPaneContentArea"> + <input id="${id}_search" + data-dojo-attach-point="search" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props="name: 'column', + intermediateChanges: true, + placeHolder: 'field name', + title: 'Start typing field name'" type="text"/></label> + <div id="${id}_clearButton" + data-dojo-type="dijit/form/Button" + data-dojo-attach-point="clearButton" + data-dojo-props="iconClass:'dijitIconDelete', + showLabel:false, + title: 'Clear Search'">Clear</div> + <div data-dojo-attach-point="optionsGrid" class="selectGrid"> + </div> + </div> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> + <input id="${id}_cancelButton" + data-dojo-attach-point="cancelButton" + data-dojo-type="dijit/form/Button" + type="button" + label="Cancel"/> + <input id="${id}_doneButton" + data-dojo-attach-point="doneButton" + data-dojo-type="dijit/form/Button" + type="button" label="Done"/> + </div> +</div> + + Added: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/QueryBuilder.html URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/QueryBuilder.html?rev=1738933&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/QueryBuilder.html (added) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/QueryBuilder.html Wed Apr 13 12:58:41 2016 @@ -0,0 +1,66 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<div> + <div class="dijit dijitToolbar"> + <label>Scope : <span data-dojo-attach-point="scope"></span></label> + <label>Category : <span data-dojo-attach-point="categoryName"></span></label> + <span data-dojo-attach-point="advancedSearch" style="display:none;"> + <label>Select : <textarea data-dojo-attach-point="selectExpression" type="text" + data-dojo-type="dijit/form/SimpleTextarea" + data-dojo-props="name: 'select', + rows: 1, + intermediateChanges: true, + placeHolder: 'comma separated attribute names', + title: 'Enter comma separated list of attributes to select', + promptMessage: 'Comma separated list of attributes to select, for example: name,type,description', + class: 'querySearchField'" rows="1"></textarea></label> + <label>Where : <textarea data-dojo-attach-point="whereExpression" type="text" + data-dojo-type="dijit/form/SimpleTextarea" + data-dojo-props="name: 'where', + rows: 1, + intermediateChanges: true, + placeHolder: 'where expression', + title: 'Enter sql like where conditions', + promptMessage: 'Use JMS filter syntax to specify where conditions', + class: 'querySearchField'" rows="1"></textarea></label> + </span> + <span data-dojo-attach-point="standardSearch"> + <span data-dojo-type="qpid/management/query/DropDownSelect" + data-dojo-attach-point="selectColumnsButton" + data-dojo-props="title: 'Select fields to display',label:'Columns'"> + </span> + + <span data-dojo-type="qpid/management/query/DropDownSelect" + data-dojo-attach-point="selectWhereButton" + data-dojo-props="title: 'Specify Filtering Conditions',label:'Conditions'"> + </span> + </span> + <div data-dojo-type="dijit/form/Button" + data-dojo-attach-point="searchButton" + data-dojo-props="title: 'Search'">Search</div> + <div data-dojo-type="dijit/form/Button" + data-dojo-attach-point="modeButton" + data-dojo-props="title:'Switch to \'Advanced\' search using SQL-like expressions'">Advanced</div> + + <div data-dojo-attach-point="whereExpressionBuilder" + data-dojo-type="qpid/management/query/WhereExpression"></div> + </div> + <div data-dojo-attach-point="queryResultGrid" jsid='grid'></div> +</div> \ No newline at end of file Added: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/WhereCriteria.html URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/WhereCriteria.html?rev=1738933&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/WhereCriteria.html (added) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/WhereCriteria.html Wed Apr 13 12:58:41 2016 @@ -0,0 +1,74 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<div class="dijit dijitReset dijitInline dijitButtonNode"> + <div id="${id}_whereCriteria_editCriteria" + data-dojo-attach-point="criteria" + data-dojo-type="dijit/form/DropDownButton" + data-dojo-props="showLabel:true, title: 'Set where criteria'"> + <span>Edit</span> + <div data-dojo-type="dijit/TooltipDialog" data-dojo-attach-point="editDialog"> + <div data-dojo-attach-point="conditionDialogContent" + data-dojo-type="dijit/form/Form"> + <script type="dojo/method" data-dojo-event="onSubmit"> + return false; + </script> + + <input class="criteriaControl" + data-dojo-type="dijit/form/TextBox" + data-dojo-attach-point="newColumnCondition" + data-dojo-props="readOnly:true, title: 'Current where expression'"/> + <div class="criteriaControl">Match: <select data-dojo-attach-point="criteriaMatchCondition" + data-dojo-type="dijit/form/Select" + data-dojo-props="value: 'and', + required: true, title:'Select how to group multiple conditions'"> + <option value="and">All</option> + <option value="or">Any</option> + </select> + </div> + + <div data-dojo-attach-point="criteriaContainer" + data-dojo-type="dijit/layout/ContentPane" class="criteriaPanelTitle"></div> + <div class="dijitDialogPaneActionBar"> + <div id="${id}_whereCriteria_addButton" + data-dojo-type="dijit/form/Button" + data-dojo-attach-point="addButton" + type="button" label="Add" class="alignLeft"></div> + <div class="alignRight"> + <div id="${id}_whereCriteria_cancelButton" + data-dojo-type="dijit/form/Button" + data-dojo-attach-point="cancelButton" + type="button" label="Cancel"></div> + + <div id="${id}_whereCriteria_doneButton" + data-dojo-type="dijit/form/Button" + data-dojo-attach-point="doneButton" + type="submit" label="Done"></div> + </div> + <div class="clear"></div> + </div> + </div> + </div> + </div> + <div data-dojo-attach-point="removeCriteria" + data-dojo-type="dijit/form/Button" + data-dojo-props="iconClass:'dijitIconDelete', + showLabel:false, + title: 'Remove'">Remove</div> +</div> Added: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showQueryTab.html URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showQueryTab.html?rev=1738933&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showQueryTab.html (added) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showQueryTab.html Wed Apr 13 12:58:41 2016 @@ -0,0 +1,24 @@ +<!-- + - + - Licensed to the Apache Software Foundation (ASF) under one + - or more contributor license agreements. See the NOTICE file + - distributed with this work for additional information + - regarding copyright ownership. The ASF licenses this file + - to you under the Apache License, Version 2.0 (the + - "License"); you may not use this file except in compliance + - with the License. You may obtain a copy of the License at + - + - http://www.apache.org/licenses/LICENSE-2.0 + - + - Unless required by applicable law or agreed to in writing, + - software distributed under the License is distributed on an + - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + - KIND, either express or implied. See the License for the + - specific language governing permissions and limitations + - under the License. + - + --> +<div class="query"> + <div class="queryEditorNode"></div> +</div> + Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showVirtualHost.html URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showVirtualHost.html?rev=1738933&r1=1738932&r2=1738933&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showVirtualHost.html (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showVirtualHost.html Wed Apr 13 12:58:41 2016 @@ -115,11 +115,15 @@ </div> <div class="dijitDialogPaneActionBar"> - <button data-dojo-type="dijit.form.Button" class="startButton" type="button" data-dojo-props="disabled: true">Start</button> - <button data-dojo-type="dijit.form.Button" class="stopButton" type="button" data-dojo-props="disabled: true">Stop</button> - <button data-dojo-type="dijit.form.Button" class="editButton" type="button" data-dojo-props="disabled: true">Edit</button> - <button data-dojo-type="dijit.form.Button" class="downloadButton" type="button" data-dojo-props="disabled: true">Download</button> - <button data-dojo-type="dijit.form.Button" class="deleteButton" data-dojo-props="iconClass: 'dijitIconDelete'">Delete</button> + <button data-dojo-type="dijit.form.Button" class="addQuery alignLeft">Query</button> + <div class="alignRight"> + <button data-dojo-type="dijit.form.Button" class="startButton" type="button" data-dojo-props="disabled: true">Start</button> + <button data-dojo-type="dijit.form.Button" class="stopButton" type="button" data-dojo-props="disabled: true">Stop</button> + <button data-dojo-type="dijit.form.Button" class="editButton" type="button" data-dojo-props="disabled: true">Edit</button> + <button data-dojo-type="dijit.form.Button" class="downloadButton" type="button" data-dojo-props="disabled: true">Download</button> + <button data-dojo-type="dijit.form.Button" class="deleteButton" data-dojo-props="iconClass: 'dijitIconDelete'">Delete</button> + </div> + <div class="clear"></div> </div> <br/> Modified: qpid/java/trunk/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties?rev=1738933&r1=1738932&r2=1738933&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties Wed Apr 13 12:58:41 2016 @@ -22,4 +22,6 @@ dojo-version=${dojo-version} dojo-path=/dojo-${dojo-version}/dojo dijit-path=/dojo-${dojo-version}/dijit dojox-path=/dojo-${dojo-version}/dojox +dgrid-path=/META-INF/resources/webjars/dgrid/${dgrid-version} +dstore-path=/META-INF/resources/webjars/dstore/${dstore-version} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org