Skip to content

Commit

Permalink
add top_hit metric
Browse files Browse the repository at this point in the history
Backports PR elastic#7302

**Commit 1:**
add top_hits aggregation

* Original sha: 22bab62
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-05-26T22:02:08Z

**Commit 2:**
support nested fields

* Original sha: 8aef2b8
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-06-11T14:57:35Z

**Commit 3:**
added choice of the order and select by default the index pattern associated time field

* Original sha: 9791ac5
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-06-14T21:08:00Z

**Commit 4:**
improved parameters name and changed aggregation from latest to top to better reflect what this aggregation may accomplish

* Original sha: 692f41c
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-06-22T20:32:12Z

**Commit 5:**
made variable a constant

* Original sha: 39cddab
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-07-01T22:42:13Z

**Commit 6:**
use shorter name for variable

* Original sha: c6494cc
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-07-27T08:50:44Z

**Commit 7:**
prevent to sort terms on top_hits

* Original sha: b365ddc
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-08-28T09:47:47Z

**Commit 8:**
Added the top_hits agg to line/pie/tile vis. Added support for function in prop_filter to allow more flexibility when filtering the list of values. The _term order is now the default ordering instead of _custom.

* Original sha: be44e90
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-09-19T14:53:48Z

**Commit 9:**
simplified tests

* Original sha: 43767f0
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-10-11T09:29:11Z

**Commit 10:**
changed as per code review

* Original sha: 53469d5
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-10-11T21:49:36Z

**Commit 11:**
Top Hit should support all field types on the metric vis

* Original sha: 20be950
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-10-17T21:18:31Z

**Commit 12:**
renamed metric to top hit

* Original sha: 20cbb12
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-10-17T21:28:30Z

**Commit 13:**
check if there is any result from buckets

* Original sha: b99d6c7
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-10-18T09:13:19Z

**Commit 14:**
support scripted fields

* Original sha: f79cdc1
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-10-23T20:58:55Z

**Commit 15:**
Merge branch 'master' of github.com:elastic/kibana into latest-value

* Original sha: 82060ce
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-01T09:47:19Z

**Commit 16:**
Merge branch 'master' of github.com:elastic/kibana into latest-value

* Original sha: 2577298
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-12T11:30:42Z

**Commit 17:**
- added logic for trying to get the field value from the source or from a
  doc_values field.
- added onlyAggregatable option for a field agg param to decide whether
  or not to retain only aggregatable fields.

* Original sha: 6a2bc01
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-13T12:34:10Z

**Commit 18:**
improved loops in getValuesAtPath method

* Original sha: 991864c
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-16T10:10:28Z

**Commit 19:**
Merge branch 'master' of github.com:elastic/kibana into latest-value

* Original sha: bc1c90a
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-17T23:51:13Z

**Commit 20:**
do not try to get the doc_values field of an IP field

* Original sha: d697f11
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-18T00:49:34Z

**Commit 21:**
improved field tests on the onlyAggregatable option

* Original sha: c2249e5
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-18T01:08:34Z

**Commit 22:**
use indexPattern.formatField to get all the values at a given path

* Original sha: f4200e1
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-19T23:02:18Z

**Commit 23:**
do not show the analyzed warning

* Original sha: 2dda53d
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-19T23:30:59Z

**Commit 24:**
support to sort on scripted field

* Original sha: eda9610
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-19T23:52:15Z

**Commit 25:**
corrected tests and rely on the field's formatter instead of trying to return a nice string

* Original sha: b465438
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-20T14:40:43Z

**Commit 26:**
do not rely on init_default_field_props to set the doc_values property

* Original sha: 19e2104
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-21T23:11:29Z

**Commit 27:**
added test for the doc_values property

* Original sha: fd323f3
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-11-23T10:04:16Z

**Commit 28:**
Merge branch 'master' of github.com:elastic/kibana into latest-value

* Original sha: cfed72e
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-12-05T15:47:45Z

**Commit 29:**
- corrected source formatter
- add option to show/hide analyzed warning of a field

* Original sha: 3090182
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-12-05T22:40:14Z

**Commit 30:**
set the default value of the showAnalyzedWarning in fieldparam

* Original sha: 0d924fc
* Authored by Stéphane Campinas <stephane.campinas@gmail.com> on 2016-12-08T16:29:46Z
  • Loading branch information
scampi committed Jan 6, 2017
1 parent 026adf9 commit d3856f5
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 56 deletions.
89 changes: 89 additions & 0 deletions src/core_plugins/kibana/public/dashboard/get_top_nav_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@

/**
* @param kbnUrl - used to change the url.
* @return {Array<kbnTopNavConfig>} - Returns an array of objects for a top nav configuration.
* Note that order matters and the top nav will be displayed in the same order.
*/
export function getTopNavConfig(kbnUrl) {
return [
getNewConfig(kbnUrl),
getAddConfig(),
getSaveConfig(),
getOpenConfig(),
getShareConfig(),
getOptionsConfig()];
}

