diff --git a/apps/red-ui/src/app/models/audit-model-wrapper.model.ts b/apps/red-ui/src/app/models/audit-model-wrapper.model.ts deleted file mode 100644 index 6fef346cf..000000000 --- a/apps/red-ui/src/app/models/audit-model-wrapper.model.ts +++ /dev/null @@ -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; - } -} diff --git a/apps/red-ui/src/app/models/audit.model.ts b/apps/red-ui/src/app/models/audit.model.ts new file mode 100644 index 000000000..3fab0969d --- /dev/null +++ b/apps/red-ui/src/app/models/audit.model.ts @@ -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; + } +} diff --git a/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.ts index 5451a3c57..49eac232b 100644 --- a/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.ts @@ -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 implements OnDestroy, OnInit { +export class AuditScreenComponent extends ListingComponent 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; - @ViewChild('dateTemplate', { static: true }) dateTemplate: TemplateRef; - @ViewChild('userTemplate', { static: true }) userTemplate: TemplateRef; - @ViewChild('categoryTemplate', { static: true }) categoryTemplate: TemplateRef; + @ViewChild('messageTemplate', { static: true }) messageTemplate: TemplateRef; + @ViewChild('dateTemplate', { static: true }) dateTemplate: TemplateRef; + @ViewChild('userTemplate', { static: true }) userTemplate: TemplateRef; + @ViewChild('categoryTemplate', { static: true }) categoryTemplate: TemplateRef; filterForm: FormGroup; categories: string[] = []; userIds: Set; logs: AuditResponse; - tableColumnConfigs: TableColumnConfig[]; + tableColumnConfigs: TableColumnConfig[]; readonly tableHeaderLabel = _('audit-screen.table-header.title'); - protected readonly _primaryKey: KeysOf = 'recordDate'; private _previousFrom: Moment; private _previousTo: Moment; @@ -133,7 +132,7 @@ export class AuditScreenComponent extends ListingComponent 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([this.ALL_USERS]); for (const id of this.logs.data.map(log => log.userId).filter(uid => !!uid)) { diff --git a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts index 51d190d8e..5a8197992 100644 --- a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts @@ -28,14 +28,13 @@ interface ListItem extends IListable { providers: [...DefaultListingServices, { provide: ListingComponent, useExisting: forwardRef(() => DefaultColorsScreenComponent) }] }) export class DefaultColorsScreenComponent extends ListingComponent implements OnInit { - @ViewChild('nameTemplate', { static: true }) nameTemplate: TemplateRef; - @ViewChild('colorTemplate', { static: true }) colorTemplate: TemplateRef; + @ViewChild('nameTemplate', { static: true }) nameTemplate: TemplateRef; + @ViewChild('colorTemplate', { static: true }) colorTemplate: TemplateRef; readonly circleButtonTypes = CircleButtonTypes; readonly currentUser = this._userService.currentUser; readonly translations = defaultColorsTranslations; readonly tableHeaderLabel = _('default-colors-screen.table-header.title'); tableColumnConfigs: TableColumnConfig[]; - protected readonly _primaryKey = 'key'; private _colorsObj: Colors; constructor( @@ -76,7 +75,7 @@ export class DefaultColorsScreenComponent extends ListingComponent 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 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); diff --git a/libs/red-ui-http/src/lib/model/auditModel.ts b/libs/red-ui-http/src/lib/model/audit.ts similarity index 53% rename from libs/red-ui-http/src/lib/model/auditModel.ts rename to libs/red-ui-http/src/lib/model/audit.ts index 8bef378ea..9427a4896 100644 --- a/libs/red-ui-http/src/lib/model/auditModel.ts +++ b/libs/red-ui-http/src/lib/model/audit.ts @@ -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; } diff --git a/libs/red-ui-http/src/lib/model/auditResponse.ts b/libs/red-ui-http/src/lib/model/auditResponse.ts index 33803a1aa..e47bd2dc9 100644 --- a/libs/red-ui-http/src/lib/model/auditResponse.ts +++ b/libs/red-ui-http/src/lib/model/auditResponse.ts @@ -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; + data?: Array; page?: number; pageSize?: number; totalHits?: number; diff --git a/libs/red-ui-http/src/lib/model/models.ts b/libs/red-ui-http/src/lib/model/models.ts index d81199479..e45355189 100644 --- a/libs/red-ui-http/src/lib/model/models.ts +++ b/libs/red-ui-http/src/lib/model/models.ts @@ -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';