-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5a8e48
commit 9c3fc26
Showing
21 changed files
with
31,001 additions
and
80 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/node_modules | ||
/node_modules | ||
/.vscode | ||
/dist |
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
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,55 @@ | ||
import { dispatch as d3_dispatch } from 'd3-dispatch'; | ||
import Store from '../store'; | ||
|
||
let store = Store.getInstance(); | ||
|
||
const singleton = Symbol(); | ||
const singletonEnforcer = Symbol(); | ||
|
||
|
||
const _updateLogin = (context) => { | ||
context.dispatch('login'); | ||
let loginUpdater = (login) => { | ||
return (state) => { | ||
state = Object.assign({}, state); | ||
state.loggedIn = login; | ||
} | ||
} | ||
context.on('login', (login) => store.update(loginUpdater(login))); | ||
} | ||
|
||
class Handler { | ||
constructor(enforcer) { | ||
if (enforcer !== singletonEnforcer) { | ||
throw new Error('Cannot construct singleton'); | ||
}; | ||
} | ||
static getInstance() { | ||
if (!this[singleton]) { | ||
this[singleton] = new Handler(singletonEnforcer); | ||
} | ||
return this[singleton]; | ||
} | ||
|
||
init() { | ||
if (!this._dispatcher) { | ||
this._dispatcher = d3_dispatch | ||
} | ||
_updateLogin(this) | ||
} | ||
|
||
call(args) { | ||
this._dispatcher.call(...args); | ||
} | ||
|
||
dispatch(args) { | ||
this._dispatcher.dispatch(...args); | ||
} | ||
|
||
on(args) { | ||
this._dispatcher.on(...args); | ||
} | ||
} | ||
|
||
export default Handler | ||
|
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { mainUi } from './views'; | ||
import Store from './store'; | ||
import Handler from './handler'; | ||
import css from './styles/main.css'; | ||
|
||
const mainStore = Store.getInstance(); | ||
mainStore.init(); | ||
const mainStore = Store.getInstance(); mainStore.init(); | ||
const mainHandler = Handler.getInstance(); mainHandler.init(); | ||
|
||
window.onload = () => { | ||
mainUi(mainStore).render(); | ||
} | ||
window.onload = () => mainUi(mainStore.state).render(); |
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.disabled { | ||
display: none; | ||
} | ||
|
||
.nav { | ||
width: 100%; | ||
height: 8vh; | ||
display: flex; | ||
align-items: center; | ||
background: #eee; | ||
border-bottom: 1px solid #000000; | ||
} | ||
|
||
#map { | ||
width: 100%; | ||
} | ||
|
||
.control { | ||
display: flex; | ||
list-style: none; | ||
padding: 0 10px; | ||
} | ||
|
||
.control li { | ||
margin: 5px 10px; | ||
padding: 10px 20px; | ||
border: 1px solid #000000; | ||
border-radius: 4px; | ||
} | ||
|
||
.control li:hover { | ||
background: #696969; | ||
} |
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,34 @@ | ||
.modal { | ||
position: fixed; | ||
display: block; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
height: 400px; | ||
max-height: 100%; | ||
width: 400px; | ||
max-width: 100%; | ||
background: white; | ||
box-shadow: 0 0 60px 20px rgba(0,0,0,0.8); | ||
z-index: 100; | ||
|
||
} | ||
|
||
.modal-content { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
padding: 20px 50px; | ||
overflow: auto; | ||
} | ||
|
||
.modal-overlay { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
z-index: 50; | ||
} |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
export { mainUi } from './main'; | ||
export { mainUi } from './main'; | ||
export { navUi } from './nav'; | ||
export { loginUi } from './login'; |
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,65 @@ | ||
import { | ||
select as d3_select, | ||
selectAll as d3_selectAll | ||
} from 'd3'; | ||
|
||
import Handler from '../handler'; | ||
import css from '../styles/modal.css'; | ||
|
||
export function loginUi (context) { | ||
const body = d3_select('body'); | ||
const handler = Handler.getInstance(); | ||
|
||
d3_dispatch('loggedIn') | ||
|
||
function doLogin() { | ||
// place where interaction w/rails app will go | ||
handler.call('loggedIn', true); | ||
} | ||
|
||
function doClose() { | ||
d3_selectAll('.modal-overlay').remove() | ||
d3_selectAll('.modal').remove() | ||
} | ||
|
||
let login = {} | ||
|
||
login.render = () => { | ||
// gross, but a modal. | ||
body | ||
.append('div').attr('class', 'modal-overlay') | ||
.append('div').attr('class', 'modal') | ||
.append('div').attr('class', 'modal-content') | ||
|
||
let modalContent = d3_select('.modal-content'); | ||
|
||
['username', 'password'].forEach(input => { | ||
modalContent | ||
.append('div').attr('class', `login-input`).attr('id', `login-input-${input}`) | ||
.append('span').attr('class', 'input-name').text(input) | ||
|
||
d3_select(`#login-input-${input}`) | ||
.append('input') | ||
.attr('class', input) | ||
.attr('type', 'text') | ||
}) | ||
|
||
modalContent | ||
.append('ul') | ||
.attr('class', 'control') | ||
.attr('id', 'login-buttons') | ||
|
||
let loginControls = d3_select('#login-buttons'); | ||
|
||
loginControls | ||
.append('li').attr('id', 'login-ok').on('click', doLogin) | ||
.append('div').attr('id', 'login-ok-text').text('ok') | ||
|
||
loginControls | ||
.append('li').attr('id', 'login-close').on('click', doClose) | ||
.append('div').attr('id', 'login-close').text('close'); | ||
|
||
} | ||
|
||
return login; | ||
} |
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
Empty file.
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,45 @@ | ||
import { select as d3_select } from 'd3'; | ||
import { dispatch as d3_dispatch } from 'd3-dispatch'; | ||
import { loginUi } from './index' | ||
|
||
export function navUi(context) { | ||
let nav = {}; | ||
d3_dispatch('login', 'logout'); | ||
|
||
function login() { | ||
if (d3_select('#login-text').text() === 'login') { | ||
loginUi(context).render(); | ||
} else { | ||
d3_dispatch.call('logout'); | ||
} | ||
} | ||
nav.render = () => { | ||
let nav = d3_select('.nav'); | ||
|
||
// controls | ||
let navControl = nav.append('ul').attr('class', 'control'); | ||
|
||
navControl | ||
.append('li') | ||
.attr('id', 'login') | ||
.on('click' , login) | ||
.append('div') | ||
.attr('id', 'login-text') | ||
.text(context.loggedIn ? 'logout' : 'login') | ||
|
||
|
||
navControl | ||
.append('li') | ||
.attr('id', 'upload') | ||
.append('div') | ||
.attr('id', 'upload-text') | ||
.text('upload') | ||
|
||
if (!context.loggedIn) { | ||
d3_select('#upload').attr('class', 'disabled') | ||
|
||
} | ||
} | ||
|
||
return nav; | ||
} |
Oops, something went wrong.