0% found this document useful (0 votes)
7 views1 page

User Service Ts

The document defines an Angular service named UserService that interacts with a REST API for user management. It includes methods to get user details by ID, retrieve all users, edit user information, and access different user roles such as public content, user board, moderator board, and admin board. Additionally, it provides functionality to enable or disable users through administrative requests.

Uploaded by

Almost Viral
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

User Service Ts

The document defines an Angular service named UserService that interacts with a REST API for user management. It includes methods to get user details by ID, retrieve all users, edit user information, and access different user roles such as public content, user board, moderator board, and admin board. Additionally, it provides functionality to enable or disable users through administrative requests.

Uploaded by

Almost Viral
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import { Injectable } from '@angular/core';

import { HttpClient } from '@angular/common/http';


import { Observable } from 'rxjs';

const API_URL = 'http://localhost:8080/api/test/';


const API_URL_USER = 'http://localhost:8080/api/user/';

@Injectable({
providedIn: 'root',
})
export class UserService {
constructor(private http: HttpClient) {}

getUserById(idUser:any): Observable<any> {
return this.http.get<any>(API_URL_USER + idUser);
}
getAllUser(){
return this.http.get<any[]>(API_URL_USER + 'all');
}

editUser(user:any){
return this.http.post<any>(API_URL_USER + 'edit',user);
}

getPublicContent(): Observable<any> {
return this.http.get(API_URL + 'all', { responseType: 'text' });
}

getUserBoard(): Observable<any> {
return this.http.get(API_URL + 'user', { responseType: 'text' });
}

getModeratorBoard(): Observable<any> {
return this.http.get(API_URL + 'mod', { responseType: 'text' });
}

enableUser(id: number): Observable<any> {


return this.http.get<any>(`${API_URL_USER}administrative-requests/enable/$
{id}`);
}

disableUser(id: number): Observable<any> {


return this.http.get<any>(`${API_URL_USER}administrative-requests/disable/$
{id}`);
}
getAdminBoard(): Observable<any> {
return this.http.get(API_URL + 'admin', { responseType: 'text' });
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy