feat(server service): added in start stop and restart from vms036

This commit is contained in:
2025-06-09 11:42:27 -05:00
parent a4dab55f7a
commit 29e0347f84
8 changed files with 400 additions and 110 deletions

View File

@@ -7,24 +7,40 @@ import {
} from "@/components/ui/tooltip";
import axios from "axios";
import { Octagon } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";
export default function StopServer(plantData: any) {
export default function StopServer(data: any) {
const token = localStorage.getItem("auth_token");
const [disable, setDisable] = useState(false);
const handleStopServer = async (plant: string) => {
toast.success(`${plant} is being stopped please wait.`);
setDisable(true);
let data: any = {
processType: "stop",
plantToken: plant,
};
const url: string = window.location.host.split(":")[0];
if (url === "localhost") {
if (url === "localhost" || url === "usmcd1vms036") {
data = { ...data, remote: "true" };
}
//console.log(data);
try {
const res = await axios.post("/api/server/serviceprocess", data, {
headers: { Authorization: `Bearer ${token}` },
});
console.log(res);
//console.log(res);
if (res.status === 200) {
setTimeout(() => {
toast.success(`${plant} Has beed stopped.`);
setDisable(false);
}, 3000);
}
} catch (error) {
console.log(error);
}
@@ -37,15 +53,16 @@ export default function StopServer(plantData: any) {
<Button
variant="destructive"
size={"icon"}
disabled={disable}
onClick={() =>
handleStopServer(plantData.plantToken)
handleStopServer(data.plantData.plantToken)
}
>
<Octagon />
</Button>
</TooltipTrigger>
<TooltipContent>
<p>Stop Server ... Needs added still</p>
<p>Stop Server</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>