2015-07-23 19:12:50 +02:00
|
|
|
import * as rest from './restapi.js';
|
2015-07-15 15:06:18 +02:00
|
|
|
|
|
|
|
export default class {
|
2015-07-24 13:15:00 +02:00
|
|
|
constructor (api) {
|
|
|
|
this.api = api;
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 19:12:50 +02:00
|
|
|
temperature () {
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.get(`${ this.api }printer/temperature`);
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 19:12:50 +02:00
|
|
|
progress () {
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.get(`${ this.api }printer/progress`);
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 19:12:50 +02:00
|
|
|
state () {
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.get(`${ this.api }printer/state`);
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 19:12:50 +02:00
|
|
|
listAll () {
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.get(`${ this.api }printer/listall`);
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 19:12:50 +02:00
|
|
|
heatup () {
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.post(`${ this.api }printer/heatup`, {});
|
2015-07-24 17:37:01 +02:00
|
|
|
}
|
|
|
|
|
2015-10-12 12:33:33 +02:00
|
|
|
print (gcode = '', first = false, start = false, last) {
|
2016-04-16 18:05:15 +02:00
|
|
|
const data = { gcode, first, start, last };
|
2015-07-24 13:15:00 +02:00
|
|
|
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.post(`${ this.api }printer/print`, data);
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-24 13:15:00 +02:00
|
|
|
stop (gcode = '') {
|
2016-04-16 18:05:15 +02:00
|
|
|
const data = { gcode };
|
2015-07-24 17:37:01 +02:00
|
|
|
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.post(`${ this.api }printer/stop`, data);
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
2015-10-12 12:33:33 +02:00
|
|
|
}
|