Compare commits
No commits in common. "c311e534d7195832aeaab769ae85612b1081f08e" and "24d5bbf4d8d39fb184647d9ef1ab83c38a9912f3" have entirely different histories.
c311e534d7
...
24d5bbf4d8
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { Queries } from "../../../../models/graphql/queries.model";
|
import { Queries } from "../../../../models/graphql/queries.model";
|
||||||
import { UserListQuery } from "../../../../models/graphql/query.model";
|
import { UserListQuery } from "../../../../models/graphql/query.model";
|
||||||
@ -10,21 +10,17 @@ 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";
|
import { Server } from "../../../../models/data/server.model";
|
||||||
import { Subject } from "rxjs";
|
|
||||||
import { takeUntil } from "rxjs/operators";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-profile",
|
selector: "app-profile",
|
||||||
templateUrl: "./profile.component.html",
|
templateUrl: "./profile.component.html",
|
||||||
styleUrls: ["./profile.component.scss"]
|
styleUrls: ["./profile.component.scss"]
|
||||||
})
|
})
|
||||||
export class ProfileComponent implements OnInit, OnDestroy {
|
export class ProfileComponent implements OnInit {
|
||||||
|
|
||||||
user: User = { createdAt: "", modifiedAt: "" };
|
user: User = { createdAt: "", modifiedAt: "" };
|
||||||
private server: Server = {};
|
private server: Server = {};
|
||||||
|
|
||||||
private unsubscriber = new Subject<void>();
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
@ -36,11 +32,10 @@ export class ProfileComponent implements OnInit, OnDestroy {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit(): void {
|
ngOnInit() {
|
||||||
this.route.params.pipe(takeUntil(this.unsubscriber)).subscribe(params => {
|
|
||||||
this.data.getServerFromRoute(this.route).then(async (server) => {
|
this.data.getServerFromRoute(this.route).then(async (server) => {
|
||||||
if (!params["memberId"] || params["memberId"] == "undefined") {
|
if (!this.route.snapshot.params["memberId"] || this.route.snapshot.params["memberId"] == "undefined") {
|
||||||
await this.router.navigate([`/server/${server.id}`]);
|
this.router.navigate([`/server/${server.id}`]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.server = server;
|
this.server = server;
|
||||||
@ -48,17 +43,17 @@ export class ProfileComponent implements OnInit, OnDestroy {
|
|||||||
let authUser = await this.auth.getLoggedInUser();
|
let authUser = await this.auth.getLoggedInUser();
|
||||||
this.spinner.showSpinner();
|
this.spinner.showSpinner();
|
||||||
let user: UserDTO | null = authUser?.users?.find(u => u.server == server.id) ?? null;
|
let user: UserDTO | null = authUser?.users?.find(u => u.server == server.id) ?? null;
|
||||||
if (!user || user?.id != params["memberId"] && !user?.isModerator) {
|
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.toast.error(this.translate.instant("view.server.profile.permission_denied"), this.translate.instant("view.server.profile.permission_denied_d"));
|
||||||
this.spinner.hideSpinner();
|
this.spinner.hideSpinner();
|
||||||
await this.router.navigate(["/server", server.id]);
|
this.router.navigate(["/server", server.id]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.data.query<UserListQuery>(Queries.usersQuery, {
|
this.data.query<UserListQuery>(Queries.usersQuery, {
|
||||||
serverId: this.server.id,
|
serverId: this.server.id,
|
||||||
filter: {
|
filter: {
|
||||||
id: params["memberId"]
|
id: this.route.snapshot.params["memberId"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(x: { servers: Server[] }) => {
|
(x: { servers: Server[] }) => {
|
||||||
@ -72,11 +67,7 @@ export class ProfileComponent implements OnInit, OnDestroy {
|
|||||||
this.spinner.hideSpinner();
|
this.spinner.hideSpinner();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public ngOnDestroy(): void {
|
|
||||||
this.unsubscriber.next();
|
|
||||||
this.unsubscriber.complete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user