From 09a290bbb887bbab8e7a5a008132e9086f7eacd7 Mon Sep 17 00:00:00 2001 From: Andrew Axelrod Date: Wed, 17 Jun 2020 17:16:53 -0500 Subject: [PATCH 1/3] Fixed Dashboard Issue --- public/hacks/custom_filter_bootstrap/index.js | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/public/hacks/custom_filter_bootstrap/index.js b/public/hacks/custom_filter_bootstrap/index.js index aa91fa0..7bf98b1 100644 --- a/public/hacks/custom_filter_bootstrap/index.js +++ b/public/hacks/custom_filter_bootstrap/index.js @@ -34,34 +34,32 @@ app.run(['$rootScope', ($rootScope) => { popover.destroy(); } - if (originalPath.indexOf('/discover/') !== -1) { - popover.init(); + if (originalPath.indexOf('/discover/') !== -1 || originalPath.indexOf('/dashboard/') !== -1) { + popover.init(); } }); }]); (async (indexPatterns, addFiltersCached) => { - const indexPatternList = await indexPatterns.getFields(['id', 'title']); - let selectedIndexPattern = null; + const indexPatternIDList = await indexPatterns.getFields(['id']); + let indexPatternLookup = {}; - const filterManagerHelper = new FilterManagerHelper(addFiltersCached); + for (let pattern of indexPatternIDList) { + let ip = await indexPatterns.get(pattern.id); + indexPatternLookup[pattern.id] = ip.fieldFormatMap; + } - await $('body').observe('.indexPattern__triggerButton', async () => { - const ipTitle = $('.indexPattern__triggerButton > span > span').text(); - const ip = indexPatternList.filter(ipItem => ipItem.title === ipTitle); - if (ip.length === 1) { - selectedIndexPattern = await indexPatterns.get(ip[0].id); - } - }); + const filterManagerHelper = new FilterManagerHelper(addFiltersCached); - filterManager.addFilters = newFilters => { + filterManager.addFilters = (newFilters, a, b, c) => { if (_.isArray(newFilters) && newFilters.length !== 1) { return; } - const { fieldFormatMap } = selectedIndexPattern; - const newFilter = newFilters[0]; + + const selectedIndexPatternID = _.get(newFilter, 'meta.index', null); + const fieldFormatMap = indexPatternLookup[selectedIndexPatternID]; const matchPhrase = _.get(newFilter, 'query.match_phrase', {}); const fieldNameKeys = Object.keys(matchPhrase); From b1a033ffe83c19afee7d6649e00e2c47cd3f5e3a Mon Sep 17 00:00:00 2001 From: Andrew Axelrod Date: Wed, 17 Jun 2020 17:51:17 -0500 Subject: [PATCH 2/3] Fixed Filtering for all pages --- public/field_formats/object/cleanFieldTemplate.js | 4 +--- public/hacks/custom_filter_bootstrap/index.js | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/public/field_formats/object/cleanFieldTemplate.js b/public/field_formats/object/cleanFieldTemplate.js index 29f0b01..fa8317e 100644 --- a/public/field_formats/object/cleanFieldTemplate.js +++ b/public/field_formats/object/cleanFieldTemplate.js @@ -62,8 +62,6 @@ const cleanTemplate = showPopover => { export default (showPopover = false) => { setTimeout(() => { - if ($('.application.tab-discover').length) { - cleanTemplate(showPopover); - } + cleanTemplate(showPopover); }, 0); }; diff --git a/public/hacks/custom_filter_bootstrap/index.js b/public/hacks/custom_filter_bootstrap/index.js index 7bf98b1..e5d9598 100644 --- a/public/hacks/custom_filter_bootstrap/index.js +++ b/public/hacks/custom_filter_bootstrap/index.js @@ -34,9 +34,7 @@ app.run(['$rootScope', ($rootScope) => { popover.destroy(); } - if (originalPath.indexOf('/discover/') !== -1 || originalPath.indexOf('/dashboard/') !== -1) { - popover.init(); - } + popover.init(); }); }]); @@ -51,7 +49,7 @@ app.run(['$rootScope', ($rootScope) => { const filterManagerHelper = new FilterManagerHelper(addFiltersCached); - filterManager.addFilters = (newFilters, a, b, c) => { + filterManager.addFilters = newFilters => { if (_.isArray(newFilters) && newFilters.length !== 1) { return; } From 75c27a0ab342382bb67783540151d98597968522 Mon Sep 17 00:00:00 2001 From: Andrew Carter Date: Wed, 17 Jun 2020 21:52:41 -0400 Subject: [PATCH 3/3] Version roll --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 70254a6..b94e490 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kibana_object_format", - "version": "0.1.7", + "version": "0.1.8", "description": "Enables objects in arrays to be configured with a field formatter.", "license": "Apache 2.0", "homepage": "https://github.com/istresearch/kibana-object-format", @@ -38,4 +38,4 @@ "eslint-plugin-prefer-object-spread": "^1.2.1", "eslint-plugin-react": "^7.12.4" } -} \ No newline at end of file +}