-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Monitoring] Cluster alerts table to EUI (#26031)
* Convert cluster alerts page to use EUI tables. Also adds baseline support for all monitoring tables * Fix tests * Remove these two files * Keep the original table but offer a new one so existing UIs still work * Use different base table controller for the EUI table * Use EUI specific asc and desc constants
- Loading branch information
1 parent
453e1f1
commit 5253ecb
Showing
16 changed files
with
328 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
x-pack/plugins/monitoring/public/components/alerts/alerts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* 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 { capitalize } from 'lodash'; | ||
import { formatDateTimeLocal } from '../../../common/formatting'; | ||
import { formatTimestampToDuration } from '../../../common'; | ||
import { CALCULATE_DURATION_SINCE, EUI_SORT_DESCENDING } from '../../../common/constants'; | ||
import { mapSeverity } from './map_severity'; | ||
import { Tooltip } from 'plugins/monitoring/components/tooltip'; | ||
import { FormattedAlert } from 'plugins/monitoring/components/alerts/formatted_alert'; | ||
import { EuiMonitoringTable } from 'plugins/monitoring/components/table'; | ||
import { EuiHealth, EuiIcon } from '@elastic/eui'; | ||
|
||
const linkToCategories = { | ||
'elasticsearch/nodes': 'Elasticsearch Nodes', | ||
'elasticsearch/indices': 'Elasticsearch Indices', | ||
'kibana/instances': 'Kibana Instances', | ||
'logstash/instances': 'Logstash Nodes', | ||
}; | ||
const getColumns = (kbnUrl, scope) => ([ | ||
{ | ||
name: 'Status', | ||
field: 'metadata.severity', | ||
sortable: true, | ||
render: severity => { | ||
const severityIcon = mapSeverity(severity); | ||
|
||
return ( | ||
<Tooltip text={severityIcon.title} placement="bottom" trigger="hover"> | ||
<EuiHealth color={severityIcon.color} data-test-subj="alertIcon" aria-label={severityIcon.title}> | ||
{ capitalize(severityIcon.value) } | ||
</EuiHealth> | ||
</Tooltip> | ||
); | ||
} | ||
}, | ||
{ | ||
name: 'Resolved', | ||
field: 'resolved_timestamp', | ||
sortable: true, | ||
render: (resolvedTimestamp) => { | ||
const resolution = { | ||
icon: null, | ||
text: 'Not Resolved' | ||
}; | ||
|
||
if (resolvedTimestamp) { | ||
resolution.text = `${formatTimestampToDuration(resolvedTimestamp, CALCULATE_DURATION_SINCE)} ago`; | ||
} else { | ||
resolution.icon = <EuiIcon type="alert" size="m" aria-label="Not Resolved" />; | ||
} | ||
|
||
return ( | ||
<span> | ||
{ resolution.icon } { resolution.text } | ||
</span> | ||
); | ||
}, | ||
}, | ||
{ | ||
name: 'Message', | ||
field: 'message', | ||
sortable: true, | ||
render: (message, alert) => ( | ||
<FormattedAlert | ||
prefix={alert.prefix} | ||
suffix={alert.suffix} | ||
message={message} | ||
metadata={alert.metadata} | ||
changeUrl={target => { | ||
scope.$evalAsync(() => { | ||
kbnUrl.changePath(target); | ||
}); | ||
}} | ||
/> | ||
) | ||
}, | ||
{ | ||
name: 'Category', | ||
field: 'metadata.link', | ||
sortable: true, | ||
render: link => linkToCategories[link] ? linkToCategories[link] : 'General' | ||
}, | ||
{ | ||
name: 'Last Checked', | ||
field: 'update_timestamp', | ||
sortable: true, | ||
render: timestamp => formatDateTimeLocal(timestamp) | ||
}, | ||
{ | ||
name: 'Triggered', | ||
field: 'timestamp', | ||
sortable: true, | ||
render: timestamp => formatTimestampToDuration(timestamp, CALCULATE_DURATION_SINCE) + ' ago' | ||
}, | ||
]); | ||
|
||
export const Alerts = ({ alerts, angular, sorting, pagination, onTableChange }) => { | ||
return ( | ||
<EuiMonitoringTable | ||
className="alertsTable" | ||
rows={alerts} | ||
columns={getColumns(angular.kbnUrl, angular.scope)} | ||
sorting={{ | ||
...sorting, | ||
sort: { | ||
...sorting.sort, | ||
field: 'metadata.severity', | ||
direction: EUI_SORT_DESCENDING, | ||
} | ||
}} | ||
pagination={pagination} | ||
search={{ | ||
box: { | ||
incremental: true, | ||
placeholder: 'Filter Alerts...' | ||
}, | ||
}} | ||
onTableChange={onTableChange} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { Alerts } from './alerts'; |
43 changes: 43 additions & 0 deletions
43
x-pack/plugins/monitoring/public/components/table/eui_table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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 { | ||
EuiInMemoryTable | ||
} from '@elastic/eui'; | ||
|
||
export class EuiMonitoringTable extends React.PureComponent { | ||
render() { | ||
const { | ||
rows: items, | ||
search = {}, | ||
columns: _columns, | ||
...props | ||
} = this.props; | ||
|
||
if (search.box && !search.box['data-test-subj']) { | ||
search.box['data-test-subj'] = 'monitoringTableToolBar'; | ||
} | ||
|
||
const columns = _columns.map(column => { | ||
if (!column['data-test-subj']) { | ||
column['data-test-subj'] = 'monitoringTableHasData'; | ||
} | ||
return column; | ||
}); | ||
|
||
return ( | ||
<div data-test-subj={`${this.props.className}Container`}> | ||
<EuiInMemoryTable | ||
items={items} | ||
search={search} | ||
columns={columns} | ||
{...props} | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 0 additions & 173 deletions
173
x-pack/plugins/monitoring/public/directives/alerts/index.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.