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" )
|
[ ( "action", E.string "reboot" )
|
||||||
, ( "deviceId", E.string machine.deviceId )
|
, ( "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
|
= ResetCashOutBills Machine
|
||||||
| UnpairMachine Machine
|
| UnpairMachine Machine
|
||||||
| RebootMachine Machine
|
| RebootMachine Machine
|
||||||
|
| RestartServices Machine
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,9 @@ rowView machine =
|
||||||
[ td []
|
[ td []
|
||||||
[ button [ class [ C.TableButton ], onClick (Submit (UnpairMachine machine)) ] [ text "Unpair" ] ]
|
[ button [ class [ C.TableButton ], onClick (Submit (UnpairMachine machine)) ] [ text "Unpair" ] ]
|
||||||
, td []
|
, 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
|
, resetBills
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,11 +71,16 @@ function reboot (rec) {
|
||||||
return axios.post(`http://localhost:3030/reboot?device_id=${rec.deviceId}`)
|
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) {
|
function setMachine (rec) {
|
||||||
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)
|
case 'reboot': return reboot(rec)
|
||||||
|
case 'restartServices': return restartServices(rec)
|
||||||
default: throw new Error('No such action: ' + rec.action)
|
default: throw new Error('No such action: ' + rec.action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ const REQUEST_TTL = 3 * 60 * 1000
|
||||||
|
|
||||||
const pids = {}
|
const pids = {}
|
||||||
const reboots = {}
|
const reboots = {}
|
||||||
|
const restartServicesMap = {}
|
||||||
|
|
||||||
const devMode = argv.dev || options.http
|
const devMode = argv.dev || options.http
|
||||||
|
|
||||||
|
|
@ -53,6 +54,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
|
||||||
|
const restartServices = pid && restartServicesMap[deviceId] && restartServicesMap[deviceId] === pid
|
||||||
const langs = config.machineLanguages
|
const langs = config.machineLanguages
|
||||||
|
|
||||||
const locale = {
|
const locale = {
|
||||||
|
|
@ -90,6 +92,7 @@ function poll (req, res, next) {
|
||||||
twoWayMode: config.cashOutEnabled,
|
twoWayMode: config.cashOutEnabled,
|
||||||
zeroConfLimit: config.zeroConfLimit,
|
zeroConfLimit: config.zeroConfLimit,
|
||||||
reboot,
|
reboot,
|
||||||
|
restartServices,
|
||||||
hasLightning,
|
hasLightning,
|
||||||
operatorInfo: {
|
operatorInfo: {
|
||||||
active: config.operatorInfoActive,
|
active: config.operatorInfoActive,
|
||||||
|
|
@ -399,6 +402,18 @@ localApp.post('/reboot', (req, res) => {
|
||||||
res.sendStatus(200)
|
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) => {
|
localApp.post('/dbChange', (req, res, next) => {
|
||||||
return settingsLoader.loadLatest()
|
return settingsLoader.loadLatest()
|
||||||
.then(poller.reload)
|
.then(poller.reload)
|
||||||
|
|
|
||||||
|
|
@ -33858,6 +33858,9 @@ var _user$project$MaintenanceMachines_Types$Machine = F7(
|
||||||
function (a, b, c, d, e, f, g) {
|
function (a, b, c, d, e, f, g) {
|
||||||
return {deviceId: a, name: b, cashbox: c, cassette1: d, cassette2: e, paired: f, cashOut: 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) {
|
var _user$project$MaintenanceMachines_Types$RebootMachine = function (a) {
|
||||||
return {ctor: 'RebootMachine', _0: a};
|
return {ctor: 'RebootMachine', _0: a};
|
||||||
};
|
};
|
||||||
|
|
@ -38033,7 +38036,7 @@ var _user$project$MaintenanceMachines_Rest$encodeAction = function (action) {
|
||||||
_1: {ctor: '[]'}
|
_1: {ctor: '[]'}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
default:
|
case 'RebootMachine':
|
||||||
return _elm_lang$core$Json_Encode$object(
|
return _elm_lang$core$Json_Encode$object(
|
||||||
{
|
{
|
||||||
ctor: '::',
|
ctor: '::',
|
||||||
|
|
@ -38052,6 +38055,25 @@ var _user$project$MaintenanceMachines_Rest$encodeAction = function (action) {
|
||||||
_1: {ctor: '[]'}
|
_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(
|
var _user$project$MaintenanceMachines_Rest$machineDecoder = A8(
|
||||||
|
|
@ -38428,15 +38450,48 @@ var _user$project$MaintenanceMachines_View$rowView = function (machine) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ctor: '::',
|
ctor: '::',
|
||||||
_0: _elm_lang$html$Html$text('Reboot'),
|
_0: _elm_lang$html$Html$text('Reboot OS'),
|
||||||
_1: {ctor: '[]'}
|
_1: {ctor: '[]'}
|
||||||
}),
|
}),
|
||||||
_1: {ctor: '[]'}
|
_1: {ctor: '[]'}
|
||||||
}),
|
}),
|
||||||
_1: {
|
_1: {
|
||||||
ctor: '::',
|
ctor: '::',
|
||||||
_0: resetBills,
|
_0: A2(
|
||||||
_1: {ctor: '[]'}
|
_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: '[]'}
|
||||||
|
}),
|
||||||
|
_1: {
|
||||||
|
ctor: '::',
|
||||||
|
_0: resetBills,
|
||||||
|
_1: {ctor: '[]'}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue