heavily simplify server and app content. unify styling
All checks were successful
ci/woodpecker/pr/pr Pipeline was successful
All checks were successful
ci/woodpecker/pr/pr Pipeline was successful
This commit is contained in:
@@ -7,6 +7,6 @@ export default defineEventHandler(async (event) => {
|
||||
requireAuth(event)
|
||||
const [db, sessions] = await Promise.all([getDb(), getActiveSessions()])
|
||||
const rows = await db.all('SELECT id, name, device_type, vendor, lat, lng, stream_url, source_type, config FROM devices ORDER BY id')
|
||||
const devices = rows.map(r => rowToDevice(r)).filter(Boolean).map(sanitizeDeviceForResponse)
|
||||
const devices = rows.map(rowToDevice).filter(Boolean).map(sanitizeDeviceForResponse)
|
||||
return { devices, liveSessions: sessions }
|
||||
})
|
||||
|
||||
@@ -1,32 +1,11 @@
|
||||
/**
|
||||
* Client-side logging endpoint.
|
||||
* Accepts log messages from the browser and outputs them server-side.
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
// Note: Auth is optional - we rely on session cookie validation if needed
|
||||
const CONSOLE_METHOD = Object.freeze({ error: 'error', warn: 'warn', info: 'log', debug: 'log' })
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event).catch(() => ({}))
|
||||
const { level, message, data, sessionId, userId } = body
|
||||
|
||||
const logPrefix = `[CLIENT${sessionId ? `:${sessionId}` : ''}${userId ? `:${userId.slice(0, 8)}` : ''}]`
|
||||
const logMessage = data ? `${message} ${JSON.stringify(data)}` : message
|
||||
|
||||
switch (level) {
|
||||
case 'error':
|
||||
console.error(logPrefix, logMessage)
|
||||
break
|
||||
case 'warn':
|
||||
console.warn(logPrefix, logMessage)
|
||||
break
|
||||
case 'info':
|
||||
console.log(logPrefix, logMessage)
|
||||
break
|
||||
case 'debug':
|
||||
console.log(logPrefix, logMessage)
|
||||
break
|
||||
default:
|
||||
console.log(logPrefix, logMessage)
|
||||
}
|
||||
|
||||
const prefix = `[CLIENT${sessionId ? `:${sessionId}` : ''}${userId ? `:${userId.slice(0, 8)}` : ''}]`
|
||||
const msg = data ? `${message} ${JSON.stringify(data)}` : message
|
||||
const method = CONSOLE_METHOD[level] || 'log'
|
||||
console[method](prefix, msg)
|
||||
return { ok: true }
|
||||
})
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
import { getDb } from '../utils/db.js'
|
||||
import { requireAuth } from '../utils/authHelpers.js'
|
||||
|
||||
const ICON_TYPES = ['pin', 'flag', 'waypoint']
|
||||
import { POI_ICON_TYPES } from '../utils/poiConstants.js'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAuth(event, { role: 'adminOrLeader' })
|
||||
const body = await readBody(event)
|
||||
const lat = Number(body?.lat)
|
||||
const lng = Number(body?.lng)
|
||||
if (!Number.isFinite(lat) || !Number.isFinite(lng)) {
|
||||
throw createError({ statusCode: 400, message: 'lat and lng required as numbers' })
|
||||
}
|
||||
if (!Number.isFinite(lat) || !Number.isFinite(lng)) throw createError({ statusCode: 400, message: 'lat and lng required as numbers' })
|
||||
const label = typeof body?.label === 'string' ? body.label.trim() : ''
|
||||
const iconType = ICON_TYPES.includes(body?.iconType) ? body.iconType : 'pin'
|
||||
const iconType = POI_ICON_TYPES.includes(body?.iconType) ? body.iconType : 'pin'
|
||||
const id = crypto.randomUUID()
|
||||
const { run } = await getDb()
|
||||
await run(
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import { getDb } from '../../utils/db.js'
|
||||
import { requireAuth } from '../../utils/authHelpers.js'
|
||||
|
||||
const ICON_TYPES = ['pin', 'flag', 'waypoint']
|
||||
import { POI_ICON_TYPES } from '../../utils/poiConstants.js'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAuth(event, { role: 'adminOrLeader' })
|
||||
const id = event.context.params?.id
|
||||
if (!id) throw createError({ statusCode: 400, message: 'id required' })
|
||||
const body = await readBody(event) || {}
|
||||
const body = (await readBody(event)) || {}
|
||||
const updates = []
|
||||
const params = []
|
||||
if (typeof body.label === 'string') {
|
||||
updates.push('label = ?')
|
||||
params.push(body.label.trim())
|
||||
}
|
||||
if (ICON_TYPES.includes(body.iconType)) {
|
||||
if (POI_ICON_TYPES.includes(body.iconType)) {
|
||||
updates.push('icon_type = ?')
|
||||
params.push(body.iconType)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user