Reviewed-on: sh-edraft.de/kd_discord_bot#227 Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de> Closes #216
This commit is contained in:
commit
a3fa7cb7b9
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "kdb-web",
|
||||
"version": "1.0.dev217",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"update-version": "ts-node-esm update-version.ts",
|
||||
|
@ -84,7 +84,10 @@ export class AutoRolesRulesComponent implements OnInit {
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.data.getServerFromRoute(this.route);
|
||||
|
||||
this.setFilterForm();
|
||||
this.data.getServerFromRoute(this.route).then(server => {
|
||||
|
||||
this.spinner.showSpinner();
|
||||
if (!this.route.snapshot.params["autoRoleId"]) {
|
||||
this.spinner.hideSpinner();
|
||||
@ -96,7 +99,7 @@ export class AutoRolesRulesComponent implements OnInit {
|
||||
this.spinner.showSpinner();
|
||||
this.data.query<SingleDiscordQuery>(Queries.guildsQuery, {
|
||||
filter: {
|
||||
id: this.sidebar.server$.value?.discordId
|
||||
id: server.discordId
|
||||
}
|
||||
}
|
||||
).subscribe(data => {
|
||||
@ -111,9 +114,8 @@ export class AutoRolesRulesComponent implements OnInit {
|
||||
});
|
||||
this.spinner.hideSpinner();
|
||||
});
|
||||
|
||||
this.setFilterForm();
|
||||
this.loadNextPage();
|
||||
});
|
||||
}
|
||||
|
||||
public loadNextPage(): void {
|
||||
|
@ -76,12 +76,13 @@ export class AutoRolesComponent implements OnInit {
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.data.getServerFromRoute(this.route);
|
||||
|
||||
this.setFilterForm();
|
||||
this.data.getServerFromRoute(this.route).then(server => {
|
||||
this.spinner.showSpinner();
|
||||
this.data.query<SingleDiscordQuery>(Queries.guildsQuery, {
|
||||
filter: {
|
||||
id: this.sidebar.server$.value?.discordId
|
||||
id: server?.discordId
|
||||
}
|
||||
}
|
||||
).subscribe(data => {
|
||||
@ -93,9 +94,8 @@ export class AutoRolesComponent implements OnInit {
|
||||
});
|
||||
this.spinner.hideSpinner();
|
||||
});
|
||||
|
||||
this.setFilterForm();
|
||||
this.loadNextPage();
|
||||
});
|
||||
}
|
||||
|
||||
public loadNextPage(): void {
|
||||
|
@ -14,7 +14,6 @@ import { LevelListQuery, UserListQuery } from "../../../../models/graphql/query.
|
||||
import { DataService } from "../../../../services/data/data.service";
|
||||
import { Page } from "../../../../models/graphql/filter/page.model";
|
||||
import { Sort, SortDirection } from "../../../../models/graphql/filter/sort.model";
|
||||
import { SidebarService } from "../../../../services/sidebar/sidebar.service";
|
||||
import { Mutations } from "../../../../models/graphql/mutations.model";
|
||||
import { throwError } from "rxjs";
|
||||
import { UpdateUserMutationResult } from "../../../../models/graphql/result.model";
|
||||
@ -88,32 +87,31 @@ export class MembersComponent implements OnInit {
|
||||
private fb: FormBuilder,
|
||||
private translate: TranslateService,
|
||||
private data: DataService,
|
||||
private sidebar: SidebarService,
|
||||
private route: ActivatedRoute
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.data.getServerFromRoute(this.route);
|
||||
this.setFilterForm();
|
||||
|
||||
this.data.getServerFromRoute(this.route).then(server => {
|
||||
this.spinner.showSpinner();
|
||||
this.data.query<LevelListQuery>(Queries.levelQuery, {
|
||||
filter: {
|
||||
server: { id: this.sidebar.server$.value?.id }
|
||||
server: { id: server.id }
|
||||
}
|
||||
}
|
||||
).subscribe(data => {
|
||||
this.levels = data.levels.map(level => {
|
||||
return { label: level.name, value: level };
|
||||
});
|
||||
this.spinner.hideSpinner();
|
||||
});
|
||||
|
||||
this.setFilterForm();
|
||||
this.loadNextPage();
|
||||
});
|
||||
}
|
||||
|
||||
loadNextPage() {
|
||||
this.spinner.showSpinner();
|
||||
this.loading = true;
|
||||
this.data.query<UserListQuery>(Queries.usersQuery, {
|
||||
filter: this.filter, page: this.page, sort: this.sort
|
||||
|
@ -7,7 +7,6 @@ import { DataService } from "../../../../services/data/data.service";
|
||||
import { User } from "../../../../models/data/user.model";
|
||||
import { UserDTO } from "../../../../models/auth/auth-user.dto";
|
||||
import { AuthService } from "src/app/services/auth/auth.service";
|
||||
import { SidebarService } from "../../../../services/sidebar/sidebar.service";
|
||||
import { ToastService } from "src/app/services/toast/toast.service";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
|
||||
@ -18,13 +17,12 @@ import { TranslateService } from "@ngx-translate/core";
|
||||
})
|
||||
export class ProfileComponent implements OnInit {
|
||||
|
||||
user!: User;
|
||||
user: User = { createdAt: "", modifiedAt: "" };
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private spinner: SpinnerService,
|
||||
private sidebar: SidebarService,
|
||||
private data: DataService,
|
||||
private auth: AuthService,
|
||||
private toast: ToastService,
|
||||
@ -32,21 +30,20 @@ export class ProfileComponent implements OnInit {
|
||||
) {
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
this.data.getServerFromRoute(this.route);
|
||||
|
||||
if (!this.route.snapshot.params["memberId"]) {
|
||||
this.router.navigate(["/dashboard"]);
|
||||
ngOnInit() {
|
||||
this.data.getServerFromRoute(this.route).then(async (server) => {
|
||||
if (!this.route.snapshot.params["memberId"] || this.route.snapshot.params["memberId"] == "undefined") {
|
||||
this.router.navigate([`/server/${server.id}`]);
|
||||
return;
|
||||
}
|
||||
|
||||
let authUser = await this.auth.getLoggedInUser();
|
||||
this.spinner.showSpinner();
|
||||
let user: UserDTO | null = authUser?.users?.find(u => u.server == this.sidebar.server$.value?.id) ?? null;
|
||||
let user: UserDTO | null = authUser?.users?.find(u => u.server == server.id) ?? null;
|
||||
if (!user || user?.id != this.route.snapshot.params["memberId"] && !user?.isModerator) {
|
||||
this.toast.error(this.translate.instant("view.server.profile.permission_denied"), this.translate.instant("view.server.profile.permission_denied_d"));
|
||||
this.spinner.hideSpinner();
|
||||
this.router.navigate(["/server", this.sidebar.server$.value?.id]);
|
||||
this.router.navigate(["/server", server.id]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -62,5 +59,8 @@ export class ProfileComponent implements OnInit {
|
||||
this.user = user;
|
||||
this.spinner.hideSpinner();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,9 @@ export class ServerDashboardComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.data.getServerFromRoute(this.route);
|
||||
this.data.getServerFromRoute(this.route).then(server => {
|
||||
this.server = server;
|
||||
});
|
||||
|
||||
this.sidebar.server$.subscribe(server => {
|
||||
if (!server) {
|
||||
|
@ -25,12 +25,13 @@ export class DataService {
|
||||
) {
|
||||
}
|
||||
|
||||
public getServerFromRoute(route: ActivatedRoute) {
|
||||
public getServerFromRoute(route: ActivatedRoute): Promise<Server> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.spinner.showSpinner();
|
||||
if (!route.snapshot.params["serverId"]) {
|
||||
this.spinner.hideSpinner();
|
||||
this.router.navigate(["/dashboard"]);
|
||||
return;
|
||||
reject();
|
||||
}
|
||||
|
||||
this.query<Server>(Queries.serversQuery, {
|
||||
@ -42,7 +43,10 @@ export class DataService {
|
||||
).subscribe(server => {
|
||||
this.sidebar.setServer(server);
|
||||
this.spinner.hideSpinner();
|
||||
resolve(server);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public query<T>(query: string, variables?: Variables, f?: Function): Observable<T> {
|
||||
@ -53,7 +57,7 @@ export class DataService {
|
||||
})
|
||||
.pipe(map(d => {
|
||||
if (d.errors && d.errors.length > 0) {
|
||||
throw new Error(d.errors.map((x: {message: String}) => x.message).toString());
|
||||
throw new Error(d.errors.map((x: { message: String }) => x.message).toString());
|
||||
}
|
||||
return d.data;
|
||||
}))
|
||||
|
@ -3,7 +3,7 @@
|
||||
"WebVersion": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "dev217"
|
||||
"Micro": "0"
|
||||
},
|
||||
"Themes": [
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user