Compare commits
2 Commits
75d4c0b45d
...
e8aab43a13
| Author | SHA1 | Date | |
|---|---|---|---|
| e8aab43a13 | |||
| 659ebf71ea |
@@ -81,6 +81,7 @@ export interface EndpointParameter {
|
||||
required: boolean;
|
||||
default_value?: any;
|
||||
description?: string;
|
||||
example_value?: string;
|
||||
in: 'query' | 'body' | 'path';
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import Sidebar from '@/components/Sidebar';
|
||||
import Login from '@/pages/Login';
|
||||
import Dashboard from '@/pages/Dashboard';
|
||||
import Endpoints from '@/pages/Endpoints';
|
||||
import EndpointEditor from '@/pages/EndpointEditor';
|
||||
import ApiKeys from '@/pages/ApiKeys';
|
||||
import Folders from '@/pages/Folders';
|
||||
import Logs from '@/pages/Logs';
|
||||
@@ -97,6 +98,26 @@ function App() {
|
||||
</PrivateRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/endpoints/new"
|
||||
element={
|
||||
<PrivateRoute>
|
||||
<Layout>
|
||||
<EndpointEditor />
|
||||
</Layout>
|
||||
</PrivateRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/endpoints/:id"
|
||||
element={
|
||||
<PrivateRoute>
|
||||
<Layout>
|
||||
<EndpointEditor />
|
||||
</Layout>
|
||||
</PrivateRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/endpoints"
|
||||
element={
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1326
frontend/src/pages/EndpointEditor.tsx
Normal file
1326
frontend/src/pages/EndpointEditor.tsx
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,18 +1,17 @@
|
||||
import { useState, useRef } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { endpointsApi, databasesApi } from '@/services/api';
|
||||
import { Endpoint, ImportPreviewResponse } from '@/types';
|
||||
import { endpointsApi } from '@/services/api';
|
||||
import { ImportPreviewResponse } from '@/types';
|
||||
import { Plus, Search, Edit2, Trash2, Download, Upload } from 'lucide-react';
|
||||
import toast from 'react-hot-toast';
|
||||
import EndpointModal from '@/components/EndpointModal';
|
||||
import ImportEndpointModal from '@/components/ImportEndpointModal';
|
||||
import Dialog from '@/components/Dialog';
|
||||
|
||||
export default function Endpoints() {
|
||||
const queryClient = useQueryClient();
|
||||
const navigate = useNavigate();
|
||||
const [search, setSearch] = useState('');
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
const [editingEndpoint, setEditingEndpoint] = useState<Endpoint | null>(null);
|
||||
const [showImportModal, setShowImportModal] = useState(false);
|
||||
const [importFile, setImportFile] = useState<File | null>(null);
|
||||
const [importPreview, setImportPreview] = useState<ImportPreviewResponse | null>(null);
|
||||
@@ -35,11 +34,6 @@ export default function Endpoints() {
|
||||
queryFn: () => endpointsApi.getAll(search).then(res => res.data),
|
||||
});
|
||||
|
||||
const { data: databases } = useQuery({
|
||||
queryKey: ['databases'],
|
||||
queryFn: () => databasesApi.getAll().then(res => res.data),
|
||||
});
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (id: string) => endpointsApi.delete(id),
|
||||
onSuccess: () => {
|
||||
@@ -61,16 +55,6 @@ export default function Endpoints() {
|
||||
});
|
||||
};
|
||||
|
||||
const handleEdit = (endpoint: Endpoint) => {
|
||||
setEditingEndpoint(endpoint);
|
||||
setShowModal(true);
|
||||
};
|
||||
|
||||
const handleCreate = () => {
|
||||
setEditingEndpoint(null);
|
||||
setShowModal(true);
|
||||
};
|
||||
|
||||
const handleExport = async (endpointId: string, endpointName: string) => {
|
||||
try {
|
||||
const response = await endpointsApi.exportEndpoint(endpointId);
|
||||
@@ -129,7 +113,7 @@ export default function Endpoints() {
|
||||
<Upload size={20} />
|
||||
Импорт
|
||||
</button>
|
||||
<button onClick={handleCreate} className="btn btn-primary flex items-center gap-2">
|
||||
<button onClick={() => navigate('/endpoints/new')} className="btn btn-primary flex items-center gap-2">
|
||||
<Plus size={20} />
|
||||
Новый эндпоинт
|
||||
</button>
|
||||
@@ -203,7 +187,7 @@ export default function Endpoints() {
|
||||
<Download size={18} className="text-gray-600" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleEdit(endpoint)}
|
||||
onClick={() => navigate(`/endpoints/${endpoint.id}`)}
|
||||
className="p-2 hover:bg-gray-100 rounded-lg transition-colors"
|
||||
title="Редактировать"
|
||||
>
|
||||
@@ -229,14 +213,6 @@ export default function Endpoints() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showModal && (
|
||||
<EndpointModal
|
||||
endpoint={editingEndpoint}
|
||||
databases={databases || []}
|
||||
onClose={() => setShowModal(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{showImportModal && importPreview && importFile && (
|
||||
<ImportEndpointModal
|
||||
preview={importPreview}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { foldersApi, endpointsApi, databasesApi } from '@/services/api';
|
||||
import { foldersApi, endpointsApi } from '@/services/api';
|
||||
import { Folder, Endpoint } from '@/types';
|
||||
import { Plus, Edit2, Trash2, Folder as FolderIcon, FolderOpen, FileCode, ChevronRight, ChevronDown } from 'lucide-react';
|
||||
import toast from 'react-hot-toast';
|
||||
import EndpointModal from '@/components/EndpointModal';
|
||||
import Dialog from '@/components/Dialog';
|
||||
|
||||
export default function Folders() {
|
||||
const queryClient = useQueryClient();
|
||||
const navigate = useNavigate();
|
||||
const [showFolderModal, setShowFolderModal] = useState(false);
|
||||
const [showEndpointModal, setShowEndpointModal] = useState(false);
|
||||
const [editingFolder, setEditingFolder] = useState<Folder | null>(null);
|
||||
const [editingEndpoint, setEditingEndpoint] = useState<Endpoint | null>(null);
|
||||
const [selectedFolderId, setSelectedFolderId] = useState<string | null>(null);
|
||||
const [expandedFolders, setExpandedFolders] = useState<Set<string>>(new Set());
|
||||
const [dialog, setDialog] = useState<{
|
||||
@@ -38,11 +37,6 @@ export default function Folders() {
|
||||
queryFn: () => endpointsApi.getAll().then(res => res.data),
|
||||
});
|
||||
|
||||
const { data: databases } = useQuery({
|
||||
queryKey: ['databases'],
|
||||
queryFn: () => databasesApi.getAll().then(res => res.data),
|
||||
});
|
||||
|
||||
const deleteFolderMutation = useMutation({
|
||||
mutationFn: (id: string) => foldersApi.delete(id),
|
||||
onSuccess: () => {
|
||||
@@ -74,14 +68,11 @@ export default function Folders() {
|
||||
};
|
||||
|
||||
const handleCreateEndpoint = (folderId?: string) => {
|
||||
setSelectedFolderId(folderId || null);
|
||||
setEditingEndpoint(null);
|
||||
setShowEndpointModal(true);
|
||||
navigate(folderId ? `/endpoints/new?folder=${folderId}` : '/endpoints/new');
|
||||
};
|
||||
|
||||
const handleEditEndpoint = (endpoint: Endpoint) => {
|
||||
setEditingEndpoint(endpoint);
|
||||
setShowEndpointModal(true);
|
||||
navigate(`/endpoints/${endpoint.id}`);
|
||||
};
|
||||
|
||||
const handleDeleteFolder = (id: string) => {
|
||||
@@ -226,15 +217,6 @@ export default function Folders() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{showEndpointModal && (
|
||||
<EndpointModal
|
||||
endpoint={editingEndpoint}
|
||||
folderId={selectedFolderId}
|
||||
databases={databases || []}
|
||||
onClose={() => setShowEndpointModal(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Dialog
|
||||
isOpen={dialog.isOpen}
|
||||
onClose={() => setDialog({ ...dialog, isOpen: false })}
|
||||
|
||||
@@ -41,6 +41,7 @@ export interface EndpointParameter {
|
||||
required: boolean;
|
||||
default_value?: any;
|
||||
description?: string;
|
||||
example_value?: string;
|
||||
in: 'query' | 'body' | 'path';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user