Add new reboot option and restart lamassu-browser
This commit is contained in:
parent
371454b6d4
commit
9f8693a33e
6 changed files with 89 additions and 5 deletions
|
|
@ -71,3 +71,9 @@ encodeAction action =
|
|||
[ ( "action", E.string "reboot" )
|
||||
, ( "deviceId", E.string machine.deviceId )
|
||||
]
|
||||
|
||||
RestartServices machine ->
|
||||
E.object
|
||||
[ ( "action", E.string "restartServices" )
|
||||
, ( "deviceId", E.string machine.deviceId )
|
||||
]
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ type MachineAction
|
|||
= ResetCashOutBills Machine
|
||||
| UnpairMachine Machine
|
||||
| RebootMachine Machine
|
||||
| RestartServices Machine
|
||||
|
||||
|
||||
type Msg
|
||||
|
|
|
|||
|
|
@ -36,7 +36,9 @@ rowView machine =
|
|||
[ td []
|
||||
[ button [ class [ C.TableButton ], onClick (Submit (UnpairMachine machine)) ] [ text "Unpair" ] ]
|
||||
, td []
|
||||
[ button [ class [ C.TableButton ], onClick (Submit (RebootMachine machine)) ] [ text "Reboot" ] ]
|
||||
[ button [ class [ C.TableButton ], onClick (Submit (RebootMachine machine)) ] [ text "Reboot OS" ] ]
|
||||
, td []
|
||||
[ button [ class [ C.TableButton ], onClick (Submit (RestartServices machine)) ] [ text "Restart Services" ] ]
|
||||
, resetBills
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -71,11 +71,16 @@ function reboot (rec) {
|
|||
return axios.post(`http://localhost:3030/reboot?device_id=${rec.deviceId}`)
|
||||
}
|
||||
|
||||
function restartServices (rec) {
|
||||
return axios.post(`http://localhost:3030/restartServices?device_id=${rec.deviceId}`)
|
||||
}
|
||||
|
||||
function setMachine (rec) {
|
||||
switch (rec.action) {
|
||||
case 'resetCashOutBills': return resetCashOutBills(rec)
|
||||
case 'unpair': return unpair(rec)
|
||||
case 'reboot': return reboot(rec)
|
||||
case 'restartServices': return restartServices(rec)
|
||||
default: throw new Error('No such action: ' + rec.action)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ const REQUEST_TTL = 3 * 60 * 1000
|
|||
|
||||
const pids = {}
|
||||
const reboots = {}
|
||||
const restartServicesMap = {}
|
||||
|
||||
const devMode = argv.dev || options.http
|
||||
|
||||
|
|
@ -53,6 +54,7 @@ function poll (req, res, next) {
|
|||
const cassettes = results.cassettes
|
||||
|
||||
const reboot = pid && reboots[deviceId] && reboots[deviceId] === pid
|
||||
const restartServices = pid && restartServicesMap[deviceId] && restartServicesMap[deviceId] === pid
|
||||
const langs = config.machineLanguages
|
||||
|
||||
const locale = {
|
||||
|
|
@ -90,6 +92,7 @@ function poll (req, res, next) {
|
|||
twoWayMode: config.cashOutEnabled,
|
||||
zeroConfLimit: config.zeroConfLimit,
|
||||
reboot,
|
||||
restartServices,
|
||||
hasLightning,
|
||||
operatorInfo: {
|
||||
active: config.operatorInfoActive,
|
||||
|
|
@ -399,6 +402,18 @@ localApp.post('/reboot', (req, res) => {
|
|||
res.sendStatus(200)
|
||||
})
|
||||
|
||||
localApp.post('/restartServices', (req, res) => {
|
||||
const deviceId = req.query.device_id
|
||||
const pid = pids[deviceId] && pids[deviceId].pid
|
||||
|
||||
if (!deviceId || !pid) {
|
||||
return res.sendStatus(400)
|
||||
}
|
||||
|
||||
restartServicesMap[deviceId] = pid
|
||||
res.sendStatus(200)
|
||||
})
|
||||
|
||||
localApp.post('/dbChange', (req, res, next) => {
|
||||
return settingsLoader.loadLatest()
|
||||
.then(poller.reload)
|
||||
|
|
|
|||
|
|
@ -33858,6 +33858,9 @@ var _user$project$MaintenanceMachines_Types$Machine = F7(
|
|||
function (a, b, c, d, e, f, g) {
|
||||
return {deviceId: a, name: b, cashbox: c, cassette1: d, cassette2: e, paired: f, cashOut: g};
|
||||
});
|
||||
var _user$project$MaintenanceMachines_Types$RestartServices = function (a) {
|
||||
return {ctor: 'RestartServices', _0: a};
|
||||
};
|
||||
var _user$project$MaintenanceMachines_Types$RebootMachine = function (a) {
|
||||
return {ctor: 'RebootMachine', _0: a};
|
||||
};
|
||||
|
|
@ -38033,7 +38036,7 @@ var _user$project$MaintenanceMachines_Rest$encodeAction = function (action) {
|
|||
_1: {ctor: '[]'}
|
||||
}
|
||||
});
|
||||
default:
|
||||
case 'RebootMachine':
|
||||
return _elm_lang$core$Json_Encode$object(
|
||||
{
|
||||
ctor: '::',
|
||||
|
|
@ -38052,6 +38055,25 @@ var _user$project$MaintenanceMachines_Rest$encodeAction = function (action) {
|
|||
_1: {ctor: '[]'}
|
||||
}
|
||||
});
|
||||
default:
|
||||
return _elm_lang$core$Json_Encode$object(
|
||||
{
|
||||
ctor: '::',
|
||||
_0: {
|
||||
ctor: '_Tuple2',
|
||||
_0: 'action',
|
||||
_1: _elm_lang$core$Json_Encode$string('restartServices')
|
||||
},
|
||||
_1: {
|
||||
ctor: '::',
|
||||
_0: {
|
||||
ctor: '_Tuple2',
|
||||
_0: 'deviceId',
|
||||
_1: _elm_lang$core$Json_Encode$string(_p0._0.deviceId)
|
||||
},
|
||||
_1: {ctor: '[]'}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
var _user$project$MaintenanceMachines_Rest$machineDecoder = A8(
|
||||
|
|
@ -38428,7 +38450,39 @@ var _user$project$MaintenanceMachines_View$rowView = function (machine) {
|
|||
},
|
||||
{
|
||||
ctor: '::',
|
||||
_0: _elm_lang$html$Html$text('Reboot'),
|
||||
_0: _elm_lang$html$Html$text('Reboot OS'),
|
||||
_1: {ctor: '[]'}
|
||||
}),
|
||||
_1: {ctor: '[]'}
|
||||
}),
|
||||
_1: {
|
||||
ctor: '::',
|
||||
_0: A2(
|
||||
_elm_lang$html$Html$td,
|
||||
{ctor: '[]'},
|
||||
{
|
||||
ctor: '::',
|
||||
_0: A2(
|
||||
_elm_lang$html$Html$button,
|
||||
{
|
||||
ctor: '::',
|
||||
_0: _user$project$Css_Admin$class(
|
||||
{
|
||||
ctor: '::',
|
||||
_0: _user$project$Css_Classes$TableButton,
|
||||
_1: {ctor: '[]'}
|
||||
}),
|
||||
_1: {
|
||||
ctor: '::',
|
||||
_0: _elm_lang$html$Html_Events$onClick(
|
||||
_user$project$MaintenanceMachines_Types$Submit(
|
||||
_user$project$MaintenanceMachines_Types$RestartServices(machine))),
|
||||
_1: {ctor: '[]'}
|
||||
}
|
||||
},
|
||||
{
|
||||
ctor: '::',
|
||||
_0: _elm_lang$html$Html$text('Restart Services'),
|
||||
_1: {ctor: '[]'}
|
||||
}),
|
||||
_1: {ctor: '[]'}
|
||||
|
|
@ -38439,6 +38493,7 @@ var _user$project$MaintenanceMachines_View$rowView = function (machine) {
|
|||
_1: {ctor: '[]'}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return A2(
|
||||
_elm_lang$html$Html$tr,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue