Skip to content

Commit

Permalink
Updated to work with live report files and format the names
Browse files Browse the repository at this point in the history
  • Loading branch information
dshook committed Nov 8, 2024
1 parent 929583d commit 23a4c07
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 82 deletions.
15 changes: 14 additions & 1 deletion src/containers/apps/appDetails/AccessLogReports.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Button, Modal } from 'antd'
import { Component } from 'react'
import { localize } from '../../../utils/Language'
import { AppDetailsTabProps } from './AppDetails'

interface GoAccessReport {
Expand Down Expand Up @@ -102,7 +103,7 @@ export default class AccessLogReports extends Component<
)
}
>
{r.name}
{this.reportName(r)}
</Button>
</p>
))}
Expand Down Expand Up @@ -162,6 +163,18 @@ export default class AccessLogReports extends Component<
})
}

reportName(report: GoAccessReport) {
if (report.name.includes('Live')) {
return localize('goaccess_settings.live', 'Live')
}
const date = new Date(report.lastModifiedTime)

return date.toLocaleString(undefined, {
dateStyle: 'short',
timeStyle: 'medium',
})
}

onReportClick(reportName: string, reportUrl: string) {
this.setState({ reportOpen: reportName })

Expand Down
79 changes: 0 additions & 79 deletions src/containers/monitoring/GoAccessSettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ interface GoAccessSettingsProps {

interface GoAccessSettingsState {
rotationFreqSelect: string | undefined
catchupFreqSelect: string | undefined
logRetentionSelect: string | undefined

rotationFreqCustom: string | undefined
catchupFreqCustom: string | undefined
logRetentionCustom: number | undefined
}

Expand All @@ -31,10 +29,6 @@ export default class GoAccessSettingsForm extends Component<
this.rotationFrequencyOptions,
props.goAccessInfo.data.rotationFrequencyCron
),
catchupFreqSelect: this.valueOrCustom(
this.catchupFrequencyOptions,
props.goAccessInfo.data.catchupFrequencyCron
),
logRetentionSelect:
props.goAccessInfo.data.logRetentionDays === undefined
? '-1'
Expand All @@ -43,7 +37,6 @@ export default class GoAccessSettingsForm extends Component<
props.goAccessInfo.data.logRetentionDays.toString()
),
rotationFreqCustom: props.goAccessInfo.data.rotationFrequencyCron,
catchupFreqCustom: props.goAccessInfo.data.catchupFrequencyCron,
logRetentionCustom: props.goAccessInfo.data.logRetentionDays,
}
}
Expand Down Expand Up @@ -84,32 +77,6 @@ export default class GoAccessSettingsForm extends Component<
},
]

catchupFrequencyOptions = [
{
value: '* * * * *',
label: localize('goaccess_settings.every_minute', 'Every Minute'),
},
{
value: '*/10 * * * *',
label: localize(
'goaccess_settings.every_10_minute',
'Every 10 Minutes'
),
},
{
value: '0 * * * *',
label: localize('goaccess_settings.every_hour', 'Every Hour'),
},
{
value: '0 0 * * *',
label: localize('goaccess_settings.every_day', 'Every Day'),
},
{
value: CUSTOM,
label: localize('goaccess_settings.custom', 'Custom'),
},
]

logRetentionOptions = [
{
value: '-1',
Expand All @@ -131,14 +98,6 @@ export default class GoAccessSettingsForm extends Component<
}
}

updateCatchupFrequency(selectValue?: string, customValue?: string) {
if (customValue !== undefined) {
this.setState({ catchupFreqCustom: customValue })
} else {
this.setState({ catchupFreqSelect: selectValue })
}
}

updateLogRetention(selectValue?: string, customValue?: string) {
let updated: number | undefined = undefined
const input = selectValue ?? customValue
Expand Down Expand Up @@ -166,11 +125,6 @@ export default class GoAccessSettingsForm extends Component<
? this.state.rotationFreqCustom
: this.state.rotationFreqSelect) ?? '0 0 1 * *'

updated.data.catchupFrequencyCron =
(this.state.catchupFreqSelect === CUSTOM
? this.state.catchupFreqCustom
: this.state.catchupFreqSelect) ?? '0 * * * *'

updated.data.logRetentionDays =
this.state.logRetentionSelect === CUSTOM
? this.state.logRetentionCustom
Expand Down Expand Up @@ -231,39 +185,6 @@ export default class GoAccessSettingsForm extends Component<
)}
</Form.Item>

<Form.Item
label={localize(
'goaccess_settings.catchup_frequency',
'Catch Up Report Processing Frequency'
)}
>
<Select
style={{ width: 200, marginRight: '1em' }}
options={this.catchupFrequencyOptions}
value={this.state.catchupFreqSelect}
onChange={(value) =>
this.updateCatchupFrequency(value)
}
/>
{this.state.catchupFreqSelect === CUSTOM && (
<Input
style={{ width: 200 }}
placeholder={localize(
'goaccess_settings.crontab_placeholder',
'Valid Crontab Expression'
)}
value={this.state.catchupFreqCustom}
required
onChange={(e) =>
this.updateCatchupFrequency(
undefined,
e.target.value
)
}
/>
)}
</Form.Item>

<Form.Item
label={localize(
'goaccess_settings.log_retention',
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
"goaccess.link": "GoAccess website",
"goaccess.start_goaccess": "Start GoAccess",
"goaccess.stop_goaccess": "Stop GoAccess",
"goaccess.live": "Live",
"goaccess.logs_location": "View access logs on the app details page",
"goaccess.update": "Update GoAccess",
"goaccess.started": "GoAccess is started and updated!",
Expand All @@ -313,7 +314,6 @@
"goaccess_settings.indefinite": "Indefinitely",
"goaccess_settings.goaccess_settings": "GoAccess Settings",
"goaccess_settings.rotation_frequency": "Log Rotation and Report Generation Frequency",
"goaccess_settings.catchup_frequency": "Catch Up Report Processing Frequency",
"goaccess_settings.log_retention": "Log and Report Retention Days",
"goaccess_settings.crontab_placeholder": "Valid Crontab Expression",
"goaccess_settings.log_retention_placeholder": "Number of days",
Expand Down
1 change: 0 additions & 1 deletion src/models/IGoAccessInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export default interface IGoAccessInfo {
isEnabled: boolean
data: {
rotationFrequencyCron: string
catchupFrequencyCron: string
logRetentionDays?: number
}
}

0 comments on commit 23a4c07

Please sign in to comment.