add ip, ua columns to the recent logs

update translations
Signed-off-by: Maksym Trofimenko <maksym@container-registry.com>
This commit is contained in:
Maksym Trofimenko 2024-01-12 20:15:48 +00:00
parent a69ab377c3
commit eb5fc28340
5 changed files with 38 additions and 8 deletions

View File

@ -56,6 +56,12 @@
<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>
@ -67,6 +73,12 @@
<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>

View File

@ -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;
@ -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 = {
@ -83,6 +87,7 @@ describe('RecentLogComponent (inline template)', () => {
providers: [
{ provide: ErrorHandler, useValue: fakedErrorHandler },
{ provide: AuditlogService, useValue: fakedAuditlogService },
{ provide: AppConfigService, useValue: fakeAppConfigService },
],
}).compileComponents();
});

View File

@ -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,
@ -43,7 +44,8 @@ export class RecentLogComponent {
constructor(
private logService: AuditlogService,
private errorHandler: ErrorHandler
private errorHandler: ErrorHandler,
private appConfigService: AppConfigService
) {}
public get inProgress(): boolean {
@ -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;

View File

@ -533,11 +533,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",

View File

@ -536,7 +536,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",