From c65849d185f57c22f7d99cd45136564cb75de4c5 Mon Sep 17 00:00:00 2001 From: seven Date: Sat, 24 May 2025 22:50:46 +0800 Subject: [PATCH 1/3] fix: index should be null when user select the main table Signed-off-by: seven --- src-tauri/src/dynamo/scan_table.rs | 19 +++++++++++----- src/datasources/dynamoApi.ts | 4 ++-- .../dynamo-editor/components/ui-editor.vue | 22 +++++++++++-------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src-tauri/src/dynamo/scan_table.rs b/src-tauri/src/dynamo/scan_table.rs index aac06f0..5542d35 100644 --- a/src-tauri/src/dynamo/scan_table.rs +++ b/src-tauri/src/dynamo/scan_table.rs @@ -1,4 +1,5 @@ use crate::dynamo::types::ApiResponse; +use aws_sdk_dynamodb::error::ProvideErrorMetadata; use aws_sdk_dynamodb::types::AttributeValue; use aws_sdk_dynamodb::Client; use serde_json::{json, Value}; @@ -185,10 +186,18 @@ pub async fn scan_table(client: &Client, input: ScanTableInput<'_>) -> Result Ok(ApiResponse { - status: 500, - message: format!("Failed to execute scan: {:?}", e), - data: None, - }), + Err(e) => { + let error_code = e.code().unwrap_or("UnknownError").to_string(); + let error_message = e.message().unwrap_or("UnknownError").to_string(); + + Ok(ApiResponse { + status: 500, + message: format!( + "Failed to execute scan!\n\nerrorCode: {}\nmessage: {}", + error_code, error_message + ), + data: None, + }) + } } } diff --git a/src/datasources/dynamoApi.ts b/src/datasources/dynamoApi.ts index 8cfc5a1..9bfb316 100644 --- a/src/datasources/dynamoApi.ts +++ b/src/datasources/dynamoApi.ts @@ -65,10 +65,10 @@ export type DynamoDBTableInfo = { export type QueryParams = { tableName: string; - indexName: string; + indexName: string | null; partitionKey: { name: string; - value: string; + value: string | null; }; sortKey?: { name: string; diff --git a/src/views/editor/dynamo-editor/components/ui-editor.vue b/src/views/editor/dynamo-editor/components/ui-editor.vue index 7214635..6f9fd71 100644 --- a/src/views/editor/dynamo-editor/components/ui-editor.vue +++ b/src/views/editor/dynamo-editor/components/ui-editor.vue @@ -196,11 +196,11 @@ const message = useMessage(); const lang = useLang(); const dynamoQueryForm = ref<{ - index: string; - partitionKey: string; - sortKey: string; + index: string | null; + partitionKey: string | null; + sortKey: string | null; formFilterItems: Array<{ key: string; value: string; operator: string }>; -}>({ index: '', partitionKey: '', sortKey: '', formFilterItems: [] }); +}>({ index: null, partitionKey: null, sortKey: null, formFilterItems: [] }); const dynamoQueryFormRules = reactive({ index: [ @@ -240,9 +240,12 @@ const indicesOrTableOptions = ref>([]); const selectedIndexOrTable = ref(undefined); -const handleUpdate = (value: string) => { +const handleUpdate = (value: string, options: DynamoIndexOrTableOption) => { const indices = getDynamoIndexOrTableOption.value(activeConnection.value as DynamoDBConnection); - selectedIndexOrTable.value = indices.find(item => item.value === value); + selectedIndexOrTable.value = indices.find( + item => item.value === value && item.label === options.label, + ); + dynamoQueryForm.value.index = selectedIndexOrTable.value!.value; }; @@ -311,12 +314,13 @@ const handleSubmit = async (event: MouseEvent) => { try { const { tableName } = activeConnection.value as DynamoDBConnection; const { partitionKey, sortKey, formFilterItems } = dynamoQueryForm.value; - const { partitionKeyName, sortKeyName, value } = + const { partitionKeyName, sortKeyName, value, label } = selectedIndexOrTable.value as DynamoIndexOrTableOption; + // Build query parameters const queryParams = { tableName, - indexName: value, + indexName: label.startsWith('Table - ') ? null : value, partitionKey: { name: partitionKeyName, value: partitionKey }, sortKey: sortKeyName && sortKey ? { name: sortKeyName, value: sortKey } : undefined, filters: formFilterItems, @@ -356,7 +360,7 @@ const handleSubmit = async (event: MouseEvent) => { const handleReset = () => { selectedIndexOrTable.value = undefined; - dynamoQueryForm.value = { index: '', partitionKey: '', sortKey: '', formFilterItems: [] }; + dynamoQueryForm.value = { index: null, partitionKey: null, sortKey: null, formFilterItems: [] }; if (dynamoQueryFormRef.value) { dynamoQueryFormRef.value.restoreValidation(); From 8b9d77d2f1fe7c7defec94c859a92c593254073b Mon Sep 17 00:00:00 2001 From: seven Date: Sun, 25 May 2025 00:25:46 +0800 Subject: [PATCH 2/3] fix: ui query editor scrollbar issue Signed-off-by: seven --- .../dynamo-editor/components/ui-editor.vue | 351 ++++++++++-------- 1 file changed, 203 insertions(+), 148 deletions(-) diff --git a/src/views/editor/dynamo-editor/components/ui-editor.vue b/src/views/editor/dynamo-editor/components/ui-editor.vue index 6f9fd71..7bcb84f 100644 --- a/src/views/editor/dynamo-editor/components/ui-editor.vue +++ b/src/views/editor/dynamo-editor/components/ui-editor.vue @@ -1,154 +1,177 @@