Files
doneit-web/src/app/services/contacts.service.ts
T

62 lines
1.8 KiB
TypeScript
Raw Normal View History

2020-08-26 14:24:18 +01:00
import { Injectable } from '@angular/core';
import { EventPerson } from '../models/eventperson.model';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service';
2021-08-27 15:21:15 +01:00
import { LoginUserRespose } from '../models/user.model';
2022-10-12 17:01:09 +01:00
import { SessionStore } from '../store/session.service';
2023-01-24 15:56:47 +01:00
import { ChangeProfileService } from './change-profile.service';
2020-08-26 14:24:18 +01:00
@Injectable({
providedIn: 'root'
})
export class ContactsService {
authheader = {};
2021-08-27 15:21:15 +01:00
loggeduser: LoginUserRespose;
2020-08-26 14:24:18 +01:00
headers: HttpHeaders;
2023-07-25 15:56:42 +01:00
constacts: EventPerson[] = []
2023-01-24 15:56:47 +01:00
constructor(
private http: HttpClient,
user: AuthService,
private changeProfileService: ChangeProfileService) {
this.setHeader()
this.changeProfileService.registerCallback(() => {
this.setHeader()
})
2023-07-25 15:56:42 +01:00
this.getContacts("").subscribe( result => {
this.constacts = result
})
2023-01-24 15:56:47 +01:00
}
setHeader() {
2022-10-12 17:01:09 +01:00
this.loggeduser = SessionStore.user;
2023-10-25 09:08:49 +01:00
this.headers = new HttpHeaders();;
2023-11-29 12:17:52 +01:00
this.headers = this.headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
2020-08-26 14:24:18 +01:00
}
getContacts(namefilter:string): Observable<EventPerson[]>{
2023-06-26 11:12:57 +01:00
/* const geturl = environment.apiURL + 'contacts/get' */;
const geturl = environment.apiURL + 'userauthentication/list'
2020-08-26 14:24:18 +01:00
let params = new HttpParams();
2023-06-26 11:12:57 +01:00
/* params = params.set("namefilter", namefilter);
params = params.set("domain", environment.domain); */
2020-08-26 14:24:18 +01:00
params = params.set("namefilter", namefilter);
2023-06-26 11:12:57 +01:00
params = params.set("domain", "");
2020-08-26 14:24:18 +01:00
let options = {
headers: this.headers,
params: params
};
return this.http.get<EventPerson[]>(`${geturl}`, options);
}
}