mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Add service for search
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SearchService } from './search.service';
|
||||
|
||||
describe('SearchService', () => {
|
||||
let service: SearchService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(SearchService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Event } from '../models/event.model';
|
||||
import { Observable } from 'rxjs';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { AuthService } from '../services/auth.service';
|
||||
import { User } from '../models/user.model';
|
||||
import { EventSearch } from "src/app/models/event-search";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SearchService {
|
||||
// state
|
||||
authheader = {};
|
||||
loggeduser: User;
|
||||
headers: HttpHeaders;
|
||||
|
||||
|
||||
|
||||
categories= Array;
|
||||
|
||||
// setup
|
||||
constructor(private http: HttpClient, user: AuthService) {
|
||||
this.loggeduser = user.ValidatedUser;
|
||||
this.headers = new HttpHeaders();
|
||||
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||
}
|
||||
|
||||
|
||||
basicSearch(subject:string, date:string, sender:string, organicEntity:string, docTypeId:string): Observable<EventSearch>{
|
||||
// Endpoint
|
||||
const geturl = environment.apiURL + 'search';
|
||||
// store params
|
||||
let params = new HttpParams();
|
||||
// set https params
|
||||
console.log(subject);
|
||||
|
||||
params = params.set("assunto", 'actividades');
|
||||
params = params.set("data", date);
|
||||
params = params.set("remetente", sender);
|
||||
params = params.set("entidadeOrganica", organicEntity);
|
||||
params = params.set("docTypeId", docTypeId);
|
||||
|
||||
|
||||
const options = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
};
|
||||
|
||||
return this.http.get<EventSearch>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user