diff --git a/frontend/app/components/Client/Audit/AuditList/AuditList.tsx b/frontend/app/components/Client/Audit/AuditList/AuditList.tsx index 2b4249155..549b25b6d 100644 --- a/frontend/app/components/Client/Audit/AuditList/AuditList.tsx +++ b/frontend/app/components/Client/Audit/AuditList/AuditList.tsx @@ -15,6 +15,7 @@ function AuditList(props: Props) { const list = useObserver(() => auditStore.list); const searchQuery = useObserver(() => auditStore.searchQuery); const page = useObserver(() => auditStore.page); + const order = useObserver(() => auditStore.order); const { showModal } = useModal(); useEffect(() => { @@ -22,8 +23,9 @@ function AuditList(props: Props) { page: auditStore.page, limit: auditStore.pageSize, query: auditStore.searchQuery, + order: auditStore.order, }); - }, [page, searchQuery]); + }, [page, searchQuery, order]); return useObserver(() => ( diff --git a/frontend/app/components/Client/Audit/AuditListItem/AuditListItem.tsx b/frontend/app/components/Client/Audit/AuditListItem/AuditListItem.tsx index 492d5c140..7d584bb06 100644 --- a/frontend/app/components/Client/Audit/AuditListItem/AuditListItem.tsx +++ b/frontend/app/components/Client/Audit/AuditListItem/AuditListItem.tsx @@ -9,7 +9,7 @@ function AuditListItem(props: Props) { const { audit, onShowDetails } = props; return (
-
asd
+
{audit.username}
{audit.action}
{audit.createdAt && checkForRecent(audit.createdAt, 'LLL dd, yyyy, hh:mm a')}
diff --git a/frontend/app/components/Client/Audit/AuditView/AuditView.tsx b/frontend/app/components/Client/Audit/AuditView/AuditView.tsx index ec9904567..1e53f24b5 100644 --- a/frontend/app/components/Client/Audit/AuditView/AuditView.tsx +++ b/frontend/app/components/Client/Audit/AuditView/AuditView.tsx @@ -4,14 +4,37 @@ import AuditList from '../AuditList'; import AuditSearchField from '../AuditSearchField'; import { useStore } from 'App/mstore'; import { useObserver } from 'mobx-react-lite'; +import Select from 'Shared/Select'; +import SelectDateRange from 'Shared/SelectDateRange'; function AuditView(props) { const { auditStore } = useStore(); + const order = useObserver(() => auditStore.order); + return useObserver(() => (
+
+ {/* */} +
+
+ +
+ ); +} + +export default SelectDateRange; \ No newline at end of file diff --git a/frontend/app/components/shared/SelectDateRange/index.ts b/frontend/app/components/shared/SelectDateRange/index.ts new file mode 100644 index 000000000..9b59aa99b --- /dev/null +++ b/frontend/app/components/shared/SelectDateRange/index.ts @@ -0,0 +1 @@ +export { default } from './SelectDateRange'; \ No newline at end of file diff --git a/frontend/app/dateRange.js b/frontend/app/dateRange.js index b50ec2fb9..4a2ea923d 100644 --- a/frontend/app/dateRange.js +++ b/frontend/app/dateRange.js @@ -23,6 +23,13 @@ Object.keys(DATE_RANGE_LABELS).forEach((key) => { DATE_RANGE_VALUES[ key ] = key export { DATE_RANGE_VALUES }; export const dateRangeValues = Object.keys(DATE_RANGE_VALUES); +export const DATE_RANGE_OPTIONS = Object.keys(DATE_RANGE_LABELS).map((key) => { + return { + label: DATE_RANGE_LABELS[ key ], + value: key, + }; +}); + export function getDateRangeFromTs(start, end) { return moment.range( moment(start), diff --git a/frontend/app/mstore/auditStore.ts b/frontend/app/mstore/auditStore.ts index 11b0ba9f4..b3df0aa6d 100644 --- a/frontend/app/mstore/auditStore.ts +++ b/frontend/app/mstore/auditStore.ts @@ -1,6 +1,7 @@ import { makeAutoObservable, runInAction, observable, action, reaction } from "mobx" import { auditService } from "App/services" import Audit from './types/audit' +import Period, { LAST_7_DAYS } from 'Types/app/period'; export default class AuditStore { list: any[] = []; @@ -9,6 +10,8 @@ export default class AuditStore { pageSize: number = 20; searchQuery: string = ''; isLoading: boolean = false; + order: string = 'desc'; + period: Period = Period({ rangeName: LAST_7_DAYS }) constructor() { makeAutoObservable(this, { @@ -18,8 +21,11 @@ export default class AuditStore { }) } + setDateRange(data: any) { + this.period = new Period(data); + } + updateKey(key: string, value: any) { - console.log(key, value) this[key] = value; } @@ -27,7 +33,6 @@ export default class AuditStore { this.isLoading = true; return new Promise((resolve, reject) => { auditService.all(data).then(response => { - console.log('response', response); runInAction(() => { this.list = response.sessions.map(item => Audit.fromJson(item)) this.total = response.count diff --git a/frontend/app/mstore/types/audit.ts b/frontend/app/mstore/types/audit.ts index b9c30343f..104ff447e 100644 --- a/frontend/app/mstore/types/audit.ts +++ b/frontend/app/mstore/types/audit.ts @@ -3,7 +3,7 @@ import { unserscoreToSpaceAndCapitalize } from 'App/utils'; export default class Audit { id: string = ''; - userName: string = ''; + username: string = ''; action: string = ''; createdAt: any = null; endPoint: string = ''; @@ -17,7 +17,7 @@ export default class Audit { static fromJson(json: any): Audit { const audit = new Audit(); audit.id = json.rn; - audit.userName = json.userName; + audit.username = json.username; audit.action = unserscoreToSpaceAndCapitalize(json.action); audit.createdAt = json.createdAt && DateTime.fromMillis(json.createdAt || 0); audit.endPoint = json.endPoint; @@ -30,7 +30,7 @@ export default class Audit { toJson(): any { return { id: this.id, - userName: this.userName + username: this.username }; } } \ No newline at end of file diff --git a/frontend/app/services/AuditService.ts b/frontend/app/services/AuditService.ts index 0a93d6bb6..39b7521ed 100644 --- a/frontend/app/services/AuditService.ts +++ b/frontend/app/services/AuditService.ts @@ -14,7 +14,7 @@ export default class AuditService { all(data: any): Promise { return this.client.post('/trails', data) .then(response => response.json()) - .then(response => response.data[0] || []); + .then(response => response.data || []); } one(id: string): Promise { diff --git a/frontend/app/svg/icons/text-paragraph.svg b/frontend/app/svg/icons/text-paragraph.svg index 9779beabf..f06f83174 100644 --- a/frontend/app/svg/icons/text-paragraph.svg +++ b/frontend/app/svg/icons/text-paragraph.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file