Commit 9f682bb0 authored by Tifenn Guillas's avatar Tifenn Guillas

WIP: Add comments for search module

parent acd2b3ee
......@@ -32,6 +32,10 @@ const routes: Routes = [
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
/**
* @class
* @classdesc Search routing module.
*/
export class SearchRoutingModule { }
export const routedComponents = [
......
......@@ -34,4 +34,8 @@ import { reducer } from './store/search.reducer';
],
providers: [SearchService]
})
/**
* @class
* @classdesc Search module.
*/
export class SearchModule { }
......@@ -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),
......
......@@ -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:
......
......@@ -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');
}
}
......@@ -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()
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment