feat: expose some more info in /settings
This commit is contained in:
parent
130a1996d7
commit
c3291edd4f
3 changed files with 37 additions and 1 deletions
|
@ -2,6 +2,7 @@ package user
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"codeberg.org/u1f320/pronouns.cc/backend/db"
|
||||
"codeberg.org/u1f320/pronouns.cc/backend/log"
|
||||
|
@ -29,6 +30,8 @@ type GetUserResponse struct {
|
|||
type GetMeResponse struct {
|
||||
GetUserResponse
|
||||
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
|
||||
MaxInvites int `json:"max_invites"`
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
ListPrivate bool `json:"list_private"`
|
||||
|
@ -194,6 +197,7 @@ func (s *Server) getMeUser(w http.ResponseWriter, r *http.Request) error {
|
|||
|
||||
render.JSON(w, r, GetMeResponse{
|
||||
GetUserResponse: dbUserToResponse(u, fields, members),
|
||||
CreatedAt: u.ID.Time(),
|
||||
MaxInvites: u.MaxInvites,
|
||||
IsAdmin: u.IsAdmin,
|
||||
ListPrivate: u.ListPrivate,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { PUBLIC_BASE_URL } from "$env/static/public";
|
||||
|
||||
export const MAX_MEMBERS = 500;
|
||||
export const MAX_FIELDS = 25;
|
||||
export const MAX_DESCRIPTION_LENGTH = 1000;
|
||||
|
||||
export interface User {
|
||||
|
@ -38,7 +39,9 @@ export enum PreferenceSize {
|
|||
}
|
||||
|
||||
export interface MeUser extends User {
|
||||
created_at: string;
|
||||
max_invites: number;
|
||||
is_admin: boolean;
|
||||
discord: string | null;
|
||||
discord_username: string | null;
|
||||
tumblr: string | null;
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
<script lang="ts">
|
||||
import { goto } from "$app/navigation";
|
||||
import { type MeUser, userAvatars, type APIError, MAX_MEMBERS } from "$lib/api/entities";
|
||||
import {
|
||||
type MeUser,
|
||||
userAvatars,
|
||||
type APIError,
|
||||
MAX_MEMBERS,
|
||||
MAX_FIELDS,
|
||||
} from "$lib/api/entities";
|
||||
import { apiFetchClient, fastFetchClient } from "$lib/api/fetch";
|
||||
import { usernameRegex } from "$lib/api/regex";
|
||||
import ErrorAlert from "$lib/components/ErrorAlert.svelte";
|
||||
|
@ -19,6 +25,7 @@
|
|||
} from "sveltestrap";
|
||||
import type { PageData } from "./$types";
|
||||
import { onMount } from "svelte";
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
|
@ -188,16 +195,38 @@
|
|||
<th scope="row">ID</th>
|
||||
<td><code>{data.user.id}</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Account created at</th>
|
||||
<td
|
||||
>{DateTime.fromISO(data.user.created_at)
|
||||
.toLocal()
|
||||
.toLocaleString(DateTime.DATETIME_MED)}</td
|
||||
>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Members</th>
|
||||
<td>{data.user.members.length}/{MAX_MEMBERS}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Member list hidden?</th>
|
||||
<td>{data.user.list_private ? "Yes" : "No"}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Custom preferences</th>
|
||||
<td>{Object.keys(data.user.custom_preferences).length}/{MAX_FIELDS}</td>
|
||||
</tr>
|
||||
{#if data.invitesEnabled}
|
||||
<tr>
|
||||
<th scope="row">Invites</th>
|
||||
<td>{data.invites.length}/{data.user.max_invites}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{#if data.user.is_admin}
|
||||
<tr>
|
||||
<th scope="row">Admin?</th>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</Table>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue