mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-10-23 07:42:05 +00:00
Fixed issues with the agent not sending apt data properly
Added Indexing to the database for faster and efficient searching Fixed some filtering from the hosts page relating to packages that need updating Added buy me a coffee link (sorry and thank you <3)
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1012,13 +1012,15 @@ const HostDetail = () => {
|
||||
{host.stats.total_packages}
|
||||
</p>
|
||||
<p className="text-sm text-secondary-500 dark:text-secondary-300">
|
||||
Total Packages
|
||||
Total Installed
|
||||
</p>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => navigate(`/packages?host=${hostId}`)}
|
||||
onClick={() =>
|
||||
navigate(`/packages?host=${hostId}&filter=outdated`)
|
||||
}
|
||||
className="text-center p-4 bg-warning-50 dark:bg-warning-900/20 rounded-lg hover:bg-warning-100 dark:hover:bg-warning-900/30 transition-colors group"
|
||||
title="View outdated packages for this host"
|
||||
>
|
||||
|
@@ -870,9 +870,11 @@ const Hosts = () => {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => navigate(`/packages?host=${host.id}`)}
|
||||
onClick={() =>
|
||||
navigate(`/packages?host=${host.id}&filter=outdated`)
|
||||
}
|
||||
className="text-sm text-primary-600 hover:text-primary-900 dark:text-primary-400 dark:hover:text-primary-300 font-medium hover:underline"
|
||||
title="View packages for this host"
|
||||
title="View outdated packages for this host"
|
||||
>
|
||||
{host.updatesCount || 0}
|
||||
</button>
|
||||
|
@@ -115,8 +115,20 @@ const Packages = () => {
|
||||
refetch,
|
||||
isFetching,
|
||||
} = useQuery({
|
||||
queryKey: ["packages"],
|
||||
queryFn: () => packagesAPI.getAll({ limit: 1000 }).then((res) => res.data),
|
||||
queryKey: ["packages", hostFilter, updateStatusFilter],
|
||||
queryFn: () => {
|
||||
const params = { limit: 10000 }; // High limit to effectively get all packages
|
||||
if (hostFilter && hostFilter !== "all") {
|
||||
params.host = hostFilter;
|
||||
}
|
||||
// Pass update status filter to backend to pre-filter packages
|
||||
if (updateStatusFilter === "needs-updates") {
|
||||
params.needsUpdate = "true";
|
||||
} else if (updateStatusFilter === "security-updates") {
|
||||
params.isSecurityUpdate = "true";
|
||||
}
|
||||
return packagesAPI.getAll(params).then((res) => res.data);
|
||||
},
|
||||
staleTime: 5 * 60 * 1000, // Data stays fresh for 5 minutes
|
||||
refetchOnWindowFocus: false, // Don't refetch when window regains focus
|
||||
});
|
||||
@@ -160,15 +172,13 @@ const Packages = () => {
|
||||
|
||||
const matchesUpdateStatus =
|
||||
updateStatusFilter === "all-packages" ||
|
||||
updateStatusFilter === "needs-updates" ||
|
||||
(updateStatusFilter === "security-updates" && pkg.isSecurityUpdate) ||
|
||||
(updateStatusFilter === "regular-updates" && !pkg.isSecurityUpdate);
|
||||
|
||||
// For "all-packages", we don't filter by update status
|
||||
// For other filters, we only show packages that need updates
|
||||
const matchesUpdateNeeded =
|
||||
updateStatusFilter === "all-packages" ||
|
||||
(pkg.stats?.updatesNeeded || 0) > 0;
|
||||
(updateStatusFilter === "needs-updates" &&
|
||||
(pkg.stats?.updatesNeeded || 0) > 0) ||
|
||||
(updateStatusFilter === "security-updates" &&
|
||||
(pkg.stats?.securityUpdates || 0) > 0) ||
|
||||
(updateStatusFilter === "regular-updates" &&
|
||||
(pkg.stats?.updatesNeeded || 0) > 0 &&
|
||||
(pkg.stats?.securityUpdates || 0) === 0);
|
||||
|
||||
const packageHosts = pkg.packageHosts || [];
|
||||
const matchesHost =
|
||||
@@ -176,11 +186,7 @@ const Packages = () => {
|
||||
packageHosts.some((host) => host.hostId === hostFilter);
|
||||
|
||||
return (
|
||||
matchesSearch &&
|
||||
matchesCategory &&
|
||||
matchesUpdateStatus &&
|
||||
matchesUpdateNeeded &&
|
||||
matchesHost
|
||||
matchesSearch && matchesCategory && matchesUpdateStatus && matchesHost
|
||||
);
|
||||
});
|
||||
|
||||
@@ -435,8 +441,16 @@ const Packages = () => {
|
||||
});
|
||||
const uniquePackageHostsCount = uniquePackageHosts.size;
|
||||
|
||||
// Calculate total packages available
|
||||
const totalPackagesCount = packages?.length || 0;
|
||||
// Calculate total packages installed
|
||||
// When filtering by host, count each package once (since it can only be installed once per host)
|
||||
// When not filtering, sum up all installations across all hosts
|
||||
const totalPackagesCount =
|
||||
hostFilter && hostFilter !== "all"
|
||||
? packages?.length || 0
|
||||
: packages?.reduce(
|
||||
(sum, pkg) => sum + (pkg.stats?.totalInstalls || 0),
|
||||
0,
|
||||
) || 0;
|
||||
|
||||
// Calculate outdated packages
|
||||
const outdatedPackagesCount =
|
||||
@@ -517,7 +531,7 @@ const Packages = () => {
|
||||
<Package className="h-5 w-5 text-primary-600 mr-2" />
|
||||
<div>
|
||||
<p className="text-sm text-secondary-500 dark:text-white">
|
||||
Total Packages
|
||||
Total Installed
|
||||
</p>
|
||||
<p className="text-xl font-semibold text-secondary-900 dark:text-white">
|
||||
{totalPackagesCount}
|
||||
|
Reference in New Issue
Block a user