Skip to content
Snippets Groups Projects
search-multiple.service.ts 1.12 KiB
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { environment } from '../../../environments/environment';
import { Observable } from "rxjs";
import { Attribute } from "../../metamodel/model";
import { map, tap, switchMap, withLatestFrom, catchError, delay } from 'rxjs/operators';
import { DatasetCount } from "./model";


@Injectable()
export class SearchMultipleService {
    API_PATH: string = environment.apiUrl;
    instanceName: string = environment.instanceName;

    constructor(private http: HttpClient) { }

    getCount(dname: string, query: string): Observable<DatasetCount> {
        return this.http.get<{ nb: number }[]>(this.API_PATH + '/search/' + query).pipe(
            map(res => {
                return {dname: dname, count: res[0].nb};
            })
        );
    }

    retrieveAttributeList(dname: string): Observable<Attribute[]> {
        return this.http.get<Attribute[]>(this.API_PATH + '/dataset/' + dname + '/attribute');
    }

    // retrieveData(query: string) {
    //     return this.http.get<any[]>(this.API_PATH + '/search/' + query);
    // }
}