mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-22 05:37:55 +01:00
Add selected printer query param
@companje
This commit is contained in:
parent
229929e4e8
commit
bc67cab75f
4
index.js
4
index.js
@ -32,10 +32,10 @@ jss.createStyleSheet({
|
||||
}
|
||||
}).attach();
|
||||
|
||||
const { file } = queryString.parse(location.search);
|
||||
const { file, selectedPrinter } = queryString.parse(location.search);
|
||||
|
||||
render((
|
||||
<MuiThemeProvider muiTheme={muiTheme}>
|
||||
<Interface fileUrl={file} name="doodle"/>
|
||||
<Interface fileUrl={file} selectedPrinter={selectedPrinter} name="doodle"/>
|
||||
</MuiThemeProvider>
|
||||
), document.getElementById('app'));
|
||||
|
@ -72,6 +72,7 @@ const updateLocalStorage = (localStorage) => {
|
||||
|
||||
class Settings extends React.Component {
|
||||
static propTypes = {
|
||||
selectedPrinter: PropTypes.string,
|
||||
classes: PropTypes.objectOf(PropTypes.string),
|
||||
onChange: PropTypes.func,
|
||||
disabled: PropTypes.bool.isRequired
|
||||
@ -89,20 +90,39 @@ class Settings extends React.Component {
|
||||
advancedFields: PropTypes.array.isRequired
|
||||
};
|
||||
|
||||
state = {
|
||||
localStorage: getLocalStorage(),
|
||||
wifiBoxes: [],
|
||||
addPrinter: {
|
||||
open: false,
|
||||
name: '',
|
||||
printer: '',
|
||||
ip: '',
|
||||
error: null
|
||||
},
|
||||
managePrinter: {
|
||||
open: false
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
const { selectedPrinter } = this.props;
|
||||
|
||||
const localStorage = getLocalStorage();
|
||||
|
||||
if (selectedPrinter) {
|
||||
const active = Object.entries(localStorage.printers)
|
||||
.map(([key, value]) => ({ key, value }))
|
||||
.find(({ key, value: { ip } }) => ip === selectedPrinter);
|
||||
|
||||
if (active) {
|
||||
localStorage.active = active.key;
|
||||
updateLocalStorage(localStorage);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.state = {
|
||||
localStorage,
|
||||
wifiBoxes: [],
|
||||
addPrinter: {
|
||||
open: false,
|
||||
name: '',
|
||||
printer: '',
|
||||
ip: '',
|
||||
error: null
|
||||
},
|
||||
managePrinter: {
|
||||
open: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
componentDidMount() {
|
||||
const { onChange } = this.props;
|
||||
|
@ -106,6 +106,7 @@ const styles = {
|
||||
class Interface extends React.Component {
|
||||
static propTypes = {
|
||||
fileUrl: PropTypes.string,
|
||||
selectedPrinter: PropTypes.string,
|
||||
mesh: PropTypes.shape({ isMesh: PropTypes.oneOf([true]) }),
|
||||
classes: PropTypes.objectOf(PropTypes.string),
|
||||
pixelRatio: PropTypes.number.isRequired,
|
||||
@ -332,7 +333,7 @@ class Interface extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { classes, onCancel } = this.props;
|
||||
const { classes, onCancel, selectedPrinter } = this.props;
|
||||
const { isSlicing, progress, showFullScreen, error, objectDimensions, settings } = this.state;
|
||||
|
||||
const style = { ...(showFullScreen ? {} : { maxWidth: 'inherit', width: '100%', height: '100%' }) };
|
||||
@ -340,6 +341,7 @@ class Interface extends React.Component {
|
||||
const settingsPanel = (
|
||||
<div className={classes.settingsBar} style={style}>
|
||||
<Settings
|
||||
selectedPrinter={selectedPrinter}
|
||||
disabled={isSlicing}
|
||||
onChange={this.onChangeSettings}
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user