forked from jaegertracing/jaeger-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from digma-ai/feature/zoom
Add zoom controls to the Trace Details Page
- Loading branch information
Showing
8 changed files
with
113 additions
and
15 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
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,4 @@ | ||
import { createContext } from 'react'; | ||
import ZoomManager from './utils/ZoomManager'; | ||
|
||
export const ZoomContext = createContext<null | ZoomManager>(null); |
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
33 changes: 33 additions & 0 deletions
33
packages/jaeger-ui/src/components/TracePage/TracePageHeader/ZoomControls.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,33 @@ | ||
import { Button } from 'antd'; | ||
import React, { useContext } from 'react'; | ||
import ButtonGroup from 'antd/lib/button/button-group'; | ||
import { ZoomContext } from '../../../Contexts'; | ||
|
||
type ZoomControlsProps = { | ||
className?: string; | ||
}; | ||
|
||
const ZoomControls = (props: ZoomControlsProps) => { | ||
const zoomManager = useContext(ZoomContext); | ||
|
||
return ( | ||
<ButtonGroup className={props.className}> | ||
<Button | ||
onClick={() => { | ||
zoomManager?.zoomOut(); | ||
}} | ||
htmlType="button" | ||
icon="zoom-out" | ||
/> | ||
<Button | ||
onClick={() => { | ||
zoomManager?.zoomIn(); | ||
}} | ||
htmlType="button" | ||
icon="zoom-in" | ||
/> | ||
</ButtonGroup> | ||
); | ||
}; | ||
|
||
export default ZoomControls; |
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,25 @@ | ||
const MIN_ZOOM_LEVEL = 0.7; | ||
const MAX_ZOOM_LEVEL = 1.5; | ||
const ZOOM_FACTOR = 0.1; | ||
|
||
export default class ZoomManager { | ||
zoomLevel: number; | ||
|
||
constructor() { | ||
this.zoomLevel = document.body.style.zoom || 1; | ||
} | ||
|
||
updateStyles = () => { | ||
document.body.style.zoom = this.zoomLevel; | ||
}; | ||
|
||
zoomIn = () => { | ||
this.zoomLevel = Math.min(this.zoomLevel + ZOOM_FACTOR, MAX_ZOOM_LEVEL); | ||
this.updateStyles(); | ||
}; | ||
|
||
zoomOut = () => { | ||
this.zoomLevel = Math.max(this.zoomLevel - ZOOM_FACTOR, MIN_ZOOM_LEVEL); | ||
this.updateStyles(); | ||
}; | ||
} |
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