mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-15 03:11:38 +00:00
Added server initiated Agent update
This commit is contained in:
@@ -187,6 +187,16 @@ const HostDetail = () => {
|
||||
},
|
||||
});
|
||||
|
||||
// Force agent update mutation
|
||||
const forceAgentUpdateMutation = useMutation({
|
||||
mutationFn: () =>
|
||||
adminHostsAPI.forceAgentUpdate(hostId).then((res) => res.data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(["host", hostId]);
|
||||
queryClient.invalidateQueries(["hosts"]);
|
||||
},
|
||||
});
|
||||
|
||||
const updateFriendlyNameMutation = useMutation({
|
||||
mutationFn: (friendlyName) =>
|
||||
adminHostsAPI
|
||||
@@ -703,6 +713,29 @@ const HostDetail = () => {
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300 mb-1.5">
|
||||
Force Update
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => forceAgentUpdateMutation.mutate()}
|
||||
disabled={forceAgentUpdateMutation.isPending}
|
||||
className="flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20 border border-primary-200 dark:border-primary-800 rounded-md hover:bg-primary-100 dark:hover:bg-primary-900/40 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
<RefreshCw
|
||||
className={`h-3 w-3 ${
|
||||
forceAgentUpdateMutation.isPending
|
||||
? "animate-spin"
|
||||
: ""
|
||||
}`}
|
||||
/>
|
||||
{forceAgentUpdateMutation.isPending
|
||||
? "Updating..."
|
||||
: "Update Now"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -95,6 +95,7 @@ export const adminHostsAPI = {
|
||||
api.put("/hosts/bulk/groups", { hostIds, groupIds }),
|
||||
toggleAutoUpdate: (hostId, autoUpdate) =>
|
||||
api.patch(`/hosts/${hostId}/auto-update`, { auto_update: autoUpdate }),
|
||||
forceAgentUpdate: (hostId) => api.post(`/hosts/${hostId}/force-agent-update`),
|
||||
updateFriendlyName: (hostId, friendlyName) =>
|
||||
api.patch(`/hosts/${hostId}/friendly-name`, {
|
||||
friendly_name: friendlyName,
|
||||
|
||||
Reference in New Issue
Block a user