fix: align frontend interfaces with backend DTO field names
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,14 +2,16 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import { adminFetch } from './admin-api';
|
||||
|
||||
export interface AuditEvent {
|
||||
id: string;
|
||||
id: number;
|
||||
timestamp: string;
|
||||
username: string;
|
||||
category: string;
|
||||
action: string;
|
||||
category: string;
|
||||
target: string;
|
||||
result: string;
|
||||
detail: Record<string, unknown>;
|
||||
result: string;
|
||||
ipAddress: string;
|
||||
userAgent: string;
|
||||
}
|
||||
|
||||
export interface AuditLogParams {
|
||||
@@ -18,13 +20,18 @@ export interface AuditLogParams {
|
||||
username?: string;
|
||||
category?: string;
|
||||
search?: string;
|
||||
sort?: string;
|
||||
order?: string;
|
||||
page?: number;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
export interface AuditLogResponse {
|
||||
events: AuditEvent[];
|
||||
total: number;
|
||||
items: AuditEvent[];
|
||||
totalCount: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
totalPages: number;
|
||||
}
|
||||
|
||||
export function useAuditLog(params: AuditLogParams) {
|
||||
@@ -34,6 +41,8 @@ export function useAuditLog(params: AuditLogParams) {
|
||||
if (params.username) query.set('username', params.username);
|
||||
if (params.category) query.set('category', params.category);
|
||||
if (params.search) query.set('search', params.search);
|
||||
if (params.sort) query.set('sort', params.sort);
|
||||
if (params.order) query.set('order', params.order);
|
||||
if (params.page !== undefined) query.set('page', String(params.page));
|
||||
if (params.size !== undefined) query.set('size', String(params.size));
|
||||
const qs = query.toString();
|
||||
|
||||
@@ -6,26 +6,29 @@ export interface DatabaseStatus {
|
||||
version: string;
|
||||
host: string;
|
||||
schema: string;
|
||||
timescaleDb: boolean;
|
||||
}
|
||||
|
||||
export interface PoolStats {
|
||||
activeConnections: number;
|
||||
idleConnections: number;
|
||||
pendingConnections: number;
|
||||
maxConnections: number;
|
||||
maxWaitMillis: number;
|
||||
pendingThreads: number;
|
||||
maxPoolSize: number;
|
||||
maxWaitMs: number;
|
||||
}
|
||||
|
||||
export interface TableInfo {
|
||||
tableName: string;
|
||||
rowEstimate: number;
|
||||
rowCount: number;
|
||||
dataSize: string;
|
||||
indexSize: string;
|
||||
dataSizeBytes: number;
|
||||
indexSizeBytes: number;
|
||||
}
|
||||
|
||||
export interface ActiveQuery {
|
||||
pid: number;
|
||||
durationMs: number;
|
||||
durationSeconds: number;
|
||||
state: string;
|
||||
query: string;
|
||||
}
|
||||
@@ -64,7 +67,7 @@ export function useKillQuery() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (pid: number) => {
|
||||
await adminFetch<void>(`/database/queries/${pid}`, { method: 'DELETE' });
|
||||
await adminFetch<void>(`/database/queries/${pid}/kill`, { method: 'POST' });
|
||||
},
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['admin', 'database', 'queries'] }),
|
||||
});
|
||||
|
||||
@@ -2,47 +2,54 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { adminFetch } from './admin-api';
|
||||
|
||||
export interface OpenSearchStatus {
|
||||
connected: boolean;
|
||||
clusterName: string;
|
||||
reachable: boolean;
|
||||
clusterHealth: string;
|
||||
version: string;
|
||||
numberOfNodes: number;
|
||||
nodeCount: number;
|
||||
host: string;
|
||||
}
|
||||
|
||||
export interface PipelineStats {
|
||||
queueDepth: number;
|
||||
maxQueueSize: number;
|
||||
totalIndexed: number;
|
||||
totalFailed: number;
|
||||
avgLatencyMs: number;
|
||||
indexedCount: number;
|
||||
failedCount: number;
|
||||
debounceMs: number;
|
||||
indexingRate: number;
|
||||
lastIndexedAt: string | null;
|
||||
}
|
||||
|
||||
export interface IndexInfo {
|
||||
name: string;
|
||||
health: string;
|
||||
status: string;
|
||||
docsCount: number;
|
||||
storeSize: string;
|
||||
docCount: number;
|
||||
size: string;
|
||||
sizeBytes: number;
|
||||
primaryShards: number;
|
||||
replicas: number;
|
||||
replicaShards: number;
|
||||
}
|
||||
|
||||
export interface IndicesPageResponse {
|
||||
indices: IndexInfo[];
|
||||
totalIndices: number;
|
||||
totalDocs: number;
|
||||
totalSize: string;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
totalPages: number;
|
||||
}
|
||||
|
||||
export interface PerformanceStats {
|
||||
queryCacheHitRate: number;
|
||||
requestCacheHitRate: number;
|
||||
avgQueryLatencyMs: number;
|
||||
avgIndexLatencyMs: number;
|
||||
jvmHeapUsedPercent: number;
|
||||
searchLatencyMs: number;
|
||||
indexingLatencyMs: number;
|
||||
jvmHeapUsedBytes: number;
|
||||
jvmHeapMaxBytes: number;
|
||||
}
|
||||
|
||||
export interface IndicesParams {
|
||||
search?: string;
|
||||
health?: string;
|
||||
sortBy?: string;
|
||||
sortDir?: 'asc' | 'desc';
|
||||
page?: number;
|
||||
size?: number;
|
||||
}
|
||||
@@ -65,9 +72,6 @@ export function usePipelineStats() {
|
||||
export function useIndices(params: IndicesParams) {
|
||||
const query = new URLSearchParams();
|
||||
if (params.search) query.set('search', params.search);
|
||||
if (params.health) query.set('health', params.health);
|
||||
if (params.sortBy) query.set('sortBy', params.sortBy);
|
||||
if (params.sortDir) query.set('sortDir', params.sortDir);
|
||||
if (params.page !== undefined) query.set('page', String(params.page));
|
||||
if (params.size !== undefined) query.set('size', String(params.size));
|
||||
const qs = query.toString();
|
||||
@@ -75,7 +79,7 @@ export function useIndices(params: IndicesParams) {
|
||||
return useQuery({
|
||||
queryKey: ['admin', 'opensearch', 'indices', params],
|
||||
queryFn: () =>
|
||||
adminFetch<{ indices: IndexInfo[]; total: number }>(
|
||||
adminFetch<IndicesPageResponse>(
|
||||
`/opensearch/indices${qs ? `?${qs}` : ''}`,
|
||||
),
|
||||
});
|
||||
|
||||
@@ -1,29 +1,41 @@
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { adminFetch } from './admin-api';
|
||||
|
||||
export interface Thresholds {
|
||||
poolWarningPercent: number;
|
||||
poolCriticalPercent: number;
|
||||
queryDurationWarningSeconds: number;
|
||||
queryDurationCriticalSeconds: number;
|
||||
osQueueWarningPercent: number;
|
||||
osQueueCriticalPercent: number;
|
||||
osHeapWarningPercent: number;
|
||||
osHeapCriticalPercent: number;
|
||||
export interface DatabaseThresholds {
|
||||
connectionPoolWarning: number;
|
||||
connectionPoolCritical: number;
|
||||
queryDurationWarning: number;
|
||||
queryDurationCritical: number;
|
||||
}
|
||||
|
||||
export interface OpenSearchThresholds {
|
||||
clusterHealthWarning: string;
|
||||
clusterHealthCritical: string;
|
||||
queueDepthWarning: number;
|
||||
queueDepthCritical: number;
|
||||
jvmHeapWarning: number;
|
||||
jvmHeapCritical: number;
|
||||
failedDocsWarning: number;
|
||||
failedDocsCritical: number;
|
||||
}
|
||||
|
||||
export interface ThresholdConfig {
|
||||
database: DatabaseThresholds;
|
||||
opensearch: OpenSearchThresholds;
|
||||
}
|
||||
|
||||
export function useThresholds() {
|
||||
return useQuery({
|
||||
queryKey: ['admin', 'thresholds'],
|
||||
queryFn: () => adminFetch<Thresholds>('/thresholds'),
|
||||
queryFn: () => adminFetch<ThresholdConfig>('/thresholds'),
|
||||
});
|
||||
}
|
||||
|
||||
export function useSaveThresholds() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (body: Thresholds) => {
|
||||
await adminFetch<Thresholds>('/thresholds', {
|
||||
mutationFn: async (body: ThresholdConfig) => {
|
||||
await adminFetch<ThresholdConfig>('/thresholds', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user