фикс страницы объекта
This commit is contained in:
parent
13ef5fed73
commit
1e9592f013
1 changed files with 18 additions and 46 deletions
|
|
@ -25,7 +25,6 @@ import {
|
||||||
Select,
|
Select,
|
||||||
Space,
|
Space,
|
||||||
Spin,
|
Spin,
|
||||||
Switch,
|
|
||||||
Table,
|
Table,
|
||||||
Tag,
|
Tag,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
|
|
@ -72,9 +71,9 @@ type GroupRow = {
|
||||||
type DeviceRow = DeviceItem & { _type: 'device' }
|
type DeviceRow = DeviceItem & { _type: 'device' }
|
||||||
type TableRow = GroupRow | DeviceRow
|
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
|
// 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({
|
function PingButton({
|
||||||
scope,
|
scope,
|
||||||
|
|
@ -127,7 +126,6 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
const [mode, setMode] = useState<Mode>(defaultMode)
|
const [mode, setMode] = useState<Mode>(defaultMode)
|
||||||
const [editMode, setEditMode] = useState(false)
|
|
||||||
|
|
||||||
const toggleMode = () => setMode((m) => (m === 'inventory' ? 'work' : 'inventory'))
|
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: 'Категория',
|
title: 'Категория',
|
||||||
dataIndex: 'category',
|
dataIndex: 'category',
|
||||||
|
|
@ -509,7 +494,6 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (!editMode) return null
|
|
||||||
return (
|
return (
|
||||||
<Space>
|
<Space>
|
||||||
<Button size="small" icon={<EditOutlined />} onClick={() => { setEditDevice(d); setDeviceModal(true) }} />
|
<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 }}>
|
<Row justify="space-between" align="middle" style={{ marginBottom: 16 }}>
|
||||||
<Col><Breadcrumb items={breadcrumbItems} /></Col>
|
<Col><Breadcrumb items={breadcrumbItems} /></Col>
|
||||||
<Col>
|
<Col>
|
||||||
<div onClick={toggleMode} style={{ cursor: 'pointer' }}>
|
<Segmented
|
||||||
<Segmented
|
value={mode}
|
||||||
value={mode}
|
options={[
|
||||||
options={[
|
{ label: 'Инвентарь', value: 'inventory', icon: <DatabaseOutlined /> },
|
||||||
{ label: 'Инвентарь', value: 'inventory', icon: <DatabaseOutlined /> },
|
{ label: 'Работа', value: 'work', icon: <ControlOutlined /> },
|
||||||
{ label: 'Работа', value: 'work', icon: <ControlOutlined /> },
|
]}
|
||||||
]}
|
onChange={(v) => setMode(v as Mode)}
|
||||||
onChange={() => {}}
|
/>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
|
|
@ -703,25 +685,15 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
{/* Search + edit toggle + delete all */}
|
{/* Search */}
|
||||||
<Row justify="space-between" align="middle" style={{ marginBottom: 12 }}>
|
<Row justify="space-between" align="middle" style={{ marginBottom: 12 }}>
|
||||||
<Col>
|
<Col>
|
||||||
<Space>
|
<Input.Search
|
||||||
<Input.Search
|
placeholder="Поиск по IP или hostname..."
|
||||||
placeholder="Поиск по IP или hostname..."
|
allowClear
|
||||||
allowClear
|
style={{ width: 360 }}
|
||||||
style={{ width: 360 }}
|
onChange={(e) => setSearchText(e.target.value)}
|
||||||
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>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue