This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
search-service.ts 1.22 KiB
Newer Older
Michael Breu's avatar
Michael Breu committed
import { Injectable } from '@angular/core';
import { HttpClient, HttpResponse, HttpParams } from '@angular/common/http';
Michael Breu's avatar
Michael Breu committed
import { Observable } from 'rxjs';

import { SERVER_API_URL } from 'app/app.constants';
import { SearchResultsDTO } from 'app/shared/model/search/search-results-dto.model';
import { SearchInput } from 'app/shared/model/search-input.model';

type EntityResponseTypeAutoComplete = HttpResponse<Array<string>>;

Michael Breu's avatar
Michael Breu committed
@Injectable({ providedIn: 'root' })
export class SearchService {
  public resourceSearchUrlPageDetails = SERVER_API_URL + 'api/search/page-details';
  public resourceKeywordsAutoCompleteDetails = SERVER_API_URL + 'api/search/keywordsAutoComplete';
Michael Breu's avatar
Michael Breu committed

  constructor(protected http: HttpClient) {}

  searchPageDetails(searchInput: SearchInput): Observable<SearchResultsDTO> {
    return this.http
      .post<SearchResultsDTO>(this.resourceSearchUrlPageDetails, searchInput);
  getKeywordsAutoComplete(prefix: string): Observable<Array<string>> {
	  const options: HttpParams = new HttpParams();
	options.append("keyWordPrefix", prefix);
    return this.http
      .get<Array<string>>(this.resourceKeywordsAutoCompleteDetails,
                {params: new HttpParams().set('keyWordPrefix', prefix) }
		);

  }