argos/dmp-frontend/src/app/core/services/user/user.service.ts

50 lines
2.0 KiB
TypeScript
Raw Normal View History

2018-11-27 15:13:56 +01:00
import { HttpHeaders } from '@angular/common/http';
2018-02-01 15:04:36 +01:00
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
2019-01-18 18:03:45 +01:00
import { environment } from '../../../../environments/environment';
import { DataTableData } from '../../model/data-table/data-table-data';
import { DataTableRequest } from '../../model/data-table/data-table-request';
import { UserListingModel } from '../../model/user/user-listing';
import { UserCriteria } from '../../query/user/user-criteria';
import { BaseHttpService } from '../http/base-http.service';
2018-02-01 15:04:36 +01:00
@Injectable()
2019-01-18 18:03:45 +01:00
export class UserService {
2018-02-01 15:04:36 +01:00
2018-10-05 17:00:54 +02:00
private actionUrl: string;
private headers: HttpHeaders;
2018-02-01 15:04:36 +01:00
2018-10-05 17:00:54 +02:00
constructor(private http: BaseHttpService) {
2018-02-01 15:04:36 +01:00
this.actionUrl = environment.Server + 'user/';
2018-10-05 17:00:54 +02:00
}
2018-02-01 15:04:36 +01:00
2018-10-05 17:00:54 +02:00
getPaged(dataTableRequest: DataTableRequest<UserCriteria>): Observable<DataTableData<UserListingModel>> {
return this.http.post<DataTableData<UserListingModel>>(this.actionUrl + 'getPaged', JSON.stringify(dataTableRequest), { headers: this.headers });
}
2018-02-01 15:04:36 +01:00
2018-10-05 17:00:54 +02:00
getUser(id: String): Observable<UserListingModel> {
return this.http.get<UserListingModel>(this.actionUrl + id, { headers: this.headers });
}
2018-08-24 17:21:02 +02:00
2018-10-05 17:00:54 +02:00
updateRoles(itemToUpdate: UserListingModel): Observable<UserListingModel> {
return this.http.post<UserListingModel>(this.actionUrl + 'updateRoles', JSON.stringify(itemToUpdate), { headers: this.headers });
}
2018-02-01 15:04:36 +01:00
2018-10-05 17:00:54 +02:00
delete(id: String): Observable<any> {
return this.http.delete<any>(this.actionUrl + id, { headers: this.headers });
}
2018-03-21 14:15:06 +01:00
2018-10-05 17:00:54 +02:00
getRecentActivity(): Observable<any[]> {
return this.http.get<any[]>(this.actionUrl + 'recentActivity', { headers: this.headers });
}
2018-08-30 13:09:36 +02:00
2018-10-05 17:00:54 +02:00
updateUserSettings(value: any): Observable<any[]> {
return this.http.post<any[]>(this.actionUrl + 'settings', value, { headers: this.headers });
}
getCollaboratorsPaged(dataTableRequest: DataTableRequest<UserCriteria>): Observable<DataTableData<UserListingModel>> {
return this.http.post<DataTableData<UserListingModel>>(this.actionUrl + 'getCollaboratorsPaged', JSON.stringify(dataTableRequest), { headers: this.headers });
}
2018-02-01 15:04:36 +01:00
}