From 9f682bb075ea0f138d376dcbb9c89f6a1f98c368 Mon Sep 17 00:00:00 2001 From: Tifenn Guillas <tifenn.guillas@lam.fr> Date: Thu, 12 Nov 2020 16:38:54 +0100 Subject: [PATCH] WIP: Add comments for search module --- src/app/search/search-routing.module.ts | 4 ++ src/app/search/search.module.ts | 4 ++ src/app/search/store/search.effects.ts | 6 ++- src/app/search/store/search.reducer.ts | 13 ++++++ src/app/search/store/search.service.ts | 44 +++++++++++++++++-- .../cone-search/store/cone-search.service.ts | 1 - 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/src/app/search/search-routing.module.ts b/src/app/search/search-routing.module.ts index b8f6be77..1b624492 100644 --- a/src/app/search/search-routing.module.ts +++ b/src/app/search/search-routing.module.ts @@ -32,6 +32,10 @@ const routes: Routes = [ imports: [RouterModule.forChild(routes)], exports: [RouterModule] }) +/** + * @class + * @classdesc Search routing module. + */ export class SearchRoutingModule { } export const routedComponents = [ diff --git a/src/app/search/search.module.ts b/src/app/search/search.module.ts index f4c02964..7209a044 100644 --- a/src/app/search/search.module.ts +++ b/src/app/search/search.module.ts @@ -34,4 +34,8 @@ import { reducer } from './store/search.reducer'; ], providers: [SearchService] }) +/** + * @class + * @classdesc Search module. + */ export class SearchModule { } diff --git a/src/app/search/store/search.effects.ts b/src/app/search/store/search.effects.ts index bc218a51..e4157218 100644 --- a/src/app/search/store/search.effects.ts +++ b/src/app/search/store/search.effects.ts @@ -32,6 +32,10 @@ import * as utils from '../../shared/utils'; import { getCriterionStr } from '../../shared/utils'; @Injectable() +/** + * @class + * @classdesc Search effects. + */ export class SearchEffects { constructor( private actions$: Actions, @@ -44,7 +48,7 @@ export class SearchEffects { coneSearch: fromConeSearch.State }> ) { } - + @Effect() initSearchByUrlAction$ = this.actions$.pipe( ofType(searchActions.INIT_SEARCH_BY_URL), diff --git a/src/app/search/store/search.reducer.ts b/src/app/search/store/search.reducer.ts index 8fde14f2..a7bc23d2 100644 --- a/src/app/search/store/search.reducer.ts +++ b/src/app/search/store/search.reducer.ts @@ -10,6 +10,11 @@ import * as actions from './search.action'; import { Criterion } from './model'; +/** + * Interface for search state. + * + * @interface State + */ export interface State { pristine: boolean; currentStep: string; @@ -50,6 +55,14 @@ export const initialState: State = { processId: null }; +/** + * Reduces state. + * + * @param {State} state - The state. + * @param {actions} action - The action. + * + * @return State + */ export function reducer(state: State = initialState, action: actions.Actions): State { switch (action.type) { case actions.CHANGE_STEP: diff --git a/src/app/search/store/search.service.ts b/src/app/search/store/search.service.ts index c601660f..f5f76ba1 100644 --- a/src/app/search/store/search.service.ts +++ b/src/app/search/store/search.service.ts @@ -10,29 +10,65 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; + import { environment } from '../../../environments/environment'; @Injectable() +/** + * @class + * @classdesc Search service. + */ export class SearchService { API_PATH: string = environment.apiUrl; instanceName: string = environment.instanceName; constructor(private http: HttpClient) { } - retrieveData(query: string) { + /** + * Retrieves results for the given parameters. + * + * @param {string} query - The query. + * + * @return Observable<any[]> + */ + retrieveData(query: string): Observable<any[]> { return this.http.get<any[]>(this.API_PATH + '/search/' + query); } - getDataLength(query: string) { + /** + * Retrieves results number for the given parameters. + * + * @param {string} query - The query. + * + * @return Observable<{ nb: number }[]> + */ + getDataLength(query: string): Observable<{ nb: number }[]> { return this.http.get<{ nb: number }[]>(this.API_PATH + '/search/' + query); } - executeProcess(typeProcess: string, dname: string, query: string) { + /** + * Executes process with the given parameters. + * + * @param {string} typeProcess - The process type. + * @param {string} dname - The dataset name. + * @param {string} query - The query. + * + * @return Observable<any> + */ + executeProcess(typeProcess: string, dname: string, query: string): Observable<any> { const url = this.API_PATH + '/service/' + this.instanceName + '/' + dname + '/' + typeProcess + query; return this.http.get<any>(url); } - checkProcess(id: string) { + /** + * Checks if process with the given ID is done. + * + * @param {string} id - The process ID. + * + * @return Observable<any> + */ + checkProcess(id: string): Observable<any> { return this.http.head<any>('http://0.0.0.0:8085/' + id + '.csv'); } } diff --git a/src/app/shared/cone-search/store/cone-search.service.ts b/src/app/shared/cone-search/store/cone-search.service.ts index 7f668473..37c3420e 100644 --- a/src/app/shared/cone-search/store/cone-search.service.ts +++ b/src/app/shared/cone-search/store/cone-search.service.ts @@ -10,7 +10,6 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { DatasetCount } from '../../../search-multiple/store/model'; @Injectable() /** -- GitLab