feat: Service-Editor mit vollem CRUD und Server-Speichern
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 16s

This commit is contained in:
Kroonk
2026-05-22 00:43:25 +02:00
parent 072fc9b9f9
commit fb3c7a99f1
4 changed files with 304 additions and 39 deletions

View File

@@ -1218,6 +1218,43 @@ const server = http.createServer(async (req, res) => {
return;
}
if (req.url?.startsWith('/api/services/save')) {
if (req.method !== 'POST') {
json(res, 405, { error: 'Method not allowed' });
return;
}
try {
await verifyAdminRequest(req);
const body = await new Promise((resolve, reject) => {
let data = '';
req.on('data', chunk => data += chunk);
req.on('end', () => {
try {
resolve(JSON.parse(data));
} catch (e) {
reject(new Error('Invalid JSON'));
}
});
req.on('error', reject);
});
if (!body || !Array.isArray(body.categories) || !Array.isArray(body.services)) {
json(res, 400, { error: 'Invalid configuration format' });
return;
}
const servicesPath = path.join(PUBLIC_DIR, 'services.json');
await fsp.writeFile(servicesPath, JSON.stringify(body, null, 2), 'utf-8');
json(res, 200, { success: true, message: 'Configuration saved successfully' });
} catch (error) {
json(res, error.statusCode || 500, { error: error.message });
}
return;
}
if (req.url?.startsWith('/api/disks/scan-folder')) {
if (req.method !== 'GET') {
json(res, 405, { error: 'Method not allowed' });