fix audit
This commit is contained in:
parent
103234c9b0
commit
3ae7679090
@ -1,38 +0,0 @@
|
||||
import { AuditModel } from '@redaction/red-ui-http';
|
||||
import { IListable } from '@iqser/common-ui';
|
||||
|
||||
export class AuditModelWrapper implements IListable {
|
||||
constructor(public auditModel: AuditModel) {}
|
||||
|
||||
get category(): string {
|
||||
return this.auditModel.category;
|
||||
}
|
||||
|
||||
get details(): any {
|
||||
return this.auditModel.details;
|
||||
}
|
||||
|
||||
get message(): string {
|
||||
return this.auditModel.message;
|
||||
}
|
||||
|
||||
get recordId(): string {
|
||||
return this.auditModel.recordId;
|
||||
}
|
||||
|
||||
get recordDate(): string {
|
||||
return this.auditModel.recordDate;
|
||||
}
|
||||
|
||||
get objectId(): string {
|
||||
return this.auditModel.objectId;
|
||||
}
|
||||
|
||||
get userId(): string {
|
||||
return this.auditModel.userId;
|
||||
}
|
||||
|
||||
get id() {
|
||||
return this.auditModel.recordDate;
|
||||
}
|
||||
}
|
||||
30
apps/red-ui/src/app/models/audit.model.ts
Normal file
30
apps/red-ui/src/app/models/audit.model.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { IAudit } from '@redaction/red-ui-http';
|
||||
import { IListable } from '@iqser/common-ui';
|
||||
|
||||
export class Audit implements IAudit, IListable {
|
||||
readonly category?: string;
|
||||
readonly details?: unknown;
|
||||
readonly message?: string;
|
||||
readonly objectId?: string;
|
||||
readonly recordDate?: string;
|
||||
readonly recordId?: string;
|
||||
readonly userId?: string;
|
||||
|
||||
constructor(audit: IAudit) {
|
||||
this.category = audit.category;
|
||||
this.details = audit.details;
|
||||
this.message = audit.message;
|
||||
this.objectId = audit.objectId;
|
||||
this.recordDate = audit.recordDate;
|
||||
this.recordId = audit.recordId;
|
||||
this.userId = audit.userId;
|
||||
}
|
||||
|
||||
get id() {
|
||||
return this.recordDate;
|
||||
}
|
||||
|
||||
get searchKey(): string {
|
||||
return this.recordDate;
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
import { Component, forwardRef, Injector, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { AuditControllerService, AuditModel, AuditResponse, AuditSearchRequest } from '@redaction/red-ui-http';
|
||||
import { AuditControllerService, AuditResponse, AuditSearchRequest, IAudit } from '@redaction/red-ui-http';
|
||||
import { Moment } from 'moment';
|
||||
import { applyIntervalConstraints } from '@utils/date-inputs-utils';
|
||||
import { DefaultListingServices, KeysOf, ListingComponent, LoadingService, TableColumnConfig } from '@iqser/common-ui';
|
||||
import { DefaultListingServices, ListingComponent, LoadingService, TableColumnConfig } from '@iqser/common-ui';
|
||||
import { auditCategoriesTranslations } from '../../translations/audit-categories-translations';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { AuditModelWrapper } from '../../../../models/audit-model-wrapper.model';
|
||||
import { Audit } from '@models/audit.model';
|
||||
|
||||
const PAGE_SIZE = 50;
|
||||
|
||||
@ -17,22 +17,21 @@ const PAGE_SIZE = 50;
|
||||
styleUrls: ['./audit-screen.component.scss'],
|
||||
providers: [...DefaultListingServices, { provide: ListingComponent, useExisting: forwardRef(() => AuditScreenComponent) }]
|
||||
})
|
||||
export class AuditScreenComponent extends ListingComponent<AuditModelWrapper> implements OnDestroy, OnInit {
|
||||
export class AuditScreenComponent extends ListingComponent<Audit> implements OnDestroy, OnInit {
|
||||
readonly ALL_CATEGORIES = 'allCategories';
|
||||
readonly ALL_USERS = _('audit-screen.all-users');
|
||||
readonly translations = auditCategoriesTranslations;
|
||||
readonly currentUser = this._userService.currentUser;
|
||||
@ViewChild('messageTemplate', { static: true }) messageTemplate: TemplateRef<never>;
|
||||
@ViewChild('dateTemplate', { static: true }) dateTemplate: TemplateRef<never>;
|
||||
@ViewChild('userTemplate', { static: true }) userTemplate: TemplateRef<never>;
|
||||
@ViewChild('categoryTemplate', { static: true }) categoryTemplate: TemplateRef<never>;
|
||||
@ViewChild('messageTemplate', { static: true }) messageTemplate: TemplateRef<unknown>;
|
||||
@ViewChild('dateTemplate', { static: true }) dateTemplate: TemplateRef<unknown>;
|
||||
@ViewChild('userTemplate', { static: true }) userTemplate: TemplateRef<unknown>;
|
||||
@ViewChild('categoryTemplate', { static: true }) categoryTemplate: TemplateRef<unknown>;
|
||||
filterForm: FormGroup;
|
||||
categories: string[] = [];
|
||||
userIds: Set<string>;
|
||||
logs: AuditResponse;
|
||||
tableColumnConfigs: TableColumnConfig<AuditModelWrapper>[];
|
||||
tableColumnConfigs: TableColumnConfig<Audit>[];
|
||||
readonly tableHeaderLabel = _('audit-screen.table-header.title');
|
||||
protected readonly _primaryKey: KeysOf<AuditModelWrapper> = 'recordDate';
|
||||
private _previousFrom: Moment;
|
||||
private _previousTo: Moment;
|
||||
|
||||
@ -133,7 +132,7 @@ export class AuditScreenComponent extends ListingComponent<AuditModelWrapper> im
|
||||
this.categories = data[0].map(c => c.category);
|
||||
this.categories.splice(0, 0, this.ALL_CATEGORIES);
|
||||
this.logs = data[1];
|
||||
const entities = this.logs.data.map((log: AuditModel) => new AuditModelWrapper(log));
|
||||
const entities = this.logs.data.map((log: IAudit) => new Audit(log));
|
||||
this.entitiesService.setEntities(entities);
|
||||
this.userIds = new Set<string>([this.ALL_USERS]);
|
||||
for (const id of this.logs.data.map(log => log.userId).filter(uid => !!uid)) {
|
||||
|
||||
@ -28,14 +28,13 @@ interface ListItem extends IListable {
|
||||
providers: [...DefaultListingServices, { provide: ListingComponent, useExisting: forwardRef(() => DefaultColorsScreenComponent) }]
|
||||
})
|
||||
export class DefaultColorsScreenComponent extends ListingComponent<ListItem> implements OnInit {
|
||||
@ViewChild('nameTemplate', { static: true }) nameTemplate: TemplateRef<never>;
|
||||
@ViewChild('colorTemplate', { static: true }) colorTemplate: TemplateRef<never>;
|
||||
@ViewChild('nameTemplate', { static: true }) nameTemplate: TemplateRef<unknown>;
|
||||
@ViewChild('colorTemplate', { static: true }) colorTemplate: TemplateRef<unknown>;
|
||||
readonly circleButtonTypes = CircleButtonTypes;
|
||||
readonly currentUser = this._userService.currentUser;
|
||||
readonly translations = defaultColorsTranslations;
|
||||
readonly tableHeaderLabel = _('default-colors-screen.table-header.title');
|
||||
tableColumnConfigs: TableColumnConfig<ListItem>[];
|
||||
protected readonly _primaryKey = 'key';
|
||||
private _colorsObj: Colors;
|
||||
|
||||
constructor(
|
||||
@ -76,7 +75,7 @@ export class DefaultColorsScreenComponent extends ListingComponent<ListItem> imp
|
||||
this.tableColumnConfigs = [
|
||||
{
|
||||
label: _('default-colors-screen.table-col-names.key'),
|
||||
sortByKey: 'key',
|
||||
sortByKey: 'searchKey',
|
||||
template: this.nameTemplate,
|
||||
width: '2fr'
|
||||
},
|
||||
@ -92,9 +91,10 @@ export class DefaultColorsScreenComponent extends ListingComponent<ListItem> imp
|
||||
this._loadingService.start();
|
||||
const data = await this._dictionaryControllerService.getColors(this._appStateService.activeDossierTemplateId).toPromise();
|
||||
this._colorsObj = data;
|
||||
const entities = Object.keys(data).map(key => ({
|
||||
const entities: ListItem[] = Object.keys(data).map(key => ({
|
||||
id: key,
|
||||
key,
|
||||
searchKey: key,
|
||||
value: data[key]
|
||||
}));
|
||||
this.entitiesService.setEntities(entities);
|
||||
|
||||
@ -10,12 +10,12 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface AuditModel {
|
||||
category?: string;
|
||||
details?: any;
|
||||
message?: string;
|
||||
objectId?: string;
|
||||
recordDate?: string;
|
||||
recordId?: string;
|
||||
userId?: string;
|
||||
export interface IAudit {
|
||||
readonly category?: string;
|
||||
readonly details?: unknown;
|
||||
readonly message?: string;
|
||||
readonly objectId?: string;
|
||||
readonly recordDate?: string;
|
||||
readonly recordId?: string;
|
||||
readonly userId?: string;
|
||||
}
|
||||
@ -9,10 +9,10 @@
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { AuditModel } from './auditModel';
|
||||
import { IAudit } from './audit';
|
||||
|
||||
export interface AuditResponse {
|
||||
data?: Array<AuditModel>;
|
||||
data?: Array<IAudit>;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
totalHits?: number;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
export * from './addCommentRequest';
|
||||
export * from './addRedactionRequest';
|
||||
export * from './approveRequest';
|
||||
export * from './auditModel';
|
||||
export * from './audit';
|
||||
export * from './auditResponse';
|
||||
export * from './auditSearchRequest';
|
||||
export * from './authInfo';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user