Merge pull request 'Fixed table loading #220' (#236) from #220 into 1.0.0

Reviewed-on: sh-edraft.de/kd_discord_bot#236
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #220
This commit is contained in:
Sven Heidemann 2023-02-23 08:46:04 +01:00
commit a80bbc33cf
17 changed files with 139 additions and 154 deletions

@ -1 +1 @@
Subproject commit 7986144705052ff38472a5d3f0776cb6c1752a55 Subproject commit 6e2ec8f2f88cca5355624da9c83c034949d12ae3

View File

@ -69,11 +69,11 @@ class ApiKey(TableABC):
return str( return str(
f""" f"""
INSERT INTO `ApiKeys` ( INSERT INTO `ApiKeys` (
`Identifier`, `Key`, {"" if self._creator is None else "`CreatorId`,"} `CreatedAt`, `LastModifiedAt` `Identifier`, `Key`, `CreatorId`, `CreatedAt`, `LastModifiedAt`
) VALUES ( ) VALUES (
'{self._identifier}', '{self._identifier}',
'{self._key}', '{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._created_at}',
'{self._modified_at}' '{self._modified_at}'
); );
@ -87,7 +87,7 @@ class ApiKey(TableABC):
UPDATE `ApiKeys` UPDATE `ApiKeys`
SET `Identifier` = '{self._identifier}', SET `Identifier` = '{self._identifier}',
`Key` = '{self._key}', `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}' `LastModifiedAt` = '{self._modified_at}'
WHERE `Id` = {self._id}; WHERE `Id` = {self._id};
""" """

View File

@ -215,10 +215,10 @@ class AuthUser(TableABC):
`EMail`, `EMail`,
`Password`, `Password`,
`PasswordSalt`, `PasswordSalt`,
{"" if self._refresh_token is None else f"`RefreshToken`,"} `RefreshToken`,
{"" if self._confirmation_id is None else f"`ConfirmationId`,"} `ConfirmationId`,
{"" if self._forgot_password_id is None else f"`ForgotPasswordId`,"} `ForgotPasswordId`,
{"" if self._oauth_id is None else f"`OAuthId`,"} `OAuthId`,
`RefreshTokenExpiryTime`, `RefreshTokenExpiryTime`,
`AuthRole`, `AuthRole`,
`CreatedAt`, `CreatedAt`,
@ -230,10 +230,10 @@ class AuthUser(TableABC):
'{self._email}', '{self._email}',
'{self._password}', '{self._password}',
'{self._password_salt}', '{self._password_salt}',
{"" if self._refresh_token is None else f"'{self._refresh_token}',"} {"NULL" if self._refresh_token is None else f"'{self._refresh_token}'"},
{"" if self._confirmation_id is None else f"'{self._confirmation_id}',"} {"NULL" if self._confirmation_id is None else f"'{self._confirmation_id}'"},
{"" if self._forgot_password_id is None else f"'{self._forgot_password_id}',"} {"NULL" 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._oauth_id is None else f"'{self._oauth_id}'"},
'{self._refresh_token_expire_time.isoformat()}', '{self._refresh_token_expire_time.isoformat()}',
{self._auth_role_id.value}, {self._auth_role_id.value},
'{self._created_at}', '{self._created_at}',
@ -252,10 +252,10 @@ class AuthUser(TableABC):
`EMail` = '{self._email}', `EMail` = '{self._email}',
`Password` = '{self._password}', `Password` = '{self._password}',
`PasswordSalt` = '{self._password_salt}', `PasswordSalt` = '{self._password_salt}',
{'' if self._refresh_token is None else f"`RefreshToken` = '{self._refresh_token}',"} `RefreshToken` = {"NULL" if self._refresh_token is None else f"'{self._refresh_token}'"},
{'' if self._confirmation_id is None else f"'`ConfirmationId` = '{self._confirmation_id}',"} `ConfirmationId` = {"NULL" if self._confirmation_id is None else f"'{self._confirmation_id}'"},
{'' if self._forgot_password_id is None else f"`ForgotPasswordId` = '{self._forgot_password_id}',"} `ForgotPasswordId` = {"NULL" if self._forgot_password_id is None else f"'{self._forgot_password_id}'"},
{'' if self._oauth_id is None else f"`OAuthId` = '{self._oauth_id}',"} `OAuthId` = {"NULL" if self._oauth_id is None else f"'{self._oauth_id}'"},
`RefreshTokenExpiryTime` = '{self._refresh_token_expire_time.isoformat()}', `RefreshTokenExpiryTime` = '{self._refresh_token_expire_time.isoformat()}',
`AuthRole` = {self._auth_role_id.value}, `AuthRole` = {self._auth_role_id.value},
`LastModifiedAt` = '{self._modified_at}' `LastModifiedAt` = '{self._modified_at}'

View File

@ -150,11 +150,11 @@ class User(TableABC):
return str( return str(
f""" f"""
INSERT INTO `Users` ( INSERT INTO `Users` (
`DiscordId`, `XP`, {"" if self._minecraft_id is None else "`MinecraftId`,"} `ServerId`, `CreatedAt`, `LastModifiedAt` `DiscordId`, `XP`, `MinecraftId`, `ServerId`, `CreatedAt`, `LastModifiedAt`
) VALUES ( ) VALUES (
{self._discord_id}, {self._discord_id},
{self._xp}, {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._server.id},
'{self._created_at}', '{self._created_at}',
'{self._modified_at}' '{self._modified_at}'
@ -168,7 +168,7 @@ class User(TableABC):
f""" f"""
UPDATE `Users` UPDATE `Users`
SET `XP` = {self._xp}, 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}' `LastModifiedAt` = '{self._modified_at}'
WHERE `UserId` = {self._user_id}; WHERE `UserId` = {self._user_id};
""" """

View File

@ -101,12 +101,12 @@ class UserJoinedGameServer(TableABC):
return str( return str(
f""" f"""
INSERT INTO `UserJoinedGameServer` ( INSERT INTO `UserJoinedGameServer` (
`UserId`, `GameServer`, `JoinedOn`, {"" if self._leaved_on is None else "`LeavedOn`,"} `CreatedAt`, `LastModifiedAt` `UserId`, `GameServer`, `JoinedOn`, `LeavedOn`, `CreatedAt`, `LastModifiedAt`
) VALUES ( ) VALUES (
{self._user.id}, {self._user.id},
'{self._game_server}', '{self._game_server}',
'{self._joined_on}', '{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._created_at}',
'{self._modified_at}' '{self._modified_at}'
); );
@ -118,8 +118,7 @@ class UserJoinedGameServer(TableABC):
return str( return str(
f""" f"""
UPDATE `UserJoinedGameServer` UPDATE `UserJoinedGameServer`
SET SET `LeavedOn` = {"NULL" if self._leaved_on is None else f"'{self._leaved_on}'"},
{"" if self._leaved_on is None else f"`LeavedOn` = '{self._leaved_on}',"}
`LastModifiedAt` = '{self._modified_at}' `LastModifiedAt` = '{self._modified_at}'
WHERE `Id` = {self._id}; WHERE `Id` = {self._id};
""" """

View File

@ -100,11 +100,11 @@ class UserJoinedServer(TableABC):
return str( return str(
f""" f"""
INSERT INTO `UserJoinedServers` ( INSERT INTO `UserJoinedServers` (
`UserId`, `JoinedOn`, {"" if self._leaved_on is None else "`LeavedOn`,"} `CreatedAt`, `LastModifiedAt` `UserId`, `JoinedOn`, `LeavedOn`, `CreatedAt`, `LastModifiedAt`
) VALUES ( ) VALUES (
{self._user.id}, {self._user.id},
'{self._joined_on}', '{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._created_at}',
'{self._modified_at}' '{self._modified_at}'
); );
@ -116,8 +116,7 @@ class UserJoinedServer(TableABC):
return str( return str(
f""" f"""
UPDATE `UserJoinedServers` UPDATE `UserJoinedServers`
SET SET `LeavedOn` = {"NULL" if self._leaved_on is None else f"'{self._leaved_on}'"},
{"" if self._leaved_on is None else f"`LeavedOn` = '{self._leaved_on}',"}
`LastModifiedAt` = '{self._modified_at}' `LastModifiedAt` = '{self._modified_at}'
WHERE `UserId` = {self._user.id}; WHERE `UserId` = {self._user.id};
""" """

View File

@ -108,12 +108,12 @@ class UserJoinedVoiceChannel(TableABC):
return str( return str(
f""" f"""
INSERT INTO `UserJoinedVoiceChannel` ( INSERT INTO `UserJoinedVoiceChannel` (
`UserId`, `DiscordChannelId`, `JoinedOn`, {"" if self._leaved_on is None else "`LeavedOn`,"} `CreatedAt`, `LastModifiedAt` `UserId`, `DiscordChannelId`, `JoinedOn`, `LeavedOn`, `CreatedAt`, `LastModifiedAt`
) VALUES ( ) VALUES (
{self._user.id}, {self._user.id},
{self._channel_id}, {self._channel_id},
'{self._joined_on}', '{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._created_at}',
'{self._modified_at}' '{self._modified_at}'
); );
@ -125,8 +125,7 @@ class UserJoinedVoiceChannel(TableABC):
return str( return str(
f""" f"""
UPDATE `UserJoinedVoiceChannel` UPDATE `UserJoinedVoiceChannel`
SET SET `LeavedOn` = {"NULL" if self._leaved_on is None else f"'{self._leaved_on}'"},
{"" if self._leaved_on is None else f"`LeavedOn` = '{self._leaved_on}',"}
`LastModifiedAt` = '{self._modified_at}' `LastModifiedAt` = '{self._modified_at}'
WHERE `JoinId` = {self._join_id}; WHERE `JoinId` = {self._join_id};
""" """

View File

@ -28,7 +28,7 @@ class AuthUserRepositoryService(AuthUserRepositoryABC):
@staticmethod @staticmethod
def _get_value_from_result(value: any) -> Optional[any]: 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 None
return value return value

View File

@ -1,6 +1,6 @@
{ {
"name": "kdb-web", "name": "kdb-web",
"version": "1.0.dev133", "version": "1.0.dev220",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"update-version": "ts-node-esm update-version.ts", "update-version": "ts-node-esm update-version.ts",

View File

@ -26,6 +26,7 @@ export class Queries {
static serversQuery = ` static serversQuery = `
query ServerInfo($filter: ServerFilter, $page: Page, $sort: Sort) { query ServerInfo($filter: ServerFilter, $page: Page, $sort: Sort) {
serverCount
servers(filter: $filter, page: $page, sort: $sort) { servers(filter: $filter, page: $page, sort: $sort) {
id id
name name
@ -46,7 +47,8 @@ export class Queries {
`; `;
static levelQuery = ` static levelQuery = `
query LevelsList($filter: LevelFilter, $page: Page, $sort: Sort) { query LevelsList($serverId: ID, $filter: LevelFilter, $page: Page, $sort: Sort) {
servers(filter: {id: $serverId}) {
levelCount levelCount
levels(filter: $filter, page: $page, sort: $sort) { levels(filter: $filter, page: $page, sort: $sort) {
id id
@ -62,54 +64,14 @@ export class Queries {
modifiedAt modifiedAt
} }
} }
}
`; `;
static usersQuery = ` static usersQuery = `
query UsersList($filter: UserFilter, $page: Page, $sort: Sort) { query UsersList($serverId: ID, $filter: UserFilter, $page: Page, $sort: Sort) {
servers(filter: {id: $serverId}) {
userCount userCount
users(filter: $filter, page: $page, sort: $sort) { users(filter: $filter, page: $page, sort: $sort) {
id
discordId
name
xp
ontime
level {
id
name
}
server {
id
name
}
leftServer
joinedServerCount
joinedServers {
id
}
joinedVoiceChannelCount
joinedVoiceChannels {
id
channelId
channelName
}
userJoinedGameServerCount
userJoinedGameServers {
id
gameServer
}
createdAt
modifiedAt
}
}
`;
static singleUserQuery = `
query singleUserQuery($filter: UserFilter) {
users(filter: $filter) {
id id
discordId discordId
name name
@ -156,6 +118,7 @@ export class Queries {
modifiedAt modifiedAt
} }
} }
}
`; `;
static autoRolesQuery = ` static autoRolesQuery = `

View File

@ -1,14 +1,19 @@
import { User } from "../data/user.model"; import { User } from "../data/user.model";
import { AutoRole, AutoRoleRule } from "../data/auto_role.model"; import { AutoRole, AutoRoleRule } from "../data/auto_role.model";
import { Level } from "../data/level.model"; import { Level } from "../data/level.model";
import { Server } from "../data/server.model";
export interface GraphQLResult { export interface GraphQLResult {
data: any; data: {
servers?: Server[];
};
errors?: []; errors?: [];
} }
export interface QueryResult { export interface QueryResult {
data: any; data: {
servers?: Server[];
};
} }
export interface UpdateUserMutationResult { export interface UpdateUserMutationResult {

View File

@ -42,7 +42,6 @@ export class AutoRolesRulesComponent implements OnInit {
isEditingNew: boolean = false; isEditingNew: boolean = false;
newAutoRoleTemplate: AutoRoleRule = { newAutoRoleTemplate: AutoRoleRule = {
id: 0,
createdAt: "", createdAt: "",
modifiedAt: "" modifiedAt: ""
}; };
@ -65,6 +64,7 @@ export class AutoRolesRulesComponent implements OnInit {
totalRecords: number = 0; totalRecords: number = 0;
private unsubscriber = new Subject<void>(); private unsubscriber = new Subject<void>();
private server: Server = {};
constructor( constructor(
private authService: AuthService, private authService: AuthService,
@ -88,7 +88,7 @@ export class AutoRolesRulesComponent implements OnInit {
this.setFilterForm(); this.setFilterForm();
this.data.getServerFromRoute(this.route).then(server => { this.data.getServerFromRoute(this.route).then(server => {
this.server = server;
this.spinner.showSpinner(); this.spinner.showSpinner();
if (!this.route.snapshot.params["autoRoleId"]) { if (!this.route.snapshot.params["autoRoleId"]) {
this.spinner.hideSpinner(); this.spinner.hideSpinner();
@ -122,7 +122,7 @@ export class AutoRolesRulesComponent implements OnInit {
public loadNextPage(): void { public loadNextPage(): void {
this.loading = true; this.loading = true;
this.data.query<AutoRoleRuleQuery>(Queries.autoRoleRulesQuery, { this.data.query<AutoRoleRuleQuery>(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[] }) => { (x: { servers: Server[] }) => {
if (!x.servers[0].autoRoles || x.servers[0].autoRoles?.length == 0) { if (!x.servers[0].autoRoles || x.servers[0].autoRoles?.length == 0) {

View File

@ -38,7 +38,6 @@ export class AutoRolesComponent implements OnInit {
isEditingNew: boolean = false; isEditingNew: boolean = false;
newAutoRoleTemplate: AutoRole = { newAutoRoleTemplate: AutoRole = {
id: 0,
createdAt: "", createdAt: "",
modifiedAt: "" modifiedAt: ""
}; };
@ -60,8 +59,9 @@ export class AutoRolesComponent implements OnInit {
sortDirection: undefined sortDirection: undefined
}; };
totalRecords!: number; totalRecords: number = 0;
private unsubscriber = new Subject<void>(); private unsubscriber = new Subject<void>();
private server: Server = {};
constructor( constructor(
private authService: AuthService, private authService: AuthService,
@ -80,6 +80,7 @@ export class AutoRolesComponent implements OnInit {
this.setFilterForm(); this.setFilterForm();
this.data.getServerFromRoute(this.route).then(server => { this.data.getServerFromRoute(this.route).then(server => {
this.server = server;
this.spinner.showSpinner(); this.spinner.showSpinner();
this.data.query<SingleDiscordQuery>(Queries.guildsQuery, { this.data.query<SingleDiscordQuery>(Queries.guildsQuery, {
filter: { filter: {
@ -102,7 +103,7 @@ export class AutoRolesComponent implements OnInit {
public loadNextPage(): void { public loadNextPage(): void {
this.loading = true; this.loading = true;
this.data.query<AutoRoleQuery>(Queries.autoRolesQuery, { this.data.query<AutoRoleQuery>(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[] }) => { (x: { servers: Server[] }) => {
return x.servers[0]; return x.servers[0];
@ -192,7 +193,7 @@ export class AutoRolesComponent implements OnInit {
this.spinner.showSpinner(); this.spinner.showSpinner();
this.data.mutation<AutoRoleMutationResult>(Mutations.createAutoRole, { this.data.mutation<AutoRoleMutationResult>(Mutations.createAutoRole, {
serverId: this.sidebar.server$.value?.id, serverId: this.server.id,
channelId: newAutoRole.channelId, channelId: newAutoRole.channelId,
messageId: newAutoRole.messageId messageId: newAutoRole.messageId
} }

View File

@ -11,7 +11,7 @@ import { ActivatedRoute } from "@angular/router";
import { Page } from "../../../../../../models/graphql/filter/page.model"; import { Page } from "../../../../../../models/graphql/filter/page.model";
import { Sort, SortDirection } from "../../../../../../models/graphql/filter/sort.model"; import { Sort, SortDirection } from "../../../../../../models/graphql/filter/sort.model";
import { Level, LevelFilter } from "../../../../../../models/data/level.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 { Queries } from "../../../../../../models/graphql/queries.model";
import { catchError, debounceTime, takeUntil } from "rxjs/operators"; import { catchError, debounceTime, takeUntil } from "rxjs/operators";
import { LazyLoadEvent } from "primeng/api"; 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 { LevelMutationResult, UpdateUserMutationResult } from "../../../../../../models/graphql/result.model";
import { Mutations } from "../../../../../../models/graphql/mutations.model"; import { Mutations } from "../../../../../../models/graphql/mutations.model";
import { Subject, throwError } from "rxjs"; import { Subject, throwError } from "rxjs";
import { Server } from "../../../../../../models/data/server.model";
@Component({ @Component({
selector: "app-levels", selector: "app-levels",
@ -28,7 +29,7 @@ import { Subject, throwError } from "rxjs";
}) })
export class LevelsComponent implements OnInit, OnDestroy { export class LevelsComponent implements OnInit, OnDestroy {
public levels!: Level[]; public levels: Level[] = [];
public loading = true; public loading = true;
public isEditingNew: boolean = false; public isEditingNew: boolean = false;
@ -51,11 +52,12 @@ export class LevelsComponent implements OnInit, OnDestroy {
sortDirection: undefined sortDirection: undefined
}; };
public totalRecords!: number; public totalRecords: number = 0;
public clonedLevels: { [s: string]: Level; } = {}; public clonedLevels: { [s: string]: Level; } = {};
private unsubscriber = new Subject<void>(); private unsubscriber = new Subject<void>();
private server: Server = {};
public constructor( public constructor(
private authService: AuthService, private authService: AuthService,
@ -70,8 +72,9 @@ export class LevelsComponent implements OnInit, OnDestroy {
} }
public ngOnInit(): void { public ngOnInit(): void {
this.data.getServerFromRoute(this.route).then(server => {
this.setFilterForm(); this.setFilterForm();
this.data.getServerFromRoute(this.route).then(server => {
this.server = server;
this.loadNextPage(); this.loadNextPage();
}); });
} }
@ -84,7 +87,10 @@ export class LevelsComponent implements OnInit, OnDestroy {
public loadNextPage(): void { public loadNextPage(): void {
this.loading = true; this.loading = true;
this.data.query<LevelListQuery>(Queries.levelQuery, { this.data.query<LevelListQuery>(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 => { ).subscribe(data => {
this.totalRecords = data.levelCount; this.totalRecords = data.levelCount;
@ -179,7 +185,7 @@ export class LevelsComponent implements OnInit, OnDestroy {
color: newLevel.color, color: newLevel.color,
minXp: newLevel.minXp, minXp: newLevel.minXp,
permissions: newLevel.permissions, permissions: newLevel.permissions,
serverId: this.sidebar.server$.value?.id serverId: this.server.id
} }
).pipe(catchError(err => { ).pipe(catchError(err => {
this.isEditingNew = false; this.isEditingNew = false;

View File

@ -10,7 +10,7 @@ import { LazyLoadEvent, MenuItem } from "primeng/api";
import { Table } from "primeng/table"; import { Table } from "primeng/table";
import { User, UserFilter } from "../../../../models/data/user.model"; import { User, UserFilter } from "../../../../models/data/user.model";
import { Queries } from "../../../../models/graphql/queries.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 { DataService } from "../../../../services/data/data.service";
import { Page } from "../../../../models/graphql/filter/page.model"; import { Page } from "../../../../models/graphql/filter/page.model";
import { Sort, SortDirection } from "../../../../models/graphql/filter/sort.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 { UpdateUserMutationResult } from "../../../../models/graphql/result.model";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { Level } from "../../../../models/data/level.model"; import { Level } from "../../../../models/data/level.model";
import { Server } from "../../../../models/data/server.model";
@Component({ @Component({
selector: "app-members", selector: "app-members",
@ -27,7 +28,6 @@ import { Level } from "../../../../models/data/level.model";
}) })
export class MembersComponent implements OnInit { export class MembersComponent implements OnInit {
members!: User[]; members!: User[];
// levelsFilter!: MenuItem[];
levels!: MenuItem[]; levels!: MenuItem[];
leftServerOptions = [ leftServerOptions = [
{ label: this.translate.instant("common.bool_as_string.true"), value: false }, { label: this.translate.instant("common.bool_as_string.true"), value: false },
@ -80,6 +80,7 @@ export class MembersComponent implements OnInit {
totalRecords!: number; totalRecords!: number;
private unsubscriber = new Subject<void>(); private unsubscriber = new Subject<void>();
private server: Server = {};
constructor( constructor(
private authService: AuthService, private authService: AuthService,
@ -97,11 +98,13 @@ export class MembersComponent implements OnInit {
this.setFilterForm(); this.setFilterForm();
this.data.getServerFromRoute(this.route).then(server => { this.data.getServerFromRoute(this.route).then(server => {
this.server = server;
this.spinner.showSpinner(); this.spinner.showSpinner();
this.data.query<LevelListQuery>(Queries.levelQuery, { this.data.query<LevelListQuery>(Queries.levelQuery, {
filter: { serverId: server.id
server: { id: server.id } },
} (data: Query) => {
return data.servers[0];
} }
).subscribe(data => { ).subscribe(data => {
this.levels = data.levels.map(level => { this.levels = data.levels.map(level => {
@ -116,7 +119,10 @@ export class MembersComponent implements OnInit {
this.spinner.showSpinner(); this.spinner.showSpinner();
this.loading = true; this.loading = true;
this.data.query<UserListQuery>(Queries.usersQuery, { this.data.query<UserListQuery>(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 => { ).subscribe(data => {
this.totalRecords = data.userCount; this.totalRecords = data.userCount;

View File

@ -9,6 +9,7 @@ import { UserDTO } from "../../../../models/auth/auth-user.dto";
import { AuthService } from "src/app/services/auth/auth.service"; import { AuthService } from "src/app/services/auth/auth.service";
import { ToastService } from "src/app/services/toast/toast.service"; import { ToastService } from "src/app/services/toast/toast.service";
import { TranslateService } from "@ngx-translate/core"; import { TranslateService } from "@ngx-translate/core";
import { Server } from "../../../../models/data/server.model";
@Component({ @Component({
selector: "app-profile", selector: "app-profile",
@ -18,6 +19,7 @@ import { TranslateService } from "@ngx-translate/core";
export class ProfileComponent implements OnInit { export class ProfileComponent implements OnInit {
user: User = { createdAt: "", modifiedAt: "" }; user: User = { createdAt: "", modifiedAt: "" };
private server: Server = {};
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
@ -36,6 +38,7 @@ export class ProfileComponent implements OnInit {
this.router.navigate([`/server/${server.id}`]); this.router.navigate([`/server/${server.id}`]);
return; return;
} }
this.server = server;
let authUser = await this.auth.getLoggedInUser(); let authUser = await this.auth.getLoggedInUser();
this.spinner.showSpinner(); this.spinner.showSpinner();
@ -47,16 +50,20 @@ export class ProfileComponent implements OnInit {
return; return;
} }
this.data.query<User>(Queries.singleUserQuery, { this.data.query<UserListQuery>(Queries.usersQuery, {
serverId: this.server.id,
filter: { filter: {
id: this.route.snapshot.params["memberId"] id: this.route.snapshot.params["memberId"]
} }
}, },
function(data: UserListQuery) { (x: { servers: Server[] }) => {
return data.users.length > 0 ? data.users[0] : null; return x.servers[0];
} }
).subscribe(user => { ).subscribe(users => {
this.user = user; if (!users.users[0]) {
this.router.navigate([`/server/${server.id}`]);
}
this.user = users.users[0];
this.spinner.hideSpinner(); this.spinner.hideSpinner();
}); });
}); });

View File

@ -3,7 +3,7 @@
"WebVersion": { "WebVersion": {
"Major": "1", "Major": "1",
"Minor": "0", "Minor": "0",
"Micro": "dev133" "Micro": "dev220"
}, },
"Themes": [ "Themes": [
{ {