Added history to all data tables #246

This commit is contained in:
Sven Heidemann 2023-03-08 14:55:26 +01:00
parent 51f0ee5744
commit b8e4146b33
10 changed files with 49 additions and 21 deletions

View File

@ -18,7 +18,6 @@ type AutoRole implements TableWithHistoryQuery {
type AutoRoleHistory implements HistoryTableQuery {
id: ID
channelId: String
channelName: String
messageId: String
server: ID

View File

@ -16,7 +16,6 @@ type AutoRoleRuleHistory implements HistoryTableQuery {
id: ID
emojiName: String
roleId: String
roleName: String
autoRole: ID

View File

@ -20,7 +20,7 @@ type LevelHistory implements HistoryTableQuery {
minXp: Int
permissions: String
server: Server
server: ID
deleted: Boolean
dateFrom: String

View File

@ -4,7 +4,6 @@ from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
from bot_data.abc.server_repository_abc import ServerRepositoryABC
from bot_data.model.auto_role import AutoRole
from bot_graphql.abc.history_query_abc import HistoryQueryABC
from bot_graphql.filter.server_filter import ServerFilter
class AutoRoleHistoryQuery(HistoryQueryABC):
@ -22,7 +21,6 @@ class AutoRoleHistoryQuery(HistoryQueryABC):
self.set_field("id", self.resolve_id)
self.set_field("channelId", self.resolve_channel_id)
self.set_field("channelName", self.resolve_channel_name)
self.set_field("messageId", self.resolve_message_id)
self.set_field("server", self.resolve_server)
@ -34,16 +32,9 @@ class AutoRoleHistoryQuery(HistoryQueryABC):
def resolve_channel_id(x: AutoRole, *_):
return x.discord_channel_id
@staticmethod
def resolve_channel_name(x: AutoRole, *_):
return x.discord_channel_name
@staticmethod
def resolve_message_id(x: AutoRole, *_):
return x.discord_message_id
def resolve_server(self, x: AutoRole, *_, filter: ServerFilter = None):
if filter is not None:
return filter.filter(self._servers.get_server_by_id(x.server.id))
return self._servers.get_server_by_id(x.server.id)
def resolve_server(self, x: AutoRole, *_):
return x.server

View File

@ -19,7 +19,6 @@ class AutoRoleRuleHistoryQuery(HistoryQueryABC):
self.set_field("id", self.resolve_id)
self.set_field("emojiName", self.resolve_emoji_name)
self.set_field("roleId", self.resolve_role_id)
self.set_field("roleName", self.resolve_role_name)
self.set_field("autoRole", self.resolve_auto_role)
@staticmethod
@ -34,9 +33,5 @@ class AutoRoleRuleHistoryQuery(HistoryQueryABC):
def resolve_role_id(x: AutoRoleRule, *_):
return x.role_id
@staticmethod
def resolve_role_name(x: AutoRoleRule, *_):
return x.role_name
def resolve_auto_role(self, x: AutoRoleRule, *_):
return self._auto_roles.get_auto_role_by_id(x.auto_role.id)
return x.auto_role

View File

@ -62,6 +62,18 @@ export class Queries {
}
createdAt
modifiedAt
history {
id
name
color
minXp
permissions
server
deleted
dateFrom
dateTo
}
}
}
}
@ -148,6 +160,16 @@ export class Queries {
createdAt
modifiedAt
history {
id
channelId
messageId
server
deleted
dateFrom
dateTo
}
}
}
}
@ -170,6 +192,16 @@ export class Queries {
createdAt
modifiedAt
history {
id
emojiName
roleId
autoRole
deleted
dateFrom
dateTo
}
}
}
}

View File

@ -160,6 +160,7 @@
<td>
<div class="btn-wrapper">
<app-history-btn [history]="autoRoleRule.history" translationKey="view.server.auto_roles.rules.header"></app-history-btn>
<button *ngIf="!editing" pButton pInitEditableRow class="btn icon-btn" icon="pi pi-pencil" (click)="onRowEditInit(dt, autoRoleRule, ri)"></button>
<button *ngIf="!editing" pButton class="btn icon-btn danger-icon-btn" icon="pi pi-trash"
(click)="deleteAutoRoleRule(autoRoleRule)"></button>

View File

@ -193,6 +193,7 @@
<div class="btn-wrapper">
<!-- <button *ngIf="!editing" pButton pInitEditableRow class="btn icon-btn" icon="pi pi-pencil"-->
<!-- (click)="onRowEditInit(dt, autoRole, ri)"></button>-->
<app-history-btn [history]="autoRole.history" translationKey="view.server.auto_roles.header"></app-history-btn>
<button *ngIf="!editing" pButton pInitEditableRow class="btn icon-btn" icon="pi pi-sliders-h" [routerLink]="[autoRole.id, 'rules']"></button>
<button *ngIf="!editing" pButton class="btn icon-btn danger-icon-btn" icon="pi pi-trash"
(click)="deleteAutoRole(autoRole)"></button>

View File

@ -184,6 +184,7 @@
</td>
<td>
<div class="btn-wrapper">
<app-history-btn [history]="level.history" translationKey="view.server.levels.header"></app-history-btn>
<button *ngIf="!editing" pButton pInitEditableRow class="btn icon-btn" icon="pi pi-pencil"
(click)="onRowEditInit(dt, level, ri)" [disabled]="!user || user.isModerator && !user.isAdmin"></button>
<button *ngIf="!editing" pButton class="btn icon-btn danger-icon-btn" icon="pi pi-trash"

View File

@ -144,7 +144,16 @@
"dateTo": "Bis",
"server": "Server",
"leftServer": "Gegangen",
"xp": "XP"
"xp": "XP",
"minXp": "Min. XP",
"color": "Farbe",
"name": "Name",
"permissions": "Berechtigung",
"channelId": "Kanal Id",
"messageId": "Message Id",
"autoRole": "Auto Rolle",
"emojiName": "Emoji",
"roleId": "Rolle"
}
},
"dialog": {