-
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
Showing
24 changed files
with
258 additions
and
51 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,7 +1,7 @@ | ||
# Farm - client | ||
Application that drives 3D printer farm | ||
|
||
Version 0.3.0 | ||
Version 0.4.0 | ||
|
||
# Requirements | ||
|
||
|
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,30 @@ | ||
export const SETTINGS_ACTIVE = 'SETTINGS_ACTIVE'; | ||
export const SETTINGS_ACTION_START = 'SETTINGS_ACTION_START'; | ||
export const SETTINGS_ACTION_FINISHED = 'SETTINGS_ACTION_FINISHED'; | ||
|
||
export const SETTINGS_SHUTDOWN_PRINTERS = 'SETTINGS_SHUTDOWN_PRINTERS'; | ||
export const SETTINGS_SHUTDOWN_FARM = 'SETTINGS_SHUTDOWN_FARM'; | ||
|
||
export const settingsActive = state => ({ | ||
type: SETTINGS_ACTIVE, | ||
state, | ||
}); | ||
|
||
export const settingsActionStart = (message, onConfirm) => ({ | ||
type: SETTINGS_ACTION_START, | ||
onConfirm, | ||
message, | ||
}); | ||
|
||
export const settingsActionFinish = () => ({ | ||
type: SETTINGS_ACTION_FINISHED, | ||
}); | ||
|
||
export const settingsShutdownPrinters = (printers) => ({ | ||
type: SETTINGS_SHUTDOWN_PRINTERS, | ||
printers, | ||
}); | ||
|
||
export const settingsShutdownFarm = () => ({ | ||
type: SETTINGS_SHUTDOWN_FARM, | ||
}); |
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 |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
} | ||
|
||
body { | ||
background-color: #faffad; | ||
background-color: #f2f5c3; | ||
} |
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
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
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,36 @@ | ||
.controllButton { | ||
padding: 0; | ||
margin: 0; | ||
border: 0; | ||
|
||
padding: 10px; | ||
margin: 3px; | ||
|
||
font-family: 'roboto'; | ||
letter-spacing: 1.1px; | ||
|
||
border: solid 1px #aaa; | ||
border-radius: 4px; | ||
|
||
background-color: #fff699; | ||
|
||
transition: 0.1s; | ||
|
||
&:hover { | ||
background-color: #fffac6; | ||
cursor: pointer; | ||
} | ||
|
||
&:active { | ||
border: solid 1px #aaa; | ||
} | ||
|
||
&--disabled { | ||
background-color: #ddd699; | ||
|
||
&:hover { | ||
background-color: #ddd699; | ||
|
||
} | ||
} | ||
} |
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
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
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,21 @@ | ||
import React from 'react'; | ||
import Modal from 'react-modal'; | ||
|
||
import H1 from '../h1'; | ||
import modalStyle from '../fileUploadModal/style.css'; | ||
import ControllButton from '../controllButton'; | ||
|
||
const Prompt = ({ children, isOpen, confirm, reject }) => ( | ||
<Modal | ||
isOpen={isOpen} | ||
className={modalStyle.modal} | ||
overlayClassName={modalStyle.modalOverlay} | ||
onRequestClose={reject} | ||
> | ||
<H1>{children}</H1> | ||
<ControllButton onClick={confirm}>Yes</ControllButton> | ||
<ControllButton onClick={reject}>No</ControllButton> | ||
</Modal> | ||
); | ||
|
||
export default Prompt; |
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,71 @@ | ||
import React from 'react'; | ||
import Modal from 'react-modal'; | ||
|
||
import modalStyle from '../fileUploadModal/style.css'; | ||
import style from './style.css'; | ||
import H1 from '../h1'; | ||
import H2 from '../h2'; | ||
import ControllButton from '../controllButton'; | ||
import Prompt from '../prompt'; | ||
import api from '../../lib/api'; | ||
|
||
class Settings extends React.Component { | ||
constructor() { | ||
super(); | ||
this.state = {}; | ||
this.closeModal = this.closeModal.bind(this); | ||
this.shutdownAllPrinters = this.shutdownAllPrinters.bind(this); | ||
this.shutdownFarm = this.shutdownFarm.bind(this); | ||
} | ||
|
||
closeModal() { | ||
this.props.settingsActive(false); | ||
} | ||
|
||
shutdownAllPrinters() { | ||
this.props.settingsActionStart('Shutdown all printers ?', () => { | ||
console.log('request'); | ||
const body = { | ||
selectedPrinters: this.props.printers | ||
}; | ||
api.sendRequest('/api/system/shutdown/printers', 'post', body) | ||
.then(() => { | ||
this.props.settingsActionFinish(); | ||
}); | ||
}); | ||
} | ||
|
||
shutdownFarm() { | ||
this.props.settingsActionStart('Shutdown farm ?', () => { | ||
console.log('request'); | ||
api.sendRequest('/api/system/shutdown/farm', 'post') | ||
.then(() => { | ||
this.props.settingsActionFinish(); | ||
}); | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<Modal | ||
isOpen={this.props.active} | ||
className={`${modalStyle.modal} ${style.modal}`} | ||
overlayClassName={modalStyle.modalOverlay} | ||
onRequestClose={this.closeModal} | ||
> | ||
<H1>Settings</H1> | ||
<H2>system</H2> | ||
<ControllButton onClick={this.shutdownAllPrinters}>shutdown all printers</ControllButton> | ||
<ControllButton onClick={this.shutdownFarm}>shutdown whole farm</ControllButton> | ||
|
||
{this.props.prompt ? <Prompt | ||
isOpen | ||
confirm={this.props.prompt.onConfirm} | ||
reject={this.props.settingsActionFinish}> | ||
{this.props.prompt.message} | ||
</Prompt> : false} | ||
</Modal>); | ||
} | ||
} | ||
|
||
export default Settings; |
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,3 @@ | ||
.modal { | ||
width: 600px; | ||
} |
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,24 @@ | ||
import { connect } from 'react-redux'; | ||
|
||
import Settings from '../components/settings/index'; | ||
import { settingsActive, settingsActionStart, settingsActionFinish } from '../actions/settings'; | ||
|
||
const mapStateToProps = state => ({ | ||
active: state.settings.active, | ||
settings: state.settings.settings, | ||
prompt: state.settings.prompt, | ||
printers: Object.keys(state.printer.printers), | ||
}); | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
settingsActive: (state) => { dispatch(settingsActive(state)); }, | ||
settingsActionStart: (message, onConfirm) => { dispatch(settingsActionStart(message, onConfirm)); }, | ||
settingsActionFinish: () => { dispatch(settingsActionFinish()); }, | ||
}); | ||
|
||
const SettingsContainer = connect( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
)(Settings); | ||
|
||
export default SettingsContainer; |
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
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
Oops, something went wrong.