film-exif/src/views/HomeView.js

71 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-04-03 14:13:16 -04:00
import {
2018-04-19 15:23:36 -04:00
Button,
Col,
2018-04-03 14:13:16 -04:00
Container,
Jumbotron,
Row,
2018-04-10 16:51:47 -04:00
} from '../components/Bootstrap';
2018-04-13 23:28:55 -04:00
import { JSONMessage } from '../helpers/web-socket';
2018-04-03 14:13:16 -04:00
2018-04-03 21:47:41 -04:00
function handleDrop (e) {
e.preventDefault();
e.stopPropagation();
2018-04-13 23:28:55 -04:00
const draggedFiles = [];
2018-04-03 21:47:41 -04:00
for (const f of e.dataTransfer.files) {
2018-04-13 23:28:55 -04:00
draggedFiles.push(f.path);
2018-04-03 21:47:41 -04:00
}
2018-04-13 23:28:55 -04:00
window.clientWS.send(JSONMessage('dropped-files', draggedFiles));
2018-04-03 21:47:41 -04:00
}
function handleDragOver (e) {
e.preventDefault();
e.stopPropagation();
}
2018-04-19 15:23:36 -04:00
function showOpenDialog () {
window.clientWS.send(JSONMessage('show-open-dialog', {}));
}
function showSaveDialog () {
window.clientWS.send(JSONMessage('show-save-dialog', {}));
}
function showErrorDialog () {
window.clientWS.send(JSONMessage(
'show-error-box',
'Looks like there was a problem. (╥﹏╥) \n (╯°□°)╯︵ ┻━┻'
));
}
2018-04-03 14:13:16 -04:00
export const HomeView = (props) => {
return (
2018-04-03 21:47:41 -04:00
<Jumbotron onDrop={handleDrop} onDragover={handleDragOver}>
2018-04-03 14:13:16 -04:00
<Container className="App">
<Row>
<header className="App-header">
2018-04-03 22:27:41 -04:00
<h1>Welcome to Film Exif</h1>
2018-04-03 14:13:16 -04:00
</header>
</Row>
<Row>
<p className="App-intro">
2018-04-03 22:27:41 -04:00
Drop files here.
2018-04-03 14:13:16 -04:00
</p>
</Row>
2018-04-19 15:23:36 -04:00
<Row>
<Col md={4}>
<Button onClick={showOpenDialog}>Show Open Dialog</Button>
</Col>
<Col md={4}>
<Button onClick={showSaveDialog}>Show Save Dialog</Button>
</Col>
<Col md={4}>
<Button onClick={showErrorDialog}>Show Error Dialog</Button>
</Col>
</Row>
2018-04-03 14:13:16 -04:00
</Container>
</Jumbotron>
2018-04-03 15:19:45 -04:00
);
};