Added statistics #420

This commit is contained in:
Sven Heidemann 2023-11-05 15:51:25 +01:00
parent d1ecfe9603
commit 90de90684c
10 changed files with 133 additions and 2 deletions

View File

@ -20,6 +20,7 @@ export interface Server extends Data {
autoRoles?: AutoRole[]; autoRoles?: AutoRole[];
clientCount?: number; clientCount?: number;
clients?: Client[]; clients?: Client[];
statistic?: ServerStatistic;
levelCount?: number; levelCount?: number;
levels?: Level[]; levels?: Level[];
userCount?: number; userCount?: number;
@ -35,3 +36,16 @@ export interface ServerFilter {
discordId?: String; discordId?: String;
name?: String; name?: String;
} }
export interface ServerStatistic {
achievementsAchieved?: Number
messageCount?: Number
userCount?: Number
activeUserCount?: Number
userJoinedVoiceChannelCount?: Number
userJoinedVoiceChannelOntime?: Number
userJoinedGameServerCount?: Number
userJoinedGameServerOntime?: Number
userWarningCount?: Number
activityScore?: Number
}

View File

@ -79,6 +79,18 @@ export class Queries {
receivedCommandCount receivedCommandCount
movedUsersCount movedUsersCount
} }
statistic {
achievementsAchieved
messageCount
userCount
activeUserCount
userJoinedVoiceChannelCount
userJoinedVoiceChannelOntime
userJoinedGameServerCount
userJoinedGameServerOntime
userWarningCount
activityScore
}
} }
} }
`; `;

View File

