-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: adds configurable 'video feed' widgets
Adds support for 'video feed' widgets. Each widget provide access to a video feed from 'Data collection' tab. This is typically used for giving users an easy way to access hutch view cameras. Adds new 'camera_setup' config to mxcube-web/ui.yaml. This element allows to configure multiple video feeds to be made accessable from 'Data collection' tab. Each configured video feed creates a button with a camera icon. Clicking the button will show/hide the video feed. It also allows to create a pop-out windows with the video feed.
- Loading branch information
Showing
6 changed files
with
184 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
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,128 @@ | ||
import React, { useState } from 'react'; | ||
import { Badge, Button, OverlayTrigger, Popover } from 'react-bootstrap'; | ||
import './style.css'; | ||
import pip from './picture_in_picture.svg'; | ||
|
||
const BeamlineCamera = ({ | ||
labelText, | ||
url, | ||
width, | ||
height, | ||
optionsOverlay, | ||
format, | ||
description, | ||
}) => { | ||
const [showLabelOverlay, setShowLabelOverlay] = useState(false); | ||
const [showValueOverlay, setShowValueOverlay] = useState(false); | ||
|
||
const onImageClick = (ev) => { | ||
setShowValueOverlay(false); | ||
window.open( | ||
url, | ||
'webcam', | ||
`toolbar=0,location=0,menubar=0,addressbar=0,height=${height},width=${width}`, | ||
'popup', | ||
); | ||
}; | ||
|
||
const renderLabel = () => { | ||
if (!optionsOverlay) { | ||
return ( | ||
<Badge bg="secondary" style={{ display: 'block', marginBottom: '3px' }}> | ||
{labelText} | ||
</Badge> | ||
); | ||
} | ||
|
||
return ( | ||
<OverlayTrigger | ||
show={showLabelOverlay} | ||
rootClose | ||
trigger="click" | ||
placement="bottom" | ||
overlay={optionsOverlay} | ||
> | ||
<div onClick={() => setShowLabelOverlay(!showLabelOverlay)}> | ||
<Badge | ||
bg="secondary" | ||
style={{ display: 'block', marginBottom: '3px' }} | ||
> | ||
{labelText} | ||
<i className="fas fa-cog ms-2" /> | ||
</Badge> | ||
</div> | ||
</OverlayTrigger> | ||
); | ||
}; | ||
|
||
const msgLabelStyle = { | ||
display: 'block', | ||
fontSize: '100%', | ||
borderRadius: '0px', | ||
color: '#000', | ||
}; | ||
|
||
const video = ( | ||
<div> | ||
{format != 'mp4' ? ( | ||
<img | ||
onClick={onImageClick} | ||
src={url} | ||
alt={labelText} | ||
width={width} | ||
height={height} | ||
/> | ||
) : ( | ||
<video | ||
src={url} | ||
alt={labelText} | ||
onClick={onImageClick} | ||
width={width} | ||
height={height} | ||
></video> | ||
)} | ||
<Button | ||
variant="outline-secondary" | ||
onClick={onImageClick} | ||
size="sm" | ||
style={{ position: 'absolute', left: '90%', bottom: '10px' }} | ||
> | ||
<img src={pip} alt="PIP Icon" /> | ||
</Button> | ||
</div> | ||
); | ||
|
||
return ( | ||
<div className="inout-switch"> | ||
{renderLabel()} | ||
<OverlayTrigger | ||
show={showValueOverlay} | ||
rootClose | ||
trigger="click" | ||
placement="bottom" | ||
overlay={ | ||
<Popover style={{ padding: '0.5em' }} id={`${labelText} popover`}> | ||
{video} | ||
</Popover> | ||
} | ||
> | ||
<div onClick={() => setShowValueOverlay(!showValueOverlay)}> | ||
<Badge bg="success" style={msgLabelStyle}> | ||
<i className="fas fa-video" /> | ||
</Badge> | ||
</div> | ||
</OverlayTrigger> | ||
</div> | ||
); | ||
}; | ||
|
||
BeamlineCamera.defaultProps = { | ||
labelText: '', | ||
width: 0, | ||
height: 0, | ||
url: '', | ||
optionsOverlay: false, | ||
format: '', | ||
}; | ||
|
||
export default BeamlineCamera; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
.inout-switch { | ||
width: 7em; | ||
} | ||
|
||
.inout-switch .badge { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} |
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