0
0
mirror of https://github.com/Doodle3D/Doodle3D-API synced 2024-11-14 16:27:56 +01:00

comply with linter

This commit is contained in:
casperlamboo 2016-04-21 15:44:20 +02:00
parent fbd5d5bf2d
commit 48693feaab
11 changed files with 61 additions and 108 deletions

View File

@ -1,18 +1,15 @@
import * as rest from '../rest.js';
export default class {
export default class Config {
constructor(api) {
this.api = api;
}
get(...keys) {
return rest.get(`${ this.api }config/?${ keys.join('=&') }=`);
}
getAll() {
return rest.get(`${ this.api }config/all`);
}
set(data) {
return rest.post(`${ this.api }config`, data);
}

View File

@ -1,22 +1,18 @@
import * as rest from '../rest.js';
export default class {
export default class Info {
constructor(api) {
this.api = api;
}
get() {
return rest.get(`${ this.api }info`);
}
status() {
return rest.get(`${ this.api }info/status`);
}
downloadLogFiles() {
window.location = `${ this.api }info/logfiles`;
}
acces() {
return rest.get(`${ this.api }info/access`);
}

View File

@ -1,50 +1,39 @@
import * as rest from '../rest.js';
export default class {
export default class Network {
constructor(api) {
this.api = api;
}
scan() {
return rest.get(`${ this.api }network/scan`);
}
known() {
return rest.get(`${ this.api }network/known`);
}
status() {
return rest.get(`${ this.api }network/status`);
}
assosiate(ssid, phrase, recreate = false) {
const data = { ssid, recreate, phrase };
return rest.post(`${ this.api }network/associate`, data);
}
disassociate() {
//not tested
return rest.post(`${ this.api }network/disassociate`, {});
}
openAccesPoint() {
//not tested
return rest.post(`${ this.api }network/openap`, {});
}
remove(ssid) {
return rest.post(`${ this.api }network/remove`, {
'ssid': ssid
});
}
signin() {
return rest.get(`${ this.api }network/signin`);
}
async alive() {
try {
await rest.get(`${ this.api }network/alive`);

View File

@ -1,36 +1,29 @@
import * as rest from '../rest.js';
export default class {
export default class Printer {
constructor(api) {
this.api = api;
}
temperature() {
return rest.get(`${ this.api }printer/temperature`);
}
progress() {
return rest.get(`${ this.api }printer/progress`);
}
state() {
return rest.get(`${ this.api }printer/state`);
}
listAll() {
return rest.get(`${ this.api }printer/listall`);
}
heatup() {
return rest.post(`${ this.api }printer/heatup`, {});
}
print(gcode = '', first = false, start = false, last) {
const data = { gcode, first, start, last };
return rest.post(`${ this.api }printer/print`, data);
}
stop(gcode = '') {
const data = { gcode };

View File

@ -1,22 +1,18 @@
import * as rest from '../rest.js';
export default class {
export default class Sketch {
constructor(api) {
this.api = api;
}
getSketch(id) {
return rest.get(`${ this.api }sketch/?id=${ id }`);
}
set(data = '') {
return rest.post(`${ this.api }sketch`, { data });
}
status() {
return rest.get(`${ this.api }sketch/status`);
}
clear() {
return rest.post(`${ this.api }sketch/clear`);
}

View File

@ -1,10 +1,9 @@
import * as rest from '../rest.js';
export default class {
export default class System {
constructor(api) {
this.api = api;
}
versions() {
return rest.get(`${ this.api }system/fwversions`);
}

View File

@ -1,29 +1,22 @@
import * as rest from '../rest.js';
export default class {
export default class Update {
constructor(api) {
this.api = api;
}
status() {
return rest.get(`${ this.api }update/status`);
}
download() {
//not tested
return rest.post(`${ this.api }update/download`, {});
}
install() {
//not tested
return rest.post(`${ this.api }update/install`, {});
}
clear() {
//not tested
return rest.post(`${ this.api }update/clear`, {});
}
}

View File

@ -31,7 +31,6 @@ export default class Doodle3DBox extends EventDispatcher {
this.system = new SystemAPI(this.api);
this.update = new UpdateAPI(this.api);
}
setAutoUpdate(autoUpdate = true, updateInterval = 1000) {
this.updateInterval = updateInterval;
if (this.autoUpdate === autoUpdate) return;
@ -41,7 +40,6 @@ export default class Doodle3DBox extends EventDispatcher {
return this;
}
async checkAlive() {
const alive = await this.network.alive();
@ -53,7 +51,6 @@ export default class Doodle3DBox extends EventDispatcher {
this.alive = alive;
return alive;
}
async sendGCode(gcode) {
const printerState = await this.printer.state();
if (printerState.state !== 'idle') {
@ -78,7 +75,6 @@ export default class Doodle3DBox extends EventDispatcher {
lastIndex = index + 1; //skip next \n
}
}
async _update() {
while (this.autoUpdate) {
if (this.alive) {
@ -96,7 +92,6 @@ export default class Doodle3DBox extends EventDispatcher {
await sleep(this.updateInterval);
}
}
async _sendBatch(gcode, start) {
try {
const response = await this.printer.print(gcode, start, start);

View File

@ -22,7 +22,6 @@ export default class Doodle3DManager extends EventDispatcher {
this.autoUpdate = false;
}
setAutoUpdate(autoUpdate = true, updateInterval = 1000) {
this.updateInterval = updateInterval;
if (this.autoUpdate === autoUpdate) return;
@ -32,7 +31,6 @@ export default class Doodle3DManager extends EventDispatcher {
return this;
}
async _update() {
while (this.autoUpdate) {
await this._checkNew();
@ -40,7 +38,6 @@ export default class Doodle3DManager extends EventDispatcher {
await sleep(this.updateInterval);
}
}
async _checkNew() {
let boxes;
try {
@ -76,13 +73,11 @@ export default class Doodle3DManager extends EventDispatcher {
this.dispatchEvent({ type: 'boxeschanged', boxes: this.boxes });
}
}
_addBox(box) {
this.boxes.push(box);
this.dispatchEvent({ type: 'boxappeared', box });
}
_removeBox(box) {
const index = this.boxes.indexOf(box);
if (index !== -1) {