Parcourir la source

Added color stepping functions

Rashid Khan il y a 12 ans
Parent
commit
f98f4d5024

+ 2 - 1
.jshintrc

@@ -28,6 +28,7 @@
 
 
   "globals": {
   "globals": {
     "define": true,
     "define": true,
-    "require": true
+    "require": true,
+    "Chromath": false
   }
   }
 }
 }

+ 0 - 1
src/app/app.js

@@ -6,7 +6,6 @@ define([
   'jquery',
   'jquery',
   'underscore',
   'underscore',
   'require',
   'require',
-
   'elasticjs',
   'elasticjs',
   'bootstrap',
   'bootstrap',
   'angular-sanitize',
   'angular-sanitize',

+ 16 - 1
src/app/components/kbn.js

@@ -1,4 +1,4 @@
-define(['jquery', 'underscore','moment'],
+define(['jquery','underscore','moment','chromath'],
 function($, _, moment) {
 function($, _, moment) {
   'use strict';
   'use strict';
 
 
@@ -459,5 +459,20 @@ function($, _, moment) {
       ].join(';') + '"></div>';
       ].join(';') + '"></div>';
   };
   };
 
 
+  kbn.colorSteps = function(col,steps) {
+    var _d = 1.6/steps, // distance between steps
+      _p = []; // adjustment percentage
+
+    // Create a range of numbers between -0.8 and 0.8
+    for(var i = 1; i<steps+1; i+=1) {
+      _p.push(i%2 ? ((i-1)*_d*-1)/2 : i*_d/2);
+    }
+
+    // Create the color range
+    return _.map(_p.sort(function(a,b){return a-b;}),function(v) {
+      return v<0 ? Chromath.darken(col,v*-1).toString() : Chromath.lighten(col,v).toString();
+    });
+  };
+
   return kbn;
   return kbn;
 });
 });

+ 1 - 1
src/app/components/require.config.js

@@ -13,7 +13,7 @@ require.config({
     text:                     '../vendor/require/text',
     text:                     '../vendor/require/text',
     moment:                   '../vendor/moment',
     moment:                   '../vendor/moment',
     filesaver:                '../vendor/filesaver',
     filesaver:                '../vendor/filesaver',
-
+    chromath:                 '../vendor/chromath',
     angular:                  '../vendor/angular/angular',
     angular:                  '../vendor/angular/angular',
     'angular-dragdrop':       '../vendor/angular/angular-dragdrop',
     'angular-dragdrop':       '../vendor/angular/angular-dragdrop',
     'angular-strap':          '../vendor/angular/angular-strap',
     'angular-strap':          '../vendor/angular/angular-strap',

+ 0 - 1
src/app/directives/esVersion.js

@@ -16,7 +16,6 @@ function (angular) {
         restrict: 'A',
         restrict: 'A',
         link: function(scope, elem, attr) {
         link: function(scope, elem, attr) {
           if(!esVersion.is(attr.esVersion)) {
           if(!esVersion.is(attr.esVersion)) {
-            console.log('hiding');
             elem.hide();
             elem.hide();
           }
           }
         }
         }

+ 1 - 0
src/app/panels/table/module.html

@@ -6,6 +6,7 @@
       overflow-x: scroll;
       overflow-x: scroll;
     }
     }
   </style>
   </style>
+
   <div class="row-fluid">
   <div class="row-fluid">
     <div ng-class="{'span3':panel.field_list}" ng-show="panel.field_list">
     <div ng-class="{'span3':panel.field_list}" ng-show="panel.field_list">
       <div class="sidebar-nav">
       <div class="sidebar-nav">

+ 1 - 0
src/app/services/dashboard.js

@@ -123,6 +123,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
     // Since the dashboard is responsible for index computation, we can compute and assign the indices
     // Since the dashboard is responsible for index computation, we can compute and assign the indices
     // here before telling the panels to refresh
     // here before telling the panels to refresh
     this.refresh = function() {
     this.refresh = function() {
+
       if(self.current.index.interval !== 'none') {
       if(self.current.index.interval !== 'none') {
         if(filterSrv.idsByType('time').length > 0) {
         if(filterSrv.idsByType('time').length > 0) {
           var _range = filterSrv.timeRange('last');
           var _range = filterSrv.timeRange('last');

+ 22 - 4
src/app/services/querySrv.js

@@ -17,14 +17,28 @@ function (angular, _, config) {
       ids : [],
       ids : [],
     });
     });
 
 
-    // Defaults for query objects
+    // Defaults for generic query object
     var _query = {
     var _query = {
-      query: '*',
       alias: '',
       alias: '',
       pin: false,
       pin: false,
       type: 'lucene'
       type: 'lucene'
     };
     };
 
 
+    // Defaults for specific query types
+    var _dTypes = {
+      "lucene": {
+        query: "*"
+      },
+      "regex": {
+        query: ".*"
+      },
+      "derive": {
+        query: "*",
+        field: "_type",
+        size: "5"
+      }
+    };
+
     // For convenience
     // For convenience
     var ejs = ejsResource(config.elasticsearch);
     var ejs = ejsResource(config.elasticsearch);
     var _q = dashboard.current.services.query;
     var _q = dashboard.current.services.query;
@@ -80,6 +94,7 @@ function (angular, _, config) {
         query.id = _id;
         query.id = _id;
         query.color = query.color || colorAt(_id);
         query.color = query.color || colorAt(_id);
         _.defaults(query,_query);
         _.defaults(query,_query);
+        _.defaults(query,_dTypes[query.type]);
 
 
         self.list[_id] = query;
         self.list[_id] = query;
         self.ids.push(_id);
         self.ids.push(_id);
@@ -102,10 +117,13 @@ function (angular, _, config) {
       }
       }
     };
     };
 
 
-    this.getEjsObj = function(id) {
-      return self.toEjsObj(self.list[id]);
+    // This must return an array to correctly resolve compound query types, eg derived
+    this.getEjsObj = function(ids) {
+      return self.toEjsObj(self.list[ids]);
     };
     };
 
 
+    // In the case of a compound query, such as a derived query, we'd need to
+    // return an array of elasticJS objects. Not sure if that is appropriate?
     this.toEjsObj = function (q) {
     this.toEjsObj = function (q) {
       switch(q.type)
       switch(q.type)
       {
       {