фикс страницы объекта
This commit is contained in:
parent
13ef5fed73
commit
1e9592f013
1 changed files with 18 additions and 46 deletions
|
|
@ -25,7 +25,6 @@ import {
|
|||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
Switch,
|
||||
Table,
|
||||
Tag,
|
||||
Tooltip,
|
||||
|
|
@ -72,9 +71,9 @@ type GroupRow = {
|
|||
type DeviceRow = DeviceItem & { _type: 'device' }
|
||||
type TableRow = GroupRow | DeviceRow
|
||||
|
||||
// Inventory cols: IP, Hostname, Rack, Category, Ping+Status, Source, Actions = 7
|
||||
// Inventory cols: IP, Hostname, Category, Ping+Status, Source, Actions = 6
|
||||
// Work cols: IP, Hostname, Category, Ping+Status, Actions = 5
|
||||
const COL_SPAN: Record<Mode, number> = { inventory: 7, work: 5 }
|
||||
const COL_SPAN: Record<Mode, number> = { inventory: 6, work: 5 }
|
||||
|
||||
function PingButton({
|
||||
scope,
|
||||
|
|
@ -127,7 +126,6 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
|
|||
const queryClient = useQueryClient()
|
||||
|
||||
const [mode, setMode] = useState<Mode>(defaultMode)
|
||||
const [editMode, setEditMode] = useState(false)
|
||||
|
||||
const toggleMode = () => setMode((m) => (m === 'inventory' ? 'work' : 'inventory'))
|
||||
|
||||
|
|
@ -397,19 +395,6 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
|
|||
)
|
||||
},
|
||||
},
|
||||
...(mode === 'inventory' ? [{
|
||||
title: 'Стойка / локация',
|
||||
key: 'location',
|
||||
onCell: (row: TableRow) => row._type === 'group' ? { colSpan: 0 } : {},
|
||||
render: (_: unknown, row: TableRow) => {
|
||||
if (row._type === 'group') return null
|
||||
const d = row as DeviceRow
|
||||
if (d.rack_name) return <Tag color="blue">{rackLabel(d.rack_name, d.rack_type)}</Tag>
|
||||
if (d.location === 'server_room') return <Tag color="purple">Серверная</Tag>
|
||||
if (d.location === 'street') return <Tag color="orange">Улица</Tag>
|
||||
return <Typography.Text type="secondary">—</Typography.Text>
|
||||
},
|
||||
}] : []),
|
||||
{
|
||||
title: 'Категория',
|
||||
dataIndex: 'category',
|
||||
|
|
@ -509,7 +494,6 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
|
|||
</Button>
|
||||
)
|
||||
}
|
||||
if (!editMode) return null
|
||||
return (
|
||||
<Space>
|
||||
<Button size="small" icon={<EditOutlined />} onClick={() => { setEditDevice(d); setDeviceModal(true) }} />
|
||||
|
|
@ -622,16 +606,14 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
|
|||
<Row justify="space-between" align="middle" style={{ marginBottom: 16 }}>
|
||||
<Col><Breadcrumb items={breadcrumbItems} /></Col>
|
||||
<Col>
|
||||
<div onClick={toggleMode} style={{ cursor: 'pointer' }}>
|
||||
<Segmented
|
||||
value={mode}
|
||||
options={[
|
||||
{ label: 'Инвентарь', value: 'inventory', icon: <DatabaseOutlined /> },
|
||||
{ label: 'Работа', value: 'work', icon: <ControlOutlined /> },
|
||||
]}
|
||||
onChange={() => {}}
|
||||
onChange={(v) => setMode(v as Mode)}
|
||||
/>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
|
|
@ -703,25 +685,15 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
|
|||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* Search + edit toggle + delete all */}
|
||||
{/* Search */}
|
||||
<Row justify="space-between" align="middle" style={{ marginBottom: 12 }}>
|
||||
<Col>
|
||||
<Space>
|
||||
<Input.Search
|
||||
placeholder="Поиск по IP или hostname..."
|
||||
allowClear
|
||||
style={{ width: 360 }}
|
||||
onChange={(e) => setSearchText(e.target.value)}
|
||||
/>
|
||||
{mode === 'inventory' && (
|
||||
<Space size={6}>
|
||||
<Switch size="small" checked={editMode} onChange={setEditMode} />
|
||||
<Typography.Text type="secondary" style={{ fontSize: 13 }}>
|
||||
Режим редактирования
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
)}
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue