Browse Source

Merge pull request #11331 from vvlladd28/bug/audit-log-table/missing-action-type

Added missing audit log action type and improved audit log table handler translation
pull/11373/head
Igor Kulikov 2 years ago
committed by GitHub
parent
commit
d433373774
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 38
      ui-ngx/src/app/modules/home/components/audit-log/audit-log-table-config.ts
  2. 2
      ui-ngx/src/app/shared/models/audit-log.models.ts
  3. 1
      ui-ngx/src/assets/locale/locale.constant-en_US.json

38
ui-ngx/src/app/modules/home/components/audit-log/audit-log-table-config.ts

@ -20,12 +20,19 @@ import {
EntityTableConfig
} from '@home/models/entity/entities-table-config.models';
import {
ActionStatus,
actionStatusTranslations,
ActionType,
actionTypeTranslations,
AuditLog,
AuditLogMode
} from '@shared/models/audit-log.models';
import { EntityTypeResource, entityTypeTranslations } from '@shared/models/entity-type.models';
import {
AliasEntityType,
EntityType,
EntityTypeResource,
entityTypeTranslations
} from '@shared/models/entity-type.models';
import { AuditLogService } from '@core/http/audit-log.service';
import { TranslateService } from '@ngx-translate/core';
import { DatePipe } from '@angular/common';
@ -82,7 +89,7 @@ export class AuditLogTableConfig extends EntityTableConfig<AuditLog, TimePageLin
if (this.auditLogMode !== AuditLogMode.ENTITY) {
this.columns.push(
new EntityTableColumn<AuditLog>('entityType', 'audit-log.entity-type', '20%',
(entity) => translate.instant(entityTypeTranslations.get(entity.entityId.entityType).type)),
(entity) => this.getEntityTypeTranslation(entity.entityId.entityType)),
new EntityTableColumn<AuditLog>('entityName', 'audit-log.entity-name', '20%'),
);
}
@ -95,9 +102,9 @@ export class AuditLogTableConfig extends EntityTableConfig<AuditLog, TimePageLin
this.columns.push(
new EntityTableColumn<AuditLog>('actionType', 'audit-log.type', '33%',
(entity) => translate.instant(actionTypeTranslations.get(entity.actionType))),
(entity) => this.getActionTypeTranslation(entity.actionType)),
new EntityTableColumn<AuditLog>('actionStatus', 'audit-log.status', '33%',
(entity) => translate.instant(actionStatusTranslations.get(entity.actionStatus)))
(entity) => this.getActionStatusTranslation(entity.actionStatus))
);
this.cellActionDescriptors.push(
@ -105,11 +112,32 @@ export class AuditLogTableConfig extends EntityTableConfig<AuditLog, TimePageLin
name: this.translate.instant('audit-log.details'),
icon: 'more_horiz',
isEnabled: () => true,
onAction: ($event, entity) => this.showAuditLogDetails(entity)
onAction: (_, entity) => this.showAuditLogDetails(entity)
}
);
}
private getEntityTypeTranslation(entityType: EntityType | AliasEntityType): string {
if (entityTypeTranslations.has(entityType) && entityTypeTranslations.get(entityType).type) {
return this.translate.instant(entityTypeTranslations.get(entityType).type);
}
return entityType;
}
private getActionTypeTranslation(actionType: ActionType): string {
if (actionTypeTranslations.has(actionType)) {
return this.translate.instant(actionTypeTranslations.get(actionType));
}
return actionType;
}
private getActionStatusTranslation(actionStatus: ActionStatus): string {
if (actionStatusTranslations.has(actionStatus)) {
return this.translate.instant(actionStatusTranslations.get(actionStatus));
}
return actionStatus;
}
fetchAuditLogs(pageLink: TimePageLink): Observable<PageData<AuditLog>> {
switch (this.auditLogMode) {
case AuditLogMode.TENANT:

2
ui-ngx/src/app/shared/models/audit-log.models.ts

@ -48,6 +48,7 @@ export enum ActionType {
ALARM_ACK = 'ALARM_ACK',
ALARM_CLEAR = 'ALARM_CLEAR',
ALARM_ASSIGNED = 'ALARM_ASSIGNED',
ALARM_DELETE = 'ALARM_DELETE',
ALARM_UNASSIGNED = 'ALARM_UNASSIGNED',
ADDED_COMMENT = 'ADDED_COMMENT',
UPDATED_COMMENT = 'UPDATED_COMMENT',
@ -91,6 +92,7 @@ export const actionTypeTranslations = new Map<ActionType, string>(
[ActionType.RELATIONS_DELETED, 'audit-log.type-relations-delete'],
[ActionType.ALARM_ACK, 'audit-log.type-alarm-ack'],
[ActionType.ALARM_CLEAR, 'audit-log.type-alarm-clear'],
[ActionType.ALARM_DELETE, 'audit-log.type-alarm-delete'],
[ActionType.ALARM_ASSIGNED, 'audit-log.type-alarm-assign'],
[ActionType.ALARM_UNASSIGNED, 'audit-log.type-alarm-unassign'],
[ActionType.ADDED_COMMENT, 'audit-log.type-added-comment'],

1
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -936,6 +936,7 @@
"type-relations-delete": "All relation deleted",
"type-alarm-ack": "Acknowledged",
"type-alarm-clear": "Cleared",
"type-alarm-delete": "Deleted",
"type-alarm-assign": "Assigned",
"type-alarm-unassign": "Unassigned",
"type-added-comment": "Added comment",

Loading…
Cancel
Save