@ -0,0 +1,35 @@
<div class="client">
<div class="client-info client-info-small">
<label class="client-info-header">{{'view.server.dashboard.activity_score' | translate}}</label>
<label class="client-info-value">{{stats?.activityScore}}</label>
</div>
<div class="client-info client-info-small">
<label class="client-info-header">{{'view.server.dashboard.achievements_achieved' | translate}}</label>
<label class="client-info-value">{{stats?.achievementsAchieved}}</label>
</div>
<div class="client-info client-info-small">
<label class="client-info-header">{{'view.server.dashboard.message_count' | translate}}</label>
<label class="client-info-value">{{stats?.messageCount}}</label>
</div>
<div class="client-info client-info-small">
<label class="client-info-header">{{'view.server.dashboard.user_joined_voice_channel_count' | translate}}</label>
<label class="client-info-value">{{stats?.userJoinedVoiceChannelCount}}</label>
</div>
<div class="client-info client-info-small">
<label class="client-info-header">{{'view.server.dashboard.user_joined_voice_channel_ontime' | translate}}</label>
<label class="client-info-value">{{stats?.userJoinedVoiceChannelOntime}}</label>
</div>
<div class="client-info client-info-small">
<label class="client-info-header">{{'view.server.dashboard.user_joined_game_server_count' | translate}}</label>
<label class="client-info-value">{{stats?.userJoinedGameServerCount}}</label>
</div>
<div class="client-info client-info-small">
<label class="client-info-header">{{'view.server.dashboard.user_joined_game_server_ontime' | translate}}</label>
<label class="client-info-value">{{stats?.userJoinedGameServerOntime}}</label>
</div>
<div class="client-info client-info-small">
<label class="client-info-header">{{'view.server.dashboard.user_warning_count' | translate}}</label>
<label class="client-info-value">{{stats?.userWarningCount}}</label>
</div>
</div>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ServerStatisticComponent } from './server-statistic.component';
describe('ServerStatisticComponent', () => {
let component: ServerStatisticComponent;
let fixture: ComponentFixture<ServerStatisticComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ServerStatisticComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(ServerStatisticComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,22 @@
import { Component, Input } from "@angular/core";
import { ServerStatistic } from "../../../../../../models/data/server.model";
@Component({
selector: 'app-server-statistic',
templateUrl: './server-statistic.component.html',
styleUrls: ['./server-statistic.component.scss']
})
export class ServerStatisticComponent {
@Input() stats?: ServerStatistic = {
achievementsAchieved: 0,
messageCount: 0,
userCount: 0,
activeUserCount: 0,
userJoinedVoiceChannelCount: 0,
userJoinedVoiceChannelOntime: 0,
userJoinedGameServerCount: 0,
userJoinedGameServerOntime: 0,
userWarningCount: 0,
activityScore: 0,
};
}

View File

@ -28,6 +28,13 @@
{{'view.dashboard.server.active_members' | translate}} {{server ? server.activeUserCount : ''}} {{'view.dashboard.server.active_members' | translate}} {{server ? server.activeUserCount : ''}}
</div> </div>
<div class="content-divider"></div>
<div class="client-data">
<app-server-statistic class="client-component" [stats]="server.statistic"></app-server-statistic>
</div>
<div class="content-divider"></div>
<div class="client-data" <div class="client-data"
*ngFor="let client of server?.clients"> *ngFor="let client of server?.clients">
<app-client class="client-component" [client]="client"></app-client> <app-client class="client-component" [client]="client"></app-client>

View File

@ -6,6 +6,7 @@ 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";
import { ServerStatisticComponent } from './server-dashboard/components/server-statistic/server-statistic.component';
@NgModule({ @NgModule({
@ -14,6 +15,7 @@ import { ClientComponent } from "./server-dashboard/components/client/client.com
ProfileComponent, ProfileComponent,
MembersComponent, MembersComponent,
ClientComponent, ClientComponent,
ServerStatisticComponent,
], ],
imports: [ imports: [
CommonModule, CommonModule,

View File

@ -454,13 +454,21 @@
} }
}, },
"dashboard": { "dashboard": {
"achievements_achieved": "Errungenschaften vergeben",
"activity_score": "Aktivitätsbewertung",
"deleted_message_count": "Gelöschte Nachrichten", "deleted_message_count": "Gelöschte Nachrichten",
"header": "Server dashboard", "header": "Server dashboard",
"message_count": "Anzahl Nachrichten",
"moved_users_count": "Verschobene Benutzer", "moved_users_count": "Verschobene Benutzer",
"name": "Name", "name": "Name",
"received_command_count": "Empfangene Befehle", "received_command_count": "Empfangene Befehle",
"received_message_count": "Empfangene Nachrichten", "received_message_count": "Empfangene Nachrichten",
"sent_message_count": "Gesendete Nachrichten" "sent_message_count": "Gesendete Nachrichten",
"user_joined_game_server_count": "Anzahl Gameserver beitritte",
"user_joined_game_server_ontime": "Gameserver Ontime",
"user_joined_voice_channel_count": "Anzahl Sprachkanal beitritte",
"user_joined_voice_channel_ontime": "Sprachkanal Ontime",
"user_warning_count": "Anzahl Verwarnungen"
}, },
"header": "Server", "header": "Server",
"levels": { "levels": {

View File

@ -454,13 +454,21 @@
} }
}, },
"dashboard": { "dashboard": {
"achievements_achieved": "Achievements achieved",
"activity_score": "Activity score",
"deleted_message_count": "Deleted messages", "deleted_message_count": "Deleted messages",
"header": "Server dashboard", "header": "Server dashboard",
"message_count": "Message count",
"moved_users_count": "Moved users", "moved_users_count": "Moved users",
"name": "Name", "name": "Name",
"received_command_count": "Received commands", "received_command_count": "Received commands",
"received_message_count": "Received messages", "received_message_count": "Received messages",
"sent_message_count": "Sent messages" "sent_message_count": "Sent messages",
"user_joined_game_server_count": "Joined Gameserver count",
"user_joined_game_server_ontime": "Gameserver ontime",
"user_joined_voice_channel_count": "Joined voice channel count",
"user_joined_voice_channel_ontime": "Joined voice channel ontime",
"user_warning_count": "User warning count"
}, },
"header": "Server", "header": "Server",
"levels": { "levels": {