forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Experimental Service Map front end
Add service map tabs on the main APM screen and for individual services. This is not yet hooked up to work with back-end data, so it always shows the same hard-coded graph. This is experimental, so you must have x-pack.apm.serviceMapEnabled: true in your Kibana config for it to show up. Also add "PSF" to the list of allowed licenses since a new dependency added uses this license (it's on the [green list](https://github.com/elastic/open-source/blob/master/elastic-product-policy.md#green-list).) Fixes elastic#44890 Fixes elastic#44853
- Loading branch information
Showing
25 changed files
with
1,251 additions
and
427 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
108 changes: 108 additions & 0 deletions
108
x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Controls.tsx
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,108 @@ | ||
/* | ||
* 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, { useContext, useState, useEffect } from 'react'; | ||
import { EuiButtonIcon, EuiPanel } from '@elastic/eui'; | ||
import theme from '@elastic/eui/dist/eui_theme_light.json'; | ||
import styled from 'styled-components'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { CytoscapeContext } from './Cytoscape'; | ||
import { FullscreenPanel } from './FullscreenPanel'; | ||
|
||
const Container = styled('div')` | ||
left: ${theme.gutterTypes.gutterMedium}; | ||
position: absolute; | ||
top: ${theme.gutterTypes.gutterSmall}; | ||
`; | ||
|
||
const Button = styled(EuiButtonIcon)` | ||
display: block; | ||
margin: ${theme.paddingSizes.xs}; | ||
`; | ||
|
||
const ZoomInButton = styled(Button)` | ||
margin-bottom: ${theme.paddingSizes.s}; | ||
`; | ||
|
||
const ZoomPanel = styled(EuiPanel)` | ||
margin-bottom: ${theme.paddingSizes.s}; | ||
`; | ||
|
||
const duration = parseInt(theme.euiAnimSpeedFast, 10); | ||
const steps = 5; | ||
|
||
function doZoom(cy: cytoscape.Core | undefined, increment: number) { | ||
if (cy) { | ||
const level = cy.zoom() + increment; | ||
cy.animate({ | ||
duration, | ||
zoom: { level, position: cy.$('.primary').position() } | ||
}); | ||
} | ||
} | ||
|
||
export function Controls() { | ||
const cy = useContext(CytoscapeContext); | ||
|
||
const [zoom, setZoom] = useState((cy && cy.zoom()) || 1); | ||
|
||
useEffect(() => { | ||
if (cy) { | ||
cy.on('zoom', event => { | ||
setZoom(event.cy.zoom()); | ||
}); | ||
} | ||
}, [cy]); | ||
|
||
function zoomIn() { | ||
doZoom(cy, increment); | ||
} | ||
|
||
function zoomOut() { | ||
doZoom(cy, -increment); | ||
} | ||
|
||
if (!cy) { | ||
return null; | ||
} | ||
|
||
const maxZoom = cy.maxZoom(); | ||
const isMaxZoom = zoom === maxZoom; | ||
const minZoom = cy.minZoom(); | ||
const isMinZoom = zoom === minZoom; | ||
const increment = (maxZoom - minZoom) / steps; | ||
const mapDomElement = cy.container(); | ||
const zoomInLabel = i18n.translate('xpack.apm.serviceMap.zoomIn', { | ||
defaultMessage: 'Zoom in' | ||
}); | ||
const zoomOutLabel = i18n.translate('xpack.apm.serviceMap.zoomOut', { | ||
defaultMessage: 'Zoom out' | ||
}); | ||
|
||
return ( | ||
<Container> | ||
<ZoomPanel hasShadow={true} paddingSize="none"> | ||
<ZoomInButton | ||
aria-label={zoomInLabel} | ||
color="text" | ||
disabled={isMaxZoom} | ||
iconType="plusInCircleFilled" | ||
onClick={zoomIn} | ||
title={zoomInLabel} | ||
/> | ||
<Button | ||
aria-label={zoomOutLabel} | ||
color="text" | ||
disabled={isMinZoom} | ||
iconType="minusInCircleFilled" | ||
onClick={zoomOut} | ||
title={zoomOutLabel} | ||
/> | ||
</ZoomPanel> | ||
<FullscreenPanel element={mapDomElement} /> | ||
</Container> | ||
); | ||
} |
Oops, something went wrong.