v1.0.22
This commit is contained in:
1 parent
aefa5e7925
commit
b55e1e5aad
107 files changed
+2193
-443
No files matched your search
@@ -11,6 +11,7 @@ import { cleanPem } from '$lib/utils/pem';
|
||||
import { unregisterSchedule } from '$lib/server/scheduler';
|
||||
import { closeEdgeConnection } from '$lib/server/hawser';
|
||||
import { computeAuditDiff } from '$lib/utils/diff';
|
||||
import { deleteEnvironmentIcon } from '$lib/server/env-icons';
|
||||
|
||||
export const GET: RequestHandler = async ({ params, cookies }) => {
|
||||
const auth = await authorize(cookies);
|
||||
@@ -167,6 +168,9 @@ export const DELETE: RequestHandler = async (event) => {
|
||||
return json({ error: 'Cannot delete this environment' }, { status: 400 });
|
||||
}
|
||||
|
||||
// Clean up custom icon file if exists
|
||||
deleteEnvironmentIcon(id);
|
||||
|
||||
// Clean up public IP entry for this environment
|
||||
await deleteEnvironmentPublicIp(id);
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getEnvironment, updateEnvironment } from '$lib/server/db';
|
||||
import { authorize } from '$lib/server/authorize';
|
||||
import { saveEnvironmentIcon, deleteEnvironmentIcon, getEnvironmentIconBuffer } from '$lib/server/env-icons';
|
||||
|
||||
export const GET: RequestHandler = async ({ params }) => {
|
||||
const id = parseInt(params.id);
|
||||
const buffer = getEnvironmentIconBuffer(id);
|
||||
|
||||
if (!buffer) {
|
||||
return json({ error: 'No custom icon' }, { status: 404 });
|
||||
}
|
||||
|
||||
return new Response(new Uint8Array(buffer), {
|
||||
headers: {
|
||||
'Content-Type': 'image/webp',
|
||||
'Cache-Control': 'public, max-age=3600'
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const POST: RequestHandler = async ({ params, request, cookies }) => {
|
||||
const auth = await authorize(cookies);
|
||||
if (auth.authEnabled && !await auth.can('environments', 'edit')) {
|
||||
return json({ error: 'Permission denied' }, { status: 403 });
|
||||
}
|
||||
|
||||
const id = parseInt(params.id);
|
||||
const env = await getEnvironment(id);
|
||||
if (!env) {
|
||||
return json({ error: 'Environment not found' }, { status: 404 });
|
||||
}
|
||||
|
||||
const data = await request.json();
|
||||
if (!data.image || typeof data.image !== 'string') {
|
||||
return json({ error: 'Missing image data' }, { status: 400 });
|
||||
}
|
||||
|
||||
// Validate size (~200KB base64 limit)
|
||||
if (data.image.length > 300_000) {
|
||||
return json({ error: 'Image too large' }, { status: 400 });
|
||||
}
|
||||
|
||||
saveEnvironmentIcon(id, data.image);
|
||||
const iconValue = `custom:env-${id}.webp`;
|
||||
await updateEnvironment(id, { icon: iconValue });
|
||||
|
||||
return json({ success: true, icon: iconValue });
|
||||
};
|
||||
|
||||
export const DELETE: RequestHandler = async ({ params, cookies }) => {
|
||||
const auth = await authorize(cookies);
|
||||
if (auth.authEnabled && !await auth.can('environments', 'edit')) {
|
||||
return json({ error: 'Permission denied' }, { status: 403 });
|
||||
}
|
||||
|
||||
const id = parseInt(params.id);
|
||||
const env = await getEnvironment(id);
|
||||
if (!env) {
|
||||
return json({ error: 'Environment not found' }, { status: 404 });
|
||||
}
|
||||
|
||||
deleteEnvironmentIcon(id);
|
||||
await updateEnvironment(id, { icon: 'globe' });
|
||||
|
||||
return json({ success: true, icon: 'globe' });
|
||||
};
|
||||
@@ -13,7 +13,23 @@ const TIMEZONE_ALIASES: Record<string, string> = {
|
||||
'Europe/Kyiv': 'Europe/Kiev',
|
||||
'Asia/Ho_Chi_Minh': 'Asia/Saigon',
|
||||
'America/Nuuk': 'America/Godthab',
|
||||
'Pacific/Kanton': 'Pacific/Enderbury'
|
||||
'Pacific/Kanton': 'Pacific/Enderbury',
|
||||
// Modern IANA names that Node.js ICU maps to legacy names
|
||||
'Asia/Kolkata': 'Asia/Calcutta',
|
||||
'Asia/Kathmandu': 'Asia/Katmandu',
|
||||
'Asia/Yangon': 'Asia/Rangoon',
|
||||
'Asia/Kashgar': 'Asia/Urumqi',
|
||||
'Atlantic/Faroe': 'Atlantic/Faeroe',
|
||||
'Europe/Uzhgorod': 'Europe/Kiev',
|
||||
'Europe/Zaporozhye': 'Europe/Kiev',
|
||||
'America/Atikokan': 'America/Coral_Harbour',
|
||||
'America/Argentina/Buenos_Aires': 'America/Buenos_Aires',
|
||||
'America/Argentina/Catamarca': 'America/Catamarca',
|
||||
'America/Argentina/Cordoba': 'America/Cordoba',
|
||||
'America/Argentina/Jujuy': 'America/Jujuy',
|
||||
'America/Argentina/Mendoza': 'America/Mendoza',
|
||||
'Pacific/Pohnpei': 'Pacific/Ponape',
|
||||
'Pacific/Chuuk': 'Pacific/Truk'
|
||||
};
|
||||
|
||||
function normalizeTimezone(tz: string): string {
|
||||
|
||||
Reference in new issue
Block a user