Skip to content

Commit

Permalink
add ip, ua columns to the recent logs
Browse files Browse the repository at this point in the history
update translations
Signed-off-by: Maksym Trofimenko <[email protected]>
  • Loading branch information
Maksym Trofimenko authored and tpoxa committed Feb 25, 2024
1 parent 05d72df commit e8455c7
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ <h2 class="custom-h2" sub-header-title>
<clr-dg-column>{{
'AUDIT_LOG.OPERATION' | translate
}}</clr-dg-column>
<clr-dg-column *ngIf="isIPTracked()">{{
'AUDIT_LOG.IP_ADDRESS' | translate
}}</clr-dg-column>
<clr-dg-column *ngIf="isUATracked()">{{
'AUDIT_LOG.USER_AGENT' | translate
}}</clr-dg-column>
<clr-dg-column>{{
'AUDIT_LOG.TIMESTAMP' | translate
}}</clr-dg-column>
Expand All @@ -67,6 +73,12 @@ <h2 class="custom-h2" sub-header-title>
<clr-dg-cell>{{ l.resource }}</clr-dg-cell>
<clr-dg-cell>{{ l.resource_type }}</clr-dg-cell>
<clr-dg-cell>{{ l.operation }}</clr-dg-cell>
<clr-dg-cell *ngIf="isIPTracked()">{{
l.client_ip
}}</clr-dg-cell>
<clr-dg-cell *ngIf="isUATracked()">{{
l.user_agent
}}</clr-dg-cell>
<clr-dg-cell>{{
l.op_time | harborDatetime : 'short'
}}</clr-dg-cell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AuditlogService } from '../../../../../ng-swagger-gen/services/auditlog
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { delay } from 'rxjs/operators';
import { SharedTestingModule } from '../../../shared/shared.module';
import { AppConfigService } from '../../../services/app-config.service';

describe('RecentLogComponent (inline template)', () => {
let component: RecentLogComponent;
Expand All @@ -20,6 +21,9 @@ describe('RecentLogComponent (inline template)', () => {
return undefined;
},
};
let fakeAppConfigService = {
handleError: () => {},
};
const mockedAuditLogs: AuditLog[] = [];
for (let i = 0; i < 18; i++) {
let item: AuditLog = {
Expand Down Expand Up @@ -83,6 +87,7 @@ describe('RecentLogComponent (inline template)', () => {
providers: [
{ provide: ErrorHandler, useValue: fakedErrorHandler },
{ provide: AuditlogService, useValue: fakedAuditlogService },
{ provide: AppConfigService, useValue: fakeAppConfigService },
],
}).compileComponents();
});
Expand Down
17 changes: 15 additions & 2 deletions src/portal/src/app/base/left-side-nav/log/recent-log.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { finalize } from 'rxjs/operators';
import { AuditlogService } from '../../../../../ng-swagger-gen/services/auditlog.service';
import { AuditLog } from '../../../../../ng-swagger-gen/models/audit-log';
import { ClrDatagridStateInterface } from '@clr/angular';
import { AppConfigService } from '../../../services/app-config.service';
import {
getPageSizeFromLocalStorage,
PageSizeMapKeys,
Expand All @@ -43,7 +44,8 @@ export class RecentLogComponent {

constructor(
private logService: AuditlogService,
private errorHandler: ErrorHandler
private errorHandler: ErrorHandler,
private appConfigService: AppConfigService
) {}

public get inProgress(): boolean {
Expand Down Expand Up @@ -74,7 +76,18 @@ export class RecentLogComponent {
this.defaultFilter = $event['target'].value;
this.doFilter(this.currentTerm);
}

isIPTracked(): boolean {
if (this.appConfigService?.configurations?.audit_log_track_ip_address) {
return true;
}
return false;
}
isUATracked(): boolean {
if (this.appConfigService?.configurations?.audit_log_track_user_agent) {
return true;
}
return false;
}
load(state?: ClrDatagridStateInterface) {
if (state && state.page) {
this.pageSize = state.page.size;
Expand Down
10 changes: 5 additions & 5 deletions src/portal/src/i18n/lang/de-de-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,11 @@
"OF": "von",
"NOT_FOUND": "Es konnten keine Logdaten gefunden werden!",
"RESOURCE": "Ressource",
"RESOURCE_TYPE": "Ressourcen-Typ",
"TRACK_IP": "IP-Address in Audit Log",
"TRACK_IP_TOOLTIP": "Capture the client's IP addresses on each request and store them in the audit log.",
"TRACK_UA": "User-Agent in Audit Log",
"TRACK_UA_TOOLTIP": "Capture the client's User-Agent on each request and store it in the audit log."
"RESOURCE_TYPE": "Ressourcen Typ",
"TRACK_IP": "IP-Adresse im Audit-Log",
"TRACK_IP_TOOLTIP": "Die IP-Adresse des Clients wird bei jeder Anfrage erfasst und im Audit-Protokoll gespeichert.",
"TRACK_UA": "Benutzer-Agent im Audit-Log",
"TRACK_UA_TOOLTIP": "Der Benutzer-Agent des Clients wird bei jeder Anfrage erfasst und im Audit-Protokoll gespeichert."
},
"REPLICATION": {
"PUSH_BASED_ONLY": "Only for the push-based replication",
Expand Down
2 changes: 1 addition & 1 deletion src/portal/src/i18n/lang/en-us-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@
"RESOURCE": "Resource",
"RESOURCE_TYPE": "Resource Type",
"IP_ADDRESS": "IP Address",
"USER_AGENT": "User Agent",
"USER_AGENT": "User-Agent",
"TRACK_IP": "IP-Address in Audit Log",
"TRACK_IP_TOOLTIP": "Capture the client's IP addresses on each request and store them in the audit log.",
"TRACK_UA": "User-Agent in Audit Log",
Expand Down

0 comments on commit e8455c7

Please sign in to comment.