/**
*
* @param kbnUrl
* @returns {kbnTopNavConfig}
*/
function getNewConfig(kbnUrl) {
return {
key: 'new',
description: 'New Dashboard',
testId: 'dashboardNewButton',
run: () => { kbnUrl.change('/dashboard', {}); }
};
}

/**
* @returns {kbnTopNavConfig}
*/
function getAddConfig() {
return {
key: 'add',
description: 'Add a panel to the dashboard',
testId: 'dashboardAddPanelButton',
template: require('plugins/kibana/dashboard/partials/pick_visualization.html')
};
}

/**
* @returns {kbnTopNavConfig}
*/
function getSaveConfig() {
return {
key: 'save',
description: 'Save Dashboard',
testId: 'dashboardSaveButton',
template: require('plugins/kibana/dashboard/partials/save_dashboard.html')
};
}

/**
* @returns {kbnTopNavConfig}
*/
function getOpenConfig() {
return {
key: 'open',
description: 'Open Saved Dashboard',
testId: 'dashboardOpenButton',
template: require('plugins/kibana/dashboard/partials/load_dashboard.html')
};
}

/**
* @returns {kbnTopNavConfig}
*/
function getShareConfig() {
return {
key: 'share',
description: 'Share Dashboard',
testId: 'dashboardShareButton',
template: require('plugins/kibana/dashboard/partials/share.html')
};
}

/**
* @returns {kbnTopNavConfig}
*/
function getOptionsConfig() {
return {
key: 'options',
description: 'Options',
testId: 'dashboardOptionsButton',
template: require('plugins/kibana/dashboard/partials/options.html')
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/kibana/public/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
>
<span
ng-show="dash.id"
ng-bind="dash.lastSavedTitle"
ng-bind="getDashTitle()"
></span>
</div>

Expand Down Expand Up @@ -54,7 +54,7 @@
<!-- Filters. -->
<filter-bar state="state"></filter-bar>

<div ng-show="!state.panels.length" class="text-center start-screen">
<div ng-show="showEditHelpText()" class="text-center start-screen">
<h2>Ready to get started?</h2>
<p>Click the <a class="btn btn-xs navbtn-inverse" ng-click="kbnTopNav.open('add'); toggleAddVisualization = !toggleAddVisualization" aria-label="Add visualization">Add</a> button in the menu bar above to add a visualization to the dashboard. <br/>If you haven't setup a visualization yet visit the <a href="#/visualize" title="Visualize">"Visualize"</a> tab to create your first visualization.</p>
</div>
Expand Down
46 changes: 13 additions & 33 deletions src/core_plugins/kibana/public/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import uiRoutes from 'ui/routes';
import uiModules from 'ui/modules';
import indexTemplate from 'plugins/kibana/dashboard/index.html';
import { savedDashboardRegister } from 'plugins/kibana/dashboard/services/saved_dashboard_register';
import { getTopNavConfig } from './get_top_nav_config';
import { createPanelState } from 'plugins/kibana/dashboard/components/panel/lib/panel_state';

require('ui/saved_objects/saved_object_registry').register(savedDashboardRegister);

const app = uiModules.get('app/dashboard', [
Expand Down Expand Up @@ -89,7 +91,7 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,
panels: dash.panelsJSON ? JSON.parse(dash.panelsJSON) : [],
options: dash.optionsJSON ? JSON.parse(dash.optionsJSON) : {},
uiState: dash.uiStateJSON ? JSON.parse(dash.uiStateJSON) : {},
query: extractQueryFromFilters(dash.searchSource.getOwn('filter')) || {query_string: {query: '*'}},
query: extractQueryFromFilters(dash.searchSource.getOwn('filter')) || { query_string: { query: '*' } },
filters: _.reject(dash.searchSource.getOwn('filter'), matchQueryFilter),
};

Expand All @@ -104,37 +106,7 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,

$scope.$watch('state.options.darkTheme', setDarkTheme);

$scope.topNavMenu = [{
key: 'new',
description: 'New Dashboard',
run: function () { kbnUrl.change('/dashboard', {}); },
testId: 'dashboardNewButton',
}, {
key: 'add',
description: 'Add a panel to the dashboard',
template: require('plugins/kibana/dashboard/partials/pick_visualization.html'),
testId: 'dashboardAddPanelButton',
}, {
key: 'save',
description: 'Save Dashboard',
template: require('plugins/kibana/dashboard/partials/save_dashboard.html'),
testId: 'dashboardSaveButton',
}, {
key: 'open',
description: 'Open Saved Dashboard',
template: require('plugins/kibana/dashboard/partials/load_dashboard.html'),
testId: 'dashboardOpenButton',
}, {
key: 'share',
description: 'Share Dashboard',
template: require('plugins/kibana/dashboard/partials/share.html'),
testId: 'dashboardShareButton',
}, {
key: 'options',
description: 'Options',
template: require('plugins/kibana/dashboard/partials/options.html'),
testId: 'dashboardOptionsButton',
}];
$scope.topNavMenu = getTopNavConfig(kbnUrl);

$scope.refresh = _.bindKey(courier, 'fetch');

Expand Down Expand Up @@ -228,6 +200,10 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,
// update data when filters fire fetch event
$scope.$listen(queryFilter, 'fetch', $scope.refresh);

$scope.getDashTitle = function () {
return dash.lastSavedTitle;
};

$scope.newDashboard = function () {
kbnUrl.change('/dashboard', {});
};
Expand Down Expand Up @@ -256,7 +232,7 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,
if (id) {
notify.info('Saved Dashboard as "' + dash.title + '"');
if (dash.id !== $routeParams.id) {
kbnUrl.change('/dashboard/{{id}}', {id: dash.id});
kbnUrl.change('/dashboard/{{id}}', { id: dash.id });
} else {
docTitle.change(dash.lastSavedTitle);
}
Expand Down Expand Up @@ -302,6 +278,10 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,
};

init();

$scope.showEditHelpText = () => {
return !$scope.state.panels.length;
};
}
};
});
1 change: 0 additions & 1 deletion src/core_plugins/kibana/public/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'ui/field_editor';
import 'plugins/kibana/management/sections/indices/_indexed_fields';
import 'plugins/kibana/management/sections/indices/_scripted_fields';
import 'plugins/kibana/management/sections/indices/source_filters/source_filters';
import 'ui/directives/bread_crumbs';
import uiRoutes from 'ui/routes';
import uiModules from 'ui/modules';
import appTemplate from 'plugins/kibana/management/app.html';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash';
import chrome from 'ui/chrome/chrome';
import breadCrumbsTemplate from 'ui/partials/bread_crumbs.html';
import breadCrumbsTemplate from './bread_crumbs.html';
import uiModules from 'ui/modules';
let module = uiModules.get('kibana');

