From fe52b718d237aaca0cce869c2114a9589aacb598 Mon Sep 17 00:00:00 2001 From: Timo Date: Thu, 29 Apr 2021 14:46:38 +0300 Subject: [PATCH] changed user flow --- README.md | 2 +- .../user-listing-screen.component.ts | 2 +- apps/red-ui/src/app/services/user.service.ts | 4 +- .../src/lib/api/userController.service.ts | 156 ++++++------------ 4 files changed, 55 insertions(+), 109 deletions(-) diff --git a/README.md b/README.md index abe0df64e..804989140 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ To re-generate http rune swagger YOu need swagger-codegen installed `brew install swagger-codegen` ``` -BASE=https://redapi-staging.iqser.cloud/ +BASE=http://localhost:8080/ URL="$BASE"v2/api-docs?group=redaction-gateway-v1 mkdir -p /tmp/swagger swagger-codegen generate -i "$URL" -l typescript-angular -o /tmp/swagger diff --git a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts index 04757f5fb..487a127be 100644 --- a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts @@ -68,7 +68,7 @@ export class UserListingScreenComponent extends BaseListingComponent imple } private async _loadData() { - this.allEntities = (await this._userControllerService.getAllUsers({ requestId: new Date().toISOString() }, 0, 100).toPromise()).users; + this.allEntities = await this._userControllerService.getAllUsers().toPromise(); this._executeSearchImmediately(); this._computeStats(); this.viewReady = true; diff --git a/apps/red-ui/src/app/services/user.service.ts b/apps/red-ui/src/app/services/user.service.ts index b72f7c44b..9a2810b1e 100644 --- a/apps/red-ui/src/app/services/user.service.ts +++ b/apps/red-ui/src/app/services/user.service.ts @@ -89,8 +89,8 @@ export class UserService { } async loadAllUsers() { - const allUsers = await this._userControllerService.getUsers({ requestId: 'users' }, 0, 100).toPromise(); - this._allUsers = allUsers.users.filter((u) => this._hasAnyRedRole(u)); + const allUsers = await this._userControllerService.getUsers().toPromise(); + this._allUsers = allUsers.filter((u) => this._hasAnyRedRole(u)); return allUsers; } diff --git a/libs/red-ui-http/src/lib/api/userController.service.ts b/libs/red-ui-http/src/lib/api/userController.service.ts index ccf626223..f468765a6 100644 --- a/libs/red-ui-http/src/lib/api/userController.service.ts +++ b/libs/red-ui-http/src/lib/api/userController.service.ts @@ -19,8 +19,6 @@ import { Observable } from 'rxjs'; import { CreateUserRequest } from '../model/createUserRequest'; import { UpdateProfileRequest } from '../model/updateProfileRequest'; import { User } from '../model/user'; -import { UserSearchRequest } from '../model/userSearchRequest'; -import { UserSearchResponse } from '../model/userSearchResponse'; import { BASE_PATH } from '../variables'; import { Configuration } from '../configuration'; @@ -243,75 +241,6 @@ export class UserControllerService { }); } - /** - * Gets all the users in realm with information of roles. - * None - * @param body userSearchRequest - * @param offset offset - * @param limit limit - * @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. - */ - public getAllUsers(body: UserSearchRequest, offset?: number, limit?: number, observe?: 'body', reportProgress?: boolean): Observable; - public getAllUsers( - body: UserSearchRequest, - offset?: number, - limit?: number, - observe?: 'response', - reportProgress?: boolean - ): Observable>; - public getAllUsers( - body: UserSearchRequest, - offset?: number, - limit?: number, - observe?: 'events', - reportProgress?: boolean - ): Observable>; - public getAllUsers(body: UserSearchRequest, offset?: number, limit?: number, observe: any = 'body', reportProgress: boolean = false): Observable { - if (body === null || body === undefined) { - throw new Error('Required parameter body was null or undefined when calling getAllUsers.'); - } - - let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); - if (offset !== undefined && offset !== null) { - queryParameters = queryParameters.set('offset', offset); - } - if (limit !== undefined && limit !== null) { - queryParameters = queryParameters.set('limit', limit); - } - - let headers = this.defaultHeaders; - - // authentication (RED-OAUTH) required - if (this.configuration.accessToken) { - const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; - headers = headers.set('Authorization', 'Bearer ' + accessToken); - } - - // to determine the Accept header - const httpHeaderAccepts: string[] = ['application/json']; - const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); - if (httpHeaderAcceptSelected !== undefined) { - headers = headers.set('Accept', httpHeaderAcceptSelected); - } - - // to determine the Content-Type header - const consumes: string[] = ['application/json']; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - headers = headers.set('Content-Type', httpContentTypeSelected); - } - - return this.httpClient.request('post', `${this.basePath}/user/search/red/all`, { - body: body, - params: queryParameters, - withCredentials: this.configuration.withCredentials, - headers: headers, - observe: observe, - reportProgress: reportProgress - }); - } - /** * Gets the user in realm with information of roles. * None @@ -356,38 +285,17 @@ export class UserControllerService { /** * Gets the users who contain redaction roles. * None - * @param body userSearchRequest - * @param offset offset - * @param limit limit + * @param refreshCache refreshCache * @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. */ - public getUsers(body: UserSearchRequest, offset?: number, limit?: number, observe?: 'body', reportProgress?: boolean): Observable; - public getUsers( - body: UserSearchRequest, - offset?: number, - limit?: number, - observe?: 'response', - reportProgress?: boolean - ): Observable>; - public getUsers( - body: UserSearchRequest, - offset?: number, - limit?: number, - observe?: 'events', - reportProgress?: boolean - ): Observable>; - public getUsers(body: UserSearchRequest, offset?: number, limit?: number, observe: any = 'body', reportProgress: boolean = false): Observable { - if (body === null || body === undefined) { - throw new Error('Required parameter body was null or undefined when calling getUsers.'); - } - + public getUsers(refreshCache?: boolean, observe?: 'body', reportProgress?: boolean): Observable>; + public getUsers(refreshCache?: boolean, observe?: 'response', reportProgress?: boolean): Observable>>; + public getUsers(refreshCache?: boolean, observe?: 'events', reportProgress?: boolean): Observable>>; + public getUsers(refreshCache?: boolean, observe: any = 'body', reportProgress: boolean = false): Observable { let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); - if (offset !== undefined && offset !== null) { - queryParameters = queryParameters.set('offset', offset); - } - if (limit !== undefined && limit !== null) { - queryParameters = queryParameters.set('limit', limit); + if (refreshCache !== undefined && refreshCache !== null) { + queryParameters = queryParameters.set('refreshCache', refreshCache); } let headers = this.defaultHeaders; @@ -406,14 +314,52 @@ export class UserControllerService { } // to determine the Content-Type header - const consumes: string[] = ['application/json']; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - headers = headers.set('Content-Type', httpContentTypeSelected); + const consumes: string[] = []; + + return this.httpClient.request>('get', `${this.basePath}/user/red`, { + params: queryParameters, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); + } + + /** + * Gets all the users in realm with information of roles. + * None + * @param refreshCache refreshCache + * @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. + */ + public getAllUsers(refreshCache?: boolean, observe?: 'body', reportProgress?: boolean): Observable>; + public getAllUsers(refreshCache?: boolean, observe?: 'response', reportProgress?: boolean): Observable>>; + public getAllUsers(refreshCache?: boolean, observe?: 'events', reportProgress?: boolean): Observable>>; + public getAllUsers(refreshCache?: boolean, observe: any = 'body', reportProgress: boolean = false): Observable { + let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); + if (refreshCache !== undefined && refreshCache !== null) { + queryParameters = queryParameters.set('refreshCache', refreshCache); } - return this.httpClient.request('post', `${this.basePath}/user/search/red`, { - body: body, + let headers = this.defaultHeaders; + + // authentication (RED-OAUTH) required + if (this.configuration.accessToken) { + const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; + headers = headers.set('Authorization', 'Bearer ' + accessToken); + } + + // to determine the Accept header + const httpHeaderAccepts: string[] = ['application/json']; + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAcceptSelected !== undefined) { + headers = headers.set('Accept', httpHeaderAcceptSelected); + } + + // to determine the Content-Type header + const consumes: string[] = []; + + return this.httpClient.request>('get', `${this.basePath}/user`, { params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers,