From 5f905b65844ee19597a458b6c26ea414d970d469 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 8 Apr 2024 16:57:49 -0700 Subject: [PATCH] ui - add langfuse modal --- .../src/components/settings.tsx | 181 +++++++++++++----- 1 file changed, 135 insertions(+), 46 deletions(-) diff --git a/ui/litellm-dashboard/src/components/settings.tsx b/ui/litellm-dashboard/src/components/settings.tsx index 4058d80739b..e9718e0c80c 100644 --- a/ui/litellm-dashboard/src/components/settings.tsx +++ b/ui/litellm-dashboard/src/components/settings.tsx @@ -1,68 +1,157 @@ import React, { useState, useEffect } from "react"; -import { Card, Title, Subtitle, Table, TableHead, TableRow, Badge, TableHeaderCell, TableCell, TableBody, Metric, Text, Grid, Button, Col, } from "@tremor/react"; +import { + Card, + Title, + Subtitle, + Table, + TableHead, + TableRow, + Badge, + TableHeaderCell, + TableCell, + TableBody, + Metric, + Text, + Grid, + Button, + Col, +} from "@tremor/react"; import { getCallbacksCall } from "./networking"; +import { Modal, Form, Input, Select, Button as Button2 } from "antd"; interface SettingsPageProps { - accessToken: string | null; - userRole: string | null; - userID: string | null; + accessToken: string | null; + userRole: string | null; + userID: string | null; } const Settings: React.FC = ({ - accessToken, - userRole, - userID, - }) => { - const [callbacks, setCallbacks] = useState(["None"]); + accessToken, + userRole, + userID, +}) => { + const [callbacks, setCallbacks] = useState(["None"]); + const [isModalVisible, setIsModalVisible] = useState(false); + const [form] = Form.useForm(); - useEffect(() => { + useEffect(() => { if (!accessToken || !userRole || !userID) { return; } - getCallbacksCall(accessToken, userID, userRole).then((data) => { - console.log("callbacks",data); - let callbacks_data = data.data; - let callback_names = callbacks_data.success_callback // ["callback1", "callback2"] + getCallbacksCall(accessToken, userID, userRole).then((data) => { + console.log("callbacks", data); + let callbacks_data = data.data; + let callback_names = callbacks_data.success_callback; // ["callback1", "callback2"] + setCallbacks(callback_names); + }); + }, [accessToken, userRole, userID]); - setCallbacks(callback_names); - }); - }, [accessToken, userRole, userID]); + const handleAddCallback = () => { + console.log("Add callback clicked"); + setIsModalVisible(true); + }; - return ( -
- - - - - + const handleCancel = () => { + setIsModalVisible(false); + form.resetFields(); + }; + + const handleOk = () => { + // Handle form submission + form.validateFields().then((values) => { + // Call API to add the callback + console.log("Callback values:", values); + setIsModalVisible(false); + form.resetFields(); + }); + }; + + return ( +
+ + + - Logging Callbacks + Logging Callbacks -
- {callbacks.length === 0 ? ( - None - ) : ( - callbacks.map((callback, index) => ( - - {callback} - - )) - )} -
+
+ {callbacks.length === 0 ? ( + None + ) : ( + callbacks.map((callback, index) => ( + + {callback} + + )) + )} +
+
+ + + +
+
- - - - - - + +
+ + + - - -
- ); + + + + + + + + + + + + + +
+ Save +
+ + +
+ ); }; export default Settings; \ No newline at end of file