Skip to content

Commit

Permalink
Merge pull request #69 from istresearch/P4-2355
Browse files Browse the repository at this point in the history
P4 2355 - Kibana 7.11 Support
  • Loading branch information
andrewkcarter committed Mar 30, 2021
2 parents b3ec884 + 1d9c727 commit 8e2bc34
Show file tree
Hide file tree
Showing 79 changed files with 1,354 additions and 1,134 deletions.
Binary file added .DS_Store
Binary file not shown.
9 changes: 7 additions & 2 deletions .eslintrc.js
@@ -1,2 +1,7 @@
---
extends: "@elastic/kibana"
module.exports = {
root: true,
extends: ['@elastic/eslint-config-kibana', 'plugin:@elastic/eui/recommended'],
rules: {
'@kbn/eslint/require-license-header': 'off',
},
};
28 changes: 0 additions & 28 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

39 changes: 0 additions & 39 deletions .github/pull_request_template.md

This file was deleted.

9 changes: 4 additions & 5 deletions .gitignore
@@ -1,7 +1,6 @@
npm-debug.log*
node_modules
/build/
yarn.lock

/build
/target
/node_modules
.DS_Store
*.idea
.github
7 changes: 7 additions & 0 deletions .i18nrc.json
@@ -0,0 +1,7 @@
{
"prefix": "kibanaObjectFormat",
"paths": {
"kibanaObjectFormat": "."
},
"translations": ["translations/ja-JP.json"]
}
7 changes: 0 additions & 7 deletions LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion README.md 100644 → 100755
Expand Up @@ -293,4 +293,4 @@ For more information about any of these commands run `yarn ${task} --help`. For
plugins/kibana-object-format/public/hacks/object_filter_hack.js
REMOVE plugins/kibana-object-format/public/common/clean-template
plugins/kibana-object-format/public/field_formats/object/cleanFieldTemplate.js
plugins/kibana-object-format/package.json
plugins/kibana-object-format/package.json
2 changes: 2 additions & 0 deletions common/index.ts
@@ -0,0 +1,2 @@
export const PLUGIN_ID = 'kibanaObjectFormat';
export const PLUGIN_NAME = 'kibana_object_format';
Binary file removed images/array_format.jpg
Binary file not shown.
Binary file removed images/array_formatted.jpg
Binary file not shown.
Binary file removed images/array_native.jpg
Binary file not shown.
Binary file removed images/basic_format.jpg
Binary file not shown.
Binary file removed images/basic_formatted.jpg
Binary file not shown.
Binary file removed images/basic_native.jpg
Binary file not shown.
Binary file removed images/basic_raw.jpg
Binary file not shown.
Binary file removed images/demo.gif
Binary file not shown.
Binary file removed images/fields_list.jpg
Binary file not shown.
Binary file removed images/not_supported.jpg
Binary file not shown.
Binary file removed images/refresh.jpg
Binary file not shown.
34 changes: 0 additions & 34 deletions index.js

This file was deleted.

