feat: CheckMK host link in inventory, system logs hidden by default in logbook
This commit is contained in:
@ -7,7 +7,7 @@ import React, { useState, useMemo } from 'react';
|
||||
import { Device, DeviceType } from '../types';
|
||||
import {
|
||||
Server, Search, Plus, Trash, Edit2, MapPin, Gauge,
|
||||
BookOpen, Save, X, Info
|
||||
BookOpen, Save, X, Info, ExternalLink
|
||||
} from 'lucide-react';
|
||||
|
||||
// Built-in device class presets shown in the dropdown.
|
||||
@ -16,6 +16,7 @@ const DEVICE_CLASS_PRESETS = ['Switch', 'Firewall', 'Access-Point', 'Controller'
|
||||
interface DeviceInventoryProps {
|
||||
devices: Device[];
|
||||
checkmkEnabled: boolean;
|
||||
checkmkBaseUrl: string;
|
||||
onAddDevice: (device: Omit<Device, 'id'>) => void;
|
||||
onUpdateDevice: (device: Device) => void;
|
||||
onDeleteDevice: (id: string) => void;
|
||||
@ -24,6 +25,7 @@ interface DeviceInventoryProps {
|
||||
export default function DeviceInventory({
|
||||
devices,
|
||||
checkmkEnabled,
|
||||
checkmkBaseUrl,
|
||||
onAddDevice,
|
||||
onUpdateDevice,
|
||||
onDeleteDevice,
|
||||
@ -62,6 +64,10 @@ export default function DeviceInventory({
|
||||
});
|
||||
|
||||
const effectiveStatus = (d: Device): 'online' | 'offline' | 'unknown' => d.status;
|
||||
const cmkHostUrl = (d: Device) =>
|
||||
checkmkEnabled && checkmkBaseUrl && d.cmkHostname
|
||||
? `${checkmkBaseUrl}/index.py?host=${encodeURIComponent(d.cmkHostname)}`
|
||||
: null;
|
||||
|
||||
const statusMeta = (s: 'online' | 'offline' | 'unknown') => {
|
||||
if (s === 'online') return { label: 'online', badge: 'bg-emerald-950/60 border-emerald-900/80 text-emerald-400', dot: 'bg-emerald-400' };
|
||||
@ -330,6 +336,17 @@ export default function DeviceInventory({
|
||||
|
||||
{/* Action Panel */}
|
||||
<div className="flex items-center gap-1.5 border-l border-slate-800/80 pl-3">
|
||||
{cmkHostUrl(device) && (
|
||||
<a
|
||||
href={cmkHostUrl(device)!}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="p-1 px-1.5 rounded hover:bg-slate-800 text-slate-400 hover:text-cyan-400 transition-colors"
|
||||
title="Open host in CheckMK"
|
||||
>
|
||||
<ExternalLink className="w-3.5 h-3.5" />
|
||||
</a>
|
||||
)}
|
||||
<button
|
||||
onClick={() => handleOpenEdit(device)}
|
||||
className="p-1 px-1.5 rounded hover:bg-slate-800 text-slate-400 hover:text-indigo-400 transition-colors"
|
||||
@ -400,6 +417,17 @@ export default function DeviceInventory({
|
||||
</span>
|
||||
); })()}
|
||||
</div>
|
||||
{cmkHostUrl(selectedDevice) && (
|
||||
<a
|
||||
href={cmkHostUrl(selectedDevice)!}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center justify-center gap-1.5 px-3 py-1.5 bg-slate-900 border border-slate-700 text-slate-200 hover:text-cyan-400 hover:border-cyan-500 rounded text-xs transition-colors font-mono"
|
||||
>
|
||||
<ExternalLink className="w-3.5 h-3.5" />
|
||||
Open host in CheckMK
|
||||
</a>
|
||||
)}
|
||||
{selectedDevice.lastCheckedAt && (
|
||||
<p className="text-[10px] text-slate-500 font-mono">
|
||||
Last checked: {new Date(selectedDevice.lastCheckedAt).toLocaleString()}
|
||||
|
||||
Reference in New Issue
Block a user