support reboot
This commit is contained in:
parent
4fff644a1f
commit
1ad90b515e
3 changed files with 126 additions and 476 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
const _ = require('lodash/fp')
|
const _ = require('lodash/fp')
|
||||||
|
const axios = require('axios')
|
||||||
|
|
||||||
const db = require('./db')
|
const db = require('./db')
|
||||||
const pairing = require('./pairing')
|
const pairing = require('./pairing')
|
||||||
|
|
@ -48,10 +49,16 @@ function unpair (rec) {
|
||||||
return pairing.unpair(rec.deviceId)
|
return pairing.unpair(rec.deviceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reboot (rec) {
|
||||||
|
return axios.post(`http://localhost:3030/reboot?device_id=${rec.deviceId}`)
|
||||||
|
}
|
||||||
|
|
||||||
function setMachine (rec) {
|
function setMachine (rec) {
|
||||||
|
console.log('DEBUG100: %j', rec.action)
|
||||||
switch (rec.action) {
|
switch (rec.action) {
|
||||||
case 'resetCashOutBills': return resetCashOutBills(rec)
|
case 'resetCashOutBills': return resetCashOutBills(rec)
|
||||||
case 'unpair': return unpair(rec)
|
case 'unpair': return unpair(rec)
|
||||||
|
case 'reboot': return reboot(rec)
|
||||||
default: throw new Error('No such action: ' + rec.action)
|
default: throw new Error('No such action: ' + rec.action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ function poll (req, res, next) {
|
||||||
const cassettes = results.cassettes
|
const cassettes = results.cassettes
|
||||||
|
|
||||||
const reboot = pid && reboots[deviceId] && reboots[deviceId] === pid
|
const reboot = pid && reboots[deviceId] && reboots[deviceId] === pid
|
||||||
|
console.log('DEBUG104: %j', {pid, reboot, reboots, pids, deviceId})
|
||||||
const langs = config.machineLanguages
|
const langs = config.machineLanguages
|
||||||
|
|
||||||
const locale = {
|
const locale = {
|
||||||
|
|
@ -274,8 +275,8 @@ localApp.get('/pid', (req, res) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
localApp.post('/reboot', (req, res) => {
|
localApp.post('/reboot', (req, res) => {
|
||||||
const pid = req.body.pid
|
const deviceId = req.query.device_id
|
||||||
const deviceId = req.body.deviceId
|
const pid = pids[deviceId] && pids[deviceId].pid
|
||||||
|
|
||||||
if (!deviceId || !pid) {
|
if (!deviceId || !pid) {
|
||||||
return res.sendStatus(400)
|
return res.sendStatus(400)
|
||||||
|
|
|
||||||
590
public/elm.js
590
public/elm.js
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue