feat(desktop): show batch drop progress
This commit is contained in:
11 files changed
+453
-37
No files matched your search
@@ -179,6 +179,7 @@ export const generateSchemaSyncSql = forward("generateSchemaSyncSql");
|
||||
// Query
|
||||
export const executeQuery = forward("executeQuery");
|
||||
export const executeMulti = forward("executeMulti");
|
||||
export const executeMultiWithProgress = forward("executeMultiWithProgress");
|
||||
export const executeBatch = forward("executeBatch");
|
||||
export const executeScript = forward("executeScript");
|
||||
export const executeInTransaction = forward("executeInTransaction");
|
||||
|
||||
@@ -820,6 +820,37 @@ export async function executeMulti(
|
||||
return post("/api/query/execute-multi", { connectionId, database, sql, schema, executionId, ...options });
|
||||
}
|
||||
|
||||
export interface ExecuteMultiProgress {
|
||||
executionId: string;
|
||||
completed: number;
|
||||
total: number;
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export async function executeMultiWithProgress(
|
||||
connectionId: string,
|
||||
database: string,
|
||||
sql: string,
|
||||
onProgress: (progress: ExecuteMultiProgress) => void,
|
||||
schema?: string,
|
||||
options?: {
|
||||
maxRows?: number;
|
||||
fetchSize?: number;
|
||||
pageSize?: number;
|
||||
resultSessionId?: string;
|
||||
clientSessionId?: string;
|
||||
timeoutSecs?: number;
|
||||
useTransaction?: boolean;
|
||||
continueOnError?: boolean;
|
||||
executionMode?: "simple";
|
||||
},
|
||||
): Promise<QueryResult[]> {
|
||||
const executionId = crypto.randomUUID();
|
||||
const results = await executeMulti(connectionId, database, sql, schema, executionId, options);
|
||||
onProgress({ executionId, completed: results.length, total: results.length, success: !results.some((result) => result.execution_error === true) });
|
||||
return results;
|
||||
}
|
||||
|
||||
export async function closeQuerySession(connectionId: string, database: string, sessionId: string, clientSessionId?: string): Promise<boolean> {
|
||||
return post("/api/query/close-session", { connectionId, database, sessionId, clientSessionId });
|
||||
}
|
||||
|
||||
@@ -939,6 +939,42 @@ export async function executeMulti(
|
||||
return invoke("execute_multi", { connectionId, database, sql, schema, executionId, ...options });
|
||||
}
|
||||
|
||||
export interface ExecuteMultiProgress {
|
||||
executionId: string;
|
||||
completed: number;
|
||||
total: number;
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export async function executeMultiWithProgress(
|
||||
connectionId: string,
|
||||
database: string,
|
||||
sql: string,
|
||||
onProgress: (progress: ExecuteMultiProgress) => void,
|
||||
schema?: string,
|
||||
options?: {
|
||||
maxRows?: number;
|
||||
fetchSize?: number;
|
||||
pageSize?: number;
|
||||
resultSessionId?: string;
|
||||
clientSessionId?: string;
|
||||
timeoutSecs?: number;
|
||||
useTransaction?: boolean;
|
||||
continueOnError?: boolean;
|
||||
executionMode?: "simple";
|
||||
},
|
||||
): Promise<QueryResult[]> {
|
||||
const executionId = crypto.randomUUID();
|
||||
const unlisten = await listen<ExecuteMultiProgress>("query-batch-progress", (event) => {
|
||||
if (event.payload.executionId === executionId) onProgress(event.payload);
|
||||
});
|
||||
try {
|
||||
return await invoke("execute_multi", { connectionId, database, sql, schema, executionId, ...options });
|
||||
} finally {
|
||||
unlisten();
|
||||
}
|
||||
}
|
||||
|
||||
export async function refreshConnections(): Promise<void> {
|
||||
return invoke("refresh_connections");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user