You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2016/04/19 00:42:27 UTC

svn commit: r1739827 - in /qpid/java/trunk/broker-plugins/management-http/src/main/java/resources: css/ js/qpid/management/query/ query/

Author: orudyy
Date: Mon Apr 18 22:42:27 2016
New Revision: 1739827

URL: http://svn.apache.org/viewvc?rev=1739827&view=rev
Log:
QPID-6983: Fix condition setting for fields having valid values and datetime fields

Modified:
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/css/common.css
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/CriteriaPane.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBuilder.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereCriteria.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereExpression.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/QueryBuilder.html

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/css/common.css
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/css/common.css?rev=1739827&r1=1739826&r2=1739827&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/css/common.css (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/css/common.css Mon Apr 18 22:42:27 2016
@@ -450,4 +450,21 @@ div .messages {
 .messageExtra
 {
   padding: 1em 0em 1em 3.2em;
+}
+
+.queryToolBar {
+    background-color: #efefef;
+    background-image: linear-gradient(rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 100%);
+    background-repeat: repeat-x;
+    border-bottom: 1px solid #b5bcc7;
+    padding: 2px 0 2px 4px;
+}
+
+.queryToolBar .dijitToolbar
+{
+    padding: 0px; !important;
+    border-bottom: none !important;
+    background-image:  none !important;
+    background-color: inherit !important;
+    background-repeat: inherit !important;
 }
\ No newline at end of file

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/CriteriaPane.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/CriteriaPane.js?rev=1739827&r1=1739826&r2=1739827&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/CriteriaPane.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/CriteriaPane.js Mon Apr 18 22:42:27 2016
@@ -30,6 +30,7 @@ define([
   "dojo/text!query/CriteriaPane.html",
   "dojox/html/entities",
   "dojo/Evented",
+  "dojo/number",
   "dijit/_WidgetBase",
   "dijit/_TemplatedMixin",
   "dijit/_WidgetsInTemplateMixin",
@@ -45,7 +46,7 @@ define([
   "dijit/form/NumberSpinner",
   "dojo/domReady!"
 ],
-function(declare, array, lang, string, domConstruct, domStyle, has, template, entities, Evented)
+function(declare, array, lang, string, domConstruct, domStyle, has, template, entities, Evented, number)
 {
     var ANY = "any";
     var IS_NULL = "is null";
@@ -74,6 +75,8 @@ function(declare, array, lang, string, d
                               GREATER_EQUAL_THAN];
     var ENUM_CONDITIONS = [ANY,IS_NULL,IS_NOT_NULL,IN,NOT_IN];
     var DATE_CONDITIONS = [ANY,IS_NULL,IS_NOT_NULL,EQUAL,NOT_EQUAL,LESS_THAN,LESS_EQUAL_THAN,GREATER_THAN,GREATER_EQUAL_THAN];
+    var UNSUPPORTED_TYPES_CONDITIONS = [ANY,IS_NULL,IS_NOT_NULL];
+    var UNSUPPORTED_TYPES = ["Map","Collection","Set","List"];
 
     var sqlEscape =                    function(value)
                                        {
@@ -182,13 +185,22 @@ function(declare, array, lang, string, d
                                          }
                                          else
                                          {
+                                            if (UNSUPPORTED_TYPES.indexOf(type) != -1)
+                                            {
+                                                return UNSUPPORTED_TYPES_CONDITIONS;
+                                            }
+
                                             if (validValues && validValues.length)
                                             {
                                                 return ENUM_CONDITIONS;
                                             }
-                                            return STRING_CONDITIONS;
+                                            else
+                                            {
+                                                return STRING_CONDITIONS;
+                                            }
                                          }
                                        }
+
     var arrayToOptions =               function(conditions, defaultValue)
                                        {
                                          var options = [];
@@ -203,6 +215,12 @@ function(declare, array, lang, string, d
                                        {
                                          return array.indexOf(CONDITIONS_NOT_NEEDING_WIDGET,condition) == -1;
                                        }
+    var isInt =                        function isInt(value)
+                                       {
+                                         return !isNaN(value) &&
+                                                parseInt(Number(value)) == value &&
+                                                !isNaN(parseInt(value, 10));
+                                       }
 
     // dojo TimeTextBox has a bug in Firefox
     // https://bugzilla.mozilla.org/show_bug.cgi?id=487897
@@ -219,7 +237,6 @@ function(declare, array, lang, string, d
                                                        domConstruct.create("span",{innerHTML:"T"}, domNode);
                                                        var timeNode = domConstruct.create("div",{}, domNode);
                                                        this.hoursEditor = new dijit.form.NumberSpinner({name: "hours",
-                                                                                                        disabled: this.disabled,
                                                                                                         constraints:{ max:23, min:0 },
                                                                                                         style: {width: "4em"},
                                                                                                         intermediateChanges: this.intermediateChanges,
@@ -229,7 +246,6 @@ function(declare, array, lang, string, d
                                                        domConstruct.create("span",{innerHTML:":"}, domNode);
                                                        var minutesNode = domConstruct.create("div",{}, domNode);
                                                        this.minutesEditor = new dijit.form.NumberSpinner({name: "minutes",
-                                                                                                          disabled: this.disabled,
                                                                                                           constraints:{ max:59, min:0 },
                                                                                                           style: {width: "4em"},
                                                                                                           intermediateChanges: this.intermediateChanges,
@@ -239,7 +255,6 @@ function(declare, array, lang, string, d
                                                        domConstruct.create("span",{innerHTML:":"}, domNode);
                                                        var secondsNode = domConstruct.create("div",{}, domNode);
                                                        this.secondsEditor = new dijit.form.NumberSpinner({name: "seconds",
-                                                                                                           disabled: this.disabled,
                                                                                                            constraints:{ max:59, min:0 },
                                                                                                            style: {width: "4em"},
                                                                                                            intermediateChanges: this.intermediateChanges,
@@ -249,7 +264,6 @@ function(declare, array, lang, string, d
                                                        domConstruct.create("span",{innerHTML:"."}, domNode);
                                                        var millisecondsNode = domConstruct.create("div",{}, domNode);
                                                        this.millisecondsEditor = new dijit.form.NumberSpinner({name: "milliseconds",
-                                                                                                            disabled: this.disabled,
                                                                                                             constraints:{ max:999, min:0 },
                                                                                                             style: {width: "5em"},
                                                                                                             intermediateChanges: this.intermediateChanges,
@@ -267,25 +281,25 @@ function(declare, array, lang, string, d
                                                      },
                                            _setValue:function()
                                                      {
-                                                       var date = new Date(0);
-                                                       if (isFinite(this.hoursEditor.value) )
+                                                       var time = 0
+                                                       if (isInt(this.hoursEditor.value) )
                                                        {
-                                                        date.setHours(this.hoursEditor.value);
+                                                         time = time + this.hoursEditor.value * 60 * 60 * 1000;
                                                        }
-                                                       if (isFinite(this.minutesEditor.value))
+                                                       if (isInt(this.minutesEditor.value))
                                                        {
-                                                         date.setMinutes(this.minutesEditor.value);
+                                                         time = time + this.minutesEditor.value * 60 * 1000;
                                                        }
-                                                       if (isFinite(this.secondsEditor.value))
+                                                       if (isInt(this.secondsEditor.value))
                                                        {
-                                                        date.setSeconds(this.secondsEditor.value);
+                                                         time = time + this.secondsEditor.value * 1000;
                                                        }
-                                                       if (isFinite(this.millisecondsEditor.value))
+                                                       if (isInt(this.millisecondsEditor.value))
                                                        {
-                                                        date.setMilliseconds(this.millisecondsEditor.value);
+                                                         time = time + this.millisecondsEditor.value;
                                                        }
-                                                       this.value = date;
-                                                       this.emit("change", date);
+                                                       this.value = new Date(time - new Date().getTimezoneOffset() * 60 * 1000);
+                                                       this.emit("change", this.value);
                                                      },
                                            _setDisabledAttr:function(value)
                                                      {
@@ -328,8 +342,8 @@ function(declare, array, lang, string, d
                                                                                           {},
                                                                                           domNode);
                                                        this.dateEditor = new dijit.form.DateTextBox({name: "date",
-                                                                                                     disabled: this.disabled,
-                                                                                                     intermediateChanges: true},
+                                                                                                     intermediateChanges: true,
+                                                                                                     constraints: {datePattern: "yyyy-MM-dd"}},
                                                                                                     dateNode);
                                                        this.dateEditor.on("change", lang.hitch(this, this._setValue));
                                                        var timeNode = domConstruct.create("div",{}, domNode);
@@ -344,7 +358,6 @@ function(declare, array, lang, string, d
                                                        else
                                                        {
                                                          this.timeEditor = new dijit.form.TimeTextBox({name: "time",
-                                                                                                       disabled: this.disabled,
                                                                                                        intermediateChanges: true,
                                                                                                        value: this.value,
                                                                                                        constraints: {
@@ -370,45 +383,65 @@ function(declare, array, lang, string, d
                                                        if (date)
                                                        {
                                                          var time = this.timeEditor.value;
-                                                         var value = date.getTime() + (time ? time.getTime() : 0) ;
-                                                         this.value = "to_date('" + new Date(value).toISOString() + "')";
+                                                         var value = date.getTime() + (time ? time.getTime() + time.getTimezoneOffset() * 60 * 1000 : 0);
+                                                         this.value = value;
+                                                         this._setExpressionAttr(value);
                                                          this.emit("change", this.value);
                                                        }
                                                      },
+                                           _setExpressionAttr: function(value)
+                                                     {
+                                                        var formattedDate = this.userPreferences.formatDateTime(value, {selector: "date", datePattern: "yyyy-MM-dd"});
+                                                        var formattedTime = this.userPreferences.formatDateTime(value, {selector: "time", datePattern: "HH:mm:ss.SSS"});
+                                                        var timeZoneOffset = "";
+                                                        var timeZone = this.userPreferences.getTimeZoneInfo();
+                                                        if (timeZone && timeZone.offset)
+                                                        {
+                                                          var timeZoneOfsetInMinutes = timeZone.offset;
+                                                          timeZoneOffset = (timeZoneOfsetInMinutes>0? "+" : "-")
+                                                               + number.format(timeZoneOfsetInMinutes/60, {pattern: "00"})
+                                                               + ":" + number.format(timeZoneOfsetInMinutes%60, {pattern: "00"});
+                                                        }
+
+                                                        this.expression = "to_date('" + formattedDate + "T" + formattedTime + timeZoneOffset +"')";
+                                                     },
+                                           _getExpressionAttr:function()
+                                                     {
+                                                       return this.expression;
+                                                     },
                                            _setDisabledAttr: function(value)
                                                      {
                                                        this.inherited(arguments);
                                                        this.disabled = value;
                                                        this.dateEditor.set("disabled", value);
                                                        this.timeEditor.set("disabled", value);
-                                                       if (value)
-                                                       {
-                                                         this._setValue();
-                                                       }
-                                                       else
-                                                       {
-                                                         this._setValueAttr(undefined);
-                                                       }
                                                      },
                                            _setValueAttr: function(value)
                                                      {
                                                        var date;
-                                                       if (value instanceof Date || isFinite(value))
+                                                       if (value instanceof Date )
                                                        {
-                                                         var date = value instanceof Date ? value : new Date(value);
+                                                         date = value;
                                                        }
-                                                       else
+                                                       else if (isInt(value))
                                                        {
-                                                         date = value;
+                                                         date =  new Date(value);
+                                                       }
+                                                       if (date)
+                                                       {
+                                                         this.dateEditor.set("value", date);
+                                                         this.timeEditor.set("value", date);
+                                                         this.value = date;
                                                        }
-                                                       this.dateEditor.set("value", date);
-                                                       this.timeEditor.set("value", date);
-                                                       this.value = value;
                                                        this.inherited(arguments);
                                                      },
                                            _getValueAttr: function()
                                                      {
                                                        return this.value;
+                                                     },
+                                           isValid: function()
+                                                     {
+                                                        return !!this.value;
                                                      }
                                          });
 
@@ -434,6 +467,7 @@ function(declare, array, lang, string, d
                         criteriaName: null,
                         typeName: null,
                         typeValidValues: null,
+                        userPreferences: null,
 
                         /**
                          * auxiliary fields
@@ -469,24 +503,24 @@ function(declare, array, lang, string, d
                                                   var val = this.typeValidValues[i];
                                                   domConstruct.create("option", {innerHTML: entities.encode(String(val)), value: val}, domNode);
                                                 }
-                                                this.valueEditor = new dijit.form.MultiSelect({disabled: true}, domNode);
+                                                this.valueEditor = new dijit.form.MultiSelect({intermediateChanges: true,
+                                                                                               multiple: true}, domNode);
                                             }
-                                            if (this.typeName === "Date")
+                                            else if (this.typeName === "Date")
                                             {
-                                                this.valueEditor = new DateTimePicker({disabled: true}, domNode);
+                                                this.valueEditor = new DateTimePicker({intermediateChanges: true,
+                                                                                       userPreferences: this.userPreferences}, domNode);
                                             }
                                             else
                                             {
                                                 this.valueEditor = isNumericType(this.typeName)
                                                                 ? new dijit.form.NumberTextBox({
                                                                                                 value: 0,
-                                                                                                disabled: true,
                                                                                                 required:true,
                                                                                                 intermediateChanges: true,
                                                                                                 invalidMessage:'Please enter a numeric value.'},
                                                                                                domNode)
                                                                 : new dijit.form.ValidationTextBox({value: '',
-                                                                                                    disabled: true,
                                                                                                     required:true,
                                                                                                     intermediateChanges: true},
                                                                                                     domNode);
@@ -545,7 +579,7 @@ function(declare, array, lang, string, d
                                         },
                         _getConditionValue: function()
                                         {
-                                            return this.valueEditor.value;
+                                            return this.valueEditor.expression || this.valueEditor.value;
                                         },
                         _removalRequested: function()
                                         {
@@ -590,7 +624,7 @@ function(declare, array, lang, string, d
                                           this._removable = removable
                                           this.removeCriteria.set("disabled", !removable);
                                         },
-                        isValidCriteria:        function()
+                        isValidCriteria:function()
                                         {
                                           if (!this.valueEditor.get("disabled"))
                                           {
@@ -604,12 +638,6 @@ function(declare, array, lang, string, d
                                               var value = this.valueEditor.value;
                                               return value && value.length;
                                             }
-
-                                            if (this.valueEditor instanceof DateTimePicker)
-                                            {
-                                              var value = this.valueEditor.value;
-                                              return !!value;
-                                            }
                                           }
                                           return true;
                                         }

Modified: 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=1739827&r1=1739826&r2=1739827&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBuilder.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBuilder.js Mon Apr 18 22:42:27 2016
@@ -178,6 +178,7 @@ define(["dojo/_base/declare",
                                                this.selectColumnsButton.startup();
                                                this.selectWhereButton.startup();
                                                this.whereExpressionBuilder.set("whereFieldsSelector", this.selectWhereButton );
+                                               this.whereExpressionBuilder.set("userPreferences", this._management.userPreferences );
                                                this.whereExpressionBuilder.startup();
                                                this.whereExpressionBuilder.on("change", lang.hitch(this, this._standardModeWhereChanged));
 
@@ -430,7 +431,7 @@ define(["dojo/_base/declare",
                                                                                   {
                                                                                     if (!isNaN(value) &&  parseInt(Number(value)) == value &&  !isNaN(parseInt(value, 10)))
                                                                                     {
-                                                                                      return that._management.userPreferences.formatDateTime(value);
+                                                                                      return that._management.userPreferences.formatDateTime(value, {addOffset: true, appendTimeZone: true});
                                                                                     }
                                                                                     return value ? entities.encode(String(value)) : "";
                                                                                   };
@@ -464,7 +465,7 @@ define(["dojo/_base/declare",
                                                                                       var list = domConstruct.create("div", {}, node);
                                                                                       for(var i in value)
                                                                                       {
-                                                                                         domConstruct.create("div", {innerHTML:entities.encode(String(value[i]))}, list)
+                                                                                         domConstruct.create("div", {innerHTML:entities.encode(json.stringify(value[i]))}, list)
                                                                                       }
                                                                                       return list;
                                                                                     }

Modified: 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=1739827&r1=1739826&r2=1739827&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereCriteria.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereCriteria.js Mon Apr 18 22:42:27 2016
@@ -68,6 +68,7 @@ function(declare, array, lang, string, t
                          * constructor arguments
                          */
                         attributeDetails: null,
+                        userPreferences: null,
 
                         /**
                          * inner fields
@@ -105,7 +106,8 @@ function(declare, array, lang, string, t
                                      {
                                        var criteriaPane = new CriteriaPane({criteriaName: this.attributeDetails.attributeName,
                                                                             typeName: this.attributeDetails.type,
-                                                                            typeValidValues: this.attributeDetails.validValues});
+                                                                            typeValidValues: this.attributeDetails.validValues,
+                                                                            userPreferences: this.userPreferences});
                                        this.criteriaContainer.addChild(criteriaPane);
                                        criteriaPane.on("change", lang.hitch(this, this._criteriaConditionChanged));
                                        this._updateRemovable();

Modified: 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=1739827&r1=1739826&r2=1739827&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereExpression.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/WhereExpression.js Mon Apr 18 22:42:27 2016
@@ -37,6 +37,7 @@ function(declare, array, lang, domConstr
                         whereExpression: "",
                         whereFieldsSelector: null,
                         _whereItems: {},
+                        userPreferences: null,
 
                         postCreate: function()
                                     {
@@ -79,7 +80,8 @@ function(declare, array, lang, domConstr
                                     },
                         _createWhereCriteriaWidget: function(item)
                                     {
-                                      var whereCriteria = new WhereCriteria({attributeDetails: item},
+                                      var whereCriteria = new WhereCriteria({attributeDetails: item,
+                                                                             userPreferences: this.userPreferences},
                                                                             domConstruct.create("div"));
                                       this.addChild(whereCriteria);
                                       whereCriteria.startup();
@@ -143,6 +145,10 @@ function(declare, array, lang, domConstr
                                       {
                                         this.whereFieldsSelector.set("data", {selected:[]});
                                       }
+                                    },
+                        _setUserPreferences: function(value)
+                                    {
+                                        this.userPreferences = value;
                                     }
                    });
 });
\ No newline at end of file

Modified: 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=1739827&r1=1739826&r2=1739827&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/QueryBuilder.html (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/query/QueryBuilder.html Mon Apr 18 22:42:27 2016
@@ -18,7 +18,7 @@
   -->
 
 <div>
-    <div class="dijit dijitToolbar">
+    <div class="dijit queryToolBar">
         <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="standardSearch">
@@ -40,7 +40,7 @@
              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>
+             data-dojo-type="qpid/management/query/WhereExpression" class="dijitToolbar"></div>
         <div data-dojo-attach-point="advancedSearch"  style="display:none;">
             <div class="advancedSearchItem">
                 <div class="advancedSearchLabel">Select :</div>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org