Skip to content

Commit

Permalink
Merge pull request #28 from belugadb/6.4.x
Browse files Browse the repository at this point in the history
Kibana 6.4.x upgrade
  • Loading branch information
Thomas Charlot authored Oct 30, 2018
2 parents f591e83 + a54a6f2 commit 78acc5d
Show file tree
Hide file tree
Showing 12 changed files with 4,338 additions and 58 deletions.
2 changes: 0 additions & 2 deletions .eslintrc

This file was deleted.

7 changes: 7 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
extends: "@elastic/eslint-config-kibana"

settings:
import/resolver:
'@elastic/eslint-import-resolver-kibana':
rootPackageName: 'datasweet_formula'
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,42 @@ Copy the last installation url for your version of Kibana from the [repository r
```
./bin/kibana-plugin install https://github.com/datasweet-fr/kibana-datasweet-formula/releases/download/version_name/datasweet_formula-X.X.X_kibana-major.minor.patch.zip
```

# Features
Check out what it can do in the [documentation.](http://www.datasweet.fr/datasweet-formula/)

# Development

See the [kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) for instructions setting up your development environment. Once you have completed that, use the following yarn scripts.

- `yarn kbn bootstrap`

Install dependencies and crosslink Kibana and all projects/plugins.

> ***IMPORTANT:*** Use this script instead of `yarn` to install dependencies when switching branches, and re-run it whenever your dependencies change.
- `yarn start`

Start kibana and have it include this plugin. You can pass any arguments that you would normally send to `bin/kibana`

```
yarn start --elasticsearch.url http://localhost:9220
```

- `yarn build`

Build a distributable archive of your plugin.

- `yarn test:browser`

Run the browser tests in a real web browser.

- `yarn test:server`

Run the server tests using mocha.

For more information about any of these commands run `yarn ${task} --help`. For a full list of tasks checkout the `package.json` file, or run `yarn run`.

# Questions ? problems ? suggestions ?
If you find a bug or want to request a feature, please create a [GitHub Issue](https://github.com/datasweet/kibana-datasweet-formula/issues/new).

Expand Down
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ if [ -n "$1" ]; then
exit
fi

build 6.4.2
build 6.4.1
build 6.4.0

build 6.3.2
build 6.3.1
build 6.3.0
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default kibana => new kibana.Plugin({
id: 'datasweet_formula',
name: 'datasweet_formula',
require: ['kibana'],
uiExports: {
hacks: [ 'plugins/datasweet_formula/formula_hack' ]
Expand Down
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"version": "kibana"
},
"scripts": {
"preinstall": "node ../../kibana/preinstall_check",
"kbn": "node ../../kibana/scripts/kbn",
"lint": "eslint **/*.js",
"start": "plugin-helpers start",
"test:server": "plugin-helpers test:server",
"test:browser": "plugin-helpers test:browser",
"build": "plugin-helpers build",
"postinstall": "plugin-helpers postinstall"
"build": "plugin-helpers build"
},
"repository": {
"type": "git",
Expand All @@ -35,11 +36,18 @@
},
"homepage": "https://github.com/datasweet-fr/kibana-datasweet-formula#readme",
"devDependencies": {
"@elastic/eslint-config-kibana": "0.0.2",
"@elastic/plugin-helpers": "^6.0.0",
"babel-eslint": "4.1.8",
"eslint": "1.10.3",
"@elastic/eslint-config-kibana": "link:../../kibana/packages/eslint-config-kibana",
"@elastic/eslint-import-resolver-kibana": "link:../../kibana/packages/kbn-eslint-import-resolver-kibana",
"@kbn/plugin-helpers": "link:../../kibana/packages/kbn-plugin-helpers",
"babel-eslint": "6.0.0",
"eslint": "^4.16.2",
"eslint-plugin-babel": "^4.1.1",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-jest": "^21.3.2",
"eslint-plugin-mocha": "1.1.0",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-react": "^7.0.1",
"expect.js": "^0.3.1"
},
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions public/agg_types/formula.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { capitalize, map } from 'lodash';
import { AggTypesMetricsMetricAggTypeProvider } from 'ui/agg_types/metrics/metric_agg_type';
import * as prov from 'ui/registry/field_formats';
import * as magprov from 'ui/agg_types/metrics/metric_agg_type';
import * as ffprov from 'ui/registry/field_formats';
import formulaEditor from './formula.html';
import formatterEditor from './formatter.html';

export function AggTypesMetricsFormulaProvider(Private) {
const MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider);
const fieldFormats = prov.fieldFormats || Private(prov.RegistryFieldFormatsProvider);
const MetricAggType = magprov.MetricAggType || Private(magprov.AggTypesMetricsMetricAggTypeProvider);
const fieldFormats = ffprov.fieldFormats || Private(ffprov.RegistryFieldFormatsProvider);
const defaultValue = null;
const formatters = map(['number', 'percent', 'boolean', 'bytes', 'numeral'], f => {
return { id: f, title: capitalize(f) };
Expand Down
4 changes: 2 additions & 2 deletions public/decorators/agg_types.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AggTypesIndexProvider } from 'ui/agg_types';
import * as prov from 'ui/agg_types';
import { AggTypesMetricsFormulaProvider } from 'plugins/datasweet_formula/agg_types/formula';

export function decorateAggTypes(Private) {
const AggTypes = Private(AggTypesIndexProvider);
const AggTypes = prov.aggTypes || Private(prov.AggTypesIndexProvider);
const AggFormula = Private(AggTypesMetricsFormulaProvider);
AggFormula.type = 'metrics';
AggTypes.push(AggFormula);
Expand Down
12 changes: 5 additions & 7 deletions public/decorators/lib/apply_column_groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import { find } from 'lodash';

/**
* Organizes columns in column groups.
* This is used when `vis.isHierarchical()` returns true,
* usually when calculating metrics for every bucket/level.
* This is used when 'Calculate metrics for every bucket/level' option is checked.
* @param {*} columns
* @param {*} isHierarchical
*/

export function applyColumnGroups(columns, isHierarchical) {
if (!isHierarchical) return;
* @param {boolean} metricsForAllBuckets
*/
export function applyColumnGroups(columns, metricsForAllBuckets) {
if (!metricsForAllBuckets) return;

// Do we have datasweet_formula ?
const isUsingFormula = find(columns, 'aggConfig.type.name', 'datasweet_formula') !== undefined;
Expand Down
4 changes: 2 additions & 2 deletions public/decorators/response_writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export function decorateTabbedAggResponseWriterProvider(Private) {
const responseFn = TabbedAggResponseWriter.prototype.response;
TabbedAggResponseWriter.prototype.response = function () {
const resp = responseFn.apply(this, arguments);
const isHierarchical = (!!this.vis ? this.vis.isHierarchical() : this.metricsForAllBuckets);
applyColumnGroups(this.columns, isHierarchical);
const metricsForAllBuckets = (!!this.vis ? this.vis.isHierarchical() : this.metricsForAllBuckets);
applyColumnGroups(this.columns, metricsForAllBuckets);
applyFormulas(this.columns, resp);
applyFormulaTotal(this.columns, resp);
applyHiddenCols(this.columns, resp);
Expand Down
68 changes: 34 additions & 34 deletions public/formula_hack.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,45 @@ const appId = chrome.getApp().id;
if (appId === 'kibana' || appId === 'dashboardViewer') {

uiModules
.get('datasweet/formula', ['kibana'])
.run((Private) => {
decorateVisAggConfigProvider(Private);
decorateVisAggConfigsProvider(Private);
decorateAggTypes(Private);
decorateTabbedAggResponseWriterProvider(Private);
});
.get('datasweet/formula', ['kibana'])
.run((Private) => {
decorateVisAggConfigProvider(Private);
decorateVisAggConfigsProvider(Private);
decorateAggTypes(Private);
decorateTabbedAggResponseWriterProvider(Private);
});

uiModules
.get('app/visualize')
.config(($provide) => {
$provide.decorator('visEditorAggDirective', ($delegate) => {
// Original
const linkFn = $delegate[0].link;
const tpl = $delegate[0].template;

// Inject template
$delegate[0].template = tpl
.replace(/<!-- title -->[\s\S]*?<\/span>/m, titleTpl)
.replace('<!-- disable aggregation -->', hiddenTpl);

// Inject new function in scope
$delegate[0].compile = function (tElem, tAttr) {
return function newLinkFn($scope, $el, attrs, kbnForm) {
linkFn.apply($delegate[0], arguments);

$scope.canHide = function (aggregation) {
const metricCount = reduce($scope.group, function (count, agg) {
return (agg.schema.name === aggregation.schema.name && !agg.hidden) ? ++count : count;
}, 0);
return metricCount > 1;
.get('app/visualize')
.config(($provide) => {
$provide.decorator('visEditorAggDirective', ($delegate) => {
// Original
const linkFn = $delegate[0].link;
const tpl = $delegate[0].template;

// Inject template
$delegate[0].template = tpl
.replace(/<!-- title -->[\s\S]*?<\/span>/m, titleTpl)
.replace('<!-- disable aggregation -->', hiddenTpl);

// Inject new function in scope
$delegate[0].compile = function () {
return function newLinkFn($scope) {
linkFn.apply($delegate[0], arguments);

$scope.canHide = function (aggregation) {
const metricCount = reduce($scope.group, function (count, agg) {
return (agg.schema.name === aggregation.schema.name && !agg.hidden) ? ++count : count;
}, 0);
return metricCount > 1;
};
};
};
};

// get rid of the old link function since we return a link function in compile
delete $delegate[0].link;
// get rid of the old link function since we return a link function in compile
delete $delegate[0].link;

return $delegate;
return $delegate;
});
});
});
}
Loading

0 comments on commit 78acc5d

Please sign in to comment.