From 4b17c442d49130142ef99686f27428c7f45586c9 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 25 Oct 2018 13:00:04 +0200 Subject: [PATCH 1/4] [Ml] Fixing results for known fields --- .../ml/common/constants/field_types.js | 5 +- .../field_data_card/styles/main.less | 2 +- .../field_type_icon/field_type_icon.js | 4 + .../components/_index.scss | 1 + .../components/about_panel/about_panel.js | 2 +- .../components/about_panel/welcome_content.js | 7 +- .../_experimental_badge.scss | 7 ++ .../components/experimental_badge/_index.scss | 1 + .../experimental_badge/experimental_badge.js | 19 ++++ .../components/experimental_badge/index.js | 8 ++ .../fields_stats/field_stats_card.js | 101 ++++++++++-------- .../components/fields_stats/fields_stats.js | 31 +++--- .../fields_stats/get_field_names.js | 37 +++++++ .../components/import_view/import_view.js | 6 +- 14 files changed, 165 insertions(+), 66 deletions(-) create mode 100644 x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/_experimental_badge.scss create mode 100644 x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/_index.scss create mode 100644 x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/experimental_badge.js create mode 100644 x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/index.js create mode 100644 x-pack/plugins/ml/public/file_datavisualizer/components/fields_stats/get_field_names.js diff --git a/x-pack/plugins/ml/common/constants/field_types.js b/x-pack/plugins/ml/common/constants/field_types.js index 3dd265c5c76ec..a3a474ab05415 100644 --- a/x-pack/plugins/ml/common/constants/field_types.js +++ b/x-pack/plugins/ml/common/constants/field_types.js @@ -27,7 +27,7 @@ export const ES_FIELD_TYPES = { TOKEN_COUNT: 'token_count', _ID: '_id', _SOURCE: '_source', - _TYPE: '_type' + _TYPE: '_type', }; export const KBN_FIELD_TYPES = { @@ -52,6 +52,7 @@ export const ML_JOB_FIELD_TYPES = { IP: 'ip', KEYWORD: 'keyword', NUMBER: 'number', - TEXT: 'text' + TEXT: 'text', + UNKNOWN_TYPE: 'unknown-type', }; diff --git a/x-pack/plugins/ml/public/components/field_data_card/styles/main.less b/x-pack/plugins/ml/public/components/field_data_card/styles/main.less index 740e82b3d976e..f918f7066a313 100644 --- a/x-pack/plugins/ml/public/components/field_data_card/styles/main.less +++ b/x-pack/plugins/ml/public/components/field_data_card/styles/main.less @@ -34,7 +34,7 @@ background-color: #920000; } - .type-other { + .type-other, .unknown-type { background-color: #bfa180; } diff --git a/x-pack/plugins/ml/public/components/field_type_icon/field_type_icon.js b/x-pack/plugins/ml/public/components/field_type_icon/field_type_icon.js index cf23fa1468f7d..8603b5aca4b2a 100644 --- a/x-pack/plugins/ml/public/components/field_type_icon/field_type_icon.js +++ b/x-pack/plugins/ml/public/components/field_type_icon/field_type_icon.js @@ -47,6 +47,10 @@ export function FieldTypeIcon({ tooltipEnabled = false, type }) { ariaLabel = 'IP type'; iconClass = 'fa-laptop'; break; + case ML_JOB_FIELD_TYPES.UNKNOWN_TYPE: + ariaLabel = 'Unknown type'; + iconChar = '?'; + break; default: // if type doesn't match one of ML_JOB_FIELD_TYPES // don't render the component at all diff --git a/x-pack/plugins/ml/public/file_datavisualizer/components/_index.scss b/x-pack/plugins/ml/public/file_datavisualizer/components/_index.scss index c1a39da59fdb3..42974d098bda4 100644 --- a/x-pack/plugins/ml/public/file_datavisualizer/components/_index.scss +++ b/x-pack/plugins/ml/public/file_datavisualizer/components/_index.scss @@ -4,3 +4,4 @@ @import 'fields_stats/index'; @import 'about_panel/index'; @import 'import_summary/index'; +@import 'experimental_badge/index'; diff --git a/x-pack/plugins/ml/public/file_datavisualizer/components/about_panel/about_panel.js b/x-pack/plugins/ml/public/file_datavisualizer/components/about_panel/about_panel.js index 18df2ea7a54ae..261584bb1534b 100644 --- a/x-pack/plugins/ml/public/file_datavisualizer/components/about_panel/about_panel.js +++ b/x-pack/plugins/ml/public/file_datavisualizer/components/about_panel/about_panel.js @@ -52,7 +52,7 @@ export function AboutPanel({ onFilePickerChange }) { export function LoadingPanel() { return ( - + diff --git a/x-pack/plugins/ml/public/file_datavisualizer/components/about_panel/welcome_content.js b/x-pack/plugins/ml/public/file_datavisualizer/components/about_panel/welcome_content.js index 323db3b35fbcc..78f89f951f28f 100644 --- a/x-pack/plugins/ml/public/file_datavisualizer/components/about_panel/welcome_content.js +++ b/x-pack/plugins/ml/public/file_datavisualizer/components/about_panel/welcome_content.js @@ -8,7 +8,6 @@ import React from 'react'; import { - EuiBetaBadge, EuiFlexGroup, EuiFlexItem, EuiIcon, @@ -18,6 +17,8 @@ import { EuiTitle, } from '@elastic/eui'; +import { ExperimentalBadge } from '../experimental_badge'; + export function WelcomeContent() { return ( @@ -29,7 +30,9 @@ export function WelcomeContent() {

Visualize data from a log file   - +

diff --git a/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/_experimental_badge.scss b/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/_experimental_badge.scss new file mode 100644 index 0000000000000..4c90d6beed51a --- /dev/null +++ b/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/_experimental_badge.scss @@ -0,0 +1,7 @@ +.ml-experimental-badge.euiBetaBadge { + font-size: 10px; + vertical-align: middle; + margin-bottom: 5px; + padding: 0px 20px; + line-height: 20px; +} diff --git a/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/_index.scss b/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/_index.scss new file mode 100644 index 0000000000000..9e25affd5e5f6 --- /dev/null +++ b/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/_index.scss @@ -0,0 +1 @@ +@import 'experimental_badge' diff --git a/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/experimental_badge.js b/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/experimental_badge.js new file mode 100644 index 0000000000000..1d45ccd8881fc --- /dev/null +++ b/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/experimental_badge.js @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; + +import { + EuiBetaBadge, +} from '@elastic/eui'; + +export function ExperimentalBadge({ tooltipContent }) { + return ( + + + + ); +} diff --git a/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/index.js b/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/index.js new file mode 100644 index 0000000000000..df986c3a2e61c --- /dev/null +++ b/x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/index.js @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + +export { ExperimentalBadge } from './experimental_badge'; diff --git a/x-pack/plugins/ml/public/file_datavisualizer/components/fields_stats/field_stats_card.js b/x-pack/plugins/ml/public/file_datavisualizer/components/fields_stats/field_stats_card.js index 9c7300363dc47..3986685d09c3e 100644 --- a/x-pack/plugins/ml/public/file_datavisualizer/components/fields_stats/field_stats_card.js +++ b/x-pack/plugins/ml/public/file_datavisualizer/components/fields_stats/field_stats_card.js @@ -9,7 +9,6 @@ import React from 'react'; import { EuiSpacer, - } from '@elastic/eui'; import { FieldTypeIcon } from '../../../components/field_type_icon'; @@ -35,59 +34,69 @@ export function FieldStatsCard({ field }) {
-
-
-