Skip to content

Commit

Permalink
Make panel scope isolate
Browse files Browse the repository at this point in the history
Also clean up and simplify scope destroying

Fix sorting on scripted date and boolean fields (elastic#9261)

The elasticsearch API only [supports][1][2] sort scripts of type `number` and
`string`. Since dates need to be returned as millis since the epoch for
visualizations to work anyway, we can simply add a condition to send dates
as type number in the sort API. ES will cast booleans if we tell them
its a string, so we can add a similar condition there as well.

[1]: https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-request-sort.html#_script_based_sorting
[2]: https://github.com/elastic/elasticsearch/blob/aeb97ff41298e26b107a733837dfe17f123c0c9b/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java#L359

Fixes: elastic#9257

Add docs on all available console server config options (elastic#9288)

settings: do not query ES for settings in non-green status (elastic#9308)

If the ui settings status is not green, that means there is at least one
dependency (so elasticsearch at the moment) that is not met in order for
it to function correctly, so we shouldn't attempt to determine user
settings at all.

This ensures that when something like the version check fails in the
elasticsearch plugin, Kibana correctly behaves by not attempting
requests to elasticsearch, which prevents 500 errors and allows users to
see the error status on the status page.

We also now periodically check for compatible elasticsearch versions so
that Kibana can automatically recover if the elasticsearch node is
upgraded to the appropriate version.

Change loading screen background to white to make it less distracting when navigating between apps. (elastic#9313)

more refactoring

Fix sorting on scripted date and boolean fields (elastic#9261)

The elasticsearch API only [supports][1][2] sort scripts of type `number` and
`string`. Since dates need to be returned as millis since the epoch for
visualizations to work anyway, we can simply add a condition to send dates
as type number in the sort API. ES will cast booleans if we tell them
its a string, so we can add a similar condition there as well.

[1]: https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-request-sort.html#_script_based_sorting
[2]: https://github.com/elastic/elasticsearch/blob/aeb97ff41298e26b107a733837dfe17f123c0c9b/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java#L359

Fixes: elastic#9257

Add docs on all available console server config options (elastic#9288)

settings: do not query ES for settings in non-green status (elastic#9308)

If the ui settings status is not green, that means there is at least one
dependency (so elasticsearch at the moment) that is not met in order for
it to function correctly, so we shouldn't attempt to determine user
settings at all.

This ensures that when something like the version check fails in the
elasticsearch plugin, Kibana correctly behaves by not attempting
requests to elasticsearch, which prevents 500 errors and allows users to
see the error status on the status page.

We also now periodically check for compatible elasticsearch versions so
that Kibana can automatically recover if the elasticsearch node is
upgraded to the appropriate version.

Change loading screen background to white to make it less distracting when navigating between apps. (elastic#9313)

Skip assertion when the test blips. (elastic#9251)

Tests fails intermittently, and for identical reasons. When this occurs, skip the test. This only occurs in CI and cannot be reproduced locally.

Additional changes:
- Use async/await to improve legibility.
- Move async behaviour to beforeEach and keep test stubs synchronous to improve labeling of tests.

[git] ignore extra files in the root config/ directory (elastic#9296)

upgrade makelogs (elastic#9295)

build: remove deepModules hackery (elastic#9327)

The deepModules hacks in the build system were added to support the long
paths that resulted from npm2, but npm3 fundamentally addresses that
problem, so deepModules is no longer necessary. In practical terms, npm3
shouldn't ever cause path lengths to become so long that they trigger
path length problems on certain operating systems.

more cleanup and tests

Save/rename flow fix (elastic#9087)

* Save/rename flow fix

- Use auto generated ids instead of coupling the id to the title which
creates problems.
- Adjust UI to make the save flow more understandable.
- Remove confirmation on overwrite since we will now be creating
duplicate objects even if they have the same title.

* use undefined instead of null

* Change titleChanged function name

* address code review comments

* Add isSaving flag to avoid checkbox flicker, fix regression bug from refactor.
Added tests and fixed a couple bugs
Updated info message

* Update doc and nav title with new name on rename
don't hardcode Dashboard
  • Loading branch information
stacey-gammon committed Dec 2, 2016
1 parent c54eb3f commit e76f638
Show file tree
Hide file tree
Showing 44 changed files with 915 additions and 477 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ target
data
disabledPlugins
webpackstats.json
config/kibana.dev.yml
config/*
!config/kibana.yml
coverage
selenium
.babelcache.json
Expand Down
18 changes: 1 addition & 17 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,7 @@ module.exports = function (grunt) {
'!<%= src %>/core_plugins/timelion/vendor_components/**/*.js',
'!<%= src %>/fixtures/**/*.js',
'!<%= root %>/test/fixtures/scenarios/**/*.js'
],
deepModules: {
'caniuse-db': '1.0.30000265',
'chalk': '1.1.0',
'glob': '4.5.3',
'har-validator': '1.8.0',
'json5': '0.4.0',
'loader-utils': '0.2.11',
'micromatch': '2.2.0',
'postcss-normalize-url': '2.1.1',
'postcss-reduce-idents': '1.0.2',
'postcss-unique-selectors': '1.0.0',
'postcss-minify-selectors': '1.4.6',
'postcss-single-charset': '0.3.0',
'regenerator': '0.8.36',
'readable-stream': '2.1.0'
}
]
};

grunt.config.merge(config);
Expand Down
2 changes: 1 addition & 1 deletion docs/console.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ include::console/history.asciidoc[]

include::console/settings.asciidoc[]

include::console/disabling-console.asciidoc[]
include::console/configuring-console.asciidoc[]
57 changes: 57 additions & 0 deletions docs/console/configuring-console.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[[configuring-console]]
== Configuring Console

You can add the following options in the `config/kibana.yml` file:

`console.enabled`:: *Default: true* Set to false to disable Console. Toggling this will cause the server to regenerate assets on the next startup, which may cause a delay before pages start being served.

`console.proxyFilter`:: *Default: `.*`* A list of regular expressions that are used to validate any outgoing request from Console. If none
of these match, the request will be rejected. See <<securing-console>> for more details.

`console.proxyConfig`:: A list of configuration options that are based on the proxy target. Use this to set custom timeouts or SSL settings for specific hosts. This is done by defining a set of `match` criteria using wildcards/globs which will be checked against each request. The configuration from all matching rules will then be merged together to configure the proxy used for that request.
+
The valid match keys are `match.protocol`, `match.host`, `match.port`, and `match.path`. All of these keys default to `*`, which means they will match any value.
+
Example:
+
[source,yaml]
--------
console.proxyConfig:
- match:
host: "*.internal.org" # allow any host that ends in .internal.org
port: "{9200..9299}" # allow any port from 9200-9299
ssl:
ca: "/opt/certs/internal.ca"
# "key" and "cert" are also valid options here
- match:
protocol: "https"
ssl:
verify: false # allows any certificate to be used, even self-signed certs
# since this rule has no "match" section it matches everything
- timeout: 180000 # 3 minutes
--------

[[securing-console]]
=== Securing Console

Console is meant to be used as a local development tool. As such, it will send requests to any host & port combination,
just as a local curl command would. To overcome the CORS limitations enforced by browsers, Console's Node.js backend
serves as a proxy to send requests on behalf of the browser. However, if put on a server and exposed to the internet
this can become a security risk. In those cases, we highly recommend you lock down the proxy by setting the
`console.proxyFilter` setting. The setting accepts a list of regular expressions that are evaluated against each URL
the proxy is requested to retrieve. If none of the regular expressions match the proxy will reject the request.

Here is an example configuration the only allows Console to connect to localhost:

[source,yaml]
--------
console.proxyFilter:
- ^https?://(localhost|127\.0\.0\.1|\[::0\]).*
--------

You will need to restart Kibana for these changes to take effect.

10 changes: 0 additions & 10 deletions docs/console/disabling-console.asciidoc

This file was deleted.

4 changes: 4 additions & 0 deletions docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ The minimum value is 100.
`status.allowAnonymous`:: *Default: false* If authentication is enabled, setting this to `true` allows
unauthenticated users to access the Kibana server status API and status page.
`console.enabled`:: *Default: true* Set to false to disable Console. Toggling this will cause the server to regenerate assets on the next startup, which may cause a delay before pages start being served.
`console.proxyFilter`:: *Default: `.*`* A list of regular expressions that are used to validate any outgoing request from Console. If none of these match, the request will be rejected.
`console.proxyConfig`:: A list of configuration options that are based on the proxy target. Use this to set custom timeouts or SSL settings for specific hosts. This is done by defining a set of `match` criteria using wildcards/globs which will be checked against each request. The configuration from all matching rules will then be merged together to configure the proxy used for that request.
+
The valid match keys are `match.protocol`, `match.host`, `match.port`, and `match.path`. All of these keys default to `*`, which means they will match any value. See <<configuring-console>> for an example.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"karma-safari-launcher": "0.1.1",
"license-checker": "5.1.2",
"load-grunt-config": "0.19.2",
"makelogs": "3.0.2",
"makelogs": "3.1.1",
"marked-text-renderer": "0.1.0",
"mocha": "2.5.3",
"murmurhash3js": "3.0.1",
Expand Down
9 changes: 8 additions & 1 deletion src/core_plugins/elasticsearch/lib/health_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,20 @@ module.exports = function (plugin, server) {
});
}

function waitForEsVersion() {
return checkEsVersion(server, kibanaVersion.get()).catch(err => {
plugin.status.red(err);
return Promise.delay(REQUEST_DELAY).then(waitForEsVersion);
});
}

function setGreenStatus() {
return plugin.status.green('Kibana index ready');
}

function check() {
return waitForPong()
.then(() => checkEsVersion(server, kibanaVersion.get()))
.then(waitForEsVersion)
.then(waitForShards)
.then(setGreenStatus)
.then(_.partial(migrateConfig, server))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import angular from 'angular';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import 'plugins/kibana/dashboard/services/_saved_dashboard';
import { DEFAULT_PANEL_WIDTH, DEFAULT_PANEL_HEIGHT } from '../components/panel/lib/panel';

describe('dashboard panels', function () {
let $scope;
let $el;

const compile = (dashboard) => {
function compile(dashboard) {
ngMock.inject(($rootScope, $controller, $compile, $route) => {
$scope = $rootScope.$new();
$route.current = {
Expand All @@ -19,12 +20,16 @@ describe('dashboard panels', function () {
$el = angular.element(`
<dashboard-app>
<dashboard-grid style="width: 600px; height: 600px;"></dashboard-grid>
</<dashboard-app>`);
</dashboard-app>`);
$compile($el)($scope);
$scope.$digest();
});
};

function findPanelWithVisualizationId(id) {
return $scope.state.panels.find((panel) => { return panel.id === id; });
}

beforeEach(() => {
ngMock.module('kibana');
});
Expand Down Expand Up @@ -77,10 +82,30 @@ describe('dashboard panels', function () {
compile(dash);
});
expect($scope.state.panels.length).to.be(16);
const foo8Panel = $scope.state.panels.find(
(panel) => { return panel.id === 'foo8'; });
const foo8Panel = findPanelWithVisualizationId('foo8');
expect(foo8Panel).to.not.be(null);
expect(foo8Panel.row).to.be(8);
expect(foo8Panel.col).to.be(1);
});

it('initializes visualizations with the default size', function () {
ngMock.inject((SavedDashboard) => {
let dash = new SavedDashboard();
dash.init();
dash.panelsJSON = `[
{"col":3,"id":"foo1","row":1,"type":"visualization"},
{"col":5,"id":"foo2","row":1,"size_x":5,"size_y":9,"type":"visualization"}]`;
compile(dash);
});
expect($scope.state.panels.length).to.be(2);
const foo1Panel = findPanelWithVisualizationId('foo1');
expect(foo1Panel).to.not.be(null);
expect(foo1Panel.size_x).to.be(DEFAULT_PANEL_WIDTH);
expect(foo1Panel.size_y).to.be(DEFAULT_PANEL_HEIGHT);

const foo2Panel = findPanelWithVisualizationId('foo2');
expect(foo2Panel).to.not.be(null);
expect(foo2Panel.size_x).to.be(5);
expect(foo2Panel.size_y).to.be(9);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
export const DEFAULT_PANEL_WIDTH = 3;
export const DEFAULT_PANEL_HEIGHT = 2;

/**
* Represents a panel on a grid. Keeps track of position in the grid and what visualization it
* contains.
*
* @param id - Id of the visualization contained in the panel.
* @param type - Type of the visualization in the panel.
* @param panelId - Unique id to represent this panel in the grid.
* @constructor
*/
function Panel(id, type, panelId) {
/**
* A reference to the gridster widget holding this panel. Used to
* update the size and column attributes.
*/
this.$el;

/**
* Width of the panel.
* @type {number}
*/
this.size_x = DEFAULT_PANEL_WIDTH;

/**
* Height of the panel.
* @type {number}
*/
this.size_y = DEFAULT_PANEL_HEIGHT;

/**
* Column index in the grid.
* @type {number}
*/
this.col;

/**
* Row index of the panel in the grid.
* @type {number}
*/
this.row;

/**
* Height of the panel.
* @type {number}
*/
this.id = id;

/**
* Unique identifier for this panel. Guaranteed to be unique among the current
* panels in the grid.
* @type {number}
*/
this.panelId = panelId;

/**
* Type of visualization this panel contains.
* @type {string}
*/
this.type = type;
}

/**
* Factory function to create a panel object.
*
* @param id {string} - The id of the visualization this panel contains
* @param type {string} - The type of visualization this panel contains
* @param panelId {number} - A unique identifier for this panel in the grid
* @returns {Panel}
*/
export function createNewPanel(id, type, panelId) {
return new Panel(id, type, panelId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { DEFAULT_PANEL_WIDTH, DEFAULT_PANEL_HEIGHT } from 'plugins/kibana/dashboard/components/panel/lib/panel';

export class PanelUtils {
/**
* Fills in default parameters where not specified.
* @param panel {Panel}
*/
static initializeDefaults(panel) {
panel.size_x = panel.size_x || DEFAULT_PANEL_WIDTH;
panel.size_y = panel.size_y || DEFAULT_PANEL_HEIGHT;

if (!panel.id) {
// In the interest of backwards comparability
if (panel.visId) {
panel.id = panel.visId;
panel.type = 'visualization';
delete panel.visId;
} else {
throw new Error('Missing object id on panel');
}
}
}

/**
* Ensures that the panel object has the latest size/pos info.
* @param panel {Panel}
*/
static refreshSizeAndPosition(panel) {
const data = panel.$el.coords().grid;
panel.size_x = data.size_x;
panel.size_y = data.size_y;
panel.col = data.col;
panel.row = data.row;
}

/**
* $el is a circular structure because it contains a reference to it's parent panel,
* so it needs to be removed before it can be serialized (we also don't
* want it to show up in the url).
* @param panel
*/
static makeSerializeable(panel) {
delete panel.$el;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
{{::savedObj.title}}
</span>
<div class="btn-group">
<a aria-label="Edit" ng-show="chrome.getVisible() && editUrl" ng-href="{{::editUrl}}">
<a aria-label="Edit" ng-show="!isFullScreenMode && editUrl" ng-href="{{::editUrl}}">
<i aria-hidden="true" class="fa fa-pencil"></i>
</a>
<a aria-label="Move" ng-show="chrome.getVisible()" class="panel-move">
<a aria-label="Move" ng-show="!isFullScreenMode" class="panel-move">
<i aria-hidden="true" class="fa fa-arrows"></i>
</a>
<a aria-label="Remove" ng-show="chrome.getVisible()" ng-click="remove()">
<a aria-label="Remove" ng-show="!isFullScreenMode" ng-click="remove()">
<i aria-hidden="true" class="fa fa-times"></i>
</a>
</div>
Expand All @@ -26,7 +26,7 @@
ng-switch-when="visualization"
vis="savedObj.vis"
search-source="savedObj.searchSource"
show-spy-panel="chrome.getVisible()"
show-spy-panel="!isFullScreenMode"
ui-state="uiState"
render-counter
class="panel-content">
Expand Down
Loading

0 comments on commit e76f638

Please sign in to comment.