From abbdfb41f226cc7368dbafbbbf6150811d06e38d Mon Sep 17 00:00:00 2001 From: dv Date: Thu, 28 May 2026 16:27:13 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D1=84=D1=84=D1=84=D1=84=D1=84=D1=84?= =?UTF-8?q?=D1=84=D1=84=D1=84=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/SnapshotDashboard.tsx | 88 +++++++++++++++--------- 1 file changed, 54 insertions(+), 34 deletions(-) diff --git a/frontend/src/pages/SnapshotDashboard.tsx b/frontend/src/pages/SnapshotDashboard.tsx index 5709b55..ac435dc 100644 --- a/frontend/src/pages/SnapshotDashboard.tsx +++ b/frontend/src/pages/SnapshotDashboard.tsx @@ -28,7 +28,7 @@ import type { ColumnsType } from 'antd/es/table' import dayjs from 'dayjs' import relativeTime from 'dayjs/plugin/relativeTime' import 'dayjs/locale/ru' -import { useMemo, useCallback, useRef, useState } from 'react' +import { useMemo, useState } from 'react' import { useSnapshotDashboard, useSnapshotPolicies, @@ -486,6 +486,31 @@ function ObjectDevicesExpanded({ ) } +function highlightIni(text: string): React.ReactNode[] { + return text.split('\n').map((line, i) => { + let node: React.ReactNode + if (/^\s*[#;]/.test(line)) { + node = {line} + } else if (/^\s*\[.+\]/.test(line)) { + node = {line} + } else if (line.includes('=')) { + const eqIdx = line.indexOf('=') + const key = line.slice(0, eqIdx) + const value = line.slice(eqIdx) + node = ( + <> + {key} + {value.charAt(0)} + {value.slice(1)} + + ) + } else { + node = {line} + } + return {node}{'\n'} + }) +} + function DevicesList({ objId, objName, @@ -498,7 +523,6 @@ function DevicesList({ const { data: devices, isLoading } = useDashboardDevices(objId, policyId, true) const [viewContent, setViewContent] = useState(null) const [viewTitle, setViewTitle] = useState('') - const contentRef = useRef(null) const handleCopy = async (snapshotId: number) => { try { @@ -537,18 +561,12 @@ function DevicesList({ } } - const handleSelectAll = useCallback((e: React.KeyboardEvent) => { - if ((e.ctrlKey || e.metaKey) && e.key === 'a') { - e.preventDefault() - if (contentRef.current) { - const range = document.createRange() - range.selectNodeContents(contentRef.current) - const sel = window.getSelection() - sel?.removeAllRanges() - sel?.addRange(range) - } + const handleViewCopy = async () => { + if (viewContent) { + await navigator.clipboard.writeText(viewContent) + message.success('Скопировано в буфер обмена') } - }, []) + } if (isLoading) return Загрузка... if (!devices || devices.length === 0) return Нет устройств @@ -637,31 +655,33 @@ function DevicesList({ title={viewTitle} open={viewContent !== null} onCancel={() => setViewContent(null)} - footer={null} + footer={ + + } width={800} maskClosable destroyOnClose > -
-
-            {viewContent}
-          
-
+
+          {viewContent && highlightIni(viewContent)}
+        
)