From 61bf508cea3a5f97fee731e20c7ca2695e7bc0b9 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 27 Mar 2023 10:01:59 +0200 Subject: [PATCH 01/16] Fixed dropdown color #260 --- kdb-web/package.json | 2 +- kdb-web/src/assets/config.json | 2 +- kdb-web/src/styles/themes/default-dark-theme.scss | 4 ++++ kdb-web/src/styles/themes/default-light-theme.scss | 4 ++++ kdb-web/src/styles/themes/sh-edraft-dark-theme.scss | 4 ++++ kdb-web/src/styles/themes/sh-edraft-light-theme.scss | 4 ++++ 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/kdb-web/package.json b/kdb-web/package.json index e9366174..fc35367e 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,6 +1,6 @@ { "name": "kdb-web", - "version": "1.0.0", + "version": "1.1.0", "scripts": { "ng": "ng", "update-version": "ts-node-esm update-version.ts", diff --git a/kdb-web/src/assets/config.json b/kdb-web/src/assets/config.json index d03fbe65..8a14a2f0 100644 --- a/kdb-web/src/assets/config.json +++ b/kdb-web/src/assets/config.json @@ -4,7 +4,7 @@ "ImprintURL": "https://www.sh-edraft.de/Impressum", "WebVersion": { "Major": "1", - "Minor": "0", + "Minor": "1", "Micro": "0" }, "Themes": [ diff --git a/kdb-web/src/styles/themes/default-dark-theme.scss b/kdb-web/src/styles/themes/default-dark-theme.scss index 2e6cac2c..5222645f 100644 --- a/kdb-web/src/styles/themes/default-dark-theme.scss +++ b/kdb-web/src/styles/themes/default-dark-theme.scss @@ -353,6 +353,10 @@ color: $primaryTextColor; } + .p-dropdown-panel .p-dropdown-items .p-dropdown-item { + color: $primaryTextColor !important; + } + .p-dropdown-panel { background-color: $secondaryBackgroundColor !important; diff --git a/kdb-web/src/styles/themes/default-light-theme.scss b/kdb-web/src/styles/themes/default-light-theme.scss index b8cd5b06..1e7078e2 100644 --- a/kdb-web/src/styles/themes/default-light-theme.scss +++ b/kdb-web/src/styles/themes/default-light-theme.scss @@ -353,6 +353,10 @@ color: $primaryTextColor; } + .p-dropdown-panel .p-dropdown-items .p-dropdown-item { + color: $primaryTextColor !important; + } + .p-dropdown-panel { background-color: $primaryBackgroundColor !important; diff --git a/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss b/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss index a116773e..42e926ff 100644 --- a/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss +++ b/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss @@ -357,6 +357,10 @@ color: $primaryTextColor; } + .p-dropdown-panel .p-dropdown-items .p-dropdown-item { + color: $primaryTextColor !important; + } + .p-dropdown-panel { background-color: $secondaryBackgroundColor !important; diff --git a/kdb-web/src/styles/themes/sh-edraft-light-theme.scss b/kdb-web/src/styles/themes/sh-edraft-light-theme.scss index ab335ab3..8fa8f2fb 100644 --- a/kdb-web/src/styles/themes/sh-edraft-light-theme.scss +++ b/kdb-web/src/styles/themes/sh-edraft-light-theme.scss @@ -353,6 +353,10 @@ color: $primaryTextColor; } + .p-dropdown-panel .p-dropdown-items .p-dropdown-item { + color: $primaryTextColor !important; + } + .p-dropdown-panel { background-color: $primaryBackgroundColor !important; From 3c8a092f4031f7577c32f09b3ab0438ea49bd3cb Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 27 Mar 2023 10:16:14 +0200 Subject: [PATCH 02/16] Added logic to add reaction after creating auto role rule in WI #259 --- kdb-bot/src/bot_core/abc/client_utils_abc.py | 8 ++++++ .../bot_core/service/client_utils_service.py | 26 +++++++++++++++++++ .../mutations/auto_role_rule_mutation.py | 22 ++++++++++++++++ .../auto_role/command/auto_role_group.py | 24 ++++------------- .../auto-roles-rules.component.ts | 2 +- 5 files changed, 62 insertions(+), 20 deletions(-) diff --git a/kdb-bot/src/bot_core/abc/client_utils_abc.py b/kdb-bot/src/bot_core/abc/client_utils_abc.py index 022665c0..6f393128 100644 --- a/kdb-bot/src/bot_core/abc/client_utils_abc.py +++ b/kdb-bot/src/bot_core/abc/client_utils_abc.py @@ -2,9 +2,11 @@ from abc import ABC, abstractmethod from datetime import datetime from typing import Callable +import discord from cpl_query.extension import List from discord.ext.commands import Context +from bot_data.model.auto_role_rule import AutoRoleRule from bot_data.model.user import User from modules.base.configuration.base_server_settings import BaseServerSettings @@ -59,3 +61,9 @@ class ClientUtilsABC(ABC): @abstractmethod def get_ontime_for_user(self, user: User) -> float: pass + + @abstractmethod + async def react_to_message_by_auto_role_rule( + self, discord_channel_id: int, discord_message_id: int, rule: AutoRoleRule, guild: discord.Guild + ): + pass diff --git a/kdb-bot/src/bot_core/service/client_utils_service.py b/kdb-bot/src/bot_core/service/client_utils_service.py index deab648d..01dafdda 100644 --- a/kdb-bot/src/bot_core/service/client_utils_service.py +++ b/kdb-bot/src/bot_core/service/client_utils_service.py @@ -9,6 +9,7 @@ from cpl_core.time import TimeFormatSettings from cpl_discord.service import DiscordBotServiceABC from cpl_query.extension import List from cpl_translation import TranslatePipe +from discord import Guild from discord.ext.commands import Context from bot_core.abc.client_utils_abc import ClientUtilsABC @@ -23,6 +24,7 @@ from bot_data.abc.user_joined_voice_channel_repository_abc import ( from bot_data.abc.user_message_count_per_hour_repository_abc import ( UserMessageCountPerHourRepositoryABC, ) +from bot_data.model.auto_role_rule import AutoRoleRule from bot_data.model.user import User from bot_data.model.user_message_count_per_hour import UserMessageCountPerHour from modules.base.configuration.base_server_settings import BaseServerSettings @@ -192,3 +194,27 @@ class ClientUtilsService(ClientUtilsABC): .sum(lambda join: (join.leaved_on - join.joined_on).total_seconds() / 3600), 2, ) + + async def react_to_message_by_auto_role_rule( + self, discord_channel_id: int, discord_message_id: int, rule: AutoRoleRule, guild: discord.Guild + ): + try: + guild: Guild = self._bot.guilds.where(lambda g: g == guild).single() + channel = guild.get_channel(discord_channel_id) + message = await channel.fetch_message(discord_message_id) + emoji = List(discord.Emoji, guild.emojis).where(lambda x: x.name == rule.emoji_name).single() + + if emoji is None: + self._logger.debug(__name__, f"Emoji {rule.emoji_name} not found") + return + await message.add_reaction(emoji) + self._logger.debug( + __name__, + f"Added reaction {rule.emoji_name} to message: {discord_message_id}", + ) + except Exception as e: + self._logger.error( + __name__, + f"Cannot add reaction {rule.emoji_name} to message: {discord_message_id}", + e, + ) diff --git a/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py b/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py index 76dce97c..56681df9 100644 --- a/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py @@ -1,5 +1,7 @@ from cpl_core.database.context import DatabaseContextABC +from cpl_discord.service import DiscordBotServiceABC +from bot_core.abc.client_utils_abc import ClientUtilsABC from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.model.auto_role_rule import AutoRoleRule @@ -10,15 +12,19 @@ from bot_graphql.abc.query_abc import QueryABC class AutoRoleRuleMutation(QueryABC): def __init__( self, + bot: DiscordBotServiceABC, servers: ServerRepositoryABC, auto_roles: AutoRoleRepositoryABC, db: DatabaseContextABC, + client_utils: ClientUtilsABC, ): QueryABC.__init__(self, "AutoRoleRuleMutation") + self._bot = bot self._servers = servers self._auto_roles = auto_roles self._db = db + self._client_utils = client_utils self.set_field("createAutoRoleRule", self.resolve_create_auto_role_rule) self.set_field("updateAutoRoleRule", self.resolve_update_auto_role_rule) @@ -40,6 +46,14 @@ class AutoRoleRuleMutation(QueryABC): and x.role_id == int(input["roleId"]) ) + self._bot.loop.create_task( + self._client_utils.react_to_message_by_auto_role_rule( + auto_role_rule.auto_role.discord_channel_id, + auto_role_rule.auto_role.discord_message_id, + auto_role_rule, + self._bot.get_guild(auto_role_rule.auto_role.server.discord_id), + ) + ) return self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role_rule.auto_role.id).where(get_new).last() def resolve_update_auto_role_rule(self, *_, input: dict): @@ -53,6 +67,14 @@ class AutoRoleRuleMutation(QueryABC): self._db.save_changes() auto_role_rule = self._auto_roles.get_auto_role_rule_by_id(input["id"]) + self._bot.loop.create_task( + self._client_utils.react_to_message_by_auto_role_rule( + auto_role_rule.auto_role.discord_channel_id, + auto_role_rule.auto_role.discord_message_id, + auto_role_rule, + self._bot.get_guild(auto_role_rule.auto_role.server.discord_id), + ) + ) return auto_role_rule def resolve_delete_auto_role_rule(self, *_, id: int): diff --git a/kdb-bot/src/modules/auto_role/command/auto_role_group.py b/kdb-bot/src/modules/auto_role/command/auto_role_group.py index b0ce3525..eff8263d 100644 --- a/kdb-bot/src/modules/auto_role/command/auto_role_group.py +++ b/kdb-bot/src/modules/auto_role/command/auto_role_group.py @@ -6,7 +6,7 @@ from cpl_discord.command import DiscordCommandABC from cpl_discord.service import DiscordBotServiceABC from cpl_query.extension import List from cpl_translation import TranslatePipe -from discord import app_commands, Guild +from discord import app_commands from discord.ext import commands from discord.ext.commands import Context @@ -312,26 +312,12 @@ class AutoRoleGroup(DiscordCommandABC): .where(lambda r: r.emoji_name == emoji.name and int(role_id) == role.id) .single() ) - try: - guild: Guild = self._bot.guilds.where(lambda g: g == ctx.guild).single() - channel = guild.get_channel(auto_role_from_db.discord_channel_id) - message = await channel.fetch_message(auto_role_from_db.discord_message_id) - emoji = List(discord.Emoji, guild.emojis).where(lambda x: x.name == rule.emoji_name).single() - if emoji is None: - self._logger.debug(__name__, f"Emoji {rule.emoji_name} not found") - return - await message.add_reaction(emoji) - self._logger.debug( - __name__, - f"Added reaction {rule.emoji_name} to message: {auto_role_from_db.discord_message_id}", - ) - except Exception as e: - self._logger.error( - __name__, - f"Cannot add reaction {rule.emoji_name} to message: {auto_role_from_db.discord_message_id}", - e, + self._bot.loop.create_task( + await self._client_utils.react_to_message_by_auto_role_rule( + auto_role_from_db.discord_channel_id, auto_role_from_db.discord_message_id, rule, ctx.guild ) + ) await self._message_service.send_ctx_msg( ctx, diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts index a4b9db54..7f302851 100644 --- a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts +++ b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts @@ -225,7 +225,7 @@ export class AutoRolesRulesComponent implements OnInit, OnDestroy { })).subscribe(result => { this.isEditingNew = false; this.spinner.hideSpinner(); - this.toastService.success(this.translate.instant("view.server.auto_roles.rules.message.auto_role_rule_created"), this.translate.instant("view.server.auto_roles.rules.message.auto_role_rule_create_d", { id: result.autoRoleRule.createAutoRoleRule?.id })); + this.toastService.success(this.translate.instant("view.server.auto_roles.rules.message.auto_role_rule_create"), this.translate.instant("view.server.auto_roles.rules.message.auto_role_rule_create_d", { id: result.autoRoleRule.createAutoRoleRule?.id })); this.loadNextPage(); }); return; From 657a8fa5867f99c4a2cdb4f4049ecf8c875a5b2c Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 27 Mar 2023 10:17:46 +0200 Subject: [PATCH 03/16] Added comment #259 --- kdb-bot/src/modules/auto_role/command/auto_role_group.py | 1 + 1 file changed, 1 insertion(+) diff --git a/kdb-bot/src/modules/auto_role/command/auto_role_group.py b/kdb-bot/src/modules/auto_role/command/auto_role_group.py index eff8263d..3969aea9 100644 --- a/kdb-bot/src/modules/auto_role/command/auto_role_group.py +++ b/kdb-bot/src/modules/auto_role/command/auto_role_group.py @@ -313,6 +313,7 @@ class AutoRoleGroup(DiscordCommandABC): .single() ) + # as task to run in background self._bot.loop.create_task( await self._client_utils.react_to_message_by_auto_role_rule( auto_role_from_db.discord_channel_id, auto_role_from_db.discord_message_id, rule, ctx.guild From 3bca3f86eb2044b59afb2680c1f280d1b2ae8623 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 27 Mar 2023 19:33:22 +0200 Subject: [PATCH 04/16] Disabled add button for mods in level list #264 --- kdb-web/package.json | 2 +- .../auto-roles-rules/auto-roles-rules.component.html | 2 +- .../auto-role/components/auto-roles/auto-roles.component.html | 2 +- .../server/levels/components/levels/levels.component.html | 4 ++-- .../app/modules/view/server/members/members.component.html | 2 +- kdb-web/src/assets/config.json | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kdb-web/package.json b/kdb-web/package.json index e9366174..fc35367e 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,6 +1,6 @@ { "name": "kdb-web", - "version": "1.0.0", + "version": "1.1.0", "scripts": { "ng": "ng", "update-version": "ts-node-esm update-version.ts", diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html index 60c0d0eb..3c389ab5 100644 --- a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html +++ b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html @@ -160,7 +160,7 @@
- + diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html index f6695fca..a2677dc0 100644 --- a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html +++ b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html @@ -193,7 +193,7 @@
- + diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html index 83f32aa3..97be32d8 100644 --- a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html +++ b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html @@ -18,7 +18,7 @@