diff --git a/new-lamassu-admin/src/components/LogsDownloaderPopper.js b/new-lamassu-admin/src/components/LogsDownloaderPopper.js
index 8e26dcd7..d0fc8f2b 100644
--- a/new-lamassu-admin/src/components/LogsDownloaderPopper.js
+++ b/new-lamassu-admin/src/components/LogsDownloaderPopper.js
@@ -129,22 +129,31 @@ const styles = {
const useStyles = makeStyles(styles)
const ALL = 'all'
const RANGE = 'range'
+const ADVANCED = 'advanced'
+const SIMPLIFIED = 'simplified'
const LogsDownloaderPopover = ({
name,
- query,
+ queries,
args,
title,
getLogs,
- timezone
+ timezone,
+ getSimplifiedLogs
}) => {
const [selectedRadio, setSelectedRadio] = useState(ALL)
+ const [selectedAdvancedRadio, setSelectedAdvancedRadio] = useState(ADVANCED)
+
const [range, setRange] = useState({ from: null, until: null })
const [anchorEl, setAnchorEl] = useState(null)
- const [fetchLogs] = useLazyQuery(query, {
+ const [fetchLogs] = useLazyQuery(queries[0], {
onCompleted: data => createLogsFile(getLogs(data), range)
})
+ const [fetchSimplifiedLogs] = useLazyQuery(queries[1], {
+ onCompleted: data => createLogsFile(getSimplifiedLogs(data), range)
+ })
+
const classes = useStyles()
const dateRangePickerClasses = {
@@ -158,6 +167,12 @@ const LogsDownloaderPopover = ({
if (selectedRadio === ALL) setRange({ from: null, until: null })
}
+ const handleAdvancedRadioButtons = evt => {
+ const selectedAdvancedRadio = R.path(['target', 'value'])(evt)
+ setSelectedAdvancedRadio(selectedAdvancedRadio)
+ if (selectedAdvancedRadio === ALL) setRange({ from: null, until: null })
+ }
+
const handleRangeChange = useCallback(
(from, until) => {
setRange({ from, until })
@@ -165,9 +180,11 @@ const LogsDownloaderPopover = ({
[setRange]
)
- const downloadLogs = (range, args, fetchLogs) => {
+ const downloadLogs = (range, args) => {
+ const fetch =
+ selectedAdvancedRadio === SIMPLIFIED ? fetchSimplifiedLogs : fetchLogs
if (selectedRadio === ALL) {
- fetchLogs({
+ fetch({
variables: {
...args
}
@@ -179,7 +196,7 @@ const LogsDownloaderPopover = ({
if (moment(range.from).isSame(range.until, 'day')) range.until = moment()
if (selectedRadio === RANGE) {
- fetchLogs({
+ fetch({
variables: {
...args,
from: range.from,
@@ -218,7 +235,9 @@ const LogsDownloaderPopover = ({
const radioButtonOptions = [
{ display: 'All logs', code: ALL },
- { display: 'Date range', code: RANGE }
+ { display: 'Date range', code: RANGE },
+ { display: 'Advanced logs', code: ADVANCED },
+ { display: 'Simplified logs', code: SIMPLIFIED }
]
const open = Boolean(anchorEl)
@@ -240,7 +259,7 @@ const LogsDownloaderPopover = ({