fix: hide reconnect button when agent is online; add printer encoding/paper_width settings
- WorkstationCard: show RefreshCw reconnect only when agentId set but offline - DeviceForm: add encoding (utf8/cp866) and paper_width fields for network printers - Backend: pass device.config in test_device command to agent Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -322,6 +322,7 @@ const workstationRoutes: FastifyPluginAsync = async (fastify) => {
|
||||
dto_user: device.config?.dto_user,
|
||||
dto_pass: device.config?.dto_pass,
|
||||
dto_device_id: device.config?.dto_device_id,
|
||||
config: device.config,
|
||||
},
|
||||
}) as { ok: boolean; error?: string; message?: string }
|
||||
return result
|
||||
|
||||
@@ -237,6 +237,8 @@ function DeviceForm({
|
||||
const [availablePrinters, setAvailablePrinters] = useState<{ name: string; isDefault: boolean }[] | null>(null)
|
||||
const [printersLoading, setPrintersLoading] = useState(false)
|
||||
const [windowsPrinter, setWindowsPrinter] = useState(String((initial?.config as any)?.windowsPrinter ?? (initial?.config as any)?.windows_printer ?? ''))
|
||||
const [encoding, setEncoding] = useState<'utf8' | 'cp866'>((initial?.config as any)?.encoding ?? 'utf8')
|
||||
const [paperWidth, setPaperWidth] = useState(String((initial?.config as any)?.paper_width ?? 576))
|
||||
|
||||
const loadPorts = () => {
|
||||
if (!wsOnline) return
|
||||
@@ -290,6 +292,10 @@ function DeviceForm({
|
||||
if (type === 'printer' && connection === 'windows' && windowsPrinter.trim()) {
|
||||
configData.windows_printer = windowsPrinter.trim()
|
||||
}
|
||||
if (type === 'printer' && connection === 'network') {
|
||||
configData.encoding = encoding
|
||||
configData.paper_width = Number(paperWidth) || 576
|
||||
}
|
||||
|
||||
await onSave({
|
||||
type,
|
||||
@@ -451,25 +457,52 @@ function DeviceForm({
|
||||
)}
|
||||
|
||||
{connection === 'network' && (
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
<div className="col-span-2">
|
||||
<label className="block text-xs font-medium text-slate-500 mb-1">IP адрес / хост</label>
|
||||
<input
|
||||
value={networkHost}
|
||||
onChange={e => setNetworkHost(e.target.value)}
|
||||
className="w-full input text-sm font-mono"
|
||||
placeholder={type === 'netup' ? '172.16.0.12' : '192.168.1.50'}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-slate-500 mb-1">Порт</label>
|
||||
<input
|
||||
value={networkPort}
|
||||
onChange={e => setNetworkPort(e.target.value)}
|
||||
className="w-full input text-sm font-mono"
|
||||
placeholder={type === 'netup' ? '8880' : '9100'}
|
||||
/>
|
||||
<div className="space-y-3">
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
<div className="col-span-2">
|
||||
<label className="block text-xs font-medium text-slate-500 mb-1">IP адрес / хост</label>
|
||||
<input
|
||||
value={networkHost}
|
||||
onChange={e => setNetworkHost(e.target.value)}
|
||||
className="w-full input text-sm font-mono"
|
||||
placeholder={type === 'netup' ? '172.16.0.12' : '192.168.1.50'}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-slate-500 mb-1">Порт</label>
|
||||
<input
|
||||
value={networkPort}
|
||||
onChange={e => setNetworkPort(e.target.value)}
|
||||
className="w-full input text-sm font-mono"
|
||||
placeholder={type === 'netup' ? '8880' : '9100'}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{type === 'printer' && (
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-slate-500 mb-1">Кодировка</label>
|
||||
<select
|
||||
value={encoding}
|
||||
onChange={e => setEncoding(e.target.value as 'utf8' | 'cp866')}
|
||||
className="w-full input text-sm"
|
||||
>
|
||||
<option value="utf8">UTF-8</option>
|
||||
<option value="cp866">CP866 (DOS Кириллица)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-slate-500 mb-1">Ширина ленты (точек)</label>
|
||||
<input
|
||||
value={paperWidth}
|
||||
onChange={e => setPaperWidth(e.target.value)}
|
||||
className="w-full input text-sm font-mono"
|
||||
placeholder="576"
|
||||
/>
|
||||
<p className="text-xs text-slate-400 mt-1">58мм=384, 80мм=576</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -766,7 +799,7 @@ function WorkstationCard({
|
||||
<Wifi size={13} />
|
||||
Подключить агента
|
||||
</button>
|
||||
) : (
|
||||
) : !ws.isOnline ? (
|
||||
<button
|
||||
onClick={() => setShowPairModal(true)}
|
||||
className="btn-ghost p-1.5 text-slate-400"
|
||||
@@ -774,7 +807,7 @@ function WorkstationCard({
|
||||
>
|
||||
<RefreshCw size={14} />
|
||||
</button>
|
||||
)}
|
||||
) : null}
|
||||
|
||||
<button onClick={deleteWs} className="btn-ghost p-1.5 text-slate-400 hover:text-red-500">
|
||||
<Trash2 size={14} />
|
||||
|
||||
Reference in New Issue
Block a user