feat: add stacker counter field to the machine
feat: use the stacker amount to properly render the cash cassettes table feat: add stacker notifications to the plugins backend
This commit is contained in:
parent
211c4b1ea7
commit
2638bd1717
14 changed files with 519 additions and 138 deletions
36
bin/lamassu-update-stackers
Normal file
36
bin/lamassu-update-stackers
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
require('../lib/environment-helper')
|
||||
|
||||
const _ = require('lodash')
|
||||
const db = require('../lib/db')
|
||||
|
||||
if (process.argv.length !== 4) {
|
||||
console.log('Usage: lamassu-update-stackers <device_id> <number_of_stackers>')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (!_.isFinite(parseInt(process.argv[3]))) {
|
||||
console.log('Error: <number_of_stackers> is not a valid number (%s)', err)
|
||||
process.exit(3)
|
||||
}
|
||||
|
||||
if (parseInt(process.argv[3]) > 3 || parseInt(process.argv[3]) < 1) {
|
||||
console.log('Error: <number_of_stackers> is out of range. Should be a number between 1 and 3')
|
||||
process.exit(3)
|
||||
}
|
||||
|
||||
const deviceId = process.argv[2]
|
||||
const numberOfStackers = parseInt(process.argv[3])
|
||||
|
||||
const query = `UPDATE devices SET number_of_stackers = $1 WHERE device_id = $2`
|
||||
|
||||
db.none(query, [numberOfStackers, deviceId])
|
||||
.then(() => {
|
||||
console.log('Success! Device %s updated to %s stackers', deviceId, numberOfStackers)
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('Error: %s', err)
|
||||
process.exit(3)
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue