mirror of
https://github.com/Doodle3D/Doodle3D-API
synced 2025-01-03 10:03:48 +01:00
updated map config
This commit is contained in:
parent
5fcbc29ca6
commit
4b6ccdebed
140
example/app.js
140
example/app.js
@ -1,80 +1,94 @@
|
|||||||
import $ from 'jquery';
|
|
||||||
import Doodle3DAPI from 'doodle3d-API';
|
import Doodle3DAPI from 'doodle3d-API';
|
||||||
import rest from 'rest-API';
|
import rest from 'rest-API';
|
||||||
|
|
||||||
var api = "http://connect.doodle3d.com/api/";
|
var api = "http://connect.doodle3d.com/api/";
|
||||||
|
var known = [];
|
||||||
|
|
||||||
function addBox (boxData) {
|
function addBox (boxData) {
|
||||||
|
|
||||||
var row = document.createElement('tr');
|
if (know.indexOf(boxData.localip) === -1) {
|
||||||
row.style.color = "gray";
|
known.push(boxData.localip);
|
||||||
|
|
||||||
var id = document.createElement('td');
|
var row = document.createElement('tr');
|
||||||
var localIP = document.createElement('td');
|
|
||||||
var bed = document.createElement('td');
|
|
||||||
var bedTarget = document.createElement('td');
|
|
||||||
var bufferedLines = document.createElement('td');
|
|
||||||
var currentLine = document.createElement('td');
|
|
||||||
var hasControl = document.createElement('td');
|
|
||||||
var hotend = document.createElement('td');
|
|
||||||
var hotendTarget = document.createElement('td');
|
|
||||||
var state = document.createElement('td');
|
|
||||||
var totalLines = document.createElement('td');
|
|
||||||
|
|
||||||
row.appendChild(id);
|
|
||||||
row.appendChild(localIP);
|
|
||||||
row.appendChild(bed);
|
|
||||||
row.appendChild(bedTarget);
|
|
||||||
row.appendChild(bufferedLines);
|
|
||||||
row.appendChild(currentLine);
|
|
||||||
row.appendChild(hasControl);
|
|
||||||
row.appendChild(hotend);
|
|
||||||
row.appendChild(hotendTarget);
|
|
||||||
row.appendChild(state);
|
|
||||||
row.appendChild(totalLines);
|
|
||||||
|
|
||||||
id.innerHTML = boxData.wifiboxid;
|
|
||||||
localIP.innerHTML = boxData.localip;
|
|
||||||
|
|
||||||
document.getElementById("table").appendChild(row);
|
|
||||||
|
|
||||||
var doodle3DAPI = new Doodle3DAPI(boxData.localip);
|
|
||||||
doodle3DAPI.onconnect = function () {
|
|
||||||
row.style.color = "black";
|
|
||||||
};
|
|
||||||
doodle3DAPI.ondisconnect = function () {
|
|
||||||
row.style.color = "gray";
|
row.style.color = "gray";
|
||||||
};
|
|
||||||
doodle3DAPI.onupdate = function (data) {
|
var id = document.createElement('td');
|
||||||
state.innerHTML = data.state;
|
var localIP = document.createElement('td');
|
||||||
if (data.state === "idle") {
|
var bed = document.createElement('td');
|
||||||
bed.innerHTML = data.bed;
|
var bedTarget = document.createElement('td');
|
||||||
bedTarget.innerHTML = data.bed_target;
|
var bufferedLines = document.createElement('td');
|
||||||
bufferedLines.innerHTML = data.buffered_lines;
|
var currentLine = document.createElement('td');
|
||||||
currentLine.innerHTML = data.current_line;
|
var hasControl = document.createElement('td');
|
||||||
hasControl.innerHTML = data.has_control;
|
var hotend = document.createElement('td');
|
||||||
hotend.innerHTML = data.hotend;
|
var hotendTarget = document.createElement('td');
|
||||||
hotendTarget.innerHTML = data.hotend_target;
|
var state = document.createElement('td');
|
||||||
|
var totalLines = document.createElement('td');
|
||||||
|
|
||||||
|
row.appendChild(id);
|
||||||
|
row.appendChild(localIP);
|
||||||
|
row.appendChild(bed);
|
||||||
|
row.appendChild(bedTarget);
|
||||||
|
row.appendChild(bufferedLines);
|
||||||
|
row.appendChild(currentLine);
|
||||||
|
row.appendChild(hasControl);
|
||||||
|
row.appendChild(hotend);
|
||||||
|
row.appendChild(hotendTarget);
|
||||||
|
row.appendChild(state);
|
||||||
|
row.appendChild(totalLines);
|
||||||
|
|
||||||
|
id.innerHTML = boxData.wifiboxid;
|
||||||
|
localIP.innerHTML = boxData.localip;
|
||||||
|
|
||||||
|
document.getElementById("table").appendChild(row);
|
||||||
|
|
||||||
|
var doodle3DAPI = new Doodle3DAPI(boxData.localip);
|
||||||
|
doodle3DAPI.onconnect = function () {
|
||||||
|
row.style.color = "black";
|
||||||
|
};
|
||||||
|
doodle3DAPI.ondisconnect = function () {
|
||||||
|
row.style.color = "gray";
|
||||||
|
};
|
||||||
|
doodle3DAPI.onupdate = function (data) {
|
||||||
state.innerHTML = data.state;
|
state.innerHTML = data.state;
|
||||||
totalLines.innerHTML = data.total_lines;
|
if (data.state === "idle") {
|
||||||
}
|
bed.innerHTML = data.bed;
|
||||||
else {
|
bedTarget.innerHTML = data.bed_target;
|
||||||
}
|
bufferedLines.innerHTML = data.buffered_lines;
|
||||||
};
|
currentLine.innerHTML = data.current_line;
|
||||||
doodle3DAPI.startUpdateLoop();
|
hasControl.innerHTML = data.has_control;
|
||||||
|
hotend.innerHTML = data.hotend;
|
||||||
|
hotendTarget.innerHTML = data.hotend_target;
|
||||||
|
state.innerHTML = data.state;
|
||||||
|
totalLines.innerHTML = data.total_lines;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
doodle3DAPI.startUpdateLoop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rest.get(api + "list.php", function (error, boxes) {
|
function searchBoxes () {
|
||||||
if (error) {
|
rest.get(api + "list.php", function (error, boxes) {
|
||||||
return;
|
if (error) {
|
||||||
console.warn(error);
|
return;
|
||||||
}
|
console.warn(error);
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = 0; i < boxes.length; i ++) {
|
for (var i = 0; i < boxes.length; i ++) {
|
||||||
var box = boxes[i];
|
var box = boxes[i];
|
||||||
|
|
||||||
addBox(box);
|
addBox(box);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setInterval(searchBoxes, 5000);
|
||||||
|
searchBoxes();
|
||||||
|
|
||||||
|
addBox({
|
||||||
|
localip: window.location.host + ":3000",
|
||||||
|
wifiboxid: "Node Server"
|
||||||
});
|
});
|
||||||
|
|
||||||
addBox({
|
addBox({
|
||||||
|
10
package.json
10
package.json
@ -12,6 +12,16 @@
|
|||||||
"babel": "npm:babel-core@^5.1.13",
|
"babel": "npm:babel-core@^5.1.13",
|
||||||
"babel-runtime": "npm:babel-runtime@^5.1.13",
|
"babel-runtime": "npm:babel-runtime@^5.1.13",
|
||||||
"core-js": "npm:core-js@^0.9.4"
|
"core-js": "npm:core-js@^0.9.4"
|
||||||
|
},
|
||||||
|
"map": {
|
||||||
|
"config-API": "src/configapi",
|
||||||
|
"info-API": "src/infoapi",
|
||||||
|
"network-API": "src/networkapi",
|
||||||
|
"printer-API": "src/printerapi",
|
||||||
|
"rest-API": "src/restapi",
|
||||||
|
"sketch-API": "src/sketchapi",
|
||||||
|
"system-API": "src/systemapi",
|
||||||
|
"update-API": "src/updateapi"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ export default class {
|
|||||||
this.api = `http://${localIP}/d3dapi/`;
|
this.api = `http://${localIP}/d3dapi/`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSketch (id, callback) {
|
getSketch (id, callback) {
|
||||||
rest.get(this.api + 'sketch/?id=' + id, callback);
|
rest.get(this.api + 'sketch/?id=' + id, callback);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,19 +16,19 @@ export default class {
|
|||||||
rest.post(this.api + 'sketch', {
|
rest.post(this.api + 'sketch', {
|
||||||
'data': data
|
'data': data
|
||||||
}, callback);
|
}, callback);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
status (callback) {
|
status (callback) {
|
||||||
rest.get(this.api + 'sketch/status', callback);
|
rest.get(this.api + 'sketch/status', callback);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear (callback) {
|
clear (callback) {
|
||||||
rest.post(this.api + 'sketch/clear', callback);
|
rest.post(this.api + 'sketch/clear', callback);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ export default class {
|
|||||||
|
|
||||||
status (callback) {
|
status (callback) {
|
||||||
rest.get(this.api + 'update/status', callback);
|
rest.get(this.api + 'update/status', callback);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ export default class {
|
|||||||
//not tested
|
//not tested
|
||||||
|
|
||||||
rest.post(this.api + 'update/download', {}, callback);
|
rest.post(this.api + 'update/download', {}, callback);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ export default class {
|
|||||||
//not tested
|
//not tested
|
||||||
|
|
||||||
rest.post(this.api + 'update/install', {}, callback);
|
rest.post(this.api + 'update/install', {}, callback);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ export default class {
|
|||||||
//not tested
|
//not tested
|
||||||
|
|
||||||
rest.post(this.api + 'update/clear', {}, callback);
|
rest.post(this.api + 'update/clear', {}, callback);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user