mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-17 20:05:24 +02:00
* feat: update dependencies and enhance UI components in Dokploy - Updated various package versions in pnpm-lock.yaml to improve compatibility and performance, including React and Tailwind CSS. - Modified components.json to change the styling to "radix-nova" and added new properties for icon library and menu color. - Refactored multiple components to use updated class names for better styling consistency and responsiveness. - Removed unused Radix UI components from package.json to streamline dependencies. - Adjusted layout and styling in several dashboard components for improved user experience and visual appeal. - Enhanced tooltip and form item components for better accessibility and usability. * refactor: enhance UI components in HandleCertificate and SidebarLogo - Updated the HandleCertificate component to improve dialog content height and textarea styling for better usability. - Adjusted the SidebarLogo component layout to enhance alignment and spacing, ensuring a more consistent appearance across the sidebar. - Implemented responsive design adjustments to textarea elements, preventing overflow and improving user experience. * refactor: improve UI consistency and styling across dashboard components - Updated Card components in ShowDeployments, ShowSchedules, and ShowVolumeBackups to remove unnecessary border styles for a cleaner look. - Enhanced TabsList components in ShowProviderForm and ShowProviderFormCompose by adding a variant for improved visual distinction. - Adjusted spacing in AdvancedEnvironmentSelector for better layout and readability. - Removed redundant border classes in Service component for a more streamlined design. * [autofix.ci] apply automated fixes * chore: update package dependencies and refactor email rendering - Upgraded React and React DOM to version 19.2.7 across multiple packages for improved performance and compatibility. - Updated TSX to version 4.22.4 in various package.json files. - Refactored email rendering from `renderAsync` to `render` in notification utilities and email templates for consistency. - Adjusted Tailwind configuration usage in email templates to utilize a centralized configuration file. These changes enhance the overall stability and maintainability of the codebase. * refactor: update badge variants across dashboard components - Changed badge variant from "outline-solid" to "outline" in multiple components including columns, show-domains, and various deployment tables for consistency in styling. - Updated button variants in billing and project templates to align with the new badge styling. - Enhanced input components to support password generation and error messaging, improving user experience. These changes streamline the UI and ensure a cohesive design across the application. * refactor: clean up calendar component imports and structure - Removed redundant imports of icons from lucide-react and streamlined the import statements for better readability. - Adjusted the placement of type imports to enhance code organization. These changes improve the maintainability and clarity of the calendar component. * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
221 lines
5.3 KiB
TypeScript
221 lines
5.3 KiB
TypeScript
"use client";
|
|
import copy from "copy-to-clipboard";
|
|
import {
|
|
Bot,
|
|
Check,
|
|
Copy,
|
|
Loader2,
|
|
RotateCcw,
|
|
Settings,
|
|
X,
|
|
} from "lucide-react";
|
|
import Link from "next/link";
|
|
import { useState } from "react";
|
|
import ReactMarkdown from "react-markdown";
|
|
import { toast } from "sonner";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
Popover,
|
|
PopoverContent,
|
|
PopoverTrigger,
|
|
} from "@/components/ui/popover";
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from "@/components/ui/select";
|
|
import { api } from "@/utils/api";
|
|
import type { LogLine } from "./utils";
|
|
|
|
interface Props {
|
|
logs: LogLine[];
|
|
context: "build" | "runtime";
|
|
}
|
|
|
|
const MAX_LOG_LINES = 200;
|
|
|
|
export function AnalyzeLogs({ logs, context }: Props) {
|
|
const [open, setOpen] = useState(false);
|
|
const [aiId, setAiId] = useState<string>("");
|
|
const [copied, setCopied] = useState(false);
|
|
const { data: providers } = api.ai.getEnabledProviders.useQuery(undefined, {
|
|
enabled: open,
|
|
});
|
|
const { mutate, isPending, data, reset } = api.ai.analyzeLogs.useMutation({
|
|
onError: (error) => {
|
|
toast.error("Analysis failed", {
|
|
description: error.message,
|
|
});
|
|
},
|
|
});
|
|
|
|
const handleAnalyze = () => {
|
|
if (!aiId || logs.length === 0) return;
|
|
|
|
const logsText = logs
|
|
.slice(-MAX_LOG_LINES)
|
|
.map((l) => l.message)
|
|
.join("\n");
|
|
|
|
mutate({ aiId, logs: logsText, context });
|
|
};
|
|
|
|
const handleCopy = () => {
|
|
if (!data?.analysis) return;
|
|
const success = copy(data.analysis);
|
|
if (success) {
|
|
setCopied(true);
|
|
setTimeout(() => setCopied(false), 2000);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Popover
|
|
open={open}
|
|
onOpenChange={(isOpen) => {
|
|
setOpen(isOpen);
|
|
if (!isOpen) {
|
|
reset();
|
|
setAiId("");
|
|
}
|
|
}}
|
|
>
|
|
<PopoverTrigger asChild>
|
|
<Button
|
|
variant="outline"
|
|
size="sm"
|
|
className="h-9"
|
|
disabled={logs.length === 0}
|
|
title="Analyze logs with AI"
|
|
>
|
|
<Bot className="mr-2 size-4" />
|
|
AI
|
|
</Button>
|
|
</PopoverTrigger>
|
|
<PopoverContent className="w-[550px] p-0" align="end">
|
|
<div className="flex items-center justify-between border-b px-4 py-3">
|
|
<div className="flex items-center gap-2">
|
|
<Bot className="h-4 w-4" />
|
|
<span className="text-sm font-medium">Log Analysis</span>
|
|
</div>
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
className="h-6 w-6"
|
|
onClick={() => setOpen(false)}
|
|
>
|
|
<X className="h-3.5 w-3.5" />
|
|
</Button>
|
|
</div>
|
|
<div className="p-4 space-y-3">
|
|
{!data?.analysis ? (
|
|
providers && providers.length === 0 ? (
|
|
<div className="flex flex-col items-center gap-3 py-2 text-center">
|
|
<p className="text-sm text-muted-foreground">
|
|
No AI providers configured. Set up a provider to start
|
|
analyzing logs.
|
|
</p>
|
|
<Button size="sm" variant="outline" asChild>
|
|
<Link href="/dashboard/settings/ai">
|
|
<Settings className="mr-2 h-3.5 w-3.5" />
|
|
Configure AI Provider
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
) : (
|
|
<>
|
|
<Select value={aiId} onValueChange={setAiId}>
|
|
<SelectTrigger className="h-9 text-sm">
|
|
<SelectValue placeholder="Select AI provider..." />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
{providers?.map((p) => (
|
|
<SelectItem key={p.aiId} value={p.aiId}>
|
|
{p.name} ({p.model})
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
<Button
|
|
size="sm"
|
|
className="w-full"
|
|
disabled={!aiId || isPending || logs.length === 0}
|
|
onClick={handleAnalyze}
|
|
>
|
|
{isPending ? (
|
|
<>
|
|
<Loader2 className="mr-2 h-3.5 w-3.5 animate-spin" />
|
|
Analyzing...
|
|
</>
|
|
) : (
|
|
<>
|
|
<Bot className="mr-2 h-3.5 w-3.5" />
|
|
Analyze{" "}
|
|
{logs.length > MAX_LOG_LINES
|
|
? `last ${MAX_LOG_LINES}`
|
|
: logs.length}{" "}
|
|
lines
|
|
</>
|
|
)}
|
|
</Button>
|
|
</>
|
|
)
|
|
) : (
|
|
<>
|
|
<div className="max-h-[400px] overflow-y-auto">
|
|
<div className="prose prose-sm dark:prose-invert max-w-none text-sm wrap-break-word">
|
|
<ReactMarkdown>{data.analysis}</ReactMarkdown>
|
|
</div>
|
|
</div>
|
|
<div className="flex gap-2">
|
|
<Button
|
|
size="sm"
|
|
variant="outline"
|
|
className="flex-1"
|
|
onClick={() => {
|
|
reset();
|
|
handleAnalyze();
|
|
}}
|
|
disabled={isPending}
|
|
>
|
|
{isPending ? (
|
|
<Loader2 className="mr-2 h-3.5 w-3.5 animate-spin" />
|
|
) : (
|
|
<RotateCcw className="mr-2 h-3.5 w-3.5" />
|
|
)}
|
|
Re-analyze
|
|
</Button>
|
|
<Button
|
|
size="sm"
|
|
variant="outline"
|
|
onClick={handleCopy}
|
|
title="Copy analysis to clipboard"
|
|
>
|
|
{copied ? (
|
|
<Check className="h-3.5 w-3.5" />
|
|
) : (
|
|
<Copy className="h-3.5 w-3.5" />
|
|
)}
|
|
</Button>
|
|
<Button
|
|
size="sm"
|
|
variant="ghost"
|
|
onClick={() => {
|
|
reset();
|
|
setAiId("");
|
|
}}
|
|
title="Change provider"
|
|
>
|
|
<X className="h-3.5 w-3.5" />
|
|
</Button>
|
|
</div>
|
|
</>
|
|
)}
|
|
</div>
|
|
</PopoverContent>
|
|
</Popover>
|
|
);
|
|
}
|