Skip to content

Commit

Permalink
[ML] Fetch the latest job messages and enable sorting by time (#52388)
Browse files Browse the repository at this point in the history
* [ML] add sorting support

* [ML] change fetch sort to desc for anomaly detection jobs

* [ML] rename param
  • Loading branch information
darnautov authored Dec 6, 2019
1 parent 2a83266 commit 80eef1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React, { FC } from 'react';

import { EuiSpacer, EuiBasicTable } from '@elastic/eui';
import { EuiSpacer, EuiInMemoryTable } from '@elastic/eui';
// @ts-ignore
import { formatDate } from '@elastic/eui/lib/services/format';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -35,11 +35,13 @@ export const JobMessages: FC<JobMessagesProps> = ({ messages, loading, error })
width: `${theme.euiSizeL}`,
},
{
field: 'timestamp',
name: i18n.translate('xpack.ml.jobMessages.timeLabel', {
defaultMessage: 'Time',
}),
render: (message: any) => formatDate(message.timestamp, TIME_FORMAT),
render: (timestamp: number) => formatDate(timestamp, TIME_FORMAT),
width: '120px',
sortable: true,
},
{
field: 'node_name',
Expand All @@ -57,13 +59,22 @@ export const JobMessages: FC<JobMessagesProps> = ({ messages, loading, error })
},
];

const defaultSorting = {
sort: {
field: 'timestamp',
direction: 'asc',
},
};

return (
<>
<EuiSpacer size="s" />
<EuiBasicTable
<EuiInMemoryTable
className="job-messages-table"
items={messages}
columns={columns}
sorting={defaultSorting}
// @ts-ignore
compressed={true}
loading={loading}
error={error}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function jobAuditMessagesProvider(callWithRequest) {
body:
{
sort: [
{ timestamp: { order: 'asc' } },
{ timestamp: { order: 'desc' } },
{ job_id: { order: 'asc' } }
],
query
Expand Down

0 comments on commit 80eef1e

Please sign in to comment.