neccessary hardcode changes to fix the last changes introducing bug. general solution soon

This commit is contained in:
filipriec
2025-05-25 19:16:42 +02:00
parent 685361a11a
commit 5afb427bb4
2 changed files with 25 additions and 7 deletions

View File

@@ -5,7 +5,8 @@ use common::proto::multieko2::adresar::adresar_client::AdresarClient;
use common::proto::multieko2::adresar::{AdresarResponse, PostAdresarRequest, PutAdresarRequest}; use common::proto::multieko2::adresar::{AdresarResponse, PostAdresarRequest, PutAdresarRequest};
use common::proto::multieko2::common::{CountResponse, PositionRequest, Empty}; use common::proto::multieko2::common::{CountResponse, PositionRequest, Empty};
use common::proto::multieko2::table_structure::table_structure_service_client::TableStructureServiceClient; use common::proto::multieko2::table_structure::table_structure_service_client::TableStructureServiceClient;
use common::proto::multieko2::table_structure::TableStructureResponse; // Import the new request type for table structure
use common::proto::multieko2::table_structure::{TableStructureResponse, GetTableStructureRequest};
use common::proto::multieko2::table_definition::{ use common::proto::multieko2::table_definition::{
table_definition_client::TableDefinitionClient, table_definition_client::TableDefinitionClient,
ProfileTreeResponse, PostTableDefinitionRequest, TableDefinitionResponse, ProfileTreeResponse, PostTableDefinitionRequest, TableDefinitionResponse,
@@ -63,9 +64,20 @@ impl GrpcClient {
Ok(response) Ok(response)
} }
pub async fn get_table_structure(&mut self) -> Result<TableStructureResponse> { // Updated get_table_structure method
let request = tonic::Request::new(Empty::default()); pub async fn get_table_structure(
let response = self.table_structure_client.get_adresar_table_structure(request).await?; &mut self,
profile_name: String,
table_name: String,
) -> Result<TableStructureResponse> {
// Create the new request type
let grpc_request = GetTableStructureRequest {
profile_name,
table_name,
};
let request = tonic::Request::new(grpc_request);
// Call the new gRPC method
let response = self.table_structure_client.get_table_structure(request).await?;
Ok(response.into_inner()) Ok(response.into_inner())
} }
@@ -87,4 +99,3 @@ impl GrpcClient {
Ok(response.into_inner()) Ok(response.into_inner())
} }
} }

View File

@@ -17,8 +17,15 @@ impl UiService {
let profile_tree = grpc_client.get_profile_tree().await.context("Failed to get profile tree")?; let profile_tree = grpc_client.get_profile_tree().await.context("Failed to get profile tree")?;
app_state.profile_tree = profile_tree; app_state.profile_tree = profile_tree;
// Fetch table structure // TODO for general tables and not hardcoded
let table_structure = grpc_client.get_table_structure().await?; let default_profile_name = "default".to_string();
let default_table_name = "2025_customer".to_string();
// Fetch table structure for the default table
let table_structure = grpc_client
.get_table_structure(default_profile_name, default_table_name)
.await
.context("Failed to get initial table structure")?;
// Extract the column names from the response // Extract the column names from the response
let column_names: Vec<String> = table_structure let column_names: Vec<String> = table_structure