+
{{ log.recordDate | date: 'd MMM. yyyy, hh:mm a' }}
- {{ log.userId }}
+
{{ log.category }}
diff --git a/apps/red-ui/src/app/screens/admin/audit-screen/audit-screen.component.scss b/apps/red-ui/src/app/screens/admin/audit-screen/audit-screen.component.scss
index c48b744be..d0c85b8cf 100644
--- a/apps/red-ui/src/app/screens/admin/audit-screen/audit-screen.component.scss
+++ b/apps/red-ui/src/app/screens/admin/audit-screen/audit-screen.component.scss
@@ -20,6 +20,10 @@
font-size: 16px;
opacity: 0.7;
}
+
+ .mr-20 {
+ margin-right: 20px;
+ }
}
cdk-virtual-scroll-viewport {
diff --git a/apps/red-ui/src/app/screens/admin/audit-screen/audit-screen.component.ts b/apps/red-ui/src/app/screens/admin/audit-screen/audit-screen.component.ts
index e7ab08841..0d0dbfae7 100644
--- a/apps/red-ui/src/app/screens/admin/audit-screen/audit-screen.component.ts
+++ b/apps/red-ui/src/app/screens/admin/audit-screen/audit-screen.component.ts
@@ -3,6 +3,7 @@ import { PermissionsService } from '../../../common/service/permissions.service'
import { FormBuilder, FormGroup } from '@angular/forms';
import { AuditControllerService, AuditResponse, AuditSearchRequest } from '@redaction/red-ui-http';
import { TranslateService } from '@ngx-translate/core';
+import { Moment } from 'moment';
const PAGE_SIZE = 5;
@@ -22,6 +23,9 @@ export class AuditScreenComponent {
public ALL_CATEGORIES = 'audit-screen.all-categories';
public ALL_USERS = 'audit-screen.all-users';
+ private _previousFrom: Moment;
+ private _previousTo: Moment;
+
constructor(
public readonly permissionsService: PermissionsService,
private readonly _formBuilder: FormBuilder,
@@ -30,25 +34,57 @@ export class AuditScreenComponent {
) {
this.filterForm = this._formBuilder.group({
category: [this.ALL_CATEGORIES],
- userId: [this.ALL_USERS]
+ userId: [this.ALL_USERS],
+ from: [],
+ to: []
});
- this.filterForm.valueChanges.subscribe(() => this._fetchData());
+ this.filterForm.valueChanges.subscribe((value) => {
+ if (!this._updateDateFilters(value)) {
+ this._fetchData();
+ }
+ });
this._fetchData();
}
+ private _updateDateFilters(value): boolean {
+ if (!!value.to && !!value.from) {
+ if (this._previousFrom !== value.from) {
+ if (value.to.isBefore(value.from)) {
+ this.filterForm.patchValue({ to: value.from });
+ return true;
+ }
+ } else if (this._previousTo !== value.to) {
+ if (value.to.isBefore(value.from)) {
+ this.filterForm.patchValue({ from: value.to });
+ return true;
+ }
+ }
+ }
+ this._previousFrom = this.filterForm.get('from').value;
+ this._previousTo = this.filterForm.get('to').value;
+ return false;
+ }
+
private _fetchData(page?: number) {
this.viewReady = false;
const promises = [];
const category = this.filterForm.get('category').value;
const userId = this.filterForm.get('userId').value;
+ const from = this.filterForm.get('from').value;
+ let to = this.filterForm.get('to').value;
+ if (!!to) {
+ to = to.clone().add(1, 'd');
+ }
const logsRequestBody: AuditSearchRequest = {
pageSize: PAGE_SIZE,
withTotalHits: true,
page: page,
category: category === this.ALL_CATEGORIES ? undefined : category,
- userId: userId === this.ALL_USERS ? undefined : userId
+ userId: userId === this.ALL_USERS ? undefined : userId,
+ from,
+ to
};
promises.push(this._auditControllerService.getAuditCategories().toPromise());
diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json
index 3e3f618f4..a777c282e 100644
--- a/apps/red-ui/src/assets/i18n/en.json
+++ b/apps/red-ui/src/assets/i18n/en.json
@@ -802,7 +802,8 @@
"category": "Category"
},
"all-categories": "All Categories",
- "all-users": "All Users"
+ "all-users": "All Users",
+ "to": "to"
},
"pagination": {
"previous": "Prev",