mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-16 19:17:57 +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();
|
}).attach();
|
||||||
|
|
||||||
const { file } = queryString.parse(location.search);
|
const { file, selectedPrinter } = queryString.parse(location.search);
|
||||||
|
|
||||||
render((
|
render((
|
||||||
<MuiThemeProvider muiTheme={muiTheme}>
|
<MuiThemeProvider muiTheme={muiTheme}>
|
||||||
<Interface fileUrl={file} name="doodle"/>
|
<Interface fileUrl={file} selectedPrinter={selectedPrinter} name="doodle"/>
|
||||||
</MuiThemeProvider>
|
</MuiThemeProvider>
|
||||||
), document.getElementById('app'));
|
), document.getElementById('app'));
|
||||||
|
@ -72,6 +72,7 @@ const updateLocalStorage = (localStorage) => {
|
|||||||
|
|
||||||
class Settings extends React.Component {
|
class Settings extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
selectedPrinter: PropTypes.string,
|
||||||
classes: PropTypes.objectOf(PropTypes.string),
|
classes: PropTypes.objectOf(PropTypes.string),
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
disabled: PropTypes.bool.isRequired
|
disabled: PropTypes.bool.isRequired
|
||||||
@ -89,8 +90,25 @@ class Settings extends React.Component {
|
|||||||
advancedFields: PropTypes.array.isRequired
|
advancedFields: PropTypes.array.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
constructor(props) {
|
||||||
localStorage: getLocalStorage(),
|
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: [],
|
wifiBoxes: [],
|
||||||
addPrinter: {
|
addPrinter: {
|
||||||
open: false,
|
open: false,
|
||||||
@ -103,6 +121,8 @@ class Settings extends React.Component {
|
|||||||
open: false
|
open: false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { onChange } = this.props;
|
const { onChange } = this.props;
|
||||||
|
@ -106,6 +106,7 @@ const styles = {
|
|||||||
class Interface extends React.Component {
|
class Interface extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
fileUrl: PropTypes.string,
|
fileUrl: PropTypes.string,
|
||||||
|
selectedPrinter: PropTypes.string,
|
||||||
mesh: PropTypes.shape({ isMesh: PropTypes.oneOf([true]) }),
|
mesh: PropTypes.shape({ isMesh: PropTypes.oneOf([true]) }),
|
||||||
classes: PropTypes.objectOf(PropTypes.string),
|
classes: PropTypes.objectOf(PropTypes.string),
|
||||||
pixelRatio: PropTypes.number.isRequired,
|
pixelRatio: PropTypes.number.isRequired,
|
||||||
@ -332,7 +333,7 @@ class Interface extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { classes, onCancel } = this.props;
|
const { classes, onCancel, selectedPrinter } = this.props;
|
||||||
const { isSlicing, progress, showFullScreen, error, objectDimensions, settings } = this.state;
|
const { isSlicing, progress, showFullScreen, error, objectDimensions, settings } = this.state;
|
||||||
|
|
||||||
const style = { ...(showFullScreen ? {} : { maxWidth: 'inherit', width: '100%', height: '100%' }) };
|
const style = { ...(showFullScreen ? {} : { maxWidth: 'inherit', width: '100%', height: '100%' }) };
|
||||||
@ -340,6 +341,7 @@ class Interface extends React.Component {
|
|||||||
const settingsPanel = (
|
const settingsPanel = (
|
||||||
<div className={classes.settingsBar} style={style}>
|
<div className={classes.settingsBar} style={style}>
|
||||||
<Settings
|
<Settings
|
||||||
|
selectedPrinter={selectedPrinter}
|
||||||
disabled={isSlicing}
|
disabled={isSlicing}
|
||||||
onChange={this.onChangeSettings}
|
onChange={this.onChangeSettings}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user