Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b408abe8c6 | ||
|
|
722c63af54 | ||
|
|
4601ba4094 | ||
|
|
3e2b8a36df | ||
|
|
11214734ae | ||
|
|
92045a4e67 | ||
|
|
9564bd8524 | ||
|
|
ad64df2ec3 | ||
|
|
aab11c1cba | ||
|
|
1fe139e0c5 | ||
|
|
4ced1a36d4 | ||
|
|
45fff34c4c | ||
|
|
c84fa4a692 |
@@ -4,3 +4,5 @@ RUST_DB_USER=multi_psql_dev
|
|||||||
RUST_DB_PASSWORD=3
|
RUST_DB_PASSWORD=3
|
||||||
RUST_DB_HOST=localhost
|
RUST_DB_HOST=localhost
|
||||||
RUST_DB_PORT=5432
|
RUST_DB_PORT=5432
|
||||||
|
|
||||||
|
JWT_SECRET=<YOUR-JWT-HERE>
|
||||||
|
|||||||
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -421,7 +421,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "client"
|
name = "client"
|
||||||
version = "0.2.0"
|
version = "0.2.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"common",
|
"common",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
@@ -457,7 +457,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "0.2.0"
|
version = "0.2.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"prost",
|
"prost",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2588,7 +2588,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "server"
|
name = "server"
|
||||||
version = "0.2.0"
|
version = "0.2.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ resolver = "2"
|
|||||||
[workspace.package]
|
[workspace.package]
|
||||||
# TODO: idk how to do the name, fix later
|
# TODO: idk how to do the name, fix later
|
||||||
# name = "Multieko2"
|
# name = "Multieko2"
|
||||||
version = "0.2.0"
|
version = "0.2.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
authors = ["Filip Priečinský <filippriec@gmail.com>"]
|
authors = ["Filip Priečinský <filippriec@gmail.com>"]
|
||||||
|
|||||||
5
client/src/components/auth.rs
Normal file
5
client/src/components/auth.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
// src/components/form.rs
|
||||||
|
pub mod login;
|
||||||
|
pub mod register;
|
||||||
|
|
||||||
|
pub use login::*;
|
||||||
58
client/src/components/auth/login.rs
Normal file
58
client/src/components/auth/login.rs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
// src/components/auth/login.rs
|
||||||
|
|
||||||
|
use ratatui::{
|
||||||
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
|
style::Style,
|
||||||
|
widgets::{Block, BorderType, Borders, Paragraph},
|
||||||
|
Frame,
|
||||||
|
};
|
||||||
|
use crate::{
|
||||||
|
config::colors::themes::Theme,
|
||||||
|
state::pages::auth::AuthState
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn render_login(f: &mut Frame, area: Rect, theme: &Theme, state: &mut AuthState) {
|
||||||
|
let block = Block::default()
|
||||||
|
.borders(Borders::ALL)
|
||||||
|
.border_type(BorderType::Rounded)
|
||||||
|
.border_style(Style::default().fg(theme.accent))
|
||||||
|
.style(Style::default().bg(theme.bg))
|
||||||
|
.title(" Login ");
|
||||||
|
|
||||||
|
let inner_area = block.inner(area);
|
||||||
|
f.render_widget(block, area);
|
||||||
|
|
||||||
|
let chunks = Layout::default()
|
||||||
|
.direction(Direction::Vertical)
|
||||||
|
.constraints([
|
||||||
|
Constraint::Percentage(40),
|
||||||
|
Constraint::Length(3),
|
||||||
|
Constraint::Percentage(40),
|
||||||
|
])
|
||||||
|
.split(inner_area);
|
||||||
|
|
||||||
|
let button_style = if state.return_selected {
|
||||||
|
Style::default()
|
||||||
|
.fg(theme.highlight)
|
||||||
|
.add_modifier(ratatui::style::Modifier::BOLD)
|
||||||
|
} else {
|
||||||
|
Style::default().fg(theme.fg)
|
||||||
|
};
|
||||||
|
|
||||||
|
f.render_widget(
|
||||||
|
Paragraph::new("Return to Intro")
|
||||||
|
.style(button_style)
|
||||||
|
.alignment(Alignment::Center)
|
||||||
|
.block(
|
||||||
|
Block::default()
|
||||||
|
.borders(Borders::ALL)
|
||||||
|
.border_type(BorderType::Plain)
|
||||||
|
.border_style(if state.return_selected {
|
||||||
|
Style::default().fg(theme.accent)
|
||||||
|
} else {
|
||||||
|
Style::default().fg(theme.border)
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
chunks[1]
|
||||||
|
);
|
||||||
|
}
|
||||||
0
client/src/components/auth/register.rs
Normal file
0
client/src/components/auth/register.rs
Normal file
@@ -6,7 +6,7 @@ use ratatui::{
|
|||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use crate::config::colors::themes::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use crate::ui::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::components::handlers::canvas::render_canvas;
|
use crate::components::handlers::canvas::render_canvas;
|
||||||
|
|
||||||
pub fn render_form(
|
pub fn render_form(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use ratatui::{
|
|||||||
prelude::Alignment,
|
prelude::Alignment,
|
||||||
};
|
};
|
||||||
use crate::config::colors::themes::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use crate::ui::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
|
|
||||||
pub fn render_canvas(
|
pub fn render_canvas(
|
||||||
f: &mut Frame,
|
f: &mut Frame,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// src/components/handlers/intro.rs
|
// src/components/intro/intro.rs
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
style::Style,
|
style::Style,
|
||||||
@@ -33,7 +33,7 @@ impl IntroState {
|
|||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints([
|
.constraints([
|
||||||
Constraint::Percentage(35),
|
Constraint::Percentage(35),
|
||||||
Constraint::Length(5),
|
Constraint::Length(7), // Increased to accommodate 3 buttons
|
||||||
Constraint::Percentage(35),
|
Constraint::Percentage(35),
|
||||||
])
|
])
|
||||||
.split(inner_area);
|
.split(inner_area);
|
||||||
@@ -48,10 +48,14 @@ impl IntroState {
|
|||||||
.alignment(Alignment::Center);
|
.alignment(Alignment::Center);
|
||||||
f.render_widget(title_para, chunks[1]);
|
f.render_widget(title_para, chunks[1]);
|
||||||
|
|
||||||
// Buttons
|
// Buttons - now with 3 options
|
||||||
let button_area = Layout::default()
|
let button_area = Layout::default()
|
||||||
.direction(Direction::Horizontal)
|
.direction(Direction::Horizontal)
|
||||||
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)])
|
.constraints([
|
||||||
|
Constraint::Percentage(33),
|
||||||
|
Constraint::Percentage(33),
|
||||||
|
Constraint::Percentage(33),
|
||||||
|
])
|
||||||
.split(chunks[1].inner(Margin {
|
.split(chunks[1].inner(Margin {
|
||||||
horizontal: 1,
|
horizontal: 1,
|
||||||
vertical: 1
|
vertical: 1
|
||||||
@@ -71,6 +75,13 @@ impl IntroState {
|
|||||||
self.selected_option == 1,
|
self.selected_option == 1,
|
||||||
theme,
|
theme,
|
||||||
);
|
);
|
||||||
|
self.render_button(
|
||||||
|
f,
|
||||||
|
button_area[2],
|
||||||
|
"Login",
|
||||||
|
self.selected_option == 2,
|
||||||
|
theme,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_button(&self, f: &mut Frame, area: Rect, text: &str, selected: bool, theme: &Theme) {
|
fn render_button(&self, f: &mut Frame, area: Rect, text: &str, selected: bool, theme: &Theme) {
|
||||||
@@ -100,11 +111,11 @@ impl IntroState {
|
|||||||
f.render_widget(button, area);
|
f.render_widget(button, area);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_option(&mut self) {
|
pub fn next_option(&mut self) {
|
||||||
self.selected_option = (self.selected_option + 1) % 2;
|
self.selected_option = (self.selected_option + 1) % 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn previous_option(&mut self) {
|
pub fn previous_option(&mut self) {
|
||||||
self.selected_option = if self.selected_option == 0 { 1 } else { 0 };
|
self.selected_option = if self.selected_option == 0 { 2 } else { self.selected_option - 1 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ pub mod intro;
|
|||||||
pub mod admin;
|
pub mod admin;
|
||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod form;
|
pub mod form;
|
||||||
|
pub mod auth;
|
||||||
|
|
||||||
pub use handlers::*;
|
pub use handlers::*;
|
||||||
pub use intro::*;
|
pub use intro::*;
|
||||||
pub use admin::*;
|
pub use admin::*;
|
||||||
pub use common::*;
|
pub use common::*;
|
||||||
pub use form::*;
|
pub use form::*;
|
||||||
|
pub use auth::*;
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
// src/modes/canvas/common.rs
|
// src/modes/canvas/common.rs
|
||||||
|
|
||||||
use crossterm::event::{KeyEvent};
|
|
||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::tui::terminal::grpc_client::GrpcClient;
|
use crate::tui::terminal::grpc_client::GrpcClient;
|
||||||
use crate::tui::terminal::core::TerminalCore;
|
use crate::tui::terminal::core::TerminalCore;
|
||||||
use crate::tui::controls::commands::CommandHandler;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::ui::handlers::form::FormState;
|
|
||||||
use crate::state::state::AppState;
|
use crate::state::state::AppState;
|
||||||
use common::proto::multieko2::adresar::{PostAdresarRequest, PutAdresarRequest};
|
use common::proto::multieko2::adresar::{PostAdresarRequest, PutAdresarRequest};
|
||||||
|
|
||||||
@@ -14,7 +12,6 @@ pub async fn handle_core_action(
|
|||||||
action: &str,
|
action: &str,
|
||||||
form_state: &mut FormState,
|
form_state: &mut FormState,
|
||||||
grpc_client: &mut GrpcClient,
|
grpc_client: &mut GrpcClient,
|
||||||
command_handler: &mut CommandHandler,
|
|
||||||
terminal: &mut TerminalCore,
|
terminal: &mut TerminalCore,
|
||||||
app_state: &mut AppState,
|
app_state: &mut AppState,
|
||||||
current_position: &mut u64,
|
current_position: &mut u64,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use crate::tui::terminal::{
|
|||||||
grpc_client::GrpcClient,
|
grpc_client::GrpcClient,
|
||||||
};
|
};
|
||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::ui::handlers::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::modes::canvas::common;
|
use crate::modes::canvas::common;
|
||||||
|
|
||||||
pub async fn handle_edit_event_internal(
|
pub async fn handle_edit_event_internal(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use crossterm::event::{KeyEvent};
|
use crossterm::event::{KeyEvent};
|
||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::ui::handlers::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::config::binds::key_sequences::KeySequenceTracker;
|
use crate::config::binds::key_sequences::KeySequenceTracker;
|
||||||
use crate::tui::terminal::grpc_client::GrpcClient;
|
use crate::tui::terminal::grpc_client::GrpcClient;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
use crossterm::event::{KeyEvent, KeyCode, KeyModifiers};
|
use crossterm::event::{KeyEvent, KeyCode, KeyModifiers};
|
||||||
use crate::tui::terminal::grpc_client::GrpcClient;
|
use crate::tui::terminal::grpc_client::GrpcClient;
|
||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::ui::handlers::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;
|
||||||
use crate::modes::{
|
use crate::modes::{
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
use crossterm::event::KeyEvent;
|
use crossterm::event::KeyEvent;
|
||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::state::state::AppState;
|
use crate::state::state::AppState;
|
||||||
use crate::ui::handlers::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
|
use crate::tui::functions::{intro, admin};
|
||||||
|
|
||||||
pub async fn handle_navigation_event(
|
pub async fn handle_navigation_event(
|
||||||
key: KeyEvent,
|
key: KeyEvent,
|
||||||
@@ -21,16 +22,11 @@ pub async fn handle_navigation_event(
|
|||||||
return Ok((false, String::new()));
|
return Ok((false, String::new()));
|
||||||
}
|
}
|
||||||
"move_down" => {
|
"move_down" => {
|
||||||
let item_count = if app_state.ui.show_intro {
|
move_down(app_state);
|
||||||
2 // Intro options count
|
|
||||||
} else {
|
|
||||||
app_state.profile_tree.profiles.len() // Admin panel items
|
|
||||||
};
|
|
||||||
move_down(app_state, item_count);
|
|
||||||
return Ok((false, String::new()));
|
return Ok((false, String::new()));
|
||||||
}
|
}
|
||||||
"next_option" => {
|
"next_option" => {
|
||||||
next_option(app_state, 2); // Intro has 2 options
|
next_option(app_state); // Intro has 2 options
|
||||||
return Ok((false, String::new()));
|
return Ok((false, String::new()));
|
||||||
}
|
}
|
||||||
"previous_option" => {
|
"previous_option" => {
|
||||||
@@ -84,7 +80,7 @@ pub fn move_up(app_state: &mut AppState) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn move_down(app_state: &mut AppState, item_count: usize) {
|
pub fn move_down(app_state: &mut AppState) {
|
||||||
if app_state.ui.show_intro {
|
if app_state.ui.show_intro {
|
||||||
app_state.ui.intro_state.next_option();
|
app_state.ui.intro_state.next_option();
|
||||||
} else if app_state.ui.show_admin {
|
} else if app_state.ui.show_admin {
|
||||||
@@ -98,11 +94,12 @@ pub fn move_down(app_state: &mut AppState, item_count: usize) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_option(app_state: &mut AppState, option_count: usize) {
|
pub fn next_option(app_state: &mut AppState) { // Remove option_count parameter
|
||||||
if app_state.ui.show_intro {
|
if app_state.ui.show_intro {
|
||||||
app_state.ui.intro_state.next_option();
|
app_state.ui.intro_state.next_option();
|
||||||
} else {
|
} else {
|
||||||
// For other screens that might have options
|
// Get option count from state instead of parameter
|
||||||
|
let option_count = app_state.profile_tree.profiles.len();
|
||||||
app_state.general.current_option = (app_state.general.current_option + 1) % option_count;
|
app_state.general.current_option = (app_state.general.current_option + 1) % option_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,36 +108,20 @@ pub fn previous_option(app_state: &mut AppState) {
|
|||||||
if app_state.ui.show_intro {
|
if app_state.ui.show_intro {
|
||||||
app_state.ui.intro_state.previous_option();
|
app_state.ui.intro_state.previous_option();
|
||||||
} else {
|
} else {
|
||||||
// For other screens that might have options
|
let option_count = app_state.profile_tree.profiles.len();
|
||||||
if app_state.general.current_option == 0 {
|
app_state.general.current_option = if app_state.general.current_option == 0 {
|
||||||
// We'd need the option count here, but since it's not passed we can't wrap around correctly
|
option_count.saturating_sub(1) // Wrap to last option
|
||||||
// For now, just stay at 0
|
|
||||||
} else {
|
} else {
|
||||||
app_state.general.current_option -= 1;
|
app_state.general.current_option - 1
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn select(app_state: &mut AppState) {
|
pub fn select(app_state: &mut AppState) {
|
||||||
if app_state.ui.show_intro {
|
if app_state.ui.show_intro {
|
||||||
// Handle selection in intro screen
|
intro::handle_intro_selection(app_state);
|
||||||
if app_state.ui.intro_state.selected_option == 0 {
|
|
||||||
// First option selected - show form
|
|
||||||
app_state.ui.show_form = true;
|
|
||||||
app_state.ui.show_admin = false;
|
|
||||||
} else {
|
|
||||||
// Second option selected - show admin
|
|
||||||
app_state.ui.show_form = false;
|
|
||||||
app_state.ui.show_admin = true;
|
|
||||||
}
|
|
||||||
app_state.ui.show_intro = false;
|
|
||||||
} else if app_state.ui.show_admin {
|
} else if app_state.ui.show_admin {
|
||||||
// Handle selection in admin panel
|
admin::handle_admin_selection(app_state);
|
||||||
let profiles = &app_state.profile_tree.profiles;
|
|
||||||
if !profiles.is_empty() && app_state.general.selected_item < profiles.len() {
|
|
||||||
// Set the selected profile
|
|
||||||
app_state.selected_profile = Some(profiles[app_state.general.selected_item].name.clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// src/modes/handlers/event.rs
|
// src/modes/handlers/event.rs
|
||||||
use crossterm::event::{Event, KeyEvent};
|
use crossterm::event::Event;
|
||||||
use crossterm::cursor::SetCursorStyle;
|
use crossterm::cursor::SetCursorStyle;
|
||||||
use crate::tui::terminal::{
|
use crate::tui::terminal::{
|
||||||
core::TerminalCore,
|
core::TerminalCore,
|
||||||
@@ -7,7 +7,7 @@ use crate::tui::terminal::{
|
|||||||
};
|
};
|
||||||
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::ui::handlers::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::ui::handlers::rat_state::UiStateHandler;
|
use crate::ui::handlers::rat_state::UiStateHandler;
|
||||||
use crate::modes::{
|
use crate::modes::{
|
||||||
common::{command_mode},
|
common::{command_mode},
|
||||||
@@ -129,7 +129,6 @@ impl EventHandler {
|
|||||||
action,
|
action,
|
||||||
form_state,
|
form_state,
|
||||||
grpc_client,
|
grpc_client,
|
||||||
command_handler,
|
|
||||||
terminal,
|
terminal,
|
||||||
app_state,
|
app_state,
|
||||||
current_position,
|
current_position,
|
||||||
@@ -188,7 +187,6 @@ impl EventHandler {
|
|||||||
action,
|
action,
|
||||||
form_state,
|
form_state,
|
||||||
grpc_client,
|
grpc_client,
|
||||||
command_handler,
|
|
||||||
terminal,
|
terminal,
|
||||||
app_state,
|
app_state,
|
||||||
current_position,
|
current_position,
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
// src/state/mod.rs
|
// src/state/mod.rs
|
||||||
pub mod state;
|
pub mod state;
|
||||||
|
pub mod pages;
|
||||||
|
|||||||
4
client/src/state/pages.rs
Normal file
4
client/src/state/pages.rs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
// src/state/pages.rs
|
||||||
|
|
||||||
|
pub mod form;
|
||||||
|
pub mod auth;
|
||||||
20
client/src/state/pages/auth.rs
Normal file
20
client/src/state/pages/auth.rs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
// src/state/pages/auth.rs
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct AuthState {
|
||||||
|
pub return_selected: bool,
|
||||||
|
pub username: String,
|
||||||
|
pub password: String,
|
||||||
|
pub error_message: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AuthState {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
return_selected: false,
|
||||||
|
username: String::new(),
|
||||||
|
password: String::new(),
|
||||||
|
error_message: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// src/client/ui/handlers/form.rs
|
// src/state/pages/form.rs
|
||||||
use crate::config::colors::themes::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use ratatui::layout::Rect;
|
use ratatui::layout::Rect;
|
||||||
use ratatui::Frame;
|
use ratatui::Frame;
|
||||||
@@ -11,6 +11,7 @@ pub struct UiState {
|
|||||||
pub show_intro: bool,
|
pub show_intro: bool,
|
||||||
pub show_admin: bool,
|
pub show_admin: bool,
|
||||||
pub show_form: bool,
|
pub show_form: bool,
|
||||||
|
pub show_login: bool,
|
||||||
pub intro_state: IntroState,
|
pub intro_state: IntroState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +76,7 @@ impl Default for UiState {
|
|||||||
show_intro: true,
|
show_intro: true,
|
||||||
show_admin: false,
|
show_admin: false,
|
||||||
show_form: false,
|
show_form: false,
|
||||||
|
show_login: false,
|
||||||
intro_state: IntroState::new(),
|
intro_state: IntroState::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
client/src/tui/functions.rs
Normal file
7
client/src/tui/functions.rs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// src/tui/functions.rs
|
||||||
|
|
||||||
|
pub mod admin;
|
||||||
|
pub mod intro;
|
||||||
|
|
||||||
|
pub use admin::*;
|
||||||
|
pub use intro::*;
|
||||||
8
client/src/tui/functions/admin.rs
Normal file
8
client/src/tui/functions/admin.rs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
use crate::state::state::AppState;
|
||||||
|
|
||||||
|
pub fn handle_admin_selection(app_state: &mut AppState) {
|
||||||
|
let profiles = &app_state.profile_tree.profiles;
|
||||||
|
if !profiles.is_empty() && app_state.general.selected_item < profiles.len() {
|
||||||
|
app_state.selected_profile = Some(profiles[app_state.general.selected_item].name.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
23
client/src/tui/functions/intro.rs
Normal file
23
client/src/tui/functions/intro.rs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
use crate::state::state::AppState;
|
||||||
|
|
||||||
|
pub fn handle_intro_selection(app_state: &mut AppState) {
|
||||||
|
match app_state.ui.intro_state.selected_option {
|
||||||
|
0 => { // Continue
|
||||||
|
app_state.ui.show_form = true;
|
||||||
|
app_state.ui.show_admin = false;
|
||||||
|
app_state.ui.show_login = false;
|
||||||
|
}
|
||||||
|
1 => { // Admin
|
||||||
|
app_state.ui.show_form = false;
|
||||||
|
app_state.ui.show_admin = true;
|
||||||
|
app_state.ui.show_login = false;
|
||||||
|
}
|
||||||
|
2 => { // Login
|
||||||
|
app_state.ui.show_form = false;
|
||||||
|
app_state.ui.show_admin = false;
|
||||||
|
app_state.ui.show_login = true;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
app_state.ui.show_intro = false;
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// src/tui/mod.rs
|
// src/tui/mod.rs
|
||||||
pub mod terminal;
|
pub mod terminal;
|
||||||
pub mod controls;
|
pub mod controls;
|
||||||
|
pub mod functions;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// src/client/ui/handlers.rs
|
// src/client/ui/handlers.rs
|
||||||
|
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
pub mod form;
|
|
||||||
pub mod render;
|
pub mod render;
|
||||||
pub mod rat_state;
|
pub mod rat_state;
|
||||||
|
|
||||||
|
|||||||
@@ -6,18 +6,20 @@ use crate::components::{
|
|||||||
render_status_line,
|
render_status_line,
|
||||||
handlers::sidebar::{self, calculate_sidebar_layout},
|
handlers::sidebar::{self, calculate_sidebar_layout},
|
||||||
form::form::render_form,
|
form::form::render_form,
|
||||||
intro::{intro},
|
|
||||||
admin::{admin_panel::AdminPanelState},
|
admin::{admin_panel::AdminPanelState},
|
||||||
|
auth::login::render_login,
|
||||||
};
|
};
|
||||||
use crate::config::colors::themes::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use ratatui::layout::{Constraint, Direction, Layout};
|
use ratatui::layout::{Constraint, Direction, Layout};
|
||||||
use ratatui::Frame;
|
use ratatui::Frame;
|
||||||
use super::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
|
use crate::state::pages::auth::AuthState;
|
||||||
use crate::state::state::AppState;
|
use crate::state::state::AppState;
|
||||||
|
|
||||||
pub fn render_ui(
|
pub fn render_ui(
|
||||||
f: &mut Frame,
|
f: &mut Frame,
|
||||||
form_state: &mut FormState,
|
form_state: &mut FormState,
|
||||||
|
auth_state: &mut AuthState,
|
||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
is_edit_mode: bool,
|
is_edit_mode: bool,
|
||||||
total_count: u64,
|
total_count: u64,
|
||||||
@@ -44,6 +46,8 @@ pub fn render_ui(
|
|||||||
if app_state.ui.show_intro {
|
if app_state.ui.show_intro {
|
||||||
// Use app_state's intro_state directly
|
// Use app_state's intro_state directly
|
||||||
app_state.ui.intro_state.render(f, main_content_area, theme);
|
app_state.ui.intro_state.render(f, main_content_area, theme);
|
||||||
|
}else if app_state.ui.show_login {
|
||||||
|
render_login(f, main_content_area, theme, auth_state);
|
||||||
} else if app_state.ui.show_admin {
|
} else if app_state.ui.show_admin {
|
||||||
// Create temporary AdminPanelState for rendering
|
// Create temporary AdminPanelState for rendering
|
||||||
let mut admin_state = AdminPanelState::new(
|
let mut admin_state = AdminPanelState::new(
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ 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;
|
||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::ui::handlers::{form::FormState, render::render_ui};
|
use crate::ui::handlers::render::render_ui;
|
||||||
|
use crate::state::pages::form::FormState;
|
||||||
|
use crate::state::pages::auth::AuthState;
|
||||||
use crate::modes::handlers::event::EventHandler;
|
use crate::modes::handlers::event::EventHandler;
|
||||||
use crate::state::state::AppState;
|
use crate::state::state::AppState;
|
||||||
use crate::components::admin::{admin_panel::AdminPanelState};
|
|
||||||
use crate::components::intro::{intro::IntroState};
|
|
||||||
|
|
||||||
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let config = Config::load()?;
|
let config = Config::load()?;
|
||||||
@@ -18,7 +18,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let mut grpc_client = GrpcClient::new().await?;
|
let mut grpc_client = GrpcClient::new().await?;
|
||||||
let mut command_handler = CommandHandler::new();
|
let mut command_handler = CommandHandler::new();
|
||||||
let theme = Theme::from_str(&config.colors.theme);
|
let theme = Theme::from_str(&config.colors.theme);
|
||||||
let mut intro_state = IntroState::new();
|
let mut auth_state = AuthState::default();
|
||||||
|
|
||||||
// Initialize app_state first
|
// Initialize app_state first
|
||||||
let mut app_state = AppState::new()?;
|
let mut app_state = AppState::new()?;
|
||||||
@@ -27,13 +27,6 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let profile_tree = grpc_client.get_profile_tree().await?;
|
let profile_tree = grpc_client.get_profile_tree().await?;
|
||||||
app_state.profile_tree = profile_tree;
|
app_state.profile_tree = profile_tree;
|
||||||
|
|
||||||
// Now create admin panel with profiles from app_state
|
|
||||||
if intro_state.selected_option == 1 {
|
|
||||||
app_state.ui.show_admin = true;
|
|
||||||
app_state.general.selected_item = 0;
|
|
||||||
app_state.general.current_option = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch table structure at startup (one-time)
|
// Fetch table structure at startup (one-time)
|
||||||
let table_structure = grpc_client.get_table_structure().await?;
|
let table_structure = grpc_client.get_table_structure().await?;
|
||||||
|
|
||||||
@@ -65,6 +58,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
render_ui(
|
render_ui(
|
||||||
f,
|
f,
|
||||||
&mut form_state,
|
&mut form_state,
|
||||||
|
&mut auth_state,
|
||||||
&theme,
|
&theme,
|
||||||
event_handler.is_edit_mode,
|
event_handler.is_edit_mode,
|
||||||
app_state.total_count,
|
app_state.total_count,
|
||||||
|
|||||||
22
server/.sqlx/query-468bb5bb4fdaefcb4b280761d7880a556d40c172568ad3a1ed13156fbef72776.json
generated
Normal file
22
server/.sqlx/query-468bb5bb4fdaefcb4b280761d7880a556d40c172568ad3a1ed13156fbef72776.json
generated
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "SELECT ltd.table_name\n FROM table_definition_links tdl\n JOIN table_definitions ltd ON tdl.linked_table_id = ltd.id\n WHERE tdl.source_table_id = $1",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "table_name",
|
||||||
|
"type_info": "Text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Int8"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "468bb5bb4fdaefcb4b280761d7880a556d40c172568ad3a1ed13156fbef72776"
|
||||||
|
}
|
||||||
42
server/.sqlx/query-48d0a6d393dac121bfa4230830a105aede2179b07395f97750ab2fa1970afacd.json
generated
Normal file
42
server/.sqlx/query-48d0a6d393dac121bfa4230830a105aede2179b07395f97750ab2fa1970afacd.json
generated
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "\n INSERT INTO users (username, email, password_hash, role)\n VALUES ($1, $2, $3, 'accountant')\n RETURNING id, username, email, role\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "id",
|
||||||
|
"type_info": "Uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "username",
|
||||||
|
"type_info": "Varchar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 2,
|
||||||
|
"name": "email",
|
||||||
|
"type_info": "Varchar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 3,
|
||||||
|
"name": "role",
|
||||||
|
"type_info": "Varchar"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Varchar",
|
||||||
|
"Varchar",
|
||||||
|
"Varchar"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "48d0a6d393dac121bfa4230830a105aede2179b07395f97750ab2fa1970afacd"
|
||||||
|
}
|
||||||
34
server/.sqlx/query-6be0bb23ad1ba85add309f6e4f55495a5d248901fb0d23fea908815747a0bd50.json
generated
Normal file
34
server/.sqlx/query-6be0bb23ad1ba85add309f6e4f55495a5d248901fb0d23fea908815747a0bd50.json
generated
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "\n SELECT id, password_hash, role\n FROM users\n WHERE username = $1 OR email = $1\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "id",
|
||||||
|
"type_info": "Uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "password_hash",
|
||||||
|
"type_info": "Varchar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 2,
|
||||||
|
"name": "role",
|
||||||
|
"type_info": "Varchar"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "6be0bb23ad1ba85add309f6e4f55495a5d248901fb0d23fea908815747a0bd50"
|
||||||
|
}
|
||||||
23
server/.sqlx/query-80f0f7f9ab12a8fe07ea71b548d27bcd6253b598ac4486b72b3d960f03df47f3.json
generated
Normal file
23
server/.sqlx/query-80f0f7f9ab12a8fe07ea71b548d27bcd6253b598ac4486b72b3d960f03df47f3.json
generated
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "SELECT table_name FROM table_definitions\n WHERE profile_id = $1 AND table_name LIKE $2",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "table_name",
|
||||||
|
"type_info": "Text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Int8",
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "80f0f7f9ab12a8fe07ea71b548d27bcd6253b598ac4486b72b3d960f03df47f3"
|
||||||
|
}
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"db_name": "PostgreSQL",
|
|
||||||
"query": "SELECT ltd.table_name \n FROM table_definition_links tdl\n JOIN table_definitions ltd ON tdl.linked_table_id = ltd.id\n WHERE tdl.source_table_id = $1 AND tdl.is_required = true",
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"ordinal": 0,
|
|
||||||
"name": "table_name",
|
|
||||||
"type_info": "Text"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Int8"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"nullable": [
|
|
||||||
false
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"hash": "b097f30f98490b979939759d85327a20ca7ade4866052a5cfdb0451fb76fbf15"
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"db_name": "PostgreSQL",
|
||||||
"query": "INSERT INTO table_scripts\n (table_definitions_id, target_column, target_column_type, script, description)\n VALUES ($1, $2, $3, $4, $5)\n RETURNING id",
|
"query": "INSERT INTO table_scripts\n (table_definitions_id, target_table, target_column,\n target_column_type, script, description, profile_id)\n VALUES ($1, $2, $3, $4, $5, $6, $7)\n RETURNING id",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
@@ -15,12 +15,14 @@
|
|||||||
"Text",
|
"Text",
|
||||||
"Text",
|
"Text",
|
||||||
"Text",
|
"Text",
|
||||||
"Text"
|
"Text",
|
||||||
|
"Text",
|
||||||
|
"Int8"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"nullable": [
|
"nullable": [
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "4cd5de4d3332ca35a9975ffb32728041978435e14f97c559e2ffec4a82d567ae"
|
"hash": "c07a8511e5f32bf230240b28cb292d40f862b6ec58883f21ee8e1937860585d6"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user