mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-02-04 12:40:08 +00:00
further implementing service page (#3)
This commit is contained in:
32
package-lock.json
generated
32
package-lock.json
generated
@@ -15,6 +15,7 @@
|
|||||||
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
||||||
"@radix-ui/react-label": "^2.1.0",
|
"@radix-ui/react-label": "^2.1.0",
|
||||||
"@radix-ui/react-navigation-menu": "^1.2.1",
|
"@radix-ui/react-navigation-menu": "^1.2.1",
|
||||||
|
"@radix-ui/react-scroll-area": "^1.2.1",
|
||||||
"@radix-ui/react-select": "^2.1.2",
|
"@radix-ui/react-select": "^2.1.2",
|
||||||
"@radix-ui/react-slot": "^1.1.0",
|
"@radix-ui/react-slot": "^1.1.0",
|
||||||
"@tanstack/react-table": "^8.20.5",
|
"@tanstack/react-table": "^8.20.5",
|
||||||
@@ -1695,6 +1696,37 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-scroll-area": {
|
||||||
|
"version": "1.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-scroll-area/-/react-scroll-area-1.2.1.tgz",
|
||||||
|
"integrity": "sha512-FnM1fHfCtEZ1JkyfH/1oMiTcFBQvHKl4vD9WnpwkLgtF+UmnXMCad6ECPTaAjcDjam+ndOEJWgHyKDGNteWSHw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@radix-ui/number": "1.1.0",
|
||||||
|
"@radix-ui/primitive": "1.1.0",
|
||||||
|
"@radix-ui/react-compose-refs": "1.1.0",
|
||||||
|
"@radix-ui/react-context": "1.1.1",
|
||||||
|
"@radix-ui/react-direction": "1.1.0",
|
||||||
|
"@radix-ui/react-presence": "1.1.1",
|
||||||
|
"@radix-ui/react-primitive": "2.0.0",
|
||||||
|
"@radix-ui/react-use-callback-ref": "1.1.0",
|
||||||
|
"@radix-ui/react-use-layout-effect": "1.1.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"@types/react-dom": "*",
|
||||||
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||||
|
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/react-dom": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/react-select": {
|
"node_modules/@radix-ui/react-select": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.1.2.tgz",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
||||||
"@radix-ui/react-label": "^2.1.0",
|
"@radix-ui/react-label": "^2.1.0",
|
||||||
"@radix-ui/react-navigation-menu": "^1.2.1",
|
"@radix-ui/react-navigation-menu": "^1.2.1",
|
||||||
|
"@radix-ui/react-scroll-area": "^1.2.1",
|
||||||
"@radix-ui/react-select": "^2.1.2",
|
"@radix-ui/react-select": "^2.1.2",
|
||||||
"@radix-ui/react-slot": "^1.1.0",
|
"@radix-ui/react-slot": "^1.1.0",
|
||||||
"@tanstack/react-table": "^8.20.5",
|
"@tanstack/react-table": "^8.20.5",
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ import { ModelServiceForm } from "@/types"
|
|||||||
import { fetcher, FetcherMethod } from "./api"
|
import { fetcher, FetcherMethod } from "./api"
|
||||||
|
|
||||||
export const createService = async (data: ModelServiceForm): Promise<number> => {
|
export const createService = async (data: ModelServiceForm): Promise<number> => {
|
||||||
return fetcher<number>(FetcherMethod.POST, '/api/v1/profile', data)
|
return fetcher<number>(FetcherMethod.POST, '/api/v1/service', data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateService = async (id: number, data: ModelServiceForm): Promise<void> => {
|
export const updateService = async (id: number, data: ModelServiceForm): Promise<void> => {
|
||||||
return fetcher<void>(FetcherMethod.PATCH, `/api/v1/profile/${id}`, data)
|
return fetcher<void>(FetcherMethod.PATCH, `/api/v1/service/${id}`, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteService = async (id: number[]): Promise<void> => {
|
export const deleteService = async (id: number[]): Promise<void> => {
|
||||||
|
|||||||
50
src/components/action-button-group.tsx
Normal file
50
src/components/action-button-group.tsx
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { TrashButton } from "@/components/xui/icon-buttons";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
DialogClose,
|
||||||
|
} from "@/components/ui/dialog"
|
||||||
|
import { KeyedMutator } from "swr";
|
||||||
|
|
||||||
|
interface ButtonGroupProps<T> {
|
||||||
|
className?: string;
|
||||||
|
children: React.ReactNode;
|
||||||
|
delete: { fn: (id: number[]) => Promise<void>, id: number, mutate: KeyedMutator<T> };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ActionButtonGroup<T>({ className, children, delete: { fn, id, mutate } }: ButtonGroupProps<T>) {
|
||||||
|
const handleDelete = async () => {
|
||||||
|
await fn([id]);
|
||||||
|
await mutate();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={className}>
|
||||||
|
{children}
|
||||||
|
<Dialog>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<TrashButton variant="outline" />
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogContent className="sm:max-w-lg">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>Confirm Deletion?</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
This operation is unrecoverable!
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<DialogFooter>
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button type="submit" variant="destructive" onClick={handleDelete}>Confirm</Button>
|
||||||
|
</DialogClose>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
64
src/components/header-button-group.tsx
Normal file
64
src/components/header-button-group.tsx
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { TrashButton } from "@/components/xui/icon-buttons";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
DialogClose,
|
||||||
|
} from "@/components/ui/dialog"
|
||||||
|
import { KeyedMutator } from "swr";
|
||||||
|
import { toast } from "sonner"
|
||||||
|
|
||||||
|
interface ButtonGroupProps<T> {
|
||||||
|
className?: string;
|
||||||
|
children: React.ReactNode;
|
||||||
|
delete: { fn: (id: number[]) => Promise<void>, id: number[], mutate: KeyedMutator<T> };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function HeaderButtonGroup<T>({ className, children, delete: { fn, id, mutate } }: ButtonGroupProps<T>) {
|
||||||
|
const handleDelete = async () => {
|
||||||
|
await fn(id);
|
||||||
|
await mutate();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={className}>
|
||||||
|
{id.length < 1 ? (
|
||||||
|
<>
|
||||||
|
<TrashButton variant="destructive" onClick={() => {
|
||||||
|
toast("Error", {
|
||||||
|
description: "No rows are selected."
|
||||||
|
});
|
||||||
|
}} />
|
||||||
|
{children}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Dialog>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<TrashButton variant="destructive" />
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogContent className="sm:max-w-lg">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>Confirm Deletion?</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
This operation is unrecoverable!
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<DialogFooter>
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button type="submit" variant="destructive" onClick={handleDelete}>Confirm</Button>
|
||||||
|
</DialogClose>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
{children}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -13,12 +13,14 @@ import { NzNavigationMenuLink } from "./xui/navigation-menu";
|
|||||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "./ui/dropdown-menu";
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "./ui/dropdown-menu";
|
||||||
import { User, LogOut } from "lucide-react";
|
import { User, LogOut } from "lucide-react";
|
||||||
import { useAuth } from "@/hooks/useAuth";
|
import { useAuth } from "@/hooks/useAuth";
|
||||||
import { Link } from "react-router-dom";
|
import { Link, useLocation } from "react-router-dom";
|
||||||
|
|
||||||
|
|
||||||
export default function Header() {
|
export default function Header() {
|
||||||
const { logout } = useAuth()
|
const { logout } = useAuth();
|
||||||
const profile = useMainStore(store => store.profile)
|
const profile = useMainStore(store => store.profile);
|
||||||
|
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
return <header className="h-16 flex items-center border-b-2 px-4">
|
return <header className="h-16 flex items-center border-b-2 px-4">
|
||||||
<NavigationMenu className="max-w-full">
|
<NavigationMenu className="max-w-full">
|
||||||
<NavigationMenuList>
|
<NavigationMenuList>
|
||||||
@@ -31,12 +33,12 @@ export default function Header() {
|
|||||||
{
|
{
|
||||||
profile && <>
|
profile && <>
|
||||||
<NavigationMenuItem>
|
<NavigationMenuItem>
|
||||||
<NzNavigationMenuLink asChild active className={navigationMenuTriggerStyle()}>
|
<NzNavigationMenuLink asChild active={location.pathname === "/dashboard"} className={navigationMenuTriggerStyle()}>
|
||||||
<Link to="/dashboard">Server</Link>
|
<Link to="/dashboard">Server</Link>
|
||||||
</NzNavigationMenuLink>
|
</NzNavigationMenuLink>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
<NavigationMenuItem>
|
<NavigationMenuItem>
|
||||||
<NzNavigationMenuLink asChild className={navigationMenuTriggerStyle()}>
|
<NzNavigationMenuLink asChild active={location.pathname === "/dashboard/service"} className={navigationMenuTriggerStyle()}>
|
||||||
<Link to="/dashboard/service">Service</Link>
|
<Link to="/dashboard/service">Service</Link>
|
||||||
</NzNavigationMenuLink>
|
</NzNavigationMenuLink>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Plus } from "lucide-react"
|
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
@@ -25,184 +25,388 @@ import {
|
|||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form"
|
} from "@/components/ui/form"
|
||||||
|
import { ScrollArea } from "@/components/ui/scroll-area"
|
||||||
import { useForm } from "react-hook-form"
|
import { useForm } from "react-hook-form"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { zodResolver } from "@hookform/resolvers/zod"
|
import { zodResolver } from "@hookform/resolvers/zod"
|
||||||
import { ModelService } from "@/types"
|
import { ModelService, ModelServiceResponse } from "@/types"
|
||||||
import { createService, updateService } from "@/api/service"
|
import { createService, updateService } from "@/api/service"
|
||||||
import { Checkbox } from "./ui/checkbox"
|
import { Checkbox } from "@/components/ui/checkbox"
|
||||||
import { Label } from "./ui/label"
|
import { Label } from "@/components/ui/label"
|
||||||
|
import { conv } from "@/lib/utils"
|
||||||
|
import { useState } from "react"
|
||||||
|
import { KeyedMutator } from "swr"
|
||||||
|
import { asOptionalField } from "@/lib/utils"
|
||||||
|
import { EditButton, PlusButton } from "@/components/xui/icon-buttons"
|
||||||
|
import { serviceTypes, serviceCoverageTypes } from "@/types"
|
||||||
|
|
||||||
interface ServiceCardProps {
|
interface ServiceCardProps {
|
||||||
className?: string;
|
|
||||||
data?: ModelService;
|
data?: ModelService;
|
||||||
|
mutate: KeyedMutator<ModelServiceResponse>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const serviceFormSchema = z.object({
|
const serviceFormSchema = z.object({
|
||||||
cover: z.number(),
|
cover: z.coerce.number().min(0),
|
||||||
duration: z.number().min(30),
|
duration: z.coerce.number().min(30),
|
||||||
enable_show_in_service: z.boolean().default(false),
|
enable_show_in_service: asOptionalField(z.boolean()),
|
||||||
enable_trigger_task: z.boolean().default(false),
|
enable_trigger_task: asOptionalField(z.boolean()),
|
||||||
fail_trigger_tasks: z.array(z.number()),
|
fail_trigger_tasks: z.array(z.string()).transform((v => {
|
||||||
latency_notify: z.boolean(),
|
return v.filter(Boolean).map(Number);
|
||||||
max_latency: z.number(),
|
})),
|
||||||
min_latency: z.number(),
|
latency_notify: asOptionalField(z.boolean()),
|
||||||
name: z.string(),
|
max_latency: z.coerce.number().min(0),
|
||||||
notification_group_id: z.number(),
|
min_latency: z.coerce.number().min(0),
|
||||||
notify: z.boolean(),
|
name: z.string().min(1),
|
||||||
recover_trigger_tasks: z.array(z.number()),
|
notification_group_id: z.coerce.number(),
|
||||||
|
notify: asOptionalField(z.boolean()),
|
||||||
|
recover_trigger_tasks: z.array(z.string()).transform((v => {
|
||||||
|
return v.filter(Boolean).map(Number);
|
||||||
|
})),
|
||||||
skip_servers: z.record(z.boolean()),
|
skip_servers: z.record(z.boolean()),
|
||||||
target: z.string(),
|
target: z.string().url(),
|
||||||
type: z.number(),
|
type: z.coerce.number().min(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
const serviceTypes = {
|
export const ServiceCard: React.FC<ServiceCardProps> = ({ data, mutate }) => {
|
||||||
1: "HTTP GET (Certificate expiration and changes)",
|
|
||||||
2: "ICMP Ping",
|
|
||||||
3: "TCPing",
|
|
||||||
}
|
|
||||||
|
|
||||||
const serviceCoverageTypes = {
|
|
||||||
0: "All excludes specific servers",
|
|
||||||
1: "Only specific servers",
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ServiceCard: React.FC<ServiceCardProps> = ({ className, data }) => {
|
|
||||||
const form = useForm<z.infer<typeof serviceFormSchema>>({
|
const form = useForm<z.infer<typeof serviceFormSchema>>({
|
||||||
resolver: zodResolver(serviceFormSchema),
|
resolver: zodResolver(serviceFormSchema),
|
||||||
defaultValues: data,
|
defaultValues: data ? data : {
|
||||||
|
type: 1,
|
||||||
|
cover: 0,
|
||||||
|
name: "",
|
||||||
|
target: "",
|
||||||
|
max_latency: 0.0,
|
||||||
|
min_latency: 0.0,
|
||||||
|
duration: 30,
|
||||||
|
notification_group_id: 0,
|
||||||
|
fail_trigger_tasks: [],
|
||||||
|
recover_trigger_tasks: [],
|
||||||
|
skip_servers: {},
|
||||||
|
},
|
||||||
|
resetOptions: {
|
||||||
|
keepDefaultValues: false,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const onSubmit = (values: z.infer<typeof serviceFormSchema>) => {
|
const [open, setOpen] = useState(false);
|
||||||
data?.id ? updateService(data.id, values)
|
|
||||||
: createService(values);
|
const onSubmit = async (values: z.infer<typeof serviceFormSchema>) => {
|
||||||
|
data?.id ? await updateService(data.id, values) : await createService(values);
|
||||||
|
setOpen(false);
|
||||||
|
await mutate();
|
||||||
|
form.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
<Button className={`${className}`}>
|
{data
|
||||||
<Plus /> Add New Service
|
?
|
||||||
</Button>
|
<EditButton variant="outline" />
|
||||||
|
:
|
||||||
|
<PlusButton />
|
||||||
|
}
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className="sm:max-w-md">
|
<DialogContent className="sm:max-w-xl">
|
||||||
<DialogHeader>
|
<ScrollArea className="max-h-[calc(100dvh-5rem)] p-3">
|
||||||
<DialogTitle>New Service</DialogTitle>
|
<div className="items-center mx-1">
|
||||||
</DialogHeader>
|
<DialogHeader>
|
||||||
<div className="items-center">
|
<DialogTitle>New Service</DialogTitle>
|
||||||
<Form {...form}>
|
<DialogDescription />
|
||||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-2">
|
</DialogHeader>
|
||||||
<FormField
|
<Form {...form}>
|
||||||
control={form.control}
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-2 my-2">
|
||||||
name="name"
|
<FormField
|
||||||
render={({ field }) => (
|
control={form.control}
|
||||||
<FormItem>
|
name="name"
|
||||||
<FormLabel>Service Name</FormLabel>
|
render={({ field }) => (
|
||||||
<FormControl>
|
<FormItem>
|
||||||
<Input {...field} />
|
<FormLabel>Service Name</FormLabel>
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="target"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Target</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input type="link" placeholder="HTTP (https://t.tt)|Ping (t.tt)|TCP (t.tt:80)" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="type"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Type</FormLabel>
|
|
||||||
<Select onValueChange={field.onChange} defaultValue={`${field.value}`}>
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<SelectTrigger>
|
<Input
|
||||||
<SelectValue placeholder="Select service type" />
|
placeholder="My Service Monitor"
|
||||||
</SelectTrigger>
|
{...field}
|
||||||
</FormControl>
|
|
||||||
<SelectContent>
|
|
||||||
{Object.entries(serviceTypes).map(([k, v]) => (
|
|
||||||
<SelectItem value={k}>{v}</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="enable_show_in_service"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="flex items-center space-x-2">
|
|
||||||
<FormControl>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Checkbox
|
|
||||||
checked={field.value}
|
|
||||||
onCheckedChange={field.onChange}
|
|
||||||
/>
|
/>
|
||||||
<Label className="text-sm">Show in Service</Label>
|
|
||||||
</div>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="duration"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Interval</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input type="number" placeholder="Seconds" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="cover"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Coverage</FormLabel>
|
|
||||||
<Select onValueChange={field.onChange} defaultValue={`${field.value}`}>
|
|
||||||
<FormControl>
|
|
||||||
<SelectTrigger>
|
|
||||||
<SelectValue placeholder="Select service type" />
|
|
||||||
</SelectTrigger>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<FormMessage />
|
||||||
{Object.entries(serviceCoverageTypes).map(([k, v]) => (
|
</FormItem>
|
||||||
<SelectItem value={k}>{v}</SelectItem>
|
)}
|
||||||
))}
|
/>
|
||||||
</SelectContent>
|
<FormField
|
||||||
</Select>
|
control={form.control}
|
||||||
<FormMessage />
|
name="target"
|
||||||
</FormItem>
|
render={({ field }) => (
|
||||||
)}
|
<FormItem>
|
||||||
/>
|
<FormLabel>Target</FormLabel>
|
||||||
</form>
|
<FormControl>
|
||||||
</Form>
|
<Input
|
||||||
</div>
|
placeholder="HTTP (https://t.tt)|Ping (t.tt)|TCP (t.tt:80)"
|
||||||
<DialogFooter className="sm:justify-start">
|
{...field}
|
||||||
<DialogClose asChild>
|
/>
|
||||||
<Button type="button" variant="secondary">
|
</FormControl>
|
||||||
Close
|
<FormMessage />
|
||||||
</Button>
|
</FormItem>
|
||||||
</DialogClose>
|
)}
|
||||||
</DialogFooter>
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="type"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Type</FormLabel>
|
||||||
|
<Select onValueChange={field.onChange} defaultValue={`${field.value}`}>
|
||||||
|
<FormControl>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select service type" />
|
||||||
|
</SelectTrigger>
|
||||||
|
</FormControl>
|
||||||
|
<SelectContent>
|
||||||
|
{Object.entries(serviceTypes).map(([k, v]) => (
|
||||||
|
<SelectItem key={k} value={k}>{v}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="enable_show_in_service"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex items-center space-x-2">
|
||||||
|
<FormControl>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Checkbox
|
||||||
|
checked={field.value}
|
||||||
|
onCheckedChange={field.onChange}
|
||||||
|
/>
|
||||||
|
<Label className="text-sm">Show in Service</Label>
|
||||||
|
</div>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="duration"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Interval (s)</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
placeholder="30"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="cover"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Coverage</FormLabel>
|
||||||
|
<Select onValueChange={field.onChange} defaultValue={`${field.value}`}>
|
||||||
|
<FormControl>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select service type" />
|
||||||
|
</SelectTrigger>
|
||||||
|
</FormControl>
|
||||||
|
<SelectContent>
|
||||||
|
{Object.entries(serviceCoverageTypes).map(([k, v]) => (
|
||||||
|
<SelectItem key={k} value={k}>{v}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="skip_servers"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Specific Servers (separate with comma)</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
placeholder="1,2,3"
|
||||||
|
{...field}
|
||||||
|
value={conv.recordToStr(field.value ?? {})}
|
||||||
|
onChange={e => {
|
||||||
|
const rec = conv.strToRecord(e.target.value);
|
||||||
|
field.onChange(rec);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="notification_group_id"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Notification Group ID</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
placeholder="1"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="notify"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex items-center space-x-2">
|
||||||
|
<FormControl>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Checkbox
|
||||||
|
checked={field.value}
|
||||||
|
onCheckedChange={field.onChange}
|
||||||
|
/>
|
||||||
|
<Label className="text-sm">Enable Failure Notification</Label>
|
||||||
|
</div>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="max_latency"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Maximum Latency Time (ms)</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
placeholder="100.88"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="min_latency"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Minimum Latency Time (ms)</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
placeholder="100.88"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="latency_notify"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex items-center space-x-2">
|
||||||
|
<FormControl>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Checkbox
|
||||||
|
checked={field.value}
|
||||||
|
onCheckedChange={field.onChange}
|
||||||
|
/>
|
||||||
|
<Label className="text-sm">Enable Latency Notification</Label>
|
||||||
|
</div>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="enable_trigger_task"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex items-center space-x-2">
|
||||||
|
<FormControl>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Checkbox
|
||||||
|
checked={field.value}
|
||||||
|
onCheckedChange={field.onChange}
|
||||||
|
/>
|
||||||
|
<Label className="text-sm">Enable Trigger Task</Label>
|
||||||
|
</div>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="fail_trigger_tasks"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Tasks to trigger on an alarm (Separate with comma)</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
placeholder="1,2,3"
|
||||||
|
{...field}
|
||||||
|
value={conv.arrToStr(field.value ?? [])}
|
||||||
|
onChange={e => {
|
||||||
|
const arr = conv.strToArr(e.target.value);
|
||||||
|
field.onChange(arr);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="recover_trigger_tasks"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Tasks to trigger after recovery (Separate with comma)</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
placeholder="1,2,3"
|
||||||
|
{...field}
|
||||||
|
value={conv.arrToStr(field.value ?? [])}
|
||||||
|
onChange={e => {
|
||||||
|
const arr = conv.strToArr(e.target.value);
|
||||||
|
field.onChange(arr);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<DialogFooter className="justify-end">
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button type="button" className="my-2" variant="secondary">
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
</DialogClose>
|
||||||
|
<Button type="submit" className="my-2">Submit</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</div>
|
||||||
|
</ScrollArea>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const Checkbox = React.forwardRef<
|
|||||||
<CheckboxPrimitive.Root
|
<CheckboxPrimitive.Root
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
"flex peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
46
src/components/ui/scroll-area.tsx
Normal file
46
src/components/ui/scroll-area.tsx
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const ScrollArea = React.forwardRef<
|
||||||
|
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<ScrollAreaPrimitive.Root
|
||||||
|
ref={ref}
|
||||||
|
className={cn("relative overflow-hidden", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
||||||
|
{children}
|
||||||
|
</ScrollAreaPrimitive.Viewport>
|
||||||
|
<ScrollBar />
|
||||||
|
<ScrollAreaPrimitive.Corner />
|
||||||
|
</ScrollAreaPrimitive.Root>
|
||||||
|
))
|
||||||
|
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
|
||||||
|
|
||||||
|
const ScrollBar = React.forwardRef<
|
||||||
|
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||||
|
>(({ className, orientation = "vertical", ...props }, ref) => (
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||||
|
ref={ref}
|
||||||
|
orientation={orientation}
|
||||||
|
className={cn(
|
||||||
|
"flex touch-none select-none transition-colors",
|
||||||
|
orientation === "vertical" &&
|
||||||
|
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
||||||
|
orientation === "horizontal" &&
|
||||||
|
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
||||||
|
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||||
|
))
|
||||||
|
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
|
||||||
|
|
||||||
|
export { ScrollArea, ScrollBar }
|
||||||
15
src/components/ui/skeleton.tsx
Normal file
15
src/components/ui/skeleton.tsx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Skeleton({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn("animate-pulse rounded-md bg-muted", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Skeleton }
|
||||||
27
src/components/xui/icon-buttons.tsx
Normal file
27
src/components/xui/icon-buttons.tsx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { Plus, Edit2, Trash2 } from "lucide-react"
|
||||||
|
import { Button, ButtonProps } from "@/components/ui/button"
|
||||||
|
import { forwardRef } from "react";
|
||||||
|
|
||||||
|
export const EditButton = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
||||||
|
return (
|
||||||
|
<Button {...props} ref={ref} size="icon">
|
||||||
|
<Edit2 />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export const TrashButton = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
||||||
|
return (
|
||||||
|
<Button {...props} ref={ref} size="icon">
|
||||||
|
<Trash2 />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export const PlusButton = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
||||||
|
return (
|
||||||
|
<Button {...props} ref={ref} size="icon">
|
||||||
|
<Plus />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -32,8 +32,9 @@ export const AuthProvider = ({ children }: {
|
|||||||
|
|
||||||
const login = async (username: string, password: string) => {
|
const login = async (username: string, password: string) => {
|
||||||
try {
|
try {
|
||||||
await loginRequest(username, password)
|
await loginRequest(username, password);
|
||||||
setProfile({ username: username });
|
const user = await getProfile();
|
||||||
|
setProfile(user);
|
||||||
navigate("/dashboard");
|
navigate("/dashboard");
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
toast(error.message);
|
toast(error.message);
|
||||||
|
|||||||
@@ -1,6 +1,44 @@
|
|||||||
import { clsx, type ClassValue } from "clsx"
|
import { clsx, type ClassValue } from "clsx"
|
||||||
import { twMerge } from "tailwind-merge"
|
import { twMerge } from "tailwind-merge"
|
||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs))
|
return twMerge(clsx(inputs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const emptyStringToUndefined = z.literal('').transform(() => undefined);
|
||||||
|
|
||||||
|
export function asOptionalField<T extends z.ZodTypeAny>(schema: T) {
|
||||||
|
return schema.optional().or(emptyStringToUndefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const conv = {
|
||||||
|
recordToStr: (rec: Record<string, boolean>) => {
|
||||||
|
const arr: string[] = [];
|
||||||
|
for (const key in rec) {
|
||||||
|
arr.push(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return arr.join(',');
|
||||||
|
},
|
||||||
|
strToRecord: (str: string) => {
|
||||||
|
const arr = str.split(',');
|
||||||
|
return arr.reduce((acc, num) => {
|
||||||
|
acc[num] = true;
|
||||||
|
return acc;
|
||||||
|
}, {} as Record<string, boolean>);
|
||||||
|
},
|
||||||
|
arrToStr: <T>(arr: T[]) => {
|
||||||
|
return arr.join(',');
|
||||||
|
},
|
||||||
|
strToArr: (str: string) => {
|
||||||
|
return str.split(',');
|
||||||
|
},
|
||||||
|
recordToArr: <T>(rec: Record<string, T>) => {
|
||||||
|
const arr: T[] = [];
|
||||||
|
for (const val of Object.values(rec)) {
|
||||||
|
arr.push(val);
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { Toaster } from "@/components/ui/sonner";
|
|||||||
export default function Root() {
|
export default function Root() {
|
||||||
return (
|
return (
|
||||||
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
||||||
<Card className="text-sm max-w-6xl mx-auto mt-5 min-h-[90%] flex flex-col justify-between">
|
<Card className="text-sm max-w-7xl mx-auto mt-5 min-h-[90%] flex flex-col justify-between">
|
||||||
<div>
|
<div>
|
||||||
<Header />
|
<Header />
|
||||||
<Outlet />
|
<Outlet />
|
||||||
|
|||||||
@@ -2,11 +2,28 @@ import { swrFetcher } from "@/api/api"
|
|||||||
import { Checkbox } from "@/components/ui/checkbox"
|
import { Checkbox } from "@/components/ui/checkbox"
|
||||||
import { ServiceCard } from "@/components/service"
|
import { ServiceCard } from "@/components/service"
|
||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||||
import { ModelService as Service } from "@/types"
|
import { ModelServiceResponse, ModelServiceResponseItem as Service } from "@/types"
|
||||||
import { ColumnDef, flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table"
|
import { ColumnDef, flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table"
|
||||||
import useSWR from "swr"
|
import useSWR from "swr"
|
||||||
|
import { conv } from "@/lib/utils"
|
||||||
|
import { useEffect, useMemo } from "react"
|
||||||
|
import { serviceTypes } from "@/types"
|
||||||
|
import { ActionButtonGroup } from "@/components/action-button-group"
|
||||||
|
import { deleteService } from "@/api/service"
|
||||||
|
import { HeaderButtonGroup } from "@/components/header-button-group"
|
||||||
|
import { Skeleton } from "@/components/ui/skeleton"
|
||||||
|
import { toast } from "sonner"
|
||||||
|
|
||||||
export default function ServicePage() {
|
export default function ServicePage() {
|
||||||
|
const { data, mutate, error, isLoading } = useSWR<ModelServiceResponse>('/api/v1/service', swrFetcher)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (error)
|
||||||
|
toast("Error", {
|
||||||
|
description: "Error fetching resource.",
|
||||||
|
})
|
||||||
|
}, [error])
|
||||||
|
|
||||||
const columns: ColumnDef<Service>[] = [
|
const columns: ColumnDef<Service>[] = [
|
||||||
{
|
{
|
||||||
id: "select",
|
id: "select",
|
||||||
@@ -32,18 +49,67 @@ export default function ServicePage() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
header: "ID",
|
header: "ID",
|
||||||
accessorKey: "id",
|
accessorKey: "service.id",
|
||||||
accessorFn: (row) => row.id,
|
accessorFn: row => row.service.id,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
header: "Name",
|
header: "Name",
|
||||||
accessorKey: "name",
|
accessorKey: "service.name",
|
||||||
accessorFn: (row) => row.name,
|
accessorFn: row => row.service.name,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "Target",
|
||||||
|
accessorKey: "service.target",
|
||||||
|
accessorFn: row => row.service.target,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "Coverage",
|
||||||
|
accessorKey: "service.cover",
|
||||||
|
accessorFn: row => {
|
||||||
|
switch (row.service.cover) {
|
||||||
|
case 0: {
|
||||||
|
return "Cover All"
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
return "Ignore All"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "Specific Servers",
|
||||||
|
accessorKey: "service.skipServers",
|
||||||
|
accessorFn: row => Object.keys(row.service.skip_servers ?? {}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
header: "Type",
|
header: "Type",
|
||||||
accessorKey: "service.type",
|
accessorKey: "service.type",
|
||||||
accessorFn: (row) => row.type,
|
accessorFn: row => serviceTypes[row.service.type] || '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "Interval",
|
||||||
|
accessorKey: "service.duration",
|
||||||
|
accessorFn: row => row.service.duration,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "Notification Group ID",
|
||||||
|
accessorKey: "service.ngroup",
|
||||||
|
accessorFn: row => row.service.notification_group_id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "Enable Trigger Task",
|
||||||
|
accessorKey: "service.triggerTask",
|
||||||
|
accessorFn: row => row.service.enable_trigger_task ?? false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "Tasks to trigger on an alarm",
|
||||||
|
accessorKey: "service.failTriggerTasks",
|
||||||
|
accessorFn: row => row.service.fail_trigger_tasks,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "Tasks to trigger after recovery",
|
||||||
|
accessorKey: "service.recoverTriggerTasks",
|
||||||
|
accessorFn: row => row.service.recover_trigger_tasks,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: "actions",
|
||||||
@@ -51,68 +117,90 @@ export default function ServicePage() {
|
|||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const s = row.original
|
const s = row.original
|
||||||
return (
|
return (
|
||||||
<>{s.id}</>
|
<ActionButtonGroup className="flex gap-2" delete={{ fn: deleteService, id: s.service.id, mutate: mutate }}>
|
||||||
|
<ServiceCard mutate={mutate} data={s.service} />
|
||||||
|
</ActionButtonGroup>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
const { data, error, isLoading } = useSWR<Service[]>('/api/v1/service', swrFetcher)
|
const dataArr = useMemo(() => {
|
||||||
|
return conv.recordToArr(data?.services ?? {});
|
||||||
|
}, [data?.services]);
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data: data ?? [],
|
data: dataArr,
|
||||||
columns,
|
columns,
|
||||||
getCoreRowModel: getCoreRowModel(),
|
getCoreRowModel: getCoreRowModel(),
|
||||||
})
|
})
|
||||||
|
|
||||||
return <div className="px-9">
|
const selectedRows = table.getSelectedRowModel().rows;
|
||||||
<div className="flex space-between mt-4 pb-4">
|
|
||||||
<h1 className="text-3xl font-bold tracking-tight">
|
return (
|
||||||
Service
|
<div className="px-8">
|
||||||
</h1>
|
<div className="flex mt-6 mb-4">
|
||||||
<ServiceCard className="ml-auto" />
|
<h1 className="flex-1 text-3xl font-bold tracking-tight">
|
||||||
</div>
|
Service
|
||||||
<Table>
|
</h1>
|
||||||
<TableHeader>
|
<HeaderButtonGroup className="flex-2 flex ml-auto gap-2" delete={{
|
||||||
{table.getHeaderGroups().map((headerGroup) => (
|
fn: deleteService,
|
||||||
<TableRow key={headerGroup.id}>
|
id: selectedRows.map(r => r.original.service.id),
|
||||||
{headerGroup.headers.map((header) => {
|
mutate: mutate,
|
||||||
return (
|
}}>
|
||||||
<TableHead key={header.id}>
|
<ServiceCard mutate={mutate} />
|
||||||
{header.isPlaceholder
|
</HeaderButtonGroup>
|
||||||
? null
|
</div>
|
||||||
: flexRender(
|
{isLoading ? (
|
||||||
header.column.columnDef.header,
|
<div className="flex flex-col items-center space-y-4">
|
||||||
header.getContext()
|
<Skeleton className="h-[60px] w-[100%] rounded-lg" />
|
||||||
)}
|
<Skeleton className="h-[60px] w-[100%] rounded-lg" />
|
||||||
</TableHead>
|
<Skeleton className="h-[60px] w-[100%] rounded-lg" />
|
||||||
)
|
</div>
|
||||||
})}
|
) : (
|
||||||
</TableRow>
|
<Table>
|
||||||
))}
|
<TableHeader>
|
||||||
</TableHeader>
|
{table.getHeaderGroups().map((headerGroup) => (
|
||||||
<TableBody>
|
<TableRow key={headerGroup.id}>
|
||||||
{table.getRowModel().rows?.length ? (
|
{headerGroup.headers.map((header) => {
|
||||||
table.getRowModel().rows.map((row) => (
|
return (
|
||||||
<TableRow
|
<TableHead key={header.id} className="text-sm">
|
||||||
key={row.id}
|
{header.isPlaceholder
|
||||||
data-state={row.getIsSelected() && "selected"}
|
? null
|
||||||
>
|
: flexRender(
|
||||||
{row.getVisibleCells().map((cell) => (
|
header.column.columnDef.header,
|
||||||
<TableCell key={cell.id}>
|
header.getContext()
|
||||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
)}
|
||||||
|
</TableHead>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{table.getRowModel().rows?.length ? (
|
||||||
|
table.getRowModel().rows.map((row) => (
|
||||||
|
<TableRow
|
||||||
|
key={row.id}
|
||||||
|
data-state={row.getIsSelected() && "selected"}
|
||||||
|
>
|
||||||
|
{row.getVisibleCells().map((cell) => (
|
||||||
|
<TableCell key={cell.id} className="text-xsm">
|
||||||
|
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||||
|
</TableCell>
|
||||||
|
))}
|
||||||
|
</TableRow>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={columns.length} className="h-24 text-center">
|
||||||
|
No results.
|
||||||
</TableCell>
|
</TableCell>
|
||||||
))}
|
</TableRow>
|
||||||
</TableRow>
|
)}
|
||||||
))
|
</TableBody>
|
||||||
) : (
|
</Table>
|
||||||
<TableRow>
|
)}
|
||||||
<TableCell colSpan={columns.length} className="h-24 text-center">
|
</div >
|
||||||
No results.
|
)
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
)}
|
|
||||||
</TableBody>
|
|
||||||
</Table>
|
|
||||||
</div >
|
|
||||||
}
|
}
|
||||||
125
src/types/api.ts
125
src/types/api.ts
@@ -142,14 +142,16 @@ export interface ModelAlertRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelAlertRuleForm {
|
export interface ModelAlertRuleForm {
|
||||||
enable: boolean;
|
enable?: boolean;
|
||||||
/** 失败时触发的任务id */
|
/** 失败时触发的任务id */
|
||||||
fail_trigger_tasks: number[];
|
fail_trigger_tasks: number[];
|
||||||
|
/** @minLength 1 */
|
||||||
name: string;
|
name: string;
|
||||||
notification_group_id: number;
|
notification_group_id: number;
|
||||||
/** 恢复时触发的任务id */
|
/** 恢复时触发的任务id */
|
||||||
recover_trigger_tasks: number[];
|
recover_trigger_tasks: number[];
|
||||||
rules: ModelRule[];
|
rules: ModelRule[];
|
||||||
|
/** @default 0 */
|
||||||
trigger_mode: number;
|
trigger_mode: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,43 +221,52 @@ export interface ModelCron {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelCronForm {
|
export interface ModelCronForm {
|
||||||
command: string;
|
command?: string;
|
||||||
|
/** @default 0 */
|
||||||
cover: number;
|
cover: number;
|
||||||
id: number;
|
id: number;
|
||||||
|
/** @minLength 1 */
|
||||||
name: string;
|
name: string;
|
||||||
notification_group_id: number;
|
notification_group_id: number;
|
||||||
push_successful: boolean;
|
push_successful?: boolean;
|
||||||
scheduler: string;
|
scheduler: string;
|
||||||
servers: number[];
|
servers: number[];
|
||||||
/** 0:计划任务 1:触发任务 */
|
/**
|
||||||
|
* 0:计划任务 1:触发任务
|
||||||
|
* @default 0
|
||||||
|
*/
|
||||||
task_type: number;
|
task_type: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelCycleTransferStats {
|
export interface ModelCycleTransferStats {
|
||||||
from?: string;
|
from: string;
|
||||||
max?: number;
|
max: number;
|
||||||
min?: number;
|
min: number;
|
||||||
name?: string;
|
name: string;
|
||||||
nextUpdate?: Record<string, string>;
|
next_update: Record<string, string>;
|
||||||
serverName?: Record<string, string>;
|
server_name: Record<string, string>;
|
||||||
to?: string;
|
to: string;
|
||||||
transfer?: Record<string, number>;
|
transfer: Record<string, number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelDDNSForm {
|
export interface ModelDDNSForm {
|
||||||
access_id: string;
|
access_id?: string;
|
||||||
access_secret: string;
|
access_secret?: string;
|
||||||
domains: string[];
|
domains: string[];
|
||||||
enable_ipv4: boolean;
|
enable_ipv4?: boolean;
|
||||||
enable_ipv6: boolean;
|
enable_ipv6?: boolean;
|
||||||
|
/** @default 3 */
|
||||||
max_retries: number;
|
max_retries: number;
|
||||||
|
/** @minLength 1 */
|
||||||
name: string;
|
name: string;
|
||||||
provider: string;
|
provider: string;
|
||||||
webhook_headers: string;
|
webhook_headers?: string;
|
||||||
webhook_method: number;
|
/** @default 1 */
|
||||||
webhook_request_body: string;
|
webhook_method?: number;
|
||||||
webhook_request_type: number;
|
webhook_request_body?: string;
|
||||||
webhook_url: string;
|
/** @default 1 */
|
||||||
|
webhook_request_type?: number;
|
||||||
|
webhook_url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelDDNSProfile {
|
export interface ModelDDNSProfile {
|
||||||
@@ -328,16 +339,17 @@ export interface ModelNAT {
|
|||||||
created_at: string;
|
created_at: string;
|
||||||
deleted_at: GormDeletedAt;
|
deleted_at: GormDeletedAt;
|
||||||
domain: string;
|
domain: string;
|
||||||
host?: string;
|
host: string;
|
||||||
id: number;
|
id: number;
|
||||||
name?: string;
|
name: string;
|
||||||
serverID?: number;
|
server_id: number;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelNATForm {
|
export interface ModelNATForm {
|
||||||
domain: string;
|
domain: string;
|
||||||
host: string;
|
host: string;
|
||||||
|
/** @minLength 1 */
|
||||||
name: string;
|
name: string;
|
||||||
server_id: number;
|
server_id: number;
|
||||||
}
|
}
|
||||||
@@ -357,14 +369,15 @@ export interface ModelNotification {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelNotificationForm {
|
export interface ModelNotificationForm {
|
||||||
|
/** @minLength 1 */
|
||||||
name: string;
|
name: string;
|
||||||
request_body: string;
|
request_body: string;
|
||||||
request_header: string;
|
request_header: string;
|
||||||
request_method: number;
|
request_method: number;
|
||||||
request_type: number;
|
request_type: number;
|
||||||
skip_check: boolean;
|
skip_check?: boolean;
|
||||||
url: string;
|
url: string;
|
||||||
verify_tls: boolean;
|
verify_tls?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelNotificationGroup {
|
export interface ModelNotificationGroup {
|
||||||
@@ -376,6 +389,7 @@ export interface ModelNotificationGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelNotificationGroupForm {
|
export interface ModelNotificationGroupForm {
|
||||||
|
/** @minLength 1 */
|
||||||
name: string;
|
name: string;
|
||||||
notifications: number[];
|
notifications: number[];
|
||||||
}
|
}
|
||||||
@@ -442,17 +456,20 @@ export interface ModelServer {
|
|||||||
export interface ModelServerForm {
|
export interface ModelServerForm {
|
||||||
/** DDNS配置 */
|
/** DDNS配置 */
|
||||||
ddns_profiles: number[];
|
ddns_profiles: number[];
|
||||||
/** 展示排序,越大越靠前 */
|
/**
|
||||||
|
* 展示排序,越大越靠前
|
||||||
|
* @default 0
|
||||||
|
*/
|
||||||
display_index: number;
|
display_index: number;
|
||||||
/** 启用DDNS */
|
/** 启用DDNS */
|
||||||
enable_ddns: boolean;
|
enable_ddns?: boolean;
|
||||||
/** 对游客隐藏 */
|
/** 对游客隐藏 */
|
||||||
hide_for_guest: boolean;
|
hide_for_guest?: boolean;
|
||||||
name: string;
|
name: string;
|
||||||
/** 管理员可见备注 */
|
/** 管理员可见备注 */
|
||||||
note: string;
|
note?: string;
|
||||||
/** 公开备注 */
|
/** 公开备注 */
|
||||||
public_note: string;
|
public_note?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelServerGroup {
|
export interface ModelServerGroup {
|
||||||
@@ -464,6 +481,7 @@ export interface ModelServerGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelServerGroupForm {
|
export interface ModelServerGroupForm {
|
||||||
|
/** @minLength 1 */
|
||||||
name: string;
|
name: string;
|
||||||
servers: number[];
|
servers: number[];
|
||||||
}
|
}
|
||||||
@@ -501,15 +519,18 @@ export interface ModelService {
|
|||||||
export interface ModelServiceForm {
|
export interface ModelServiceForm {
|
||||||
cover: number;
|
cover: number;
|
||||||
duration: number;
|
duration: number;
|
||||||
enable_show_in_service: boolean;
|
enable_show_in_service?: boolean;
|
||||||
enable_trigger_task: boolean;
|
enable_trigger_task?: boolean;
|
||||||
fail_trigger_tasks: number[];
|
fail_trigger_tasks: number[];
|
||||||
latency_notify: boolean;
|
latency_notify?: boolean;
|
||||||
|
/** @default 0 */
|
||||||
max_latency: number;
|
max_latency: number;
|
||||||
|
/** @default 0 */
|
||||||
min_latency: number;
|
min_latency: number;
|
||||||
|
/** @minLength 1 */
|
||||||
name: string;
|
name: string;
|
||||||
notification_group_id: number;
|
notification_group_id: number;
|
||||||
notify: boolean;
|
notify?: boolean;
|
||||||
recover_trigger_tasks: number[];
|
recover_trigger_tasks: number[];
|
||||||
skip_servers: Record<string, boolean>;
|
skip_servers: Record<string, boolean>;
|
||||||
target: string;
|
target: string;
|
||||||
@@ -526,30 +547,30 @@ export interface ModelServiceInfos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelServiceResponse {
|
export interface ModelServiceResponse {
|
||||||
cycleTransferStats?: Record<string, ModelCycleTransferStats>;
|
cycle_transfer_stats: Record<string, ModelCycleTransferStats>;
|
||||||
services?: Record<string, ModelServiceResponseItem>;
|
services: Record<string, ModelServiceResponseItem>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelServiceResponseItem {
|
export interface ModelServiceResponseItem {
|
||||||
currentDown?: number;
|
current_down: number;
|
||||||
currentUp?: number;
|
current_up: number;
|
||||||
delay?: number[];
|
delay: number[];
|
||||||
down?: number[];
|
down: number[];
|
||||||
service?: ModelService;
|
service: ModelService;
|
||||||
totalDown?: number;
|
total_down: number;
|
||||||
totalUp?: number;
|
total_up: number;
|
||||||
up?: number[];
|
up: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelSettingForm {
|
export interface ModelSettingForm {
|
||||||
cover: number;
|
cover: number;
|
||||||
custom_code: string;
|
custom_code?: string;
|
||||||
custom_code_dashboard: string;
|
custom_code_dashboard?: string;
|
||||||
custom_nameservers: string;
|
custom_nameservers?: string;
|
||||||
enable_ip_change_notification: boolean;
|
enable_ip_change_notification?: boolean;
|
||||||
enable_plain_ip_in_notification: boolean;
|
enable_plain_ip_in_notification?: boolean;
|
||||||
ignored_ip_notification: string;
|
ignored_ip_notification?: string;
|
||||||
install_host: string;
|
install_host?: string;
|
||||||
/** IP变更提醒的通知组 */
|
/** IP变更提醒的通知组 */
|
||||||
ip_change_notification_group_id: number;
|
ip_change_notification_group_id: number;
|
||||||
language: string;
|
language: string;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
export * from './mainStore';
|
export * from './mainStore';
|
||||||
export * from './authContext';
|
export * from './authContext';
|
||||||
export * from './api';
|
export * from './api';
|
||||||
|
export * from './service';
|
||||||
|
|||||||
10
src/types/service.ts
Normal file
10
src/types/service.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
export const serviceTypes: Record<number, string> = {
|
||||||
|
1: "HTTP GET",
|
||||||
|
2: "ICMP Ping",
|
||||||
|
3: "TCPing",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const serviceCoverageTypes: Record<number, string> = {
|
||||||
|
0: "All excludes specific servers",
|
||||||
|
1: "Only specific servers",
|
||||||
|
}
|
||||||
@@ -1,57 +1,60 @@
|
|||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
export default {
|
export default {
|
||||||
darkMode: ["class"],
|
darkMode: ["class"],
|
||||||
content: ["./index.html", "./src/**/*.{ts,tsx,js,jsx}"],
|
content: ["./index.html", "./src/**/*.{ts,tsx,js,jsx}"],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
borderRadius: {
|
borderRadius: {
|
||||||
lg: 'var(--radius)',
|
lg: 'var(--radius)',
|
||||||
md: 'calc(var(--radius) - 2px)',
|
md: 'calc(var(--radius) - 2px)',
|
||||||
sm: 'calc(var(--radius) - 4px)'
|
sm: 'calc(var(--radius) - 4px)'
|
||||||
},
|
},
|
||||||
colors: {
|
colors: {
|
||||||
background: 'hsl(var(--background))',
|
background: 'hsl(var(--background))',
|
||||||
foreground: 'hsl(var(--foreground))',
|
foreground: 'hsl(var(--foreground))',
|
||||||
card: {
|
card: {
|
||||||
DEFAULT: 'hsl(var(--card))',
|
DEFAULT: 'hsl(var(--card))',
|
||||||
foreground: 'hsl(var(--card-foreground))'
|
foreground: 'hsl(var(--card-foreground))'
|
||||||
},
|
},
|
||||||
popover: {
|
popover: {
|
||||||
DEFAULT: 'hsl(var(--popover))',
|
DEFAULT: 'hsl(var(--popover))',
|
||||||
foreground: 'hsl(var(--popover-foreground))'
|
foreground: 'hsl(var(--popover-foreground))'
|
||||||
},
|
},
|
||||||
primary: {
|
primary: {
|
||||||
DEFAULT: 'hsl(var(--primary))',
|
DEFAULT: 'hsl(var(--primary))',
|
||||||
foreground: 'hsl(var(--primary-foreground))'
|
foreground: 'hsl(var(--primary-foreground))'
|
||||||
},
|
},
|
||||||
secondary: {
|
secondary: {
|
||||||
DEFAULT: 'hsl(var(--secondary))',
|
DEFAULT: 'hsl(var(--secondary))',
|
||||||
foreground: 'hsl(var(--secondary-foreground))'
|
foreground: 'hsl(var(--secondary-foreground))'
|
||||||
},
|
},
|
||||||
muted: {
|
muted: {
|
||||||
DEFAULT: 'hsl(var(--muted))',
|
DEFAULT: 'hsl(var(--muted))',
|
||||||
foreground: 'hsl(var(--muted-foreground))'
|
foreground: 'hsl(var(--muted-foreground))'
|
||||||
},
|
},
|
||||||
accent: {
|
accent: {
|
||||||
DEFAULT: 'hsl(var(--accent))',
|
DEFAULT: 'hsl(var(--accent))',
|
||||||
foreground: 'hsl(var(--accent-foreground))'
|
foreground: 'hsl(var(--accent-foreground))'
|
||||||
},
|
},
|
||||||
destructive: {
|
destructive: {
|
||||||
DEFAULT: 'hsl(var(--destructive))',
|
DEFAULT: 'hsl(var(--destructive))',
|
||||||
foreground: 'hsl(var(--destructive-foreground))'
|
foreground: 'hsl(var(--destructive-foreground))'
|
||||||
},
|
},
|
||||||
border: 'hsl(var(--border))',
|
border: 'hsl(var(--border))',
|
||||||
input: 'hsl(var(--input))',
|
input: 'hsl(var(--input))',
|
||||||
ring: 'hsl(var(--ring))',
|
ring: 'hsl(var(--ring))',
|
||||||
chart: {
|
chart: {
|
||||||
'1': 'hsl(var(--chart-1))',
|
'1': 'hsl(var(--chart-1))',
|
||||||
'2': 'hsl(var(--chart-2))',
|
'2': 'hsl(var(--chart-2))',
|
||||||
'3': 'hsl(var(--chart-3))',
|
'3': 'hsl(var(--chart-3))',
|
||||||
'4': 'hsl(var(--chart-4))',
|
'4': 'hsl(var(--chart-4))',
|
||||||
'5': 'hsl(var(--chart-5))'
|
'5': 'hsl(var(--chart-5))'
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
fontSize: {
|
||||||
},
|
xsm: ['0.825rem', '1.25rem'],
|
||||||
plugins: [require("tailwindcss-animate")],
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [require("tailwindcss-animate")],
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user