Compare commits
1 Commits
3cba8de675
...
1.1.10
Author | SHA1 | Date | |
---|---|---|---|
eeda0405f3 |
@@ -9,13 +9,11 @@ from bot_data.migration.api_key_migration import ApiKeyMigration
|
|||||||
from bot_data.migration.api_migration import ApiMigration
|
from bot_data.migration.api_migration import ApiMigration
|
||||||
from bot_data.migration.auto_role_fix1_migration import AutoRoleFix1Migration
|
from bot_data.migration.auto_role_fix1_migration import AutoRoleFix1Migration
|
||||||
from bot_data.migration.auto_role_migration import AutoRoleMigration
|
from bot_data.migration.auto_role_migration import AutoRoleMigration
|
||||||
from bot_data.migration.birthday_migration import BirthdayMigration
|
|
||||||
from bot_data.migration.config_feature_flags_migration import ConfigFeatureFlagsMigration
|
from bot_data.migration.config_feature_flags_migration import ConfigFeatureFlagsMigration
|
||||||
from bot_data.migration.config_migration import ConfigMigration
|
from bot_data.migration.config_migration import ConfigMigration
|
||||||
from bot_data.migration.db_history_migration import DBHistoryMigration
|
from bot_data.migration.db_history_migration import DBHistoryMigration
|
||||||
from bot_data.migration.default_role_migration import DefaultRoleMigration
|
from bot_data.migration.default_role_migration import DefaultRoleMigration
|
||||||
from bot_data.migration.fix_updates_migration import FixUpdatesMigration
|
from bot_data.migration.fix_updates_migration import FixUpdatesMigration
|
||||||
from bot_data.migration.fix_user_history_migration import FixUserHistoryMigration
|
|
||||||
from bot_data.migration.initial_migration import InitialMigration
|
from bot_data.migration.initial_migration import InitialMigration
|
||||||
from bot_data.migration.level_migration import LevelMigration
|
from bot_data.migration.level_migration import LevelMigration
|
||||||
from bot_data.migration.remove_stats_migration import RemoveStatsMigration
|
from bot_data.migration.remove_stats_migration import RemoveStatsMigration
|
||||||
@@ -58,5 +56,3 @@ class StartupMigrationExtension(StartupExtensionABC):
|
|||||||
services.add_transient(MigrationABC, ShortRoleNameMigration) # 28.09.2023 #378 - 1.1.7
|
services.add_transient(MigrationABC, ShortRoleNameMigration) # 28.09.2023 #378 - 1.1.7
|
||||||
services.add_transient(MigrationABC, FixUpdatesMigration) # 28.09.2023 #378 - 1.1.7
|
services.add_transient(MigrationABC, FixUpdatesMigration) # 28.09.2023 #378 - 1.1.7
|
||||||
services.add_transient(MigrationABC, ShortRoleNameOnlyHighestMigration) # 02.10.2023 #391 - 1.1.9
|
services.add_transient(MigrationABC, ShortRoleNameOnlyHighestMigration) # 02.10.2023 #391 - 1.1.9
|
||||||
services.add_transient(MigrationABC, FixUserHistoryMigration) # 10.10.2023 #401 - 1.2.0
|
|
||||||
services.add_transient(MigrationABC, BirthdayMigration) # 10.10.2023 #401 - 1.2.0
|
|
||||||
|
@@ -229,10 +229,6 @@
|
|||||||
"success": "Verlinkung wurde entfernt :D"
|
"success": "Verlinkung wurde entfernt :D"
|
||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
"birthday": {
|
|
||||||
"success": "Dein Geburtstag wurde eingetragen.",
|
|
||||||
"success_team": "{} hat seinen Geburtstag eingetragen: {}"
|
|
||||||
},
|
|
||||||
"add": {
|
"add": {
|
||||||
"xp": "Die {} von {} wurden um {} erhöht"
|
"xp": "Die {} von {} wurden um {} erhöht"
|
||||||
},
|
},
|
||||||
|
@@ -131,7 +131,7 @@ class ClientUtilsService(ClientUtilsABC):
|
|||||||
if current in sl:
|
if current in sl:
|
||||||
sl = sl.skip(sl.index_of(current))
|
sl = sl.skip(sl.index_of(current))
|
||||||
|
|
||||||
_l = _l.where(lambda x: select(x) in sl)
|
_l = _l.where(lambda x: x.name in sl)
|
||||||
|
|
||||||
return _l.take(25)
|
return _l.take(25)
|
||||||
|
|
||||||
|
@@ -1,84 +0,0 @@
|
|||||||
from bot_core.logging.database_logger import DatabaseLogger
|
|
||||||
from bot_data.abc.migration_abc import MigrationABC
|
|
||||||
from bot_data.db_context import DBContext
|
|
||||||
|
|
||||||
|
|
||||||
class BirthdayMigration(MigrationABC):
|
|
||||||
name = "1.2.0_BirthdayMigration"
|
|
||||||
|
|
||||||
def __init__(self, logger: DatabaseLogger, db: DBContext):
|
|
||||||
MigrationABC.__init__(self)
|
|
||||||
self._logger = logger
|
|
||||||
self._db = db
|
|
||||||
self._cursor = db.cursor
|
|
||||||
|
|
||||||
def upgrade(self):
|
|
||||||
self._logger.debug(__name__, "Running upgrade")
|
|
||||||
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""
|
|
||||||
ALTER TABLE Users
|
|
||||||
ADD Birthday DATE NULL AFTER MessageCount;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""
|
|
||||||
ALTER TABLE UsersHistory
|
|
||||||
ADD Birthday DATE NULL AFTER MessageCount;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self._exec(__file__, "users.sql")
|
|
||||||
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""
|
|
||||||
ALTER TABLE CFG_Server
|
|
||||||
ADD XpForBirthday BIGINT(20) NOT NULL DEFAULT 0 AFTER XpPerAchievement;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""
|
|
||||||
ALTER TABLE CFG_ServerHistory
|
|
||||||
ADD XpForBirthday BIGINT(20) NOT NULL DEFAULT 0 AFTER XpPerAchievement;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self._exec(__file__, "config/server.sql")
|
|
||||||
|
|
||||||
def downgrade(self):
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""
|
|
||||||
ALTER TABLE Users DROP COLUMN Birthday;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""
|
|
||||||
ALTER TABLE UsersHistory DROP COLUMN Birthday;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""
|
|
||||||
ALTER TABLE CFG_Server DROP COLUMN XpForBirthday;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""
|
|
||||||
ALTER TABLE CFG_ServerHistory DROP COLUMN XpForBirthday;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
@@ -6,16 +6,13 @@ ALTER TABLE `Users`
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `UsersHistory`
|
CREATE TABLE IF NOT EXISTS `UsersHistory`
|
||||||
(
|
(
|
||||||
`Id` BIGINT(20) NOT NULL,
|
`Id` BIGINT(20) NOT NULL,
|
||||||
`DiscordId` BIGINT(20) NOT NULL,
|
`DiscordId` BIGINT(20) NOT NULL,
|
||||||
`XP` BIGINT(20) NOT NULL DEFAULT 0,
|
`XP` BIGINT(20) NOT NULL DEFAULT 0,
|
||||||
`ReactionCount` BIGINT(20) NOT NULL DEFAULT 0,
|
`ServerId` BIGINT(20) DEFAULT NULL,
|
||||||
`MessageCount` BIGINT(20) NOT NULL DEFAULT 0,
|
`Deleted` BOOL DEFAULT FALSE,
|
||||||
`Birthday` DATE NULL,
|
`DateFrom` DATETIME(6) NOT NULL,
|
||||||
`ServerId` BIGINT(20) DEFAULT NULL,
|
`DateTo` DATETIME(6) NOT NULL
|
||||||
`Deleted` BOOL DEFAULT FALSE,
|
|
||||||
`DateFrom` DATETIME(6) NOT NULL,
|
|
||||||
`DateTo` DATETIME(6) NOT NULL
|
|
||||||
);
|
);
|
||||||
|
|
||||||
DROP TRIGGER IF EXISTS `TR_UsersUpdate`;
|
DROP TRIGGER IF EXISTS `TR_UsersUpdate`;
|
||||||
@@ -25,10 +22,12 @@ CREATE TRIGGER `TR_UsersUpdate`
|
|||||||
ON `Users`
|
ON `Users`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO `UsersHistory` (`Id`, `DiscordId`, `XP`, `ReactionCount`, `MessageCount`, `Birthday`, `ServerId`,
|
INSERT INTO `UsersHistory` (
|
||||||
`DateFrom`, `DateTo`)
|
`Id`, `DiscordId`, `XP`, `ServerId`, `DateFrom`, `DateTo`
|
||||||
VALUES (OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ReactionCount, OLD.MessageCount, OLD.Birthday, OLD.ServerId,
|
)
|
||||||
OLD.LastModifiedAt, CURRENT_TIMESTAMP(6));
|
VALUES (
|
||||||
|
OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ServerId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
|
||||||
|
);
|
||||||
END;
|
END;
|
||||||
|
|
||||||
DROP TRIGGER IF EXISTS `TR_UsersDelete`;
|
DROP TRIGGER IF EXISTS `TR_UsersDelete`;
|
||||||
@@ -38,8 +37,10 @@ CREATE TRIGGER `TR_UsersDelete`
|
|||||||
ON `Users`
|
ON `Users`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO `UsersHistory` (`Id`, `DiscordId`, `XP`, `ReactionCount`, `MessageCount`, `Birthday`, `ServerId`,
|
INSERT INTO `UsersHistory` (
|
||||||
`Deleted`, `DateFrom`, `DateTo`)
|
`Id`, `DiscordId`, `XP`, `ServerId`, `Deleted`, `DateFrom`, `DateTo`
|
||||||
VALUES (OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ReactionCount, OLD.MessageCount, OLD.Birthday, OLD.ServerId, TRUE,
|
)
|
||||||
OLD.LastModifiedAt, CURRENT_TIMESTAMP(6));
|
VALUES (
|
||||||
|
OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ServerId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
|
||||||
|
);
|
||||||
END;
|
END;
|
@@ -1,45 +0,0 @@
|
|||||||
from bot_core.logging.database_logger import DatabaseLogger
|
|
||||||
from bot_data.abc.migration_abc import MigrationABC
|
|
||||||
from bot_data.db_context import DBContext
|
|
||||||
|
|
||||||
|
|
||||||
class FixUserHistoryMigration(MigrationABC):
|
|
||||||
name = "1.2.0_FixUserHistoryMigration"
|
|
||||||
|
|
||||||
def __init__(self, logger: DatabaseLogger, db: DBContext):
|
|
||||||
MigrationABC.__init__(self)
|
|
||||||
self._logger = logger
|
|
||||||
self._db = db
|
|
||||||
self._cursor = db.cursor
|
|
||||||
|
|
||||||
def upgrade(self):
|
|
||||||
self._logger.debug(__name__, "Running upgrade")
|
|
||||||
|
|
||||||
# fix 1.1.0_AchievementsMigration
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""ALTER TABLE UsersHistory ADD COLUMN IF NOT EXISTS ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP;"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""ALTER TABLE UsersHistory ADD COLUMN IF NOT EXISTS MessageCount BIGINT NOT NULL DEFAULT 0 AFTER ReactionCount;"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self._exec(__file__, "users.sql")
|
|
||||||
|
|
||||||
def downgrade(self):
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""
|
|
||||||
ALTER TABLE UsersHistory DROP COLUMN MessageCount;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self._cursor.execute(
|
|
||||||
str(
|
|
||||||
f"""
|
|
||||||
ALTER TABLE UsersHistory DROP COLUMN ReactionCount;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
@@ -24,7 +24,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
|||||||
xp_per_ontime_hour: int,
|
xp_per_ontime_hour: int,
|
||||||
xp_per_event_participation: int,
|
xp_per_event_participation: int,
|
||||||
xp_per_achievement: int,
|
xp_per_achievement: int,
|
||||||
xp_for_birthday: int,
|
|
||||||
afk_command_channel_id: int,
|
afk_command_channel_id: int,
|
||||||
help_voice_channel_id: int,
|
help_voice_channel_id: int,
|
||||||
team_channel_id: int,
|
team_channel_id: int,
|
||||||
@@ -49,7 +48,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
|||||||
self._xp_per_ontime_hour = xp_per_ontime_hour
|
self._xp_per_ontime_hour = xp_per_ontime_hour
|
||||||
self._xp_per_event_participation = xp_per_event_participation
|
self._xp_per_event_participation = xp_per_event_participation
|
||||||
self._xp_per_achievement = xp_per_achievement
|
self._xp_per_achievement = xp_per_achievement
|
||||||
self._xp_for_birthday = xp_for_birthday
|
|
||||||
self._afk_command_channel_id = afk_command_channel_id
|
self._afk_command_channel_id = afk_command_channel_id
|
||||||
self._help_voice_channel_id = help_voice_channel_id
|
self._help_voice_channel_id = help_voice_channel_id
|
||||||
self._team_channel_id = team_channel_id
|
self._team_channel_id = team_channel_id
|
||||||
@@ -78,7 +76,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
|||||||
10,
|
10,
|
||||||
10,
|
10,
|
||||||
10,
|
10,
|
||||||
10,
|
|
||||||
guild.system_channel.id,
|
guild.system_channel.id,
|
||||||
guild.system_channel.id,
|
guild.system_channel.id,
|
||||||
guild.system_channel.id,
|
guild.system_channel.id,
|
||||||
@@ -167,14 +164,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
|||||||
def xp_per_achievement(self, value: int):
|
def xp_per_achievement(self, value: int):
|
||||||
self._xp_per_achievement = value
|
self._xp_per_achievement = value
|
||||||
|
|
||||||
@property
|
|
||||||
def xp_for_birthday(self) -> int:
|
|
||||||
return self._xp_for_birthday
|
|
||||||
|
|
||||||
@xp_for_birthday.setter
|
|
||||||
def xp_for_birthday(self, value: int):
|
|
||||||
self._xp_for_birthday = value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def afk_command_channel_id(self) -> int:
|
def afk_command_channel_id(self) -> int:
|
||||||
return self._afk_command_channel_id
|
return self._afk_command_channel_id
|
||||||
@@ -291,7 +280,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
|||||||
`XpPerOntimeHour`,
|
`XpPerOntimeHour`,
|
||||||
`XpPerEventParticipation`,
|
`XpPerEventParticipation`,
|
||||||
`XpPerAchievement`,
|
`XpPerAchievement`,
|
||||||
`XpForBirthday`,
|
|
||||||
`AFKCommandChannelId`,
|
`AFKCommandChannelId`,
|
||||||
`HelpVoiceChannelId`,
|
`HelpVoiceChannelId`,
|
||||||
`TeamChannelId`,
|
`TeamChannelId`,
|
||||||
@@ -310,7 +298,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
|||||||
{self._xp_per_ontime_hour},
|
{self._xp_per_ontime_hour},
|
||||||
{self._xp_per_event_participation},
|
{self._xp_per_event_participation},
|
||||||
{self._xp_per_achievement},
|
{self._xp_per_achievement},
|
||||||
'{self._xp_for_birthday}',
|
|
||||||
{self._afk_command_channel_id},
|
{self._afk_command_channel_id},
|
||||||
{self._help_voice_channel_id},
|
{self._help_voice_channel_id},
|
||||||
{self._team_channel_id},
|
{self._team_channel_id},
|
||||||
@@ -337,7 +324,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
|||||||
`XpPerOntimeHour` = {self._xp_per_ontime_hour},
|
`XpPerOntimeHour` = {self._xp_per_ontime_hour},
|
||||||
`XpPerEventParticipation` = {self._xp_per_event_participation},
|
`XpPerEventParticipation` = {self._xp_per_event_participation},
|
||||||
`XpPerAchievement` = {self._xp_per_achievement},
|
`XpPerAchievement` = {self._xp_per_achievement},
|
||||||
`XpForBirthday` = {self._xp_for_birthday},
|
|
||||||
`AFKCommandChannelId` = {self._afk_command_channel_id},
|
`AFKCommandChannelId` = {self._afk_command_channel_id},
|
||||||
`HelpVoiceChannelId` = {self._help_voice_channel_id},
|
`HelpVoiceChannelId` = {self._help_voice_channel_id},
|
||||||
`TeamChannelId` = {self._team_channel_id},
|
`TeamChannelId` = {self._team_channel_id},
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
from datetime import datetime, date
|
from datetime import datetime
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.database import TableABC
|
from cpl_core.database import TableABC
|
||||||
@@ -17,7 +17,6 @@ class User(TableABC):
|
|||||||
xp: int,
|
xp: int,
|
||||||
reaction_count: int,
|
reaction_count: int,
|
||||||
message_count: int,
|
message_count: int,
|
||||||
birthday: Optional[date],
|
|
||||||
server: Optional[Server],
|
server: Optional[Server],
|
||||||
created_at: datetime = None,
|
created_at: datetime = None,
|
||||||
modified_at: datetime = None,
|
modified_at: datetime = None,
|
||||||
@@ -28,7 +27,6 @@ class User(TableABC):
|
|||||||
self._xp = xp
|
self._xp = xp
|
||||||
self._reaction_count = reaction_count
|
self._reaction_count = reaction_count
|
||||||
self._message_count = message_count
|
self._message_count = message_count
|
||||||
self._birthday = birthday
|
|
||||||
self._server = server
|
self._server = server
|
||||||
|
|
||||||
TableABC.__init__(self)
|
TableABC.__init__(self)
|
||||||
@@ -81,14 +79,6 @@ class User(TableABC):
|
|||||||
def reaction_count(self, value: int):
|
def reaction_count(self, value: int):
|
||||||
self._reaction_count = value
|
self._reaction_count = value
|
||||||
|
|
||||||
@property
|
|
||||||
def birthday(self) -> Optional[datetime]:
|
|
||||||
return self._birthday
|
|
||||||
|
|
||||||
@birthday.setter
|
|
||||||
def birthday(self, value: Optional[datetime]):
|
|
||||||
self._birthday = value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def ontime(self, services: ServiceProviderABC) -> float:
|
def ontime(self, services: ServiceProviderABC) -> float:
|
||||||
@@ -181,13 +171,12 @@ class User(TableABC):
|
|||||||
return str(
|
return str(
|
||||||
f"""
|
f"""
|
||||||
INSERT INTO `Users` (
|
INSERT INTO `Users` (
|
||||||
`DiscordId`, `XP`, `MessageCount`, `ReactionCount`, `Birthday`, `ServerId`
|
`DiscordId`, `XP`, `MessageCount`, `ReactionCount`, `ServerId`
|
||||||
) VALUES (
|
) VALUES (
|
||||||
{self._discord_id},
|
{self._discord_id},
|
||||||
{self._xp},
|
{self._xp},
|
||||||
{self._message_count},
|
{self._message_count},
|
||||||
{self._reaction_count},
|
{self._reaction_count},
|
||||||
'{self._birthday}',
|
|
||||||
{self._server.id}
|
{self._server.id}
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
@@ -200,8 +189,7 @@ class User(TableABC):
|
|||||||
UPDATE `Users`
|
UPDATE `Users`
|
||||||
SET `XP` = {self._xp},
|
SET `XP` = {self._xp},
|
||||||
`MessageCount` = {self._message_count},
|
`MessageCount` = {self._message_count},
|
||||||
`ReactionCount` = {self._reaction_count},
|
`ReactionCount` = {self._reaction_count}
|
||||||
`Birthday` = '{self._birthday}'
|
|
||||||
WHERE `UserId` = {self._user_id};
|
WHERE `UserId` = {self._user_id};
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
@@ -1,43 +0,0 @@
|
|||||||
from typing import Optional
|
|
||||||
|
|
||||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
|
||||||
|
|
||||||
|
|
||||||
# had to name it UserWarnings instead of UserWarning because UserWarning is a builtin class
|
|
||||||
class UserWarningsHistory(HistoryTableABC):
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
description: str,
|
|
||||||
user: int,
|
|
||||||
author: Optional[int],
|
|
||||||
deleted: bool,
|
|
||||||
date_from: str,
|
|
||||||
date_to: str,
|
|
||||||
id=0,
|
|
||||||
):
|
|
||||||
HistoryTableABC.__init__(self)
|
|
||||||
|
|
||||||
self._id = id
|
|
||||||
self._description = description
|
|
||||||
self._user = user
|
|
||||||
self._author = author
|
|
||||||
|
|
||||||
self._deleted = deleted
|
|
||||||
self._date_from = date_from
|
|
||||||
self._date_to = date_to
|
|
||||||
|
|
||||||
@property
|
|
||||||
def id(self) -> int:
|
|
||||||
return self._id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def description(self) -> str:
|
|
||||||
return self._description
|
|
||||||
|
|
||||||
@property
|
|
||||||
def user(self) -> int:
|
|
||||||
return self._user
|
|
||||||
|
|
||||||
@property
|
|
||||||
def author(self) -> Optional[int]:
|
|
||||||
return self._author
|
|
@@ -66,13 +66,12 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC):
|
|||||||
result[13],
|
result[13],
|
||||||
result[14],
|
result[14],
|
||||||
result[15],
|
result[15],
|
||||||
result[16],
|
json.loads(result[16]),
|
||||||
json.loads(result[17]),
|
self._servers.get_server_by_id(result[17]),
|
||||||
self._servers.get_server_by_id(result[18]),
|
self._get_afk_channel_ids(result[17]),
|
||||||
self._get_afk_channel_ids(result[18]),
|
self._get_team_role_ids(result[17]),
|
||||||
self._get_team_role_ids(result[18]),
|
result[18],
|
||||||
result[19],
|
result[19],
|
||||||
result[20],
|
|
||||||
id=result[0],
|
id=result[0],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -29,10 +29,9 @@ class UserRepositoryService(UserRepositoryABC):
|
|||||||
result[2],
|
result[2],
|
||||||
result[3],
|
result[3],
|
||||||
result[4],
|
result[4],
|
||||||
result[5].strftime("%d.%m.%Y") if result[5] is not None else None,
|
self._servers.get_server_by_id(result[5]),
|
||||||
self._servers.get_server_by_id(result[6]),
|
result[6],
|
||||||
result[7],
|
result[7],
|
||||||
result[8],
|
|
||||||
id=result[0],
|
id=result[0],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ class UserWarningsRepositoryService(UserWarningsRepositoryABC):
|
|||||||
def _from_result(self, sql_result: tuple) -> UserWarnings:
|
def _from_result(self, sql_result: tuple) -> UserWarnings:
|
||||||
user = self._users.get_user_by_id(self._get_value_from_result(sql_result[2]))
|
user = self._users.get_user_by_id(self._get_value_from_result(sql_result[2]))
|
||||||
author = None
|
author = None
|
||||||
author_id = self._get_value_from_result(sql_result[3])
|
author_id = self._get_value_from_result(sql_result[2])
|
||||||
if author_id is not None:
|
if author_id is not None:
|
||||||
author = self._users.get_user_by_id(author_id)
|
author = self._users.get_user_by_id(author_id)
|
||||||
|
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
|
|
||||||
from bot_data.model.user import User
|
from bot_data.model.user import User
|
||||||
@@ -6,14 +5,9 @@ from bot_graphql.abc.filter_abc import FilterABC
|
|||||||
|
|
||||||
|
|
||||||
class AchievementFilter(FilterABC):
|
class AchievementFilter(FilterABC):
|
||||||
def __init__(
|
def __init__(self):
|
||||||
self,
|
|
||||||
services: ServiceProviderABC,
|
|
||||||
):
|
|
||||||
FilterABC.__init__(self)
|
FilterABC.__init__(self)
|
||||||
|
|
||||||
self._services = services
|
|
||||||
|
|
||||||
self._id = None
|
self._id = None
|
||||||
self._name = None
|
self._name = None
|
||||||
self._description = None
|
self._description = None
|
||||||
|
@@ -1,56 +0,0 @@
|
|||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
|
||||||
from cpl_query.extension import List
|
|
||||||
|
|
||||||
from bot_data.model.user_warnings import UserWarnings
|
|
||||||
from bot_graphql.abc.filter_abc import FilterABC
|
|
||||||
|
|
||||||
|
|
||||||
class UserWarningFilter(FilterABC):
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
services: ServiceProviderABC,
|
|
||||||
):
|
|
||||||
FilterABC.__init__(self)
|
|
||||||
|
|
||||||
self._services = services
|
|
||||||
|
|
||||||
self._id = None
|
|
||||||
self._user = None
|
|
||||||
self._description = None
|
|
||||||
self._author = None
|
|
||||||
|
|
||||||
def from_dict(self, values: dict):
|
|
||||||
if "id" in values:
|
|
||||||
self._id = int(values["id"])
|
|
||||||
|
|
||||||
if "user" in values:
|
|
||||||
from bot_graphql.filter.user_filter import UserFilter
|
|
||||||
|
|
||||||
self._user: UserFilter = self._services.get_service(UserFilter)
|
|
||||||
self._user.from_dict(values["user"])
|
|
||||||
|
|
||||||
if "description" in values:
|
|
||||||
self._description = values["description"]
|
|
||||||
|
|
||||||
if "author" in values:
|
|
||||||
from bot_graphql.filter.user_filter import UserFilter
|
|
||||||
|
|
||||||
self._author: UserFilter = self._services.get_service(UserFilter)
|
|
||||||
self._author.from_dict(values["author"])
|
|
||||||
|
|
||||||
def filter(self, query: List[UserWarnings]) -> List[UserWarnings]:
|
|
||||||
if self._id is not None:
|
|
||||||
query = query.where(lambda x: x.id == self._id)
|
|
||||||
|
|
||||||
if self._user is not None:
|
|
||||||
users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id)
|
|
||||||
query = query.where(lambda x: x.id in users)
|
|
||||||
|
|
||||||
if self._description is not None:
|
|
||||||
query = query.where(lambda x: x.description == self._description or self._description in x.description)
|
|
||||||
|
|
||||||
if self._author is not None:
|
|
||||||
users = self._author.filter(query.select(lambda x: x.author)).select(lambda x: x.id)
|
|
||||||
query = query.where(lambda x: x.id in users)
|
|
||||||
|
|
||||||
return query
|
|
@@ -41,9 +41,6 @@ type Query {
|
|||||||
shortRoleNames(filter: ShortRoleNameFilter, page: Page, sort: Sort): [ShortRoleName]
|
shortRoleNames(filter: ShortRoleNameFilter, page: Page, sort: Sort): [ShortRoleName]
|
||||||
shortRoleNamePositions: [String]
|
shortRoleNamePositions: [String]
|
||||||
|
|
||||||
userWarningCount: Int
|
|
||||||
userWarnings(filter: UserWarningFilter, page: Page, sort: Sort): [UserWarning]
|
|
||||||
|
|
||||||
technicianConfig: TechnicianConfig
|
technicianConfig: TechnicianConfig
|
||||||
possibleFeatureFlags: [String]
|
possibleFeatureFlags: [String]
|
||||||
discord: Discord
|
discord: Discord
|
||||||
|
@@ -9,7 +9,6 @@ type ServerConfig implements TableWithHistoryQuery {
|
|||||||
xpPerOntimeHour: Int
|
xpPerOntimeHour: Int
|
||||||
xpPerEventParticipation: Int
|
xpPerEventParticipation: Int
|
||||||
xpPerAchievement: Int
|
xpPerAchievement: Int
|
||||||
xpForBirthday: Int
|
|
||||||
afkCommandChannelId: String
|
afkCommandChannelId: String
|
||||||
helpVoiceChannelId: String
|
helpVoiceChannelId: String
|
||||||
teamChannelId: String
|
teamChannelId: String
|
||||||
@@ -42,7 +41,6 @@ type ServerConfigHistory implements HistoryTableQuery {
|
|||||||
xpPerOntimeHour: Int
|
xpPerOntimeHour: Int
|
||||||
xpPerEventParticipation: Int
|
xpPerEventParticipation: Int
|
||||||
xpPerAchievement: Int
|
xpPerAchievement: Int
|
||||||
xpForBirthday: Int
|
|
||||||
afkCommandChannelId: String
|
afkCommandChannelId: String
|
||||||
helpVoiceChannelId: String
|
helpVoiceChannelId: String
|
||||||
teamChannelId: String
|
teamChannelId: String
|
||||||
@@ -93,7 +91,6 @@ input ServerConfigInput {
|
|||||||
xpPerOntimeHour: Int
|
xpPerOntimeHour: Int
|
||||||
xpPerEventParticipation: Int
|
xpPerEventParticipation: Int
|
||||||
xpPerAchievement: Int
|
xpPerAchievement: Int
|
||||||
xpForBirthday: Int
|
|
||||||
afkCommandChannelId: String
|
afkCommandChannelId: String
|
||||||
helpVoiceChannelId: String
|
helpVoiceChannelId: String
|
||||||
teamChannelId: String
|
teamChannelId: String
|
||||||
|
@@ -5,7 +5,6 @@ type User implements TableWithHistoryQuery {
|
|||||||
xp: Int
|
xp: Int
|
||||||
messageCount: Int
|
messageCount: Int
|
||||||
reactionCount: Int
|
reactionCount: Int
|
||||||
birthday: String
|
|
||||||
ontime: Float
|
ontime: Float
|
||||||
level: Level
|
level: Level
|
||||||
|
|
||||||
@@ -21,9 +20,6 @@ type User implements TableWithHistoryQuery {
|
|||||||
achievementCount: Int
|
achievementCount: Int
|
||||||
achievements(filter: AchievementFilter, page: Page, sort: Sort): [Achievement]
|
achievements(filter: AchievementFilter, page: Page, sort: Sort): [Achievement]
|
||||||
|
|
||||||
userWarningCount: Int
|
|
||||||
userWarnings(filter: UserWarningFilter, page: Page, sort: Sort): [UserWarning]
|
|
||||||
|
|
||||||
server: Server
|
server: Server
|
||||||
leftServer: Boolean
|
leftServer: Boolean
|
||||||
|
|
||||||
@@ -63,7 +59,5 @@ type UserMutation {
|
|||||||
input UserInput {
|
input UserInput {
|
||||||
id: ID
|
id: ID
|
||||||
xp: Int
|
xp: Int
|
||||||
birthday: String
|
|
||||||
levelId: ID
|
levelId: ID
|
||||||
userWarnings: [UserWarningInput]
|
|
||||||
}
|
}
|
@@ -1,34 +0,0 @@
|
|||||||
type UserWarning implements TableWithHistoryQuery {
|
|
||||||
id: ID
|
|
||||||
user: User
|
|
||||||
description: String
|
|
||||||
author: User
|
|
||||||
|
|
||||||
createdAt: String
|
|
||||||
modifiedAt: String
|
|
||||||
|
|
||||||
history: [UserWarningHistory]
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserWarningHistory implements HistoryTableQuery {
|
|
||||||
id: ID
|
|
||||||
user: ID
|
|
||||||
description: String
|
|
||||||
author: ID
|
|
||||||
|
|
||||||
deleted: Boolean
|
|
||||||
dateFrom: String
|
|
||||||
dateTo: String
|
|
||||||
}
|
|
||||||
|
|
||||||
input UserWarningFilter {
|
|
||||||
id: ID
|
|
||||||
user: UserFilter
|
|
||||||
}
|
|
||||||
|
|
||||||
input UserWarningInput {
|
|
||||||
id: ID
|
|
||||||
user: ID
|
|
||||||
description: String
|
|
||||||
author: ID
|
|
||||||
}
|
|
@@ -18,7 +18,6 @@ from bot_graphql.filter.user_filter import UserFilter
|
|||||||
from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter
|
from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter
|
||||||
from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter
|
from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter
|
||||||
from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter
|
from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter
|
||||||
from bot_graphql.filter.user_warning_filter import UserWarningFilter
|
|
||||||
from bot_graphql.graphql_service import GraphQLService
|
from bot_graphql.graphql_service import GraphQLService
|
||||||
from bot_graphql.mutation import Mutation
|
from bot_graphql.mutation import Mutation
|
||||||
from bot_graphql.mutations.achievement_mutation import AchievementMutation
|
from bot_graphql.mutations.achievement_mutation import AchievementMutation
|
||||||
@@ -67,8 +66,6 @@ from bot_graphql.queries.user_joined_server_query import UserJoinedServerQuery
|
|||||||
from bot_graphql.queries.user_joined_voice_channel_history_query import UserJoinedVoiceChannelHistoryQuery
|
from bot_graphql.queries.user_joined_voice_channel_history_query import UserJoinedVoiceChannelHistoryQuery
|
||||||
from bot_graphql.queries.user_joined_voice_channel_query import UserJoinedVoiceChannelQuery
|
from bot_graphql.queries.user_joined_voice_channel_query import UserJoinedVoiceChannelQuery
|
||||||
from bot_graphql.queries.user_query import UserQuery
|
from bot_graphql.queries.user_query import UserQuery
|
||||||
from bot_graphql.queries.user_warning_history_query import UserWarningHistoryQuery
|
|
||||||
from bot_graphql.queries.user_warning_query import UserWarningQuery
|
|
||||||
from bot_graphql.query import Query
|
from bot_graphql.query import Query
|
||||||
from bot_graphql.schema import Schema
|
from bot_graphql.schema import Schema
|
||||||
|
|
||||||
@@ -118,8 +115,6 @@ class GraphQLModule(ModuleABC):
|
|||||||
services.add_transient(QueryABC, UserJoinedGameServerQuery)
|
services.add_transient(QueryABC, UserJoinedGameServerQuery)
|
||||||
services.add_transient(QueryABC, ShortRoleNameHistoryQuery)
|
services.add_transient(QueryABC, ShortRoleNameHistoryQuery)
|
||||||
services.add_transient(QueryABC, ShortRoleNameQuery)
|
services.add_transient(QueryABC, ShortRoleNameQuery)
|
||||||
services.add_transient(QueryABC, UserWarningHistoryQuery)
|
|
||||||
services.add_transient(QueryABC, UserWarningQuery)
|
|
||||||
|
|
||||||
services.add_transient(QueryABC, DiscordQuery)
|
services.add_transient(QueryABC, DiscordQuery)
|
||||||
services.add_transient(QueryABC, GuildQuery)
|
services.add_transient(QueryABC, GuildQuery)
|
||||||
@@ -140,7 +135,6 @@ class GraphQLModule(ModuleABC):
|
|||||||
services.add_transient(FilterABC, UserJoinedVoiceChannelFilter)
|
services.add_transient(FilterABC, UserJoinedVoiceChannelFilter)
|
||||||
services.add_transient(FilterABC, UserJoinedGameServerFilter)
|
services.add_transient(FilterABC, UserJoinedGameServerFilter)
|
||||||
services.add_transient(FilterABC, ShortRoleNameFilter)
|
services.add_transient(FilterABC, ShortRoleNameFilter)
|
||||||
services.add_transient(FilterABC, UserWarningFilter)
|
|
||||||
|
|
||||||
# mutations
|
# mutations
|
||||||
services.add_transient(QueryABC, AutoRoleMutation)
|
services.add_transient(QueryABC, AutoRoleMutation)
|
||||||
|
@@ -139,7 +139,6 @@ class ServerConfigMutation(QueryABC):
|
|||||||
self._update_team_role_ids(server_config)
|
self._update_team_role_ids(server_config)
|
||||||
|
|
||||||
self._db.save_changes()
|
self._db.save_changes()
|
||||||
self._bot.loop.create_task(self._config_service.reload_server_config(server_config.server))
|
|
||||||
return server_config
|
return server_config
|
||||||
|
|
||||||
def _update_afk_channel_ids(self, new_config: ServerConfig):
|
def _update_afk_channel_ids(self, new_config: ServerConfig):
|
||||||
@@ -179,3 +178,5 @@ class ServerConfigMutation(QueryABC):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
self._server_configs.add_server_team_role_id_config(role_id)
|
self._server_configs.add_server_team_role_id_config(role_id)
|
||||||
|
|
||||||
|
self._bot.loop.create_task(self._config_service.reload_server_config(new_config.server))
|
||||||
|
@@ -1,17 +1,11 @@
|
|||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
|
|
||||||
from bot_api.route.route import Route
|
|
||||||
from bot_data.abc.level_repository_abc import LevelRepositoryABC
|
from bot_data.abc.level_repository_abc import LevelRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC
|
|
||||||
from bot_data.model.user import User
|
|
||||||
from bot_data.model.user_role_enum import UserRoleEnum
|
from bot_data.model.user_role_enum import UserRoleEnum
|
||||||
from bot_graphql.abc.query_abc import QueryABC
|
from bot_graphql.abc.query_abc import QueryABC
|
||||||
from modules.base.service.user_warnings_service import UserWarningsService
|
|
||||||
from modules.level.service.level_service import LevelService
|
from modules.level.service.level_service import LevelService
|
||||||
from modules.permission.service.permission_service import PermissionService
|
from modules.permission.service.permission_service import PermissionService
|
||||||
|
|
||||||
@@ -26,8 +20,6 @@ class UserMutation(QueryABC):
|
|||||||
permissions: PermissionService,
|
permissions: PermissionService,
|
||||||
levels: LevelRepositoryABC,
|
levels: LevelRepositoryABC,
|
||||||
level_service: LevelService,
|
level_service: LevelService,
|
||||||
user_warnings: UserWarningsRepositoryABC,
|
|
||||||
user_warning_service: UserWarningsService,
|
|
||||||
):
|
):
|
||||||
QueryABC.__init__(self, "UserMutation")
|
QueryABC.__init__(self, "UserMutation")
|
||||||
|
|
||||||
@@ -38,33 +30,20 @@ class UserMutation(QueryABC):
|
|||||||
self._permissions = permissions
|
self._permissions = permissions
|
||||||
self._levels = levels
|
self._levels = levels
|
||||||
self._level_service = level_service
|
self._level_service = level_service
|
||||||
self._user_warnings = user_warnings
|
|
||||||
self._user_warning_service = user_warning_service
|
|
||||||
|
|
||||||
self.set_field("updateUser", self.resolve_update_user)
|
self.set_field("updateUser", self.resolve_update_user)
|
||||||
|
|
||||||
def resolve_update_user(self, *_, input: dict):
|
def resolve_update_user(self, *_, input: dict):
|
||||||
user = self._users.get_user_by_id(input["id"])
|
user = self._users.get_user_by_id(input["id"])
|
||||||
|
self._can_user_mutate_data(user.server, UserRoleEnum.moderator)
|
||||||
|
|
||||||
auth_user = Route.get_user()
|
new_xp = None
|
||||||
member = self._bot.get_guild(user.server.discord_id).get_member(
|
if "levelId" in input:
|
||||||
auth_user.users.where(lambda x: x.server.id == user.server.id).single().discord_id
|
level = self._levels.get_level_by_id(input["levelId"])
|
||||||
)
|
if user.level.id != level.id:
|
||||||
if member.id != user.discord_id:
|
new_xp = level.min_xp
|
||||||
self._can_user_mutate_data(user.server, UserRoleEnum.moderator)
|
|
||||||
|
|
||||||
new_xp = None
|
user.xp = new_xp if new_xp is not None else input["xp"] if "xp" in input else user.xp
|
||||||
if "levelId" in input:
|
|
||||||
level = self._levels.get_level_by_id(input["levelId"])
|
|
||||||
if user.level.id != level.id:
|
|
||||||
new_xp = level.min_xp
|
|
||||||
|
|
||||||
if "userWarnings" in input:
|
|
||||||
self._update_user_warning(user, input["userWarnings"])
|
|
||||||
|
|
||||||
user.xp = new_xp if new_xp is not None else input["xp"] if "xp" in input else user.xp
|
|
||||||
|
|
||||||
user.birthday = datetime.strptime(input["birthday"], "%d.%m.%Y") if "birthday" in input else user.birthday
|
|
||||||
|
|
||||||
self._users.update_user(user)
|
self._users.update_user(user)
|
||||||
self._db.save_changes()
|
self._db.save_changes()
|
||||||
@@ -72,19 +51,3 @@ class UserMutation(QueryABC):
|
|||||||
|
|
||||||
user = self._users.get_user_by_id(input["id"])
|
user = self._users.get_user_by_id(input["id"])
|
||||||
return user
|
return user
|
||||||
|
|
||||||
def _update_user_warning(self, user: User, new_warnings: dict):
|
|
||||||
old_warnings = self._user_warnings.get_user_warnings_by_user_id(user.id)
|
|
||||||
for warning in old_warnings:
|
|
||||||
if warning.id in [int(x["id"]) if "id" in x else None for x in new_warnings]:
|
|
||||||
continue
|
|
||||||
|
|
||||||
self._user_warning_service.remove_warnings(warning.id)
|
|
||||||
|
|
||||||
for warning in new_warnings:
|
|
||||||
if "id" in warning and int(warning["id"]) in old_warnings.select(lambda x: x.id):
|
|
||||||
continue
|
|
||||||
|
|
||||||
member = self._bot.get_guild(user.server.discord_id).get_member(user.discord_id)
|
|
||||||
author = self._users.get_user_by_id(int(warning["author"]))
|
|
||||||
self._user_warning_service.add_warnings(member, warning["description"], author.discord_id)
|
|
||||||
|
@@ -20,7 +20,6 @@ class ServerConfigQuery(DataQueryWithHistoryABC):
|
|||||||
self.set_field("xpPerOntimeHour", lambda config, *_: config.xp_per_ontime_hour)
|
self.set_field("xpPerOntimeHour", lambda config, *_: config.xp_per_ontime_hour)
|
||||||
self.set_field("xpPerEventParticipation", lambda config, *_: config.xp_per_event_participation)
|
self.set_field("xpPerEventParticipation", lambda config, *_: config.xp_per_event_participation)
|
||||||
self.set_field("xpPerAchievement", lambda config, *_: config.xp_per_achievement)
|
self.set_field("xpPerAchievement", lambda config, *_: config.xp_per_achievement)
|
||||||
self.set_field("xpForBirthday", lambda config, *_: config.xp_for_birthday)
|
|
||||||
self.set_field("afkCommandChannelId", lambda config, *_: config.afk_command_channel_id)
|
self.set_field("afkCommandChannelId", lambda config, *_: config.afk_command_channel_id)
|
||||||
self.set_field("helpVoiceChannelId", lambda config, *_: config.help_voice_channel_id)
|
self.set_field("helpVoiceChannelId", lambda config, *_: config.help_voice_channel_id)
|
||||||
self.set_field("teamChannelId", lambda config, *_: config.team_channel_id)
|
self.set_field("teamChannelId", lambda config, *_: config.team_channel_id)
|
||||||
|
@@ -6,7 +6,6 @@ from bot_data.abc.achievement_repository_abc import AchievementRepositoryABC
|
|||||||
from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC
|
from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC
|
||||||
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
||||||
from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC
|
from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC
|
||||||
from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC
|
|
||||||
from bot_data.model.user import User
|
from bot_data.model.user import User
|
||||||
from bot_data.model.user_history import UserHistory
|
from bot_data.model.user_history import UserHistory
|
||||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||||
@@ -14,7 +13,6 @@ from bot_graphql.filter.achievement_filter import AchievementFilter
|
|||||||
from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter
|
from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter
|
||||||
from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter
|
from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter
|
||||||
from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter
|
from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter
|
||||||
from bot_graphql.filter.user_warning_filter import UserWarningFilter
|
|
||||||
from modules.level.service.level_service import LevelService
|
from modules.level.service.level_service import LevelService
|
||||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||||
|
|
||||||
@@ -31,7 +29,6 @@ class UserQuery(DataQueryWithHistoryABC):
|
|||||||
user_joined_game_server: UserJoinedGameServerRepositoryABC,
|
user_joined_game_server: UserJoinedGameServerRepositoryABC,
|
||||||
permissions: PermissionServiceABC,
|
permissions: PermissionServiceABC,
|
||||||
achievements: AchievementRepositoryABC,
|
achievements: AchievementRepositoryABC,
|
||||||
user_warnings: UserWarningsRepositoryABC,
|
|
||||||
):
|
):
|
||||||
DataQueryWithHistoryABC.__init__(self, "User", "UsersHistory", UserHistory, db)
|
DataQueryWithHistoryABC.__init__(self, "User", "UsersHistory", UserHistory, db)
|
||||||
|
|
||||||
@@ -50,7 +47,6 @@ class UserQuery(DataQueryWithHistoryABC):
|
|||||||
self.set_field("xp", self.resolve_xp)
|
self.set_field("xp", self.resolve_xp)
|
||||||
self.set_field("messageCount", lambda x, *_: x.message_count)
|
self.set_field("messageCount", lambda x, *_: x.message_count)
|
||||||
self.set_field("reactionCount", lambda x, *_: x.reaction_count)
|
self.set_field("reactionCount", lambda x, *_: x.reaction_count)
|
||||||
self.set_field("birthday", lambda x, *_: x.birthday)
|
|
||||||
self.set_field("ontime", self.resolve_ontime)
|
self.set_field("ontime", self.resolve_ontime)
|
||||||
self.set_field("level", self.resolve_level)
|
self.set_field("level", self.resolve_level)
|
||||||
self.add_collection(
|
self.add_collection(
|
||||||
@@ -71,9 +67,6 @@ class UserQuery(DataQueryWithHistoryABC):
|
|||||||
self.add_collection(
|
self.add_collection(
|
||||||
"achievement", lambda user, *_: achievements.get_achievements_by_user_id(user.id), AchievementFilter
|
"achievement", lambda user, *_: achievements.get_achievements_by_user_id(user.id), AchievementFilter
|
||||||
)
|
)
|
||||||
self.add_collection(
|
|
||||||
"userWarning", lambda user, *_: user_warnings.get_user_warnings_by_user_id(user.id), UserWarningFilter
|
|
||||||
)
|
|
||||||
|
|
||||||
self.set_field("server", self.resolve_server)
|
self.set_field("server", self.resolve_server)
|
||||||
self.set_field("leftServer", self.resolve_left_server)
|
self.set_field("leftServer", self.resolve_left_server)
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
from bot_graphql.abc.history_query_abc import HistoryQueryABC
|
|
||||||
|
|
||||||
|
|
||||||
class UserWarningHistoryQuery(HistoryQueryABC):
|
|
||||||
def __init__(self):
|
|
||||||
HistoryQueryABC.__init__(self, "UserWarning")
|
|
||||||
|
|
||||||
self.set_field("id", lambda x, *_: x.id)
|
|
||||||
self.set_field("user", lambda x, *_: x.user)
|
|
||||||
self.set_field("description", lambda x, *_: x.description)
|
|
||||||
self.set_field("author", lambda x, *_: x.author)
|
|
@@ -1,17 +0,0 @@
|
|||||||
from cpl_core.database.context import DatabaseContextABC
|
|
||||||
|
|
||||||
from bot_data.model.user_warnings_history import UserWarningsHistory
|
|
||||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
|
||||||
|
|
||||||
|
|
||||||
class UserWarningQuery(DataQueryWithHistoryABC):
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
db: DatabaseContextABC,
|
|
||||||
):
|
|
||||||
DataQueryWithHistoryABC.__init__(self, "UserWarning", "UserWarningsHistory", UserWarningsHistory, db)
|
|
||||||
|
|
||||||
self.set_field("id", lambda x, *_: x.id)
|
|
||||||
self.set_field("user", lambda x, *_: x.user)
|
|
||||||
self.set_field("description", lambda x, *_: x.description)
|
|
||||||
self.set_field("author", lambda x, *_: x.author)
|
|
@@ -15,7 +15,6 @@ from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameSe
|
|||||||
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
||||||
from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC
|
from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC
|
|
||||||
from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum
|
from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum
|
||||||
from bot_graphql.abc.query_abc import QueryABC
|
from bot_graphql.abc.query_abc import QueryABC
|
||||||
from bot_graphql.filter.achievement_filter import AchievementFilter
|
from bot_graphql.filter.achievement_filter import AchievementFilter
|
||||||
@@ -29,7 +28,6 @@ from bot_graphql.filter.user_filter import UserFilter
|
|||||||
from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter
|
from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter
|
||||||
from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter
|
from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter
|
||||||
from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter
|
from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter
|
||||||
from bot_graphql.filter.user_warning_filter import UserWarningFilter
|
|
||||||
from bot_graphql.model.discord import Discord
|
from bot_graphql.model.discord import Discord
|
||||||
from modules.achievements.achievement_service import AchievementService
|
from modules.achievements.achievement_service import AchievementService
|
||||||
|
|
||||||
@@ -50,7 +48,6 @@ class Query(QueryABC):
|
|||||||
users: UserRepositoryABC,
|
users: UserRepositoryABC,
|
||||||
achievements: AchievementRepositoryABC,
|
achievements: AchievementRepositoryABC,
|
||||||
short_role_names: ShortRoleNameRepositoryABC,
|
short_role_names: ShortRoleNameRepositoryABC,
|
||||||
user_warnings: UserWarningsRepositoryABC,
|
|
||||||
achievement_service: AchievementService,
|
achievement_service: AchievementService,
|
||||||
technician_config: TechnicianConfigRepositoryABC,
|
technician_config: TechnicianConfigRepositoryABC,
|
||||||
):
|
):
|
||||||
@@ -79,13 +76,11 @@ class Query(QueryABC):
|
|||||||
self.add_collection("user", lambda *_: users.get_users(), UserFilter)
|
self.add_collection("user", lambda *_: users.get_users(), UserFilter)
|
||||||
self.add_collection("achievement", lambda *_: achievements.get_achievements(), AchievementFilter)
|
self.add_collection("achievement", lambda *_: achievements.get_achievements(), AchievementFilter)
|
||||||
self.add_collection("shortRoleName", lambda *_: short_role_names.get_short_role_names(), ShortRoleNameFilter)
|
self.add_collection("shortRoleName", lambda *_: short_role_names.get_short_role_names(), ShortRoleNameFilter)
|
||||||
self.add_collection("userWarning", lambda *_: user_warnings.get_user_warnings(), UserWarningFilter)
|
|
||||||
|
|
||||||
self.set_field("technicianConfig", lambda *_: technician_config.get_technician_config())
|
self.set_field("technicianConfig", lambda *_: technician_config.get_technician_config())
|
||||||
|
|
||||||
self.set_field("achievementAttributes", lambda *_: achievement_service.get_attributes())
|
self.set_field("achievementAttributes", lambda *_: achievement_service.get_attributes())
|
||||||
self.set_field("achievementOperators", lambda *_: achievement_service.get_operators())
|
self.set_field("achievementOperators", lambda *_: achievement_service.get_operators())
|
||||||
self.set_field("shortRoleNamePositions", lambda *_: [x.value for x in ShortRoleNamePositionEnum])
|
self.set_field("shortRoleNamePositions", lambda *_: [x.value for x in ShortRoleNamePositionEnum])
|
||||||
|
|
||||||
self.set_field("possibleFeatureFlags", lambda *_: [e.value for e in FeatureFlagsEnum])
|
self.set_field("possibleFeatureFlags", lambda *_: [e.value for e in FeatureFlagsEnum])
|
||||||
self.set_field("discord", lambda *_: Discord(bot.guilds, List(any).extend(bot.users)))
|
self.set_field("discord", lambda *_: Discord(bot.guilds, List(any).extend(bot.users)))
|
||||||
|
@@ -61,7 +61,7 @@ class AutoRoleGroup(DiscordCommandABC):
|
|||||||
auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select(lambda x: x.id)
|
auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select(lambda x: x.id)
|
||||||
return [
|
return [
|
||||||
app_commands.Choice(name=auto_role, value=auto_role)
|
app_commands.Choice(name=auto_role, value=auto_role)
|
||||||
for auto_role in self._client_utils.get_auto_complete_list(auto_roles, current, lambda x: x.name)
|
for auto_role in self._client_utils.get_auto_complete_list(auto_roles, current)
|
||||||
]
|
]
|
||||||
|
|
||||||
@commands.hybrid_group(name="auto-role")
|
@commands.hybrid_group(name="auto-role")
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
import datetime
|
from typing import Optional, List
|
||||||
from typing import Optional, List as TList
|
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_discord.command import DiscordCommandABC
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_query.extension import List
|
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
@@ -24,7 +22,6 @@ from bot_data.abc.user_joined_voice_channel_repository_abc import (
|
|||||||
)
|
)
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC
|
from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC
|
||||||
from bot_data.model.server_config import ServerConfig
|
|
||||||
from modules.base.service.user_warnings_service import UserWarningsService
|
from modules.base.service.user_warnings_service import UserWarningsService
|
||||||
from modules.level.service.level_service import LevelService
|
from modules.level.service.level_service import LevelService
|
||||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||||
@@ -76,7 +73,7 @@ class UserGroup(DiscordCommandABC):
|
|||||||
"ontime": self._t.transform("modules.base.user.atr.ontime"),
|
"ontime": self._t.transform("modules.base.user.atr.ontime"),
|
||||||
}
|
}
|
||||||
|
|
||||||
self._atr_TList = [(key, self._atr_dict[key]) for key in self._atr_dict]
|
self._atr_list = [(key, self._atr_dict[key]) for key in self._atr_dict]
|
||||||
|
|
||||||
async def _handle_atr_calc(
|
async def _handle_atr_calc(
|
||||||
self,
|
self,
|
||||||
@@ -119,61 +116,6 @@ class UserGroup(DiscordCommandABC):
|
|||||||
async def user(self, ctx: Context):
|
async def user(self, ctx: Context):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@user.command()
|
|
||||||
@commands.guild_only()
|
|
||||||
@CommandChecks.check_is_ready()
|
|
||||||
async def birthday(self, ctx: Context, day: int, month: int, year: int):
|
|
||||||
self._logger.debug(__name__, f"Received command user birthday {ctx}:{ctx.author},{day}:{month}:{year}")
|
|
||||||
date = datetime.date(year, month, day)
|
|
||||||
server = self._servers.get_server_by_discord_id(ctx.guild.id)
|
|
||||||
user = self._users.get_user_by_discord_id_and_server_id(ctx.author.id, server.id)
|
|
||||||
user.birthday = date
|
|
||||||
self._users.update_user(user)
|
|
||||||
self._db.save_changes()
|
|
||||||
await self._message_service.send_interaction_msg(
|
|
||||||
ctx.interaction, self._t.transform("modules.base.user.birthday.success")
|
|
||||||
)
|
|
||||||
# notify team to prevent multiple entries every day
|
|
||||||
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
|
||||||
channel = ctx.guild.get_channel(settings.team_channel_id)
|
|
||||||
await self._message_service.send_channel_message(
|
|
||||||
channel,
|
|
||||||
self._t.transform("modules.base.user.birthday.success_team").format(ctx.author.mention, date),
|
|
||||||
is_persistent=True,
|
|
||||||
)
|
|
||||||
self._logger.trace(__name__, f"Finished user-info command")
|
|
||||||
|
|
||||||
@birthday.autocomplete("day")
|
|
||||||
async def birthday_autocomplete(
|
|
||||||
self, interaction: discord.Interaction, current: str
|
|
||||||
) -> TList[app_commands.Choice[int]]:
|
|
||||||
days = List(int, range(0, 32)).select(lambda x: str(x))
|
|
||||||
return [
|
|
||||||
app_commands.Choice(name=date, value=date)
|
|
||||||
for date in self._client_utils.get_auto_complete_list(days, current)
|
|
||||||
]
|
|
||||||
|
|
||||||
@birthday.autocomplete("month")
|
|
||||||
async def birthday_autocomplete(
|
|
||||||
self, interaction: discord.Interaction, current: str
|
|
||||||
) -> TList[app_commands.Choice[int]]:
|
|
||||||
days = List(int, range(0, 13)).select(lambda x: str(x))
|
|
||||||
return [
|
|
||||||
app_commands.Choice(name=date, value=date)
|
|
||||||
for date in self._client_utils.get_auto_complete_list(days, current)
|
|
||||||
]
|
|
||||||
|
|
||||||
@birthday.autocomplete("year")
|
|
||||||
async def birthday_autocomplete(
|
|
||||||
self, interaction: discord.Interaction, current: str
|
|
||||||
) -> TList[app_commands.Choice[int]]:
|
|
||||||
today = datetime.date.today()
|
|
||||||
days = List(int, range(today.year - 75, today.year)).select(lambda x: str(x))
|
|
||||||
return [
|
|
||||||
app_commands.Choice(name=date, value=date)
|
|
||||||
for date in self._client_utils.get_auto_complete_list(days, current)
|
|
||||||
]
|
|
||||||
|
|
||||||
@user.command()
|
@user.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@CommandChecks.check_is_ready()
|
@CommandChecks.check_is_ready()
|
||||||
@@ -295,8 +237,8 @@ class UserGroup(DiscordCommandABC):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@get.autocomplete("atr")
|
@get.autocomplete("atr")
|
||||||
async def get_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
|
async def get_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
|
||||||
return [app_commands.Choice(name=value, value=key) for key, value in self._atr_TList]
|
return [app_commands.Choice(name=value, value=key) for key, value in self._atr_list]
|
||||||
|
|
||||||
@user.command()
|
@user.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@@ -339,9 +281,9 @@ class UserGroup(DiscordCommandABC):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@set.autocomplete("atr")
|
@set.autocomplete("atr")
|
||||||
async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
|
async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
|
||||||
atr_TList = [("xp", self._atr_dict["xp"])]
|
atr_list = [("xp", self._atr_dict["xp"])]
|
||||||
return [app_commands.Choice(name=value, value=key) for key, value in atr_TList]
|
return [app_commands.Choice(name=value, value=key) for key, value in atr_list]
|
||||||
|
|
||||||
@user.command()
|
@user.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@@ -352,9 +294,9 @@ class UserGroup(DiscordCommandABC):
|
|||||||
await self._handle_atr_calc(ctx, atr, value, member)
|
await self._handle_atr_calc(ctx, atr, value, member)
|
||||||
|
|
||||||
@add.autocomplete("atr")
|
@add.autocomplete("atr")
|
||||||
async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
|
async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
|
||||||
atr_TList = [("xp", self._atr_dict["xp"])]
|
atr_list = [("xp", self._atr_dict["xp"])]
|
||||||
return [app_commands.Choice(name=value, value=key) for key, value in atr_TList]
|
return [app_commands.Choice(name=value, value=key) for key, value in atr_list]
|
||||||
|
|
||||||
@user.command()
|
@user.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@@ -365,9 +307,9 @@ class UserGroup(DiscordCommandABC):
|
|||||||
await self._handle_atr_calc(ctx, atr, value, member, is_remove=True)
|
await self._handle_atr_calc(ctx, atr, value, member, is_remove=True)
|
||||||
|
|
||||||
@remove.autocomplete("atr")
|
@remove.autocomplete("atr")
|
||||||
async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
|
async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
|
||||||
atr_TList = [("xp", self._atr_dict["xp"])]
|
atr_list = [("xp", self._atr_dict["xp"])]
|
||||||
return [app_commands.Choice(name=value, value=key) for key, value in atr_TList]
|
return [app_commands.Choice(name=value, value=key) for key, value in atr_list]
|
||||||
|
|
||||||
@user.command()
|
@user.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@@ -407,8 +349,8 @@ class UserGroup(DiscordCommandABC):
|
|||||||
@reset.autocomplete("atr")
|
@reset.autocomplete("atr")
|
||||||
async def reset_autocomplete(
|
async def reset_autocomplete(
|
||||||
self, interaction: discord.Interaction, current: str
|
self, interaction: discord.Interaction, current: str
|
||||||
) -> TList[app_commands.Choice[str]]:
|
) -> List[app_commands.Choice[str]]:
|
||||||
return [app_commands.Choice(name=value, value=key) for key, value in self._atr_TList]
|
return [app_commands.Choice(name=value, value=key) for key, value in self._atr_list]
|
||||||
|
|
||||||
@user.group()
|
@user.group()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@@ -458,7 +400,7 @@ class UserGroup(DiscordCommandABC):
|
|||||||
async def add(self, ctx: Context, member: discord.Member, description: str):
|
async def add(self, ctx: Context, member: discord.Member, description: str):
|
||||||
self._logger.debug(__name__, f"Received command user warning add {ctx}:{member},{description}")
|
self._logger.debug(__name__, f"Received command user warning add {ctx}:{member},{description}")
|
||||||
try:
|
try:
|
||||||
await self._user_warnings_service.add_warnings_async(member, description, ctx.author.id)
|
await self._user_warnings_service.add_warnings(member, description, ctx.author.id)
|
||||||
await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.add.success"))
|
await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.add.success"))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(__name__, f"Adding user warning failed", e)
|
self._logger.error(__name__, f"Adding user warning failed", e)
|
||||||
@@ -472,7 +414,7 @@ class UserGroup(DiscordCommandABC):
|
|||||||
async def remove(self, ctx: Context, warning_id: int):
|
async def remove(self, ctx: Context, warning_id: int):
|
||||||
self._logger.debug(__name__, f"Received command user warning remove {ctx}:{warning_id}")
|
self._logger.debug(__name__, f"Received command user warning remove {ctx}:{warning_id}")
|
||||||
try:
|
try:
|
||||||
await self._user_warnings_service.remove_warnings_async(warning_id)
|
await self._user_warnings_service.remove_warnings(warning_id)
|
||||||
await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.remove.success"))
|
await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.remove.success"))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(__name__, f"Removing user warning failed", e)
|
self._logger.error(__name__, f"Removing user warning failed", e)
|
||||||
|
@@ -108,15 +108,7 @@ class UserWarningsService:
|
|||||||
await self.notify_team(member, self._t.transform("modules.base.warnings.kick").format(member.mention))
|
await self.notify_team(member, self._t.transform("modules.base.warnings.kick").format(member.mention))
|
||||||
await member.kick()
|
await member.kick()
|
||||||
|
|
||||||
async def _notify_after_add(self, member: discord.Member, warning: UserWarnings):
|
async def add_warnings(self, member: discord.Member, description: str, author_id: int = None):
|
||||||
server = self._servers.get_server_by_discord_id(member.guild.id)
|
|
||||||
user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id)
|
|
||||||
|
|
||||||
await self.notify_user(member, self._t.transform("modules.base.warnings.warned").format(warning.description))
|
|
||||||
await self.notify_team(member, warning.description)
|
|
||||||
await self.check_for_warnings(member, user)
|
|
||||||
|
|
||||||
def _add_warnings(self, member: discord.Member, description: str, author_id: int = None):
|
|
||||||
server = self._servers.get_server_by_discord_id(member.guild.id)
|
server = self._servers.get_server_by_discord_id(member.guild.id)
|
||||||
user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id)
|
user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id)
|
||||||
|
|
||||||
@@ -127,32 +119,17 @@ class UserWarningsService:
|
|||||||
warning = UserWarnings(description, user, author)
|
warning = UserWarnings(description, user, author)
|
||||||
self._warnings.add_user_warnings(warning)
|
self._warnings.add_user_warnings(warning)
|
||||||
self._db.save_changes()
|
self._db.save_changes()
|
||||||
return warning
|
await self.notify_user(member, self._t.transform("modules.base.warnings.warned").format(warning.description))
|
||||||
|
await self.notify_team(member, warning.description)
|
||||||
|
await self.check_for_warnings(member, user)
|
||||||
|
|
||||||
def add_warnings(self, member: discord.Member, description: str, author_id: int = None):
|
async def remove_warnings(self, id: int):
|
||||||
warning = self._add_warnings(member, description, author_id)
|
|
||||||
self._bot.loop.create_task(self._notify_after_add(member, warning))
|
|
||||||
|
|
||||||
async def add_warnings_async(self, member: discord.Member, description: str, author_id: int = None):
|
|
||||||
warning = self._add_warnings(member, description, author_id)
|
|
||||||
await self._notify_after_add(member, warning)
|
|
||||||
|
|
||||||
async def _notify_after_remove(self, warning: UserWarnings):
|
|
||||||
guild = self._bot.get_guild(warning.user.server.discord_id)
|
|
||||||
member = guild.get_member(warning.user.discord_id)
|
|
||||||
await self.notify_user(member, self._t.transform("modules.base.warnings.removed").format(warning.description))
|
|
||||||
await self.notify_team(member, warning.description, removed=True)
|
|
||||||
|
|
||||||
def _remove_warnings(self, id: int):
|
|
||||||
warning = self._warnings.get_user_warnings_by_id(id)
|
warning = self._warnings.get_user_warnings_by_id(id)
|
||||||
self._warnings.delete_user_warnings(warning)
|
self._warnings.delete_user_warnings(warning)
|
||||||
self._db.save_changes()
|
self._db.save_changes()
|
||||||
return warning
|
|
||||||
|
|
||||||
def remove_warnings(self, id: int):
|
guild = self._bot.get_guild(warning.user.server.discord_id)
|
||||||
warning = self._remove_warnings(id)
|
member = guild.get_member(warning.user.discord_id)
|
||||||
self._bot.loop.create_task(self._notify_after_remove(warning))
|
|
||||||
|
|
||||||
async def remove_warnings_async(self, id: int):
|
await self.notify_user(member, self._t.transform("modules.base.warnings.removed").format(warning.description))
|
||||||
warning = self._remove_warnings(id)
|
await self.notify_team(member, warning.description, removed=True)
|
||||||
await self._notify_after_remove(warning)
|
|
||||||
|
19
kdb-web/package-lock.json
generated
19
kdb-web/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "kdb-web",
|
"name": "kdb-web",
|
||||||
"version": "1.2.0",
|
"version": "1.0.dev127_config_in_wi",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "kdb-web",
|
"name": "kdb-web",
|
||||||
"version": "1.2.0",
|
"version": "1.0.dev127_config_in_wi",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^15.1.4",
|
"@angular/animations": "^15.1.4",
|
||||||
"@angular/common": "^15.1.4",
|
"@angular/common": "^15.1.4",
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
"@ngx-translate/core": "^14.0.0",
|
"@ngx-translate/core": "^14.0.0",
|
||||||
"@ngx-translate/http-loader": "^7.0.0",
|
"@ngx-translate/http-loader": "^7.0.0",
|
||||||
"@types/socket.io-client": "^3.0.0",
|
"@types/socket.io-client": "^3.0.0",
|
||||||
"moment": "^2.29.4",
|
"primeflex": "^3.3.1",
|
||||||
"primeicons": "^6.0.1",
|
"primeicons": "^6.0.1",
|
||||||
"primeng": "^15.2.0",
|
"primeng": "^15.2.0",
|
||||||
"rxjs": "~7.5.0",
|
"rxjs": "~7.5.0",
|
||||||
@@ -8157,14 +8157,6 @@
|
|||||||
"mkdirp": "bin/cmd.js"
|
"mkdirp": "bin/cmd.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/moment": {
|
|
||||||
"version": "2.29.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
|
|
||||||
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
|
|
||||||
"engines": {
|
|
||||||
"node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ms": {
|
"node_modules/ms": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
@@ -9311,6 +9303,11 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/primeflex": {
|
||||||
|
"version": "3.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/primeflex/-/primeflex-3.3.1.tgz",
|
||||||
|
"integrity": "sha512-zaOq3YvcOYytbAmKv3zYc+0VNS9Wg5d37dfxZnveKBFPr7vEIwfV5ydrpiouTft8MVW6qNjfkaQphHSnvgQbpQ=="
|
||||||
|
},
|
||||||
"node_modules/primeicons": {
|
"node_modules/primeicons": {
|
||||||
"version": "6.0.1",
|
"version": "6.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/primeicons/-/primeicons-6.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/primeicons/-/primeicons-6.0.1.tgz",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kdb-web",
|
"name": "kdb-web",
|
||||||
"version": "1.2.0",
|
"version": "1.1.10",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"update-version": "ts-node update-version.ts",
|
"update-version": "ts-node update-version.ts",
|
||||||
@@ -30,7 +30,6 @@
|
|||||||
"@ngx-translate/core": "^14.0.0",
|
"@ngx-translate/core": "^14.0.0",
|
||||||
"@ngx-translate/http-loader": "^7.0.0",
|
"@ngx-translate/http-loader": "^7.0.0",
|
||||||
"@types/socket.io-client": "^3.0.0",
|
"@types/socket.io-client": "^3.0.0",
|
||||||
"moment": "^2.29.4",
|
|
||||||
"primeicons": "^6.0.1",
|
"primeicons": "^6.0.1",
|
||||||
"primeng": "^15.2.0",
|
"primeng": "^15.2.0",
|
||||||
"rxjs": "~7.5.0",
|
"rxjs": "~7.5.0",
|
||||||
|
@@ -1,22 +1,23 @@
|
|||||||
import { HttpClient, HttpClientModule } from "@angular/common/http";
|
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||||
import { APP_INITIALIZER, ErrorHandler, NgModule } from "@angular/core";
|
import { APP_INITIALIZER, ErrorHandler, NgModule } from '@angular/core';
|
||||||
import { BrowserModule } from "@angular/platform-browser";
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { JwtModule } from "@auth0/angular-jwt";
|
import { JwtModule } from '@auth0/angular-jwt';
|
||||||
import { TranslateLoader, TranslateModule } from "@ngx-translate/core";
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
|
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
||||||
import { ConfirmationService, MessageService } from "primeng/api";
|
import { ConfirmationService, MessageService } from 'primeng/api';
|
||||||
import { DialogService } from "primeng/dynamicdialog";
|
import { DialogService } from 'primeng/dynamicdialog';
|
||||||
import { AppRoutingModule } from "./app-routing.module";
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
import { AppComponent } from "./app.component";
|
import { AppComponent } from './app.component';
|
||||||
import { NotFoundComponent } from "./components/error/not-found/not-found.component";
|
import { NotFoundComponent } from './components/error/not-found/not-found.component';
|
||||||
import { FooterComponent } from "./components/footer/footer.component";
|
import { FooterComponent } from './components/footer/footer.component';
|
||||||
import { HeaderComponent } from "./components/header/header.component";
|
import { HeaderComponent } from './components/header/header.component';
|
||||||
import { SidebarComponent } from "./components/sidebar/sidebar.component";
|
import { SidebarComponent } from './components/sidebar/sidebar.component';
|
||||||
import { SpinnerComponent } from "./components/spinner/spinner.component";
|
import { SpinnerComponent } from './components/spinner/spinner.component';
|
||||||
import { SharedModule } from "./modules/shared/shared.module";
|
import { SharedModule } from './modules/shared/shared.module';
|
||||||
import { ErrorHandlerService } from "./services/error-handler/error-handler.service";
|
import { ErrorHandlerService } from './services/error-handler/error-handler.service';
|
||||||
import { SettingsService } from "./services/settings/settings.service";
|
import { SettingsService } from './services/settings/settings.service';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -62,7 +63,7 @@ import { SettingsService } from "./services/settings/settings.service";
|
|||||||
},
|
},
|
||||||
MessageService,
|
MessageService,
|
||||||
ConfirmationService,
|
ConfirmationService,
|
||||||
DialogService,
|
DialogService
|
||||||
],
|
],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
|
@@ -5,16 +5,14 @@ import { UserJoinedServer } from "./user_joined_server.model";
|
|||||||
import { UserJoinedVoiceChannel } from "./user_joined_voice_channel.model";
|
import { UserJoinedVoiceChannel } from "./user_joined_voice_channel.model";
|
||||||
import { UserJoinedGameServer } from "./user_joined_game_server.model";
|
import { UserJoinedGameServer } from "./user_joined_game_server.model";
|
||||||
import { Achievement } from "./achievement.model";
|
import { Achievement } from "./achievement.model";
|
||||||
import { UserWarning } from "./user_warning.model";
|
|
||||||
|
|
||||||
export interface User extends DataWithHistory {
|
export interface User extends DataWithHistory {
|
||||||
id?: number;
|
id?: number;
|
||||||
discordId?: number;
|
discordId?: number;
|
||||||
name?: string;
|
name?: string;
|
||||||
xp?: number;
|
xp?: number;
|
||||||
messageCount?: number;
|
message_count?: number;
|
||||||
reactionCount?: number;
|
reaction_count?: number;
|
||||||
birthday?: string;
|
|
||||||
ontime?: number;
|
ontime?: number;
|
||||||
level?: Level;
|
level?: Level;
|
||||||
server?: Server;
|
server?: Server;
|
||||||
@@ -31,9 +29,6 @@ export interface User extends DataWithHistory {
|
|||||||
|
|
||||||
achievementCount?: number;
|
achievementCount?: number;
|
||||||
achievements?: Achievement[];
|
achievements?: Achievement[];
|
||||||
|
|
||||||
userWarningCount?: number;
|
|
||||||
userWarnings?: UserWarning[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserFilter {
|
export interface UserFilter {
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
import { DataWithHistory } from "./data.model";
|
|
||||||
import { User, UserFilter } from "./user.model";
|
|
||||||
|
|
||||||
export interface UserWarning extends DataWithHistory {
|
|
||||||
id?: number;
|
|
||||||
user?: User;
|
|
||||||
description?: string;
|
|
||||||
author?: User;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UserWarningFilter {
|
|
||||||
id?: number;
|
|
||||||
user?: UserFilter;
|
|
||||||
description?: string;
|
|
||||||
author?: UserFilter;
|
|
||||||
}
|
|
@@ -1,22 +1,15 @@
|
|||||||
export class Mutations {
|
export class Mutations {
|
||||||
static updateUser = `
|
static updateUser = `
|
||||||
mutation updateUser($id: ID, $xp: Int $birthday: String, $levelId: ID, $userWarnings: [UserWarningInput]) {
|
mutation updateUser($id: ID, $xp: Int, $levelId: ID) {
|
||||||
user {
|
user {
|
||||||
updateUser(input: { id: $id, xp: $xp, birthday: $birthday, levelId: $levelId, userWarnings: $userWarnings }) {
|
updateUser(input: { id: $id, xp: $xp, levelId: $levelId }) {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
xp
|
xp
|
||||||
messageCount
|
|
||||||
reactionCount
|
|
||||||
birthday
|
|
||||||
level {
|
level {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
userWarnings {
|
|
||||||
id
|
|
||||||
description
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,50 +314,4 @@ export class Mutations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static createUserWarning = `
|
|
||||||
mutation createUserWarning($name: String, $description: String, $attribute: String, $operator: String, $value: String, $serverId: ID) {
|
|
||||||
userWarning {
|
|
||||||
createUserWarning(input: { name: $name, description: $description, attribute: $attribute, operator: $operator, value: $value, serverId: $serverId}) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
description
|
|
||||||
attribute
|
|
||||||
operator
|
|
||||||
value
|
|
||||||
server {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
static updateUserWarning = `
|
|
||||||
mutation updateUserWarning($id: ID, $name: String, $description: String, $attribute: String, $operator: String, $value: String) {
|
|
||||||
userWarning {
|
|
||||||
updateUserWarning(input: { id: $id, name: $name, description: $description, attribute: $attribute, operator: $operator, value: $value}) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
description
|
|
||||||
attribute
|
|
||||||
operator
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
static deleteUserWarning = `
|
|
||||||
mutation deleteUserWarning($id: ID) {
|
|
||||||
userWarning {
|
|
||||||
deleteUserWarning(id: $id) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
|
@@ -208,7 +208,7 @@ export class Queries {
|
|||||||
query {
|
query {
|
||||||
shortRoleNamePositions
|
shortRoleNamePositions
|
||||||
}
|
}
|
||||||
`;
|
`
|
||||||
|
|
||||||
static shortRoleNameQuery = `
|
static shortRoleNameQuery = `
|
||||||
query ShortRoleNameList($serverId: ID, $filter: ShortRoleNameFilter, $page: Page, $sort: Sort) {
|
query ShortRoleNameList($serverId: ID, $filter: ShortRoleNameFilter, $page: Page, $sort: Sort) {
|
||||||
@@ -279,101 +279,58 @@ export class Queries {
|
|||||||
|
|
||||||
static userProfile = `
|
static userProfile = `
|
||||||
query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) {
|
query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) {
|
||||||
userCount
|
servers(filter: {id: $serverId}) {
|
||||||
users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) {
|
userCount
|
||||||
id
|
users(filter: {id: $userId}, page: $page, sort: $sort) {
|
||||||
discordId
|
|
||||||
name
|
|
||||||
xp
|
|
||||||
messageCount
|
|
||||||
reactionCount
|
|
||||||
birthday
|
|
||||||
ontime
|
|
||||||
level {
|
|
||||||
id
|
id
|
||||||
|
discordId
|
||||||
name
|
name
|
||||||
}
|
xp
|
||||||
leftServer
|
ontime
|
||||||
server {
|
level {
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
|
|
||||||
joinedServerCount
|
|
||||||
joinedServers {
|
|
||||||
id
|
|
||||||
joinedOn
|
|
||||||
leavedOn
|
|
||||||
}
|
|
||||||
|
|
||||||
createdAt
|
|
||||||
modifiedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
static userProfileAchievements = `
|
|
||||||
query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) {
|
|
||||||
users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) {
|
|
||||||
achievementCount
|
|
||||||
achievements {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
description
|
|
||||||
createdAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
static userProfileVoiceChannelJoins = `
|
|
||||||
query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) {
|
|
||||||
users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) {
|
|
||||||
joinedVoiceChannelCount
|
|
||||||
joinedVoiceChannels {
|
|
||||||
id
|
|
||||||
channelId
|
|
||||||
channelName
|
|
||||||
time
|
|
||||||
joinedOn
|
|
||||||
leavedOn
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
static userProfileGameserverJoins = `
|
|
||||||
query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) {
|
|
||||||
users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) {
|
|
||||||
userJoinedGameServerCount
|
|
||||||
userJoinedGameServers {
|
|
||||||
id
|
|
||||||
gameServer
|
|
||||||
time
|
|
||||||
joinedOn
|
|
||||||
leavedOn
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
static userProfileWarnings = `
|
|
||||||
query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) {
|
|
||||||
users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) {
|
|
||||||
userWarningCount
|
|
||||||
userWarnings {
|
|
||||||
id
|
|
||||||
user {
|
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
description
|
leftServer
|
||||||
author {
|
server {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
joinedServerCount
|
||||||
|
joinedServers {
|
||||||
|
id
|
||||||
|
joinedOn
|
||||||
|
leavedOn
|
||||||
|
}
|
||||||
|
|
||||||
|
joinedVoiceChannelCount
|
||||||
|
joinedVoiceChannels {
|
||||||
|
id
|
||||||
|
channelId
|
||||||
|
channelName
|
||||||
|
time
|
||||||
|
joinedOn
|
||||||
|
leavedOn
|
||||||
|
}
|
||||||
|
|
||||||
|
userJoinedGameServerCount
|
||||||
|
userJoinedGameServers {
|
||||||
|
id
|
||||||
|
gameServer
|
||||||
|
time
|
||||||
|
joinedOn
|
||||||
|
leavedOn
|
||||||
|
}
|
||||||
|
|
||||||
|
achievements {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
|
||||||
createdAt
|
createdAt
|
||||||
|
modifiedAt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,6 @@ import { TechnicianConfig } from "../config/technician-config.model";
|
|||||||
import { ServerConfig } from "../config/server-config.model";
|
import { ServerConfig } from "../config/server-config.model";
|
||||||
import { ShortRoleName } from "../data/short_role_name.model";
|
import { ShortRoleName } from "../data/short_role_name.model";
|
||||||
import { FeatureFlag } from "../config/feature-flags.model";
|
import { FeatureFlag } from "../config/feature-flags.model";
|
||||||
import { UserWarning } from "../data/user_warning.model";
|
|
||||||
|
|
||||||
export interface Query {
|
export interface Query {
|
||||||
serverCount: number;
|
serverCount: number;
|
||||||
@@ -32,11 +31,6 @@ export interface UserListQuery {
|
|||||||
users: User[];
|
users: User[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserWarningQuery {
|
|
||||||
userWarningCount: number;
|
|
||||||
userWarnings: UserWarning[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GameServerListQuery {
|
export interface GameServerListQuery {
|
||||||
gameServerCount: number;
|
gameServerCount: number;
|
||||||
gameServers: GameServer[];
|
gameServers: GameServer[];
|
||||||
|
@@ -6,7 +6,6 @@ import { Achievement } from "../data/achievement.model";
|
|||||||
import { TechnicianConfig } from "../config/technician-config.model";
|
import { TechnicianConfig } from "../config/technician-config.model";
|
||||||
import { ServerConfig } from "../config/server-config.model";
|
import { ServerConfig } from "../config/server-config.model";
|
||||||
import { ShortRoleName } from "../data/short_role_name.model";
|
import { ShortRoleName } from "../data/short_role_name.model";
|
||||||
import { UserWarning } from "../data/user_warning.model";
|
|
||||||
|
|
||||||
export interface GraphQLResult {
|
export interface GraphQLResult {
|
||||||
data: {
|
data: {
|
||||||
@@ -78,11 +77,3 @@ export interface ShortRoleNameMutationResult {
|
|||||||
deleteShortRoleName?: ShortRoleName
|
deleteShortRoleName?: ShortRoleName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserWarningMutationResult {
|
|
||||||
userWarning: {
|
|
||||||
createUserWarning?: UserWarning
|
|
||||||
updateUserWarning?: UserWarning
|
|
||||||
deleteUserWarning?: UserWarning
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
@@ -32,37 +32,8 @@ import { HideableHeaderComponent } from './components/hideable-header/hideable-h
|
|||||||
import { MultiSelectColumnsComponent } from './base/multi-select-columns/multi-select-columns.component';
|
import { MultiSelectColumnsComponent } from './base/multi-select-columns/multi-select-columns.component';
|
||||||
import { FeatureFlagListComponent } from './components/feature-flag-list/feature-flag-list.component';
|
import { FeatureFlagListComponent } from './components/feature-flag-list/feature-flag-list.component';
|
||||||
import { InputSwitchModule } from "primeng/inputswitch";
|
import { InputSwitchModule } from "primeng/inputswitch";
|
||||||
import { CalendarModule } from "primeng/calendar";
|
|
||||||
|
|
||||||
|
|
||||||
const PrimeNGModules = [
|
|
||||||
ButtonModule,
|
|
||||||
PasswordModule,
|
|
||||||
MenuModule,
|
|
||||||
DialogModule,
|
|
||||||
ProgressSpinnerModule,
|
|
||||||
HttpClientModule,
|
|
||||||
FormsModule,
|
|
||||||
ReactiveFormsModule,
|
|
||||||
ToastModule,
|
|
||||||
ConfirmDialogModule,
|
|
||||||
TableModule,
|
|
||||||
InputTextModule,
|
|
||||||
CheckboxModule,
|
|
||||||
DropdownModule,
|
|
||||||
TranslateModule,
|
|
||||||
DynamicDialogModule,
|
|
||||||
PanelMenuModule,
|
|
||||||
PanelModule,
|
|
||||||
InputNumberModule,
|
|
||||||
ImageModule,
|
|
||||||
SidebarModule,
|
|
||||||
DataViewModule,
|
|
||||||
MultiSelectModule,
|
|
||||||
InputSwitchModule,
|
|
||||||
CalendarModule,
|
|
||||||
]
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
AuthRolePipe,
|
AuthRolePipe,
|
||||||
@@ -77,20 +48,66 @@ const PrimeNGModules = [
|
|||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
...PrimeNGModules
|
ButtonModule,
|
||||||
|
PasswordModule,
|
||||||
|
MenuModule,
|
||||||
|
DialogModule,
|
||||||
|
ProgressSpinnerModule,
|
||||||
|
HttpClientModule,
|
||||||
|
FormsModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
ToastModule,
|
||||||
|
ConfirmDialogModule,
|
||||||
|
TableModule,
|
||||||
|
InputTextModule,
|
||||||
|
CheckboxModule,
|
||||||
|
DropdownModule,
|
||||||
|
TranslateModule,
|
||||||
|
DynamicDialogModule,
|
||||||
|
PanelMenuModule,
|
||||||
|
PanelModule,
|
||||||
|
InputNumberModule,
|
||||||
|
ImageModule,
|
||||||
|
SidebarModule,
|
||||||
|
DataViewModule,
|
||||||
|
MultiSelectModule,
|
||||||
|
InputSwitchModule,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
...PrimeNGModules,
|
ButtonModule,
|
||||||
|
PasswordModule,
|
||||||
|
MenuModule,
|
||||||
|
DialogModule,
|
||||||
|
ProgressSpinnerModule,
|
||||||
|
HttpClientModule,
|
||||||
|
FormsModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
ToastModule,
|
||||||
|
ConfirmDialogModule,
|
||||||
|
TableModule,
|
||||||
|
InputTextModule,
|
||||||
|
CheckboxModule,
|
||||||
|
DropdownModule,
|
||||||
|
TranslateModule,
|
||||||
|
DynamicDialogModule,
|
||||||
|
PanelMenuModule,
|
||||||
|
PanelModule,
|
||||||
AuthRolePipe,
|
AuthRolePipe,
|
||||||
IpAddressPipe,
|
IpAddressPipe,
|
||||||
BoolPipe,
|
BoolPipe,
|
||||||
|
InputNumberModule,
|
||||||
|
ImageModule,
|
||||||
|
SidebarModule,
|
||||||
HistoryBtnComponent,
|
HistoryBtnComponent,
|
||||||
|
DataViewModule,
|
||||||
DataViewLayoutOptions,
|
DataViewLayoutOptions,
|
||||||
ConfigListComponent,
|
ConfigListComponent,
|
||||||
|
MultiSelectModule,
|
||||||
HideableColumnComponent,
|
HideableColumnComponent,
|
||||||
HideableHeaderComponent,
|
HideableHeaderComponent,
|
||||||
MultiSelectColumnsComponent,
|
MultiSelectColumnsComponent,
|
||||||
FeatureFlagListComponent,
|
FeatureFlagListComponent,
|
||||||
|
InputSwitchModule,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class SharedModule {
|
export class SharedModule {
|
||||||
|
@@ -204,7 +204,7 @@
|
|||||||
<span class="p-column-title">{{'common.level' | translate}}:</span>
|
<span class="p-column-title">{{'common.level' | translate}}:</span>
|
||||||
<p-cellEditor>
|
<p-cellEditor>
|
||||||
<ng-template pTemplate="input">
|
<ng-template pTemplate="input">
|
||||||
<p-dropdown [options]="levels" [(ngModel)]="member.level" dataKey="id" placeholder="{{'common.level' | translate}}"></p-dropdown>
|
<p-dropdown [options]="levels" [(ngModel)]="member.level" placeholder="{{'common.level' | translate}}"></p-dropdown>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template pTemplate="output">
|
<ng-template pTemplate="output">
|
||||||
{{member.level.name}}
|
{{member.level.name}}
|
||||||
|
@@ -30,32 +30,7 @@
|
|||||||
<div class="content-row">
|
<div class="content-row">
|
||||||
<div class="content-column">
|
<div class="content-column">
|
||||||
<div class="content-data-name">{{'view.server.profile.xp' | translate}}:</div>
|
<div class="content-data-name">{{'view.server.profile.xp' | translate}}:</div>
|
||||||
<div *ngIf="!isEditing" class="content-data-value">{{user.xp}}</div>
|
<div class="content-data-value">{{user.xp}}</div>
|
||||||
<div *ngIf="isModerator && isEditing" class="content-data-value"><input class="table-edit-input" pInputText min="0" type="number" [(ngModel)]="user.xp"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content-row">
|
|
||||||
<div class="content-column">
|
|
||||||
<div class="content-data-name">{{'view.server.profile.message_count' | translate}}:</div>
|
|
||||||
<div class="content-data-value">{{user.messageCount}}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content-row">
|
|
||||||
<div class="content-column">
|
|
||||||
<div class="content-data-name">{{'view.server.profile.reaction_count' | translate}}:</div>
|
|
||||||
<div class="content-data-value">{{user.reactionCount}}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content-row">
|
|
||||||
<div class="content-column">
|
|
||||||
<div class="content-data-name">{{'view.server.profile.birthday' | translate}}:</div>
|
|
||||||
<div *ngIf="!isEditing" class="content-data-value">{{user.birthday}}</div>
|
|
||||||
<div *ngIf="isEditing" class="content-data-value">
|
|
||||||
<p-calendar [(ngModel)]="user.birthday" dateFormat="dd.mm.yy" [showIcon]="true"></p-calendar>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -66,14 +41,17 @@
|
|||||||
</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>
|
||||||
<div *ngIf="!isEditing" class="content-data-value">{{user.level?.name}}</div>
|
<div class="content-data-value">{{user.level?.name}}</div>
|
||||||
<div *ngIf="isModerator && isEditing" class="content-data-value">
|
|
||||||
<p-dropdown [options]="levels" [(ngModel)]="user.level" dataKey="id" placeholder="{{'common.level' | translate}}">
|
|
||||||
</p-dropdown>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -98,103 +76,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
|
||||||
<div class="content-divider"></div>
|
|
||||||
<p-table #dt [value]="(user.userWarnings ?? [])" [responsive]="true" responsiveLayout="stack" [breakpoint]="'720px'" dataKey="id" editMode="row">
|
|
||||||
<ng-template pTemplate="caption">
|
|
||||||
<div class="table-caption">
|
|
||||||
<div class="table-caption-table-info">
|
|
||||||
<div class="table-caption-text">
|
|
||||||
<h3>{{'common.user_warnings' | translate}}</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="table-caption-btn-wrapper btn-wrapper">
|
|
||||||
<button pButton label="{{'common.add' | translate}}" class="icon-btn btn"
|
|
||||||
icon="pi pi-plus" (click)="addNewUserWarning(dt)">
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ng-template>
|
|
||||||
<ng-template pTemplate="header">
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
<div class="table-header-label">
|
|
||||||
<div class="table-header-text">{{'common.description' | translate}}</div>
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
|
|
||||||
<th>
|
|
||||||
<div class="table-header-label">
|
|
||||||
<div class="table-header-text">{{'common.author' | translate}}</div>
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
|
|
||||||
<th>
|
|
||||||
<div class="table-header-label">
|
|
||||||
<div class="table-header-text">{{'common.created_at' | translate}}</div>
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
|
|
||||||
<th class="table-header-actions">
|
|
||||||
<div class="table-header-label">
|
|
||||||
<div class="table-header-text">{{'common.actions' | translate}}</div>
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</ng-template>
|
|
||||||
<ng-template pTemplate="body" let-value let-editing="editing" let-ri="rowIndex">
|
|
||||||
<tr [pEditableRow]="value">
|
|
||||||
<td>
|
|
||||||
<p-cellEditor>
|
|
||||||
<ng-template pTemplate="input">
|
|
||||||
<input class="table-edit-input" pInputText type="text" [(ngModel)]="value.description">
|
|
||||||
</ng-template>
|
|
||||||
<ng-template pTemplate="output">
|
|
||||||
{{value.description}}
|
|
||||||
</ng-template>
|
|
||||||
</p-cellEditor>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p-cellEditor>
|
|
||||||
<ng-template pTemplate="input">
|
|
||||||
{{value.author?.name}}
|
|
||||||
</ng-template>
|
|
||||||
<ng-template pTemplate="output">
|
|
||||||
{{value.author?.name}}
|
|
||||||
</ng-template>
|
|
||||||
</p-cellEditor>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
|
||||||
<span class="p-column-title">{{'common.created_at' | translate}}:</span>
|
|
||||||
<p-cellEditor>
|
|
||||||
<ng-template pTemplate="input">
|
|
||||||
{{value.createdAt | date:'dd.MM.yy HH:mm'}}
|
|
||||||
</ng-template>
|
|
||||||
<ng-template pTemplate="output">
|
|
||||||
{{value.createdAt | date:'dd.MM.yy HH:mm'}}
|
|
||||||
</ng-template>
|
|
||||||
</p-cellEditor>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div class="btn-wrapper">
|
|
||||||
<button *ngIf="!editing" pButton type="button" class="btn danger-icon-btn" icon="pi pi-trash" (click)="deleteUserWarning(ri)"></button>
|
|
||||||
|
|
||||||
<button *ngIf="editing" pButton type="button" pSaveEditableRow class="btn icon-btn" icon="pi pi-check" (click)="editSaveUserWarning(value, ri)"></button>
|
|
||||||
<button *ngIf="editing" pButton type="button" pCancelEditableRow class="btn danger-icon-btn" icon="pi pi-times"
|
|
||||||
(click)="editCancelUserWarning(ri)"></button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</ng-template>
|
|
||||||
</p-table>
|
|
||||||
<br>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content-divider"></div>
|
<div class="content-divider"></div>
|
||||||
|
|
||||||
<p-panel header="{{'view.server.profile.achievements.header' | translate}}" [toggleable]="true" [collapsed]="true"
|
<p-panel header="{{'view.server.profile.achievements.header' | translate}}" [toggleable]="true">
|
||||||
(onBeforeToggle)="onBeforeToggle($event.event, $event.collapsed)">
|
|
||||||
<div *ngFor="let achievement of user.achievements;">
|
<div *ngFor="let achievement of user.achievements;">
|
||||||
<div class="content-row">
|
<div class="content-row">
|
||||||
<div class="content-column">
|
<div class="content-column">
|
||||||
@@ -202,11 +86,6 @@
|
|||||||
<div class="content-data-value">{{achievement.name}}</div>
|
<div class="content-data-value">{{achievement.name}}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content-column">
|
|
||||||
<div class="content-data-name">{{'common.description' | translate}}:</div>
|
|
||||||
<div class="content-data-value">{{achievement.description}}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content-column">
|
<div class="content-column">
|
||||||
<div class="content-data-name">{{'view.server.profile.achievements.time' | translate}}:</div>
|
<div class="content-data-name">{{'view.server.profile.achievements.time' | translate}}:</div>
|
||||||
<div class="content-data-value">{{achievement.createdAt | date:'dd.MM.yyyy HH:mm:ss'}}</div>
|
<div class="content-data-value">{{achievement.createdAt | date:'dd.MM.yyyy HH:mm:ss'}}</div>
|
||||||
@@ -215,8 +94,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</p-panel>
|
</p-panel>
|
||||||
|
|
||||||
<p-panel header="{{'view.server.profile.joined_voice_channel.header' | translate}}" [toggleable]="true" [collapsed]="true"
|
<p-panel header="{{'view.server.profile.joined_voice_channel.header' | translate}}" [toggleable]="true">
|
||||||
(onBeforeToggle)="onBeforeToggle($event.event, $event.collapsed)">
|
|
||||||
<div *ngFor="let join of user.joinedVoiceChannels;">
|
<div *ngFor="let join of user.joinedVoiceChannels;">
|
||||||
<div class="content-row">
|
<div class="content-row">
|
||||||
<div class="content-column">
|
<div class="content-column">
|
||||||
@@ -242,8 +120,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</p-panel>
|
</p-panel>
|
||||||
|
|
||||||
<p-panel header="{{'view.server.profile.joined_game_server.header' | translate}}" [toggleable]="true" [collapsed]="true"
|
<p-panel header="{{'view.server.profile.joined_game_server.header' | translate}}" [toggleable]="true">
|
||||||
(onBeforeToggle)="onBeforeToggle($event.event, $event.collapsed)">
|
|
||||||
<div *ngFor="let join of user.userJoinedGameServers;">
|
<div *ngFor="let join of user.userJoinedGameServers;">
|
||||||
<div class="content-row">
|
<div class="content-row">
|
||||||
<div class="content-column">
|
<div class="content-column">
|
||||||
@@ -284,16 +161,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</p-panel>
|
</p-panel>
|
||||||
|
|
||||||
<div class="content-divider"></div>
|
|
||||||
|
|
||||||
<div class="content-row">
|
|
||||||
<div style="width: 100%; display: flex; gap: 10px; justify-content: end;">
|
|
||||||
<button pButton icon="pi pi-edit" label="{{'common.edit' | translate}}" class="btn login-form-submit-btn"
|
|
||||||
(click)="toogleEditUser()"></button>
|
|
||||||
<button pButton icon="pi pi-save" label="{{'common.save' | translate}}" class="btn login-form-submit-btn"
|
|
||||||
(click)="updateUser()" [disabled]="!isEditing"></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
import { Component, OnDestroy, 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 { LevelListQuery, Query, UserListQuery, UserWarningQuery } from "../../../../models/graphql/query.model";
|
import { UserListQuery } from "../../../../models/graphql/query.model";
|
||||||
import { SpinnerService } from "../../../../services/spinner/spinner.service";
|
import { SpinnerService } from "../../../../services/spinner/spinner.service";
|
||||||
import { DataService } from "../../../../services/data/data.service";
|
import { DataService } from "../../../../services/data/data.service";
|
||||||
import { User } from "../../../../models/data/user.model";
|
import { User } from "../../../../models/data/user.model";
|
||||||
@@ -10,14 +10,8 @@ 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 { forkJoin, Subject, throwError } from "rxjs";
|
import { Subject } from "rxjs";
|
||||||
import { catchError, takeUntil } from "rxjs/operators";
|
import { takeUntil } from "rxjs/operators";
|
||||||
import { Table } from "primeng/table";
|
|
||||||
import { UpdateUserMutationResult } from "../../../../models/graphql/result.model";
|
|
||||||
import { Mutations } from "../../../../models/graphql/mutations.model";
|
|
||||||
import { MenuItem } from "primeng/api";
|
|
||||||
import { UserWarning } from "../../../../models/data/user_warning.model";
|
|
||||||
import moment from "moment";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-profile",
|
selector: "app-profile",
|
||||||
@@ -27,13 +21,7 @@ import moment from "moment";
|
|||||||
export class ProfileComponent implements OnInit, OnDestroy {
|
export class ProfileComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
user: User = { createdAt: "", modifiedAt: "" };
|
user: User = { createdAt: "", modifiedAt: "" };
|
||||||
levels!: MenuItem[];
|
|
||||||
private server: Server = {};
|
private server: Server = {};
|
||||||
private author?: UserDTO;
|
|
||||||
private clonedUserWarnings: UserWarning[] = [];
|
|
||||||
public isEditingNewUserWarning: boolean = false;
|
|
||||||
public isEditing: boolean = false;
|
|
||||||
public isModerator: boolean = false;
|
|
||||||
|
|
||||||
private unsubscriber = new Subject<void>();
|
private unsubscriber = new Subject<void>();
|
||||||
|
|
||||||
@@ -44,17 +32,11 @@ export class ProfileComponent implements OnInit, OnDestroy {
|
|||||||
private data: DataService,
|
private data: DataService,
|
||||||
private auth: AuthService,
|
private auth: AuthService,
|
||||||
private toast: ToastService,
|
private toast: ToastService,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService
|
||||||
private toastService: ToastService
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit(): void {
|
public ngOnInit(): void {
|
||||||
this.isEditing = false;
|
|
||||||
this.loadProfile();
|
|
||||||
}
|
|
||||||
|
|
||||||
private loadProfile() {
|
|
||||||
this.route.params.pipe(takeUntil(this.unsubscriber)).subscribe(params => {
|
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 (!params["memberId"] || params["memberId"] == "undefined") {
|
||||||
@@ -63,18 +45,6 @@ export class ProfileComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
|
||||||
this.data.query<LevelListQuery>(Queries.levelQuery, {
|
|
||||||
serverId: server.id
|
|
||||||
},
|
|
||||||
(data: Query) => {
|
|
||||||
return data.servers[0];
|
|
||||||
}
|
|
||||||
).subscribe(data => {
|
|
||||||
this.levels = data.levels.map(level => {
|
|
||||||
return { label: level.name, value: level };
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
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;
|
||||||
@@ -84,161 +54,27 @@ export class ProfileComponent implements OnInit, OnDestroy {
|
|||||||
await this.router.navigate(["/server", server.id]);
|
await this.router.navigate(["/server", server.id]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.author = user;
|
|
||||||
this.isModerator = user?.isModerator;
|
|
||||||
|
|
||||||
this.data.query<UserListQuery>(Queries.userProfile, {
|
this.data.query<UserListQuery>(Queries.userProfile, {
|
||||||
serverId: this.server.id,
|
serverId: this.server.id,
|
||||||
userId: params["memberId"]
|
userId: params["memberId"]
|
||||||
|
},
|
||||||
|
(x: { servers: Server[] }) => {
|
||||||
|
return x.servers[0];
|
||||||
}
|
}
|
||||||
).subscribe(users => {
|
).subscribe(users => {
|
||||||
if (!users.users[0]) {
|
if (!users.users[0]) {
|
||||||
this.router.navigate([`/server/${server.id}`]);
|
this.router.navigate([`/server/${server.id}`]);
|
||||||
}
|
}
|
||||||
this.user = users.users[0];
|
this.user = users.users[0];
|
||||||
|
this.spinner.hideSpinner();
|
||||||
this.data.query<UserWarningQuery>(Queries.userProfileWarnings, {
|
|
||||||
serverId: this.server.id,
|
|
||||||
userId: this.user.id
|
|
||||||
},
|
|
||||||
(data: UserListQuery) => {
|
|
||||||
return data.users[0];
|
|
||||||
}
|
|
||||||
).subscribe(result => {
|
|
||||||
this.user.userWarningCount = result.userWarningCount;
|
|
||||||
this.user.userWarnings = result.userWarnings;
|
|
||||||
|
|
||||||
this.spinner.hideSpinner();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public toogleEditUser() {
|
|
||||||
this.isEditing = !this.isEditing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public updateUser() {
|
|
||||||
this.spinner.showSpinner();
|
|
||||||
this.data.mutation<UpdateUserMutationResult>(Mutations.updateUser, {
|
|
||||||
id: this.user.id,
|
|
||||||
xp: this.user.xp,
|
|
||||||
birthday: moment(this.user.birthday).format("DD.MM.YYYY"),
|
|
||||||
levelId: this.user.level?.id,
|
|
||||||
userWarnings: this.user.userWarnings?.map(userWarning => {
|
|
||||||
return {
|
|
||||||
id: userWarning.id,
|
|
||||||
user: userWarning.user?.id ?? this.user.id,
|
|
||||||
description: userWarning.description,
|
|
||||||
author: userWarning.author?.id ?? this.author?.id
|
|
||||||
};
|
|
||||||
})
|
|
||||||
}
|
|
||||||
).pipe(catchError(err => {
|
|
||||||
this.spinner.hideSpinner();
|
|
||||||
this.isEditing = false;
|
|
||||||
return throwError(err);
|
|
||||||
})).subscribe(_ => {
|
|
||||||
this.spinner.hideSpinner();
|
|
||||||
this.toastService.success(this.translate.instant("view.server.members.message.user_changed"), this.translate.instant("view.server.members.message.user_changed_d", { name: this.user.name }));
|
|
||||||
this.isEditing = false;
|
|
||||||
this.loadProfile();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public ngOnDestroy(): void {
|
public ngOnDestroy(): void {
|
||||||
this.unsubscriber.next();
|
this.unsubscriber.next();
|
||||||
this.unsubscriber.complete();
|
this.unsubscriber.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public onBeforeToggle(event: Event, collapsed: boolean) {
|
|
||||||
const filterUser = (x: { users: User[] }) => {
|
|
||||||
const users = x.users ?? [];
|
|
||||||
return users[0];
|
|
||||||
};
|
|
||||||
|
|
||||||
if (collapsed) {
|
|
||||||
this.spinner.showSpinner();
|
|
||||||
forkJoin([
|
|
||||||
this.data.query<User>(Queries.userProfileAchievements, {
|
|
||||||
serverId: this.server.id,
|
|
||||||
userId: this.user.id
|
|
||||||
},
|
|
||||||
filterUser
|
|
||||||
),
|
|
||||||
this.data.query<User>(Queries.userProfileVoiceChannelJoins, {
|
|
||||||
serverId: this.server.id,
|
|
||||||
userId: this.user.id
|
|
||||||
},
|
|
||||||
filterUser
|
|
||||||
),
|
|
||||||
this.data.query<User>(Queries.userProfileGameserverJoins, {
|
|
||||||
serverId: this.server.id,
|
|
||||||
userId: this.user.id
|
|
||||||
},
|
|
||||||
filterUser
|
|
||||||
)
|
|
||||||
]).subscribe(data => {
|
|
||||||
this.user.achievementCount = data[0].achievementCount;
|
|
||||||
this.user.achievements = data[0].achievements;
|
|
||||||
|
|
||||||
this.user.joinedVoiceChannelCount = data[1].joinedVoiceChannelCount;
|
|
||||||
this.user.joinedVoiceChannels = data[1].joinedVoiceChannels;
|
|
||||||
|
|
||||||
this.user.userJoinedGameServerCount = data[2].userJoinedGameServerCount;
|
|
||||||
this.user.userJoinedGameServers = data[2].userJoinedGameServers;
|
|
||||||
this.spinner.hideSpinner();
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.user.achievementCount = 0;
|
|
||||||
this.user.achievements = [];
|
|
||||||
|
|
||||||
this.user.userJoinedGameServerCount = 0;
|
|
||||||
this.user.userJoinedGameServers = [];
|
|
||||||
|
|
||||||
this.user.joinedVoiceChannelCount = 0;
|
|
||||||
this.user.joinedVoiceChannels = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public addNewUserWarning(table: Table) {
|
|
||||||
const newWarning: UserWarning = {
|
|
||||||
description: "",
|
|
||||||
user: this.user
|
|
||||||
};
|
|
||||||
|
|
||||||
this.user.userWarnings = [newWarning, ...this.user.userWarnings ?? []];
|
|
||||||
|
|
||||||
table.initRowEdit(newWarning);
|
|
||||||
|
|
||||||
const index = this.user.userWarnings.findIndex(l => l.id == newWarning.id);
|
|
||||||
this.onRowEditInit(table, newWarning, index);
|
|
||||||
|
|
||||||
this.isEditingNewUserWarning = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public onRowEditInit(table: Table, user: User, index: number): void {
|
|
||||||
this.clonedUserWarnings[index] = { ...user };
|
|
||||||
}
|
|
||||||
|
|
||||||
public deleteUserWarning(index: number) {
|
|
||||||
this.user.userWarnings?.splice(index, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public editSaveUserWarning(value: any, index: number) {
|
|
||||||
this.isEditingNewUserWarning = false;
|
|
||||||
if (!value.value || !this.user.userWarnings || this.user.userWarnings[index] == this.clonedUserWarnings[index]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete this.clonedUserWarnings[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
public editCancelUserWarning(index: number) {
|
|
||||||
if (this.user.userWarnings) {
|
|
||||||
this.user.userWarnings[index] = this.clonedUserWarnings[index];
|
|
||||||
}
|
|
||||||
delete this.clonedUserWarnings[index];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { NgModule } from "@angular/core";
|
import { NgModule } from '@angular/core';
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from '@angular/common';
|
||||||
import { ServerDashboardComponent } from "./server-dashboard/server-dashboard.component";
|
import { ServerDashboardComponent } from './server-dashboard/server-dashboard.component';
|
||||||
import { ServerRoutingModule } from "./server-routing.module";
|
import { ServerRoutingModule } from './server-routing.module';
|
||||||
import { SharedModule } from "../../shared/shared.module";
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
import { ProfileComponent } from "./profile/profile.component";
|
import { ProfileComponent } from './profile/profile.component';
|
||||||
import { MembersComponent } from "./members/members.component";
|
import { MembersComponent } from './members/members.component';
|
||||||
import { ClientComponent } from "./server-dashboard/components/client/client.component";
|
import { ClientComponent } from './server-dashboard/components/client/client.component';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@@ -194,6 +194,7 @@ export class SidebarService {
|
|||||||
let user: UserDTO | null = authUser?.users?.find(u => u.server == this.server?.id) ?? null;
|
let user: UserDTO | null = authUser?.users?.find(u => u.server == this.server?.id) ?? null;
|
||||||
let isTechnician = (authUser?.users?.map(u => u.isTechnician).filter(u => u) ?? []).length > 0;
|
let isTechnician = (authUser?.users?.map(u => u.isTechnician).filter(u => u) ?? []).length > 0;
|
||||||
let isTechnicianAndFullAccessActive = this.hasFeature("TechnicianFullAccess") && isTechnician;
|
let isTechnicianAndFullAccessActive = this.hasFeature("TechnicianFullAccess") && isTechnician;
|
||||||
|
console.log(this.hasFeature("TechnicianFullAccess"))
|
||||||
|
|
||||||
if (build || this.menuItems$.value.length == 0) {
|
if (build || this.menuItems$.value.length == 0) {
|
||||||
await this.buildMenu(user, hasPermission, isTechnician);
|
await this.buildMenu(user, hasPermission, isTechnician);
|
||||||
|
@@ -122,9 +122,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
"edit": "Bearbeiten",
|
|
||||||
"user_warnings": "Verwarnungen",
|
|
||||||
"author": "Autor",
|
|
||||||
"404": "404 - Der Eintrag konnte nicht gefunden werden",
|
"404": "404 - Der Eintrag konnte nicht gefunden werden",
|
||||||
"actions": "Aktionen",
|
"actions": "Aktionen",
|
||||||
"active": "Aktiv",
|
"active": "Aktiv",
|
||||||
@@ -485,9 +482,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"message_count": "Anzahl Nachrichten",
|
|
||||||
"reaction_count": "Anzahl Reaktionen",
|
|
||||||
"birthday": "Geburtstag",
|
|
||||||
"achievements": {
|
"achievements": {
|
||||||
"header": "Errungeschaften",
|
"header": "Errungeschaften",
|
||||||
"time": "Erreicht am"
|
"time": "Erreicht am"
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"WebVersion": {
|
"WebVersion": {
|
||||||
"Major": "1",
|
"Major": "1",
|
||||||
"Minor": "2",
|
"Minor": "1",
|
||||||
"Micro": "0"
|
"Micro": "10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -201,10 +201,10 @@ header {
|
|||||||
|
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.content-divider {
|
.content-divider {
|
||||||
margin: 10px 0;
|
margin: 5px 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p-panel {
|
p-panel {
|
||||||
@@ -493,7 +493,7 @@ header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.content-divider {
|
.content-divider {
|
||||||
margin: 10px 0;
|
margin: 5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-input-field {
|
.content-input-field {
|
||||||
|
@@ -94,13 +94,8 @@ p-table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-row {
|
.p-dropdown {
|
||||||
p-dropdown,
|
width: 100% !important;
|
||||||
.p-dropdown,
|
|
||||||
p-calendar,
|
|
||||||
.p-calendar, {
|
|
||||||
width: 100% !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.pi-sort-alt:before {
|
.pi-sort-alt:before {
|
||||||
|
@@ -20,8 +20,7 @@
|
|||||||
background-color: $primaryBackgroundColor;
|
background-color: $primaryBackgroundColor;
|
||||||
|
|
||||||
h1,
|
h1,
|
||||||
h2,
|
h2 {
|
||||||
h3 {
|
|
||||||
color: $primaryHeaderColor;
|
color: $primaryHeaderColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,8 +20,7 @@
|
|||||||
background-color: $primaryBackgroundColor;
|
background-color: $primaryBackgroundColor;
|
||||||
|
|
||||||
h1,
|
h1,
|
||||||
h2,
|
h2 {
|
||||||
h3 {
|
|
||||||
color: $primaryHeaderColor;
|
color: $primaryHeaderColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,8 +21,7 @@
|
|||||||
|
|
||||||
|
|
||||||
h1,
|
h1,
|
||||||
h2,
|
h2 {
|
||||||
h3 {
|
|
||||||
color: $primaryHeaderColor;
|
color: $primaryHeaderColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,77 +682,4 @@
|
|||||||
p-inputNumber {
|
p-inputNumber {
|
||||||
background-color: $primaryBackgroundColor !important;
|
background-color: $primaryBackgroundColor !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
p-calendar > span > button {
|
|
||||||
background-color: $primaryHeaderColor !important;
|
|
||||||
border: 1px solid $primaryHeaderColor !important;
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
box-shadow: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-calendar {
|
|
||||||
.p-datepicker:not(.p-datepicker-inline) {
|
|
||||||
background-color: $secondaryBackgroundColor !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-datepicker {
|
|
||||||
.p-datepicker-header {
|
|
||||||
color: $primaryHeaderColor !important;
|
|
||||||
background-color: $primaryBackgroundColor !important;
|
|
||||||
|
|
||||||
.p-datepicker-title .p-datepicker-year,
|
|
||||||
.p-datepicker-title .p-datepicker-month,
|
|
||||||
.p-datepicker .p-datepicker-header .p-datepicker-title .p-datepicker-month {
|
|
||||||
color: $primaryTextColor !important;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: $primaryHeaderColor !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
box-shadow: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
table td > span {
|
|
||||||
color: $primaryTextColor !important;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: $primaryHeaderColor !important;
|
|
||||||
background-color: $primaryBackgroundColor !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
box-shadow: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
table td.p-datepicker-today > span {
|
|
||||||
color: $primaryHeaderColor !important;
|
|
||||||
background-color: $primaryBackgroundColor !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
table td > span.p-highlight {
|
|
||||||
color: $primaryHeaderColor !important;
|
|
||||||
background-color: $primaryBackgroundColor !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-yearpicker .p-yearpicker-year,
|
|
||||||
.p-monthpicker .p-monthpicker-month:not(.p-disabled):not(.p-highlight) {
|
|
||||||
color: $primaryTextColor !important;
|
|
||||||
background-color: $secondaryBackgroundColor !important;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: $primaryHeaderColor !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
box-shadow: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -20,8 +20,7 @@
|
|||||||
background-color: $primaryBackgroundColor;
|
background-color: $primaryBackgroundColor;
|
||||||
|
|
||||||
h1,
|
h1,
|
||||||
h2,
|
h2 {
|
||||||
h3 {
|
|
||||||
color: $primaryHeaderColor;
|
color: $primaryHeaderColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user