film-exif/src/views/HomeView.js

77 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-04-03 14:13:16 -04:00
import {
2018-05-01 09:53:09 -04:00
Alert,
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-05-01 09:53:09 -04:00
<main>
<Alert color="info">
This is a work in progress
</Alert>
<Jumbotron onDrop={handleDrop} onDragover={handleDragOver}>
<Container className="App">
<Row>
<header className="App-header">
<h1>Welcome to Film Exif</h1>
</header>
</Row>
<Row>
<p className="App-intro">
Drop files here.
</p>
</Row>
<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>
</Container>
</Jumbotron>
</main>
2018-04-03 15:19:45 -04:00
);
};