Manual merge after auto precision was backed out

This commit is contained in:
Rashid Khan 2015-04-28 15:20:49 -07:00
commit e83998b416
19 changed files with 232 additions and 170 deletions

View file

@ -3,8 +3,7 @@ define(function (require) {
var _ = require('lodash');
var moment = require('moment');
var BucketAggType = Private(require('components/agg_types/buckets/_bucket_agg_type'));
var defaultPrecision = 2;
var defaultPrecision = 3;
function getPrecision(precision) {
var maxPrecision = _.parseInt(config.get('visualization:tileMap:maxPrecision'));

View file

@ -45,7 +45,7 @@ define(function (require) {
queue.forEach(function (q) { q.reject(err); });
})
.finally(function () {
$rootScope.$emit('change:config', updated.concat(deleted));
$rootScope.$broadcast('change:config', updated.concat(deleted));
});
};
@ -70,7 +70,7 @@ define(function (require) {
var defer = Promise.defer();
queue.push(defer);
notify.log('config change: ' + key + ': ' + oldVal + ' -> ' + newVal);
$rootScope.$emit('change:config.' + key, newVal, oldVal);
$rootScope.$broadcast('change:config.' + key, newVal, oldVal);
// reset the fire timer
clearTimeout(timer);
@ -80,4 +80,4 @@ define(function (require) {
};
};
});
});

View file

@ -19,7 +19,7 @@ define(function (require) {
var angular = require('angular');
var _ = require('lodash');
var defaults = require('components/config/defaults');
var defaults = Private(require('components/config/defaults'));
var DelayedUpdater = Private(require('components/config/_delayed_updater'));
var vals = Private(require('components/config/_vals'));
@ -123,6 +123,29 @@ define(function (require) {
if (updater) updater.fire();
};
/**
* A little helper for binding config variables to $scopes
*
* @param {Scope} $scope - an angular $scope object
* @param {string} key - the config key to bind to
* @param {string} [property] - optional property name where the value should
* be stored. Defaults to the config key
* @return {function} - an unbind function
*/
config.$bind = function ($scope, key, property) {
if (!property) property = key;
var update = function () {
$scope[property] = config.get(key);
};
update();
return _.partial(_.invoke, [
$scope.$on('change:config.' + key, update),
$scope.$on('init:config', update)
], 'call');
};
/*****
* PRIVATE API
*****/

View file

@ -1,91 +1,93 @@
define(function (require) {
var _ = require('lodash');
return function () {
var _ = require('lodash');
return {
'query:queryString:options': {
value: '{ "analyze_wildcard": true }',
description: 'Options for the lucene query string parser',
type: 'json'
},
'dateFormat': {
value: 'MMMM Do YYYY, HH:mm:ss.SSS',
description: 'When displaying a pretty formatted date, use this format',
},
'dateFormat:scaled': {
type: 'json',
value:
'[\n' +
' ["", "hh:mm:ss.SSS"],\n' +
' ["PT1S", "HH:mm:ss"],\n' +
' ["PT1M", "HH:mm"],\n' +
' ["PT1H",\n' +
' "YYYY-MM-DD HH:mm"],\n' +
' ["P1DT", "YYYY-MM-DD"],\n' +
' ["P1YT", "YYYY"]\n' +
']',
description: 'Values that define the format used in situations where timebased' +
' data is rendered in order, and formatted timestamps should adapt to the' +
' interval between measurements. Keys are ISO 8601 intervals:' +
' http://en.wikipedia.org/wiki/ISO_8601#Time_intervals'
},
'defaultIndex': {
value: null,
description: 'The index to access if no index is set',
},
'metaFields': {
value: ['_source', '_id', '_type', '_index'],
description: 'Fields that exist outside of _source to merge into our document when displaying it',
},
'discover:sampleSize': {
value: 500,
description: 'The number of rows to show in the table',
},
'fields:popularLimit': {
value: 10,
description: 'The top N most popular fields to show',
},
'format:numberPrecision': {
value: 3,
description: 'Round numbers to this many decimal places',
},
'histogram:barTarget': {
value: 50,
description: 'Attempt to generate around this many bar when using "auto" interval in date histograms',
},
'histogram:maxBars': {
value: 100,
description: 'Never show more than this many bar in date histograms, scale values if needed',
},
'visualization:tileMap:maxPrecision': {
value: 7,
description: 'The maximum geoHash precision displayed on tile maps: 7 is high, 10 is very high, ' +
'12 is the max. Explanation of cell dimensions: http://www.elastic.co/guide/en/elasticsearch/reference/current/' +
'search-aggregations-bucket-geohashgrid-aggregation.html#_cell_dimensions_at_the_equator',
},
'csv:separator': {
value: ',',
description: 'Separate exported values with this string',
},
'csv:quoteValues': {
value: true,
description: 'Should values be quoted in csv exports?',
},
'history:limit': {
value: 10,
description: 'In fields that have history (e.g. query inputs), show this many recent values',
},
'shortDots:enable': {
value: false,
description: 'Shorten long fields, for example, instead of foo.bar.baz, show f.b.baz',
},
'truncate:maxHeight': {
value: 115,
description: 'The maximum height that a cell in a table should occupy. Set to 0 to disable truncation.'
},
'indexPattern:fieldMapping:lookBack': {
value: 5,
description: 'For index patterns containing timestamps in their names, look for this many recent matching ' +
'patterns from which to query the field mapping.'
}
return {
'query:queryString:options': {
value: '{ "analyze_wildcard": true }',
description: 'Options for the lucene query string parser',
type: 'json'
},
'dateFormat': {
value: 'MMMM Do YYYY, HH:mm:ss.SSS',
description: 'When displaying a pretty formatted date, use this format',
},
'dateFormat:scaled': {
type: 'json',
value:
'[\n' +
' ["", "hh:mm:ss.SSS"],\n' +
' ["PT1S", "HH:mm:ss"],\n' +
' ["PT1M", "HH:mm"],\n' +
' ["PT1H",\n' +
' "YYYY-MM-DD HH:mm"],\n' +
' ["P1DT", "YYYY-MM-DD"],\n' +
' ["P1YT", "YYYY"]\n' +
']',
description: 'Values that define the format used in situations where timebased' +
' data is rendered in order, and formatted timestamps should adapt to the' +
' interval between measurements. Keys are ISO 8601 intervals:' +
' http://en.wikipedia.org/wiki/ISO_8601#Time_intervals'
},
'defaultIndex': {
value: null,
description: 'The index to access if no index is set',
},
'metaFields': {
value: ['_source', '_id', '_type', '_index'],
description: 'Fields that exist outside of _source to merge into our document when displaying it',
},
'discover:sampleSize': {
value: 500,
description: 'The number of rows to show in the table',
},
'fields:popularLimit': {
value: 10,
description: 'The top N most popular fields to show',
},
'format:numberPrecision': {
value: 3,
description: 'Round numbers to this many decimal places',
},
'histogram:barTarget': {
value: 50,
description: 'Attempt to generate around this many bar when using "auto" interval in date histograms',
},
'histogram:maxBars': {
value: 100,
description: 'Never show more than this many bar in date histograms, scale values if needed',
},
'visualization:tileMap:maxPrecision': {
value: 7,
description: 'The maximum geoHash precision displayed on tile maps: 7 is high, 10 is very high, ' +
'12 is the max. Explanation of cell dimensions: http://www.elastic.co/guide/en/elasticsearch/reference/current/' +
'search-aggregations-bucket-geohashgrid-aggregation.html#_cell_dimensions_at_the_equator',
},
'csv:separator': {
value: ',',
description: 'Separate exported values with this string',
},
'csv:quoteValues': {
value: true,
description: 'Should values be quoted in csv exports?',
},
'history:limit': {
value: 10,
description: 'In fields that have history (e.g. query inputs), show this many recent values',
},
'shortDots:enable': {
value: false,
description: 'Shorten long fields, for example, instead of foo.bar.baz, show f.b.baz',
},
'truncate:maxHeight': {
value: 115,
description: 'The maximum height that a cell in a table should occupy. Set to 0 to disable truncation.'
},
'indexPattern:fieldMapping:lookBack': {
value: 5,
description: 'For index patterns containing timestamps in their names, look for this many recent matching ' +
'patterns from which to query the field mapping.'
}
};
};
});

View file

@ -1,6 +1,6 @@
<th width="1%"></th>
<th ng-if="indexPattern.timeFieldName">
<span ng-click="sort(indexPattern.timeFieldName)" tooltip="Sort by time">Time <i ng-class="headerClass(indexPattern.timeFieldName)"></i></span>
<span>Time <i ng-class="headerClass(indexPattern.timeFieldName)" ng-click="sort(indexPattern.timeFieldName)" tooltip="Sort by time"></i></span>
</th>
<th ng-repeat="name in columns">
<span class="table-header-name">
@ -11,4 +11,4 @@
<i ng-click="moveLeft(name)" class="fa fa-angle-double-left" ng-show="!$first" tooltip="Move column to the left" tooltip-append-to-body="1"></i>
<i ng-click="moveRight(name)" class="fa fa-angle-double-right" ng-show="!$last" tooltip="Move column to the right" tooltip-append-to-body="1"></i>
</span>
</th>
</th>

View file

@ -14,7 +14,7 @@ define(function (require) {
function Dispatch(handler) {
var stockEvents = ['brush', 'click', 'hover', 'mouseup', 'mousedown', 'mouseover', 'mouseout', 'mapZoomEnd'];
var stockEvents = ['brush', 'click', 'hover', 'mouseup', 'mousedown', 'mouseover', 'mouseout'];
var customEvents = _.deepGet(handler, 'vis.eventTypes.enabled');
var eventTypes = customEvents ? stockEvents.concat(customEvents) : stockEvents;

View file

@ -151,15 +151,6 @@ define(function (require) {
});
});
map.on('zoomend', function (e) {
var mapInfo = {
zoom: map.getZoom(),
zoomPct: map.getZoom() / 18
};
self.events.dispatch.mapZoomEnd(mapInfo);
});
// add label for splits
if (mapData.properties.label) {
self.addLabel(mapData.properties.label, map);
@ -189,14 +180,6 @@ define(function (require) {
};
};
TileMap.prototype.addZoomEndEvent = function (element) {
var events = this.events;
var zoomend = events.addMapZoomEndEvent();
var attachedEvents = element.call(zoomend);
return attachedEvents;
};
/**
* zoom map to fit all features in featureLayer
*

View file

@ -1,6 +1,5 @@
define(function (require) {
var _ = require('lodash');
var configDefaults = require('components/config/defaults');
require('modules').get('apps/settings')
.directive('advancedRow', function (config, Notifier, Private) {
@ -13,6 +12,7 @@ define(function (require) {
configs: '='
},
link: function ($scope) {
var configDefaults = Private(require('components/config/defaults'));
var notify = new Notifier();
var keyCodes = {
ESC: 27
@ -66,4 +66,4 @@ define(function (require) {
}
};
});
});
});

View file

@ -1,6 +1,5 @@
define(function (require) {
var _ = require('lodash');
var configDefaults = require('components/config/defaults');
var getValType = require('plugins/settings/sections/advanced/lib/get_val_type');
@ -16,6 +15,7 @@ define(function (require) {
return {
restrict: 'E',
link: function ($scope) {
var configDefaults = Private(require('components/config/defaults'));
var keyCodes = {
ESC: 27
};
@ -70,4 +70,4 @@ define(function (require) {
display: 'Advanced',
url: '#/settings/advanced'
};
});
});

View file

@ -22,11 +22,8 @@ define(function (require) {
template: require('text!plugins/settings/sections/indices/index.html'),
link: function ($scope) {
$scope.edittingId = $route.current.params.id;
$scope.defaultIndex = config.get('defaultIndex');
$rootScope.$on('change:config.defaultIndex', function () {
$scope.defaultIndex = config.get('defaultIndex');
});
config.$bind($scope, 'defaultIndex');
$scope.$watch('defaultIndex', function (defaultIndex) {
$scope.indexPatternList = _($route.current.locals.indexPatternIds)
.map(function (id) {
@ -50,4 +47,4 @@ define(function (require) {
display: 'Indices',
url: '#/settings/indices',
};
});
});

View file

@ -11,25 +11,9 @@
</div>
<div class="vis-option-item">
</br>
<label>
<input type="checkbox"
name="autoPrecision"
value="{{autoPrecision}}"
ng-model="vis.params.autoPrecision"
ng-checked="vis.params.autoPrecision">
Change geoHash precision on map zoom
</label>
</div>
<div class="vis-option-item">
<label>
<input type="checkbox"
name="isDesaturated"
value="{{isDesaturated}}"
ng-model="vis.params.isDesaturated"
ng-checked="vis.params.isDesaturated">
<input type="checkbox" value="{{isDesaturated}}" ng-model="vis.params.isDesaturated" name="isDesaturated" ng-checked="vis.params.isDesaturated">
Desaturate map tiles
</label>
</div>
</div>

View file

@ -14,8 +14,7 @@ define(function (require) {
params: {
defaults: {
mapType: 'Scaled Circle Markers',
isDesaturated: true,
autoPrecision: true
isDesaturated: true
},
mapTypes: ['Scaled Circle Markers', 'Shaded Circle Markers', 'Shaded Geohash Grid'],
editor: require('text!plugins/vis_types/vislib/editors/tile_map.html')

View file

@ -50,7 +50,7 @@ define(function (require) {
'kibana/notify',
'kibana/courier'
])
.controller('VisEditor', function ($scope, $route, timefilter, AppState, $location, kbnUrl, $timeout, courier, Private, Promise, config) {
.controller('VisEditor', function ($scope, $route, timefilter, AppState, $location, kbnUrl, $timeout, courier, Private, Promise) {
var _ = require('lodash');
var angular = require('angular');
@ -125,16 +125,6 @@ define(function (require) {
editableVis.listeners.click = vis.listeners.click = filterBarClickHandler($state);
editableVis.listeners.brush = vis.listeners.brush = brushEvent;
editableVis.listeners.mapZoomEnd = vis.listeners.mapZoomEnd = function (event) {
if (!vis.params.autoPrecision) return;
var geoHash = _.find(vis.aggs, function (agg) {
return agg.type.name === 'geohash_grid';
});
geoHash.params.precision = autoPrecision(event.zoom, config.get('visualization:tileMap:maxPrecision'));
$scope.fetch();
};
// track state of editable vis vs. "actual" vis
$scope.stageEditableVis = transferVisState(editableVis, vis, true);
@ -298,10 +288,6 @@ define(function (require) {
};
}
function autoPrecision(zoom, limit) {
return Math.min(Math.round(0.02 * Math.pow(zoom, 2) + 0.24 * zoom + 0.723), limit);
}
init();
});
});

View file

@ -10,7 +10,7 @@ define(function (require) {
'=' : '-equal-'
};
_.each(trans, function (val, key) {
var regex = new RegExp(key);
var regex = new RegExp(key, 'g');
id = id.replace(regex, val);
});
id = id.replace(/[\s]+/g, '-');

View file

@ -16,6 +16,17 @@ function checkPath(path) {
}
}
// Set defaults for config file stuff
kibana.port = kibana.port || 5601;
kibana.host = kibana.host || '0.0.0.0';
kibana.elasticsearch_url = kibana.elasticsearch_url || 'http://localhost:9200';
kibana.maxSockets = kibana.maxSockets || Infinity;
kibana.log_file = kibana.log_file || null;
kibana.request_timeout = kibana.startup_timeout == null ? 0 : kibana.request_timeout;
kibana.ping_timeout = kibana.ping_timeout == null ? kibana.request_timeout : kibana.ping_timeout;
kibana.startup_timeout = kibana.startup_timeout == null ? 5000 : kibana.startup_timeout;
// Check if the local public folder is present. This means we are running in
// the NPM module. If it's not there then we are running in the git root.
var public_folder = path.resolve(__dirname, '..', 'public');
@ -33,13 +44,10 @@ try {
packagePath = path.resolve(__dirname, '..', '..', '..', 'package.json');
}
var requestTimeout = kibana.request_timeout || 0;
var pingTimeout = kibana.ping_timeout == null ? requestTimeout : kibana.ping_timeout;
var config = module.exports = {
port : kibana.port || 5601,
host : kibana.host || '0.0.0.0',
elasticsearch : kibana.elasticsearch_url || 'http://localhost:9200',
port : kibana.port,
host : kibana.host,
elasticsearch : kibana.elasticsearch_url,
root : path.normalize(path.join(__dirname, '..')),
quiet : false,
public_folder : public_folder,
@ -49,10 +57,10 @@ var config = module.exports = {
package : require(packagePath),
htpasswd : htpasswdPath,
buildNum : '@@buildNum',
maxSockets : kibana.maxSockets || Infinity,
log_file : kibana.log_file || null,
request_timeout : requestTimeout,
ping_timeout : pingTimeout
maxSockets : kibana.maxSockets,
log_file : kibana.log_file,
request_timeout : kibana.request_timeout,
ping_timeout : kibana.ping_timeout
};
config.plugins = listPlugins(config);

View file

@ -45,6 +45,9 @@ request_timeout: 300000
# Set to 0 to disable.
shard_timeout: 0
# Time in milliseconds to wait for Elasticsearch at Kibana startup before retrying
# startup_timeout: 5000
# Set to false to have a complete disregard for the validity of the SSL
# certificate.
verify_ssl: true

View file

@ -6,7 +6,7 @@ var logger = require('./logger');
var config = require('../config');
function waitForPong() {
return client.ping()
return client.ping({requestTimeout: config.kibana.startup_timeout})
.catch(function (err) {
if (!(err instanceof NoConnections)) throw err;

View file

@ -0,0 +1,74 @@
define(function (require) {
describe('config component', function () {
var $scope;
var config;
var defaults;
var configFile;
beforeEach(module('kibana'));
beforeEach(inject(function ($injector, Private) {
config = $injector.get('config');
$scope = $injector.get('$rootScope');
configFile = $injector.get('configFile');
defaults = Private(require('components/config/defaults'));
}));
it('exposes the configFile', function () {
expect(config.file).to.be(configFile);
});
describe('#get', function () {
it('gives access to config values', function () {
expect(config.get('dateFormat')).to.be.a('string');
});
it('reads from the defaults', function () {
var initial = config.get('dateFormat');
var newDefault = initial + '- new';
defaults.dateFormat.value = newDefault;
expect(config.get('dateFormat')).to.be(newDefault);
});
});
describe('#set', function () {
it('stores a value in the config val set', function () {
var initial = config.get('dateFormat');
config.set('dateFormat', 'notaformat');
expect(config.get('dateFormat')).to.be('notaformat');
});
});
describe('#$bind', function () {
it('binds a config key to a $scope property', function () {
var dateFormat = config.get('dateFormat');
config.$bind($scope, 'dateFormat');
expect($scope).to.have.property('dateFormat', dateFormat);
});
it('alows overriding the property name', function () {
var dateFormat = config.get('dateFormat');
config.$bind($scope, 'dateFormat', 'defaultDateFormat');
expect($scope).to.not.have.property('dateFormat');
expect($scope).to.have.property('defaultDateFormat', dateFormat);
});
it('keeps the property up to date', function () {
var dateFormat = config.get('dateFormat');
var newDateFormat = dateFormat + ' NEW NEW NEW!';
config.$bind($scope, 'dateFormat');
expect($scope).to.have.property('dateFormat', dateFormat);
config.set('dateFormat', newDateFormat);
expect($scope).to.have.property('dateFormat', newDateFormat);
});
});
});
});

View file

@ -16,7 +16,11 @@ define(function (require) {
['test / ^test', 'test-slash-^test'],
['test ? test', 'test-questionmark-test'],
['test = test', 'test-equal-test'],
['test & test', 'test-ampersand-test']
['test & test', 'test-ampersand-test'],
['test/test/test', 'test-slash-test-slash-test'],
['test?test?test', 'test-questionmark-test-questionmark-test'],
['test&test&test', 'test-ampersand-test-ampersand-test'],
['test=test=test', 'test-equal-test-equal-test']
];
_.each(fixtures, function (fixture) {