diff --git a/src/interface/Settings.js b/src/interface/Settings.js index ad0dc62..50f749c 100644 --- a/src/interface/Settings.js +++ b/src/interface/Settings.js @@ -19,6 +19,7 @@ import qualitySettings from '../settings/quality.yml'; import infillSettings from '../settings/infill.yml'; import update from 'react-addons-update'; import SettingsIcon from 'material-ui-icons/Settings'; +import ExitToAppIcon from 'material-ui-icons/ExitToApp'; import validateIp from 'validate-ip'; import { Doodle3DManager } from 'doodle3d-api'; @@ -26,6 +27,8 @@ const DOODLE_3D_MANAGER = new Doodle3DManager(); DOODLE_3D_MANAGER.checkNonServerBoxes = false; DOODLE_3D_MANAGER.setAutoUpdate(true, 5000); +const CONNECT_URL = 'http://connect.doodle3d.com/'; + const styles = { textFieldRow: { display: 'flex', @@ -455,77 +458,61 @@ class Settings extends React.Component { - , - - ]} - > - - {Object.entries(printerSettings).map(([value, { title }]) => ( - - ))} - - - {(addPrinter.printer === 'doodle3d_printer') ? - : - - {wifiBoxes.map(({ localip, id, wifiboxid }) => ())} - - } - {addPrinter.error &&

{addPrinter.error}

} -
- , - , - - ]} - > - - {Object.entries(printerSettings).map(([value, { title }]) => ( - - ))} - - - {(managePrinter.printer === 'doodle3d_printer') ? - : - - {wifiBoxes.map(({ localip, id, wifiboxid }) => ())} - - } - {managePrinter.error &&

{managePrinter.error}

} -
+ {printDialog(this.props, this.state, 'Add Printer', 'addPrinter', 'Add', addPrinter, this.closeAddPrinterDialog, null, this.addPrinter)} + {printDialog(this.props, this.state, 'Manage Printer', 'managePrinter', 'Save', managePrinter, this.closeManagePrinterDialog, this.removeActivePrinter, this.editPrinter)} ); } } +function printDialog(props, state, title, form, submitText, data, closeDialog, removeActivePrinter, save) { + const { classes } = props; + const { wifiBoxes } = state; + + return ( + , + removeActivePrinter && , + + ]} + > + + {Object.entries(printerSettings).map(([value, { title }]) => ( + + ))} + + + {(data.printer === 'doodle3d_printer') ? + : +
+ + {wifiBoxes.map(({ localip, id, wifiboxid }) => ())} + + {data.ip && window.open(`${CONNECT_URL}#box?localip=${data.ip}`, '_blank')} + style={{ fill: grey800, marginLeft: '10px', cursor: 'pointer' }} + />} +
+ } + {data.error &&

{data.error}

} +
+ ); +} + export default injectSheet(styles)(Settings);