Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit Logs #2759

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/_nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ const _nav = [
},
{
component: CNavItem,
name: 'Alerts',
to: '/tenant/administration/alertsqueue',
name: 'Alert Configuration',
to: '/tenant/administration/alert-configuration',
},
{
component: CNavItem,
name: 'Audit Logs',
to: '/tenant/administration/audit-logs',
},
{
component: CNavItem,
Expand Down
3 changes: 2 additions & 1 deletion src/importsMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import React from 'react'
"/tenant/administration/domains": React.lazy(() => import('./views/tenant/administration/Domains')),
"/tenant/administration/alertswizard": React.lazy(() => import('./views/tenant/administration/AlertWizard')),
"/tenant/administration/alertrules": React.lazy(() => import('./views/tenant/administration/AlertRules')),
"/tenant/administration/alertsqueue": React.lazy(() => import('./views/tenant/administration/ListAlertsQueue')),
"/tenant/administration/alert-configuration": React.lazy(() => import('./views/tenant/administration/ListAlertsQueue')),
"/tenant/administration/audit-logs": React.lazy(() => import('./views/tenant/administration/ListAuditLogs')),
"/tenant/administration/graph-explorer": React.lazy(() => import('./views/tenant/administration/GraphExplorer')),
"/tenant/administration/service-health": React.lazy(() => import('./views/tenant/administration/ServiceHealth')),
"/tenant/administration/enterprise-apps": React.lazy(() => import('./views/tenant/administration/ListEnterpriseApps')),
Expand Down
10 changes: 8 additions & 2 deletions src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,17 @@
"allowedRoles": ["admin", "editor", "readonly"]
},
{
"path": "/tenant/administration/alertsqueue",
"name": "Alerts Queue",
"path": "/tenant/administration/alert-configuration",
"name": "Alert Configuration",
"component": "views/tenant/administration/ListAlertsQueue",
"allowedRoles": ["admin", "editor", "readonly"]
},
{
"path": "/tenant/administration/audit-logs",
"name": "Audit Logs",
"component": "views/tenant/administration/ListAuditLogs",
"allowedRoles": ["admin", "editor", "readonly"]
},
{
"path": "/tenant/administration/graph-explorer",
"name": "Graph Explorer",
Expand Down
2 changes: 1 addition & 1 deletion src/views/tenant/administration/ListAlertsQueue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const ListClassicAlerts = () => {
allTenants: true,
helpContext: 'https://google.com',
}}
title="Alerts List"
title="Alert Configuration"
titleButton={
<TitleButton
key="add-user"
Expand Down
233 changes: 233 additions & 0 deletions src/views/tenant/administration/ListAuditLogs.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
import React, { useEffect } from 'react'
import { CippPageList } from 'src/components/layout'
import { TitleButton } from 'src/components/buttons'
import { cellGenericFormatter } from 'src/components/tables/CellGenericFormat'
import { cellDateFormatter } from 'src/components/tables'
import { useSelector } from 'react-redux'
import {
CButton,
CCard,
CCardBody,
CCardHeader,
CCardTitle,
CCol,
CCollapse,
CForm,
CFormCheck,
CFormInput,
CFormLabel,
CFormSelect,
CInputGroup,
CInputGroupText,
CLink,
CRow,
CTooltip,
} from '@coreui/react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { Condition, RFFCFormInput, RFFCFormRadioList } from 'src/components/forms'
import { Field, Form } from 'react-final-form'

const ListAuditLogs = () => {
const [interval, setInterval] = React.useState('d')
const [time, setTime] = React.useState(1)
const [relativeTime, setRelativeTime] = React.useState('1d')
const [startDate, setStartDate] = React.useState(null)
const [endDate, setEndDate] = React.useState(null)
const [visibleA, setVisibleA] = React.useState(true)
const [tenantColumnSet, setTenantColumn] = React.useState(false)
const tenant = useSelector((state) => state.app.currentTenant)

useEffect(() => {
if (tenant.defaultDomainName === 'AllTenants') {
setTenantColumn(false)
}
if (tenant.defaultDomainName !== 'AllTenants') {
setTenantColumn(true)
}
}, [tenant.defaultDomainName, tenantColumnSet])

const handleSearch = (values) => {
if (values.dateFilter === 'relative') {
setRelativeTime(`${values.Time}${values.Interval}`)
setStartDate(null)
setEndDate(null)
} else if (values.dateFilter === 'startEnd') {
setRelativeTime(null)
setStartDate(values.startDate)
setEndDate(values.endDate)
}
setVisibleA(false)
}

const Actions = () => {
return (
<CLink variant="ghost" color="primary" className="me-2">
<CTooltip content="View">
<FontAwesomeIcon icon="eye" />
</CTooltip>
</CLink>
)
}

const columns = [
{
name: 'Timestamp',
selector: (row) => row['Timestamp'],
sortable: true,
exportSelector: 'Timestamp',
cell: cellDateFormatter({ format: 'short' }),
maxWidth: '200px',
},
{
name: 'Tenant',
selector: (row) => row['Tenant'],
exportSelector: 'Tenant',
omit: !tenantColumnSet,
cell: cellGenericFormatter(),
maxWidth: '150px',
},
{
name: 'Title',
selector: (row) => row['Title'],
exportSelector: 'Title',
cell: cellGenericFormatter(),
},
{
name: 'Actions',
cell: Actions,
maxWidth: '100px',
},
]
return (
<div>
<CRow>
<CCol>
<CCard className="options-card">
<CCardHeader>
<CCardTitle className="d-flex justify-content-between">
Search Options
<CButton
size="sm"
variant="ghost"
className="stretched-link"
onClick={() => setVisibleA(!visibleA)}
>
<FontAwesomeIcon icon={visibleA ? 'chevron-down' : 'chevron-right'} />
</CButton>
</CCardTitle>
</CCardHeader>
</CCard>
<CCollapse visible={visibleA}>
<CCard className="options-card">
<CCardHeader></CCardHeader>
<CCardBody>
<Form
onSubmit={handleSearch}
render={({ handleSubmit, submitting, values }) => {
return (
<CForm onSubmit={handleSubmit}>
<CRow>
<CCol>
<CFormLabel>Date Filter Type</CFormLabel>
<div>
<RFFCFormRadioList
name={`dateFilter`}
button={{ color: 'primary' }}
buttonClassName="me-1"
options={[
{
label: 'Relative',
value: `relative`,
defaultChecked: true,
},
{
label: 'Start / End',
value: `startEnd`,
},
]}
inline={true}
/>
</div>
</CCol>
</CRow>
<hr />
<Condition when="dateFilter" is="relative">
<CRow>
<CCol xl="3">
<CFormLabel>Relative Time</CFormLabel>
<CInputGroup>
<CInputGroupText as="label" htmlFor="Time">
Last
</CInputGroupText>
<Field name="Time" id="Time">
{({ input, meta }) => <CFormInput {...input} defaultValue={1} />}
</Field>
<Field name="Interval">
{({ input, meta }) => (
<CFormSelect {...input}>
<option value="m">Minutes</option>
<option value="h">Hours</option>
<option value="d" selected>
Days
</option>
</CFormSelect>
)}
</Field>
</CInputGroup>
</CCol>
</CRow>
</Condition>
<Condition when="dateFilter" is="startEnd">
<CRow>
<CCol>
<RFFCFormInput name="startDate" label="Start Date" type="date" />
</CCol>
<CCol>
<RFFCFormInput name="endDate" label="End Date" type="date" />
</CCol>
</CRow>
</Condition>
<CRow className="my-3">
<CCol>
<CButton type="submit">
<FontAwesomeIcon icon="search" className="me-2" />
Search
</CButton>
</CCol>
</CRow>
</CForm>
)
}}
/>
</CCardBody>
</CCard>
</CCollapse>
</CCol>
</CRow>
<hr />
<CippPageList
capabilities={{ allTenants: true, helpContext: 'https://google.com' }}
title="Audit Logs"
tenantSelector={false}
datatable={{
keyField: 'id',
columns,
reportName: `Audit-Logs`,
path: '/api/ListAuditLogs',
params: {
TenantFilter: tenant.defaultDomainName,
RelativeTime: relativeTime,
StartDate: startDate,
EndDate: endDate,
},
tableProps: {
selectableRows: true,
keyField: 'RowKey',
},
}}
/>
</div>
)
}

export default ListAuditLogs
Loading