diff --git a/src/app/core/chat/discussion.service.ts b/src/app/core/chat/discussion.service.ts index 9bf68cf..1b99218 100644 --- a/src/app/core/chat/discussion.service.ts +++ b/src/app/core/chat/discussion.service.ts @@ -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 { return this.http.post(`${this.apiUrl}/discussions/group`, { groupName, usernames }); } + + getDiscussionMembers(discussionId: string): Observable { + return this.http.get(`${this.apiUrl}/discussions/${discussionId}/members`); + } + + getMembersWithRoles(discussionId: string): Observable { + return this.http.get(`${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 { + return this.http.post(`${this.apiUrl}/groups/${groupId}/members/${userId}/role`, { roleId }); + } } \ No newline at end of file diff --git a/src/app/pages/messages/messages-infouser/messages-infouser.component.css b/src/app/pages/messages/messages-infouser/messages-infouser.component.css index bf9091e..d6c01aa 100644 --- a/src/app/pages/messages/messages-infouser/messages-infouser.component.css +++ b/src/app/pages/messages/messages-infouser/messages-infouser.component.css @@ -40,4 +40,216 @@ font-size: 18px; font-weight: 500; color: #c07070; +} + +ion-modal { + --background: transparent; +} + +/* MODALE */ +.modal-layout { + display: flex; + flex-direction: column; + + height: 100%; + + background: radial-gradient( + ellipse at top, + #fff 0%, + #f9ece9 45%, + #f3d4cc 100% + ); + + border-radius: 22px 22px 0 0; + + box-shadow: 0 -12px 45px rgba(200, 120, 100, 0.25); + + overflow: hidden; +} + +/* HEADER */ + +.modal-header { + display: flex; + align-items: center; + justify-content: space-between; + + padding: 18px; + + background: rgba(255, 255, 255, 0.6); + backdrop-filter: blur(10px); + + border-bottom: 1px solid rgba(192, 112, 112, 0.15); +} + +.modal-title { + margin: 0; + font-size: 1.15rem; + font-weight: 700; + color: #c07070; +} + +/* CLOSE */ + +.modal-close-btn { + width: 38px; + height: 38px; + + border: none; + border-radius: 50%; + + background: #fff; + color: #c07070; + + display: flex; + align-items: center; + justify-content: center; + + box-shadow: 0 3px 12px rgba(200, 120, 100, 0.15); + + cursor: pointer; + + transition: all 0.2s ease; + + ion-icon { + font-size: 1.2rem; + } + + &:hover { + transform: translateY(-1px); + box-shadow: 0 6px 18px rgba(200, 120, 100, 0.22); + } + + &:active { + transform: scale(0.92); + } +} + +/* BODY */ + +.modal-body { + display: flex; + flex-direction: column; + gap: 12px; + + padding: 18px; + + overflow-y: auto; +} + +/* MEMBER CARD */ + +.member-card { + display: flex; + align-items: center; + justify-content: space-between; + + padding: 14px; + + background: rgba(255, 255, 255, 0.75); + border-radius: 16px; + + box-shadow: 0 2px 12px rgba(200, 120, 100, 0.12); + + transition: all 0.2s ease; + + &:hover { + transform: translateY(-2px); + background: rgba(255, 255, 255, 0.92); + } +} + +/* MEMBER INFO */ + +.member-info { + display: flex; + align-items: center; + gap: 12px; +} + +.member-info img { + width: 38px; + height: 38px; + border-radius: 50%; +} + +.member-text { + display: flex; + flex-direction: column; + gap: 2px; +} + +.member-name { + font-size: 0.95rem; + font-weight: 600; + color: #7a3a3a; +} + +.member-role { + font-size: 0.75rem; + color: rgba(122, 58, 58, 0.6); +} + +/* ROLE ASSIGN */ + +.role-assign { + display: flex; + align-items: center; + gap: 6px; +} + +/* INPUT */ + +.role-input { + width: 120px; + + padding: 8px 10px; + + border: 1px solid rgba(192, 112, 112, 0.25); + border-radius: 10px; + + background: rgba(255, 255, 255, 0.8); + + font-size: 0.85rem; + color: #7a3a3a; + + outline: none; + + transition: all 0.2s ease; + + &:focus { + border-color: #c07070; + box-shadow: 0 0 0 3px rgba(192, 112, 112, 0.15); + } +} + +/* BUTTON + */ + +.role-btn { + width: 34px; + height: 34px; + + border: none; + border-radius: 10px; + + background: #c07070; + color: white; + + font-size: 18px; + font-weight: 600; + + cursor: pointer; + + box-shadow: 0 2px 10px rgba(192, 112, 112, 0.25); + + transition: all 0.2s ease; + + &:hover { + transform: translateY(-1px); + box-shadow: 0 6px 16px rgba(192, 112, 112, 0.35); + } + + &:active { + transform: scale(0.92); + } } \ No newline at end of file diff --git a/src/app/pages/messages/messages-infouser/messages-infouser.component.html b/src/app/pages/messages/messages-infouser/messages-infouser.component.html index 4477fe4..28a77aa 100644 --- a/src/app/pages/messages/messages-infouser/messages-infouser.component.html +++ b/src/app/pages/messages/messages-infouser/messages-infouser.component.html @@ -1,6 +1,40 @@ - \ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/src/app/pages/messages/messages-infouser/messages-infouser.component.ts b/src/app/pages/messages/messages-infouser/messages-infouser.component.ts index 8bbbe6f..43d6163 100644 --- a/src/app/pages/messages/messages-infouser/messages-infouser.component.ts +++ b/src/app/pages/messages/messages-infouser/messages-infouser.component.ts @@ -1,15 +1,63 @@ -import {Component, inject, Input} from '@angular/core'; -import {AuthService} from "../../../core/auth/auth.service"; +import { Component, Input, inject, signal } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { IonModal, IonIcon } from '@ionic/angular/standalone'; +import { addIcons } from 'ionicons'; +import { closeOutline } from 'ionicons/icons'; +import { discussionsService, MemberWithRole } from '../../../core/chat/discussion.service'; +import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'app-messages-infouser', - imports: [], + imports: [CommonModule, IonModal, IonIcon, FormsModule], templateUrl: './messages-infouser.component.html', styleUrl: './messages-infouser.component.css' }) export class MessagesInfoUser { @Input() name: string = ''; - private authService = inject(AuthService); + @Input() groupId: number | null = null; - user = this.authService.currentUser; -} + private discussionService = inject(discussionsService); + private route = inject(ActivatedRoute); + + isModalOpen = signal(false); + members = signal([]); + newRoleInput: { [userId: number]: string } = {}; + + constructor() { + addIcons({ closeOutline }); + } + + openModal() { + const discussionId = this.route.snapshot.paramMap.get('discussionId')!; + this.discussionService.getMembersWithRoles(discussionId).subscribe({ + next: (members) => { + this.members.set(members); + this.isModalOpen.set(true); + } + }); + } + + closeModal() { this.isModalOpen.set(false); } + + assignRole(userId: number) { + const libelle = this.newRoleInput[userId]?.trim(); + if (!libelle || !this.groupId) return; + + this.discussionService.createRole(libelle).subscribe({ + next: (role) => { + this.discussionService.assignRole(this.groupId!, userId, role.id).subscribe({ + next: () => { + this.members.update(members => + members.map(m => m.userId === userId + ? { ...m, roleId: role.id, roleLibelle: libelle } + : m + ) + ); + this.newRoleInput[userId] = ''; + } + }); + } + }); + } +} \ No newline at end of file diff --git a/src/app/pages/messages/messages-main/messages-main.component.html b/src/app/pages/messages/messages-main/messages-main.component.html index f25738b..bcee0fe 100644 --- a/src/app/pages/messages/messages-main/messages-main.component.html +++ b/src/app/pages/messages/messages-main/messages-main.component.html @@ -2,7 +2,7 @@
- +
diff --git a/src/app/pages/messages/messages-main/messages-main.component.ts b/src/app/pages/messages/messages-main/messages-main.component.ts index b5b7c3b..c044bce 100644 --- a/src/app/pages/messages/messages-main/messages-main.component.ts +++ b/src/app/pages/messages/messages-main/messages-main.component.ts @@ -23,6 +23,7 @@ export class MessagesMain implements OnInit { currentUserId!: number; messages: Message[] = []; discussionName: string = ''; + groupId: number | null = null; ngOnInit() { this.currentDiscussionId = this.route.snapshot.paramMap.get('discussionId')!; @@ -31,7 +32,10 @@ export class MessagesMain implements OnInit { this.discussionService.getDiscussions().subscribe({ next: (discussions) => { const discussion = discussions.find(d => d.id === +this.currentDiscussionId); + console.log('discussion:', discussion); this.discussionName = discussion?.name ?? ''; + this.groupId = discussion?.groupId ?? null; + console.log('groupId:', this.groupId); } }); diff --git a/src/app/services/api/.openapi-generator/FILES b/src/app/services/api/.openapi-generator/FILES index 7cacb3a..548140c 100644 --- a/src/app/services/api/.openapi-generator/FILES +++ b/src/app/services/api/.openapi-generator/FILES @@ -27,7 +27,6 @@ model/knots-dto-key-delete-key-dto.ts model/knots-dto-message-create-message-dto.ts model/knots-dto-message-delete-message-dto.ts model/knots-dto-message-get-message-details-dto.ts -model/knots-dto-role-create-role-dto.ts model/knots-dto-role-delete-role-dto.ts model/knots-dto-user-create-user-dto.ts model/knots-dto-user-delete-user-dto.ts @@ -41,6 +40,10 @@ model/knots-dto-user-update-user-profile-picture-dto.ts model/knots-dto-user-update-username-dto.ts model/knots-endpoints-discussion-create-group-discussion-request.ts model/knots-endpoints-discussion-create-private-discussion-request.ts +model/knots-endpoints-discussion-member-with-role-dto.ts +model/knots-endpoints-role-assign-role-request.ts +model/knots-endpoints-role-create-role-request.ts +model/knots-endpoints-role-role-dto.ts model/models.ts param.ts provide-api.ts diff --git a/src/app/services/api/api/discussions.service.ts b/src/app/services/api/api/discussions.service.ts index 250b1dc..d8e7c43 100644 --- a/src/app/services/api/api/discussions.service.ts +++ b/src/app/services/api/api/discussions.service.ts @@ -28,6 +28,8 @@ import { KnotsDTOMessageGetMessageDetailsDto } from '../model/knots-dto-message- import { KnotsEndpointsDiscussionCreateGroupDiscussionRequest } from '../model/knots-endpoints-discussion-create-group-discussion-request'; // @ts-ignore import { KnotsEndpointsDiscussionCreatePrivateDiscussionRequest } from '../model/knots-endpoints-discussion-create-private-discussion-request'; +// @ts-ignore +import { KnotsEndpointsDiscussionMemberWithRoleDto } from '../model/knots-endpoints-discussion-member-with-role-dto'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -317,14 +319,15 @@ export class DiscussionsService extends BaseService { * @param name * @param isGroup * @param membersCount + * @param groupId * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. * @param options additional options */ - public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable; - public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable>; - public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable>; - public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable { + public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, groupId?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable; + public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, groupId?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable>; + public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, groupId?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable>; + public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, groupId?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable { if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getDiscussionEndpoint.'); } @@ -373,6 +376,15 @@ export class DiscussionsService extends BaseService { ); + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + 'groupId', + groupId, + QueryParamStyle.Form, + true, + ); + + let localVarHeaders = this.defaultHeaders; const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ @@ -413,6 +425,122 @@ export class DiscussionsService extends BaseService { ); } + /** + * @endpoint get /API/discussions/{discussionId}/members + * @param discussionId + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + * @param options additional options + */ + public getDiscussionMembersEndpoint(discussionId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDiscussionMembersEndpoint(discussionId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getDiscussionMembersEndpoint(discussionId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getDiscussionMembersEndpoint(discussionId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (discussionId === null || discussionId === undefined) { + throw new Error('Required parameter discussionId was null or undefined when calling getDiscussionMembersEndpoint.'); + } + + let localVarHeaders = this.defaultHeaders; + + // authentication (JWTBearerAuth) required + localVarHeaders = this.configuration.addCredentialToHeaders('JWTBearerAuth', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/API/discussions/${this.configuration.encodeParam({name: "discussionId", value: discussionId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/members`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request>('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + + /** + * @endpoint get /API/discussions/{discussionId}/members/roles + * @param discussionId + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + * @param options additional options + */ + public getDiscussionMembersWithRolesEndpoint(discussionId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDiscussionMembersWithRolesEndpoint(discussionId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getDiscussionMembersWithRolesEndpoint(discussionId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getDiscussionMembersWithRolesEndpoint(discussionId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (discussionId === null || discussionId === undefined) { + throw new Error('Required parameter discussionId was null or undefined when calling getDiscussionMembersWithRolesEndpoint.'); + } + + let localVarHeaders = this.defaultHeaders; + + // authentication (JWTBearerAuth) required + localVarHeaders = this.configuration.addCredentialToHeaders('JWTBearerAuth', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/API/discussions/${this.configuration.encodeParam({name: "discussionId", value: discussionId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/members/roles`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request>('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + /** * @endpoint get /API/discussions/{discussionId}/messages * @param discussionId diff --git a/src/app/services/api/api/groups.service.ts b/src/app/services/api/api/groups.service.ts index 14beb85..11d60b5 100644 --- a/src/app/services/api/api/groups.service.ts +++ b/src/app/services/api/api/groups.service.ts @@ -28,6 +28,8 @@ import { KnotsDTOGroupUpdateGroupMembersAmountDto } from '../model/knots-dto-gro import { KnotsDTOGroupUpdateGroupNameDto } from '../model/knots-dto-group-update-group-name-dto'; // @ts-ignore import { KnotsDTOGroupUpdateGroupProfilePictureDto } from '../model/knots-dto-group-update-group-profile-picture-dto'; +// @ts-ignore +import { KnotsEndpointsRoleAssignRoleRequest } from '../model/knots-endpoints-role-assign-role-request'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -45,6 +47,81 @@ export class GroupsService extends BaseService { super(basePath, configuration); } + /** + * @endpoint post /API/groups/{groupId}/members/{userId}/role + * @param groupId + * @param userId + * @param knotsEndpointsRoleAssignRoleRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + * @param options additional options + */ + public assignRoleEndpoint(groupId: string, userId: string, knotsEndpointsRoleAssignRoleRequest: KnotsEndpointsRoleAssignRoleRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable; + public assignRoleEndpoint(groupId: string, userId: string, knotsEndpointsRoleAssignRoleRequest: KnotsEndpointsRoleAssignRoleRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable>; + public assignRoleEndpoint(groupId: string, userId: string, knotsEndpointsRoleAssignRoleRequest: KnotsEndpointsRoleAssignRoleRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable>; + public assignRoleEndpoint(groupId: string, userId: string, knotsEndpointsRoleAssignRoleRequest: KnotsEndpointsRoleAssignRoleRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable { + if (groupId === null || groupId === undefined) { + throw new Error('Required parameter groupId was null or undefined when calling assignRoleEndpoint.'); + } + if (userId === null || userId === undefined) { + throw new Error('Required parameter userId was null or undefined when calling assignRoleEndpoint.'); + } + if (knotsEndpointsRoleAssignRoleRequest === null || knotsEndpointsRoleAssignRoleRequest === undefined) { + throw new Error('Required parameter knotsEndpointsRoleAssignRoleRequest was null or undefined when calling assignRoleEndpoint.'); + } + + let localVarHeaders = this.defaultHeaders; + + // authentication (JWTBearerAuth) required + localVarHeaders = this.configuration.addCredentialToHeaders('JWTBearerAuth', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/API/groups/${this.configuration.encodeParam({name: "groupId", value: groupId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/members/${this.configuration.encodeParam({name: "userId", value: userId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/role`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('post', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: knotsEndpointsRoleAssignRoleRequest, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + /** * @endpoint post /API/groups * @param knotsDTOGroupCreateGroupDto diff --git a/src/app/services/api/api/roles.service.ts b/src/app/services/api/api/roles.service.ts index 441abc4..61c2cd7 100644 --- a/src/app/services/api/api/roles.service.ts +++ b/src/app/services/api/api/roles.service.ts @@ -19,9 +19,11 @@ import { OpenApiHttpParams, QueryParamStyle } from '../query.params'; // @ts-ignore import { FastEndpointsErrorResponse } from '../model/fast-endpoints-error-response'; // @ts-ignore -import { KnotsDTORoleCreateRoleDto } from '../model/knots-dto-role-create-role-dto'; -// @ts-ignore import { KnotsDTORoleDeleteRoleDto } from '../model/knots-dto-role-delete-role-dto'; +// @ts-ignore +import { KnotsEndpointsRoleCreateRoleRequest } from '../model/knots-endpoints-role-create-role-request'; +// @ts-ignore +import { KnotsEndpointsRoleRoleDto } from '../model/knots-endpoints-role-role-dto'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -41,23 +43,26 @@ export class RolesService extends BaseService { /** * @endpoint post /API/roles - * @param knotsDTORoleCreateRoleDto + * @param knotsEndpointsRoleCreateRoleRequest * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. * @param options additional options */ - public createRoleEndpoint(knotsDTORoleCreateRoleDto: KnotsDTORoleCreateRoleDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/problem+json', context?: HttpContext, transferCache?: boolean}): Observable; - public createRoleEndpoint(knotsDTORoleCreateRoleDto: KnotsDTORoleCreateRoleDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/problem+json', context?: HttpContext, transferCache?: boolean}): Observable>; - public createRoleEndpoint(knotsDTORoleCreateRoleDto: KnotsDTORoleCreateRoleDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/problem+json', context?: HttpContext, transferCache?: boolean}): Observable>; - public createRoleEndpoint(knotsDTORoleCreateRoleDto: KnotsDTORoleCreateRoleDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/problem+json', context?: HttpContext, transferCache?: boolean}): Observable { - if (knotsDTORoleCreateRoleDto === null || knotsDTORoleCreateRoleDto === undefined) { - throw new Error('Required parameter knotsDTORoleCreateRoleDto was null or undefined when calling createRoleEndpoint.'); + public createRoleEndpoint(knotsEndpointsRoleCreateRoleRequest: KnotsEndpointsRoleCreateRoleRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public createRoleEndpoint(knotsEndpointsRoleCreateRoleRequest: KnotsEndpointsRoleCreateRoleRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public createRoleEndpoint(knotsEndpointsRoleCreateRoleRequest: KnotsEndpointsRoleCreateRoleRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public createRoleEndpoint(knotsEndpointsRoleCreateRoleRequest: KnotsEndpointsRoleCreateRoleRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (knotsEndpointsRoleCreateRoleRequest === null || knotsEndpointsRoleCreateRoleRequest === undefined) { + throw new Error('Required parameter knotsEndpointsRoleCreateRoleRequest was null or undefined when calling createRoleEndpoint.'); } let localVarHeaders = this.defaultHeaders; + // authentication (JWTBearerAuth) required + localVarHeaders = this.configuration.addCredentialToHeaders('JWTBearerAuth', 'Authorization', localVarHeaders, 'Bearer '); + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ - 'application/problem+json' + 'application/json' ]); if (localVarHttpHeaderAcceptSelected !== undefined) { localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); @@ -90,10 +95,10 @@ export class RolesService extends BaseService { let localVarPath = `/API/roles`; const { basePath, withCredentials } = this.configuration; - return this.httpClient.request('post', `${basePath}${localVarPath}`, + return this.httpClient.request('post', `${basePath}${localVarPath}`, { context: localVarHttpContext, - body: knotsDTORoleCreateRoleDto, + body: knotsEndpointsRoleCreateRoleRequest, responseType: responseType_, ...(withCredentials ? { withCredentials } : {}), headers: localVarHeaders, diff --git a/src/app/services/api/model/knots-endpoints-discussion-member-with-role-dto.ts b/src/app/services/api/model/knots-endpoints-discussion-member-with-role-dto.ts new file mode 100644 index 0000000..c9db5c3 --- /dev/null +++ b/src/app/services/api/model/knots-endpoints-discussion-member-with-role-dto.ts @@ -0,0 +1,18 @@ +/** + * Knots + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface KnotsEndpointsDiscussionMemberWithRoleDto { + userId?: number; + username?: string; + roleId?: number | null; + roleLibelle?: string | null; +} + diff --git a/src/app/services/api/model/knots-dto-role-create-role-dto.ts b/src/app/services/api/model/knots-endpoints-role-assign-role-request.ts similarity index 71% rename from src/app/services/api/model/knots-dto-role-create-role-dto.ts rename to src/app/services/api/model/knots-endpoints-role-assign-role-request.ts index 07cbf1f..fabcb6e 100644 --- a/src/app/services/api/model/knots-dto-role-create-role-dto.ts +++ b/src/app/services/api/model/knots-endpoints-role-assign-role-request.ts @@ -9,7 +9,7 @@ */ -export interface KnotsDTORoleCreateRoleDto { - libelle: string; +export interface KnotsEndpointsRoleAssignRoleRequest { + roleId?: number; } diff --git a/src/app/services/api/model/knots-endpoints-role-create-role-request.ts b/src/app/services/api/model/knots-endpoints-role-create-role-request.ts new file mode 100644 index 0000000..8b43923 --- /dev/null +++ b/src/app/services/api/model/knots-endpoints-role-create-role-request.ts @@ -0,0 +1,15 @@ +/** + * Knots + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface KnotsEndpointsRoleCreateRoleRequest { + libelle?: string; +} + diff --git a/src/app/services/api/model/knots-endpoints-role-role-dto.ts b/src/app/services/api/model/knots-endpoints-role-role-dto.ts new file mode 100644 index 0000000..23ff3b0 --- /dev/null +++ b/src/app/services/api/model/knots-endpoints-role-role-dto.ts @@ -0,0 +1,16 @@ +/** + * Knots + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface KnotsEndpointsRoleRoleDto { + id?: number; + libelle?: string; +} + diff --git a/src/app/services/api/model/models.ts b/src/app/services/api/model/models.ts index 5a273ba..dd6fb8f 100644 --- a/src/app/services/api/model/models.ts +++ b/src/app/services/api/model/models.ts @@ -11,7 +11,6 @@ export * from './knots-dto-key-delete-key-dto'; export * from './knots-dto-message-create-message-dto'; export * from './knots-dto-message-delete-message-dto'; export * from './knots-dto-message-get-message-details-dto'; -export * from './knots-dto-role-create-role-dto'; export * from './knots-dto-role-delete-role-dto'; export * from './knots-dto-user-create-user-dto'; export * from './knots-dto-user-delete-user-dto'; @@ -25,3 +24,7 @@ export * from './knots-dto-user-update-user-profile-picture-dto'; export * from './knots-dto-user-update-username-dto'; export * from './knots-endpoints-discussion-create-group-discussion-request'; export * from './knots-endpoints-discussion-create-private-discussion-request'; +export * from './knots-endpoints-discussion-member-with-role-dto'; +export * from './knots-endpoints-role-assign-role-request'; +export * from './knots-endpoints-role-create-role-request'; +export * from './knots-endpoints-role-role-dto';