Refactor player handling: replace player arrays with IDs, implement PlayerSelector component
This commit is contained in:
@@ -7,11 +7,11 @@ export class AuditLogRepo {
|
||||
actionText: string | undefined,
|
||||
serverText: string | undefined,
|
||||
fullText: string | undefined,
|
||||
actor: string[] | undefined,
|
||||
actor: number[] | undefined,
|
||||
actionType: string[] | undefined,
|
||||
timeFrom: number | undefined,
|
||||
timeTo: number | undefined,
|
||||
serverOwner: string[] | undefined,
|
||||
serverOwner: number[] | undefined,
|
||||
velocity: boolean | undefined,
|
||||
page: number,
|
||||
pageSize: number,
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import type { Player, Server } from "@type/data.ts";
|
||||
import { PlayerSchema, ServerSchema } from "@type/data.ts";
|
||||
import type { Player, PlayerList, Server } from "@type/data.ts";
|
||||
import { PlayerListSchema, PlayerSchema, ServerSchema } from "@type/data.ts";
|
||||
import { fetchWithToken, tokenStore } from "./repo.ts";
|
||||
import { derived, get } from "svelte/store";
|
||||
import { TeamSchema, type Team } from "@components/types/team.ts";
|
||||
@@ -38,10 +38,28 @@ export class DataRepo {
|
||||
.then(PlayerSchema.parse);
|
||||
}
|
||||
|
||||
public async getPlayers(): Promise<Player[]> {
|
||||
return await fetchWithToken(get(tokenStore), "/data/admin/users")
|
||||
public async queryPlayers(
|
||||
name: string | undefined,
|
||||
uuid: string | undefined,
|
||||
team: number[] | undefined,
|
||||
limit: number | undefined,
|
||||
page: number | undefined,
|
||||
includePerms: boolean | undefined,
|
||||
includeId: boolean | undefined
|
||||
): Promise<PlayerList> {
|
||||
let query = new URLSearchParams();
|
||||
|
||||
if (name) query.append("name", name);
|
||||
if (uuid) query.append("uuid", uuid);
|
||||
if (team) team.forEach((t) => query.append("team", t.toString()));
|
||||
if (limit) query.append("limit", limit.toString());
|
||||
if (page) query.append("page", page.toString());
|
||||
if (includePerms !== undefined) query.append("includePerms", includePerms.toString());
|
||||
if (includeId !== undefined) query.append("includeId", includeId.toString());
|
||||
|
||||
return await fetchWithToken(this.token, "/data/admin/users?" + query.toString())
|
||||
.then((value) => value.json())
|
||||
.then(PlayerSchema.array().parse);
|
||||
.then(PlayerListSchema.parse);
|
||||
}
|
||||
|
||||
public async getTeams(): Promise<Team[]> {
|
||||
|
||||
Reference in New Issue
Block a user