Improved profile voice states & fixed new vs handling
All checks were successful
Deploy staging on push / on-push-deploy_sh-edraft (push) Successful in 5m31s

This commit is contained in:
Sven Heidemann 2023-11-20 09:28:53 +01:00
parent 0c807a7de7
commit 5f8ae787f0
3 changed files with 36 additions and 14 deletions

View File

@ -58,14 +58,22 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
return
try:
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}")
if joined:
active_joins = self._user_joins_vc.find_active_user_joined_voice_channels_by_user_id(user.id)
for join in active_joins:
join.leaved_on = datetime.now()
user.xp += round(join.time * settings.xp_per_ontime_hour)
self._user_joins_vc.update_user_joined_voice_channel(join)
self._users.update_user(user)
self._db.save_changes()
join = UserJoinedVoiceChannel(user, channel_id, datetime.now())
self._user_joins_vc.add_user_joined_voice_channel(join)
self._db.save_changes()
return
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}")
join = self._user_joins_vc.get_active_user_joined_voice_channel_by_user_id(user.id)
join.leaved_on = datetime.now()

View File

@ -31,7 +31,9 @@
<div class="content-column">
<div class="content-data-name">{{'view.server.profile.xp' | translate}}:</div>
<div *ngIf="!isEditing" 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 *ngIf="isModerator && isEditing" class="content-data-value"><input class="table-edit-input" pInputText
min="0" type="number"
[(ngModel)]="user.xp"></div>
</div>
</div>
@ -71,7 +73,8 @@
<div class="content-data-name">{{'view.server.profile.level' | translate}}:</div>
<div *ngIf="!isEditing" 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 [options]="levels" [(ngModel)]="user.level" dataKey="id"
placeholder="{{'common.level' | translate}}">
</p-dropdown>
</div>
</div>
@ -100,7 +103,8 @@
<div>
<div class="content-divider"></div>
<p-table #dt [value]="(user.userWarnings ?? [])" [responsive]="true" responsiveLayout="stack" [breakpoint]="'720px'" dataKey="id" editMode="row">
<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">
@ -178,10 +182,13 @@
</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" 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"
<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>
@ -215,16 +222,22 @@
</div>
</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"
[collapsed]="true"
(onBeforeToggle)="onBeforeToggle($event.event, $event.collapsed)">
<div *ngFor="let join of user.joinedVoiceChannels;">
<div class="content-row">
<div class="content-column">
<div class="content-column" style="flex: 0.3;">
<div class="content-data-name">{{'common.id' | translate}}:</div>
<div class="content-data-value">{{join.id}}</div>
</div>
<div class="content-column" style="flex: 0.75;">
<div class="content-data-name">{{'view.server.profile.joined_voice_channel.time' | translate}}:</div>
<div class="content-data-value">{{join.time}} {{'general.hours' | translate}}</div>
</div>
<div class="content-column">
<div class="content-column" style="flex: 2;">
<div class="content-data-name">{{'view.server.profile.joined_voice_channel.channel' | translate}}:</div>
<div class="content-data-value">{{join.channelName}}</div>
</div>
@ -242,7 +255,8 @@
</div>
</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"
[collapsed]="true"
(onBeforeToggle)="onBeforeToggle($event.event, $event.collapsed)">
<div *ngFor="let join of user.userJoinedGameServers;">
<div class="content-row">

View File

@ -176,15 +176,16 @@ header {
flex-direction: row;
flex: 1;
margin: 5px 0;
gap: 5px;
.content-column {
display: flex;
flex: 1;
gap: 5px;
}
.content-data-name {
display: flex;
flex: 1;
align-items: center;
font-size: 18px;
@ -192,7 +193,6 @@ header {
.content-data-value {
display: flex;
flex: 1;
align-items: center;
font-size: 18px;