feat: COM-port support for workstation devices + agent UI fixes
- EquipmentPage: add COM-port connection type with port field (COM1, /dev/ttyUSB0) - api.ts: add comPort field to WorkstationDevice type - workstations route: pass com_port to INSERT/PATCH - migration 042: extend connection check constraint to include 'com', add com_port column - agent index.html: highlight first cell on load, reset input on unpair Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -209,17 +209,17 @@ const workstationRoutes: FastifyPluginAsync = async (fastify) => {
|
||||
// ── POST /api/hotels/:slug/workstations/:id/devices ─────────────────────────
|
||||
fastify.post<WsParam & { Body: {
|
||||
type: string; name: string; connection: string
|
||||
network_host?: string; network_port?: number; purpose?: string; config?: object
|
||||
network_host?: string; network_port?: number; com_port?: string; purpose?: string; config?: object
|
||||
} }>(
|
||||
'/api/hotels/:slug/workstations/:id/devices',
|
||||
{ onRequest: [fastify.authenticate] },
|
||||
async (req, reply) => {
|
||||
const { id } = req.params
|
||||
const { type, name, connection, network_host, network_port, purpose, config } = req.body
|
||||
const { type, name, connection, network_host, network_port, com_port, purpose, config } = req.body
|
||||
const { rows } = await db.query(
|
||||
`INSERT INTO workstation_devices (workstation_id, type, name, connection, network_host, network_port, purpose, config)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8) RETURNING *`,
|
||||
[id, type, name, connection, network_host ?? null, network_port ?? null, purpose ?? 'other', config ?? {}],
|
||||
`INSERT INTO workstation_devices (workstation_id, type, name, connection, network_host, network_port, com_port, purpose, config)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9) RETURNING *`,
|
||||
[id, type, name, connection, network_host ?? null, network_port ?? null, com_port ?? null, purpose ?? 'other', config ?? {}],
|
||||
)
|
||||
return reply.code(201).send(rows[0])
|
||||
},
|
||||
@@ -232,7 +232,7 @@ const workstationRoutes: FastifyPluginAsync = async (fastify) => {
|
||||
async (req, reply) => {
|
||||
const { deviceId } = req.params
|
||||
const body = req.body as Record<string, unknown>
|
||||
const fields = ['name', 'connection', 'network_host', 'network_port', 'purpose', 'config']
|
||||
const fields = ['name', 'connection', 'network_host', 'network_port', 'com_port', 'purpose', 'config']
|
||||
const sets: string[] = []
|
||||
const vals: unknown[] = []
|
||||
fields.forEach(f => {
|
||||
|
||||
Reference in New Issue
Block a user