Procházet zdrojové kódy

Fixed bug in sorting

Rashid Khan před 12 roky
rodič
revize
5fa49c6228
4 změnil soubory, kde provedl 33 přidání a 9 odebrání
  1. 5 0
      js/services.js
  2. 6 5
      panels/table/module.html
  3. 19 4
      panels/table/module.js
  4. 3 0
      partials/dasheditor.html

+ 5 - 0
js/services.js

@@ -449,6 +449,11 @@ angular.module('kibana.services', [])
     return _.pluck(_.where(self.list,_require),'id');
   };
 
+  // TOFIX: Error handling when there is more than one field
+  this.timeField = function() {
+    return self.getByType('time')[0].field;
+  };
+
   // This special function looks for all time filters, and returns a time range according to the mode
   // No idea when max would actually be used
   this.timeRange = function(mode) {

+ 6 - 5
panels/table/module.html

@@ -55,11 +55,12 @@
           </th>
         
         </thead>
-        <tbody ng-repeat="row in data | slice:panel.offset:panel.offset+panel.size" ng-class-odd="'odd'">
-          <tr ng-click="toggle_details(row)" class="pointer">
-            <td ng-repeat="field in panel.fields" ng-bind-html-unsafe="(row.highlight[field]||row._source[field]) | tableHighlight | tableTruncate:panel.trimFactor:panel.fields.length"></td>
+        <tbody ng-repeat="event in data | slice:panel.offset:panel.offset+panel.size" ng-class-odd="'odd'">
+          <tr ng-click="toggle_details(event)" class="pointer">
+            <!--<td ng-repeat="field in panel.fields" ng-bind-html-unsafe="(event.highlight[field]||event._source[field]) | tableFieldFormat:field:event:this |tableHighlight | tableTruncate:panel.trimFactor:panel.fields.length"></td>-->
+            <td ng-repeat="field in panel.fields" ng-bind-html-unsafe="(event.highlight[field]||event._source[field]) |tableHighlight | tableTruncate:panel.trimFactor:panel.fields.length"></td>
           </tr>
-          <tr ng-show="row.kibana.details">
+          <tr ng-show="event.kibana.details">
             <td colspan=1000>
               <table class='table table-bordered table-condensed'>
                 <thead>
@@ -67,7 +68,7 @@
                   <th>Action</th>
                   <th>Value</th>
                 </thead>
-                <tr ng-repeat="(key,value) in row.kibana.details._source" ng-class-odd="'odd'">
+                <tr ng-repeat="(key,value) in event.kibana.details._source" ng-class-odd="'odd'">
                   <td>{{key}}</td>
                   <td>
                     <i class='icon-search pointer' ng-click="build_search(key,value)"></i> 

+ 19 - 4
panels/table/module.js

@@ -52,6 +52,7 @@ angular.module('kibana.table', [])
     paging  : true,
     field_list: true,
     trimFactor: 300,
+    normTimes : true,
     spyable : true
   };
   _.defaults($scope.panel,_d);
@@ -219,10 +220,9 @@ angular.module('kibana.table', [])
       // If we're not sorting in reverse chrono order, query every index for
       // size*pages results
       // Otherwise, only get size*pages results then stop querying
-      //($scope.data.length < $scope.panel.size*$scope.panel.pages
-      // || !(($scope.panel.sort[0] === $scope.time.field) && $scope.panel.sort[1] === 'desc'))
-      if($scope.data.length < $scope.panel.size*$scope.panel.pages &&
-        _segment+1 < dashboard.indices.length ) {
+      if (($scope.data.length < $scope.panel.size*$scope.panel.pages ||
+        !(($scope.panel.sort[0] === filterSrv.timeField()) && $scope.panel.sort[1] === 'desc')) &&
+        _segment+1 < dashboard.indices.length) {
         $scope.get_data(_segment+1,$scope.query_id);
       }
 
@@ -274,4 +274,19 @@ angular.module('kibana.table', [])
     }
     return '';
   };
+// WIP
+}).filter('tableFieldFormat', function(fields){
+  return function(text,field,event,scope) {
+    var type;
+    if(
+      !_.isUndefined(fields.mapping[event._index]) &&
+      !_.isUndefined(fields.mapping[event._index][event._type])
+    ) {
+      type = fields.mapping[event._index][event._type][field]['type'];
+      if(type === 'date' && scope.panel.normTimes) {
+        return moment(text).format('YYYY-MM-DD HH:mm:ss');
+      }    
+    }
+    return text;
+  };
 });

+ 3 - 0
partials/dasheditor.html

@@ -30,6 +30,7 @@
           <code>[logstash-]YYYY.MM.DD</code>. The [] in "[logstash-]" are 
           important as they instruct Kibana not to treat those letters as a 
           pattern.
+          Please also note that indices should rollover at midnight <strong>UTC</strong>.
         </p>
         <p class="small">
           See <a href="http://momentjs.com/docs/#/displaying/format/">http://momentjs.com/docs/#/displaying/format/</a>
@@ -85,6 +86,8 @@
       </div>
     </form>
   </div>
+  <div class="row-fluid" ng-show="editor.index == 3">
+  </div>
 </div>
 <div class="modal-footer">
   <button ng-click="add_row(dashboard.current,row); reset_row();" class="btn btn-success" ng-show="editor.index == 2">Create Row</button>