Implement immediate deployment, and automatically load scheduled tasks when the service starts.

This commit is contained in:
yoan
2024-08-21 16:34:28 +08:00
parent 90967fc2e1
commit f6760515e9
16 changed files with 539 additions and 238 deletions

View File

@@ -1,19 +1,35 @@
import DeployProgress from "@/components/certimate/DeployProgress";
import Show from "@/components/Show";
import {
AlertDialogAction,
AlertDialogCancel,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialog,
AlertDialogContent,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { Switch } from "@/components/ui/switch";
import { Toaster } from "@/components/ui/toaster";
import { Tooltip, TooltipTrigger } from "@/components/ui/tooltip";
import { useToast } from "@/components/ui/use-toast";
import { Domain } from "@/domain/domain";
import { convertZulu2Beijing, getDate } from "@/lib/time";
import { list, remove, save } from "@/repository/domains";
import { TooltipContent, TooltipProvider } from "@radix-ui/react-tooltip";
import { CircleCheck, CircleX, Earth } from "lucide-react";
import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { Link, useNavigate } from "react-router-dom";
const Home = () => {
const toast = useToast();
const navigate = useNavigate();
const handleCreateClick = () => {
navigate("/edit");
@@ -64,6 +80,37 @@ const Home = () => {
setDomains(updatedDomains);
};
const handleRightNowClick = async (domain: Domain) => {
try {
domain.rightnow = true;
const resp = await save(domain);
const updatedDomains = domains.map((domain) => {
if (domain.id === resp.id) {
return { ...resp };
}
return domain;
});
setDomains(updatedDomains);
} catch (e) {
toast.toast({
title: "执行失败",
description: (
<>
<Link
to={`/history?domain=${domain.id}`}
className="underline text-blue-500"
>
</Link>
</>
),
variant: "destructive",
});
}
};
return (
<>
<div className="">
@@ -179,16 +226,46 @@ const Home = () => {
>
</Button>
<Show when={domain.enabled ? true : false}>
<Separator orientation="vertical" className="h-4 mx-2" />
<Button
variant={"link"}
className="p-0"
onClick={() => handleRightNowClick(domain)}
>
</Button>
</Show>
{!domain.enabled && (
<>
<Separator orientation="vertical" className="h-4 mx-2" />
<Button
variant={"link"}
className="p-0"
onClick={() => handleDeleteClick(domain.id)}
>
</Button>
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant={"link"} className="p-0">
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle></AlertDialogTitle>
<AlertDialogDescription>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel></AlertDialogCancel>
<AlertDialogAction
onClick={() => {
handleDeleteClick(domain.id);
}}
>
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<Separator orientation="vertical" className="h-4 mx-2" />
<Button
variant={"link"}