mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-12 00:15:48 +01:00
✨ Add logging for config deletion
This commit is contained in:
@@ -16,9 +16,6 @@ export default function ConfigChanger() {
|
||||
const [isRefreshing, toggle] = useToggle();
|
||||
|
||||
const onConfigChange = (value: string) => {
|
||||
// TODO: check what should happen here with @manuel-rw
|
||||
// Wheter it should check for the current url and then load the new config only on index
|
||||
// Or it should always load the selected config and open index or ? --> change url to page
|
||||
setCookie('config-name', value ?? 'default', {
|
||||
maxAge: 60 * 60 * 24 * 30,
|
||||
sameSite: 'strict',
|
||||
|
||||
@@ -130,6 +130,7 @@ function Delete(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||
// Get the slug of the request
|
||||
const { slug } = req.query as { slug: string };
|
||||
if (!slug) {
|
||||
Consola.error('Rejected config deletion request because config slug was not present');
|
||||
return res.status(400).json({
|
||||
message: 'Wrong request',
|
||||
});
|
||||
@@ -145,6 +146,7 @@ function Delete(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||
|
||||
// If the target is not in the list of files, return an error
|
||||
if (!configs.includes(slug)) {
|
||||
Consola.error(`Rejected config deletion request because config name '${slug}' was not included in present configurations`);
|
||||
return res.status(404).json({
|
||||
message: 'Target not found',
|
||||
});
|
||||
@@ -152,6 +154,7 @@ function Delete(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||
|
||||
// Delete the file
|
||||
fs.unlinkSync(path.join('data/configs', `${slug}.json`));
|
||||
Consola.info(`Successfully deleted configuration '${slug}' from your file system`);
|
||||
return res.status(200).json({
|
||||
message: 'Configuration deleted with success',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user