mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 19:36:02 -05:00
Added custom user avatar support.
## Extra Details:
- Users can upload custom `PNG, JPEG, SVG, WebP, AVIF`, and `ICO`
avatars.
- Added avatar management to the user account area.
- Added admin controls to update and remove user avatars.
- Custom User avatars appear in:
- Panel Navbar.
- Panel Admin Activity Logs.
- Server Sub user List.
- Server Activity Logs
- Personal Account Activity Logs.
- Server Ownership Details.
---
<img width="1329" height="327"
alt="{B32EBD7F-1FCA-4356-966C-0D60A9A23E49}"
src="https://github.com/user-attachments/assets/881fa5b3-9599-4370-975d-83b6bd91a7d1"
/>
---
<img width="997" height="847" alt="adminpage"
src="https://github.com/user-attachments/assets/989acbcc-351c-431b-ab7f-557ba4c7e070"
/>
---
<img width="955" height="781" alt="serverinfo"
src="https://github.com/user-attachments/assets/6556afac-1971-4112-9686-b71137072c5f"
/>
---
<img width="1376" height="919" alt="userarea"
src="https://github.com/user-attachments/assets/d49f0ddb-1f38-4884-b186-8db78bfed4b0"
/>
---
<img width="936" height="232" alt="userslist"
src="https://github.com/user-attachments/assets/0e8a4b4a-719a-4d52-a485-d7577736b43f"
/>
---
<img width="983" height="772" alt="activity"
src="https://github.com/user-attachments/assets/37ef7176-a804-43f7-ae32-ae65e1a2671b"
/>
93 lines
2.8 KiB
TypeScript
93 lines
2.8 KiB
TypeScript
import type { UserData } from '@/api/account/types';
|
|
import type { SiteSettings } from '@/api/settings/types';
|
|
import type { DevelopmentPayload } from '@/extensions/development';
|
|
import type { SiteExtensionEntry } from '@/extensions/registry';
|
|
|
|
export type ThemeScheme = 'dark' | 'light';
|
|
export type ThemeSettingValue = string | number | boolean | null;
|
|
|
|
/** The active theme as the server renders it; `classic` with an empty chain when none is active. */
|
|
export interface ThemeBootstrap {
|
|
id: string;
|
|
/** Parent first, excluding classic; `development` is set while `p:extension:dev` serves an entry. */
|
|
chain: {
|
|
id: string;
|
|
version: string;
|
|
entry: string | null;
|
|
development?: DevelopmentPayload | null;
|
|
}[];
|
|
settings: Record<string, ThemeSettingValue>;
|
|
scheme: ThemeScheme;
|
|
schemes: ThemeScheme[];
|
|
safeMode: boolean;
|
|
preview: boolean;
|
|
}
|
|
|
|
interface ExtendedWindow extends Window {
|
|
SiteConfiguration?: SiteSettings & {
|
|
extensions?: SiteExtensionEntry[];
|
|
theme?: Partial<ThemeBootstrap>;
|
|
};
|
|
PterodactylUser?: {
|
|
uuid: string;
|
|
username: string;
|
|
email: string;
|
|
root_admin: boolean;
|
|
use_totp: boolean;
|
|
language: string;
|
|
avatar?: string | null;
|
|
updated_at: string;
|
|
created_at: string;
|
|
};
|
|
}
|
|
|
|
export const getBootstrapUser = (): UserData | undefined => {
|
|
const user = (window as ExtendedWindow).PterodactylUser;
|
|
|
|
return user
|
|
? {
|
|
uuid: user.uuid,
|
|
username: user.username,
|
|
email: user.email,
|
|
language: user.language,
|
|
avatar: user.avatar ?? null,
|
|
rootAdmin: user.root_admin,
|
|
useTotp: user.use_totp,
|
|
createdAt: new Date(user.created_at),
|
|
updatedAt: new Date(user.updated_at),
|
|
}
|
|
: undefined;
|
|
};
|
|
|
|
let sessionEnded = false;
|
|
|
|
export const endBootstrapSession = (): void => {
|
|
sessionEnded = true;
|
|
};
|
|
|
|
export const hasBootstrapSession = (): boolean => !sessionEnded && !!getBootstrapUser()?.uuid;
|
|
|
|
export const getBootstrapSiteSettings = (): SiteSettings | undefined => (window as ExtendedWindow).SiteConfiguration;
|
|
|
|
export const getBootstrapExtensions = (): SiteExtensionEntry[] =>
|
|
(window as ExtendedWindow).SiteConfiguration?.extensions ?? [];
|
|
|
|
const classicTheme: ThemeBootstrap = {
|
|
id: 'classic',
|
|
chain: [],
|
|
settings: {},
|
|
scheme: 'dark',
|
|
schemes: ['dark'],
|
|
safeMode: false,
|
|
preview: false,
|
|
};
|
|
|
|
export const getBootstrapTheme = (): ThemeBootstrap => ({
|
|
...classicTheme,
|
|
...(window as ExtendedWindow).SiteConfiguration?.theme,
|
|
});
|
|
|
|
export type ThemeChainEntry = ThemeBootstrap['chain'][number];
|
|
|
|
export const getBootstrapThemeChain = (): ThemeChainEntry[] => getBootstrapTheme().chain;
|