-
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.
Add a simple read-only table of rollup jobs and a details panel (#21900)
- Loading branch information
Showing
44 changed files
with
1,646 additions
and
1 deletion.
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
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 const CRUD_APP_BASE_PATH = '/management/elasticsearch/index_rollup_jobs/'; |
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
*/ | ||
|
||
export { PLUGIN } from './plugin'; | ||
export { CRUD_APP_BASE_PATH } from './crud_app'; |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { Switch, Route } from 'react-router-dom'; | ||
import { CRUD_APP_BASE_PATH } from '../../common/constants'; | ||
import { JobList } from './sections'; | ||
|
||
export const App = () => ( | ||
<div> | ||
<Switch> | ||
<Route path={CRUD_APP_BASE_PATH} component={JobList} /> | ||
</Switch> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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 { render, unmountComponentAtNode } from 'react-dom'; | ||
import { Provider } from 'react-redux'; | ||
import { HashRouter } from 'react-router-dom'; | ||
import { management } from 'ui/management'; | ||
import routes from 'ui/routes'; | ||
|
||
import { CRUD_APP_BASE_PATH } from '../../common/constants'; | ||
import { setHttpClient } from './services'; | ||
import { App } from './app'; | ||
import template from './main.html'; | ||
import { rollupJobsStore } from './store'; | ||
|
||
const esSection = management.getSection('elasticsearch'); | ||
|
||
esSection.register('rollup_jobs', { | ||
visible: true, | ||
display: 'Rollup Jobs', | ||
order: 2, | ||
url: `#${CRUD_APP_BASE_PATH}home` | ||
}); | ||
|
||
export const manageAngularLifecycle = ($scope, $route, elem) => { | ||
const lastRoute = $route.current; | ||
|
||
const deregister = $scope.$on('$locationChangeSuccess', () => { | ||
const currentRoute = $route.current; | ||
if (lastRoute.$$route.template === currentRoute.$$route.template) { | ||
$route.current = lastRoute; | ||
} | ||
}); | ||
|
||
$scope.$on('$destroy', () => { | ||
deregister && deregister(); | ||
elem && unmountComponentAtNode(elem); | ||
}); | ||
}; | ||
|
||
const renderReact = async (elem) => { | ||
render( | ||
<Provider store={rollupJobsStore()}> | ||
<HashRouter> | ||
<App /> | ||
</HashRouter> | ||
</Provider>, | ||
elem | ||
); | ||
}; | ||
|
||
routes.when(`${CRUD_APP_BASE_PATH}:view?`, { | ||
template: template, | ||
controllerAs: 'rollupJobs', | ||
controller: class IndexRollupJobsController { | ||
constructor($scope, $route, $http) { | ||
// NOTE: We depend upon Angular's $http service because it's decorated with interceptors, | ||
// e.g. to check license status per request. | ||
setHttpClient($http); | ||
|
||
$scope.$$postDigest(() => { | ||
const elem = document.getElementById('rollupJobsReactRoot'); | ||
renderReact(elem); | ||
manageAngularLifecycle($scope, $route, elem); | ||
}); | ||
} | ||
} | ||
}); |
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,3 @@ | ||
<kbn-management-app section="elasticsearch/rollup_jobs"> | ||
<div id="rollupJobsReactRoot"></div> | ||
</kbn-management-app> |
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 { JobList } from './job_list'; |
42 changes: 42 additions & 0 deletions
42
...k/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.container.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,42 @@ | ||
/* | ||
* 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 { connect } from 'react-redux'; | ||
import { DetailPanel as DetailPanelView } from './detail_panel'; | ||
|
||
import { | ||
getDetailPanelType, | ||
getDetailPanelJob, | ||
} from '../../../store/selectors'; | ||
|
||
import { | ||
closeDetailPanel, | ||
openDetailPanel, | ||
} from '../../../store/actions'; | ||
|
||
const mapStateToProps = (state) => { | ||
const job = getDetailPanelJob(state); | ||
return { | ||
panelType: getDetailPanelType(state), | ||
job, | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch) => { | ||
return { | ||
closeDetailPanel: () => { | ||
dispatch(closeDetailPanel()); | ||
}, | ||
openDetailPanel: ({ panelType, job }) => { | ||
dispatch(openDetailPanel({ panelType, job })); | ||
}, | ||
}; | ||
}; | ||
|
||
export const DetailPanel = connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(DetailPanelView); |
157 changes: 157 additions & 0 deletions
157
x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.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,157 @@ | ||
/* | ||
* 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, { Component } from 'react'; | ||
|
||
import { | ||
EuiFlyout, | ||
EuiFlyoutBody, | ||
EuiFlyoutHeader, | ||
EuiTitle, | ||
EuiTab, | ||
EuiTabs, | ||
EuiSpacer, | ||
} from '@elastic/eui'; | ||
|
||
import { | ||
TabSummary, | ||
TabTerms, | ||
TabMetrics, | ||
TabJson, | ||
TabHistogram, | ||
} from './tabs'; | ||
|
||
const tabs = ['Summary', 'Terms', 'Histogram', 'Metrics', 'JSON']; | ||
|
||
export class DetailPanel extends Component { | ||
static defaultProps = { | ||
job: {}, | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
renderTabs() { | ||
const { panelType, job, openDetailPanel } = this.props; | ||
|
||
return tabs.map((tab, index) => { | ||
if (tab === 'Terms' && !job.terms.fields.length) { | ||
return; | ||
} | ||
|
||
if (tab === 'Histogram' && !job.histogram.fields.length) { | ||
return; | ||
} | ||
|
||
if (tab === 'Metrics' && !job.metrics.length) { | ||
return; | ||
} | ||
|
||
const isSelected = tab === panelType; | ||
return ( | ||
<EuiTab | ||
onClick={() => openDetailPanel({ panelType: tab, job })} | ||
isSelected={isSelected} | ||
data-test-subj={`detailPanelTab${isSelected ? 'Selected' : ''}`} | ||
key={index} | ||
> | ||
{tab} | ||
</EuiTab> | ||
); | ||
}).filter(tab => tab); | ||
} | ||
|
||
render() { | ||
const { | ||
panelType, | ||
closeDetailPanel, | ||
job: { | ||
id, | ||
indexPattern, | ||
rollupIndex, | ||
rollupCron, | ||
rollupInterval, | ||
rollupDelay, | ||
dateHistogramTimeZone, | ||
dateHistogramField, | ||
metrics, | ||
terms, | ||
histogram, | ||
status, | ||
documentsProcessed, | ||
pagesProcessed, | ||
rollupsIndexed, | ||
triggerCount, | ||
json, | ||
}, | ||
} = this.props; | ||
|
||
if (!panelType) { | ||
return null; | ||
} | ||
|
||
const tabToContentMap = { | ||
Summary: ( | ||
<TabSummary | ||
id={id} | ||
indexPattern={indexPattern} | ||
rollupIndex={rollupIndex} | ||
rollupCron={rollupCron} | ||
rollupInterval={rollupInterval} | ||
rollupDelay={rollupDelay} | ||
dateHistogramTimeZone={dateHistogramTimeZone} | ||
dateHistogramField={dateHistogramField} | ||
documentsProcessed={documentsProcessed} | ||
pagesProcessed={pagesProcessed} | ||
rollupsIndexed={rollupsIndexed} | ||
triggerCount={triggerCount} | ||
status={status} | ||
/> | ||
), | ||
Terms: ( | ||
<TabTerms terms={terms} /> | ||
), | ||
Histogram: ( | ||
<TabHistogram histogram={histogram} /> | ||
), | ||
Metrics: ( | ||
<TabMetrics metrics={metrics} /> | ||
), | ||
JSON: ( | ||
<TabJson json={json} /> | ||
), | ||
}; | ||
|
||
const content = tabToContentMap[panelType]; | ||
|
||
return ( | ||
<EuiFlyout | ||
data-test-subj="indexDetailFlyout" | ||
onClose={closeDetailPanel} | ||
aria-labelledby="rollupJobDetailsFlyoutTitle" | ||
size="m" | ||
maxWidth="520px" | ||
> | ||
<EuiFlyoutHeader> | ||
<EuiTitle size="m" id="rollupJobDetailsFlyoutTitle"> | ||
<h2>{id}</h2> | ||
</EuiTitle> | ||
|
||
<EuiSpacer size="s" /> | ||
|
||
<EuiTabs> | ||
{this.renderTabs()} | ||
</EuiTabs> | ||
</EuiFlyoutHeader> | ||
|
||
<EuiFlyoutBody> | ||
{content} | ||
</EuiFlyoutBody> | ||
</EuiFlyout> | ||
); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/index.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,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 { DetailPanel } from './detail_panel.container'; |
11 changes: 11 additions & 0 deletions
11
x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/tabs/index.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,11 @@ | ||
/* | ||
* 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 { TabSummary } from './tab_summary'; | ||
export { TabTerms } from './tab_terms'; | ||
export { TabHistogram } from './tab_histogram'; | ||
export { TabMetrics } from './tab_metrics'; | ||
export { TabJson } from './tab_json'; |
Oops, something went wrong.