Add export to wifi box

This commit is contained in:
casperlamboo 2018-01-25 17:57:38 +01:00
parent fb06bfb135
commit abf426c5f2
6 changed files with 218 additions and 203 deletions

254
package-lock.json generated
View File

@ -22,8 +22,17 @@
"resolved": "https://registry.npmjs.org/@doodle3d/clipper-lib/-/clipper-lib-6.4.2-b.tgz",
"integrity": "sha512-glELSijsD9b+/0d9iOdasBwqH3s+xPxD59tJ7aXkBx7klugygGOMXn7PB05AdhVyA1OYMj7GUCegaQa7nvLtmQ=="
},
"@doodle3d/doodle3d-api": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@doodle3d/doodle3d-api/-/doodle3d-api-1.0.2.tgz",
"integrity": "sha512-zrm6NOGkX27Rzd6Bgyjiz9GWGOh23MQAL9JncaMZQmJ55Zrf3hw9alGs0a948qcgNw/HBbqnAZFZypWqTfd5rw==",
"requires": {
"eventdispatcher.js": "0.0.2",
"whatwg-fetch": "2.0.3"
}
},
"@doodle3d/doodle3d-core": {
"version": "github:doodle3d/doodle3d-core#36a73c233e569fca79d2059a50edb6bdb511aa58",
"version": "github:doodle3d/doodle3d-core#ad944024006ae63f6b7da49d663bd1ba8dacfac4",
"requires": {
"@doodle3d/cal": "0.0.8",
"@doodle3d/clipper-js": "1.0.10",
@ -44,7 +53,7 @@
"lodash": "4.17.4",
"memoizee": "0.3.10",
"normalize-wheel": "1.0.1",
"pouchdb": "6.4.1",
"pouchdb": "6.4.2",
"proptypes": "1.1.0",
"raf": "3.4.0",
"ramda": "0.21.0",
@ -168,7 +177,6 @@
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.3.0.tgz",
"integrity": "sha1-RBT/dKUIecII7l/cgm4ywwNUnto=",
"dev": true,
"requires": {
"co": "4.6.0",
"fast-deep-equal": "1.0.0",
@ -342,9 +350,9 @@
}
},
"assert-plus": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz",
"integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ="
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
},
"async": {
"version": "2.6.0",
@ -377,9 +385,9 @@
"integrity": "sha512-hIp37ojJRRW8ExWSxxLpkDHUufk/DFfsb7/cUC1cVbBg7JV4gJTkCTRa44dlL9e5jx1P3VNrjL7QOQfi4MyltA=="
},
"aws-sign2": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz",
"integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8="
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
"integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg="
},
"aws4": {
"version": "1.6.0",
@ -1733,11 +1741,11 @@
"dev": true
},
"boom": {
"version": "2.10.1",
"resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz",
"integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=",
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz",
"integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=",
"requires": {
"hoek": "2.16.3"
"hoek": "4.2.0"
}
},
"bowser": {
@ -2242,11 +2250,21 @@
}
},
"cryptiles": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz",
"integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=",
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz",
"integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=",
"requires": {
"boom": "2.10.1"
"boom": "5.2.0"
},
"dependencies": {
"boom": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz",
"integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==",
"requires": {
"hoek": "4.2.0"
}
}
}
},
"crypto-browserify": {
@ -2325,13 +2343,6 @@
"integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
"requires": {
"assert-plus": "1.0.0"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
}
}
},
"date-now": {
@ -2448,6 +2459,11 @@
"repeating": "2.0.1"
}
},
"detect-libc": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups="
},
"detect-node": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.3.tgz",
@ -3008,8 +3024,7 @@
"fast-deep-equal": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz",
"integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=",
"dev": true
"integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8="
},
"fast-future": {
"version": "1.0.2",
@ -3019,8 +3034,7 @@
"fast-json-stable-stringify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=",
"dev": true
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
},
"faye-websocket": {
"version": "0.10.0",
@ -3166,9 +3180,9 @@
"integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
},
"form-data": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz",
"integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=",
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz",
"integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=",
"requires": {
"asynckit": "0.4.0",
"combined-stream": "1.0.5",
@ -4153,13 +4167,6 @@
"integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
"requires": {
"assert-plus": "1.0.0"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
}
}
},
"github-from-package": {
@ -4266,28 +4273,17 @@
"dev": true
},
"har-schema": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz",
"integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4="
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
"integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI="
},
"har-validator": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz",
"integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=",
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz",
"integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=",
"requires": {
"ajv": "4.11.8",
"har-schema": "1.0.5"
},
"dependencies": {
"ajv": {
"version": "4.11.8",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz",
"integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=",
"requires": {
"co": "4.6.0",
"json-stable-stringify": "1.0.1"
}
}
"ajv": "5.3.0",
"har-schema": "2.0.0"
}
},
"has": {
@ -4361,14 +4357,14 @@
}
},
"hawk": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz",
"integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=",
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz",
"integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==",
"requires": {
"boom": "2.10.1",
"cryptiles": "2.0.5",
"hoek": "2.16.3",
"sntp": "1.0.9"
"boom": "4.3.1",
"cryptiles": "3.1.2",
"hoek": "4.2.0",
"sntp": "2.1.0"
}
},
"he": {
@ -4389,9 +4385,9 @@
}
},
"hoek": {
"version": "2.16.3",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz",
"integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0="
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz",
"integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ=="
},
"hoist-non-react-statics": {
"version": "1.2.0",
@ -4599,11 +4595,11 @@
}
},
"http-signature": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz",
"integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
"integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
"requires": {
"assert-plus": "0.2.0",
"assert-plus": "1.0.0",
"jsprim": "1.4.1",
"sshpk": "1.13.1"
}
@ -5126,16 +5122,7 @@
"json-schema-traverse": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
"integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=",
"dev": true
},
"json-stable-stringify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz",
"integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=",
"requires": {
"jsonify": "0.0.0"
}
"integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A="
},
"json-stringify-safe": {
"version": "5.0.1",
@ -5153,11 +5140,6 @@
"resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz",
"integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE="
},
"jsonify": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
"integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM="
},
"jsprim": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
@ -5167,13 +5149,6 @@
"extsprintf": "1.3.0",
"json-schema": "0.2.3",
"verror": "1.10.0"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
}
}
},
"jss": {
@ -5388,7 +5363,7 @@
"bindings": "1.3.0",
"fast-future": "1.0.2",
"nan": "2.8.0",
"prebuild-install": "2.4.1"
"prebuild-install": "2.5.0"
},
"dependencies": {
"nan": {
@ -6419,9 +6394,9 @@
"integrity": "sha1-FggOlwqud5kTdWwtrviOqnSG30E="
},
"performance-now": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz",
"integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU="
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
},
"pify": {
"version": "2.3.0",
@ -6473,14 +6448,14 @@
}
},
"pouchdb": {
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/pouchdb/-/pouchdb-6.4.1.tgz",
"integrity": "sha512-7YrhsBXbQh/iPA8O5Nzixi9QigaQJjqbbCFr+D7Kc258oeXNW9a0t/tOME1Lh84TJiFRuN9982FGVnrBrUhLiA==",
"version": "6.4.2",
"resolved": "https://registry.npmjs.org/pouchdb/-/pouchdb-6.4.2.tgz",
"integrity": "sha512-z4rq2lLB/wYULcVb0O5G41hv/V/RMUqDNbmgDhAvvqeyBTkCf6RLL1bMCEo+m+igM4iFfITkKVJj8gnYehh/fg==",
"requires": {
"argsarray": "0.0.1",
"buffer-from": "0.1.1",
"clone-buffer": "1.0.0",
"debug": "3.0.1",
"debug": "3.1.0",
"double-ended-queue": "2.1.0-0",
"immediate": "3.0.6",
"inherits": "2.0.3",
@ -6492,7 +6467,7 @@
"lie": "3.1.1",
"ltgt": "2.2.0",
"readable-stream": "1.0.33",
"request": "2.80.0",
"request": "2.83.0",
"spark-md5": "3.0.0",
"through2": "2.0.3",
"uuid": "3.2.1",
@ -6500,9 +6475,9 @@
},
"dependencies": {
"debug": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.0.1.tgz",
"integrity": "sha512-6nVc6S36qbt/mutyt+UGMnawAMrPDZUPQjRZI3FS9tCtDRhvxJbK79unYBLPi+z5SLXQ3ftoVBFCblQtNSls8w==",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
@ -6536,10 +6511,11 @@
}
},
"prebuild-install": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-2.4.1.tgz",
"integrity": "sha512-99TyEFYTTkBWANT+mwSptmLb9ZCLQ6qKIUE36fXSIOtShB0JNprL2hzBD8F1yIuT9btjFrFEwbRHXhqDi1HmRA==",
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-2.5.0.tgz",
"integrity": "sha512-3wlyZgmkeeyduOR8Ursu5gKr3yWAYObACa5aJOtt2farRRFV/+zXk/Y3wM6yQRMqmqHh+pHAwyKp5r82K699Rg==",
"requires": {
"detect-libc": "1.0.3",
"expand-template": "1.1.0",
"github-from-package": "0.0.0",
"minimist": "1.2.0",
@ -6713,13 +6689,6 @@
"integrity": "sha512-pDP/NMRAXoTfrhCfyfSEwJAKLaxBU9eApMeBPB1TkDouZmvPerIClV8lTAd+uF8ZiTaVl69e1FCxQrAd/VTjGw==",
"requires": {
"performance-now": "2.1.0"
},
"dependencies": {
"performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
}
}
},
"ramda": {
@ -7211,43 +7180,34 @@
}
},
"request": {
"version": "2.80.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.80.0.tgz",
"integrity": "sha1-jMFi1215OBze/dNQXXa4C2BYm9A=",
"version": "2.83.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz",
"integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==",
"requires": {
"aws-sign2": "0.6.0",
"aws-sign2": "0.7.0",
"aws4": "1.6.0",
"caseless": "0.12.0",
"combined-stream": "1.0.5",
"extend": "3.0.1",
"forever-agent": "0.6.1",
"form-data": "2.1.4",
"har-validator": "4.2.1",
"hawk": "3.1.3",
"http-signature": "1.1.1",
"form-data": "2.3.1",
"har-validator": "5.0.3",
"hawk": "6.0.2",
"http-signature": "1.2.0",
"is-typedarray": "1.0.0",
"isstream": "0.1.2",
"json-stringify-safe": "5.0.1",
"mime-types": "2.1.17",
"oauth-sign": "0.8.2",
"performance-now": "0.2.0",
"qs": "6.3.2",
"performance-now": "2.1.0",
"qs": "6.5.1",
"safe-buffer": "5.1.1",
"stringstream": "0.0.5",
"tough-cookie": "2.3.3",
"tunnel-agent": "0.4.3",
"tunnel-agent": "0.6.0",
"uuid": "3.2.1"
},
"dependencies": {
"qs": {
"version": "6.3.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz",
"integrity": "sha1-51vV9uJoEioqDgvaYwslUMFmUCw="
},
"tunnel-agent": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz",
"integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us="
},
"uuid": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz",
@ -7522,11 +7482,11 @@
"dev": true
},
"sntp": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz",
"integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz",
"integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==",
"requires": {
"hoek": "2.16.3"
"hoek": "4.2.0"
}
},
"sockjs": {
@ -7658,13 +7618,6 @@
"getpass": "0.1.7",
"jsbn": "0.1.1",
"tweetnacl": "0.14.5"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
}
}
},
"statuses": {
@ -8304,13 +8257,6 @@
"assert-plus": "1.0.0",
"core-util-is": "1.0.2",
"extsprintf": "1.3.0"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
}
}
},
"vm-browserify": {

View File

@ -19,6 +19,7 @@
},
"dependencies": {
"@doodle3d/clipper-js": "^1.0.10",
"@doodle3d/doodle3d-api": "^1.0.2",
"@doodle3d/doodle3d-core": "github:doodle3d/doodle3d-core",
"babel-plugin-transform-class-properties": "^6.24.1",
"file-saver": "^1.3.3",

View File

@ -19,6 +19,7 @@ import qualitySettings from '../settings/quality.yml';
import update from 'react-addons-update';
import SettingsIcon from 'material-ui-icons/Settings';
import validateIp from 'validate-ip';
import { Doodle3DManager } from 'doodle3d-api';
const styles = {
textFieldRow: {
@ -82,6 +83,7 @@ class Settings extends React.Component {
state = {
localStorage: getLocalStorage(),
wifiBoxes: [],
addPrinter: {
open: false,
name: '',
@ -102,6 +104,21 @@ class Settings extends React.Component {
} else {
this.openAddPrinterDialog();
}
const doodle3DManager = new Doodle3DManager();
doodle3DManager.checkNonServerBoxes = false;
doodle3DManager.setAutoUpdate(true, 1000);
doodle3DManager.addEventListener('boxeschanged', ({ boxes: wifiBoxes }) => {
this.setState({ wifiBoxes });
});
this.setState({ doodle3DManager })
}
componentWillUnMount() {
const { doodle3DManager } = this.state;
if (doodle3DManager) doodle3DManager.setAutoUpdate(false);
}
changeSettings = (fieldName, value) => {
@ -336,7 +353,7 @@ class Settings extends React.Component {
}
render() {
const { addPrinter, managePrinter, localStorage } = this.state;
const { addPrinter, managePrinter, localStorage, wifiBoxes } = this.state;
const { classes, disabled } = this.props;
return (
@ -437,6 +454,7 @@ class Settings extends React.Component {
open={addPrinter.open}
onRequestClose={this.closeAddPrinterDialog}
contentStyle={{ maxWidth: '400px' }}
autoScrollBodyContent
actions={[
<FlatButton
label="Cancel"
@ -455,7 +473,12 @@ class Settings extends React.Component {
))}
</SelectField>
<TextField name="addPrinter.name" floatingLabelText="Name" fullWidth />
{(addPrinter.printer === 'doodle3d_printer') && <TextField name="addPrinter.ip" floatingLabelText="IP Adress" fullWidth />}
{(addPrinter.printer === 'doodle3d_printer') ?
<TextField name="addPrinter.ip" floatingLabelText="IP Adress" fullWidth /> :
<SelectField name="addPrinter.ip" floatingLabelText="Doodle3D WiFi-Box" fullWidth>
{wifiBoxes.map(({ localip, id, wifiboxid }) => (<MenuItem key={id} value={localip} primaryText={wifiboxid} />))}
</SelectField>
}
{addPrinter.error && <p className={classes.error}>{addPrinter.error}</p>}
</Dialog>
<Dialog
@ -463,6 +486,7 @@ class Settings extends React.Component {
open={managePrinter.open}
onRequestClose={this.closeManagePrinterDialog}
contentStyle={{ maxWidth: '400px' }}
autoScrollBodyContent
actions={[
<FlatButton
label="Cancel"
@ -485,7 +509,12 @@ class Settings extends React.Component {
))}
</SelectField>
<TextField name="managePrinter.name" floatingLabelText="Name" fullWidth />
{(managePrinter.printer === 'doodle3d_printer') && <TextField name="managePrinter.ip" floatingLabelText="IP Adress" fullWidth />}
{(managePrinter.printer === 'doodle3d_printer') ?
<TextField name="managePrinter.ip" floatingLabelText="IP Adress" fullWidth /> :
<SelectField name="managePrinter.ip" floatingLabelText="Doodle3D WiFi-Box" fullWidth>
{wifiBoxes.map(({ localip, id, wifiboxid }) => (<MenuItem key={id} value={localip} primaryText={wifiboxid} />))}
</SelectField>
}
{managePrinter.error && <p className={classes.error}>{managePrinter.error}</p>}
</Dialog>
</div>

View File

@ -0,0 +1,60 @@
import React from 'react';
import PropTypes from 'proptypes';
import muiThemeable from 'material-ui/styles/muiThemeable';
import injectSheet from 'react-jss';
import FlatButton from 'material-ui/FlatButton';
import { sleep, getMalyanStatus } from './utils.js';
import { Doodle3DBox } from 'doodle3d-api';
const styles = {
};
class WifiBoxControl extends React.Component {
static propTypes = {
ip: PropTypes.string.isRequired
};
state = {
box: null,
status: null
};
componentDidMount = async () => {
const { ip } = this.props;
const box = new Doodle3DBox(ip);
window.d3dbox = box;
box.addEventListener('update', ({ state }) => this.setState({ status: state }));
box.setAutoUpdate(true, 1000);
this.setState({ box });
const alive = await box.checkAlive();
};
stop = async () => {
const { box } = this.state;
const result = await box.printer.stop();
console.log('result: ', result);
};
componentWillUnmount() {
const { box } = this.state;
if (box) box.setAutoUpdate(false);
this.setState({ mounted: false });
}
render() {
const { status } = this.state;
return (
<div>
<FlatButton label="Stop" onTouchTap={this.stop} />
</div>
);
}
}
export default muiThemeable()(injectSheet(styles)(WifiBoxControl));

View File

@ -15,6 +15,7 @@ import MenuItem from 'material-ui/MenuItem';
import { Tabs, Tab } from 'material-ui/Tabs';
import Settings from './Settings.js';
import MalyanControl from './MalyanControl.js';
import WifiBoxControl from './WifiBoxControl.js';
import ReactResizeDetector from 'react-resize-detector';
import JSONToSketchData from 'doodle3d-core/shape/JSONToSketchData';
import createSceneData from 'doodle3d-core/d3/createSceneData.js';
@ -119,8 +120,7 @@ class Interface extends React.Component {
error: null,
mesh: null,
objectDimensions: '0x0x0mm',
popover: { open: false, element: null },
openUrlDialog: { open: false, url: '' }
popover: { open: false, element: null }
};
}
@ -212,6 +212,7 @@ class Interface extends React.Component {
if (isSlicing) return;
if (!settings) {
this.setState({ error: 'please select a printer first' });
return;
}
if (target === 'WIFI' && !settings.ip) {
this.setState({ error: 'please connect to a WiFi enabled printer' });
@ -232,12 +233,8 @@ class Interface extends React.Component {
const updateProgres = progress => this.setState({ progress: { ...this.state.progress, ...progress } });
await slice(target, name, exportMesh, settings, updateProgres);
} catch (error) {
if (error.code === 3) {
this.setState({ openUrlDialog: { open: true, url: error.url } });
} else {
this.setState({ error: error.message });
throw error;
}
this.setState({ error: error.message });
throw error;
} finally {
this.setState({ isSlicing: false });
}
@ -319,7 +316,7 @@ class Interface extends React.Component {
render() {
const { classes, onCancel } = this.props;
const { isSlicing, progress, showFullScreen, error, objectDimensions, openUrlDialog, settings } = this.state;
const { isSlicing, progress, showFullScreen, error, objectDimensions, settings } = this.state;
const style = { ...(showFullScreen ? {} : { maxWidth: 'inherit', width: '100%', height: '100%' }) };
@ -341,7 +338,10 @@ class Interface extends React.Component {
className={`${classes.button}`}
onTouchTap={onCancel}
/>}
{settings && settings.printer === 'doodle3d_printer' && <MalyanControl ip={settings.ip} />}
{(settings && settings.ip) && ((settings.printer === 'doodle3d_printer') ?
<MalyanControl ip={settings.ip} /> :
<WifiBoxControl ip={settings.ip} />
)}
<RaisedButton
label="Print"
ref="button"
@ -385,32 +385,6 @@ class Interface extends React.Component {
</div>
);
const closeDialog = () => this.setState({ openUrlDialog: { open: false, url: '' } });
const dialog = (
<Dialog
open={openUrlDialog.open}
title="Open with Doodle3D Connect"
contentStyle={{ maxWidth: '400px' }}
actions={[
<FlatButton
label="Cancel"
onTouchTap={closeDialog}
/>,
<RaisedButton
label="Open"
primary
onTouchTap={() => {
window.open(openUrlDialog.url, '_blank');
closeDialog();
}}
/>
]}
>
<p>Click 'Open' to continue to Doodle3D Connect</p>
</Dialog>
)
if (showFullScreen) {
return (
<div
@ -426,7 +400,6 @@ class Interface extends React.Component {
<h1 className={classes.title}>Doodle3D Slicer</h1>
{d3Panel}
{settingsPanel}
{dialog}
</div>
);
} else {
@ -455,7 +428,6 @@ class Interface extends React.Component {
{d3Panel}
</Tab>
</Tabs>
{dialog}
</div>
);
}

View File

@ -8,6 +8,7 @@ import { grey800, red500 } from 'material-ui/styles/colors';
import React from 'react';
import PropTypes from 'prop-types';
import fileSaver from 'file-saver';
import { Doodle3DBox } from 'doodle3d-api';
export function placeOnGround(mesh) {
const boundingBox = new THREE.Box3().setFromObject(mesh);
@ -90,8 +91,9 @@ export function fetchProgress(url, data = {}, onProgress) {
const xhr = new XMLHttpRequest();
xhr.onload = () => {
const { status, statusText, responseURL: url } = xhr;
resolve(new Response(xhr.response, { status, statusText, url }));
resolve(new Response(xhr.response));
// const { status, statusText, responseURL: url } = xhr;
// resolve(new Response(xhr.response, { status, statusText, url }));
}
xhr.onerror = () => reject(new TypeError('Network request failed'));
xhr.ontimeout = () => reject(new TypeError('Network request failed'));
@ -147,15 +149,22 @@ const CONNECT_URL = 'http://connect.doodle3d.com/';
export async function slice(target, name, mesh, settings, updateProgress) {
let steps;
let currentStep = 0;
let wifiBox;
switch (target) {
case 'DOWNLOAD':
steps = 1;
break;
case 'WIFI':
// if (settings.printer === 'doodle3d_printer') {
if (settings.printer === 'doodle3d_printer') {
// const { state } = await getMalyanStatus(settings.ip);
// if (state !== 'idle') throw { message: 'printer must be idle before starting a print', code: 1 };
// }
// if (state !== 'idle') throw { message: 'printer must be idle before starting a print', code: 0 };
} else {
wifiBox = new Doodle3DBox(settings.ip);
if (!await wifiBox.checkAlive()) throw { message: `can't connect to printer`, code: 4 }
const { state } = await wifiBox.info.status();
if (state !== 'idle') throw { message: 'printer must be idle before starting a print', code: 0 };
}
steps = 2;
break;
default:
@ -241,9 +250,7 @@ export async function slice(target, name, mesh, settings, updateProgress) {
});
currentStep ++;
const url = `${CONNECT_URL}?uuid=${id}`;
const popup = window.open(url, '_blank');
if (!popup) throw { message: 'popup was blocked by browser', code: 3, url };
const result = await wifiBox.printer.fetch(id);
}
break;
}