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 +} 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 aa91fa0..e5d9598 100644 --- a/public/hacks/custom_filter_bootstrap/index.js +++ b/public/hacks/custom_filter_bootstrap/index.js @@ -34,34 +34,30 @@ app.run(['$rootScope', ($rootScope) => { popover.destroy(); } - if (originalPath.indexOf('/discover/') !== -1) { - popover.init(); - } + 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 => { 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);