From 691551593232bf9d3b12ce4543cec565f2ea85be Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 22 Feb 2023 21:02:49 +0100 Subject: [PATCH] Fixed table loading #220 --- kdb-bot/src/bot/config | 2 +- kdb-bot/src/bot_data/model/api_key.py | 6 +- kdb-bot/src/bot_data/model/auth_user.py | 24 +-- kdb-bot/src/bot_data/model/user.py | 6 +- .../bot_data/model/user_joined_game_server.py | 7 +- .../src/bot_data/model/user_joined_server.py | 7 +- .../model/user_joined_voice_channel.py | 7 +- .../service/auth_user_repository_service.py | 2 +- kdb-web/package.json | 2 +- .../src/app/models/graphql/queries.model.ts | 149 +++++++----------- .../src/app/models/graphql/result.model.ts | 9 +- .../auto-roles-rules.component.ts | 6 +- .../auto-roles/auto-roles.component.ts | 9 +- .../components/levels/levels.component.ts | 20 ++- .../view/server/members/members.component.ts | 18 ++- .../view/server/profile/profile.component.ts | 17 +- kdb-web/src/assets/config.json | 2 +- 17 files changed, 139 insertions(+), 154 deletions(-) diff --git a/kdb-bot/src/bot/config b/kdb-bot/src/bot/config index 79861447..6e2ec8f2 160000 --- a/kdb-bot/src/bot/config +++ b/kdb-bot/src/bot/config @@ -1 +1 @@ -Subproject commit 7986144705052ff38472a5d3f0776cb6c1752a55 +Subproject commit 6e2ec8f2f88cca5355624da9c83c034949d12ae3 diff --git a/kdb-bot/src/bot_data/model/api_key.py b/kdb-bot/src/bot_data/model/api_key.py index 94ce7dfd..39f69677 100644 --- a/kdb-bot/src/bot_data/model/api_key.py +++ b/kdb-bot/src/bot_data/model/api_key.py @@ -69,11 +69,11 @@ class ApiKey(TableABC): return str( f""" INSERT INTO `ApiKeys` ( - `Identifier`, `Key`, {"" if self._creator is None else "`CreatorId`,"} `CreatedAt`, `LastModifiedAt` + `Identifier`, `Key`, `CreatorId`, `CreatedAt`, `LastModifiedAt` ) VALUES ( '{self._identifier}', '{self._key}', - {"" if self._creator is None else f"{self._creator.id},"} + {"NULL" if self._creator is None else f"'{self._creator.id}'"}, '{self._created_at}', '{self._modified_at}' ); @@ -87,7 +87,7 @@ class ApiKey(TableABC): UPDATE `ApiKeys` SET `Identifier` = '{self._identifier}', `Key` = '{self._key}', - {"" if self._creator is None else f"`CreatorId` = {self._creator.id},"} + `CreatorId` = {"NULL" if self._creator is None else f"'{self._creator.id}'"}, `LastModifiedAt` = '{self._modified_at}' WHERE `Id` = {self._id}; """ diff --git a/kdb-bot/src/bot_data/model/auth_user.py b/kdb-bot/src/bot_data/model/auth_user.py index 5ce5914e..9255bede 100644 --- a/kdb-bot/src/bot_data/model/auth_user.py +++ b/kdb-bot/src/bot_data/model/auth_user.py @@ -215,10 +215,10 @@ class AuthUser(TableABC): `EMail`, `Password`, `PasswordSalt`, - {"" if self._refresh_token is None else f"`RefreshToken`,"} - {"" if self._confirmation_id is None else f"`ConfirmationId`,"} - {"" if self._forgot_password_id is None else f"`ForgotPasswordId`,"} - {"" if self._oauth_id is None else f"`OAuthId`,"} + `RefreshToken`, + `ConfirmationId`, + `ForgotPasswordId`, + `OAuthId`, `RefreshTokenExpiryTime`, `AuthRole`, `CreatedAt`, @@ -230,10 +230,10 @@ class AuthUser(TableABC): '{self._email}', '{self._password}', '{self._password_salt}', - {"" if self._refresh_token is None else f"'{self._refresh_token}',"} - {"" if self._confirmation_id is None else f"'{self._confirmation_id}',"} - {"" if self._forgot_password_id is None else f"'{self._forgot_password_id}',"} - {"" if self._oauth_id is None else f"'{self._oauth_id}',"} + {"NULL" if self._refresh_token is None else f"'{self._refresh_token}'"}, + {"NULL" if self._confirmation_id is None else f"'{self._confirmation_id}'"}, + {"NULL" if self._forgot_password_id is None else f"'{self._forgot_password_id}'"}, + {"NULL" if self._oauth_id is None else f"'{self._oauth_id}'"}, '{self._refresh_token_expire_time.isoformat()}', {self._auth_role_id.value}, '{self._created_at}', @@ -252,10 +252,10 @@ class AuthUser(TableABC): `EMail` = '{self._email}', `Password` = '{self._password}', `PasswordSalt` = '{self._password_salt}', - {'' if self._refresh_token is None else f"`RefreshToken` = '{self._refresh_token}',"} - {'' if self._confirmation_id is None else f"'`ConfirmationId` = '{self._confirmation_id}',"} - {'' if self._forgot_password_id is None else f"`ForgotPasswordId` = '{self._forgot_password_id}',"} - {'' if self._oauth_id is None else f"`OAuthId` = '{self._oauth_id}',"} + `RefreshToken` = {"NULL" if self._refresh_token is None else f"'{self._refresh_token}'"}, + `ConfirmationId` = {"NULL" if self._confirmation_id is None else f"'{self._confirmation_id}'"}, + `ForgotPasswordId` = {"NULL" if self._forgot_password_id is None else f"'{self._forgot_password_id}'"}, + `OAuthId` = {"NULL" if self._oauth_id is None else f"'{self._oauth_id}'"}, `RefreshTokenExpiryTime` = '{self._refresh_token_expire_time.isoformat()}', `AuthRole` = {self._auth_role_id.value}, `LastModifiedAt` = '{self._modified_at}' diff --git a/kdb-bot/src/bot_data/model/user.py b/kdb-bot/src/bot_data/model/user.py index 908eff91..c153a979 100644 --- a/kdb-bot/src/bot_data/model/user.py +++ b/kdb-bot/src/bot_data/model/user.py @@ -150,11 +150,11 @@ class User(TableABC): return str( f""" INSERT INTO `Users` ( - `DiscordId`, `XP`, {"" if self._minecraft_id is None else "`MinecraftId`,"} `ServerId`, `CreatedAt`, `LastModifiedAt` + `DiscordId`, `XP`, `MinecraftId`, `ServerId`, `CreatedAt`, `LastModifiedAt` ) VALUES ( {self._discord_id}, {self._xp}, - {"" if self._minecraft_id is None else f"'{self._minecraft_id}',"} + {"NULL" if self._minecraft_id is None else f"'{self._minecraft_id}'"}, {self._server.id}, '{self._created_at}', '{self._modified_at}' @@ -168,7 +168,7 @@ class User(TableABC): f""" UPDATE `Users` SET `XP` = {self._xp}, - {"" if self._minecraft_id is None else f"`MinecraftId` = '{self._minecraft_id}',"} + `MinecraftId` = {"NULL" if self._minecraft_id is None else f"'{self._minecraft_id}'"}, `LastModifiedAt` = '{self._modified_at}' WHERE `UserId` = {self._user_id}; """ diff --git a/kdb-bot/src/bot_data/model/user_joined_game_server.py b/kdb-bot/src/bot_data/model/user_joined_game_server.py index 1a1186e5..e25d6b1d 100644 --- a/kdb-bot/src/bot_data/model/user_joined_game_server.py +++ b/kdb-bot/src/bot_data/model/user_joined_game_server.py @@ -101,12 +101,12 @@ class UserJoinedGameServer(TableABC): return str( f""" INSERT INTO `UserJoinedGameServer` ( - `UserId`, `GameServer`, `JoinedOn`, {"" if self._leaved_on is None else "`LeavedOn`,"} `CreatedAt`, `LastModifiedAt` + `UserId`, `GameServer`, `JoinedOn`, `LeavedOn`, `CreatedAt`, `LastModifiedAt` ) VALUES ( {self._user.id}, '{self._game_server}', '{self._joined_on}', - {"" if self._leaved_on is None else f"'{self._leaved_on}',"} + {"NULL" if self._leaved_on is None else f"'{self._leaved_on}'"}, '{self._created_at}', '{self._modified_at}' ); @@ -118,8 +118,7 @@ class UserJoinedGameServer(TableABC): return str( f""" UPDATE `UserJoinedGameServer` - SET - {"" if self._leaved_on is None else f"`LeavedOn` = '{self._leaved_on}',"} + SET `LeavedOn` = {"NULL" if self._leaved_on is None else f"'{self._leaved_on}'"}, `LastModifiedAt` = '{self._modified_at}' WHERE `Id` = {self._id}; """ diff --git a/kdb-bot/src/bot_data/model/user_joined_server.py b/kdb-bot/src/bot_data/model/user_joined_server.py index 9af3168a..5946104a 100644 --- a/kdb-bot/src/bot_data/model/user_joined_server.py +++ b/kdb-bot/src/bot_data/model/user_joined_server.py @@ -100,11 +100,11 @@ class UserJoinedServer(TableABC): return str( f""" INSERT INTO `UserJoinedServers` ( - `UserId`, `JoinedOn`, {"" if self._leaved_on is None else "`LeavedOn`,"} `CreatedAt`, `LastModifiedAt` + `UserId`, `JoinedOn`, `LeavedOn`, `CreatedAt`, `LastModifiedAt` ) VALUES ( {self._user.id}, '{self._joined_on}', - {"" if self._leaved_on is None else f"'{self._leaved_on}',"} + {"NULL" if self._leaved_on is None else f"'{self._leaved_on}'"}, '{self._created_at}', '{self._modified_at}' ); @@ -116,8 +116,7 @@ class UserJoinedServer(TableABC): return str( f""" UPDATE `UserJoinedServers` - SET - {"" if self._leaved_on is None else f"`LeavedOn` = '{self._leaved_on}',"} + SET `LeavedOn` = {"NULL" if self._leaved_on is None else f"'{self._leaved_on}'"}, `LastModifiedAt` = '{self._modified_at}' WHERE `UserId` = {self._user.id}; """ diff --git a/kdb-bot/src/bot_data/model/user_joined_voice_channel.py b/kdb-bot/src/bot_data/model/user_joined_voice_channel.py index bb69e7cb..928c0341 100644 --- a/kdb-bot/src/bot_data/model/user_joined_voice_channel.py +++ b/kdb-bot/src/bot_data/model/user_joined_voice_channel.py @@ -108,12 +108,12 @@ class UserJoinedVoiceChannel(TableABC): return str( f""" INSERT INTO `UserJoinedVoiceChannel` ( - `UserId`, `DiscordChannelId`, `JoinedOn`, {"" if self._leaved_on is None else "`LeavedOn`,"} `CreatedAt`, `LastModifiedAt` + `UserId`, `DiscordChannelId`, `JoinedOn`, `LeavedOn`, `CreatedAt`, `LastModifiedAt` ) VALUES ( {self._user.id}, {self._channel_id}, '{self._joined_on}', - {"" if self._leaved_on is None else f"'{self._leaved_on}',"} + {"NULL" if self._leaved_on is None else f"'{self._leaved_on}'"}, '{self._created_at}', '{self._modified_at}' ); @@ -125,8 +125,7 @@ class UserJoinedVoiceChannel(TableABC): return str( f""" UPDATE `UserJoinedVoiceChannel` - SET - {"" if self._leaved_on is None else f"`LeavedOn` = '{self._leaved_on}',"} + SET `LeavedOn` = {"NULL" if self._leaved_on is None else f"'{self._leaved_on}'"}, `LastModifiedAt` = '{self._modified_at}' WHERE `JoinId` = {self._join_id}; """ diff --git a/kdb-bot/src/bot_data/service/auth_user_repository_service.py b/kdb-bot/src/bot_data/service/auth_user_repository_service.py index 397c31f8..295e3c2f 100644 --- a/kdb-bot/src/bot_data/service/auth_user_repository_service.py +++ b/kdb-bot/src/bot_data/service/auth_user_repository_service.py @@ -28,7 +28,7 @@ class AuthUserRepositoryService(AuthUserRepositoryABC): @staticmethod def _get_value_from_result(value: any) -> Optional[any]: - if isinstance(value, str) and "null" in value: + if isinstance(value, str) and "NULL" in value: return None return value diff --git a/kdb-web/package.json b/kdb-web/package.json index 7d88a478..630cd8ce 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,6 +1,6 @@ { "name": "kdb-web", - "version": "1.0.dev133", + "version": "1.0.dev220", "scripts": { "ng": "ng", "update-version": "ts-node-esm update-version.ts", diff --git a/kdb-web/src/app/models/graphql/queries.model.ts b/kdb-web/src/app/models/graphql/queries.model.ts index 5911d5f3..799d88cb 100644 --- a/kdb-web/src/app/models/graphql/queries.model.ts +++ b/kdb-web/src/app/models/graphql/queries.model.ts @@ -26,6 +26,7 @@ export class Queries { static serversQuery = ` query ServerInfo($filter: ServerFilter, $page: Page, $sort: Sort) { + serverCount servers(filter: $filter, page: $page, sort: $sort) { id name @@ -46,114 +47,76 @@ export class Queries { `; static levelQuery = ` - query LevelsList($filter: LevelFilter, $page: Page, $sort: Sort) { - levelCount - levels(filter: $filter, page: $page, sort: $sort) { - id - name - color - minXp - permissions - server { + query LevelsList($serverId: ID, $filter: LevelFilter, $page: Page, $sort: Sort) { + servers(filter: {id: $serverId}) { + levelCount + levels(filter: $filter, page: $page, sort: $sort) { id name + color + minXp + permissions + server { + id + name + } + createdAt + modifiedAt } - createdAt - modifiedAt } } `; static usersQuery = ` - query UsersList($filter: UserFilter, $page: Page, $sort: Sort) { - userCount - users(filter: $filter, page: $page, sort: $sort) { - id - discordId - name - xp - ontime - level { + query UsersList($serverId: ID, $filter: UserFilter, $page: Page, $sort: Sort) { + servers(filter: {id: $serverId}) { + userCount + users(filter: $filter, page: $page, sort: $sort) { id + discordId name - } - server { - id - name - } - leftServer + xp + ontime + minecraftId + level { + id + name + } + leftServer + server { + id + name + } - joinedServerCount - joinedServers { - id - } + joinedServerCount + joinedServers { + id + joinedOn + leavedOn + } - joinedVoiceChannelCount - joinedVoiceChannels { - id - channelId - channelName - } + joinedVoiceChannelCount + joinedVoiceChannels { + id + channelId + channelName + time + joinedOn + leavedOn + } - userJoinedGameServerCount - userJoinedGameServers { - id - gameServer - } + userJoinedGameServerCount + userJoinedGameServers { + id + gameServer + time + joinedOn + leavedOn + } - createdAt - modifiedAt - } - } - `; - - static singleUserQuery = ` - query singleUserQuery($filter: UserFilter) { - users(filter: $filter) { - id - discordId - name - xp - ontime - minecraftId - level { - id - name + createdAt + modifiedAt } - leftServer - server { - id - name - } - - joinedServerCount - joinedServers { - id - joinedOn - leavedOn - } - - joinedVoiceChannelCount - joinedVoiceChannels { - id - channelId - channelName - time - joinedOn - leavedOn - } - - userJoinedGameServerCount - userJoinedGameServers { - id - gameServer - time - joinedOn - leavedOn - } - - createdAt - modifiedAt } } `; diff --git a/kdb-web/src/app/models/graphql/result.model.ts b/kdb-web/src/app/models/graphql/result.model.ts index bf3b660e..d3d6e4a4 100644 --- a/kdb-web/src/app/models/graphql/result.model.ts +++ b/kdb-web/src/app/models/graphql/result.model.ts @@ -1,14 +1,19 @@ import { User } from "../data/user.model"; import { AutoRole, AutoRoleRule } from "../data/auto_role.model"; import { Level } from "../data/level.model"; +import { Server } from "../data/server.model"; export interface GraphQLResult { - data: any; + data: { + servers?: Server[]; + }; errors?: []; } export interface QueryResult { - data: any; + data: { + servers?: Server[]; + }; } export interface UpdateUserMutationResult { diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts index 62a5de17..9254351f 100644 --- a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts +++ b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts @@ -42,7 +42,6 @@ export class AutoRolesRulesComponent implements OnInit { isEditingNew: boolean = false; newAutoRoleTemplate: AutoRoleRule = { - id: 0, createdAt: "", modifiedAt: "" }; @@ -65,6 +64,7 @@ export class AutoRolesRulesComponent implements OnInit { totalRecords: number = 0; private unsubscriber = new Subject(); + private server: Server = {}; constructor( private authService: AuthService, @@ -88,7 +88,7 @@ export class AutoRolesRulesComponent implements OnInit { this.setFilterForm(); this.data.getServerFromRoute(this.route).then(server => { - + this.server = server; this.spinner.showSpinner(); if (!this.route.snapshot.params["autoRoleId"]) { this.spinner.hideSpinner(); @@ -122,7 +122,7 @@ export class AutoRolesRulesComponent implements OnInit { public loadNextPage(): void { this.loading = true; this.data.query(Queries.autoRoleRulesQuery, { - serverId: this.sidebar.server$.value?.id, autoRoleId: this.autoRoleId, filter: this.filter, page: this.page, sort: this.sort + serverId: this.server.id, autoRoleId: this.autoRoleId, filter: this.filter, page: this.page, sort: this.sort }, (x: { servers: Server[] }) => { if (!x.servers[0].autoRoles || x.servers[0].autoRoles?.length == 0) { diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts index 1631a811..48ee380c 100644 --- a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts +++ b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts @@ -38,7 +38,6 @@ export class AutoRolesComponent implements OnInit { isEditingNew: boolean = false; newAutoRoleTemplate: AutoRole = { - id: 0, createdAt: "", modifiedAt: "" }; @@ -60,8 +59,9 @@ export class AutoRolesComponent implements OnInit { sortDirection: undefined }; - totalRecords!: number; + totalRecords: number = 0; private unsubscriber = new Subject(); + private server: Server = {}; constructor( private authService: AuthService, @@ -80,6 +80,7 @@ export class AutoRolesComponent implements OnInit { this.setFilterForm(); this.data.getServerFromRoute(this.route).then(server => { + this.server = server; this.spinner.showSpinner(); this.data.query(Queries.guildsQuery, { filter: { @@ -102,7 +103,7 @@ export class AutoRolesComponent implements OnInit { public loadNextPage(): void { this.loading = true; this.data.query(Queries.autoRolesQuery, { - id: this.sidebar.server$.value?.id, filter: this.filter, page: this.page, sort: this.sort + serverId: this.server.id, filter: this.filter, page: this.page, sort: this.sort }, (x: { servers: Server[] }) => { return x.servers[0]; @@ -192,7 +193,7 @@ export class AutoRolesComponent implements OnInit { this.spinner.showSpinner(); this.data.mutation(Mutations.createAutoRole, { - serverId: this.sidebar.server$.value?.id, + serverId: this.server.id, channelId: newAutoRole.channelId, messageId: newAutoRole.messageId } diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts index e9cead67..cf83aaf5 100644 --- a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts +++ b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts @@ -11,7 +11,7 @@ import { ActivatedRoute } from "@angular/router"; import { Page } from "../../../../../../models/graphql/filter/page.model"; import { Sort, SortDirection } from "../../../../../../models/graphql/filter/sort.model"; import { Level, LevelFilter } from "../../../../../../models/data/level.model"; -import { LevelListQuery } from "../../../../../../models/graphql/query.model"; +import { LevelListQuery, Query } from "../../../../../../models/graphql/query.model"; import { Queries } from "../../../../../../models/graphql/queries.model"; import { catchError, debounceTime, takeUntil } from "rxjs/operators"; import { LazyLoadEvent } from "primeng/api"; @@ -20,6 +20,7 @@ import { User } from "../../../../../../models/data/user.model"; import { LevelMutationResult, UpdateUserMutationResult } from "../../../../../../models/graphql/result.model"; import { Mutations } from "../../../../../../models/graphql/mutations.model"; import { Subject, throwError } from "rxjs"; +import { Server } from "../../../../../../models/data/server.model"; @Component({ selector: "app-levels", @@ -28,7 +29,7 @@ import { Subject, throwError } from "rxjs"; }) export class LevelsComponent implements OnInit, OnDestroy { - public levels!: Level[]; + public levels: Level[] = []; public loading = true; public isEditingNew: boolean = false; @@ -51,11 +52,12 @@ export class LevelsComponent implements OnInit, OnDestroy { sortDirection: undefined }; - public totalRecords!: number; + public totalRecords: number = 0; public clonedLevels: { [s: string]: Level; } = {}; private unsubscriber = new Subject(); + private server: Server = {}; public constructor( private authService: AuthService, @@ -70,8 +72,9 @@ export class LevelsComponent implements OnInit, OnDestroy { } public ngOnInit(): void { + this.setFilterForm(); this.data.getServerFromRoute(this.route).then(server => { - this.setFilterForm(); + this.server = server; this.loadNextPage(); }); } @@ -84,8 +87,11 @@ export class LevelsComponent implements OnInit, OnDestroy { public loadNextPage(): void { this.loading = true; this.data.query(Queries.levelQuery, { - filter: this.filter, page: this.page, sort: this.sort - } + serverId: this.server.id, filter: this.filter, page: this.page, sort: this.sort + }, + (data: Query) => { + return data.servers[0]; + } ).subscribe(data => { this.totalRecords = data.levelCount; this.levels = data.levels; @@ -179,7 +185,7 @@ export class LevelsComponent implements OnInit, OnDestroy { color: newLevel.color, minXp: newLevel.minXp, permissions: newLevel.permissions, - serverId: this.sidebar.server$.value?.id + serverId: this.server.id } ).pipe(catchError(err => { this.isEditingNew = false; diff --git a/kdb-web/src/app/modules/view/server/members/members.component.ts b/kdb-web/src/app/modules/view/server/members/members.component.ts index a4f3e004..8b3e7e27 100644 --- a/kdb-web/src/app/modules/view/server/members/members.component.ts +++ b/kdb-web/src/app/modules/view/server/members/members.component.ts @@ -10,7 +10,7 @@ import { LazyLoadEvent, MenuItem } from "primeng/api"; import { Table } from "primeng/table"; import { User, UserFilter } from "../../../../models/data/user.model"; import { Queries } from "../../../../models/graphql/queries.model"; -import { LevelListQuery, UserListQuery } from "../../../../models/graphql/query.model"; +import { LevelListQuery, Query, UserListQuery } from "../../../../models/graphql/query.model"; import { DataService } from "../../../../services/data/data.service"; import { Page } from "../../../../models/graphql/filter/page.model"; import { Sort, SortDirection } from "../../../../models/graphql/filter/sort.model"; @@ -19,6 +19,7 @@ import { Subject, throwError } from "rxjs"; import { UpdateUserMutationResult } from "../../../../models/graphql/result.model"; import { ActivatedRoute } from "@angular/router"; import { Level } from "../../../../models/data/level.model"; +import { Server } from "../../../../models/data/server.model"; @Component({ selector: "app-members", @@ -27,7 +28,6 @@ import { Level } from "../../../../models/data/level.model"; }) export class MembersComponent implements OnInit { members!: User[]; - // levelsFilter!: MenuItem[]; levels!: MenuItem[]; leftServerOptions = [ { label: this.translate.instant("common.bool_as_string.true"), value: false }, @@ -80,6 +80,7 @@ export class MembersComponent implements OnInit { totalRecords!: number; private unsubscriber = new Subject(); + private server: Server = {}; constructor( private authService: AuthService, @@ -97,11 +98,13 @@ export class MembersComponent implements OnInit { this.setFilterForm(); this.data.getServerFromRoute(this.route).then(server => { + this.server = server; this.spinner.showSpinner(); this.data.query(Queries.levelQuery, { - filter: { - server: { id: server.id } - } + serverId: server.id + }, + (data: Query) => { + return data.servers[0]; } ).subscribe(data => { this.levels = data.levels.map(level => { @@ -116,7 +119,10 @@ export class MembersComponent implements OnInit { this.spinner.showSpinner(); this.loading = true; this.data.query(Queries.usersQuery, { - filter: this.filter, page: this.page, sort: this.sort + serverId: this.server.id, filter: this.filter, page: this.page, sort: this.sort + }, + (x: { servers: Server[] }) => { + return x.servers[0]; } ).subscribe(data => { this.totalRecords = data.userCount; diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.ts b/kdb-web/src/app/modules/view/server/profile/profile.component.ts index 80909967..6e3e81a1 100644 --- a/kdb-web/src/app/modules/view/server/profile/profile.component.ts +++ b/kdb-web/src/app/modules/view/server/profile/profile.component.ts @@ -9,6 +9,7 @@ import { UserDTO } from "../../../../models/auth/auth-user.dto"; import { AuthService } from "src/app/services/auth/auth.service"; import { ToastService } from "src/app/services/toast/toast.service"; import { TranslateService } from "@ngx-translate/core"; +import { Server } from "../../../../models/data/server.model"; @Component({ selector: "app-profile", @@ -18,6 +19,7 @@ import { TranslateService } from "@ngx-translate/core"; export class ProfileComponent implements OnInit { user: User = { createdAt: "", modifiedAt: "" }; + private server: Server = {}; constructor( private route: ActivatedRoute, @@ -36,6 +38,7 @@ export class ProfileComponent implements OnInit { this.router.navigate([`/server/${server.id}`]); return; } + this.server = server; let authUser = await this.auth.getLoggedInUser(); this.spinner.showSpinner(); @@ -47,16 +50,20 @@ export class ProfileComponent implements OnInit { return; } - this.data.query(Queries.singleUserQuery, { + this.data.query(Queries.usersQuery, { + serverId: this.server.id, filter: { id: this.route.snapshot.params["memberId"] } }, - function(data: UserListQuery) { - return data.users.length > 0 ? data.users[0] : null; + (x: { servers: Server[] }) => { + return x.servers[0]; } - ).subscribe(user => { - this.user = user; + ).subscribe(users => { + if (!users.users[0]) { + this.router.navigate([`/server/${server.id}`]); + } + this.user = users.users[0]; this.spinner.hideSpinner(); }); }); diff --git a/kdb-web/src/assets/config.json b/kdb-web/src/assets/config.json index 89caec01..c3479190 100644 --- a/kdb-web/src/assets/config.json +++ b/kdb-web/src/assets/config.json @@ -3,7 +3,7 @@ "WebVersion": { "Major": "1", "Minor": "0", - "Micro": "dev133" + "Micro": "dev220" }, "Themes": [ { -- 2.45.2