complete redesign oh how client is displaying data
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
// src/services/grpc_client.rs
|
||||
|
||||
use tonic::transport::Channel;
|
||||
use common::proto::multieko2::common::{CountResponse, Empty};
|
||||
use common::proto::multieko2::common::Empty;
|
||||
use common::proto::multieko2::table_structure::table_structure_service_client::TableStructureServiceClient;
|
||||
use common::proto::multieko2::table_structure::{GetTableStructureRequest, TableStructureResponse};
|
||||
use common::proto::multieko2::table_definition::{
|
||||
@@ -25,6 +24,7 @@ use common::proto::multieko2::search::{
|
||||
};
|
||||
use anyhow::{Context, Result};
|
||||
use std::collections::HashMap;
|
||||
use tonic::transport::Channel;
|
||||
use prost_types::Value;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -155,18 +155,14 @@ pub async fn get_table_data_by_position(
|
||||
Ok(response.into_inner())
|
||||
}
|
||||
|
||||
pub async fn post_table_data(
|
||||
pub async fn post_table_data(
|
||||
&mut self,
|
||||
profile_name: String,
|
||||
table_name: String,
|
||||
data: HashMap<String, String>,
|
||||
// CHANGE THIS: Accept the pre-converted data
|
||||
data: HashMap<String, Value>,
|
||||
) -> Result<PostTableDataResponse> {
|
||||
// 2. CONVERT THE HASHMAP
|
||||
let data: HashMap<String, Value> = data
|
||||
.into_iter()
|
||||
.map(|(k, v)| (k, Value::from(v)))
|
||||
.collect();
|
||||
|
||||
// The conversion logic is now gone from here.
|
||||
let grpc_request = PostTableDataRequest {
|
||||
profile_name,
|
||||
table_name,
|
||||
@@ -186,14 +182,10 @@ pub async fn post_table_data(
|
||||
profile_name: String,
|
||||
table_name: String,
|
||||
id: i64,
|
||||
data: HashMap<String, String>,
|
||||
// CHANGE THIS: Accept the pre-converted data
|
||||
data: HashMap<String, Value>,
|
||||
) -> Result<PutTableDataResponse> {
|
||||
// 2. CONVERT THE HASHMAP
|
||||
let data: HashMap<String, Value> = data
|
||||
.into_iter()
|
||||
.map(|(k, v)| (k, Value::from(v)))
|
||||
.collect();
|
||||
|
||||
// The conversion logic is now gone from here.
|
||||
let grpc_request = PutTableDataRequest {
|
||||
profile_name,
|
||||
table_name,
|
||||
|
||||
@@ -7,6 +7,7 @@ use crate::state::pages::add_logic::AddLogicState;
|
||||
use crate::state::app::state::AppState;
|
||||
use crate::utils::columns::filter_user_columns;
|
||||
use anyhow::{Context, Result};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct UiService;
|
||||
|
||||
@@ -102,7 +103,6 @@ impl UiService {
|
||||
.context("Failed to get profile tree")?;
|
||||
app_state.profile_tree = profile_tree;
|
||||
|
||||
// Determine initial table to load (e.g., first table of first profile, or a default)
|
||||
let initial_profile_name = app_state
|
||||
.profile_tree
|
||||
.profiles
|
||||
@@ -115,7 +115,7 @@ impl UiService {
|
||||
.profiles
|
||||
.first()
|
||||
.and_then(|p| p.tables.first().map(|t| t.name.clone()))
|
||||
.unwrap_or_else(|| "2025_company_data1".to_string()); // Fallback if no tables
|
||||
.unwrap_or_else(|| "2025_company_data1".to_string());
|
||||
|
||||
app_state.set_current_view_table(
|
||||
initial_profile_name.clone(),
|
||||
@@ -133,6 +133,15 @@ impl UiService {
|
||||
initial_profile_name, initial_table_name
|
||||
))?;
|
||||
|
||||
// NEW: Populate the "Rulebook" cache
|
||||
let cache_key = format!(
|
||||
"{}.{}",
|
||||
initial_profile_name, initial_table_name
|
||||
);
|
||||
app_state
|
||||
.schema_cache
|
||||
.insert(cache_key, Arc::new(table_structure.clone()));
|
||||
|
||||
let column_names: Vec<String> = table_structure
|
||||
.columns
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user