From 98d15e9dece007f42f7307f3c4a9b00ae7667588 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 7 Sep 2017 18:35:15 +0900 Subject: [PATCH] Add WIP connection screen Does the basics but still needs to implement: - Autoconnect - "Connecting..." UI - Disconnect by request - Disconnect by circumstance --- scss/main.scss | 18 +++++++++++++- src/actions/socket.js | 5 ++++ src/index.js | 34 ++++++++++++++------------ src/reducers/index.js | 2 ++ src/reducers/socket.js | 12 +++++++++ src/socket.js | 4 +-- src/ui/connection.js | 55 ++++++++++++++++++++++++++++++++++++++++-- src/ui/main.js | 7 +++++- 8 files changed, 116 insertions(+), 21 deletions(-) create mode 100644 src/actions/socket.js create mode 100644 src/reducers/socket.js diff --git a/scss/main.scss b/scss/main.scss index 22f7f7f..f09a01c 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -49,6 +49,22 @@ background-position: left bottom; } +.connection-overlay { + position: fixed; + display: flex; + justify-content: center; + align-items: center; + left: 0; + right: 0; + top: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.5); + + .card { + min-width: 20rem; + } +} + input[type="text"], input[type="number"] { padding: 0.05rem 0.25rem; border-radius: 0; @@ -127,7 +143,7 @@ select.form-control { font-size: 0.9rem; } -.form-check-input:only-child { +fieldset .form-check-input:only-child { position: absolute; } diff --git a/src/actions/socket.js b/src/actions/socket.js new file mode 100644 index 0000000..172e772 --- /dev/null +++ b/src/actions/socket.js @@ -0,0 +1,5 @@ +export const SOCKET_CONNECTED = "SOCKET_CONNECTED"; +export const SOCKET_DISCONNECTED = "SOCKET_DISCONNECTED"; + +export const socket_connected = () => ({ type: SOCKET_CONNECTED }); +export const socket_disconnected = () => ({ type: SOCKET_DISCONNECTED }); diff --git a/src/index.js b/src/index.js index 9e349e8..ac17c8f 100644 --- a/src/index.js +++ b/src/index.js @@ -10,29 +10,33 @@ import store, { history } from './store'; import scss from '../scss/main.scss'; import { ws_init } from './socket'; import { filter_subscribe } from './actions/filter_subscribe'; +import { socket_connected, socket_disconnected } from './actions/socket'; import Nav from './ui/navigation'; import Main from './ui/main'; import Connection from './ui/connection'; const root = document.getElementById('root'); -ReactDOM.render(, root); -ws_init(() => { - store.dispatch(filter_subscribe()); - store.dispatch(filter_subscribe('server')); - ReactDOM.render( - - -
-
); } } + +export default connect(state => ({ socket: state.socket }))(Main);