move audit models to red-domain

This commit is contained in:
Dan Percic 2021-10-21 23:23:51 +03:00
parent ade00d4e28
commit d068d54568
12 changed files with 45 additions and 77 deletions

View File

@ -1,13 +1,12 @@
import { Component, forwardRef, Injector, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { AuditResponse, AuditSearchRequest, IAudit } from '@redaction/red-ui-http';
import { Moment } from 'moment';
import { applyIntervalConstraints } from '@utils/date-inputs-utils';
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 { Audit } from '@models/audit.model';
import { Audit, IAudit, IAuditResponse, IAuditSearchRequest } from '@red/domain';
import { AuditService } from '../../services/audit.service';
const PAGE_SIZE = 50;
@ -26,7 +25,7 @@ export class AuditScreenComponent extends ListingComponent<Audit> implements OnD
filterForm: FormGroup;
categories: string[] = [];
userIds: Set<string>;
logs: AuditResponse;
logs: IAuditResponse;
readonly tableColumnConfigs: TableColumnConfig<Audit>[] = [
{ label: _('audit-screen.table-col-names.message') },
{ label: _('audit-screen.table-col-names.date') },
@ -94,7 +93,7 @@ export class AuditScreenComponent extends ListingComponent<Audit> implements OnD
if (to) {
to = to.clone().add(1, 'd');
}
const logsRequestBody: AuditSearchRequest = {
const logsRequestBody: IAuditSearchRequest = {
pageSize: PAGE_SIZE,
page: page,
category: category === this.ALL_CATEGORIES ? undefined : category,

View File

@ -1,7 +1,8 @@
import { Injectable, Injector } from '@angular/core';
import { GenericService, RequiredParam, Validate } from '@iqser/common-ui';
import { AuditResponse, AuditSearchRequest, CategoryModel, IAudit } from '@redaction/red-ui-http';
import { CategoryModel } from '@redaction/red-ui-http';
import { Observable } from 'rxjs';
import { IAudit, IAuditResponse, IAuditSearchRequest } from '@red/domain';
@Injectable()
export class AuditService extends GenericService<IAudit> {
@ -14,7 +15,7 @@ export class AuditService extends GenericService<IAudit> {
}
@Validate()
searchAuditLog(@RequiredParam() body: AuditSearchRequest): Observable<AuditResponse> {
searchAuditLog(@RequiredParam() body: IAuditSearchRequest): Observable<IAuditResponse> {
return this._post(body, `${this._defaultModelPath}/search`);
}
}

View File

@ -4,3 +4,4 @@ export * from './lib/shared/types';
export * from './lib/dossier-attributes';
export * from './lib/users';
export * from './lib/pages';
export * from './lib/audit';

View File

@ -0,0 +1,10 @@
export interface IAuditSearchRequest {
readonly category?: string;
readonly from?: string;
readonly objectId?: string;
readonly page?: number;
readonly pageSize?: number;
readonly requestingUserId?: string;
readonly to?: string;
readonly userId?: string;
}

View File

@ -0,0 +1,9 @@
export interface IAudit {
readonly category: string;
readonly details?: unknown;
readonly message: string;
readonly objectId?: string;
readonly recordDate: string;
readonly recordId: string;
readonly userId: string;
}

View File

@ -1,14 +1,14 @@
import { IAudit } from '@redaction/red-ui-http';
import { IListable } from '@iqser/common-ui';
import { IAudit } from './audit.interface';
export class Audit implements IAudit, IListable {
readonly recordId?: number;
readonly category?: string;
readonly recordId: string;
readonly category: string;
readonly details?: unknown;
readonly message?: string;
readonly message: string;
readonly objectId?: string;
readonly recordDate: string;
readonly userId?: string;
readonly userId: string;
constructor(audit: IAudit) {
this.category = audit.category;
@ -21,7 +21,7 @@ export class Audit implements IAudit, IListable {
}
get id(): string {
return this.recordDate;
return this.recordId;
}
get searchKey(): string {

View File

@ -0,0 +1,9 @@
import { IAudit } from './audit.interface';
import { List } from '@iqser/common-ui';
export interface IAuditResponse {
data: List<IAudit>;
page?: number;
pageSize?: number;
totalHits?: number;
}

View File

@ -0,0 +1,4 @@
export * from './audit.model';
export * from './audit.interface';
export * from './audit.response';
export * from './audit-search.request';

View File

@ -1,21 +0,0 @@
/**
* API Documentation for Redaction Gateway
* Description for redaction
*
* OpenAPI spec version: 1.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
export interface IAudit {
readonly category?: string;
readonly details?: unknown;
readonly message?: string;
readonly objectId?: string;
readonly recordDate: string;
readonly recordId?: number;
readonly userId?: string;
}

View File

@ -1,19 +0,0 @@
/**
* API Documentation for Redaction Gateway
* Description for redaction
*
* OpenAPI spec version: 1.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import { IAudit } from './audit';
export interface AuditResponse {
data?: Array<IAudit>;
page?: number;
pageSize?: number;
totalHits?: number;
}

View File

@ -1,22 +0,0 @@
/**
* API Documentation for Redaction Gateway
* Description for redaction
*
* OpenAPI spec version: 1.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
export interface AuditSearchRequest {
category?: string;
from?: string;
objectId?: string;
page?: number;
pageSize?: number;
requestingUserId?: string;
to?: string;
userId?: string;
}

View File

@ -1,8 +1,5 @@
export * from './addRedactionRequest';
export * from './approveRequest';
export * from './audit';
export * from './auditResponse';
export * from './auditSearchRequest';
export * from './categoryModel';
export * from './cellRectangle';
export * from './change';