Added more stuff on follow list

This commit is contained in:
nise.moe 2024-03-10 15:00:15 +01:00
parent cc3fe8ae96
commit 024246fc5a
3 changed files with 120 additions and 43 deletions

View File

@ -34,8 +34,12 @@ class FollowsController(
data class FollowsBanStatusEntry( data class FollowsBanStatusEntry(
val userId: Long, val userId: Long,
val username: String, val username: String,
val isBanned: Boolean, val secondsPlayed: Long?,
val lastUpdate: OffsetDateTime val pp: Double?,
val rank: Long?,
val isBanned: Boolean?,
val approximateBanTime: OffsetDateTime?,
val lastUpdate: OffsetDateTime?
) )
@GetMapping("follows") @GetMapping("follows")
@ -44,8 +48,12 @@ class FollowsController(
val follows = dslContext.select( val follows = dslContext.select(
USERS.USER_ID, USERS.USER_ID,
USERS.USERNAME, USERS.USERNAME,
USERS.SECONDS_PLAYED,
USERS.IS_BANNED, USERS.IS_BANNED,
USERS.SYS_LAST_UPDATE USERS.PP_RAW,
USERS.RANK,
USERS.SYS_LAST_UPDATE,
USERS.APPROX_BAN_DATE
) )
.from(USER_FOLLOWS) .from(USER_FOLLOWS)
.join(USERS).on(USER_FOLLOWS.FOLLOWS_USER_ID.eq(USERS.USER_ID)) .join(USERS).on(USER_FOLLOWS.FOLLOWS_USER_ID.eq(USERS.USER_ID))
@ -55,8 +63,12 @@ class FollowsController(
FollowsBanStatusEntry( FollowsBanStatusEntry(
it[USERS.USER_ID]!!, it[USERS.USER_ID]!!,
it[USERS.USERNAME]!!, it[USERS.USERNAME]!!,
it[USERS.IS_BANNED]!!, it[USERS.SECONDS_PLAYED],
it[USERS.SYS_LAST_UPDATE]!! it[USERS.PP_RAW],
it[USERS.RANK],
it[USERS.IS_BANNED],
it[USERS.APPROX_BAN_DATE],
it[USERS.SYS_LAST_UPDATE]
) )
} }
@ -72,8 +84,12 @@ class FollowsController(
val follows = dslContext.select( val follows = dslContext.select(
USERS.USER_ID, USERS.USER_ID,
USERS.USERNAME, USERS.USERNAME,
USERS.SECONDS_PLAYED,
USERS.IS_BANNED, USERS.IS_BANNED,
USERS.SYS_LAST_UPDATE USERS.PP_RAW,
USERS.RANK,
USERS.SYS_LAST_UPDATE,
USERS.APPROX_BAN_DATE
) )
.from(USER_FOLLOWS) .from(USER_FOLLOWS)
.join(USERS).on(USER_FOLLOWS.FOLLOWS_USER_ID.eq(USERS.USER_ID)) .join(USERS).on(USER_FOLLOWS.FOLLOWS_USER_ID.eq(USERS.USER_ID))
@ -83,8 +99,12 @@ class FollowsController(
FollowsBanStatusEntry( FollowsBanStatusEntry(
it[USERS.USER_ID]!!, it[USERS.USER_ID]!!,
it[USERS.USERNAME]!!, it[USERS.USERNAME]!!,
it[USERS.IS_BANNED]!!, it[USERS.SECONDS_PLAYED],
it[USERS.SYS_LAST_UPDATE]!! it[USERS.PP_RAW],
it[USERS.RANK],
it[USERS.IS_BANNED],
it[USERS.APPROX_BAN_DATE],
it[USERS.SYS_LAST_UPDATE]
) )
} }

View File

@ -2,39 +2,87 @@
<div class="fade-stuff"> <div class="fade-stuff">
<h1 class="mb-4"><span class="text-muted">hi,</span> {{ this.userService.currentUser?.username }}</h1> <h1 class="mb-4"><span class="text-muted">hi,</span> {{ this.userService.currentUser?.username }}</h1>
<h1 class="mb-4"># follow-list</h1> <h1># follow-list</h1>
<div class="text-center">
<p>You can follow users by going on their profile and clicking the <code>(+) Add follow</code> buttan.</p>
</div>
<ng-template #noFollows> <ng-template #noFollows>
<div class="text-center"> <div class="text-center">
<p>You are not following anyone!</p> <p>You are not following anyone!</p>
<p>You can follow users by going on their profile and clicking the <code>(+) Add follow</code> buttan.</p>
<p>Then, they'll appear here, and you'll be able to check if they've been banned or not.</p>
</div> </div>
</ng-template> </ng-template>
<table *ngIf="this.follows && this.follows.follows.length > 0; else noFollows"> <ng-template #nullTemplate>
<code>null</code>
</ng-template>
<ng-container *ngIf="this.follows && this.follows.follows.length > 0; else noFollows">
<fieldset class="mb-2">
<legend>tools</legend>
<div class="text-center">
<button (click)="this.downloadFilesService.downloadCSV(this.follows.follows, ['userId', 'username', 'secondsPlayed', 'pp', 'rank', 'isBanned', 'approximateBanTime', 'lastUpdate'], 'nise-follows')">Download .csv</button>
<button (click)="this.downloadFilesService.downloadJSON(this.follows.follows, 'nise-follows')">Download .json</button>
<button (click)="this.downloadFilesService.downloadXLSX(this.follows.follows, 'nise-follows')">Download .xlsx</button>
</div>
</fieldset>
<table>
<thead> <thead>
<tr> <tr>
<th colspan="2">Username</th> <th colspan="2">Username</th>
<th>Time played</th>
<th>Total PP</th>
<th>Rank</th>
<th>Is banned?</th> <th>Is banned?</th>
<th>Last check</th> <th>Last check</th>
<th>Approximate ban date</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let user of this.follows.follows"> <tr *ngFor="let user of this.follows.follows">
<td> <td>
<img [src]="'https://a.ppy.sh/' + user.userId" class="avatar" style="width: 16px; min-height: 16px; height: 16px;"> <img [src]="'https://a.ppy.sh/' + user.userId" class="avatar" style="width: 16px; min-height: 16px; height: 16px;" loading="lazy">
</td> </td>
<td> <td>
<a [routerLink]="['/u', user.username]"> <a [routerLink]="['/u', user.username]">
{{ user.username }} {{ user.username }}
</a> </a>
</td> </td>
<td>{{ user.isBanned }}</td> <td>
<td>{{ calculateTimeAgo(user.lastUpdate) }}</td> <ng-container *ngIf="user.secondsPlayed else nullTemplate">
{{ formatDuration(user.secondsPlayed) }}
</ng-container>
</td>
<td>
<ng-container *ngIf="user.pp; else nullTemplate">
{{ user.pp | number: '1.0-0' }}
</ng-container>
</td>
<td>
<ng-container *ngIf="user.rank; else nullTemplate">
#{{ user.rank | number }}
</ng-container>
</td>
<td>
<ng-container *ngIf="user.isBanned;">
yes
</ng-container>
<ng-container *ngIf="!user.isBanned;">
nope
</ng-container>
</td>
<td>
<ng-container *ngIf="user.lastUpdate; else nullTemplate">
{{ calculateTimeAgo(user.lastUpdate) }}
</ng-container>
</td>
<td>
<ng-container *ngIf="user.approximateBanTime; else nullTemplate">
{{ user.approximateBanTime | date: 'medium' }}
</ng-container>
</td>
<td> <td>
</td> </td>
</tbody> </tbody>
</table> </table>
</ng-container>
</div> </div>
</div> </div>

View File

@ -1,11 +1,12 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {environment} from "../../environments/environment"; import {environment} from "../../environments/environment";
import {JsonPipe, NgForOf, NgIf} from "@angular/common"; import {DatePipe, DecimalPipe, JsonPipe, NgForOf, NgIf} from "@angular/common";
import {calculateTimeAgo} from "../format"; import {calculateTimeAgo, formatDuration} from "../format";
import {RouterLink} from "@angular/router"; import {RouterLink} from "@angular/router";
import {UserService} from "../../corelib/service/user.service"; import {UserService} from "../../corelib/service/user.service";
import {Title} from "@angular/platform-browser"; import {Title} from "@angular/platform-browser";
import {DownloadFilesService} from "../../corelib/service/download-files.service";
interface FollowsBanStatusResponse { interface FollowsBanStatusResponse {
follows: FollowsBanStatusEntry[]; follows: FollowsBanStatusEntry[];
@ -14,8 +15,12 @@ interface FollowsBanStatusResponse {
interface FollowsBanStatusEntry { interface FollowsBanStatusEntry {
userId: number; userId: number;
username: string; username: string;
isBanned: boolean; secondsPlayed?: number;
lastUpdate: string; pp?: number;
rank?: number;
isBanned?: boolean;
approximateBanTime?: string;
lastUpdate?: string;
} }
@ -26,7 +31,9 @@ interface FollowsBanStatusEntry {
JsonPipe, JsonPipe,
NgForOf, NgForOf,
NgIf, NgIf,
RouterLink RouterLink,
DatePipe,
DecimalPipe
], ],
templateUrl: './profile.component.html', templateUrl: './profile.component.html',
styleUrl: './profile.component.css' styleUrl: './profile.component.css'
@ -38,7 +45,8 @@ export class ProfileComponent implements OnInit {
constructor( constructor(
private httpClient: HttpClient, private httpClient: HttpClient,
private title: Title, private title: Title,
public userService: UserService public userService: UserService,
public downloadFilesService: DownloadFilesService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
@ -53,4 +61,5 @@ export class ProfileComponent implements OnInit {
} }
protected readonly calculateTimeAgo = calculateTimeAgo; protected readonly calculateTimeAgo = calculateTimeAgo;
protected readonly formatDuration = formatDuration;
} }