mirror of
https://github.com/aljazceru/enclava.git
synced 2025-12-17 15:34:36 +01:00
cleanup
This commit is contained in:
@@ -1,6 +1,12 @@
|
|||||||
{
|
{
|
||||||
"extends": "next/core-web-vitals",
|
"extends": "next/core-web-vitals",
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"no-console": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"allow": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"no-restricted-globals": [
|
"no-restricted-globals": [
|
||||||
"warn",
|
"warn",
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ export default function AdminPage() {
|
|||||||
const statsData = await apiClient.get<SystemStats>("/api-internal/v1/settings/system-info");
|
const statsData = await apiClient.get<SystemStats>("/api-internal/v1/settings/system-info");
|
||||||
setStats(statsData);
|
setStats(statsData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch system stats:", error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch recent activity
|
// Fetch recent activity
|
||||||
@@ -66,10 +65,8 @@ export default function AdminPage() {
|
|||||||
const activityData = await apiClient.get("/api-internal/v1/audit?page=1&size=10") as any;
|
const activityData = await apiClient.get("/api-internal/v1/audit?page=1&size=10") as any;
|
||||||
setRecentActivity(activityData.logs || []);
|
setRecentActivity(activityData.logs || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch recent activity:", error);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch admin data:", error);
|
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ function AnalyticsPageContent() {
|
|||||||
setData(analyticsData);
|
setData(analyticsData);
|
||||||
setLastUpdated(new Date());
|
setLastUpdated(new Date());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch analytics:', error);
|
|
||||||
// Set empty data structure on error
|
// Set empty data structure on error
|
||||||
setData({
|
setData({
|
||||||
overview: {
|
overview: {
|
||||||
|
|||||||
@@ -157,7 +157,6 @@ export default function ApiKeysPage() {
|
|||||||
const result = await apiClient.get("/api-internal/v1/api-keys") as any;
|
const result = await apiClient.get("/api-internal/v1/api-keys") as any;
|
||||||
setApiKeys(result.api_keys || result.data || []);
|
setApiKeys(result.api_keys || result.data || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch API keys:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: "Failed to fetch API keys",
|
description: "Failed to fetch API keys",
|
||||||
@@ -173,7 +172,6 @@ export default function ApiKeysPage() {
|
|||||||
const result = await apiClient.get("/api-internal/v1/llm/models") as any;
|
const result = await apiClient.get("/api-internal/v1/llm/models") as any;
|
||||||
setAvailableModels(result.data || []);
|
setAvailableModels(result.data || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch models:", error);
|
|
||||||
setAvailableModels([]);
|
setAvailableModels([]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -183,7 +181,6 @@ export default function ApiKeysPage() {
|
|||||||
const result = await apiClient.get("/api-internal/v1/chatbot/list") as any;
|
const result = await apiClient.get("/api-internal/v1/chatbot/list") as any;
|
||||||
setAvailableChatbots(result || []);
|
setAvailableChatbots(result || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch chatbots:", error);
|
|
||||||
setAvailableChatbots([]);
|
setAvailableChatbots([]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -214,7 +211,6 @@ export default function ApiKeysPage() {
|
|||||||
|
|
||||||
await fetchApiKeys();
|
await fetchApiKeys();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to create API key:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to create API key",
|
description: error instanceof Error ? error.message : "Failed to create API key",
|
||||||
@@ -237,7 +233,6 @@ export default function ApiKeysPage() {
|
|||||||
|
|
||||||
await fetchApiKeys();
|
await fetchApiKeys();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to toggle API key:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to update API key",
|
description: error instanceof Error ? error.message : "Failed to update API key",
|
||||||
@@ -262,7 +257,6 @@ export default function ApiKeysPage() {
|
|||||||
setShowRegenerateDialog(null);
|
setShowRegenerateDialog(null);
|
||||||
await fetchApiKeys();
|
await fetchApiKeys();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to regenerate API key:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to regenerate API key",
|
description: error instanceof Error ? error.message : "Failed to regenerate API key",
|
||||||
@@ -289,7 +283,6 @@ export default function ApiKeysPage() {
|
|||||||
|
|
||||||
await fetchApiKeys();
|
await fetchApiKeys();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to delete API key:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to delete API key",
|
description: error instanceof Error ? error.message : "Failed to delete API key",
|
||||||
@@ -321,7 +314,6 @@ export default function ApiKeysPage() {
|
|||||||
setEditKeyData({});
|
setEditKeyData({});
|
||||||
await fetchApiKeys();
|
await fetchApiKeys();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to update API key:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to update API key",
|
description: error instanceof Error ? error.message : "Failed to update API key",
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ export async function GET() {
|
|||||||
const data = await handleProxyResponse(response, 'Failed to fetch analytics overview')
|
const data = await handleProxyResponse(response, 'Failed to fetch analytics overview')
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching analytics overview:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch analytics overview' },
|
{ error: 'Failed to fetch analytics overview' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ export async function GET() {
|
|||||||
const data = await handleProxyResponse(response, 'Failed to fetch analytics')
|
const data = await handleProxyResponse(response, 'Failed to fetch analytics')
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching analytics:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch analytics' },
|
{ error: 'Failed to fetch analytics' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const data = await handleProxyResponse(response, 'Failed to fetch audit logs')
|
const data = await handleProxyResponse(response, 'Failed to fetch audit logs')
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching audit logs:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch audit logs' },
|
{ error: 'Failed to fetch audit logs' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error in auth login:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to process login' },
|
{ error: 'Failed to process login' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error in auth me:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to get user info' },
|
{ error: 'Failed to get user info' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error in auth refresh:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to refresh token' },
|
{ error: 'Failed to refresh token' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error in auth register:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to process registration' },
|
{ error: 'Failed to process registration' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -141,7 +141,6 @@ export async function POST(request: NextRequest) {
|
|||||||
message_id: messageId
|
message_id: messageId
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error in chat API route:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
error: 'Internal Server Error',
|
error: 'Internal Server Error',
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export async function POST(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating chatbot:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: 'Internal server error' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ export async function DELETE(
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting chatbot:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to delete chatbot' },
|
{ error: 'Failed to delete chatbot' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching chatbots:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: 'Internal server error' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching chatbot types:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: 'Internal server error' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ export async function PUT(
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating chatbot:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: 'Internal server error' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export async function POST(
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error regenerating API key:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: 'Internal server error' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ export async function DELETE(
|
|||||||
|
|
||||||
return NextResponse.json({ success: true })
|
return NextResponse.json({ success: true })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting API key:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: 'Internal server error' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -72,7 +71,6 @@ export async function PUT(
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating API key:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: 'Internal server error' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json({ data: data.api_keys })
|
return NextResponse.json({ data: data.api_keys })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching API keys:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: 'Internal server error' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -77,7 +76,6 @@ export async function POST(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating API key:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: 'Internal server error' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ export async function GET() {
|
|||||||
const data = await handleProxyResponse(response, 'Failed to fetch budget status')
|
const data = await handleProxyResponse(response, 'Failed to fetch budget status')
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching budget status:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch budget status' },
|
{ error: 'Failed to fetch budget status' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json({ data: data.budgets || [] })
|
return NextResponse.json({ data: data.budgets || [] })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching budgets:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: 'Internal server error' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export async function POST(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error in chat completions:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to process chat completion' },
|
{ error: 'Failed to process chat completion' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json({ data: transformedModels })
|
return NextResponse.json({ data: transformedModels })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching models:", error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: "Internal server error" },
|
{ error: "Internal server error" },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ export async function POST(
|
|||||||
refreshRequired: true
|
refreshRequired: true
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error performing ${params.action} on module ${params.name}:`, error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: `Failed to ${params.action} module` },
|
{ error: `Failed to ${params.action} module` },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ export async function GET(
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error fetching config for module ${params.name}:`, error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch module configuration' },
|
{ error: 'Failed to fetch module configuration' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -54,7 +53,6 @@ export async function POST(
|
|||||||
refreshRequired: true
|
refreshRequired: true
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error updating config for module ${params.name}:`, error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to update module configuration' },
|
{ error: 'Failed to update module configuration' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export async function GET() {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching modules:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch modules' },
|
{ error: 'Failed to fetch modules' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ export async function GET() {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching modules status:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch modules status' },
|
{ error: 'Failed to fetch modules status' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ export async function POST(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating prompt template:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to create prompt template' },
|
{ error: 'Failed to create prompt template' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ export async function POST(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error improving prompt with AI:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to improve prompt' },
|
{ error: 'Failed to improve prompt' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export async function POST(
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error resetting prompt template:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to reset prompt template' },
|
{ error: 'Failed to reset prompt template' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ export async function PUT(
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating prompt template:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to update prompt template' },
|
{ error: 'Failed to update prompt template' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -73,7 +72,6 @@ export async function GET(
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching prompt template:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch prompt template' },
|
{ error: 'Failed to fetch prompt template' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching prompt templates:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch prompt templates' },
|
{ error: 'Failed to fetch prompt templates' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching prompt variables:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch prompt variables' },
|
{ error: 'Failed to fetch prompt variables' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export async function DELETE(
|
|||||||
const data = await backendResponse.json()
|
const data = await backendResponse.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting collection:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: 'Failed to delete collection' },
|
{ success: false, error: 'Failed to delete collection' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -70,7 +69,6 @@ export async function GET(
|
|||||||
const data = await backendResponse.json()
|
const data = await backendResponse.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching collection:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: 'Failed to fetch collection' },
|
{ success: false, error: 'Failed to fetch collection' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const data = await backendResponse.json()
|
const data = await backendResponse.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching collections:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: 'Failed to fetch collections' },
|
{ success: false, error: 'Failed to fetch collections' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -69,7 +68,6 @@ export async function POST(request: NextRequest) {
|
|||||||
const data = await backendResponse.json()
|
const data = await backendResponse.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating collection:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: 'Failed to create collection' },
|
{ success: false, error: 'Failed to create collection' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ export async function GET(
|
|||||||
|
|
||||||
return new NextResponse(backendResponse.body, { headers })
|
return new NextResponse(backendResponse.body, { headers })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error downloading document:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: 'Failed to download document' },
|
{ success: false, error: 'Failed to download document' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export async function DELETE(
|
|||||||
const data = await backendResponse.json()
|
const data = await backendResponse.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting document:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: 'Failed to delete document' },
|
{ success: false, error: 'Failed to delete document' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -70,7 +69,6 @@ export async function GET(
|
|||||||
const data = await backendResponse.json()
|
const data = await backendResponse.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching document:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: 'Failed to fetch document' },
|
{ success: false, error: 'Failed to fetch document' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const data = await backendResponse.json()
|
const data = await backendResponse.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching documents:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: 'Failed to fetch documents' },
|
{ success: false, error: 'Failed to fetch documents' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -69,7 +68,6 @@ export async function POST(request: NextRequest) {
|
|||||||
const data = await backendResponse.json()
|
const data = await backendResponse.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error uploading document:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: 'Failed to upload document' },
|
{ success: false, error: 'Failed to upload document' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const data = await backendResponse.json()
|
const data = await backendResponse.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching RAG stats:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: 'Failed to fetch RAG stats' },
|
{ success: false, error: 'Failed to fetch RAG stats' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ export async function GET(request: NextRequest) {
|
|||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching chatbots:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: 'Internal server error' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json({ data: transformedModels })
|
return NextResponse.json({ data: transformedModels })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching models:", error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: "Internal server error" },
|
{ error: "Internal server error" },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching provider status:", error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: "Internal server error" },
|
{ error: "Internal server error" },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ export async function GET(
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error getting plugin config:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to get plugin config' },
|
{ error: 'Failed to get plugin config' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -84,7 +83,6 @@ export async function POST(
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error saving plugin config:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to save plugin config' },
|
{ error: 'Failed to save plugin config' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ export async function POST(
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error disabling plugin:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to disable plugin' },
|
{ error: 'Failed to disable plugin' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ export async function POST(
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error enabling plugin:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to enable plugin' },
|
{ error: 'Failed to enable plugin' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ export async function POST(
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading plugin:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to load plugin' },
|
{ error: 'Failed to load plugin' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ export async function DELETE(
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error uninstalling plugin:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to uninstall plugin' },
|
{ error: 'Failed to uninstall plugin' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ export async function GET(
|
|||||||
|
|
||||||
return nextResponse
|
return nextResponse
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error getting plugin schema:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to get plugin schema' },
|
{ error: 'Failed to get plugin schema' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ export async function POST(
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error testing plugin credentials:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to test plugin credentials' },
|
{ error: 'Failed to test plugin credentials' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ export async function POST(
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error unloading plugin:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to unload plugin' },
|
{ error: 'Failed to unload plugin' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error discovering plugins:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to discover plugins' },
|
{ error: 'Failed to discover plugins' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error installing plugin:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to install plugin' },
|
{ error: 'Failed to install plugin' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching installed plugins:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch installed plugins' },
|
{ error: 'Failed to fetch installed plugins' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ export async function PUT(
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error updating ${params.category} settings:`, error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to update category settings' },
|
{ error: 'Failed to update category settings' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -122,7 +121,6 @@ export async function GET(
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error fetching ${params.category} settings:`, error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch category settings' },
|
{ error: 'Failed to fetch category settings' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching settings:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch settings' },
|
{ error: 'Failed to fetch settings' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -85,7 +84,6 @@ export async function PUT(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating settings:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to update settings' },
|
{ error: 'Failed to update settings' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching Zammad chatbots:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch Zammad chatbots' },
|
{ error: 'Failed to fetch Zammad chatbots' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ export async function PUT(request: NextRequest, { params }: { params: { id: stri
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating Zammad configuration:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to update Zammad configuration' },
|
{ error: 'Failed to update Zammad configuration' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -78,7 +77,6 @@ export async function DELETE(request: NextRequest, { params }: { params: { id: s
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting Zammad configuration:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to delete Zammad configuration' },
|
{ error: 'Failed to delete Zammad configuration' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching Zammad configurations:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch Zammad configurations' },
|
{ error: 'Failed to fetch Zammad configurations' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
@@ -75,7 +74,6 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating Zammad configuration:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to create Zammad configuration' },
|
{ error: 'Failed to create Zammad configuration' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error processing Zammad tickets:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to process Zammad tickets' },
|
{ error: 'Failed to process Zammad tickets' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching Zammad processing logs:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch Zammad processing logs' },
|
{ error: 'Failed to fetch Zammad processing logs' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching Zammad status:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to fetch Zammad status' },
|
{ error: 'Failed to fetch Zammad status' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error testing Zammad connection:', error)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to test Zammad connection' },
|
{ error: 'Failed to test Zammad connection' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ export default function AuditPage() {
|
|||||||
setTotalPages(Math.ceil((logsData.total || 0) / pageSize));
|
setTotalPages(Math.ceil((logsData.total || 0) / pageSize));
|
||||||
setStats(statsData);
|
setStats(statsData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch audit data:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: "Failed to fetch audit logs",
|
description: "Failed to fetch audit logs",
|
||||||
@@ -165,7 +164,6 @@ export default function AuditPage() {
|
|||||||
description: "Audit logs have been exported successfully",
|
description: "Audit logs have been exported successfully",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to export audit logs:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Export Failed",
|
title: "Export Failed",
|
||||||
description: error instanceof Error ? error.message : "Failed to export audit logs",
|
description: error instanceof Error ? error.message : "Failed to export audit logs",
|
||||||
@@ -492,7 +490,6 @@ export default function AuditPage() {
|
|||||||
metadata: JSON.stringify(log.metadata, null, 2)
|
metadata: JSON.stringify(log.metadata, null, 2)
|
||||||
};
|
};
|
||||||
// Would open a detail modal in a real implementation
|
// Would open a detail modal in a real implementation
|
||||||
console.log("Audit log details:", details);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Eye className="mr-2 h-3 w-3" />
|
<Eye className="mr-2 h-3 w-3" />
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ export default function BudgetsPage() {
|
|||||||
setStats(statsData.value);
|
setStats(statsData.value);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch budget data:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: "Failed to fetch budget data",
|
description: "Failed to fetch budget data",
|
||||||
@@ -155,7 +154,6 @@ export default function BudgetsPage() {
|
|||||||
|
|
||||||
await fetchBudgetData();
|
await fetchBudgetData();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to create budget:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to create budget",
|
description: error instanceof Error ? error.message : "Failed to create budget",
|
||||||
@@ -180,7 +178,6 @@ export default function BudgetsPage() {
|
|||||||
setEditingBudget(null);
|
setEditingBudget(null);
|
||||||
await fetchBudgetData();
|
await fetchBudgetData();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to update budget:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to update budget",
|
description: error instanceof Error ? error.message : "Failed to update budget",
|
||||||
@@ -212,7 +209,6 @@ export default function BudgetsPage() {
|
|||||||
|
|
||||||
await fetchBudgetData();
|
await fetchBudgetData();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to delete budget:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to delete budget",
|
description: error instanceof Error ? error.message : "Failed to delete budget",
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ function DashboardContent() {
|
|||||||
setRecentActivity([])
|
setRecentActivity([])
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching dashboard data:', error)
|
|
||||||
// Set empty states on error
|
// Set empty states on error
|
||||||
setStats({
|
setStats({
|
||||||
activeModules: 0,
|
activeModules: 0,
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ function LLMPageContent() {
|
|||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
console.log('Fetching data...')
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const token = localStorage.getItem('token')
|
const token = localStorage.getItem('token')
|
||||||
if (!token) {
|
if (!token) {
|
||||||
@@ -109,11 +108,9 @@ function LLMPageContent() {
|
|||||||
// Fetch API keys and models using API client
|
// Fetch API keys and models using API client
|
||||||
const [keysData, modelsData] = await Promise.all([
|
const [keysData, modelsData] = await Promise.all([
|
||||||
apiClient.get('/api-internal/v1/api-keys').catch(e => {
|
apiClient.get('/api-internal/v1/api-keys').catch(e => {
|
||||||
console.error('Failed to fetch API keys:', e)
|
|
||||||
return { data: [] }
|
return { data: [] }
|
||||||
}),
|
}),
|
||||||
apiClient.get('/api-internal/v1/llm/models').catch(e => {
|
apiClient.get('/api-internal/v1/llm/models').catch(e => {
|
||||||
console.error('Failed to fetch models:', e)
|
|
||||||
return { data: [] }
|
return { data: [] }
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
@@ -122,7 +119,6 @@ function LLMPageContent() {
|
|||||||
setModels(modelsData.data || [])
|
setModels(modelsData.data || [])
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching data:', error)
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: "Failed to load data",
|
description: "Failed to load data",
|
||||||
@@ -169,11 +165,9 @@ function LLMPageContent() {
|
|||||||
|
|
||||||
const deleteAPIKey = async (keyId: number) => {
|
const deleteAPIKey = async (keyId: number) => {
|
||||||
try {
|
try {
|
||||||
console.log('Deleting API key with ID:', keyId)
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
const responseData = await apiClient.delete(`/api-internal/v1/api-keys/${keyId}`)
|
const responseData = await apiClient.delete(`/api-internal/v1/api-keys/${keyId}`)
|
||||||
console.log('Delete response data:', responseData)
|
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: "Success",
|
title: "Success",
|
||||||
@@ -182,9 +176,7 @@ function LLMPageContent() {
|
|||||||
|
|
||||||
// Force refresh data and wait for it to complete
|
// Force refresh data and wait for it to complete
|
||||||
await fetchData()
|
await fetchData()
|
||||||
console.log('Data refreshed after deletion')
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting API key:', error)
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to delete API key",
|
description: error instanceof Error ? error.message : "Failed to delete API key",
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ export default function PromptTemplatesPage() {
|
|||||||
setTemplates(templatesResult.value)
|
setTemplates(templatesResult.value)
|
||||||
setVariables(variablesResult.value)
|
setVariables(variablesResult.value)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading data:', error)
|
|
||||||
toast.error('Failed to load prompt templates')
|
toast.error('Failed to load prompt templates')
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
@@ -162,7 +161,6 @@ export default function PromptTemplatesPage() {
|
|||||||
setEditingTemplate(null)
|
setEditingTemplate(null)
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error saving template:', error)
|
|
||||||
toast.error(error instanceof Error ? error.message : 'Failed to save template')
|
toast.error(error instanceof Error ? error.message : 'Failed to save template')
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false)
|
setSaving(false)
|
||||||
@@ -178,7 +176,6 @@ export default function PromptTemplatesPage() {
|
|||||||
await loadData()
|
await loadData()
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error resetting template:', error)
|
|
||||||
toast.error(error instanceof Error ? error.message : 'Failed to reset template')
|
toast.error(error instanceof Error ? error.message : 'Failed to reset template')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,7 +225,6 @@ export default function PromptTemplatesPage() {
|
|||||||
setUseCustomType(false)
|
setUseCustomType(false)
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating template:', error)
|
|
||||||
toast.error(error instanceof Error ? error.message : 'Failed to create template')
|
toast.error(error instanceof Error ? error.message : 'Failed to create template')
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false)
|
setSaving(false)
|
||||||
@@ -261,7 +257,6 @@ export default function PromptTemplatesPage() {
|
|||||||
toast.success('Prompt improved with AI successfully')
|
toast.success('Prompt improved with AI successfully')
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error improving prompt with AI:', error)
|
|
||||||
toast.error(error instanceof Error ? error.message : 'Failed to improve prompt')
|
toast.error(error instanceof Error ? error.message : 'Failed to improve prompt')
|
||||||
} finally {
|
} finally {
|
||||||
setImprovingWithAI(false)
|
setImprovingWithAI(false)
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ function RAGPageContent() {
|
|||||||
const data = await apiClient.get('/api-internal/v1/rag/collections')
|
const data = await apiClient.get('/api-internal/v1/rag/collections')
|
||||||
setCollections(data.collections || [])
|
setCollections(data.collections || [])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load collections:', error)
|
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
@@ -88,7 +87,6 @@ function RAGPageContent() {
|
|||||||
const data = await apiClient.get('/api-internal/v1/rag/stats')
|
const data = await apiClient.get('/api-internal/v1/rag/stats')
|
||||||
setStats(data.stats)
|
setStats(data.stats)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load stats:', error)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ export default function RegisterPage() {
|
|||||||
// Redirect to login page
|
// Redirect to login page
|
||||||
router.push("/login?message=registration-success");
|
router.push("/login?message=registration-success");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Registration error:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Registration failed",
|
title: "Registration failed",
|
||||||
description: error instanceof Error ? error.message : "An unexpected error occurred",
|
description: error instanceof Error ? error.message : "An unexpected error occurred",
|
||||||
|
|||||||
@@ -198,7 +198,6 @@ function SettingsPageContent() {
|
|||||||
setSettings(transformedSettings);
|
setSettings(transformedSettings);
|
||||||
setIsDirty(false);
|
setIsDirty(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch settings:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: "Failed to fetch system settings",
|
description: "Failed to fetch system settings",
|
||||||
@@ -239,7 +238,6 @@ function SettingsPageContent() {
|
|||||||
|
|
||||||
setIsDirty(false);
|
setIsDirty(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to save settings:", error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Save Failed",
|
title: "Save Failed",
|
||||||
description: error instanceof Error ? error.message : "Failed to save settings",
|
description: error instanceof Error ? error.message : "Failed to save settings",
|
||||||
@@ -259,7 +257,6 @@ function SettingsPageContent() {
|
|||||||
description: `${type.toUpperCase()} connection is working properly`,
|
description: `${type.toUpperCase()} connection is working properly`,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to test ${type} connection:`, error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Connection Test Failed",
|
title: "Connection Test Failed",
|
||||||
description: error instanceof Error ? error.message : `Failed to test ${type} connection`,
|
description: error instanceof Error ? error.message : `Failed to test ${type} connection`,
|
||||||
@@ -287,7 +284,6 @@ function SettingsPageContent() {
|
|||||||
triggerModuleRefresh();
|
triggerModuleRefresh();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to ${action} module:`, error);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : `Failed to ${action} module`,
|
description: error instanceof Error ? error.message : `Failed to ${action} module`,
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ export function ChatInterface({ chatbotId, chatbotName, onClose }: ChatInterface
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const appError = error as AppError
|
const appError = error as AppError
|
||||||
console.error('Error sending message:', appError)
|
|
||||||
|
|
||||||
// More specific error handling
|
// More specific error handling
|
||||||
if (appError.code === 'UNAUTHORIZED') {
|
if (appError.code === 'UNAUTHORIZED') {
|
||||||
@@ -127,7 +126,6 @@ export function ChatInterface({ chatbotId, chatbotName, onClose }: ChatInterface
|
|||||||
await navigator.clipboard.writeText(content)
|
await navigator.clipboard.writeText(content)
|
||||||
toast.success("Copied", "Message copied to clipboard")
|
toast.success("Copied", "Message copied to clipboard")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to copy message:', error)
|
|
||||||
toast.error("Copy Failed", "Unable to copy message to clipboard")
|
toast.error("Copy Failed", "Unable to copy message to clipboard")
|
||||||
}
|
}
|
||||||
}, [toast])
|
}, [toast])
|
||||||
|
|||||||
@@ -216,7 +216,6 @@ export function ChatbotManager() {
|
|||||||
const data = await apiClient.get('/api-internal/v1/chatbot/list')
|
const data = await apiClient.get('/api-internal/v1/chatbot/list')
|
||||||
setChatbots(data)
|
setChatbots(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load chatbots:', error)
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: "Failed to load chatbots",
|
description: "Failed to load chatbots",
|
||||||
@@ -232,7 +231,6 @@ export function ChatbotManager() {
|
|||||||
const data = await apiClient.get('/api-internal/v1/rag/collections')
|
const data = await apiClient.get('/api-internal/v1/rag/collections')
|
||||||
setRagCollections(data.collections || [])
|
setRagCollections(data.collections || [])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load RAG collections:', error)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +239,6 @@ export function ChatbotManager() {
|
|||||||
const templates = await apiClient.get('/api-internal/v1/prompt-templates/templates')
|
const templates = await apiClient.get('/api-internal/v1/prompt-templates/templates')
|
||||||
setPromptTemplates(templates)
|
setPromptTemplates(templates)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load prompt templates:', error)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +342,6 @@ export function ChatbotManager() {
|
|||||||
description: `${deletingChatbot.name} has been deleted`
|
description: `${deletingChatbot.name} has been deleted`
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to delete chatbot:', error)
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to delete chatbot",
|
description: error instanceof Error ? error.message : "Failed to delete chatbot",
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ export function ZammadConfig() {
|
|||||||
fetchModuleStatus()
|
fetchModuleStatus()
|
||||||
])
|
])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching Zammad data:", error)
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: "Failed to load Zammad configuration",
|
description: "Failed to load Zammad configuration",
|
||||||
@@ -152,7 +151,7 @@ export function ZammadConfig() {
|
|||||||
const data = await apiClient.get("/api-internal/v1/zammad/configurations")
|
const data = await apiClient.get("/api-internal/v1/zammad/configurations")
|
||||||
setConfigurations(data.configurations || [])
|
setConfigurations(data.configurations || [])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching configurations:", error)
|
// Silent failure for configuration fetching
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +160,7 @@ export function ZammadConfig() {
|
|||||||
const data = await apiClient.get("/api-internal/v1/zammad/chatbots")
|
const data = await apiClient.get("/api-internal/v1/zammad/chatbots")
|
||||||
setChatbots(data.chatbots || [])
|
setChatbots(data.chatbots || [])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching chatbots:", error)
|
// Silent failure for chatbot fetching
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +169,7 @@ export function ZammadConfig() {
|
|||||||
const data = await apiClient.get("/api-internal/v1/zammad/processing-logs?limit=5")
|
const data = await apiClient.get("/api-internal/v1/zammad/processing-logs?limit=5")
|
||||||
setProcessingLogs(data.logs || [])
|
setProcessingLogs(data.logs || [])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching processing logs:", error)
|
// Silent failure for processing logs fetching
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +178,7 @@ export function ZammadConfig() {
|
|||||||
const data = await apiClient.get("/api-internal/v1/zammad/status")
|
const data = await apiClient.get("/api-internal/v1/zammad/status")
|
||||||
setModuleStatus(data)
|
setModuleStatus(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching module status:", error)
|
// Silent failure for module status fetching
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +224,6 @@ export function ZammadConfig() {
|
|||||||
|
|
||||||
await fetchConfigurations()
|
await fetchConfigurations()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error saving configuration:", error)
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to save configuration",
|
description: error instanceof Error ? error.message : "Failed to save configuration",
|
||||||
@@ -253,8 +251,6 @@ export function ZammadConfig() {
|
|||||||
zammad_url: newConfig.zammad_url,
|
zammad_url: newConfig.zammad_url,
|
||||||
api_token: newConfig.api_token
|
api_token: newConfig.api_token
|
||||||
})
|
})
|
||||||
console.log("Test connection response:", data)
|
|
||||||
|
|
||||||
if (data.status === "success") {
|
if (data.status === "success") {
|
||||||
toast({
|
toast({
|
||||||
title: "✅ Connection Successful",
|
title: "✅ Connection Successful",
|
||||||
@@ -270,7 +266,6 @@ export function ZammadConfig() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error testing connection:", error)
|
|
||||||
toast({
|
toast({
|
||||||
title: "⚠️ Connection Test Error",
|
title: "⚠️ Connection Test Error",
|
||||||
description: `Failed to test connection: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
description: `Failed to test connection: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
||||||
@@ -302,7 +297,6 @@ export function ZammadConfig() {
|
|||||||
fetchModuleStatus()
|
fetchModuleStatus()
|
||||||
}, 2000)
|
}, 2000)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error processing tickets:", error)
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: error instanceof Error ? error.message : "Failed to process tickets",
|
description: error instanceof Error ? error.message : "Failed to process tickets",
|
||||||
@@ -324,7 +318,6 @@ export function ZammadConfig() {
|
|||||||
|
|
||||||
await fetchConfigurations()
|
await fetchConfigurations()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error deleting configuration:", error)
|
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: "Failed to delete configuration",
|
description: "Failed to delete configuration",
|
||||||
|
|||||||
@@ -283,7 +283,6 @@ export const PluginManager: React.FC = () => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Failed to ${action} plugin:`, err);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -291,7 +290,6 @@ export const PluginManager: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
await installPlugin(plugin.id, plugin.version);
|
await installPlugin(plugin.id, plugin.version);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to install plugin:', err);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ const PluginIframe: React.FC<PluginIframeProps> = ({
|
|||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
|
||||||
if (!allowedOrigins.some(origin => event.origin.startsWith(origin))) {
|
if (!allowedOrigins.some(origin => event.origin.startsWith(origin))) {
|
||||||
console.warn('Rejected message from unauthorized origin:', event.origin);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +83,6 @@ const PluginIframe: React.FC<PluginIframeProps> = ({
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error processing plugin message:', err);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
|||||||
localStorage.setItem('token', previousToken)
|
localStorage.setItem('token', previousToken)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Token validation failed:", error)
|
|
||||||
localStorage.removeItem("access_token")
|
localStorage.removeItem("access_token")
|
||||||
localStorage.removeItem("refresh_token")
|
localStorage.removeItem("refresh_token")
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ export function DocumentBrowser({ collections, selectedCollection, onCollectionS
|
|||||||
const data = await apiClient.get(url)
|
const data = await apiClient.get(url)
|
||||||
setDocuments(data.documents || [])
|
setDocuments(data.documents || [])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load documents:', error)
|
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ export function ModulesProvider({ children }: { children: ReactNode }) {
|
|||||||
setLastUpdated(new Date())
|
setLastUpdated(new Date())
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error fetching modules:", err)
|
|
||||||
setError(err instanceof Error ? err.message : "Failed to load modules")
|
setError(err instanceof Error ? err.message : "Failed to load modules")
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ export const PluginProvider: React.FC<PluginProviderProps> = ({ children }) => {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(`Failed to load config for plugin ${plugin.id}:`, e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +324,6 @@ export const PluginProvider: React.FC<PluginProviderProps> = ({ children }) => {
|
|||||||
const data = await apiRequest(`/${pluginId}/config`);
|
const data = await apiRequest(`/${pluginId}/config`);
|
||||||
return data;
|
return data;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Failed to get configuration for plugin ${pluginId}:`, err);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -380,7 +378,6 @@ export const PluginProvider: React.FC<PluginProviderProps> = ({ children }) => {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
} catch (chatbotError) {
|
} catch (chatbotError) {
|
||||||
console.warn('Failed to load chatbots for Zammad configuration:', chatbotError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate model options for AI settings
|
// Populate model options for AI settings
|
||||||
@@ -405,7 +402,6 @@ export const PluginProvider: React.FC<PluginProviderProps> = ({ children }) => {
|
|||||||
schema.properties.draft_settings.properties.model.options = modelOptions;
|
schema.properties.draft_settings.properties.model.options = modelOptions;
|
||||||
}
|
}
|
||||||
} catch (modelError) {
|
} catch (modelError) {
|
||||||
console.warn('Failed to load models for Zammad configuration:', modelError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,13 +418,11 @@ export const PluginProvider: React.FC<PluginProviderProps> = ({ children }) => {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
} catch (modelError) {
|
} catch (modelError) {
|
||||||
console.warn('Failed to load models for Signal configuration:', modelError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return schema;
|
return schema;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Failed to get schema for plugin ${pluginId}:`, err);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -460,7 +454,6 @@ export const PluginProvider: React.FC<PluginProviderProps> = ({ children }) => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Failed to load components for plugin ${pluginId}:`, err);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ export function useChatbotForm() {
|
|||||||
setChatbots(data)
|
setChatbots(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const appError = error as AppError
|
const appError = error as AppError
|
||||||
console.error('Error loading chatbots:', appError)
|
|
||||||
toast.error("Loading Failed", "Failed to load chatbots")
|
toast.error("Loading Failed", "Failed to load chatbots")
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
@@ -80,7 +79,6 @@ export function useChatbotForm() {
|
|||||||
return newChatbot
|
return newChatbot
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const appError = error as AppError
|
const appError = error as AppError
|
||||||
console.error('Error creating chatbot:', appError)
|
|
||||||
|
|
||||||
if (appError.code === 'VALIDATION_ERROR') {
|
if (appError.code === 'VALIDATION_ERROR') {
|
||||||
toast.error("Validation Error", appError.details || "Please check your input")
|
toast.error("Validation Error", appError.details || "Please check your input")
|
||||||
@@ -103,7 +101,6 @@ export function useChatbotForm() {
|
|||||||
return updatedChatbot
|
return updatedChatbot
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const appError = error as AppError
|
const appError = error as AppError
|
||||||
console.error('Error updating chatbot:', appError)
|
|
||||||
toast.error("Update Failed", "Failed to update chatbot")
|
toast.error("Update Failed", "Failed to update chatbot")
|
||||||
throw error
|
throw error
|
||||||
} finally {
|
} finally {
|
||||||
@@ -120,7 +117,6 @@ export function useChatbotForm() {
|
|||||||
toast.success("Success", "Chatbot deleted successfully")
|
toast.success("Success", "Chatbot deleted successfully")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const appError = error as AppError
|
const appError = error as AppError
|
||||||
console.error('Error deleting chatbot:', appError)
|
|
||||||
toast.error("Deletion Failed", "Failed to delete chatbot")
|
toast.error("Deletion Failed", "Failed to delete chatbot")
|
||||||
throw error
|
throw error
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ export function useBudgetStatus(autoRefresh = true, refreshInterval = 30000) {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
const errorMessage = err instanceof Error ? err.message : 'Unknown error occurred'
|
const errorMessage = err instanceof Error ? err.message : 'Unknown error occurred'
|
||||||
setError(errorMessage)
|
setError(errorMessage)
|
||||||
console.error('Budget status fetch error:', err)
|
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user