0
0
mirror of https://github.com/Doodle3D/Doodle3D-API synced 2025-01-07 03:24:08 +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'; import * as rest from '../rest.js';
export default class { export default class Config {
constructor(api) { constructor(api) {
this.api = api; this.api = api;
} }
get(...keys) { get(...keys) {
return rest.get(`${ this.api }config/?${ keys.join('=&') }=`); return rest.get(`${ this.api }config/?${ keys.join('=&') }=`);
} }
getAll() { getAll() {
return rest.get(`${ this.api }config/all`); return rest.get(`${ this.api }config/all`);
} }
set(data) { set(data) {
return rest.post(`${ this.api }config`, data); return rest.post(`${ this.api }config`, data);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,29 +1,22 @@
import * as rest from '../rest.js'; import * as rest from '../rest.js';
export default class { export default class Update {
constructor(api) { constructor(api) {
this.api = api; this.api = api;
} }
status() { status() {
return rest.get(`${ this.api }update/status`); return rest.get(`${ this.api }update/status`);
} }
download() { download() {
//not tested //not tested
return rest.post(`${ this.api }update/download`, {}); return rest.post(`${ this.api }update/download`, {});
} }
install() { install() {
//not tested //not tested
return rest.post(`${ this.api }update/install`, {}); return rest.post(`${ this.api }update/install`, {});
} }
clear() { clear() {
//not tested //not tested
return rest.post(`${ this.api }update/clear`, {}); 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.system = new SystemAPI(this.api);
this.update = new UpdateAPI(this.api); this.update = new UpdateAPI(this.api);
} }
setAutoUpdate(autoUpdate = true, updateInterval = 1000) { setAutoUpdate(autoUpdate = true, updateInterval = 1000) {
this.updateInterval = updateInterval; this.updateInterval = updateInterval;
if (this.autoUpdate === autoUpdate) return; if (this.autoUpdate === autoUpdate) return;
@ -41,7 +40,6 @@ export default class Doodle3DBox extends EventDispatcher {
return this; return this;
} }
async checkAlive() { async checkAlive() {
const alive = await this.network.alive(); const alive = await this.network.alive();
@ -53,7 +51,6 @@ export default class Doodle3DBox extends EventDispatcher {
this.alive = alive; this.alive = alive;
return alive; return alive;
} }
async sendGCode(gcode) { async sendGCode(gcode) {
const printerState = await this.printer.state(); const printerState = await this.printer.state();
if (printerState.state !== 'idle') { if (printerState.state !== 'idle') {
@ -78,7 +75,6 @@ export default class Doodle3DBox extends EventDispatcher {
lastIndex = index + 1; //skip next \n lastIndex = index + 1; //skip next \n
} }
} }
async _update() { async _update() {
while (this.autoUpdate) { while (this.autoUpdate) {
if (this.alive) { if (this.alive) {
@ -96,7 +92,6 @@ export default class Doodle3DBox extends EventDispatcher {
await sleep(this.updateInterval); await sleep(this.updateInterval);
} }
} }
async _sendBatch(gcode, start) { async _sendBatch(gcode, start) {
try { try {
const response = await this.printer.print(gcode, start, start); const response = await this.printer.print(gcode, start, start);

View File

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