-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Data Frames Summary Stats Bar #43986
Changes from all commits
327b3c9
8cdc209
c156928
0111711
8bd96d8
a9ea63a
401f93e
8f2a9a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import 'stat'; | ||
@import 'stats_bar'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.stat { | ||
margin-right: $euiSizeS; | ||
|
||
.stat-value { | ||
font-weight: bold | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.mlStatsBar { | ||
// SASSTODO: proper calcs | ||
height: 42px; | ||
padding: 14px; | ||
background-color: $euiColorLightestShade; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could also drop these styles by using |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* 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 { StatsBar, TransformStatsBarStats } from './stats_bar'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* 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, { FC } from 'react'; | ||
|
||
export interface StatsBarStat { | ||
label: string; | ||
value: string | number; | ||
show?: boolean; | ||
} | ||
interface StatProps { | ||
stat: StatsBarStat; | ||
} | ||
|
||
export const Stat: FC<StatProps> = ({ stat }) => { | ||
return ( | ||
<span className="stat"> | ||
<span>{stat.label}</span>: <span className="stat-value">{stat.value}</span> | ||
</span> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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, { FC } from 'react'; | ||
import { Stat, StatsBarStat } from './stat'; | ||
|
||
interface JobStatsBarStats { | ||
activeNodes: StatsBarStat; | ||
total: StatsBarStat; | ||
open: StatsBarStat; | ||
failed: StatsBarStat; | ||
closed: StatsBarStat; | ||
activeDatafeeds: StatsBarStat; | ||
} | ||
|
||
export interface TransformStatsBarStats { | ||
total: StatsBarStat; | ||
batch: StatsBarStat; | ||
continuous: StatsBarStat; | ||
failed: StatsBarStat; | ||
started: StatsBarStat; | ||
} | ||
|
||
type StatsBarStats = TransformStatsBarStats | JobStatsBarStats; | ||
type StatsKey = keyof StatsBarStats; | ||
|
||
interface StatsBarProps { | ||
stats: StatsBarStats; | ||
dataTestSub: string; | ||
} | ||
|
||
export const StatsBar: FC<StatsBarProps> = ({ stats, dataTestSub }) => { | ||
const statsList = Object.keys(stats).map(k => stats[k as StatsKey]); | ||
return ( | ||
<div className="mlStatsBar" data-test-subj={dataTestSub}> | ||
{statsList | ||
.filter((s: StatsBarStat) => s.show) | ||
.map((s: StatsBarStat) => ( | ||
<Stat key={s.label} stat={s} /> | ||
))} | ||
</div> | ||
); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* 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, { FC } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { StatsBar, TransformStatsBarStats } from '../../../../../components/stats_bar'; | ||
import { DATA_FRAME_TRANSFORM_STATE, DATA_FRAME_MODE, DataFrameTransformListRow } from './common'; | ||
|
||
function createTranformStats(transformsList: DataFrameTransformListRow[]) { | ||
const transformStats = { | ||
total: { | ||
label: i18n.translate('xpack.ml.dataFrame.statsBar.totalTransformsLabel', { | ||
defaultMessage: 'Total transforms', | ||
}), | ||
value: 0, | ||
show: true, | ||
}, | ||
batch: { | ||
label: i18n.translate('xpack.ml.dataFrame.statsBar.batchTransformsLabel', { | ||
defaultMessage: 'Batch transforms', | ||
}), | ||
value: 0, | ||
show: true, | ||
}, | ||
continuous: { | ||
label: i18n.translate('xpack.ml.dataFrame.statsBar.continuousTransformsLabel', { | ||
defaultMessage: 'Continuous transforms', | ||
}), | ||
value: 0, | ||
show: true, | ||
}, | ||
failed: { | ||
label: i18n.translate('xpack.ml.dataFrame.statsBar.failedTransformsLabel', { | ||
defaultMessage: 'Failed transforms', | ||
}), | ||
value: 0, | ||
show: false, | ||
}, | ||
started: { | ||
label: i18n.translate('xpack.ml.dataFrame.statsBar.startedTransformsLabel', { | ||
defaultMessage: 'Started transforms', | ||
}), | ||
value: 0, | ||
show: true, | ||
}, | ||
}; | ||
|
||
if (transformsList === undefined) { | ||
return transformStats; | ||
} | ||
|
||
let failedTransforms = 0; | ||
let startedTransforms = 0; | ||
|
||
transformsList.forEach(transform => { | ||
if (transform.mode === DATA_FRAME_MODE.CONTINUOUS) { | ||
transformStats.continuous.value++; | ||
} else if (transform.mode === DATA_FRAME_MODE.BATCH) { | ||
transformStats.batch.value++; | ||
} else if (transform.stats.state === DATA_FRAME_TRANSFORM_STATE.FAILED) { | ||
failedTransforms++; | ||
} else if (transform.stats.state === DATA_FRAME_TRANSFORM_STATE.STARTED) { | ||
startedTransforms++; | ||
} | ||
}); | ||
|
||
transformStats.total.value = transformsList.length; | ||
transformStats.started.value = startedTransforms; | ||
|
||
if (failedTransforms !== 0) { | ||
transformStats.failed.value = failedTransforms; | ||
transformStats.failed.show = true; | ||
} else { | ||
transformStats.failed.show = false; | ||
} | ||
|
||
return transformStats; | ||
} | ||
|
||
interface Props { | ||
transformsList: DataFrameTransformListRow[]; | ||
} | ||
|
||
export const TransformStatsBar: FC<Props> = ({ transformsList }) => { | ||
const transformStats: TransformStatsBarStats = createTranformStats(transformsList); | ||
|
||
return <StatsBar stats={transformStats} dataTestSub={'mlTransformStatsBar'} />; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to make the class names prefixed with
ml
and not nested.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good - this will likely be fixed by the follow up to switch to using the Eui Stat component.