Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd4d9e88c6 | ||
|
|
f66d67c238 | ||
|
|
9cf25afa52 | ||
|
|
2ed2419f9e |
@@ -5,6 +5,7 @@ pub mod config;
|
|||||||
pub mod state;
|
pub mod state;
|
||||||
pub mod components;
|
pub mod components;
|
||||||
pub mod modes;
|
pub mod modes;
|
||||||
|
pub mod services;
|
||||||
|
|
||||||
pub use ui::run_ui;
|
pub use ui::run_ui;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
// src/modes/canvas/common.rs
|
// src/modes/canvas/common.rs
|
||||||
|
|
||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::tui::terminal::grpc_client::GrpcClient;
|
|
||||||
use crate::tui::terminal::core::TerminalCore;
|
use crate::tui::terminal::core::TerminalCore;
|
||||||
use crate::state::pages::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::state::state::AppState;
|
use crate::state::state::AppState;
|
||||||
|
use crate::services::grpc_client::GrpcClient;
|
||||||
|
|
||||||
use common::proto::multieko2::adresar::{PostAdresarRequest, PutAdresarRequest};
|
use common::proto::multieko2::adresar::{PostAdresarRequest, PutAdresarRequest};
|
||||||
|
|
||||||
/// Main handler for common core actions
|
/// Main handler for common core actions
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
// TODO THIS is freaking bloated with functions it never uses REFACTOR 200 LOC can be gone
|
// TODO THIS is freaking bloated with functions it never uses REFACTOR 200 LOC can be gone
|
||||||
use crossterm::event::{KeyEvent, KeyCode, KeyModifiers};
|
use crossterm::event::{KeyEvent, KeyCode, KeyModifiers};
|
||||||
use crate::tui::terminal::{
|
|
||||||
grpc_client::GrpcClient,
|
|
||||||
};
|
|
||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::state::pages::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::modes::canvas::common;
|
use crate::modes::canvas::common;
|
||||||
|
use crate::services::grpc_client::GrpcClient;
|
||||||
|
|
||||||
|
|
||||||
pub async fn handle_edit_event_internal(
|
pub async fn handle_edit_event_internal(
|
||||||
key: KeyEvent,
|
key: KeyEvent,
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ use crossterm::event::{KeyEvent};
|
|||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::state::pages::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::state::pages::auth::AuthState;
|
use crate::state::pages::auth::AuthState;
|
||||||
|
use crate::services::grpc_client::GrpcClient;
|
||||||
use crate::config::binds::key_sequences::KeySequenceTracker;
|
use crate::config::binds::key_sequences::KeySequenceTracker;
|
||||||
use crate::tui::terminal::grpc_client::GrpcClient;
|
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
enum CharType {
|
enum CharType {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// src/modes/handlers/command_mode.rs
|
// src/modes/handlers/command_mode.rs
|
||||||
|
|
||||||
use crossterm::event::{KeyEvent, KeyCode, KeyModifiers};
|
use crossterm::event::{KeyEvent, KeyCode, KeyModifiers};
|
||||||
use crate::tui::terminal::grpc_client::GrpcClient;
|
|
||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
|
use crate::services::grpc_client::GrpcClient;
|
||||||
use crate::state::pages::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::tui::controls::commands::CommandHandler;
|
use crate::tui::controls::commands::CommandHandler;
|
||||||
use crate::tui::terminal::core::TerminalCore;
|
use crate::tui::terminal::core::TerminalCore;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ use crossterm::event::Event;
|
|||||||
use crossterm::cursor::SetCursorStyle;
|
use crossterm::cursor::SetCursorStyle;
|
||||||
use crate::tui::terminal::{
|
use crate::tui::terminal::{
|
||||||
core::TerminalCore,
|
core::TerminalCore,
|
||||||
grpc_client::GrpcClient,
|
|
||||||
};
|
};
|
||||||
|
use crate::services::grpc_client::GrpcClient;
|
||||||
use crate::tui::controls::commands::CommandHandler;
|
use crate::tui::controls::commands::CommandHandler;
|
||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::state::pages::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
|
|||||||
1
client/src/services/adresar.rs
Normal file
1
client/src/services/adresar.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// src/services/adresar.rs
|
||||||
0
client/src/services/auth.rs
Normal file
0
client/src/services/auth.rs
Normal file
@@ -1,4 +1,4 @@
|
|||||||
// src/tui/terminal/grpc_client.rs
|
// src/services/grpc_client.rs
|
||||||
|
|
||||||
use tonic::transport::Channel;
|
use tonic::transport::Channel;
|
||||||
use common::proto::multieko2::adresar::adresar_client::AdresarClient;
|
use common::proto::multieko2::adresar::adresar_client::AdresarClient;
|
||||||
@@ -10,11 +10,17 @@ use common::proto::multieko2::table_definition::{
|
|||||||
table_definition_client::TableDefinitionClient,
|
table_definition_client::TableDefinitionClient,
|
||||||
ProfileTreeResponse
|
ProfileTreeResponse
|
||||||
};
|
};
|
||||||
|
use common::proto::multieko2::auth::{
|
||||||
|
auth_service_client::AuthServiceClient,
|
||||||
|
LoginRequest, LoginResponse
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct GrpcClient {
|
pub struct GrpcClient {
|
||||||
adresar_client: AdresarClient<Channel>,
|
adresar_client: AdresarClient<Channel>,
|
||||||
table_structure_client: TableStructureServiceClient<Channel>,
|
table_structure_client: TableStructureServiceClient<Channel>,
|
||||||
table_definition_client: TableDefinitionClient<Channel>,
|
table_definition_client: TableDefinitionClient<Channel>,
|
||||||
|
auth_client: AuthServiceClient<Channel>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GrpcClient {
|
impl GrpcClient {
|
||||||
@@ -22,11 +28,13 @@ impl GrpcClient {
|
|||||||
let adresar_client = AdresarClient::connect("http://[::1]:50051").await?;
|
let adresar_client = AdresarClient::connect("http://[::1]:50051").await?;
|
||||||
let table_structure_client = TableStructureServiceClient::connect("http://[::1]:50051").await?;
|
let table_structure_client = TableStructureServiceClient::connect("http://[::1]:50051").await?;
|
||||||
let table_definition_client = TableDefinitionClient::connect("http://[::1]:50051").await?;
|
let table_definition_client = TableDefinitionClient::connect("http://[::1]:50051").await?;
|
||||||
|
let auth_client = AuthServiceClient::connect("http://[::1]:50051").await?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
adresar_client,
|
adresar_client,
|
||||||
table_structure_client,
|
table_structure_client,
|
||||||
table_definition_client,
|
table_definition_client,
|
||||||
|
auth_client,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,4 +73,10 @@ impl GrpcClient {
|
|||||||
let response = self.table_definition_client.get_profile_tree(request).await?;
|
let response = self.table_definition_client.get_profile_tree(request).await?;
|
||||||
Ok(response.into_inner())
|
Ok(response.into_inner())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn login(&mut self, identifier: String, password: String) -> Result<LoginResponse, Box<dyn std::error::Error>> {
|
||||||
|
let request = tonic::Request::new(LoginRequest { identifier, password });
|
||||||
|
let response = self.auth_client.login(request).await?.into_inner();
|
||||||
|
Ok(response)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
13
client/src/services/mod.rs
Normal file
13
client/src/services/mod.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// services/mod.rs
|
||||||
|
|
||||||
|
pub mod grpc_client;
|
||||||
|
pub mod adresar;
|
||||||
|
pub mod table;
|
||||||
|
pub mod profile;
|
||||||
|
pub mod auth;
|
||||||
|
|
||||||
|
pub use grpc_client::*;
|
||||||
|
pub use adresar::*;
|
||||||
|
pub use table::*;
|
||||||
|
pub use profile::*;
|
||||||
|
pub use auth::*;
|
||||||
1
client/src/services/profile.rs
Normal file
1
client/src/services/profile.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// src/services/profile.rs
|
||||||
1
client/src/services/table.rs
Normal file
1
client/src/services/table.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// src/services/table.rs
|
||||||
@@ -9,6 +9,9 @@ pub struct AuthState {
|
|||||||
pub error_message: Option<String>,
|
pub error_message: Option<String>,
|
||||||
pub current_field: usize,
|
pub current_field: usize,
|
||||||
pub current_cursor_pos: usize,
|
pub current_cursor_pos: usize,
|
||||||
|
pub auth_token: Option<String>,
|
||||||
|
pub user_id: Option<String>,
|
||||||
|
pub role: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AuthState {
|
impl AuthState {
|
||||||
@@ -20,6 +23,9 @@ impl AuthState {
|
|||||||
error_message: None,
|
error_message: None,
|
||||||
current_field: 0,
|
current_field: 0,
|
||||||
current_cursor_pos: 0,
|
current_cursor_pos: 0,
|
||||||
|
auth_token: None,
|
||||||
|
user_id: None,
|
||||||
|
role: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// src/tui/functions/form.rs
|
// src/tui/functions/form.rs
|
||||||
use crate::state::pages::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::tui::terminal::GrpcClient;
|
use crate::services::grpc_client::GrpcClient;
|
||||||
use common::proto::multieko2::adresar::AdresarResponse;
|
use common::proto::multieko2::adresar::AdresarResponse;
|
||||||
|
|
||||||
pub async fn handle_action(
|
pub async fn handle_action(
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
// src/tui/terminal.rs
|
// src/tui/terminal.rs
|
||||||
|
|
||||||
pub mod core;
|
pub mod core;
|
||||||
pub mod grpc_client;
|
|
||||||
pub mod event_reader;
|
pub mod event_reader;
|
||||||
|
|
||||||
pub use core::TerminalCore;
|
pub use core::TerminalCore;
|
||||||
pub use grpc_client::GrpcClient;
|
|
||||||
pub use event_reader::EventReader;
|
pub use event_reader::EventReader;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// src/ui/handlers/ui.rs
|
// src/ui/handlers/ui.rs
|
||||||
|
|
||||||
use crate::tui::terminal::TerminalCore;
|
use crate::tui::terminal::TerminalCore;
|
||||||
use crate::tui::terminal::GrpcClient;
|
use crate::services::grpc_client::GrpcClient;
|
||||||
use crate::tui::controls::CommandHandler;
|
use crate::tui::controls::CommandHandler;
|
||||||
use crate::tui::terminal::EventReader;
|
use crate::tui::terminal::EventReader;
|
||||||
use crate::config::colors::themes::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
|
|||||||
Reference in New Issue
Block a user