Rôles ajoutés
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { Observable } from "rxjs";
|
||||
import { Discussion } from "../../pages/menu/menu-users/menu-users.component";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { inject, Injectable } from "@angular/core";
|
||||
|
||||
@@ -11,6 +10,21 @@ export interface Message {
|
||||
authorName: string;
|
||||
}
|
||||
|
||||
export interface MemberWithRole {
|
||||
userId: number;
|
||||
username: string;
|
||||
roleId: number | null;
|
||||
roleLibelle: string | null;
|
||||
}
|
||||
|
||||
export interface Discussion {
|
||||
id: number;
|
||||
name: string;
|
||||
isGroup: boolean;
|
||||
membersCount?: number;
|
||||
groupId?: number;
|
||||
}
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class discussionsService {
|
||||
|
||||
@@ -32,4 +46,20 @@ export class discussionsService {
|
||||
createGroupDiscussion(groupName: string, usernames: string[]): Observable<Discussion> {
|
||||
return this.http.post<Discussion>(`${this.apiUrl}/discussions/group`, { groupName, usernames });
|
||||
}
|
||||
|
||||
getDiscussionMembers(discussionId: string): Observable<string[]> {
|
||||
return this.http.get<string[]>(`${this.apiUrl}/discussions/${discussionId}/members`);
|
||||
}
|
||||
|
||||
getMembersWithRoles(discussionId: string): Observable<MemberWithRole[]> {
|
||||
return this.http.get<MemberWithRole[]>(`${this.apiUrl}/discussions/${discussionId}/members/roles`);
|
||||
}
|
||||
|
||||
createRole(libelle: string): Observable<{ id: number, libelle: string }> {
|
||||
return this.http.post<{ id: number, libelle: string }>(`${this.apiUrl}/roles`, { libelle });
|
||||
}
|
||||
|
||||
assignRole(groupId: number, userId: number, roleId: number): Observable<void> {
|
||||
return this.http.post<void>(`${this.apiUrl}/groups/${groupId}/members/${userId}/role`, { roleId });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user