Compare commits
14 Commits
1.0.6
...
400e54a501
Author | SHA1 | Date | |
---|---|---|---|
400e54a501 | |||
3c0233e8b3 | |||
8d2ae38d85 | |||
2b866b5ab1 | |||
4da87ae3cb | |||
1ebad89c97 | |||
b8320c83fe | |||
0ee26ccf3d | |||
31ca9cd8f4 | |||
089de53136 | |||
280b22af55 | |||
ebdf375283 | |||
c058312af7 | |||
2befa921ea |
@@ -25,10 +25,10 @@ class ModuleList:
|
||||
DataModule,
|
||||
GraphQLModule,
|
||||
PermissionModule,
|
||||
LevelModule,
|
||||
DatabaseModule,
|
||||
AutoRoleModule,
|
||||
BaseModule,
|
||||
LevelModule,
|
||||
ApiModule,
|
||||
TechnicianModule,
|
||||
# has to be last!
|
||||
|
@@ -1,13 +1,9 @@
|
||||
from typing import Optional
|
||||
|
||||
from cpl_translation import TranslatePipe
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
from bot_core.exception.check_error import CheckError
|
||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||
|
||||
|
||||
class EventChecks:
|
||||
@@ -23,7 +19,7 @@ class EventChecks:
|
||||
@classmethod
|
||||
def check_is_ready(cls):
|
||||
async def check_if_bot_is_ready() -> bool:
|
||||
result = await cls._client_utils.check_if_bot_is_ready()
|
||||
result = await cls._client_utils.check_if_bot_is_ready_yet()
|
||||
if not result:
|
||||
raise CheckError(f"Bot is not ready")
|
||||
return result
|
||||
|
@@ -0,0 +1,34 @@
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events.on_raw_reaction_add_abc import OnRawReactionAddABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from discord import RawReactionActionEvent
|
||||
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from modules.level.service.level_service import LevelService
|
||||
|
||||
|
||||
class LevelOnRawReactionAddEvent(OnRawReactionAddABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: LoggerABC,
|
||||
bot: DiscordBotServiceABC,
|
||||
level: LevelService,
|
||||
):
|
||||
OnRawReactionAddABC.__init__(self)
|
||||
|
||||
self._logger = logger
|
||||
self._bot = bot
|
||||
self._level = level
|
||||
|
||||
@EventChecks.check_is_ready()
|
||||
async def on_raw_reaction_add(self, payload: RawReactionActionEvent):
|
||||
self._logger.debug(__name__, f"Module {type(self)} started")
|
||||
try:
|
||||
self._logger.trace(__name__, f"Handle reaction {payload} for level")
|
||||
|
||||
guild = self._bot.get_guild(payload.guild_id)
|
||||
member = guild.get_member(payload.user_id)
|
||||
|
||||
await self._level.check_level(member)
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Level check by message failed", e)
|
@@ -0,0 +1,34 @@
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events.on_raw_reaction_remove_abc import OnRawReactionRemoveABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from discord import RawReactionActionEvent
|
||||
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from modules.level.service.level_service import LevelService
|
||||
|
||||
|
||||
class LevelOnRawReactionRemoveEvent(OnRawReactionRemoveABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: LoggerABC,
|
||||
bot: DiscordBotServiceABC,
|
||||
level: LevelService,
|
||||
):
|
||||
OnRawReactionRemoveABC.__init__(self)
|
||||
|
||||
self._logger = logger
|
||||
self._bot = bot
|
||||
self._level = level
|
||||
|
||||
@EventChecks.check_is_ready()
|
||||
async def on_raw_reaction_remove(self, payload: RawReactionActionEvent):
|
||||
self._logger.debug(__name__, f"Module {type(self)} started")
|
||||
try:
|
||||
self._logger.trace(__name__, f"Handle reaction {payload} for level")
|
||||
|
||||
guild = self._bot.get_guild(payload.guild_id)
|
||||
member = guild.get_member(payload.user_id)
|
||||
|
||||
await self._level.check_level(member)
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Level check by message failed", e)
|
@@ -12,6 +12,8 @@ from bot_data.abc.data_seeder_abc import DataSeederABC
|
||||
from modules.level.command.level_group import LevelGroup
|
||||
from modules.level.events.level_on_member_join_event import LevelOnMemberJoinEvent
|
||||
from modules.level.events.level_on_message_event import LevelOnMessageEvent
|
||||
from modules.level.events.level_on_raw_reaction_add_event import LevelOnRawReactionAddEvent
|
||||
from modules.level.events.level_on_raw_reaction_remove_event import LevelOnRawReactionRemoveEvent
|
||||
from modules.level.events.level_on_voice_state_update_event import (
|
||||
LevelOnVoiceStateUpdateEvent,
|
||||
)
|
||||
@@ -43,3 +45,5 @@ class LevelModule(ModuleABC):
|
||||
LevelOnVoiceStateUpdateEvent,
|
||||
)
|
||||
self._dc.add_event(DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent)
|
||||
self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent)
|
||||
self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_remove.value, LevelOnRawReactionRemoveEvent)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "kdb-web",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.7",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"update-version": "ts-node-esm update-version.ts",
|
||||
|
@@ -23,17 +23,6 @@ export interface User extends DataWithHistory {
|
||||
|
||||
userJoinedGameServerCount?: number;
|
||||
userJoinedGameServers?: UserJoinedGameServer[];
|
||||
|
||||
// history?: UserHistory[];
|
||||
}
|
||||
|
||||
export interface UserHistory extends History {
|
||||
id?: number;
|
||||
discordId?: number;
|
||||
xp?: number;
|
||||
level?: number;
|
||||
server?: number;
|
||||
leftServer?: boolean;
|
||||
}
|
||||
|
||||
export interface UserFilter {
|
||||
|
@@ -62,6 +62,17 @@ export class Queries {
|
||||
}
|
||||
createdAt
|
||||
modifiedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
static levelWithHistoryQuery = `
|
||||
query LevelHistory($serverId: ID, $id: ID) {
|
||||
servers(filter: {id: $serverId}) {
|
||||
levelCount
|
||||
levels(filter: {id: $id}) {
|
||||
id
|
||||
|
||||
history {
|
||||
id
|
||||
@@ -94,6 +105,29 @@ export class Queries {
|
||||
name
|
||||
}
|
||||
leftServer
|
||||
|
||||
createdAt
|
||||
modifiedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
static userProfile = `
|
||||
query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) {
|
||||
servers(filter: {id: $serverId}) {
|
||||
userCount
|
||||
users(filter: {id: $userId}, page: $page, sort: $sort) {
|
||||
id
|
||||
discordId
|
||||
name
|
||||
xp
|
||||
ontime
|
||||
level {
|
||||
id
|
||||
name
|
||||
}
|
||||
leftServer
|
||||
server {
|
||||
id
|
||||
name
|
||||
@@ -124,9 +158,17 @@ export class Queries {
|
||||
joinedOn
|
||||
leavedOn
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
createdAt
|
||||
modifiedAt
|
||||
static userQueryWithHistory = `
|
||||
query UsersWithHistory($serverId: ID, $id: ID) {
|
||||
servers(filter: {id: $serverId}) {
|
||||
userCount
|
||||
users(filter: {id: $id}) {
|
||||
id
|
||||
|
||||
history {
|
||||
id
|
||||
@@ -159,6 +201,17 @@ export class Queries {
|
||||
|
||||
createdAt
|
||||
modifiedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
static autoRolesWithHistoryQuery = `
|
||||
query AutoRoleWithHistoryQuery($serverId: ID, $id: ID) {
|
||||
servers(filter: {id: $serverId}) {
|
||||
autoRoleCount
|
||||
autoRoles(filter: {id: $id}) {
|
||||
id
|
||||
|
||||
history {
|
||||
id
|
||||
@@ -191,6 +244,19 @@ export class Queries {
|
||||
|
||||
createdAt
|
||||
modifiedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
static autoRoleRulesHistoryQuery = `
|
||||
query AutoRoleRuleHistoryQuery($serverId: ID, $autoRoleId: ID, $id: ID) {
|
||||
servers(filter: {id: $serverId}) {
|
||||
autoRoles(filter: {id: $autoRoleId}) {
|
||||
autoRoleRuleCount
|
||||
autoRoleRules(filter: {id: $id}) {
|
||||
id
|
||||
|
||||
history {
|
||||
id
|
||||
|
@@ -40,7 +40,7 @@ export class ForgetPasswordComponent implements OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.spinnerService.showSpinner();
|
||||
if (!this.authService.isLoggedIn$.value) {
|
||||
if (this.authService.isLoggedIn$.value) {
|
||||
this.router.navigate(["/dashboard"]);
|
||||
}
|
||||
|
||||
|
@@ -49,7 +49,7 @@ export class RegistrationComponent implements OnInit, OnDestroy {
|
||||
private settings: SettingsService
|
||||
) {
|
||||
this.spinnerService.showSpinner();
|
||||
if (!this.authService.isLoggedIn$.value) {
|
||||
if (this.authService.isLoggedIn$.value) {
|
||||
this.router.navigate(["/dashboard"]);
|
||||
}
|
||||
this.spinnerService.hideSpinner();
|
||||
@@ -57,7 +57,6 @@ export class RegistrationComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.translate.onLangChange.pipe(takeUntil(this.unsubscriber)).subscribe(lang => {
|
||||
|
||||
this.confirmPrivacyString = this.translate.instant("auth.register.confirm_privacy", { url: this.settings.getPrivacyURL() });
|
||||
});
|
||||
|
||||
@@ -167,8 +166,4 @@ export class RegistrationComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
log($event: Event): void {
|
||||
console.log($event);
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,16 @@
|
||||
import { Component, Input, OnInit } from "@angular/core";
|
||||
import { History } from "../../../../models/data/data.model";
|
||||
import { UserListQuery } from "../../../../models/graphql/query.model";
|
||||
import { Server } from "../../../../models/data/server.model";
|
||||
import { DataService } from "../../../../services/data/data.service";
|
||||
import { AuthService } from "../../../../services/auth/auth.service";
|
||||
import { SpinnerService } from "../../../../services/spinner/spinner.service";
|
||||
import { ToastService } from "../../../../services/toast/toast.service";
|
||||
import { ConfirmationDialogService } from "../../../../services/confirmation-dialog/confirmation-dialog.service";
|
||||
import { FormBuilder } from "@angular/forms";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { SidebarService } from "../../../../services/sidebar/sidebar.service";
|
||||
|
||||
@Component({
|
||||
selector: "app-history-btn",
|
||||
@@ -8,19 +19,62 @@ import { History } from "../../../../models/data/data.model";
|
||||
})
|
||||
export class HistoryBtnComponent implements OnInit {
|
||||
|
||||
@Input() history: History[] = [];
|
||||
@Input() id: number = 0;
|
||||
@Input() query: string = "";
|
||||
@Input() translationKey: string = "";
|
||||
|
||||
public showSidebar: boolean = false;
|
||||
public history: History[] = [];
|
||||
|
||||
public constructor() {
|
||||
public showSidebar: boolean = false;
|
||||
private server: Server = {};
|
||||
|
||||
public constructor(
|
||||
private authService: AuthService,
|
||||
private spinner: SpinnerService,
|
||||
private toastService: ToastService,
|
||||
private confirmDialog: ConfirmationDialogService,
|
||||
private fb: FormBuilder,
|
||||
private translate: TranslateService,
|
||||
private data: DataService,
|
||||
private route: ActivatedRoute,
|
||||
private sidebar: SidebarService
|
||||
) {
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.server = this.sidebar.server$.value ?? {};
|
||||
}
|
||||
|
||||
private findVal(object: any, key: string) {
|
||||
var value;
|
||||
Object.keys(object).some((k: string) => {
|
||||
if (k === key) {
|
||||
value = object[k];
|
||||
return true;
|
||||
}
|
||||
if (object[k] && typeof object[k] === "object") {
|
||||
value = this.findVal(object[k], key);
|
||||
return value !== undefined;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return value;
|
||||
}
|
||||
|
||||
public openHistory(): void {
|
||||
this.showSidebar = true;
|
||||
this.data.query<UserListQuery>(this.query, {
|
||||
serverId: this.server.id, id: this.id
|
||||
},
|
||||
(x: { servers: Server[] }) => {
|
||||
return x.servers[0];
|
||||
}
|
||||
).subscribe(data => {
|
||||
this.history = this.findVal(data, "history") ?? [];
|
||||
this.spinner.hideSpinner();
|
||||
});
|
||||
|
||||
|
||||
let oldHistory: Partial<History> = {};
|
||||
for (const history of this.history) {
|
||||
const attributes = Object.keys(history).map((key) => {
|
||||
|
@@ -160,7 +160,7 @@
|
||||
|
||||
<td>
|
||||
<div class="btn-wrapper">
|
||||
<app-history-btn *ngIf="!isEditingNew" [history] ="autoRoleRule.history" translationKey="view.server.auto_roles.rules.header"></app-history-btn>
|
||||
<app-history-btn *ngIf="!isEditingNew" [id] ="autoRoleRule.id" [query]="query" translationKey="view.server.auto_roles.rules.header"></app-history-btn>
|
||||
<button *ngIf="!editing" pButton pInitEditableRow class="btn icon-btn" icon="pi pi-pencil" (click)="onRowEditInit(dt, autoRoleRule, ri)"></button>
|
||||
<button *ngIf="!editing" pButton class="btn icon-btn danger-icon-btn" icon="pi pi-trash"
|
||||
(click)="deleteAutoRoleRule(autoRoleRule)"></button>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { Component, OnDestroy, OnInit, Query } from "@angular/core";
|
||||
import { DataService } from "../../../../../../services/data/data.service";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { AutoRoleRule, AutoRoleRuleFilter } from "../../../../../../models/data/auto_role.model";
|
||||
@@ -66,6 +66,8 @@ export class AutoRolesRulesComponent implements OnInit, OnDestroy {
|
||||
private unsubscriber = new Subject<void>();
|
||||
private server: Server = {};
|
||||
|
||||
query: string = Queries.autoRoleRulesHistoryQuery;
|
||||
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
private spinner: SpinnerService,
|
||||
|
@@ -126,7 +126,8 @@
|
||||
<td>
|
||||
<p-cellEditor>
|
||||
<ng-template pTemplate="input">
|
||||
<p-dropdown [options]="channels" optionValue="value.id" [(ngModel)]="autoRole.channelId" placeholder="{{'view.server.auto_roles.headers.channel_id' | translate}}"></p-dropdown>
|
||||
<p-dropdown [options]="channels" optionValue="value.id" [(ngModel)]="autoRole.channelId"
|
||||
placeholder="{{'view.server.auto_roles.headers.channel_id' | translate}}"></p-dropdown>
|
||||
</ng-template>
|
||||
<ng-template pTemplate="output">
|
||||
{{autoRole.channelId}}
|
||||
@@ -191,9 +192,9 @@
|
||||
|
||||
<td>
|
||||
<div class="btn-wrapper">
|
||||
<!-- <button *ngIf="!editing" pButton pInitEditableRow class="btn icon-btn" icon="pi pi-pencil"-->
|
||||
<!-- (click)="onRowEditInit(dt, autoRole, ri)"></button>-->
|
||||
<app-history-btn *ngIf="!isEditingNew" [history] ="autoRole.history" translationKey="view.server.auto_roles.header"></app-history-btn>
|
||||
<!-- <button *ngIf="!editing" pButton pInitEditableRow class="btn icon-btn" icon="pi pi-pencil"-->
|
||||
<!-- (click)="onRowEditInit(dt, autoRole, ri)"></button>-->
|
||||
<app-history-btn *ngIf="!isEditingNew" [id]="autoRole.id" [query]="query" translationKey="view.server.auto_roles.header"></app-history-btn>
|
||||
<button *ngIf="!editing" pButton pInitEditableRow class="btn icon-btn" icon="pi pi-sliders-h" [routerLink]="[autoRole.id, 'rules']"></button>
|
||||
<button *ngIf="!editing" pButton class="btn icon-btn danger-icon-btn" icon="pi pi-trash"
|
||||
(click)="deleteAutoRole(autoRole)"></button>
|
||||
|
@@ -63,6 +63,8 @@ export class AutoRolesComponent implements OnInit, OnDestroy {
|
||||
private unsubscriber = new Subject<void>();
|
||||
private server: Server = {};
|
||||
|
||||
query: string = Queries.autoRolesWithHistoryQuery;
|
||||
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
private spinner: SpinnerService,
|
||||
|
@@ -184,7 +184,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-wrapper">
|
||||
<app-history-btn *ngIf="!isEditingNew" [history] ="level.history" translationKey="view.server.levels.header"></app-history-btn>
|
||||
<app-history-btn *ngIf="!isEditingNew" [id]="level.id" [query]="query" translationKey="view.server.levels.header"></app-history-btn>
|
||||
<button *ngIf="!editing" pButton pInitEditableRow class="btn icon-btn" icon="pi pi-pencil"
|
||||
(click)="onRowEditInit(dt, level, ri)" [disabled]="!user || user.isModerator && !user.isAdmin"></button>
|
||||
<button *ngIf="!editing" pButton class="btn icon-btn danger-icon-btn" icon="pi pi-trash"
|
||||
|
@@ -61,6 +61,8 @@ export class LevelsComponent implements OnInit, OnDestroy {
|
||||
private server: Server = {};
|
||||
public user: UserDTO | null = null;
|
||||
|
||||
query: string = Queries.levelWithHistoryQuery;
|
||||
|
||||
public constructor(
|
||||
private authService: AuthService,
|
||||
private spinner: SpinnerService,
|
||||
|
@@ -224,7 +224,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-wrapper">
|
||||
<app-history-btn *ngIf="!isEditingNew" [history] ="member.history" translationKey="view.server.members.header"></app-history-btn>
|
||||
<app-history-btn *ngIf="!isEditingNew" [id]="member.id" [query]="query" translationKey="view.server.members.header"></app-history-btn>
|
||||
<button *ngIf="!editing" pButton pInitEditableRow class="btn icon-btn" icon="pi pi-pencil"
|
||||
(click)="onRowEditInit(dt, member, ri)"></button>
|
||||
<button *ngIf="!editing" pButton pInitEditableRow class="btn icon-btn" icon="pi pi-user"
|
||||
|
@@ -81,6 +81,7 @@ export class MembersComponent implements OnInit, OnDestroy {
|
||||
totalRecords!: number;
|
||||
private unsubscriber = new Subject<void>();
|
||||
private server: Server = {};
|
||||
query = Queries.userQueryWithHistory;
|
||||
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
|
@@ -55,11 +55,9 @@ export class ProfileComponent implements OnInit, OnDestroy {
|
||||
return;
|
||||
}
|
||||
|
||||
this.data.query<UserListQuery>(Queries.usersQuery, {
|
||||
this.data.query<UserListQuery>(Queries.userProfile, {
|
||||
serverId: this.server.id,
|
||||
filter: {
|
||||
id: params["memberId"]
|
||||
}
|
||||
userId: params["memberId"]
|
||||
},
|
||||
(x: { servers: Server[] }) => {
|
||||
return x.servers[0];
|
||||
|
@@ -37,7 +37,7 @@ export class SidebarService {
|
||||
) {
|
||||
this.themeService.isSidebarOpen$.subscribe(value => {
|
||||
this.isSidebarOpen = value;
|
||||
this.setMenu();
|
||||
this.setMenu(true);
|
||||
});
|
||||
|
||||
this.translateService.onLangChange.subscribe(_ => {
|
||||
|
@@ -5,7 +5,7 @@
|
||||
"WebVersion": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "5"
|
||||
"Micro": "7"
|
||||
},
|
||||
"Themes": [
|
||||
{
|
||||
|
Reference in New Issue
Block a user