From 80906d22a60de370601fc56933c95eda50157270 Mon Sep 17 00:00:00 2001 From: Marcin Czachurski Date: Sun, 3 Nov 2024 08:25:25 +0100 Subject: [PATCH] Only local filter on users list --- src/app/models/user.ts | 1 + src/app/pages/users/users.page.html | 44 ++++++++++++++++---------- src/app/pages/users/users.page.scss | 9 ++++++ src/app/pages/users/users.page.ts | 12 ++++--- src/app/services/http/users.service.ts | 4 +-- 5 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/app/models/user.ts b/src/app/models/user.ts index 0f6f271..b3614a6 100644 --- a/src/app/models/user.ts +++ b/src/app/models/user.ts @@ -30,6 +30,7 @@ export class User { public twoFactorEnabled = false; public manuallyApprovesFollowers = false; public featured = false; + public lastLoginDate = ''; public createdAt = ''; public updatedAt = ''; } diff --git a/src/app/pages/users/users.page.html b/src/app/pages/users/users.page.html index e34870c..45fab48 100644 --- a/src/app/pages/users/users.page.html +++ b/src/app/pages/users/users.page.html @@ -18,6 +18,11 @@

+
+ + Only local + +
@@ -28,21 +33,9 @@

- - - - - - - - User name
- + A M @@ -52,11 +45,18 @@

- - - Full name + + + Name - {{ element.name }} + +
+ {{ element.name }} +
@@ -98,6 +98,16 @@

+ + + Last login + + + {{ element.lastLoginDate | date: 'short' }} + + + + Created date diff --git a/src/app/pages/users/users.page.scss b/src/app/pages/users/users.page.scss index 77041d7..bbf8a2a 100644 --- a/src/app/pages/users/users.page.scss +++ b/src/app/pages/users/users.page.scss @@ -18,6 +18,15 @@ h1 { display: block; } +.name { + width: 140px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + display: block; +} + + ::ng-deep .mat-mdc-form-field-subscript-wrapper { height: 0; } \ No newline at end of file diff --git a/src/app/pages/users/users.page.ts b/src/app/pages/users/users.page.ts index 7a3f06a..59be7a0 100644 --- a/src/app/pages/users/users.page.ts +++ b/src/app/pages/users/users.page.ts @@ -30,6 +30,7 @@ export class UsersPage extends ResponsiveComponent implements OnInit { readonly role = Role; search = ''; + onlyLocal = false; isReady = false; pageIndex = 0; users?: PaginableResult; @@ -38,8 +39,8 @@ export class UsersPage extends ResponsiveComponent implements OnInit { private readonly displayedColumnsHandsetPortrait: string[] = ['avatar', 'userName', 'actions']; private readonly displayedColumnsHandsetLandscape: string[] = ['avatar', 'userName', 'createdAt', 'actions']; - private readonly displayedColumnsTablet: string[] = ['avatar', 'userName', 'userFullName', 'email', 'isApproved', 'createdAt', 'actions']; - private readonly displayedColumnsBrowser: string[] = ['avatar', 'userName', 'userFullName', 'email', 'isLocal', 'isApproved', 'statuses', 'createdAt', 'actions']; + private readonly displayedColumnsTablet: string[] = ['avatar', 'userName', 'email', 'isApproved', 'lastLoginDate', 'createdAt', 'actions']; + private readonly displayedColumnsBrowser: string[] = ['avatar', 'userName', 'email', 'isLocal', 'isApproved', 'statuses', 'lastLoginDate', 'createdAt', 'actions']; constructor( private authorizationService: AuthorizationService, @@ -68,13 +69,16 @@ export class UsersPage extends ResponsiveComponent implements OnInit { const pageString = params['page'] as string; const sizeString = params['size'] as string; const query = params['query'] as string; + const local = params['onlyLocal'] as string; const page = pageString ? +pageString : 0; const size = sizeString ? +sizeString : 10; this.pageIndex = page; this.search = query - this.users = await this.usersService.get(page + 1, size, query); + this.onlyLocal = local === 'true'; + + this.users = await this.usersService.get(page + 1, size, query, this.onlyLocal); this.isReady = true; this.loadingService.hideLoader(); @@ -83,7 +87,7 @@ export class UsersPage extends ResponsiveComponent implements OnInit { async onSubmit(): Promise { const navigationExtras: NavigationExtras = { - queryParams: { query: this.search }, + queryParams: { query: this.search, onlyLocal: this.onlyLocal }, queryParamsHandling: 'merge' }; diff --git a/src/app/services/http/users.service.ts b/src/app/services/http/users.service.ts index 3f2a8c8..6524d8e 100644 --- a/src/app/services/http/users.service.ts +++ b/src/app/services/http/users.service.ts @@ -16,8 +16,8 @@ export class UsersService { constructor(private httpClient: HttpClient, private windowService: WindowService) { } - public async get(page: number, size: number, query: string): Promise> { - const event$ = this.httpClient.get>(this.windowService.apiUrl() + `/api/v1/users?page=${page}&size=${size}&query=${query ?? ''}`); + public async get(page: number, size: number, query: string, onlyLocal = false): Promise> { + const event$ = this.httpClient.get>(this.windowService.apiUrl() + `/api/v1/users?page=${page}&size=${size}&query=${query ?? ''}&onlyLocal=${onlyLocal}`); return await firstValueFrom(event$); }