fix: migration runner and scan logging fixes
- Fix migration conflicts and duplicate key errors - Remove duplicate scan logging from agents - Fix AgentHealth UI and Storage page triggers - Prevent scans from appearing on wrong pages Fixes duplicate key violations on fresh installs and storage scans appearing on Updates page.
This commit is contained in:
@@ -227,31 +227,25 @@ export function AgentHealth({ agentId }: AgentHealthProps) {
|
||||
};
|
||||
|
||||
// Get package manager badges based on OS type
|
||||
const getPackageManagerBadges = (osType: string) => {
|
||||
const getPackageManagerStatus = (pm: string, osType: string) => {
|
||||
const os = osType.toLowerCase();
|
||||
const badges = [];
|
||||
|
||||
if (os.includes('windows')) {
|
||||
badges.push(
|
||||
<span key="windows" className="text-[10px] px-1 py-0.5 bg-blue-100 rounded text-blue-700">Windows</span>,
|
||||
<span key="winget" className="text-[10px] px-1 py-0.5 bg-blue-100 rounded text-blue-700">Winget</span>
|
||||
);
|
||||
} else if (os.includes('fedora') || os.includes('rhel') || os.includes('centos')) {
|
||||
badges.push(
|
||||
<span key="dnf" className="text-[10px] px-1 py-0.5 bg-green-100 rounded text-green-700">DNF</span>
|
||||
);
|
||||
} else if (os.includes('debian') || os.includes('ubuntu') || os.includes('linux')) {
|
||||
badges.push(
|
||||
<span key="apt" className="text-[10px] px-1 py-0.5 bg-purple-100 rounded text-purple-700">APT</span>
|
||||
);
|
||||
switch (pm) {
|
||||
case 'apt': return os.includes('debian') || os.includes('ubuntu');
|
||||
case 'dnf': return os.includes('fedora') || os.includes('rhel') || os.includes('centos');
|
||||
case 'winget': return os.includes('windows');
|
||||
case 'windows': return os.includes('windows');
|
||||
default: return false;
|
||||
}
|
||||
};
|
||||
|
||||
const getPackageManagerBadgeStyle = (pm: string) => {
|
||||
switch (pm) {
|
||||
case 'apt': return 'bg-purple-100 text-purple-700';
|
||||
case 'dnf': return 'bg-green-100 text-green-700';
|
||||
case 'winget': return 'bg-blue-100 text-blue-700';
|
||||
case 'windows': return 'bg-blue-100 text-blue-700';
|
||||
default: return 'bg-gray-100 text-gray-500';
|
||||
}
|
||||
|
||||
// Docker is cross-platform
|
||||
badges.push(
|
||||
<span key="docker" className="text-[10px] px-1 py-0.5 bg-gray-100 rounded text-gray-600">Docker</span>
|
||||
);
|
||||
|
||||
return badges;
|
||||
};
|
||||
|
||||
const frequencyOptions = [
|
||||
@@ -337,11 +331,27 @@ export function AgentHealth({ agentId }: AgentHealthProps) {
|
||||
<div className="font-medium">{config.name}</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
{subsystem.subsystem === 'updates' ? (
|
||||
<div className="flex items-center space-x-1">
|
||||
<span>Scans for available package updates</span>
|
||||
<div className="flex items-center space-x-1 ml-1">
|
||||
{getPackageManagerBadges(agent?.os_type || '')}
|
||||
</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
<span>Scans for available package updates (</span>
|
||||
{['apt', 'dnf', 'winget', 'windows'].map((pm, index) => {
|
||||
const isEnabled = getPackageManagerStatus(pm, agent?.os_type || '');
|
||||
const isLast = index === 3;
|
||||
|
||||
return (
|
||||
<span key={pm}>
|
||||
{index > 0 && ', '}
|
||||
<span className={cn(
|
||||
'text-[10px] px-1 py-0.5 rounded',
|
||||
isEnabled
|
||||
? getPackageManagerBadgeStyle(pm)
|
||||
: 'bg-gray-100 text-gray-500'
|
||||
)}>
|
||||
{pm === 'windows' ? 'Windows Update' : pm.toUpperCase()}
|
||||
</span>
|
||||
{isLast && ')'}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
config.description
|
||||
|
||||
@@ -66,13 +66,13 @@ export function AgentStorage({ agentId }: AgentStorageProps) {
|
||||
const handleFullStorageScan = async () => {
|
||||
setIsScanning(true);
|
||||
try {
|
||||
// Trigger a system scan to get full disk inventory
|
||||
await agentApi.scanAgent(agentId);
|
||||
toast.success('Full storage scan initiated');
|
||||
// Trigger storage scan only (not full system scan)
|
||||
await agentApi.triggerSubsystem(agentId, 'storage');
|
||||
toast.success('Storage scan initiated');
|
||||
|
||||
// Refresh data after a short delay
|
||||
setTimeout(() => {
|
||||
refetchAgent();
|
||||
refetchStorage();
|
||||
setIsScanning(false);
|
||||
}, 3000);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user