Chore: make notification center UI

Chore: fiatBalancesNotify refactor

Chore: removed now-unused code in some files

Feat: change column "detail" in database to use jsonb

Chore: add notification center background and button

Chore: notifications screen scaffolding

Fix: change position of notification UI

Feat: join backend and frontend

Feat: notification icons and machine names

Feat: add clear all button, stripe overlay on invalid notification

Fix: rework notification styles

Feat: use popper to render notifications

Feat: make notification center UI

Fix: fix css on notification center

Fix: fix invalidateNotification

Chore: apply PR requested changes

Fix: PR fixes

Fix: make toggleable body/root styles be handled by react

Chore: delete old notifier file

Fix: undo variable name changes for cryptobalance notifs
This commit is contained in:
Cesar 2020-12-17 22:18:35 +00:00 committed by Josh Harvey
parent 2a9e8dadba
commit c457faab40
37 changed files with 1337 additions and 1332 deletions

View file

@ -1,5 +1,5 @@
const _ = require('lodash/fp')
const utils = require("./utils")
const utils = require('./utils')
const email = require('../email')
@ -12,61 +12,47 @@ const {
LOW_CASH_OUT
} = require('./codes')
function alertSubject(alertRec, config) {
function alertSubject (alertRec, config) {
let alerts = []
if (config.balance) {
alerts = _.concat(alerts, alertRec.general)
}
_.keys(alertRec.devices).forEach(function (device) {
if (config.balance) {
alerts = _.concat(alerts, alertRec.devices[device].balanceAlerts)
}
if (config.errors) {
alerts = _.concat(alerts, alertRec.devices[device].deviceAlerts)
}
})
_.forEach(device => {
alerts = _.concat(alerts, utils.deviceAlerts(config, alertRec, device))
}, _.keys(alertRec.devices))
if (alerts.length === 0) return null
const alertTypes = _.map(codeDisplay, _.uniq(_.map('code', alerts))).sort()
const alertTypes = _.flow(_.map('code'), _.uniq, _.map(utils.codeDisplay), _.sortBy(o => o))(alerts)
return '[Lamassu] Errors reported: ' + alertTypes.join(', ')
}
function printEmailAlerts(alertRec, config) {
function printEmailAlerts (alertRec, config) {
let body = 'Errors were reported by your Lamassu Machines.\n'
if (config.balance && alertRec.general.length !== 0) {
body = body + '\nGeneral errors:\n'
body = body + emailAlerts(alertRec.general) + '\n'
body += '\nGeneral errors:\n'
body += emailAlerts(alertRec.general) + '\n'
}
_.keys(alertRec.devices).forEach(function (device) {
_.forEach(device => {
const deviceName = alertRec.deviceNames[device]
body = body + '\nErrors for ' + deviceName + ':\n'
body += '\nErrors for ' + deviceName + ':\n'
let alerts = []
if (config.balance) {
alerts = _.concat(alerts, alertRec.devices[device].balanceAlerts)
}
if (config.errors) {
alerts = _.concat(alerts, alertRec.devices[device].deviceAlerts)
}
body = body + emailAlerts(alerts)
})
const alerts = utils.deviceAlerts(config, alertRec, device)
body += emailAlerts(alerts)
}, _.keys(alertRec.devices))
return body
}
function emailAlerts(alerts) {
return alerts.map(emailAlert).join('\n') + '\n'
function emailAlerts (alerts) {
return _.join('\n', _.map(emailAlert, alerts)) + '\n'
}
function emailAlert(alert) {
function emailAlert (alert) {
switch (alert.code) {
case PING:
if (alert.age) {
@ -98,5 +84,4 @@ function emailAlert(alert) {
const sendMessage = email.sendMessage
module.exports = { alertSubject, printEmailAlerts, sendMessage }