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) { 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

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

View File

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

View File

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

View File

@ -6,18 +6,18 @@ export default class {
} }
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

@ -6,48 +6,48 @@ export default class {
} }
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`);
return true; return true;
} catch(error) { } catch(error) {

View File

@ -6,34 +6,34 @@ export default class {
} }
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 };
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) { 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`, { return rest.post(`${ this.api }sketch`, { data });
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

@ -6,6 +6,6 @@ export default class {
} }
versions () { 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 () { 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`, {});
} }
} }