Skip to content

Commit

Permalink
Fixed double button in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
shimberger committed Jan 23, 2019
1 parent f6bf3dd commit 8af34fc
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions ui/src/Components/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,19 @@ class Player extends React.Component<any, any> {
this.setState({ anchorEl: event.currentTarget });
};

handleDownload = () => {
handleReset = () => {
this.setState({ anchorEl: null });
};

handleClip = () => {
this.setState({ openDialog: true, anchorEl: null });
};

handleDownload = () => {
var win = window.open(this.downloadsPath(), '_blank');
this.setState({ anchorEl: null });
};

handleClose = () => {
this.setState({ openDialog: false });
};
Expand All @@ -120,14 +125,19 @@ class Player extends React.Component<any, any> {
});
};

downloadsPath() {
const path = this.props.match.params[0];
return "/api/download/" + path
}

public render() {
const { classes } = this.props;
const path = this.props.match.params[0];
const name = path.substring(path.lastIndexOf("/") + 1);
const parent = path.substring(0, path.lastIndexOf("/"));
const { anchorEl, openDialog, start, duration } = this.state;
const open = Boolean(anchorEl);
const downloadsPath = "/api/download/" + path
const downloadsPath = this.downloadsPath()
const clipPath = downloadsPath + "?start=" + start + "&duration=" + duration

const clipDialog =
Expand All @@ -140,14 +150,16 @@ class Player extends React.Component<any, any> {
<DialogTitle id="alert-dialog-title">{"Download video clip"}</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
Enter the starting position and duration of the clip in seconds:
Enter the starting position and duration of the clip in seconds.
<br /><br />
</DialogContentText>
<TextField
label="Start at"
value={start}
autoFocus={true}
onChange={this.handleChange('start')}
/>
&nbsp;&nbsp;
<TextField
label="Duration"
value={duration}
Expand Down Expand Up @@ -182,15 +194,13 @@ class Player extends React.Component<any, any> {
id="download-menu"
anchorEl={anchorEl}
open={open}
onClose={this.handleDownload}
onClose={this.handleReset}
>
<MenuItem onClick={this.handleDownload}>
<Button target="_blank" href={downloadsPath}>
Download video
</Button>
Download Video
</MenuItem>
<MenuItem onClick={this.handleClip}>
<Button>Download clip</Button>
Download Clip
</MenuItem>
</Menu>
</div>
Expand Down

0 comments on commit 8af34fc

Please sign in to comment.