fix: CSS clean up due to some orphan styling

This commit is contained in:
João Leal 2021-07-08 16:35:39 +01:00 committed by Josh Harvey
parent 53431a9fd9
commit 735c46ed55
4 changed files with 34 additions and 167 deletions

View file

@ -10,6 +10,10 @@ const settingsLoader = require('./new-settings-loader')
const notifierUtils = require('./notifier/utils') const notifierUtils = require('./notifier/utils')
const notifierQueries = require('./notifier/queries') const notifierQueries = require('./notifier/queries')
const fullyFunctionalStatus = { label: 'Fully functional', type: 'success' }
const unresponsiveStatus = { label: 'Unresponsive', type: 'error' }
const stuckStatus = { label: 'Stuck', type: 'error' }
function getMachines () { function getMachines () {
return db.any('SELECT * FROM devices WHERE display=TRUE ORDER BY created') return db.any('SELECT * FROM devices WHERE display=TRUE ORDER BY created')
.then(rr => rr.map(r => ({ .then(rr => rr.map(r => ({
@ -34,40 +38,38 @@ function getConfig (defaultConfig) {
return settingsLoader.loadLatest().config return settingsLoader.loadLatest().config
} }
function getMachineNames (config) { const getStatus = (ping, stuck) => {
const fullyFunctionalStatus = { label: 'Fully functional', type: 'success' } if (ping && ping.age) return unresponsiveStatus
const unresponsiveStatus = { label: 'Unresponsive', type: 'error' }
const stuckStatus = { label: 'Stuck', type: 'error' }
if (stuck && stuck.age) return stuckStatus
return fullyFunctionalStatus
}
function addName (pings, events, config) {
return machine => {
const cashOutConfig = configManager.getCashOut(machine.deviceId, config)
const cashOut = !!cashOutConfig.active
const statuses = [
getStatus(
_.first(pings[machine.deviceId]),
_.first(checkStuckScreen(events, machine.name))
)
]
return _.assign(machine, { cashOut, statuses })
}
}
function getMachineNames (config) {
return Promise.all([getMachines(), getConfig(config)]) return Promise.all([getMachines(), getConfig(config)])
.then(([machines, config]) => Promise.all( .then(([machines, config]) => Promise.all(
[machines, checkPings(machines), dbm.machineEvents(), config] [machines, checkPings(machines), dbm.machineEvents(), config]
)) ))
.then(([machines, pings, events, config]) => { .then(([machines, pings, events, config]) => {
const getStatus = (ping, stuck) => { return machines.map(addName(pings, events, config))
if (ping && ping.age) return unresponsiveStatus
if (stuck && stuck.age) return stuckStatus
return fullyFunctionalStatus
}
const addName = r => {
const cashOutConfig = configManager.getCashOut(r.deviceId, config)
const cashOut = !!cashOutConfig.active
const statuses = [
getStatus(
_.first(pings[r.deviceId]),
_.first(checkStuckScreen(events, r.name))
)
]
return _.assign(r, { cashOut, statuses })
}
return _.map(addName, machines)
}) })
} }
@ -88,10 +90,6 @@ function getMachineName (machineId) {
} }
function getMachine (machineId, config) { function getMachine (machineId, config) {
const fullyFunctionalStatus = { label: 'Fully functional', type: 'success' }
const unresponsiveStatus = { label: 'Unresponsive', type: 'error' }
const stuckStatus = { label: 'Stuck', type: 'error' }
const sql = 'SELECT * FROM devices WHERE device_id=$1' const sql = 'SELECT * FROM devices WHERE device_id=$1'
const queryMachine = db.oneOrNone(sql, [machineId]).then(r => ({ const queryMachine = db.oneOrNone(sql, [machineId]).then(r => ({
deviceId: r.device_id, deviceId: r.device_id,
@ -109,31 +107,8 @@ function getMachine (machineId, config) {
return Promise.all([queryMachine, dbm.machineEvents(), config]) return Promise.all([queryMachine, dbm.machineEvents(), config])
.then(([machine, events, config]) => { .then(([machine, events, config]) => {
const pings = checkPings([machine]) const pings = checkPings([machine])
const getStatus = (ping, stuck) => {
if (ping && ping.age) return unresponsiveStatus
if (stuck && stuck.age) return stuckStatus return [machine].map(addName(pings, events, config))[0]
return fullyFunctionalStatus
}
const addName = r => {
const cashOutConfig = configManager.getCashOut(r.deviceId, config)
const cashOut = !!cashOutConfig.active
const statuses = [
getStatus(
_.first(pings[r.deviceId]),
_.first(checkStuckScreen(events, r.name))
)
]
return _.assign(r, { cashOut, statuses })
}
return addName(machine)
}) })
} }

View file

@ -1,24 +1,9 @@
import { fade } from '@material-ui/core/styles/colorManipulator'
import typographyStyles from 'src/components/typography/styles' import typographyStyles from 'src/components/typography/styles'
import { import { offColor, spacer, errorColor } from 'src/styling/variables'
offColor,
spacer,
comet,
primaryColor,
fontSize4,
errorColor
} from 'src/styling/variables'
const { label1 } = typographyStyles const { label1 } = typographyStyles
const machineActionsStyles = { const machineActionsStyles = {
colDivider: {
width: 1,
margin: [[spacer * 2, spacer * 4]],
backgroundColor: comet,
border: 'none'
},
label: { label: {
extend: label1, extend: label1,
color: offColor, color: offColor,
@ -33,44 +18,10 @@ const machineActionsStyles = {
flexWrap: 'wrap', flexWrap: 'wrap',
justifyContent: 'start' justifyContent: 'start'
}, },
wrapper: {
display: 'flex',
marginTop: 12,
marginBottom: 16,
fontSize: fontSize4
},
row: {
display: 'flex',
flexDirection: 'row'
},
list: {
padding: 0,
margin: 0,
listStyle: 'none'
},
item: {
height: spacer * 3,
marginBottom: spacer * 1.5
},
link: {
color: primaryColor,
textDecoration: 'none'
},
divider: {
margin: '0 1rem'
},
mr: { mr: {
marginRight: spacer, marginRight: spacer,
marginBottom: spacer marginBottom: spacer
}, },
separator: {
width: 1,
height: 170,
zIndex: 1,
marginRight: 60,
marginLeft: 'auto',
background: fade(comet, 0.5)
},
warning: { warning: {
color: errorColor color: errorColor
} }

View file

@ -1,10 +1,4 @@
import { import { spacer, comet } from 'src/styling/variables'
spacer,
fontPrimary,
primaryColor,
white,
comet
} from 'src/styling/variables'
const styles = { const styles = {
grid: { grid: {
@ -18,16 +12,6 @@ const styles = {
marginLeft: spacer * 6, marginLeft: spacer * 6,
maxWidth: 900 maxWidth: 900
}, },
footer: {
margin: [['auto', 0, spacer * 3, 'auto']]
},
modalTitle: {
lineHeight: '120%',
color: primaryColor,
fontSize: 14,
fontFamily: fontPrimary,
fontWeight: 900
},
subtitle: { subtitle: {
display: 'flex', display: 'flex',
justifyContent: 'space-between', justifyContent: 'space-between',
@ -39,15 +23,6 @@ const styles = {
color: comet, color: comet,
marginTop: 0 marginTop: 0
}, },
white: {
color: white
},
deleteButton: {
paddingLeft: 13
},
addressRow: {
marginLeft: 8
},
row: { row: {
display: 'flex', display: 'flex',
flexDirection: 'row', flexDirection: 'row',
@ -60,16 +35,10 @@ const styles = {
detailItem: { detailItem: {
marginBottom: spacer * 4 marginBottom: spacer * 4
}, },
transactionsItem: {
marginBottom: -spacer * 4
},
actionButtonsContainer: { actionButtonsContainer: {
display: 'flex', display: 'flex',
flexDirection: 'row' flexDirection: 'row'
}, },
actionButton: {
marginRight: 8
},
breadcrumbsContainer: { breadcrumbsContainer: {
marginTop: 32 marginTop: 32
}, },

View file

@ -4,29 +4,10 @@ import {
detailsRowStyles, detailsRowStyles,
labelStyles labelStyles
} from 'src/pages/Transactions/Transactions.styles' } from 'src/pages/Transactions/Transactions.styles'
import { import { spacer, comet, primaryColor, fontSize4 } from 'src/styling/variables'
spacer,
comet,
primaryColor,
fontSize4,
errorColor
} from 'src/styling/variables'
const machineDetailsStyles = { const machineDetailsStyles = {
...detailsRowStyles, ...detailsRowStyles,
colDivider: {
width: 1,
margin: [[spacer * 2, spacer * 4]],
backgroundColor: comet,
border: 'none'
},
inlineChip: {
marginInlineEnd: '0.25em'
},
stack: {
display: 'flex',
flexDirection: 'row'
},
wrapper: { wrapper: {
display: 'flex', display: 'flex',
// marginTop: 24, // marginTop: 24,
@ -53,12 +34,6 @@ const machineDetailsStyles = {
color: primaryColor, color: primaryColor,
textDecoration: 'none' textDecoration: 'none'
}, },
divider: {
margin: '0 1rem'
},
mr: {
marginRight: spacer
},
separator: { separator: {
width: 1, width: 1,
height: 170, height: 170,
@ -66,9 +41,6 @@ const machineDetailsStyles = {
marginRight: 60, marginRight: 60,
marginLeft: 'auto', marginLeft: 'auto',
background: fade(comet, 0.5) background: fade(comet, 0.5)
},
warning: {
color: errorColor
} }
} }