Browse Source

code cleanup

pull/14262/head
Maksym Tsymbarov 10 months ago
parent
commit
ea557ec2b6
  1. 68
      ui-ngx/src/app/core/http/audit-log.service.ts
  2. 56
      ui-ngx/src/app/modules/home/components/audit-log/audit-log-filter.component.html
  3. 3
      ui-ngx/src/app/modules/home/components/audit-log/audit-log-filter.component.scss
  4. 122
      ui-ngx/src/app/modules/home/components/audit-log/audit-log-filter.component.ts
  5. 21
      ui-ngx/src/app/modules/home/components/audit-log/audit-log-header.component.scss
  6. 3
      ui-ngx/src/app/modules/home/components/audit-log/audit-log-header.component.ts
  7. 26
      ui-ngx/src/app/modules/home/components/audit-log/audit-log-table-config.ts
  8. 3
      ui-ngx/src/app/modules/home/components/audit-log/audit-log-table.component.ts
  9. 6
      ui-ngx/src/app/modules/home/components/entity/entity-table-header.component.ts
  10. 6
      ui-ngx/src/app/modules/home/components/home-components.module.ts
  11. 7
      ui-ngx/src/app/modules/home/pages/audit-log/audit-log.module.ts
  12. 43
      ui-ngx/src/app/shared/models/audit-log.models.ts
  13. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json

68
ui-ngx/src/app/core/http/audit-log.service.ts

@ -15,12 +15,12 @@
///
import { Injectable } from '@angular/core';
import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { createDefaultHttpOptions, RequestConfig } from './http-utils';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { TimePageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data';
import { AuditLog, AuditLogQuery } from '@shared/models/audit-log.models';
import { AuditLog, AuditLogFilter } from '@shared/models/audit-log.models';
import { EntityId } from '@shared/models/id/entity-id';
@Injectable({
@ -32,28 +32,58 @@ export class AuditLogService {
private http: HttpClient
) { }
public getAuditLogs(auditLogQuery: AuditLogQuery,
config?: RequestConfig): Observable<PageData<AuditLog>> {
return this.http.get<PageData<AuditLog>>(`/api/audit/logs${auditLogQuery.toQuery()}`,
defaultHttpOptionsFromConfig(config));
public getAuditLogs(pageLink: TimePageLink, config?: RequestConfig): Observable<PageData<AuditLog>>;
public getAuditLogs(pageLink: TimePageLink, filters: AuditLogFilter, config?: RequestConfig): Observable<PageData<AuditLog>>;
public getAuditLogs(
pageLink: TimePageLink,
filtersOrConfig?: AuditLogFilter | RequestConfig,
config?: RequestConfig
): Observable<PageData<AuditLog>> {
return this.http.get<PageData<AuditLog>>(
`/api/audit/logs${pageLink.toQuery()}`,
createDefaultHttpOptions(filtersOrConfig, config)
);
}
public getAuditLogsByCustomerId(auditLogQuery: AuditLogQuery,
config?: RequestConfig): Observable<PageData<AuditLog>> {
return this.http.get<PageData<AuditLog>>(`/api/audit/logs/customer/${auditLogQuery.toQuery()}`,
defaultHttpOptionsFromConfig(config));
public getAuditLogsByCustomerId(customerId: string, pageLink: TimePageLink, config?: RequestConfig): Observable<PageData<AuditLog>>;
public getAuditLogsByCustomerId(customerId: string, pageLink: TimePageLink, filters: AuditLogFilter, config?: RequestConfig): Observable<PageData<AuditLog>>;
public getAuditLogsByCustomerId(
customerId: string,
pageLink: TimePageLink,
filtersOrConfig?: AuditLogFilter | RequestConfig,
config?: RequestConfig
): Observable<PageData<AuditLog>> {
return this.http.get<PageData<AuditLog>>(
`/api/audit/logs/customer/${customerId}${pageLink.toQuery()}`,
createDefaultHttpOptions(filtersOrConfig, config)
);
}
public getAuditLogsByUserId(auditLogQuery: AuditLogQuery,
config?: RequestConfig): Observable<PageData<AuditLog>> {
return this.http.get<PageData<AuditLog>>(`/api/audit/logs/user/${auditLogQuery.toQuery()}`,
defaultHttpOptionsFromConfig(config));
public getAuditLogsByUserId(userId: string, pageLink: TimePageLink, config?: RequestConfig): Observable<PageData<AuditLog>>;
public getAuditLogsByUserId(userId: string, pageLink: TimePageLink, filters: AuditLogFilter, config?: RequestConfig): Observable<PageData<AuditLog>>;
public getAuditLogsByUserId(
userId: string,
pageLink: TimePageLink,
filtersOrConfig?: AuditLogFilter | RequestConfig,
config?: RequestConfig
): Observable<PageData<AuditLog>> {
return this.http.get<PageData<AuditLog>>(
`/api/audit/logs/user/${userId}${pageLink.toQuery()}`,
createDefaultHttpOptions(filtersOrConfig, config)
);
}
public getAuditLogsByEntityId(auditLogQuery: AuditLogQuery,
config?: RequestConfig): Observable<PageData<AuditLog>> {
return this.http.get<PageData<AuditLog>>(`/api/audit/logs/entity/${auditLogQuery.toQuery()}`,
defaultHttpOptionsFromConfig(config));
public getAuditLogsByEntityId(entityId: EntityId, pageLink: TimePageLink, config?: RequestConfig): Observable<PageData<AuditLog>>;
public getAuditLogsByEntityId(entityId: EntityId, pageLink: TimePageLink, filters: AuditLogFilter, config?: RequestConfig): Observable<PageData<AuditLog>>;
public getAuditLogsByEntityId(
entityId: EntityId,
pageLink: TimePageLink,
filtersOrConfig?: AuditLogFilter | RequestConfig,
config?: RequestConfig
): Observable<PageData<AuditLog>> {
return this.http.get<PageData<AuditLog>>(
`/api/audit/logs/entity/${entityId.entityType}/${entityId.id}${pageLink.toQuery()}`,
createDefaultHttpOptions(filtersOrConfig, config)
);
}
}

56
ui-ngx/src/app/modules/home/components/audit-log/audit-log-filter.component.html

@ -15,24 +15,36 @@
limitations under the License.
-->
<ng-container *ngIf="panelMode; else componentMode">
<ng-container *ngTemplateOutlet="auditLogFilterPanel"></ng-container>
</ng-container>
<ng-template #componentMode>
<ng-container *ngIf="buttonMode; else auditLogFilter">
<button color="primary"
matTooltip="{{buttonDisplayValue}}"
matTooltipPosition="above"
mat-stroked-button
(click)="toggleAuditLogFilterPanel($event)">
<mat-icon>filter_list</mat-icon>{{buttonDisplayValue}}
</button>
</ng-container>
</ng-template>
<button color="primary"
matTooltip="{{buttonDisplayValue}}"
matTooltipPosition="above"
mat-stroked-button
(click)="toggleAuditLogFilterPanel($event)">
<mat-icon>filter_list</mat-icon>{{buttonDisplayValue}}
</button>
<ng-template #auditLogFilterPanel>
<form class="mat-content mat-padding flex flex-col" (ngSubmit)="update()">
<ng-container *ngTemplateOutlet="auditLogFilter"></ng-container>
<form class="mat-content mat-padding flex flex-col" [formGroup]="auditLogFilterForm" (ngSubmit)="update()">
<div class="tb-form-panel flex-1 no-padding no-border">
<div class="tb-form-row flex-1 space-between column-xs">
<div class="fixed-title-width" translate>audit-log.filter-types</div>
<tb-string-items-list appearance="outline"
class="flex flex-1 gt-xs:w-64"
subscriptSizing="dynamic"
[placeholder]="'audit-log.filter-type-add' | translate"
[predefinedValues]="predefinedTypeValues"
formControlName="actionTypes">
</tb-string-items-list>
</div>
</div>
<div class="tb-panel-actions flex flex-row items-center justify-end">
<button type="button"
mat-button
color="primary"
(click)="reset()">
{{ 'action.reset' | translate }}
</button>
<span class="flex-1"></span>
<button type="button"
mat-button
(click)="cancel()">
@ -47,15 +59,3 @@
</div>
</form>
</ng-template>
<ng-template #auditLogFilter>
<div class="flex flex-col gap-4" style="min-width: 280px;" [formGroup]="auditLogFilterForm">
<tb-string-items-list [label]="'audit-log.type' | translate"
appearance="outline"
subscriptSizing="dynamic"
[placeholder]="'audit-log.filter-type-add' | translate"
[predefinedValues]="predefinedTypeValues"
formControlName="types"
>
</tb-string-items-list>
</div>
</ng-template>

3
ui-ngx/src/app/modules/home/components/audit-log/audit-log-filter.component.scss

@ -14,8 +14,7 @@
* limitations under the License.
*/
:host {
display: block;
overflow: hidden;
display: flex;
max-width: 100%;
padding-right: 20px;
.mdc-button {

122
ui-ngx/src/app/modules/home/components/audit-log/audit-log-filter.component.ts

@ -14,28 +14,27 @@
/// limitations under the License.
///
import { ConnectedPosition, Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
import { Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
import { TemplatePortal } from '@angular/cdk/portal';
import { ChangeDetectorRef, Component, DestroyRef, ElementRef, forwardRef, Inject, InjectionToken, Input, OnInit, Optional, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core';
import { ChangeDetectorRef, Component, DestroyRef, ElementRef, forwardRef, Input, OnInit, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ControlValueAccessor, NG_VALUE_ACCESSOR, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { isDefinedAndNotNull } from '@app/core/utils';
import { isDefined, isDefinedAndNotNull } from '@app/core/utils';
import { StringItemsOption } from '@app/shared/components/string-items-list.component';
import { ActionType, actionTypeTranslations, AuditLogFilter, coerceBoolean } from '@app/shared/public-api';
import {
ActionType,
actionTypeTranslations,
auditLogFilterEquals,
AuditLogFilter,
POSITION_MAP,
} from '@app/shared/public-api';
import { TranslateService } from '@ngx-translate/core';
export const AUDIT_LOG_FILTER_CONFIG_DATA = new InjectionToken<any>('AuditLogFilterConfigData');
export interface AuditLogConfigData {
panelMode: boolean;
auditLogFilter: AuditLogFilter;
}
// @dynamic
@Component({
selector: 'tb-audit-log-filter',
templateUrl: './audit-log-filter.component.html',
styleUrl: './audit-log-filter.component.scss',
styleUrls: ['./audit-log-filter.component.scss'],
providers: [
{
provide: NG_VALUE_ACCESSOR,
@ -45,23 +44,17 @@ export interface AuditLogConfigData {
]
})
export class AuditLogFilterComponent implements OnInit, ControlValueAccessor {
@ViewChild('auditLogFilterPanel')
auditLogFilterPanel: TemplateRef<any>;
@Input() disabled: boolean;
@coerceBoolean()
@Input()
buttonMode = true;
ActionType = ActionType;
actionTypes = Object.values(ActionType);
actionTypeTranslations = actionTypeTranslations;
panelMode = false;
actionTypeTranslations = actionTypeTranslations;
buttonDisplayValue = this.translate.instant('audit-log.filter');
@ -69,17 +62,13 @@ export class AuditLogFilterComponent implements OnInit, ControlValueAccessor {
auditLogOverlayRef: OverlayRef;
panelResult: AuditLogFilter = null;
initialAuditLogFilter: AuditLogFilter;
private auditLogFilter: AuditLogFilter;
private propagateChange = (_: any) => {};
constructor(@Optional() @Inject(AUDIT_LOG_FILTER_CONFIG_DATA)
private data: AuditLogConfigData | undefined,
@Optional()
private overlayRef: OverlayRef,
private fb: UntypedFormBuilder,
constructor(private fb: UntypedFormBuilder,
private translate: TranslateService,
private overlay: Overlay,
private nativeElement: ElementRef,
@ -88,27 +77,16 @@ export class AuditLogFilterComponent implements OnInit, ControlValueAccessor {
private destroyRef: DestroyRef) {}
ngOnInit(): void {
if (this.data) {
this.panelMode = this.data.panelMode;
this.auditLogFilter = this.data.auditLogFilter;
}
this.auditLogFilterForm = this.fb.group({
types: ['', []]
actionTypes: [[]]
});
this.auditLogFilterForm.valueChanges.pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe(
() => {
this.updateValidators();
if (!this.buttonMode) {
this.auditLogFilterUpdated(this.auditLogFilterForm.value);
}
}
);
if (this.panelMode) {
this.updateAuditLogFilterForm(this.auditLogFilter);
}
}
registerOnChange(fn: any): void {
@ -127,18 +105,21 @@ export class AuditLogFilterComponent implements OnInit, ControlValueAccessor {
this.updateValidators();
}
}
writeValue(auditLogFilter?: AuditLogFilter): void {
this.auditLogFilter = auditLogFilter;
if(!this.initialAuditLogFilter && isDefined(this.auditLogFilter)) {
this.initialAuditLogFilter = this.auditLogFilterForm.getRawValue();
}
this.updateButtonDisplayValue();
this.updateAuditLogFilterForm(auditLogFilter);
}
get predefinedTypeValues (): StringItemsOption[] {
return [...this.actionTypes].map(type => ({
name: this.translate.instant(this.actionTypeTranslations.get(type)),
value: type
}))
}));
}
private updateValidators() {
@ -157,14 +138,9 @@ export class AuditLogFilterComponent implements OnInit, ControlValueAccessor {
minWidth: ''
});
config.hasBackdrop = true;
const connectedPosition: ConnectedPosition = {
originX: 'start',
originY: 'bottom',
overlayX: 'start',
overlayY: 'top'
};
config.positionStrategy = this.overlay.position().flexibleConnectedTo(this.nativeElement)
.withPositions([connectedPosition]);
config.positionStrategy = this.overlay.position()
.flexibleConnectedTo(this.nativeElement)
.withPositions([POSITION_MAP.bottomLeft]);
this.auditLogOverlayRef = this.overlay.create(config);
this.auditLogOverlayRef.backdropClick().subscribe(() => {
@ -176,28 +152,26 @@ export class AuditLogFilterComponent implements OnInit, ControlValueAccessor {
cancel() {
this.updateAuditLogFilterForm(this.auditLogFilter);
if (this.overlayRef) {
this.overlayRef.dispose();
} else {
this.auditLogOverlayRef.dispose();
}
this.auditLogOverlayRef.dispose();
}
update() {
this.auditLogFilterUpdated(this.auditLogFilterForm.value);
if (this.panelMode) {
this.panelResult = this.auditLogFilter;
}
if (this.overlayRef) {
this.overlayRef.dispose();
} else {
this.auditLogOverlayRef.dispose();
this.auditLogOverlayRef.dispose();
}
reset() {
if (this.initialAuditLogFilter) {
if (!auditLogFilterEquals(this.auditLogFilter, this.initialAuditLogFilter)) {
this.updateAuditLogFilterForm(this.initialAuditLogFilter);
this.auditLogFilterForm.markAsDirty();
}
}
}
private updateAuditLogFilterForm(auditLogFilter?: AuditLogFilter) {
this.auditLogFilterForm.patchValue({
types: auditLogFilter?.types,
actionTypes: auditLogFilter?.actionTypes,
}, {emitEvent: false});
this.updateValidators();
}
@ -209,18 +183,16 @@ export class AuditLogFilterComponent implements OnInit, ControlValueAccessor {
}
private updateButtonDisplayValue() {
if (this.buttonMode) {
const filterTextParts: string[] = [];
if (isDefinedAndNotNull(this.auditLogFilter?.types)) {
const types = this.auditLogFilter.types;
types.forEach(type => filterTextParts.push(this.translate.instant(this.actionTypeTranslations.get(type as ActionType))))
}
if (!filterTextParts.length) {
this.buttonDisplayValue = this.translate.instant('audit-log.audit-log-filter-title');
} else {
this.buttonDisplayValue = this.translate.instant('audit-log.filter-title') + `: ${filterTextParts.join(', ')}`;
}
this.cd.detectChanges();
const filterTextParts: string[] = [];
if (isDefinedAndNotNull(this.auditLogFilter?.actionTypes)) {
const actionTypes = this.auditLogFilter.actionTypes;
actionTypes.forEach(actionType => filterTextParts.push(this.translate.instant(this.actionTypeTranslations.get(actionType as ActionType))))
}
if (!filterTextParts.length) {
this.buttonDisplayValue = this.translate.instant('audit-log.audit-log-filter-title');
} else {
this.buttonDisplayValue = this.translate.instant('audit-log.filter-title') + `: ${filterTextParts.join(', ')}`;
}
this.cd.detectChanges();
}
}

21
ui-ngx/src/app/modules/home/components/audit-log/audit-log-header.component.scss

@ -0,0 +1,21 @@
/**
* Copyright © 2016-2025 The Thingsboard Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
:host {
padding-right: 8px;
overflow: hidden;
max-width: 100%;
}

3
ui-ngx/src/app/modules/home/components/audit-log/audit-log-header.component.ts

@ -26,13 +26,12 @@ import { Store } from '@ngrx/store';
styles: ``
})
export class AuditLogHeaderComponent extends EntityTableHeaderComponent<AuditLog, TimePageLink> {
constructor(protected store: Store<AppState>) {
super(store)
}
auditLogFiltersChanged(auditLogFilter: AuditLogFilter) {
console.log("auditLogFilter",auditLogFilter )
this.entitiesTableConfig.componentsData.auditLogFilter = auditLogFilter;
this.entitiesTableConfig.getTable().resetSortAndFilter(true, true);
}

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

@ -26,8 +26,7 @@ import {
actionTypeTranslations,
AuditLog,
AuditLogMode,
AuditLogQuery,
AuditLogRequestParams
AuditLogFilter
} from '@shared/models/audit-log.models';
import {
AliasEntityType,
@ -50,7 +49,7 @@ import {
AuditLogDetailsDialogComponent,
AuditLogDetailsDialogData
} from '@home/components/audit-log/audit-log-details-dialog.component';
import { deepClone, isDefinedAndNotNull } from '@app/core/utils';
import { deepClone } from '@app/core/utils';
import { AuditLogHeaderComponent } from '@home/components/audit-log/audit-log-header.component';
export class AuditLogTableConfig extends EntityTableConfig<AuditLog, TimePageLink> {
@ -84,7 +83,9 @@ export class AuditLogTableConfig extends EntityTableConfig<AuditLog, TimePageLin
this.entityResources = {
} as EntityTypeResource<AuditLog>;
if(!isDefinedAndNotNull(this.componentsData)) this.componentsData = {}
this.componentsData = {
auditLogFilter: []
};
this.entitiesFetchFunction = pageLink => this.fetchAuditLogs(pageLink);
@ -146,19 +147,16 @@ export class AuditLogTableConfig extends EntityTableConfig<AuditLog, TimePageLin
}
fetchAuditLogs(pageLink: TimePageLink): Observable<PageData<AuditLog>> {
const auditLogFilter: AuditLogRequestParams = deepClone(this.componentsData?.auditLogFilter) || {};
const auditLogFilter: AuditLogFilter = deepClone(this.componentsData?.auditLogFilter) || {};
switch (this.auditLogMode) {
case AuditLogMode.TENANT:
return this.auditLogService.getAuditLogs(this.prepareAuditLogQuery(pageLink, auditLogFilter));
return this.auditLogService.getAuditLogs(pageLink, auditLogFilter);
case AuditLogMode.ENTITY:
auditLogFilter.id = `${this.entityId.entityType}/${this.entityId.id}`;
return this.auditLogService.getAuditLogsByEntityId(this.prepareAuditLogQuery(pageLink, auditLogFilter));
return this.auditLogService.getAuditLogsByEntityId(this.entityId, pageLink, auditLogFilter);
case AuditLogMode.USER:
auditLogFilter.id = this.userId.id;
return this.auditLogService.getAuditLogsByUserId(this.prepareAuditLogQuery(pageLink, auditLogFilter));
return this.auditLogService.getAuditLogsByUserId(this.userId.id, pageLink, auditLogFilter);
case AuditLogMode.CUSTOMER:
auditLogFilter.id = this.customerId.id;
return this.auditLogService.getAuditLogsByCustomerId(this.prepareAuditLogQuery(pageLink, auditLogFilter));
return this.auditLogService.getAuditLogsByCustomerId(this.customerId.id, pageLink, auditLogFilter);
}
}
@ -172,8 +170,4 @@ export class AuditLogTableConfig extends EntityTableConfig<AuditLog, TimePageLin
});
}
prepareAuditLogQuery(pageLink: TimePageLink, auditLogFilter: AuditLogRequestParams): AuditLogQuery {
return new AuditLogQuery(pageLink, auditLogFilter);
}
}

3
ui-ngx/src/app/modules/home/components/audit-log/audit-log-table.component.ts

@ -97,9 +97,6 @@ export class AuditLogTableComponent implements OnInit {
}
}
@Input()
isFilterShown: boolean;
@ViewChild(EntitiesTableComponent, {static: true}) entitiesTable: EntitiesTableComponent;
auditLogTableConfig: AuditLogTableConfig;

6
ui-ngx/src/app/modules/home/components/entity/entity-table-header.component.ts

@ -17,8 +17,6 @@
import { BaseData, HasId } from '@shared/models/base-data';
import { PageComponent } from '@shared/components/page.component';
import { Directive, Input, OnInit } from '@angular/core';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
import { PageLink } from '@shared/models/page/page-link';
@ -41,8 +39,8 @@ export abstract class EntityTableHeaderComponent<T extends BaseData<HasId>,
return this.entitiesTableConfigValue;
}
protected constructor(protected store: Store<AppState>) {
super(store);
protected constructor(...args: unknown[]) {
super();
}
ngOnInit() {

6
ui-ngx/src/app/modules/home/components/home-components.module.ts

@ -23,7 +23,7 @@ import { DetailsPanelComponent } from '@home/components/details-panel.component'
import { EntityDetailsPanelComponent } from '@home/components/entity/entity-details-panel.component';
import { AuditLogDetailsDialogComponent } from '@home/components/audit-log/audit-log-details-dialog.component';
import { AuditLogTableComponent } from '@home/components/audit-log/audit-log-table.component';
import { AuditLogFilterComponent } from '@home/components/audit-log/audit-log-filter.component';
import { AuditLogHeaderComponent } from '@home/components/audit-log/audit-log-header.component';
import { EventTableHeaderComponent } from '@home/components/event/event-table-header.component';
import { EventTableComponent } from '@home/components/event/event-table.component';
import { EventFilterPanelComponent } from '@home/components/event/event-filter-panel.component';
@ -198,6 +198,7 @@ import {
import { CalculatedFieldsModule } from '@home/components/calculated-fields/calculated-field.module';
import { AlarmRuleModule } from "@home/components/alarm-rules/alarm-rule.module";
import { AlarmRulesTableComponent } from "@home/components/alarm-rules/alarm-rules-table.component";
import { AuditLogFilterComponent } from "@home/components/audit-log/audit-log-filter.component";
@NgModule({
declarations:
@ -209,7 +210,6 @@ import { AlarmRulesTableComponent } from "@home/components/alarm-rules/alarm-rul
EntityDetailsPanelComponent,
EntityDetailsPageComponent,
AuditLogTableComponent,
AuditLogFilterComponent,
AuditLogDetailsDialogComponent,
CalculatedFieldsTableComponent,
CalculatedFieldDebugDialogComponent,
@ -350,6 +350,8 @@ import { AlarmRulesTableComponent } from "@home/components/alarm-rules/alarm-rul
AIModelDialogComponent,
ResourcesDialogComponent,
ResourcesLibraryComponent,
AuditLogHeaderComponent,
AuditLogFilterComponent
],
imports: [
CommonModule,

7
ui-ngx/src/app/modules/home/pages/audit-log/audit-log.module.ts

@ -18,17 +18,12 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SharedModule } from '@shared/shared.module';
import { AuditLogRoutingModule } from '@modules/home/pages/audit-log/audit-log-routing.module';
import { AuditLogHeaderComponent } from '@home/components/audit-log/audit-log-header.component';
import { HomeComponentsModule } from '@home/components/public-api';
@NgModule({
declarations: [
AuditLogHeaderComponent,
],
declarations: [],
imports: [
CommonModule,
SharedModule,
HomeComponentsModule,
AuditLogRoutingModule
]
})

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

@ -20,9 +20,7 @@ import { CustomerId } from './id/customer-id';
import { EntityId } from './id/entity-id';
import { UserId } from './id/user-id';
import { TenantId } from './id/tenant-id';
import { PageLink } from '@shared/models/page/page-link';
import { isDefinedAndNotNull } from '@app/core/utils';
import { StringItemsOption } from '../components/string-items-list.component';
import {isArraysEqualIgnoreUndefined, isDefinedAndNotNull, isEmpty, isUndefinedOrNull} from "@core/utils";
export enum AuditLogMode {
TENANT,
@ -136,37 +134,18 @@ export interface AuditLog extends BaseData<AuditLogId> {
actionFailureDetails: string;
}
export interface AuditLogFilter {
types?: string[];
}
export interface AuditLogRequestParams {
types?: string[];
id?: string;
actionTypes?: string[];
}
export class AuditLogQuery {
pageLink: PageLink;
auditLogFilter: AuditLogRequestParams;
constructor(pageLink: PageLink, auditLogFilter: AuditLogRequestParams) {
this.pageLink = pageLink;
this.auditLogFilter = auditLogFilter;
export const auditLogFilterEquals = (filter1?: AuditLogFilter, filter2?: AuditLogFilter): boolean => {
if (filter1 === filter2) {
return true;
}
public toQuery(): string {
let query = '';
if(isDefinedAndNotNull(this.auditLogFilter.id)) {
query += `${this.auditLogFilter.id}`;
}
query += this.pageLink.toQuery();
if (isDefinedAndNotNull(this.auditLogFilter?.types)) {
const types = this.auditLogFilter.types.join(',');
query += `&actionTypes=${types}`;
}
return query;
if ((isUndefinedOrNull(filter1) || isEmpty(filter1)) && (isUndefinedOrNull(filter2) || isEmpty(filter2))) {
return true;
} else if (isDefinedAndNotNull(filter1) && isDefinedAndNotNull(filter2)) {
return isArraysEqualIgnoreUndefined(filter1.actionTypes, filter2.actionTypes);
}
}
return false;
};

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

@ -1038,7 +1038,8 @@
"filter":"Audit Log Filters",
"audit-log-filter-title": "Audit Log Filter",
"filter-title": "Filter",
"filter-type-add": "+ Add type"
"filter-type-add": "+ Add type",
"filter-types": "Audit Log Types"
},
"debug-settings": {
"label": "Debug Configuration",

Loading…
Cancel
Save