move search models to red-domain

This commit is contained in:
Dan Percic 2021-10-21 15:12:21 +03:00
parent 4d8342f492
commit 47333c97c0
9 changed files with 32 additions and 27 deletions

View File

@ -10,7 +10,6 @@ import {
SearchPositions,
TableColumnConfig,
} from '@iqser/common-ui';
import { MatchedDocument, SearchResult } from '@redaction/red-ui-http';
import { BehaviorSubject, Observable } from 'rxjs';
import { debounceTime, map, skip, switchMap, tap } from 'rxjs/operators';
import { ActivatedRoute, Router } from '@angular/router';
@ -20,6 +19,7 @@ import { TranslateService } from '@ngx-translate/core';
import { RouterHistoryService } from '@services/router-history.service';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { PlatformSearchService } from '../../shared/services/platform-search.service';
import { IMatchedDocument, ISearchResponse } from '@red/domain';
interface ListItem extends IListable {
readonly dossierId: string;
@ -109,7 +109,7 @@ export class SearchScreenComponent extends ListingComponent<ListItem> implements
this._router.navigate([], { queryParams }).then();
}
private _search(searchInput: SearchInput): Observable<SearchResult> {
private _search(searchInput: SearchInput): Observable<ISearchResponse> {
return this._platformSearchService.search({
dossierIds: [...searchInput.dossierIds],
queryString: searchInput.query ?? '',
@ -127,15 +127,15 @@ export class SearchScreenComponent extends ListingComponent<ListItem> implements
this.search$.next({ query, dossierIds: dossierId ? [dossierId] : [] });
}
private _toMatchedDocuments({ matchedDocuments }: SearchResult): MatchedDocument[] {
private _toMatchedDocuments({ matchedDocuments }: ISearchResponse): IMatchedDocument[] {
return matchedDocuments.filter(doc => doc.score > 0 && doc.matchedTerms.length > 0);
}
private _toListItems(matchedDocuments: MatchedDocument[]): ListItem[] {
private _toListItems(matchedDocuments: IMatchedDocument[]): ListItem[] {
return matchedDocuments.map(document => this._toListItem(document)).filter(value => value);
}
private _toListItem({ dossierId, fileId, unmatchedTerms, highlights }: MatchedDocument): ListItem {
private _toListItem({ dossierId, fileId, unmatchedTerms, highlights }: IMatchedDocument): ListItem {
const file = this._dossiersService.find(dossierId, fileId);
if (!file) {
return undefined;

View File

@ -1,14 +1,14 @@
import { Injectable, Injector } from '@angular/core';
import { GenericService } from '@iqser/common-ui';
import { SearchRequest, SearchResult } from '@redaction/red-ui-http';
import { ISearchRequest, ISearchResponse } from '@red/domain';
@Injectable()
export class PlatformSearchService extends GenericService<SearchResult> {
export class PlatformSearchService extends GenericService<ISearchResponse> {
constructor(protected readonly _injector: Injector) {
super(_injector, 'search');
}
search(body: SearchRequest) {
search(body: ISearchRequest) {
return this._post(body);
}
}

View File

@ -1,2 +1,3 @@
export * from './lib/dossiers';
export * from './lib/search';
export * from './lib/shared/types';

View File

@ -0,0 +1,4 @@
export * from './matched-document';
export * from './matched-section';
export * from './search.request';
export * from './search.response';

View File

@ -9,16 +9,17 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import { MatchedSection } from './matchedSection';
import { IMatchedSection } from './matched-section';
import { List } from '@iqser/common-ui';
export interface MatchedDocument {
export interface IMatchedDocument {
containsAllMatchedSections?: boolean;
dossierId?: string;
dossierTemplateId?: string;
fileId?: string;
highlights?: { [key: string]: Array<string> };
matchedSections?: Array<MatchedSection>;
matchedTerms?: Array<string>;
highlights?: { [key: string]: List };
matchedSections?: List<IMatchedSection>;
matchedTerms?: List;
score?: number;
unmatchedTerms?: Array<string>;
unmatchedTerms?: List;
}

View File

@ -9,10 +9,11 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import { List } from '@iqser/common-ui';
export interface MatchedSection {
export interface IMatchedSection {
headline?: string;
matchedTerms?: Array<string>;
pages?: Array<number>;
matchedTerms?: List;
pages?: List<number>;
sectionNumber?: number;
}

View File

@ -9,10 +9,11 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import { List } from '@iqser/common-ui';
export interface SearchRequest {
dossierIds?: Array<string>;
dossierTemplateIds?: Array<string>;
export interface ISearchRequest {
dossierIds?: List;
dossierTemplateIds?: List;
fileId?: string;
page?: number;
pageSize?: number;

View File

@ -9,10 +9,11 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import { MatchedDocument } from './matchedDocument';
import { IMatchedDocument } from './matched-document';
import { List } from '@iqser/common-ui';
export interface SearchResult {
matchedDocuments?: Array<MatchedDocument>;
export interface ISearchResponse {
matchedDocuments?: List<IMatchedDocument>;
maxScore?: number;
total?: number;
}

View File

@ -37,8 +37,6 @@ export * from './licenseReport';
export * from './licenseReportRequest';
export * from './manualAddResponse';
export * from './manualRedactionEntry';
export * from './matchedDocument';
export * from './matchedSection';
export * from './notification.model';
export * from './notificationResponse';
export * from './pageExclusionRequest';
@ -56,8 +54,6 @@ export * from './reportTemplate';
export * from './resetPasswordRequest';
export * from './rules';
export * from './smtp-configuration';
export * from './searchRequest';
export * from './searchResult';
export * from './sectionGrid';
export * from './sectionRectangle';
export * from './updateMyProfileRequest';