fix: add timezone to specific tx logs

feat: pass timezone to details row
This commit is contained in:
Sérgio Salgado 2021-06-27 16:56:03 +01:00 committed by Josh Harvey
parent b5e35b82c2
commit 4e88c995d3
6 changed files with 34 additions and 18 deletions

View file

@ -10,7 +10,7 @@ const resolvers = {
logs.simpleGetMachineLogs(deviceId, from, until, limit, offset), logs.simpleGetMachineLogs(deviceId, from, until, limit, offset),
machineLogsCsv: (...[, { deviceId, from, until, limit, offset, timezone }]) => machineLogsCsv: (...[, { deviceId, from, until, limit, offset, timezone }]) =>
logs.simpleGetMachineLogs(deviceId, from, until, limit, offset) logs.simpleGetMachineLogs(deviceId, from, until, limit, offset)
.then(res => parseAsync(dateFormat(timezone, res))), .then(res => parseAsync(logs.logDateFormat(timezone, res, ['timestamp']))),
serverLogs: (...[, { from, until, limit, offset }]) => serverLogs: (...[, { from, until, limit, offset }]) =>
serverLogs.getServerLogs(from, until, limit, offset), serverLogs.getServerLogs(from, until, limit, offset),
serverLogsCsv: (...[, { from, until, limit, offset, timezone }]) => serverLogsCsv: (...[, { from, until, limit, offset, timezone }]) =>

View file

@ -32,11 +32,15 @@ const resolvers = {
transactions.batch(from, until, limit, offset, deviceId, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status), transactions.batch(from, until, limit, offset, deviceId, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status),
transactionsCsv: (...[, { from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, timezone }]) => transactionsCsv: (...[, { from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, timezone }]) =>
transactions.batch(from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status) transactions.batch(from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status)
.then(data => parseAsync(data, { fields: tx_logFields, transforms: logDateFormat(timezone, data, ['created', 'sendTime']) })), .then(data => parseAsync(logDateFormat(timezone, data, ['created', 'sendTime']), { fields: txLogFields })),
transactionCsv: (...[, { id, txClass }]) => transactionCsv: (...[, { id, txClass, timezone }]) =>
transactions.getTx(id, txClass).then(data => parseAsync(data)), transactions.getTx(id, txClass).then(data =>
txAssociatedDataCsv: (...[, { id, txClass }]) => parseAsync(logDateFormat(timezone, [data], ['created', 'sendTime']))
transactions.getTxAssociatedData(id, txClass).then(data => parseAsync(data)), ),
txAssociatedDataCsv: (...[, { id, txClass, timezone }]) =>
transactions.getTxAssociatedData(id, txClass).then(data =>
parseAsync(logDateFormat(timezone, data, ['created']))
),
transactionFilters: () => filters.transaction() transactionFilters: () => filters.transaction()
} }
} }

View file

@ -52,9 +52,9 @@ const typeDef = gql`
type Query { type Query {
transactions(from: Date, until: Date, limit: Int, offset: Int, deviceId: ID, txClass: String, machineName: String, customerName: String, fiatCode: String, cryptoCode: String, toAddress: String, status: String): [Transaction] @auth transactions(from: Date, until: Date, limit: Int, offset: Int, deviceId: ID, txClass: String, machineName: String, customerName: String, fiatCode: String, cryptoCode: String, toAddress: String, status: String): [Transaction] @auth
transactionsCsv(from: Date, until: Date, limit: Int, offset: Int, txClass: String, machineName: String, customerName: String, fiatCode: String, cryptoCode: String, toAddress: String, status: String): String @auth transactionsCsv(from: Date, until: Date, limit: Int, offset: Int, txClass: String, machineName: String, customerName: String, fiatCode: String, cryptoCode: String, toAddress: String, status: String, timezone: String): String @auth
transactionCsv(id: ID, txClass: String): String @auth transactionCsv(id: ID, txClass: String, timezone: String): String @auth
txAssociatedDataCsv(id: ID, txClass: String): String @auth txAssociatedDataCsv(id: ID, txClass: String, timezone: String): String @auth
transactionFilters: [Filter] @auth transactionFilters: [Filter] @auth
} }
` `

View file

@ -37,7 +37,8 @@ const Row = ({
expWidth, expWidth,
expandable, expandable,
onClick, onClick,
size size,
...props
}) => { }) => {
const classes = useStyles() const classes = useStyles()
@ -80,7 +81,7 @@ const Row = ({
<div className={classes.after}> <div className={classes.after}>
<Tr className={classnames({ [classes.expanded]: expanded })}> <Tr className={classnames({ [classes.expanded]: expanded })}>
<Td width={width}> <Td width={width}>
<Details it={data} /> <Details it={data} timezone={props.timezone} />
</Td> </Td>
</Tr> </Tr>
</div> </div>
@ -153,6 +154,7 @@ const DataTable = ({
expandRow={expandRow} expandRow={expandRow}
expandable={expandable} expandable={expandable}
onClick={onClick} onClick={onClick}
timezone={props.timezone}
/> />
</div> </div>
)} )}

View file

@ -39,16 +39,23 @@ const TX_SUMMARY = gql`
$from: DateTime $from: DateTime
$until: DateTime $until: DateTime
$txClass: String $txClass: String
$timezone: String
) { ) {
serverLogsCsv(limit: $limit, from: $from, until: $until) serverLogsCsv(
limit: $limit
from: $from
until: $until
timezone: $timezone
)
machineLogsCsv( machineLogsCsv(
deviceId: $deviceId deviceId: $deviceId
limit: $limit limit: $limit
from: $from from: $from
until: $until until: $until
timezone: $timezone
) )
transactionCsv(id: $txId, txClass: $txClass) transactionCsv(id: $txId, txClass: $txClass, timezone: $timezone)
txAssociatedDataCsv(id: $txId, txClass: $txClass) txAssociatedDataCsv(id: $txId, txClass: $txClass, timezone: $timezone)
} }
` `
@ -60,7 +67,7 @@ const Label = ({ children }) => {
return <Label1 className={classes.label}>{children}</Label1> return <Label1 className={classes.label}>{children}</Label1>
} }
const DetailsRow = ({ it: tx }) => { const DetailsRow = ({ it: tx, timezone }) => {
const classes = useStyles() const classes = useStyles()
const zip = new JSZip() const zip = new JSZip()
@ -96,8 +103,10 @@ const DetailsRow = ({ it: tx }) => {
.add(MINUTES_OFFSET, 'm') .add(MINUTES_OFFSET, 'm')
.format() .format()
const downloadRawLogs = ({ id: txId, deviceId, txClass }) => { const downloadRawLogs = ({ id: txId, deviceId, txClass }, timezone) => {
fetchSummary({ variables: { txId, from, until, deviceId, txClass } }) fetchSummary({
variables: { txId, from, until, deviceId, txClass, timezone }
})
} }
const createCsv = async logs => { const createCsv = async logs => {
@ -266,7 +275,7 @@ const DetailsRow = ({ it: tx }) => {
Icon={Download} Icon={Download}
InverseIcon={DownloadInverseIcon} InverseIcon={DownloadInverseIcon}
className={classes.downloadRawLogs} className={classes.downloadRawLogs}
onClick={() => downloadRawLogs(tx)}> onClick={() => downloadRawLogs(tx, timezone)}>
Download raw logs Download raw logs
</ActionButton> </ActionButton>
</div> </div>

View file

@ -329,6 +329,7 @@ const Transactions = () => {
Details={DetailsRow} Details={DetailsRow}
expandable expandable
rowSize="sm" rowSize="sm"
timezone={timezone}
/> />
</> </>
) )