Expand Down
41 changes: 22 additions & 19 deletions src/ui/public/kbn_top_nav/kbn_top_nav.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/**
* A configuration object for a top nav component.
* @typedef {Object} KbnTopNavConfig
* @type Object
* @property {string} key - A display string which will be shown in the top nav for this option.
* @property {string} [description] - optional, used for the screen-reader description of this
* menu. Defaults to "Toggle ${key} view" for templated menu items and just "${key}" for
* programmatic menu items
* @property {string} testId - for testing purposes, can be used to retrieve this item.
* @property {Object} [template] - an html template that will be shown when this item is clicked.
* If template is not given then run should be supplied.
* @property {function} [run] - an optional function that will be run when the nav item is clicked.
* Either this or template parameter should be specified.
* @param {boolean} [hideButton] - optional, set to true to prevent a menu item from being created.
* This allow injecting templates into the navbar that don't have an associated template
*/

/**
* kbnTopNav directive
*
Expand All @@ -9,27 +26,11 @@
*
* Menu items/templates are passed to the kbnTopNav via the config attribute
* and should be defined as an array of objects. Each object represents a menu
* item and should have the following properties:
* item and should be of type kbnTopNavConfig.
*
* @param {Array<Object>|KbnTopNavController} config
* @param {string} config[].key
* - the uniq key for this menu item.
* @param {string} [config[].label]
* - optional, string that will be displayed for the menu button.
* Defaults to the key
* @param {string} [config[].description]
* - optional, used for the screen-reader description of this menu
* item, defaults to "Toggle ${key} view" for templated menu items
* and just "${key}" for programatic menu items
* @param {boolean} [config[].hideButton]
* - optional, set to true to prevent a menu item from being created.
* This allow injecting templates into the navbar that don't have
* an associated template
* @param {function} [config[].run]
* - optional, function to call when the menu item is clicked, defaults
* to toggling the template
* @param {Array<kbnTopNavConfig>|KbnTopNavController} config
*
* Programatic control of the navbar can be acheived one of two ways
* Programmatic control of the navbar can be achieved one of two ways
*/

import _ from 'lodash';
Expand All @@ -40,6 +41,7 @@ import uiModules from 'ui/modules';
import template from './kbn_top_nav.html';
import KbnTopNavControllerProvider from './kbn_top_nav_controller';
import RegistryNavbarExtensionsProvider from 'ui/registry/navbar_extensions';
import './bread_crumbs/bread_crumbs';

const module = uiModules.get('kibana');

Expand Down Expand Up @@ -98,6 +100,7 @@ module.directive('kbnTopNav', function (Private) {
});

const extensions = getNavbarExtensions($attrs.name);

let controls = _.get($scope, $attrs.config, []);
if (controls instanceof KbnTopNavController) {
controls.addItems(extensions);
Expand Down

0 comments on commit d3856f5

Please sign in to comment.