0
0
mirror of https://github.com/Doodle3D/Doodle3D-API synced 2024-11-14 00:17:55 +01:00

added spaces

This commit is contained in:
casperlamboo 2016-04-21 15:09:49 +02:00
parent cd58c9fbc6
commit 92fc33e2de
10 changed files with 40 additions and 42 deletions

View File

@ -6,14 +6,14 @@ export default class {
}
get (...keys) {
return rest.get(`${this.api}config/?${keys.join('=&')}=`);
return rest.get(`${ this.api }config/?${ keys.join('=&') }=`);
}
getAll () {
return rest.get(`${this.api}config/all`);
return rest.get(`${ this.api }config/all`);
}
set (data) {
return rest.post(`${this.api}config`, data);
return rest.post(`${ this.api }config`, data);
}
}

View File

@ -6,7 +6,7 @@ import PrinterAPI from './printerapi.js';
import SketchAPI from './sketchapi.js';
import SystemAPI from './systemapi.js';
import UpdateAPI from './updateapi.js';
import {sleep} from './utils.js';
import { sleep } from './utils.js';
export default class extends EventDispatcher {
constructor (boxData) {
@ -14,13 +14,13 @@ export default class extends EventDispatcher {
this.boxData = boxData;
this.api = `http://${boxData.localip}/d3dapi/`;
this.api = `http://${ boxData.localip }/d3dapi/`;
this.alive = false;
this.autoUpdate = false;
this.state = {};
this.maxBatchSize = 10*1024;
this.maxBatchSize = 10 * 1024;
this.fullBufferTimeout = 10000;
this.config = new ConfigAPI(this.api);
@ -57,7 +57,7 @@ export default class extends EventDispatcher {
async sendGCode (gcode) {
const printerState = await this.printer.state();
if (printerState.state !== 'idle') {
throw `Cannot print, print state is ${printerState.state}`;
throw `Cannot print, print state is ${ printerState.state }`;
}
if (!gcode.endsWith('\n')) {
@ -98,7 +98,7 @@ export default class extends EventDispatcher {
const response = await this.printer.print(gcode, start, start);
// maybe do something with failing response
console.log(`batch sent: ${index}`, printRequest);
console.log(`batch sent: ${ index }`, printRequest);
} catch(error) {
await sleep(1000);

View File

@ -1,7 +1,7 @@
import * as rest from './restapi.js';
import Doodle3DAPI from './doodle3dapi.js';
import EventDispatcher from 'casperlamboo/EventDispatcher';
import {sleep} from './utils.js';
import { sleep } from './utils.js';
export default class Doodle3DManager extends EventDispatcher {
constructor () {
@ -44,7 +44,7 @@ export default class Doodle3DManager extends EventDispatcher {
async _checkNew () {
let boxes;
try {
boxes = await rest.get(`${this.api}list.php`);
boxes = await rest.get(`${ this.api }list.php`);
} catch(error) {
console.warn('fail connecting to Doodle3D server');
return;

View File

@ -1,4 +1,4 @@
import Doodle3DManager from './doodle3dmanager.js';
import Doodle3DAPI from './doodle3dapi.js';
export {Doodle3DManager, Doodle3DAPI};
export { Doodle3DManager, Doodle3DAPI };

View File

@ -6,18 +6,18 @@ export default class {
}
get () {
return rest.get(`${this.api}info`);
return rest.get(`${ this.api }info`);
}
status () {
return rest.get(`${this.api}info/status`);
return rest.get(`${ this.api }info/status`);
}
downloadLogFiles () {
window.location = `${this.api}info/logfiles`;
window.location = `${ this.api }info/logfiles`;
}
acces () {
return rest.get(`${this.api}info/access`);
return rest.get(`${ this.api }info/access`);
}
}

View File

@ -6,48 +6,48 @@ export default class {
}
scan () {
return rest.get(`${this.api}network/scan`);
return rest.get(`${ this.api }network/scan`);
}
known () {
return rest.get(`${this.api}network/known`);
return rest.get(`${ this.api }network/known`);
}
status () {
return rest.get(`${this.api}network/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);
return rest.post(`${ this.api }network/associate`, data);
}
disassociate () {
//not tested
return rest.post(`${this.api}network/disassociate`, {});
return rest.post(`${ this.api }network/disassociate`, {});
}
openAccesPoint () {
//not tested
return rest.post(`${this.api}network/openap`, {});
return rest.post(`${ this.api }network/openap`, {});
}
remove (ssid) {
return rest.post(`${this.api}network/remove`, {
return rest.post(`${ this.api }network/remove`, {
'ssid': ssid
});
}
signin () {
return rest.get(`${this.api}network/signin`);
return rest.get(`${ this.api }network/signin`);
}
async alive () {
try {
await rest.get(`${this.api}network/alive`);
await rest.get(`${ this.api }network/alive`);
return true;
} catch(error) {

View File

@ -6,34 +6,34 @@ export default class {
}
temperature () {
return rest.get(`${this.api}printer/temperature`);
return rest.get(`${ this.api }printer/temperature`);
}
progress () {
return rest.get(`${this.api}printer/progress`);
return rest.get(`${ this.api }printer/progress`);
}
state () {
return rest.get(`${this.api}printer/state`);
return rest.get(`${ this.api }printer/state`);
}
listAll () {
return rest.get(`${this.api}printer/listall`);
return rest.get(`${ this.api }printer/listall`);
}
heatup () {
return rest.post(`${this.api}printer/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);
return rest.post(`${ this.api }printer/print`, data);
}
stop (gcode = '') {
const data = { gcode };
return rest.post(`${this.api}printer/stop`, data);
return rest.post(`${ this.api }printer/stop`, data);
}
}

View File

@ -6,20 +6,18 @@ export default class {
}
getSketch (id) {
return rest.get(`${this.api}sketch/?id=${id}`);
return rest.get(`${ this.api }sketch/?id=${ id }`);
}
set (data = '') {
return rest.post(`${this.api}sketch`, {
data
});
return rest.post(`${ this.api }sketch`, { data });
}
status () {
return rest.get(`${this.api}sketch/status`);
return rest.get(`${ this.api }sketch/status`);
}
clear () {
return rest.post(`${this.api}sketch/clear`);
return rest.post(`${ this.api }sketch/clear`);
}
}

View File

@ -6,6 +6,6 @@ export default class {
}
versions () {
return rest.get(`${this.api}system/fwversions`);
return rest.get(`${ this.api }system/fwversions`);
}
}

View File

@ -6,24 +6,24 @@ export default class {
}
status () {
return rest.get(`${this.api}update/status`);
return rest.get(`${ this.api }update/status`);
}
download () {
//not tested
return rest.post(`${this.api}update/download`, {});
return rest.post(`${ this.api }update/download`, {});
}
install () {
//not tested
return rest.post(`${this.api}update/install`, {});
return rest.post(`${ this.api }update/install`, {});
}
clear () {
//not tested
return rest.post(`${this.api}update/clear`, {});
return rest.post(`${ this.api }update/clear`, {});
}
}