init
This commit is contained in:
1 parent
c7fccf99c7
commit
8471f368eb
33 files changed
+444
-2095
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { ArrowLeft, Database, Table2, Users, Clock, Cpu, Play, RefreshCw } from 'lucide-react';
|
||||
import { ArrowLeft, Database, Table2, Users, Cpu, Play, RefreshCw } from 'lucide-react';
|
||||
import { instanceDetailApi } from '@/api/instanceDetail';
|
||||
import { instanceApi } from '@/api/instance';
|
||||
import { queryApi } from '@/api/query';
|
||||
@@ -10,7 +10,7 @@ interface InstanceInfo {
|
||||
status: string; version: string | null; env: string;
|
||||
}
|
||||
|
||||
type TabKey = 'overview' | 'tables' | 'query' | 'users' | 'slow' | 'process';
|
||||
type TabKey = 'overview' | 'tables' | 'query' | 'users' | 'process';
|
||||
|
||||
export default function InstanceDetailPage() {
|
||||
var params = useParams<{ id: string }>();
|
||||
@@ -23,7 +23,6 @@ export default function InstanceDetailPage() {
|
||||
var [selectedDb, setSelectedDb] = useState('');
|
||||
var [tables, setTables] = useState<any[]>([]);
|
||||
var [users, setUsers] = useState<any[]>([]);
|
||||
var [slowQueries, setSlowQueries] = useState<any[]>([]);
|
||||
var [processes, setProcesses] = useState<any[]>([]);
|
||||
var [sqlText, setSqlText] = useState('');
|
||||
var [queryResult, setQueryResult] = useState<any>(null);
|
||||
@@ -34,7 +33,6 @@ export default function InstanceDetailPage() {
|
||||
{ key: 'tables', label: '表管理', icon: Table2 },
|
||||
{ key: 'query', label: 'SQL查询', icon: Play },
|
||||
{ key: 'users', label: '用户权限', icon: Users },
|
||||
{ key: 'slow', label: '慢查询', icon: Clock },
|
||||
{ key: 'process', label: '进程列表', icon: Cpu },
|
||||
];
|
||||
|
||||
@@ -57,11 +55,6 @@ export default function InstanceDetailPage() {
|
||||
setUsers(res.users || res || []);
|
||||
}).catch(function () { setUsers([]); });
|
||||
}
|
||||
if (activeTab === 'slow') {
|
||||
instanceDetailApi.getSlowQueries(instanceId, selectedDb).then(function (res: any) {
|
||||
setSlowQueries(res.queries || res || []);
|
||||
}).catch(function () { setSlowQueries([]); });
|
||||
}
|
||||
if (activeTab === 'process') {
|
||||
instanceDetailApi.getProcesslist(instanceId).then(function (res: any) {
|
||||
setProcesses(res.processes || res || []);
|
||||
@@ -236,28 +229,6 @@ export default function InstanceDetailPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 慢查询 */}
|
||||
{activeTab === 'slow' && (
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm">
|
||||
<thead><tr className="text-left text-[var(--dg-text-muted)] border-b border-[var(--dg-border)]">
|
||||
<th className="px-4 py-2">SQL</th><th className="px-4 py-2">执行时间</th><th className="px-4 py-2">扫描行数</th><th className="px-4 py-2">时间</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
{slowQueries.map(function (q: any, i: number) {
|
||||
return <tr key={i} className="border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)]">
|
||||
<td className="px-4 py-2 max-w-md truncate font-mono text-xs">{q.sql_text || q.SQL || '-'}</td>
|
||||
<td className="px-4 py-2">{q.query_time || q.Time || '-'}</td>
|
||||
<td className="px-4 py-2">{q.rows_examined || q.ScanRows || '-'}</td>
|
||||
<td className="px-4 py-2">{q.start_time || q.Timestamp || '-'}</td>
|
||||
</tr>;
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
{slowQueries.length === 0 && <div className="text-center py-8 text-[var(--dg-text-muted)]">暂无慢查询记录</div>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 进程列表 */}
|
||||
{activeTab === 'process' && (
|
||||
<div className="overflow-x-auto">
|
||||
|
||||
Reference in new issue
Block a user