9 changes: 9 additions & 0 deletions kibana.json
@@ -0,0 +1,9 @@
{
"id": "kibanaObjectFormat",
"version": "1.0.0",
"kibanaVersion": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["data", "indexPatternManagement"],
"optionalPlugins": []
}
37 changes: 6 additions & 31 deletions package.json
@@ -1,41 +1,16 @@
{
"name": "kibana_object_format",
"version": "0.1.10",
"version": "1.0.0",
"description": "Enables objects in arrays to be configured with a field formatter.",
"license": "Apache 2.0",
"homepage": "https://github.com/istresearch/kibana-object-format",
"main": "index.js",
"kibana": {
"version": "kibana",
"templateVersion": "1.0.0"
},
"scripts": {
"preinstall": "node ../../preinstall_check",
"kbn": "node ../../scripts/kbn",
"es": "node ../../scripts/es",
"lint": "eslint .",
"start": "plugin-helpers start",
"test:server": "plugin-helpers test:server",
"test:browser": "plugin-helpers test:browser",
"build": "plugin-helpers build"
"build": "yarn plugin-helpers build",
"plugin-helpers": "node ../../scripts/plugin_helpers",
"kbn": "node ../../scripts/kbn"
},
"dependencies": {
"tippy.js": "~6.2.2"
},
"devDependencies": {
"@elastic/eslint-config-kibana": "link:../../packages/eslint-config-kibana",
"@elastic/eslint-import-resolver-kibana": "link:../../packages/kbn-eslint-import-resolver-kibana",
"@kbn/expect": "link:../../packages/kbn-expect",
"@kbn/plugin-helpers": "link:../../packages/kbn-plugin-helpers",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jest": "^22.4.1",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-mocha": "^5.3.0",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-react": "^7.12.4"
"tippy.js": "^6.3.1",
"uuid": "^8.3.2"
}
}
108 changes: 108 additions & 0 deletions public/bootstrap/custom_filter_manager/FilterManagerHelper.ts
@@ -0,0 +1,108 @@
import { get } from 'lodash';
import { Filter, CustomFilterManager, CustomFilterMeta } from '../../types';

class FilterManagerHelper {
private addFiltersCache: (filters: Filter | Filter[], pinFilterStatus?: boolean) => void;
private similarityScript: string = '';
private newFilter: Partial<Filter> = {};
private filterManager: CustomFilterManager;

constructor(addFiltersCache: any, filterManager: any) {
this.addFiltersCache = addFiltersCache;
this.similarityScript = '';
this.filterManager = filterManager;
}

private getFilterIndex({ path, value, negate }: Partial<CustomFilterMeta>) {
const currentFilters = this.getCurrentFilters();

return currentFilters.findIndex(
(filter) => filter.path === path && filter.value === value && filter.negate === negate
);
}

public getCurrentFilters(): Partial<CustomFilterMeta>[] {
return this.filterManager.getFilters().map((filter) => ({
path:
get(filter, 'query.bool.must.script.script.params.field', null) ||
get(filter, 'meta.key', null),
value:
get(filter, 'query.bool.must.script.script.params.dhash', null) ||
get(filter, 'meta.params.query', null),
negate: get(filter, 'meta.negate', null),
distance: get(filter, 'query.bool.must.script.script.params.distance', null),
}));
}

public addFilter({ path, value, negate, alias = null }: Partial<CustomFilterMeta>) {
const filterIndex = this.getFilterIndex({ path, value, negate });

if (filterIndex >= 0) {
return;
}

if (path) {
this.addFiltersCache.apply(this.filterManager, [
{
...this.newFilter,
meta: {
alias,
negate: !!this.newFilter?.meta?.negate,
index: this.newFilter?.meta?.index,
disabled: false,
},
query: {
match_phrase: {
[path]: value,
},
},
},
]);
}
}

public addImageSimilarityFilter({ path, value, distance = '8' }: CustomFilterMeta) {
this.removeFilter({ path, value, negate: true });
this.removeFilter({ path, value, negate: false });

this.addFiltersCache.apply(this.filterManager, [
{
...this.newFilter,
meta: {
alias: `Image Similarity: ${value} (${distance})`,
negate: !!this.newFilter?.meta?.negate,
index: this.newFilter?.meta?.index,
disabled: false,
},
query: {
bool: {
must: {
script: {
script: {
lang: 'painless',
params: {
dhash: value,
distance: parseInt(distance, 10),
field: path,
},
source: this.similarityScript,
},
},
},
},
},
},
]);
}

public removeFilter({ path, value, negate }: Partial<CustomFilterMeta>) {
const currentFilters = this.filterManager.getFilters();
const filterIndex = this.getFilterIndex({ path, value, negate });

if (filterIndex >= 0) {
this.filterManager.removeFilter(currentFilters[filterIndex]);
}
}
}

export default FilterManagerHelper;

0 comments on commit 8e2bc34

Please sign in to comment.