chore: add prettier with config and format all files

This commit is contained in:
Sebastian Seedorf
2026-06-04 11:44:20 +02:00
parent d212ae3f30
commit cf9bb33ecb
50 changed files with 1290 additions and 714 deletions

View File

@@ -6,17 +6,25 @@ export const PUT = withAuth(async (req: NextRequest, { params }) => {
const { id } = await params;
const body = await req.json();
const {
title, pos_x, pos_y, width, height,
signal_type, chart_type, viz_type,
filter_items_regex, y_scale,
series_limit, order_by,
title,
pos_x,
pos_y,
width,
height,
signal_type,
chart_type,
viz_type,
filter_items_regex,
y_scale,
series_limit,
order_by,
} = body;
const hasFilterCombinators = 'filter_combinators' in body;
const hasFilterItems = 'filter_items' in body;
const hasFilterCombinators = 'filter_combinators' in body;
const hasFilterItems = 'filter_items' in body;
const hasFilterItemsExclude = 'filter_items_exclude' in body;
const hasYMin = 'y_min' in body;
const hasYMax = 'y_max' in body;
const hasYMin = 'y_min' in body;
const hasYMax = 'y_max' in body;
const result = await pool.query(
`UPDATE charts SET
@@ -40,15 +48,28 @@ export const PUT = withAuth(async (req: NextRequest, { params }) => {
WHERE id = $23
RETURNING *`,
[
title, pos_x, pos_y, width, height, signal_type, chart_type, viz_type,
hasFilterCombinators, body.filter_combinators ?? null,
hasFilterItems, body.filter_items ?? null,
hasFilterItemsExclude, body.filter_items_exclude ?? null,
title,
pos_x,
pos_y,
width,
height,
signal_type,
chart_type,
viz_type,
hasFilterCombinators,
body.filter_combinators ?? null,
hasFilterItems,
body.filter_items ?? null,
hasFilterItemsExclude,
body.filter_items_exclude ?? null,
filter_items_regex,
hasYMin, body.y_min ?? null,
hasYMax, body.y_max ?? null,
hasYMin,
body.y_min ?? null,
hasYMax,
body.y_max ?? null,
y_scale,
series_limit, order_by,
series_limit,
order_by,
id,
],
);
@@ -61,4 +82,4 @@ export const DELETE = withAuth(async (_req: NextRequest, { params }) => {
const result = await pool.query('DELETE FROM charts WHERE id = $1', [id]);
if (result.rowCount === 0) return NextResponse.json({ error: 'Not found' }, { status: 404 });
return NextResponse.json({ ok: true });
});
});

View File

@@ -11,12 +11,22 @@ export const POST = withAuth(async (req: NextRequest) => {
const body = await req.json();
const {
title,
pos_x = 0, pos_y = 0, width = 2, height = 4,
signal_type = 'both', chart_type = 'signals', viz_type = 'line',
filter_combinators = null, filter_items = null,
filter_items_exclude = null, filter_items_regex = false,
y_min = null, y_max = null, y_scale = 'linear',
series_limit = 20, order_by = 'value_asc',
pos_x = 0,
pos_y = 0,
width = 2,
height = 4,
signal_type = 'both',
chart_type = 'signals',
viz_type = 'line',
filter_combinators = null,
filter_items = null,
filter_items_exclude = null,
filter_items_regex = false,
y_min = null,
y_max = null,
y_scale = 'linear',
series_limit = 20,
order_by = 'value_asc',
} = body;
if (!title) return NextResponse.json({ error: 'title required' }, { status: 400 });
@@ -28,9 +38,25 @@ export const POST = withAuth(async (req: NextRequest) => {
y_min,y_max,y_scale,series_limit,order_by)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17)
RETURNING *`,
[title,pos_x,pos_y,width,height,signal_type,chart_type,viz_type,
filter_combinators,filter_items,filter_items_exclude,filter_items_regex,
y_min,y_max,y_scale,series_limit,order_by],
[
title,
pos_x,
pos_y,
width,
height,
signal_type,
chart_type,
viz_type,
filter_combinators,
filter_items,
filter_items_exclude,
filter_items_regex,
y_min,
y_max,
y_scale,
series_limit,
order_by,
],
);
return NextResponse.json(result.rows[0], { status: 201 });
});
});