master #475
| @@ -370,7 +370,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): | ||||
|                 `LoginMessageChannelId` = {self._login_message_channel_id}, | ||||
|                 `DefaultRoleId` = {"NULL" if self._default_role_id is None else self._default_role_id}, | ||||
|                 `ShortRoleNameSetOnlyHighest` = {self._short_role_name_only_set_highest_role}, | ||||
|                 `GameOfferNotificationChatId` = {self._game_offer_notification_chat_id}, | ||||
|                 `GameOfferNotificationChatId` = {"NULL" if self._game_offer_notification_chat_id is None else self._game_offer_notification_chat_id}, | ||||
|                 `ResetMemberAfterRejoin` = {self._reset_member_after_rejoin}, | ||||
|                 `FeatureFlags` = '{json.dumps(self._feature_flags)}', | ||||
|                 `ServerId` = {self._server.id} | ||||
|   | ||||
| @@ -44,7 +44,7 @@ class UserWarningFilter(FilterABC): | ||||
|  | ||||
|         if self._user is not None: | ||||
|             users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) | ||||
|             query = query.where(lambda x: x.id in users) | ||||
|             query = query.where(lambda x: x.user.id in users) | ||||
|  | ||||
|         if self._description is not None: | ||||
|             query = query.where(lambda x: x.description == self._description or self._description in x.description) | ||||
|   | ||||
| @@ -520,10 +520,10 @@ export class Queries { | ||||
|   `; | ||||
|  | ||||
|   static userWarningsQuery = ` | ||||
|     query userWarnings($serverId: ID, $page: Page, $sort: Sort) { | ||||
|     query userWarnings($serverId: ID, $filter: UserWarningFilter, $page: Page, $sort: Sort) { | ||||
|       servers(filter: {id: $serverId}) { | ||||
|         userWarningCount | ||||
|         userWarnings(page: $page, sort: $sort) { | ||||
|         userWarnings(filter: $filter, page: $page, sort: $sort) { | ||||
|           id | ||||
|           user { | ||||
|             id | ||||
|   | ||||
| @@ -48,21 +48,21 @@ | ||||
|           <th hideable-th="description" [parent]="this" [sortable]="true"> | ||||
|             <div class="table-header-label"> | ||||
|               <div class="table-header-text">{{'common.description' | translate}}</div> | ||||
|               <p-sortIcon field="name" class="table-header-icon"></p-sortIcon> | ||||
|               <p-sortIcon field="description" class="table-header-icon"></p-sortIcon> | ||||
|             </div> | ||||
|           </th> | ||||
|  | ||||
|           <th hideable-th="member" [parent]="this" [sortable]="true"> | ||||
|             <div class="table-header-label"> | ||||
|               <div class="table-header-text">{{'common.member' | translate}}</div> | ||||
|               <p-sortIcon field="attribute" class="table-header-icon"></p-sortIcon> | ||||
|               <p-sortIcon field="user" class="table-header-icon"></p-sortIcon> | ||||
|             </div> | ||||
|           </th> | ||||
|  | ||||
|           <th hideable-th="author" [parent]="this" [sortable]="true"> | ||||
|             <div class="table-header-label"> | ||||
|               <div class="table-header-text">{{'common.author' | translate}}</div> | ||||
|               <p-sortIcon field="operator" class="table-header-icon"></p-sortIcon> | ||||
|               <p-sortIcon field="author" class="table-header-icon"></p-sortIcon> | ||||
|             </div> | ||||
|           </th> | ||||
|  | ||||
|   | ||||
| @@ -14,7 +14,7 @@ import { TranslateService } from "@ngx-translate/core"; | ||||
| import { DataService } from "../../../../../../services/data/data.service"; | ||||
| import { SidebarService } from "../../../../../../services/sidebar/sidebar.service"; | ||||
| import { ActivatedRoute } from "@angular/router"; | ||||
| import { Query, UserListQuery, UserWarningQuery } from "../../../../../../models/graphql/query.model"; | ||||
| import { UserListQuery, UserWarningQuery } from "../../../../../../models/graphql/query.model"; | ||||
| import { catchError, debounceTime, takeUntil } from "rxjs/operators"; | ||||
| import { LazyLoadEvent } from "primeng/api"; | ||||
| import { Table } from "primeng/table"; | ||||
| @@ -78,12 +78,28 @@ export class UserWarningComponent extends ComponentWithTable implements OnInit, | ||||
|   } | ||||
|  | ||||
|   public ngOnInit(): void { | ||||
|     this.setFilterForm(); | ||||
|  | ||||
|     this.loading = true; | ||||
|     this.data.getServerFromRoute(this.route).then(async server => { | ||||
|       this.server = server; | ||||
|       this.spinner.showSpinner(); | ||||
|       let authUser = await this.authService.getLoggedInUser(); | ||||
|       this.user = authUser?.users?.find(u => u.server == this.server.id) ?? null; | ||||
|       this.setFilterForm(); | ||||
|  | ||||
|       this.data.query<UserListQuery>(Queries.liteUsersQuery, { | ||||
|           serverId: this.server.id, filter: { | ||||
|             leftServer: false | ||||
|           } | ||||
|         }, | ||||
|         (x: { servers: Server[] }) => { | ||||
|           return x.servers[0]; | ||||
|         } | ||||
|       ).subscribe(data => { | ||||
|         this.users = data.users; | ||||
|       }); | ||||
|       this.spinner.hideSpinner(); | ||||
|       this.loadNextPage(); | ||||
|     }); | ||||
|   } | ||||
|  | ||||
| @@ -96,27 +112,13 @@ export class UserWarningComponent extends ComponentWithTable implements OnInit, | ||||
|     this.data.query<UserWarningQuery>(Queries.userWarningsQuery, { | ||||
|         serverId: this.server.id, filter: this.filter, page: this.page, sort: this.sort | ||||
|       }, | ||||
|       (data: Query) => { | ||||
|         return data.servers[0]; | ||||
|       (x: { servers: Server[] }) => { | ||||
|         return x.servers[0]; | ||||
|       } | ||||
|     ).subscribe(data => { | ||||
|       this.totalRecords = data.userWarningCount; | ||||
|       this.userWarnings = data.userWarnings; | ||||
|  | ||||
|       this.data.query<UserListQuery>(Queries.liteUsersQuery, { | ||||
|           serverId: this.server.id, filter: { | ||||
|             leftServer: false | ||||
|           } | ||||
|         }, | ||||
|         (x: { servers: Server[] }) => { | ||||
|           return x.servers[0]; | ||||
|         } | ||||
|       ).subscribe(data => { | ||||
|         this.users = data.users; | ||||
|  | ||||
|         this.spinner.hideSpinner(); | ||||
|         this.loading = false; | ||||
|       }); | ||||
|       this.loading = false; | ||||
|     }); | ||||
|   } | ||||
|  | ||||
| @@ -138,6 +140,24 @@ export class UserWarningComponent extends ComponentWithTable implements OnInit, | ||||
|         this.filter.id = undefined; | ||||
|       } | ||||
|  | ||||
|       if (changes.description) { | ||||
|         this.filter.description = changes.description; | ||||
|       } else { | ||||
|         this.filter.description = undefined; | ||||
|       } | ||||
|  | ||||
|       if (changes.user) { | ||||
|         this.filter.user = { name: changes.user }; | ||||
|       } else { | ||||
|         this.filter.user = undefined; | ||||
|       } | ||||
|  | ||||
|       if (changes.author) { | ||||
|         this.filter.author = { name: changes.author }; | ||||
|       } else { | ||||
|         this.filter.author = undefined; | ||||
|       } | ||||
|  | ||||
|       if (this.page.pageSize) | ||||
|         this.page.pageSize = 10; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user