mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Merge branch 'master' of github.com:elastic/kibana into apps/home
This commit is contained in:
commit
608be7435e
13 changed files with 303 additions and 30 deletions
|
@ -29,7 +29,7 @@
|
|||
# elasticsearch.ssl.cert: /path/to/your/client.crt
|
||||
# elasticsearch.ssl.key: /path/to/your/client.key
|
||||
|
||||
# If you need to provide a CA certificate for your Elasticsarech instance, put
|
||||
# If you need to provide a CA certificate for your Elasticsearch instance, put
|
||||
# the path of the pem file here.
|
||||
# elasticsearch.ssl.ca: /path/to/your/CA.pem
|
||||
|
||||
|
|
|
@ -21,9 +21,60 @@ describe('pluigns/elasticsearch', function () {
|
|||
upgrade = upgradeConfig(server);
|
||||
});
|
||||
|
||||
it('should resolve with undefined if nothing is found', function () {
|
||||
return upgrade({ hits: { hits:[] } }).then(function (resp) {
|
||||
expect(resp).to.be(undefined);
|
||||
describe('nothing is found', function () {
|
||||
var env = process.env.NODE_ENV;
|
||||
var response = { hits: { hits:[] } };
|
||||
|
||||
beforeEach(function () {
|
||||
client.create.returns(Promise.resolve());
|
||||
});
|
||||
|
||||
describe('production', function () {
|
||||
beforeEach(function () {
|
||||
process.env.NODE_ENV = 'production';
|
||||
});
|
||||
|
||||
it('should resolve buildNum to kibana.buildNum', function () {
|
||||
get.withArgs('kibana.buildNum').returns(5801);
|
||||
return upgrade(response).then(function (resp) {
|
||||
sinon.assert.calledOnce(client.create);
|
||||
var params = client.create.args[0][0];
|
||||
expect(params.body).to.have.property('buildNum', 5801);
|
||||
});
|
||||
});
|
||||
|
||||
it('should resolve version to kibana.package.version', function () {
|
||||
return upgrade(response).then(function (resp) {
|
||||
var params = client.create.args[0][0];
|
||||
expect(params).to.have.property('id', '4.0.1');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('development', function () {
|
||||
beforeEach(function () {
|
||||
process.env.NODE_ENV = 'development';
|
||||
});
|
||||
|
||||
it('should resolve buildNum to the max integer', function () {
|
||||
return upgrade(response).then(function (resp) {
|
||||
var params = client.create.args[0][0];
|
||||
expect(params.body).to.have.property('buildNum', (Math.pow(2, 53) - 1));
|
||||
});
|
||||
});
|
||||
|
||||
it('should resolve version to @@version', function () {
|
||||
return upgrade(response).then(function (resp) {
|
||||
var params = client.create.args[0][0];
|
||||
expect(params).to.have.property('id', '@@version');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
process.env.NODE_ENV = env;
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -9,16 +9,7 @@ module.exports = function (server) {
|
|||
type: 'config',
|
||||
body: {
|
||||
size: 1000,
|
||||
sort: [ { buildNum: { order: 'desc' } } ],
|
||||
query: {
|
||||
filtered: {
|
||||
filter: {
|
||||
bool: {
|
||||
must_not: [ { query: { match: { _id: '@@version' } } } ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sort: [ { buildNum: { order: 'desc' } } ]
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -4,16 +4,32 @@ var pkg = require('../../../utils/closestPackageJson').getSync();
|
|||
var _ = require('lodash');
|
||||
var format = require('util').format;
|
||||
module.exports = function (server) {
|
||||
|
||||
var MAX_INTEGER = Math.pow(2, 53) - 1;
|
||||
|
||||
var client = server.plugins.elasticsearch.client;
|
||||
var config = server.config();
|
||||
return function (response) {
|
||||
var newConfig = {};
|
||||
// Check to see if there are any doc. If not then we can assume
|
||||
// nothing needs to be done
|
||||
if (response.hits.hits.length === 0) return Promise.resolve();
|
||||
|
||||
// Check to see if there are any doc. If not then we set the build number and id
|
||||
if (response.hits.hits.length === 0) {
|
||||
var isProduction = process.env.NODE_ENV === 'production';
|
||||
return client.create({
|
||||
index: config.get('kibana.index'),
|
||||
type: 'config',
|
||||
body: {
|
||||
buildNum: isProduction ? config.get('kibana.buildNum') : MAX_INTEGER
|
||||
},
|
||||
id: isProduction ? config.get('kibana.package.version') : '@@version'
|
||||
});
|
||||
}
|
||||
|
||||
// if we already have a the current version in the index then we need to stop
|
||||
if (_.find(response.hits.hits, { _id: pkg.version })) {
|
||||
if (_.find(response.hits.hits, function currentVersion(hit) {
|
||||
return hit._id !== '@@version' &&
|
||||
hit._id === pkg.version;
|
||||
})) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
@ -22,10 +38,9 @@ module.exports = function (server) {
|
|||
var body = _.find(response.hits.hits, isUpgradeable.bind(null, server));
|
||||
if (!body) return Promise.resolve();
|
||||
|
||||
|
||||
// if the build number is still the template string (which it wil be in development)
|
||||
// then we need to set it to the max interger. Otherwise we will set it to the build num
|
||||
body._source.buildNum = Math.pow(2, 53) - 1;
|
||||
body._source.buildNum = MAX_INTEGER;
|
||||
if (!/^@@/.test(config.get('kibana.buildNum'))) {
|
||||
body._source.buildNum = parseInt(config.get('kibana.buildNum'), 10);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<li ng-class="{active: mode == 'json'}"><a ng-click="mode='json'">JSON</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="content">
|
||||
<div class="doc-viewer-content">
|
||||
<table class="table table-condensed" ng-show="mode == 'table'">
|
||||
<tbody>
|
||||
<tr ng-repeat="field in fields">
|
||||
|
|
|
@ -17,7 +17,7 @@ doc-viewer .doc-viewer {
|
|||
font-family: "Lucida Console", Monaco, monospace;
|
||||
}
|
||||
|
||||
.content {
|
||||
&-content {
|
||||
margin-top: @padding-base-vertical;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,11 @@ define(function (require) {
|
|||
angular.module('SeedColorUtilService', ['kibana']);
|
||||
angular.module('ColorObjUtilService', ['kibana']);
|
||||
angular.module('ColorPaletteUtilService', ['kibana']);
|
||||
angular.module('MappedColorService', ['kibana']);
|
||||
|
||||
describe('Vislib Color Module Test Suite', function () {
|
||||
var seedColors;
|
||||
var MappedColors, mappedColors;
|
||||
|
||||
describe('Color (main)', function () {
|
||||
var getColors;
|
||||
|
@ -32,6 +34,8 @@ define(function (require) {
|
|||
ngMock.inject(function (d3, Private) {
|
||||
seedColors = Private(require('ui/vislib/components/color/seed_colors'));
|
||||
getColors = Private(require('ui/vislib/components/color/color'));
|
||||
MappedColors = Private(require('ui/vislib/components/color/mapped_colors'));
|
||||
mappedColors = new MappedColors();
|
||||
color = getColors(arr);
|
||||
});
|
||||
});
|
||||
|
@ -103,6 +107,10 @@ define(function (require) {
|
|||
it('should return the first hex color in the seed colors array', function () {
|
||||
expect(color(arr[0])).to.be(seedColors[0]);
|
||||
});
|
||||
|
||||
it('should return the value from the mapped colors', function () {
|
||||
expect(color(arr[1])).to.be(mappedColors.get(arr[1]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Seed Colors', function () {
|
||||
|
@ -117,6 +125,45 @@ define(function (require) {
|
|||
|
||||
});
|
||||
|
||||
describe('Mapped Colors', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
module('MappedColorService');
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
inject(function (d3, Private) {
|
||||
MappedColors = Private(require('ui/vislib/components/color/mapped_colors'));
|
||||
mappedColors = new MappedColors();
|
||||
});
|
||||
});
|
||||
|
||||
it('should clear all the keys from the map table', function () {
|
||||
mappedColors.reset();
|
||||
expect(mappedColors.count()).to.be(0);
|
||||
});
|
||||
|
||||
it('should return the color for the added value', function () {
|
||||
mappedColors.reset();
|
||||
mappedColors.add('value1', '#somecolor');
|
||||
expect(mappedColors.get('value1')).to.be('#somecolor');
|
||||
});
|
||||
|
||||
it('should return the count of mapped keys', function () {
|
||||
mappedColors.reset();
|
||||
mappedColors.add('value1', '#color1');
|
||||
mappedColors.add('value2', '#color2');
|
||||
expect(mappedColors.count()).to.be(2);
|
||||
});
|
||||
|
||||
it('should return all the colors in the map', function () {
|
||||
mappedColors.reset();
|
||||
mappedColors.add('value1', '#colors1');
|
||||
mappedColors.add('value3', '#newColor');
|
||||
expect(mappedColors.all()).to.eql(['#colors1', '#newColor']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Color Palette', function () {
|
||||
var num1 = 45;
|
||||
var num2 = 72;
|
||||
|
|
|
@ -122,8 +122,87 @@ define(function (require) {
|
|||
var rowIn = new Data(rowsData, {});
|
||||
expect(_.isObject(rowIn)).to.be(true);
|
||||
});
|
||||
|
||||
it('should update label in series data', function () {
|
||||
var seriesDataWithoutLabelInSeries = {
|
||||
'label': '',
|
||||
'series': [
|
||||
{
|
||||
'label': '',
|
||||
'values': [{x: 0, y: 1}, {x: 1, y: 2}, {x: 2, y: 3}]
|
||||
}
|
||||
],
|
||||
'yAxisLabel': 'customLabel'
|
||||
};
|
||||
var modifiedData = new Data(seriesDataWithoutLabelInSeries, {});
|
||||
expect(modifiedData.data.series[0].label).to.be('customLabel');
|
||||
});
|
||||
|
||||
it('should update label in row data', function () {
|
||||
var seriesDataWithoutLabelInRow = {
|
||||
'rows': [
|
||||
{
|
||||
'label': '',
|
||||
'series': [
|
||||
{
|
||||
'label': '',
|
||||
'values': [{x: 0, y: 1}, {x: 1, y: 2}, {x: 2, y: 3}]
|
||||
}
|
||||
],
|
||||
'yAxisLabel': 'customLabel'
|
||||
},
|
||||
{
|
||||
'label': '',
|
||||
'series': [
|
||||
{
|
||||
'label': '',
|
||||
'values': [{x: 0, y: 1}, {x: 1, y: 2}, {x: 2, y: 3}]
|
||||
}
|
||||
],
|
||||
'yAxisLabel': 'customLabel'
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
var modifiedData = new Data(seriesDataWithoutLabelInRow, {});
|
||||
expect(modifiedData.data.rows[0].series[0].label).to.be('customLabel');
|
||||
expect(modifiedData.data.rows[1].series[0].label).to.be('customLabel');
|
||||
});
|
||||
|
||||
it('should update label in column data', function () {
|
||||
var seriesDataWithoutLabelInRow = {
|
||||
'columns': [
|
||||
{
|
||||
'label': '',
|
||||
'series': [
|
||||
{
|
||||
'label': '',
|
||||
'values': [{x: 0, y: 1}, {x: 1, y: 2}, {x: 2, y: 3}]
|
||||
}
|
||||
],
|
||||
'yAxisLabel': 'customLabel'
|
||||
},
|
||||
{
|
||||
'label': '',
|
||||
'series': [
|
||||
{
|
||||
'label': '',
|
||||
'values': [{x: 0, y: 1}, {x: 1, y: 2}, {x: 2, y: 3}]
|
||||
}
|
||||
],
|
||||
'yAxisLabel': 'customLabel'
|
||||
}
|
||||
],
|
||||
'yAxisLabel': 'customLabel'
|
||||
};
|
||||
|
||||
var modifiedData = new Data(seriesDataWithoutLabelInRow, {});
|
||||
expect(modifiedData.data.columns[0].series[0].label).to.be('customLabel');
|
||||
expect(modifiedData.data.columns[1].series[0].label).to.be('customLabel');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('_removeZeroSlices', function () {
|
||||
var data;
|
||||
var pieData = {
|
||||
|
|
|
@ -3,6 +3,8 @@ define(function (require) {
|
|||
var _ = require('lodash');
|
||||
|
||||
var createColorPalette = Private(require('ui/vislib/components/color/color_palette'));
|
||||
var MappedColors = Private(require('ui/vislib/components/color/mapped_colors'));
|
||||
var mappedColors = new MappedColors();
|
||||
|
||||
/*
|
||||
* Accepts an array of strings or numbers that are used to create a
|
||||
|
@ -23,11 +25,16 @@ define(function (require) {
|
|||
});
|
||||
|
||||
var arrayLength = arrayOfStringsOrNumbers.length;
|
||||
var colorObj = _.zipObject(arrayOfStringsOrNumbers, createColorPalette(arrayLength));
|
||||
var colors = createColorPalette(arrayLength + mappedColors.count());
|
||||
var uniqueColors = _.difference(colors, mappedColors.all()).slice(0, arrayLength + 1);
|
||||
var colorObj = _.zipObject(arrayOfStringsOrNumbers, uniqueColors);
|
||||
|
||||
return function (value) {
|
||||
return colorObj[value];
|
||||
if (!mappedColors.get(value)) {
|
||||
mappedColors.add(value, colorObj[value]);
|
||||
}
|
||||
return mappedColors.get(value);
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
63
src/ui/vislib/components/color/mapped_colors.js
Normal file
63
src/ui/vislib/components/color/mapped_colors.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
define(function () {
|
||||
return function MappedColorFactory() {
|
||||
|
||||
var _ = require('lodash');
|
||||
/*
|
||||
* Maintains a lookup table that associates the value (key) with a hex color (value)
|
||||
* across the visualizations.
|
||||
* Provides functions to interact with the lookup table
|
||||
*/
|
||||
|
||||
var MappedColorService = function () {
|
||||
};
|
||||
|
||||
MappedColorService.colors = {};
|
||||
/**
|
||||
* Allows to add value (key) and color (value) to the lookup table
|
||||
*
|
||||
* @method add
|
||||
* @param {String} key - the value in a visualization
|
||||
* @param {String} value - the color associated with the value
|
||||
*/
|
||||
MappedColorService.prototype.add = function (key, value) {
|
||||
MappedColorService.colors[key] = value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides the color (value) associated with the value (key)
|
||||
*
|
||||
* @method get
|
||||
* @param {String} key - the value for which color is required
|
||||
* @returns the color associated with the value
|
||||
*/
|
||||
MappedColorService.prototype.get = function (key) {
|
||||
return MappedColorService.colors[key];
|
||||
};
|
||||
|
||||
/**
|
||||
* Size of the mapped colors
|
||||
*
|
||||
* @method count
|
||||
* @returns the number of values (keys) stored in the lookup table
|
||||
*/
|
||||
MappedColorService.prototype.count = function () {
|
||||
return _.keys(MappedColorService.colors).length;
|
||||
};
|
||||
|
||||
/**
|
||||
* All the colors of in the lookup table
|
||||
*
|
||||
* @method all
|
||||
* @returns all the colors used in the lookup table
|
||||
*/
|
||||
MappedColorService.prototype.all = function () {
|
||||
return _.values(MappedColorService.colors);
|
||||
};
|
||||
|
||||
MappedColorService.prototype.reset = function () {
|
||||
MappedColorService.colors = {};
|
||||
};
|
||||
|
||||
return MappedColorService;
|
||||
};
|
||||
});
|
|
@ -37,6 +37,7 @@ define(function (require) {
|
|||
|
||||
this.data = data;
|
||||
this.type = this.getDataType();
|
||||
|
||||
this.labels = this._getLabels(this.data);
|
||||
this.color = this.labels ? color(this.labels) : undefined;
|
||||
this._normalizeOrdered();
|
||||
|
@ -60,10 +61,29 @@ define(function (require) {
|
|||
}
|
||||
}
|
||||
|
||||
Data.prototype._updateData = function () {
|
||||
if (this.data.rows) {
|
||||
_.map(this.data.rows, this._updateDataSeriesLabel, this);
|
||||
} else if (this.data.columns) {
|
||||
_.map(this.data.columns, this._updateDataSeriesLabel, this);
|
||||
} else {
|
||||
this._updateDataSeriesLabel(this.data);
|
||||
}
|
||||
};
|
||||
|
||||
Data.prototype._updateDataSeriesLabel = function (eachData) {
|
||||
if (eachData.series) {
|
||||
eachData.series[0].label = this.get('yAxisLabel');
|
||||
}
|
||||
};
|
||||
|
||||
Data.prototype._getLabels = function (data) {
|
||||
if (this.type === 'series') {
|
||||
var noLabel = getLabels(data).length === 1 && getLabels(data)[0] === '';
|
||||
if (noLabel) return [(this.get('yAxisLabel'))];
|
||||
if (noLabel) {
|
||||
this._updateData();
|
||||
return [(this.get('yAxisLabel'))];
|
||||
}
|
||||
return getLabels(data);
|
||||
}
|
||||
return this.pieNames();
|
||||
|
|
|
@ -150,9 +150,9 @@ define(function (require) {
|
|||
.attr('fill-opacity', (this._attr.drawLinesBetweenPoints ? 1 : 0.7))
|
||||
.attr('cx', cx)
|
||||
.attr('cy', cy)
|
||||
.attr('fill', colorCircle)
|
||||
.attr('class', 'circle-decoration')
|
||||
.call(this._addIdentifier);
|
||||
.call(this._addIdentifier)
|
||||
.attr('fill', colorCircle);
|
||||
|
||||
circles
|
||||
.enter()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
define(function (require) {
|
||||
describe('Vis Type', function () {
|
||||
describe(require('specs/components/vislib_vis_type/_VislibRenderbot'));
|
||||
describe(require('specs/components/vislib_vis_type/_buildChartData'));
|
||||
describe(require('./_VislibRenderbot'));
|
||||
describe(require('./_buildChartData'));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue