Improved sidebar handling & added minecraftId to profile #130
This commit is contained in:
parent
b96288f4a3
commit
de8262dae1
@ -140,7 +140,7 @@ class User(TableABC):
|
|||||||
) VALUES (
|
) VALUES (
|
||||||
{self._discord_id},
|
{self._discord_id},
|
||||||
{self._xp},
|
{self._xp},
|
||||||
'{"NULL" if self._minecraft_id is None else self._minecraft_id}',
|
'{self._minecraft_id}',
|
||||||
{self._server.id},
|
{self._server.id},
|
||||||
'{self._created_at}',
|
'{self._created_at}',
|
||||||
'{self._modified_at}'
|
'{self._modified_at}'
|
||||||
@ -154,7 +154,7 @@ class User(TableABC):
|
|||||||
f"""
|
f"""
|
||||||
UPDATE `Users`
|
UPDATE `Users`
|
||||||
SET `XP` = {self._xp},
|
SET `XP` = {self._xp},
|
||||||
`MinecraftId` = '{"NULL" if self._minecraft_id is None else self._minecraft_id}',
|
`MinecraftId` = '{self._minecraft_id}',
|
||||||
`LastModifiedAt` = '{self._modified_at}'
|
`LastModifiedAt` = '{self._modified_at}'
|
||||||
WHERE `UserId` = {self._user_id};
|
WHERE `UserId` = {self._user_id};
|
||||||
"""
|
"""
|
||||||
|
@ -87,6 +87,7 @@ export class Queries {
|
|||||||
name
|
name
|
||||||
xp
|
xp
|
||||||
ontime
|
ontime
|
||||||
|
minecraftId
|
||||||
level {
|
level {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
@ -41,6 +41,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="content-row">
|
||||||
|
<div class="content-column">
|
||||||
|
<div class="content-data-name">{{'view.server.profile.minecraft_id' | translate}}:</div>
|
||||||
|
<div class="content-data-value">{{user.minecraftId}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="content-row">
|
<div class="content-row">
|
||||||
<div class="content-column">
|
<div class="content-column">
|
||||||
<div class="content-data-name">{{'view.server.profile.level' | translate}}:</div>
|
<div class="content-data-name">{{'view.server.profile.level' | translate}}:</div>
|
||||||
@ -81,6 +88,11 @@
|
|||||||
<div class="content-data-value">{{join.time}} {{'general.hours' | translate}}</div>
|
<div class="content-data-value">{{join.time}} {{'general.hours' | translate}}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="content-column">
|
||||||
|
<div class="content-data-name">{{'view.server.profile.joined_voice_channel.channel' | translate}}:</div>
|
||||||
|
<div class="content-data-value">{{join.channelName}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="content-column">
|
<div class="content-column">
|
||||||
<div class="content-data-name">{{'view.server.profile.joined_voice_channel.joined_at' | translate}}:</div>
|
<div class="content-data-name">{{'view.server.profile.joined_voice_channel.joined_at' | translate}}:</div>
|
||||||
<div class="content-data-value">{{join.joinedOn | date:'dd.MM.yyyy HH:mm:ss'}}</div>
|
<div class="content-data-value">{{join.joinedOn | date:'dd.MM.yyyy HH:mm:ss'}}</div>
|
||||||
|
@ -18,6 +18,15 @@ export class SidebarService {
|
|||||||
menuItems$ = new BehaviorSubject<MenuItem[]>(new Array<MenuItem>());
|
menuItems$ = new BehaviorSubject<MenuItem[]>(new Array<MenuItem>());
|
||||||
server$ = new BehaviorSubject<Server | null>(null);
|
server$ = new BehaviorSubject<Server | null>(null);
|
||||||
|
|
||||||
|
dashboard!: MenuItem;
|
||||||
|
serverDashboard!: MenuItem;
|
||||||
|
serverProfile!: MenuItem;
|
||||||
|
serverMembers!: MenuItem;
|
||||||
|
serverMenu!: MenuItem;
|
||||||
|
adminConfig!: MenuItem;
|
||||||
|
adminUsers!: MenuItem;
|
||||||
|
adminMenu!: MenuItem;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private themeService: ThemeService,
|
private themeService: ThemeService,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
@ -33,10 +42,6 @@ export class SidebarService {
|
|||||||
this.setMenu();
|
this.setMenu();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.server$.subscribe(_ => {
|
|
||||||
this.setMenu();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.router.events.subscribe(event => {
|
this.router.events.subscribe(event => {
|
||||||
if (!(event instanceof NavigationEnd)) {
|
if (!(event instanceof NavigationEnd)) {
|
||||||
return;
|
return;
|
||||||
@ -50,55 +55,75 @@ export class SidebarService {
|
|||||||
setServer(server: Server | null) {
|
setServer(server: Server | null) {
|
||||||
if (server?.id != this.server$.value?.id) {
|
if (server?.id != this.server$.value?.id) {
|
||||||
this.server$.next(server);
|
this.server$.next(server);
|
||||||
|
if (server) {
|
||||||
|
this.setMenu(true);
|
||||||
|
} else {
|
||||||
|
this.setMenu(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setMenu() {
|
async buildMenu(user: UserDTO | null, hasPermission: boolean) {
|
||||||
this.authService.hasUserPermission(AuthRoles.Admin).then(async hasPermission => {
|
this.dashboard = { label: this.isSidebarOpen ? this.translateService.instant("sidebar.dashboard") : "", icon: "pi pi-th-large", routerLink: "dashboard" };
|
||||||
let menuItems: MenuItem[] = [
|
this.serverDashboard = {
|
||||||
{ label: this.isSidebarOpen ? this.translateService.instant("sidebar.dashboard") : "", icon: "pi pi-th-large", routerLink: "dashboard" }
|
label: this.isSidebarOpen ? this.translateService.instant("sidebar.server.dashboard") : "",
|
||||||
];
|
icon: "pi pi-th-large",
|
||||||
|
routerLink: `server/${this.server$.value?.id}`
|
||||||
|
};
|
||||||
|
this.serverProfile = {
|
||||||
|
label: this.isSidebarOpen ? this.translateService.instant("sidebar.server.profile") : "",
|
||||||
|
icon: "pi pi-user",
|
||||||
|
routerLink: `server/${this.server$.value?.id}/members/${user?.id}`
|
||||||
|
};
|
||||||
|
this.serverMembers = {
|
||||||
|
label: this.isSidebarOpen ? this.translateService.instant("sidebar.server.members") : "",
|
||||||
|
icon: "pi pi-users",
|
||||||
|
visible: true,
|
||||||
|
routerLink: `server/${this.server$.value?.id}/members`
|
||||||
|
};
|
||||||
|
this.serverMenu = {
|
||||||
|
label: this.isSidebarOpen ? this.server$.value?.name : "",
|
||||||
|
icon: "pi pi-server",
|
||||||
|
visible: false,
|
||||||
|
expanded: true,
|
||||||
|
items: [this.serverDashboard, this.serverProfile, this.serverMembers]
|
||||||
|
};
|
||||||
|
this.adminConfig = { label: this.isSidebarOpen ? this.translateService.instant("sidebar.config") : "", icon: "pi pi-cog", routerLink: "/admin/settings" };
|
||||||
|
this.adminUsers = {
|
||||||
|
label: this.isSidebarOpen ? this.translateService.instant("sidebar.auth_user_list") : "",
|
||||||
|
icon: "pi pi-user-edit",
|
||||||
|
routerLink: "/admin/users"
|
||||||
|
};
|
||||||
|
this.adminMenu = {
|
||||||
|
label: this.isSidebarOpen ? this.translateService.instant("sidebar.administration") : "",
|
||||||
|
icon: "pi pi-cog",
|
||||||
|
visible: hasPermission,
|
||||||
|
expanded: true,
|
||||||
|
items: [this.adminConfig, this.adminUsers]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
setMenu(build: boolean = false) {
|
||||||
|
this.authService.hasUserPermission(AuthRoles.Admin).then(async hasPermission => {
|
||||||
let authUser = await this.authService.getLoggedInUser();
|
let authUser = await this.authService.getLoggedInUser();
|
||||||
let user: UserDTO | null = authUser?.users?.find(u => u.server == this.server$.value?.id) ?? null;
|
let user: UserDTO | null = authUser?.users?.find(u => u.server == this.server$.value?.id) ?? null;
|
||||||
const serverMenu = {
|
|
||||||
label: this.isSidebarOpen ? this.server$.value?.name : "", icon: "pi pi-server", items: [
|
if (build || this.menuItems$.value.length == 0) {
|
||||||
{ label: this.isSidebarOpen ? this.translateService.instant("sidebar.server.dashboard") : "", icon: "pi pi-th-large", routerLink: `server/${this.server$.value?.id}` },
|
await this.buildMenu(user, hasPermission);
|
||||||
{
|
}
|
||||||
label: this.isSidebarOpen ? this.translateService.instant("sidebar.server.profile") : "",
|
|
||||||
icon: "pi pi-user",
|
|
||||||
routerLink: `server/${this.server$.value?.id}/members/${user?.id}`
|
|
||||||
}
|
|
||||||
// { label: this.isSidebarOpen ? this.translateService.instant("sidebar.members") : "", icon: "pi pi-users", routerLink: "server/members" }
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.server$.value) {
|
if (this.server$.value) {
|
||||||
if (user?.isAdmin) {
|
this.serverMenu.visible = true;
|
||||||
serverMenu.items.push(
|
this.serverMembers.visible = !!user?.isAdmin;
|
||||||
{
|
} else {
|
||||||
label: this.isSidebarOpen ? this.translateService.instant("sidebar.server.members") : "",
|
this.serverMenu.visible = false;
|
||||||
icon: "pi pi-users",
|
|
||||||
routerLink: `server/${this.server$.value?.id}/members`
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
menuItems.push(serverMenu);
|
|
||||||
} else if (menuItems.find(x => x.icon == "pi pi-server")) {
|
|
||||||
menuItems.splice(menuItems.indexOf(serverMenu), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasPermission) {
|
let menuItems: MenuItem[] = [
|
||||||
menuItems.push(
|
this.dashboard,
|
||||||
{
|
this.serverMenu,
|
||||||
label: this.isSidebarOpen ? this.translateService.instant("sidebar.administration") : "", icon: "pi pi-cog", items: [
|
this.adminMenu
|
||||||
{ label: this.isSidebarOpen ? this.translateService.instant("sidebar.config") : "", icon: "pi pi-cog", routerLink: "/admin/settings" },
|
];
|
||||||
{ label: this.isSidebarOpen ? this.translateService.instant("sidebar.auth_user_list") : "", icon: "pi pi-user-edit", routerLink: "/admin/users" }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
this.menuItems$.next(menuItems);
|
this.menuItems$.next(menuItems);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -167,11 +167,13 @@
|
|||||||
"name": "Name",
|
"name": "Name",
|
||||||
"xp": "XP",
|
"xp": "XP",
|
||||||
"ontime": "Ontime",
|
"ontime": "Ontime",
|
||||||
|
"minecraft_id": "Minecraft Id",
|
||||||
"level": "Level",
|
"level": "Level",
|
||||||
"left_server": "Hat Server verlassen",
|
"left_server": "Hat Server verlassen",
|
||||||
"joined_voice_channel": {
|
"joined_voice_channel": {
|
||||||
"header": "Sprachkanal-beitritte",
|
"header": "Sprachkanal-beitritte",
|
||||||
"time": "Zeit",
|
"time": "Zeit",
|
||||||
|
"channel": "Sprachkanal",
|
||||||
"joined_at": "Beigetreten am",
|
"joined_at": "Beigetreten am",
|
||||||
"leaved_at": "Verlassen am"
|
"leaved_at": "Verlassen am"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user