feat: TTLock page redesign — sector circles, COM dropdown, DLL diagnostics

- SectorPicker: circles 1–16, click to toggle (blue=selected, gray=not)
- COM port: dropdown populated from agent's serial ports list + refresh button
- Per-workstation buttons: HardDriveDownload (save), Zap (test encoder)
- Workstations without COM port shown as dimmed with amber 'Энкодер не настроен'
- DLL entry point error shown with hint to check TTHotel libs/index.js
- Backend: GET /ttlock/dll-info?workstation_id= → reads TTHotel index.js via agent
- api.ts: added dllInfo() call

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-01 22:11:22 +03:00
parent 070a333609
commit 061fc165b5
3 changed files with 253 additions and 69 deletions

View File

@@ -98,6 +98,35 @@ const ttlockRoutes: FastifyPluginAsync = async (fastify) => {
return { ok: true }
})
// ── GET /api/hotels/:slug/ttlock/dll-info?workstation_id=... ────────────────
// Читаем index.js из TTHotel чтобы узнать реальные имена функций DLL
fastify.get<SlugParam & { Querystring: { workstation_id: string } }>(
'/api/hotels/:slug/ttlock/dll-info',
{ onRequest: [fastify.authenticate] },
async (req, reply) => {
const { slug } = req.params
if (!canManage(req.user.hotelSlug, req.user.role, slug))
return reply.code(403).send({ error: 'Forbidden' })
const hotelId = await getHotelId(slug)
if (!hotelId) return reply.code(404).send({ error: 'Hotel not found' })
const { workstation_id } = req.query
if (!workstation_id) return reply.code(400).send({ error: 'workstation_id required' })
try {
const result = await sendCommandAndWait(workstation_id, {
type: 'ttlock:read_index_js',
}, 8000) as { ok?: boolean; content?: string; path?: string; error?: string }
if (!result.ok) return reply.code(502).send({ error: result.error ?? 'Ошибка чтения файла' })
return { ok: true, content: result.content, path: result.path }
} catch (err) {
const msg = err instanceof Error ? err.message : 'Агент не ответил'
return reply.code(502).send({ error: msg })
}
},
)
// ── POST /api/hotels/:slug/ttlock/test ──────────────────────────────────────
// Проверяем: агент онлайн, энкодер отвечает на COM-порту
fastify.post<SlugParam & { Body: { workstation_id: string } }>(