Skip to content

Commit

Permalink
Merge pull request #20 from conlan0/develop
Browse files Browse the repository at this point in the history
Add Shutdown option to agent action menu
  • Loading branch information
wh1te909 authored Feb 22, 2024
2 parents 23bf81e + 38dc709 commit 07cc6ac
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/api/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ export async function agentRebootNow(agent_id) {
return data;
}

export async function agentShutdown(agent_id) {
const { data } = await axios.post(`${baseUrl}/${agent_id}/shutdown/`);
return data;
}

export async function sendAgentRecoverMesh(agent_id, params = {}) {
const { data } = await axios.post(
`${baseUrl}/${agent_id}/meshcentral/recover/`,
Expand Down
35 changes: 35 additions & 0 deletions src/components/agents/AgentActionMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@
</q-menu>
</q-item>

<q-item clickable v-close-popup @click="shutdown(agent)">
<q-item-section side>
<q-icon size="xs" name="power" />
</q-item-section>
<q-item-section>Shutdown</q-item-section>
</q-item>

<q-item clickable v-close-popup @click="showPolicyAdd(agent)">
<q-item-section side>
<q-icon size="xs" name="policy" />
Expand Down Expand Up @@ -231,6 +238,7 @@ import { fetchURLActions, runURLAction } from "@/api/core";
import {
editAgent,
agentRebootNow,
agentShutdown,
sendAgentPing,
removeAgent,
runRemoteBackground,
Expand Down Expand Up @@ -437,6 +445,32 @@ export default {
});
}
function shutdown(agent) {
$q.dialog({
title:
'Please type <code style="color:red">yes</code> in the box below to confirm shutdown.',
prompt: {
model: "",
type: "text",
isValid: (val) => val === "yes",
},
cancel: true,
ok: { label: "Shutdown", color: "negative" },
persistent: true,
html: true,
}).onOk(async () => {
$q.loading.show();
try {
await agentShutdown(agent.agent_id);
notifySuccess(`${agent.hostname} will now be shutdown`);
$q.loading.hide();
} catch (e) {
$q.loading.hide();
console.error(e);
}
});
}
function showPolicyAdd(agent) {
$q.dialog({
component: PolicyAdd,
Expand Down Expand Up @@ -534,6 +568,7 @@ export default {
runChecks,
showRebootLaterModal,
rebootNow,
shutdown,
showPolicyAdd,
showAgentRecovery,
pingAgent,
Expand Down

0 comments on commit 07cc6ac

Please sign in to comment.