Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f42790980d | ||
|
|
779683de4b | ||
|
|
aa8887318f | ||
|
|
3ad8dc6490 | ||
|
|
20f9fae141 | ||
|
|
ec062bbf24 | ||
|
|
8745c9ea2f | ||
|
|
0917654361 | ||
|
|
d892d1cfa0 | ||
|
|
e31138c250 | ||
|
|
7cbe5ce8be | ||
|
|
1c31d4cd1c | ||
|
|
990ec9317f | ||
|
|
718ceac17e | ||
|
|
d154ba6b89 | ||
|
|
f2a63476b3 | ||
|
|
adcd3b37fa | ||
|
|
71dabc1e37 |
@@ -10,6 +10,7 @@ next_option = ["l", "Right"]
|
|||||||
previous_option = ["h", "Left"]
|
previous_option = ["h", "Left"]
|
||||||
select = ["Enter"]
|
select = ["Enter"]
|
||||||
toggle_sidebar = ["ctrl+t"]
|
toggle_sidebar = ["ctrl+t"]
|
||||||
|
toggle_buffer_list = ["ctrl+b"]
|
||||||
next_field = ["Tab"]
|
next_field = ["Tab"]
|
||||||
prev_field = ["Shift+Tab"]
|
prev_field = ["Shift+Tab"]
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ save_and_quit = ["ctrl+shift+s"]
|
|||||||
move_up = ["Up"]
|
move_up = ["Up"]
|
||||||
move_down = ["Down"]
|
move_down = ["Down"]
|
||||||
toggle_sidebar = ["ctrl+t"]
|
toggle_sidebar = ["ctrl+t"]
|
||||||
|
toggle_buffer_list = ["ctrl+b"]
|
||||||
|
|
||||||
# MODE SPECIFIC
|
# MODE SPECIFIC
|
||||||
# READ ONLY MODE
|
# READ ONLY MODE
|
||||||
|
|||||||
@@ -1,118 +1,137 @@
|
|||||||
// src/components/admin/admin_panel.rs
|
// src/components/admin/admin_panel.rs
|
||||||
|
|
||||||
|
use crate::config::colors::themes::Theme;
|
||||||
|
use crate::state::pages::auth::AuthState;
|
||||||
|
use crate::state::pages::admin::AdminState;
|
||||||
|
use common::proto::multieko2::table_definition::ProfileTreeResponse;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
widgets::{Block, BorderType, Borders, List, ListItem, ListState, Paragraph},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
style::Style,
|
style::Style,
|
||||||
text::{Line, Span, Text},
|
text::{Line, Span, Text},
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
widgets::{Block, BorderType, Borders, List, ListItem, Paragraph, Wrap},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use common::proto::multieko2::table_definition::ProfileTreeResponse;
|
|
||||||
use crate::config::colors::themes::Theme;
|
|
||||||
|
|
||||||
pub struct AdminPanelState {
|
/// Renders the view specific to admin users.
|
||||||
pub list_state: ListState,
|
fn render_admin_panel_admin(f: &mut Frame, content_chunks: &[Rect], theme: &Theme) {
|
||||||
pub profiles: Vec<String>,
|
// Admin-specific view placeholder
|
||||||
|
let admin_message = Paragraph::new("Admin-specific view. Profile selection not applicable.")
|
||||||
|
.style(Style::default().fg(theme.fg))
|
||||||
|
.alignment(Alignment::Center);
|
||||||
|
// Render only in the right pane for now, leaving left empty
|
||||||
|
f.render_widget(admin_message, content_chunks[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AdminPanelState {
|
pub fn render_admin_panel(
|
||||||
pub fn new(profiles: Vec<String>) -> Self {
|
f: &mut Frame,
|
||||||
let mut list_state = ListState::default();
|
auth_state: &AuthState,
|
||||||
if !profiles.is_empty() {
|
admin_state: &AdminState,
|
||||||
list_state.select(Some(0));
|
area: Rect,
|
||||||
}
|
theme: &Theme,
|
||||||
Self { list_state, profiles }
|
profile_tree: &ProfileTreeResponse,
|
||||||
|
selected_profile: &Option<String>,
|
||||||
|
) {
|
||||||
|
let block = Block::default()
|
||||||
|
.borders(Borders::ALL)
|
||||||
|
.border_type(BorderType::Rounded)
|
||||||
|
.border_style(Style::default().fg(theme.accent))
|
||||||
|
.style(Style::default().bg(theme.bg));
|
||||||
|
|
||||||
|
let inner_area = block.inner(area);
|
||||||
|
f.render_widget(block, area);
|
||||||
|
|
||||||
|
let chunks = Layout::default()
|
||||||
|
.direction(Direction::Vertical)
|
||||||
|
.constraints([Constraint::Length(3), Constraint::Min(1)])
|
||||||
|
.split(inner_area);
|
||||||
|
|
||||||
|
// Title
|
||||||
|
let title = Line::from(Span::styled("Admin Panel", Style::default().fg(theme.highlight)));
|
||||||
|
let title_widget = Paragraph::new(title).alignment(Alignment::Center);
|
||||||
|
f.render_widget(title_widget, chunks[0]);
|
||||||
|
|
||||||
|
// Content
|
||||||
|
let content_chunks = Layout::default()
|
||||||
|
.direction(Direction::Horizontal)
|
||||||
|
.constraints([Constraint::Percentage(30), Constraint::Percentage(70)])
|
||||||
|
.split(chunks[1]);
|
||||||
|
|
||||||
|
if auth_state.role.as_deref() != Some("admin") {
|
||||||
|
render_admin_panel_non_admin(
|
||||||
|
f,
|
||||||
|
admin_state,
|
||||||
|
&content_chunks,
|
||||||
|
theme,
|
||||||
|
profile_tree,
|
||||||
|
selected_profile,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
render_admin_panel_admin(f, &content_chunks, theme);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn next(&mut self) {
|
/// Renders the view for non-admin users (profile list and details).
|
||||||
let i = self.list_state.selected().map_or(0, |i|
|
fn render_admin_panel_non_admin(
|
||||||
if i >= self.profiles.len() - 1 { 0 } else { i + 1 });
|
f: &mut Frame,
|
||||||
self.list_state.select(Some(i));
|
admin_state: &AdminState,
|
||||||
}
|
content_chunks: &[Rect],
|
||||||
|
theme: &Theme,
|
||||||
pub fn previous(&mut self) {
|
profile_tree: &ProfileTreeResponse,
|
||||||
let i = self.list_state.selected().map_or(0, |i|
|
selected_profile: &Option<String>,
|
||||||
if i == 0 { self.profiles.len() - 1 } else { i - 1 });
|
) {
|
||||||
self.list_state.select(Some(i));
|
// Profile list - Use data from admin_state
|
||||||
}
|
let items: Vec<ListItem> = admin_state
|
||||||
|
.profiles
|
||||||
pub fn render(
|
.iter()
|
||||||
&mut self,
|
.map(|p| {
|
||||||
f: &mut Frame,
|
ListItem::new(Line::from(vec![
|
||||||
area: Rect,
|
|
||||||
theme: &Theme,
|
|
||||||
profile_tree: &ProfileTreeResponse,
|
|
||||||
selected_profile: &Option<String>,
|
|
||||||
) {
|
|
||||||
let block = Block::default()
|
|
||||||
.borders(Borders::ALL)
|
|
||||||
.border_type(BorderType::Rounded)
|
|
||||||
.border_style(Style::default().fg(theme.accent))
|
|
||||||
.style(Style::default().bg(theme.bg));
|
|
||||||
|
|
||||||
let inner_area = block.inner(area);
|
|
||||||
f.render_widget(block, area);
|
|
||||||
|
|
||||||
let chunks = Layout::default()
|
|
||||||
.direction(Direction::Vertical)
|
|
||||||
.constraints([Constraint::Length(3), Constraint::Min(1)])
|
|
||||||
.split(inner_area);
|
|
||||||
|
|
||||||
// Title
|
|
||||||
let title = Line::from(Span::styled("Admin Panel", Style::default().fg(theme.highlight)));
|
|
||||||
let title_widget = Paragraph::new(title).alignment(Alignment::Center);
|
|
||||||
f.render_widget(title_widget, chunks[0]);
|
|
||||||
|
|
||||||
// Content
|
|
||||||
let content_chunks = Layout::default()
|
|
||||||
.direction(Direction::Horizontal)
|
|
||||||
.constraints([Constraint::Percentage(30), Constraint::Percentage(70)])
|
|
||||||
.split(chunks[1]);
|
|
||||||
|
|
||||||
// Profile list
|
|
||||||
let items: Vec<ListItem> = self.profiles.iter()
|
|
||||||
.map(|p| ListItem::new(Line::from(vec![
|
|
||||||
Span::styled(
|
Span::styled(
|
||||||
if Some(p) == selected_profile.as_ref() { "✓ " } else { " " },
|
if Some(p) == selected_profile.as_ref() { "✓ " } else { " " },
|
||||||
Style::default().fg(theme.accent)
|
Style::default().fg(theme.accent),
|
||||||
),
|
),
|
||||||
Span::styled(p, Style::default().fg(theme.fg)),
|
Span::styled(p, Style::default().fg(theme.fg)),
|
||||||
])))
|
]))
|
||||||
.collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
let list = List::new(items)
|
let list = List::new(items)
|
||||||
.block(Block::default().title("Profiles"))
|
.block(Block::default().title("Profiles"))
|
||||||
.highlight_style(Style::default().bg(theme.highlight).fg(theme.bg));
|
.highlight_style(Style::default().bg(theme.highlight).fg(theme.bg));
|
||||||
|
|
||||||
f.render_stateful_widget(list, content_chunks[0], &mut self.list_state);
|
|
||||||
|
|
||||||
// Profile details
|
let mut list_state_clone = admin_state.list_state.clone();
|
||||||
if let Some(profile) = self.list_state.selected()
|
f.render_stateful_widget(list, content_chunks[0], &mut list_state_clone);
|
||||||
.and_then(|i| profile_tree.profiles.get(i))
|
|
||||||
{
|
|
||||||
let mut text = Text::default();
|
|
||||||
text.lines.push(Line::from(vec![
|
|
||||||
Span::styled("Profile: ", Style::default().fg(theme.accent)),
|
|
||||||
Span::styled(&profile.name, Style::default().fg(theme.highlight)),
|
|
||||||
]));
|
|
||||||
|
|
||||||
text.lines.push(Line::from(""));
|
// Profile details - Use selection info from admin_state
|
||||||
text.lines.push(Line::from(Span::styled("Tables:", Style::default().fg(theme.accent))));
|
if let Some(profile) = admin_state
|
||||||
|
.get_selected_index()
|
||||||
for table in &profile.tables {
|
.and_then(|i| profile_tree.profiles.get(i))
|
||||||
let mut line = vec![Span::styled(format!("├─ {}", table.name), theme.fg)];
|
{
|
||||||
if !table.depends_on.is_empty() {
|
let mut text = Text::default();
|
||||||
line.push(Span::styled(
|
text.lines.push(Line::from(vec![
|
||||||
format!(" → {}", table.depends_on.join(", ")),
|
Span::styled("Profile: ", Style::default().fg(theme.accent)),
|
||||||
Style::default().fg(theme.secondary)
|
Span::styled(&profile.name, Style::default().fg(theme.highlight)),
|
||||||
));
|
]));
|
||||||
}
|
|
||||||
text.lines.push(Line::from(line));
|
text.lines.push(Line::from(""));
|
||||||
|
text.lines.push(Line::from(Span::styled(
|
||||||
|
"Tables:",
|
||||||
|
Style::default().fg(theme.accent),
|
||||||
|
)));
|
||||||
|
|
||||||
|
for table in &profile.tables {
|
||||||
|
let mut line = vec![Span::styled(format!("├─ {}", table.name), theme.fg)];
|
||||||
|
if !table.depends_on.is_empty() {
|
||||||
|
line.push(Span::styled(
|
||||||
|
format!(" → {}", table.depends_on.join(", ")),
|
||||||
|
Style::default().fg(theme.secondary),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
text.lines.push(Line::from(line));
|
||||||
let details_widget = Paragraph::new(text)
|
|
||||||
.block(Block::default().title("Details"));
|
|
||||||
f.render_widget(details_widget, content_chunks[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let details_widget = Paragraph::new(text)
|
||||||
|
.block(Block::default().title("Details"))
|
||||||
|
.wrap(Wrap { trim: true });
|
||||||
|
f.render_widget(details_widget, content_chunks[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ pub fn render_login(
|
|||||||
// Login Button
|
// Login Button
|
||||||
let login_button_index = 0;
|
let login_button_index = 0;
|
||||||
let login_active = if app_state.ui.focus_outside_canvas {
|
let login_active = if app_state.ui.focus_outside_canvas {
|
||||||
app_state.general.selected_item == login_button_index
|
app_state.focused_button_index== login_button_index
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
@@ -104,7 +104,7 @@ pub fn render_login(
|
|||||||
// Return Button
|
// Return Button
|
||||||
let return_button_index = 1; // Assuming Return is the second general element
|
let return_button_index = 1; // Assuming Return is the second general element
|
||||||
let return_active = if app_state.ui.focus_outside_canvas {
|
let return_active = if app_state.ui.focus_outside_canvas {
|
||||||
app_state.general.selected_item == return_button_index
|
app_state.focused_button_index== return_button_index
|
||||||
} else {
|
} else {
|
||||||
false // Not active if focus is in canvas or other modes
|
false // Not active if focus is in canvas or other modes
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use crate::{
|
|||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect, Margin},
|
layout::{Alignment, Constraint, Direction, Layout, Rect, Margin},
|
||||||
style::{Style, Modifier, Color},
|
style::{Style, Modifier, Color},
|
||||||
widgets::{Block, BorderType, Borders, Paragraph, Wrap},
|
widgets::{Block, BorderType, Borders, Paragraph},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ pub fn render_register(
|
|||||||
// Register Button
|
// Register Button
|
||||||
let register_button_index = 0;
|
let register_button_index = 0;
|
||||||
let register_active = if app_state.ui.focus_outside_canvas {
|
let register_active = if app_state.ui.focus_outside_canvas {
|
||||||
app_state.general.selected_item == register_button_index
|
app_state.focused_button_index== register_button_index
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
@@ -119,7 +119,7 @@ pub fn render_register(
|
|||||||
// Return Button (logic remains similar)
|
// Return Button (logic remains similar)
|
||||||
let return_button_index = 1;
|
let return_button_index = 1;
|
||||||
let return_active = if app_state.ui.focus_outside_canvas {
|
let return_active = if app_state.ui.focus_outside_canvas {
|
||||||
app_state.general.selected_item == return_button_index
|
app_state.focused_button_index== return_button_index
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// src/components/handlers.rs
|
// src/components/handlers.rs
|
||||||
pub mod canvas;
|
pub mod canvas;
|
||||||
pub mod sidebar;
|
pub mod sidebar;
|
||||||
|
pub mod buffer_list;
|
||||||
|
|
||||||
pub use canvas::*;
|
pub use canvas::*;
|
||||||
pub use sidebar::*;
|
pub use sidebar::*;
|
||||||
|
pub use buffer_list::*;
|
||||||
|
|||||||
63
client/src/components/handlers/buffer_list.rs
Normal file
63
client/src/components/handlers/buffer_list.rs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
// src/components/handlers/buffer_list.rs
|
||||||
|
|
||||||
|
use crate::config::colors::themes::Theme;
|
||||||
|
use crate::state::app::state::AppState;
|
||||||
|
use ratatui::{
|
||||||
|
layout::{Alignment, Rect},
|
||||||
|
style::{Style, Stylize},
|
||||||
|
text::{Line, Span},
|
||||||
|
widgets::Paragraph,
|
||||||
|
Frame,
|
||||||
|
};
|
||||||
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
|
pub fn render_buffer_list(
|
||||||
|
f: &mut Frame,
|
||||||
|
area: Rect,
|
||||||
|
theme: &Theme,
|
||||||
|
app_state: &AppState,
|
||||||
|
) {
|
||||||
|
// --- Style Definitions ---
|
||||||
|
let active_style = Style::default()
|
||||||
|
.fg(theme.bg)
|
||||||
|
.bg(theme.highlight);
|
||||||
|
|
||||||
|
let inactive_style = Style::default()
|
||||||
|
.fg(theme.fg)
|
||||||
|
.bg(theme.bg);
|
||||||
|
|
||||||
|
// --- Create Spans ---
|
||||||
|
let mut spans = Vec::new();
|
||||||
|
let history = &app_state.ui.buffer_history;
|
||||||
|
let mut current_width = 0;
|
||||||
|
|
||||||
|
for (i, view) in history.iter().enumerate() {
|
||||||
|
let is_active = i == app_state.ui.active_buffer_index;
|
||||||
|
let buffer_name = view.display_name();
|
||||||
|
let buffer_text = format!(" {} ", buffer_name);
|
||||||
|
let text_width = UnicodeWidthStr::width(buffer_text.as_str());
|
||||||
|
|
||||||
|
// Calculate width needed for this buffer (separator + text)
|
||||||
|
let needed_width = text_width;
|
||||||
|
if current_width + needed_width > area.width as usize {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the buffer text itself
|
||||||
|
let text_style = if is_active { active_style } else { inactive_style };
|
||||||
|
spans.push(Span::styled(buffer_text, text_style));
|
||||||
|
current_width += text_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Filler Span ---
|
||||||
|
let remaining_width = area.width.saturating_sub(current_width as u16);
|
||||||
|
spans.push(Span::styled(
|
||||||
|
" ".repeat(remaining_width as usize),
|
||||||
|
inactive_style,
|
||||||
|
));
|
||||||
|
|
||||||
|
// --- Render ---
|
||||||
|
let buffer_line = Line::from(spans);
|
||||||
|
let paragraph = Paragraph::new(buffer_line).alignment(Alignment::Left);
|
||||||
|
f.render_widget(paragraph, area);
|
||||||
|
}
|
||||||
@@ -9,8 +9,6 @@ use ratatui::{
|
|||||||
};
|
};
|
||||||
use crate::config::colors::themes::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use crate::state::pages::canvas_state::CanvasState;
|
use crate::state::pages::canvas_state::CanvasState;
|
||||||
use crate::components::common::autocomplete;
|
|
||||||
use crate::components::render_autocomplete_dropdown;
|
|
||||||
|
|
||||||
pub fn render_canvas(
|
pub fn render_canvas(
|
||||||
f: &mut Frame,
|
f: &mut Frame,
|
||||||
|
|||||||
@@ -8,103 +8,80 @@ use ratatui::{
|
|||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use crate::config::colors::themes::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
|
use crate::state::pages::intro::IntroState;
|
||||||
|
|
||||||
pub struct IntroState {
|
pub fn render_intro(f: &mut Frame, intro_state: &IntroState, area: Rect, theme: &Theme) {
|
||||||
pub selected_option: usize,
|
let block = Block::default()
|
||||||
|
.borders(Borders::ALL)
|
||||||
|
.border_type(BorderType::Rounded)
|
||||||
|
.border_style(Style::default().fg(theme.accent))
|
||||||
|
.style(Style::default().bg(theme.bg));
|
||||||
|
|
||||||
|
let inner_area = block.inner(area);
|
||||||
|
f.render_widget(block, area);
|
||||||
|
|
||||||
|
// Center layout
|
||||||
|
let chunks = Layout::default()
|
||||||
|
.direction(Direction::Vertical)
|
||||||
|
.constraints([
|
||||||
|
Constraint::Percentage(40),
|
||||||
|
Constraint::Length(5),
|
||||||
|
Constraint::Percentage(40),
|
||||||
|
])
|
||||||
|
.split(inner_area);
|
||||||
|
|
||||||
|
// Title
|
||||||
|
let title = Line::from(vec![
|
||||||
|
Span::styled("multieko2", Style::default().fg(theme.highlight)),
|
||||||
|
Span::styled(" v", Style::default().fg(theme.fg)),
|
||||||
|
Span::styled(env!("CARGO_PKG_VERSION"), Style::default().fg(theme.secondary)),
|
||||||
|
]);
|
||||||
|
let title_para = Paragraph::new(title)
|
||||||
|
.alignment(Alignment::Center);
|
||||||
|
f.render_widget(title_para, chunks[1]);
|
||||||
|
|
||||||
|
// Buttons - now with 4 options
|
||||||
|
let button_area = Layout::default()
|
||||||
|
.direction(Direction::Horizontal)
|
||||||
|
.constraints([
|
||||||
|
Constraint::Percentage(25),
|
||||||
|
Constraint::Percentage(25),
|
||||||
|
Constraint::Percentage(25),
|
||||||
|
Constraint::Percentage(25),
|
||||||
|
])
|
||||||
|
.split(chunks[1].inner(Margin {
|
||||||
|
horizontal: 1,
|
||||||
|
vertical: 1
|
||||||
|
}));
|
||||||
|
|
||||||
|
let buttons = ["Continue", "Admin", "Login", "Register"];
|
||||||
|
for (i, &text) in buttons.iter().enumerate() {
|
||||||
|
render_button(f, button_area[i], text, intro_state.selected_option == i, theme);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntroState {
|
fn render_button(f: &mut Frame, area: Rect, text: &str, selected: bool, theme: &Theme) {
|
||||||
pub fn new() -> Self {
|
let button_style = Style::default()
|
||||||
Self { selected_option: 0 }
|
.fg(if selected { theme.highlight } else { theme.fg })
|
||||||
}
|
.bg(theme.bg)
|
||||||
|
.add_modifier(if selected {
|
||||||
|
ratatui::style::Modifier::BOLD
|
||||||
|
} else {
|
||||||
|
ratatui::style::Modifier::empty()
|
||||||
|
});
|
||||||
|
|
||||||
pub fn render(&self, f: &mut Frame, area: Rect, theme: &Theme) {
|
let border_style = Style::default()
|
||||||
let block = Block::default()
|
.fg(if selected { theme.accent } else { theme.border });
|
||||||
|
|
||||||
|
let button = Paragraph::new(text)
|
||||||
|
.style(button_style)
|
||||||
|
.alignment(Alignment::Center)
|
||||||
|
.block(
|
||||||
|
Block::default()
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_type(BorderType::Rounded)
|
.border_type(BorderType::Double)
|
||||||
.border_style(Style::default().fg(theme.accent))
|
.border_style(border_style),
|
||||||
.style(Style::default().bg(theme.bg));
|
);
|
||||||
|
|
||||||
let inner_area = block.inner(area);
|
f.render_widget(button, area);
|
||||||
f.render_widget(block, area);
|
|
||||||
|
|
||||||
// Center layout
|
|
||||||
let chunks = Layout::default()
|
|
||||||
.direction(Direction::Vertical)
|
|
||||||
.constraints([
|
|
||||||
Constraint::Percentage(40),
|
|
||||||
Constraint::Length(5),
|
|
||||||
Constraint::Percentage(40),
|
|
||||||
])
|
|
||||||
.split(inner_area);
|
|
||||||
|
|
||||||
// Title
|
|
||||||
let title = Line::from(vec![
|
|
||||||
Span::styled("multieko2", Style::default().fg(theme.highlight)),
|
|
||||||
Span::styled(" v", Style::default().fg(theme.fg)),
|
|
||||||
Span::styled(env!("CARGO_PKG_VERSION"), Style::default().fg(theme.secondary)),
|
|
||||||
]);
|
|
||||||
let title_para = Paragraph::new(title)
|
|
||||||
.alignment(Alignment::Center);
|
|
||||||
f.render_widget(title_para, chunks[1]);
|
|
||||||
|
|
||||||
// Buttons - now with 4 options
|
|
||||||
let button_area = Layout::default()
|
|
||||||
.direction(Direction::Horizontal)
|
|
||||||
.constraints([
|
|
||||||
Constraint::Percentage(25),
|
|
||||||
Constraint::Percentage(25),
|
|
||||||
Constraint::Percentage(25),
|
|
||||||
Constraint::Percentage(25),
|
|
||||||
])
|
|
||||||
.split(chunks[1].inner(Margin {
|
|
||||||
horizontal: 1,
|
|
||||||
vertical: 1
|
|
||||||
}));
|
|
||||||
|
|
||||||
let buttons = ["Continue", "Admin", "Login", "Register"];
|
|
||||||
for (i, &text) in buttons.iter().enumerate() {
|
|
||||||
self.render_button(
|
|
||||||
f,
|
|
||||||
button_area[i],
|
|
||||||
text,
|
|
||||||
self.selected_option == i,
|
|
||||||
theme,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_button(&self, f: &mut Frame, area: Rect, text: &str, selected: bool, theme: &Theme) {
|
|
||||||
let button_style = Style::default()
|
|
||||||
.fg(if selected { theme.highlight } else { theme.fg })
|
|
||||||
.bg(theme.bg)
|
|
||||||
.add_modifier(if selected {
|
|
||||||
ratatui::style::Modifier::BOLD
|
|
||||||
} else {
|
|
||||||
ratatui::style::Modifier::empty()
|
|
||||||
});
|
|
||||||
|
|
||||||
let border_style = Style::default()
|
|
||||||
.fg(if selected { theme.accent } else { theme.border });
|
|
||||||
|
|
||||||
let button = Paragraph::new(text)
|
|
||||||
.style(button_style)
|
|
||||||
.alignment(Alignment::Center)
|
|
||||||
.block(
|
|
||||||
Block::default()
|
|
||||||
.borders(Borders::ALL)
|
|
||||||
.border_type(BorderType::Double)
|
|
||||||
.border_style(border_style),
|
|
||||||
);
|
|
||||||
|
|
||||||
f.render_widget(button, area);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn next_option(&mut self) {
|
|
||||||
self.selected_option = (self.selected_option + 1) % 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn previous_option(&mut self) {
|
|
||||||
self.selected_option = if self.selected_option == 0 { 3 } else { self.selected_option - 1 };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,4 +6,3 @@ pub mod navigation;
|
|||||||
|
|
||||||
pub use read_only::*;
|
pub use read_only::*;
|
||||||
pub use edit::*;
|
pub use edit::*;
|
||||||
pub use navigation::*;
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
// src/functions/modes/navigation.rs
|
// src/functions/modes/navigation.rs
|
||||||
|
|
||||||
pub mod admin_nav;
|
// pub mod admin_nav;
|
||||||
|
|||||||
@@ -1,36 +1 @@
|
|||||||
// src/functions/modes/navigation/admin_nav.rs
|
// src/functions/modes/navigation/admin_nav.rs
|
||||||
|
|
||||||
use crate::state::app::state::AppState;
|
|
||||||
use crate::state::pages::admin::AdminState;
|
|
||||||
|
|
||||||
/// Handles moving the selection up in the admin profile list.
|
|
||||||
pub fn move_admin_list_up(app_state: &AppState, admin_state: &mut AdminState) {
|
|
||||||
// Read profile count directly from app_state where the source data lives
|
|
||||||
let profile_count = app_state.profile_tree.profiles.len();
|
|
||||||
if profile_count == 0 {
|
|
||||||
admin_state.list_state.select(None); // Ensure nothing selected if empty
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let current_index = admin_state.get_selected_index().unwrap_or(0);
|
|
||||||
let new_index = if current_index == 0 {
|
|
||||||
profile_count - 1 // Wrap to end
|
|
||||||
} else {
|
|
||||||
current_index.saturating_sub(1) // Move up
|
|
||||||
};
|
|
||||||
admin_state.list_state.select(Some(new_index));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Handles moving the selection down in the admin profile list.
|
|
||||||
pub fn move_admin_list_down(app_state: &AppState, admin_state: &mut AdminState) {
|
|
||||||
// Read profile count directly from app_state
|
|
||||||
let profile_count = app_state.profile_tree.profiles.len();
|
|
||||||
if profile_count == 0 {
|
|
||||||
admin_state.list_state.select(None); // Ensure nothing selected if empty
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let current_index = admin_state.get_selected_index().unwrap_or(0);
|
|
||||||
let new_index = (current_index + 1) % profile_count; // Wrap around
|
|
||||||
admin_state.list_state.select(Some(new_index));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ pub async fn execute_action<S: CanvasState>(
|
|||||||
if current_field == last_field_index {
|
if current_field == last_field_index {
|
||||||
// Already on the last field, move focus outside
|
// Already on the last field, move focus outside
|
||||||
app_state.ui.focus_outside_canvas = true;
|
app_state.ui.focus_outside_canvas = true;
|
||||||
app_state.general.selected_item = 0; // Focus first general item (e.g., Login button)
|
app_state.focused_button_index= 0;
|
||||||
key_sequence_tracker.reset();
|
key_sequence_tracker.reset();
|
||||||
Ok("Focus moved below canvas".to_string())
|
Ok("Focus moved below canvas".to_string())
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use crate::config::binds::config::Config;
|
|||||||
use crate::config::binds::key_sequences::KeySequenceTracker;
|
use crate::config::binds::key_sequences::KeySequenceTracker;
|
||||||
use crate::services::grpc_client::GrpcClient;
|
use crate::services::grpc_client::GrpcClient;
|
||||||
use crate::state::pages::{canvas_state::CanvasState, auth::RegisterState};
|
use crate::state::pages::{canvas_state::CanvasState, auth::RegisterState};
|
||||||
use crate::state::pages::auth::AuthState;
|
|
||||||
use crate::state::pages::auth::LoginState;
|
use crate::state::pages::auth::LoginState;
|
||||||
use crate::state::pages::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::state::app::state::AppState;
|
use crate::state::app::state::AppState;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use crate::state::app::state::AppState;
|
|||||||
use crate::state::pages::auth::AuthState;
|
use crate::state::pages::auth::AuthState;
|
||||||
use crate::state::pages::auth::LoginState;
|
use crate::state::pages::auth::LoginState;
|
||||||
use crate::state::pages::auth::RegisterState;
|
use crate::state::pages::auth::RegisterState;
|
||||||
use crate::services::auth::AuthClient;
|
|
||||||
use crate::modes::handlers::event::EventOutcome;
|
use crate::modes::handlers::event::EventOutcome;
|
||||||
use crate::tui::functions::common::{login, register};
|
use crate::tui::functions::common::{login, register};
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ use crate::state::app::state::AppState;
|
|||||||
use crate::state::pages::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::state::pages::auth::LoginState;
|
use crate::state::pages::auth::LoginState;
|
||||||
use crate::state::pages::auth::RegisterState;
|
use crate::state::pages::auth::RegisterState;
|
||||||
|
use crate::state::pages::intro::IntroState;
|
||||||
use crate::state::pages::admin::AdminState;
|
use crate::state::pages::admin::AdminState;
|
||||||
use crate::state::pages::canvas_state::CanvasState;
|
use crate::state::pages::canvas_state::CanvasState;
|
||||||
use crate::ui::handlers::context::UiContext;
|
use crate::ui::handlers::context::UiContext;
|
||||||
use crate::modes::handlers::event::EventOutcome;
|
use crate::modes::handlers::event::EventOutcome;
|
||||||
use crate::functions::modes::navigation::admin_nav;
|
|
||||||
|
|
||||||
pub async fn handle_navigation_event(
|
pub async fn handle_navigation_event(
|
||||||
key: KeyEvent,
|
key: KeyEvent,
|
||||||
@@ -19,6 +19,7 @@ pub async fn handle_navigation_event(
|
|||||||
app_state: &mut AppState,
|
app_state: &mut AppState,
|
||||||
login_state: &mut LoginState,
|
login_state: &mut LoginState,
|
||||||
register_state: &mut RegisterState,
|
register_state: &mut RegisterState,
|
||||||
|
intro_state: &mut IntroState,
|
||||||
admin_state: &mut AdminState,
|
admin_state: &mut AdminState,
|
||||||
command_mode: &mut bool,
|
command_mode: &mut bool,
|
||||||
command_input: &mut String,
|
command_input: &mut String,
|
||||||
@@ -27,27 +28,21 @@ pub async fn handle_navigation_event(
|
|||||||
if let Some(action) = config.get_general_action(key.code, key.modifiers) {
|
if let Some(action) = config.get_general_action(key.code, key.modifiers) {
|
||||||
match action {
|
match action {
|
||||||
"move_up" => {
|
"move_up" => {
|
||||||
move_up(app_state, login_state, register_state, admin_state);
|
move_up(app_state, login_state, register_state, intro_state, admin_state);
|
||||||
return Ok(EventOutcome::Ok(String::new()));
|
return Ok(EventOutcome::Ok(String::new()));
|
||||||
}
|
}
|
||||||
"move_down" => {
|
"move_down" => {
|
||||||
move_down(app_state, admin_state);
|
move_down(app_state, intro_state, admin_state);
|
||||||
return Ok(EventOutcome::Ok(String::new()));
|
return Ok(EventOutcome::Ok(String::new()));
|
||||||
}
|
}
|
||||||
"next_option" => {
|
"next_option" => {
|
||||||
next_option(app_state);
|
next_option(app_state, intro_state);
|
||||||
return Ok(EventOutcome::Ok(String::new()));
|
return Ok(EventOutcome::Ok(String::new()));
|
||||||
}
|
}
|
||||||
"previous_option" => {
|
"previous_option" => {
|
||||||
previous_option(app_state);
|
previous_option(app_state, intro_state);
|
||||||
return Ok(EventOutcome::Ok(String::new()));
|
return Ok(EventOutcome::Ok(String::new()));
|
||||||
}
|
}
|
||||||
"toggle_sidebar" => {
|
|
||||||
toggle_sidebar(app_state);
|
|
||||||
return Ok(EventOutcome::Ok(format!("Sidebar {}",
|
|
||||||
if app_state.ui.show_sidebar { "shown" } else { "hidden" }
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
"next_field" => {
|
"next_field" => {
|
||||||
next_field(form_state);
|
next_field(form_state);
|
||||||
return Ok(EventOutcome::Ok(String::new()));
|
return Ok(EventOutcome::Ok(String::new()));
|
||||||
@@ -62,17 +57,16 @@ pub async fn handle_navigation_event(
|
|||||||
}
|
}
|
||||||
"select" => {
|
"select" => {
|
||||||
let (context, index) = if app_state.ui.show_intro {
|
let (context, index) = if app_state.ui.show_intro {
|
||||||
(UiContext::Intro, app_state.ui.intro_state.selected_option)
|
(UiContext::Intro, intro_state.selected_option)
|
||||||
} else if app_state.ui.show_login && app_state.ui.focus_outside_canvas {
|
} else if app_state.ui.show_login && app_state.ui.focus_outside_canvas {
|
||||||
(UiContext::Login, app_state.general.selected_item)
|
(UiContext::Login, app_state.focused_button_index)
|
||||||
} else if app_state.ui.show_register && app_state.ui.focus_outside_canvas {
|
} else if app_state.ui.show_register && app_state.ui.focus_outside_canvas {
|
||||||
(UiContext::Register, app_state.general.selected_item)
|
(UiContext::Register, app_state.focused_button_index)
|
||||||
} else if app_state.ui.show_admin {
|
} else if app_state.ui.show_admin {
|
||||||
(UiContext::Admin, app_state.general.selected_item)
|
(UiContext::Admin, admin_state.get_selected_index().unwrap_or(0))
|
||||||
} else if app_state.ui.dialog.dialog_show {
|
} else if app_state.ui.dialog.dialog_show {
|
||||||
(UiContext::Dialog, app_state.ui.dialog.dialog_active_button_index)
|
(UiContext::Dialog, app_state.ui.dialog.dialog_active_button_index)
|
||||||
} else {
|
} else {
|
||||||
// Handle cases where select is pressed but no button context applies
|
|
||||||
return Ok(EventOutcome::Ok("Select (No Action)".to_string()));
|
return Ok(EventOutcome::Ok("Select (No Action)".to_string()));
|
||||||
};
|
};
|
||||||
return Ok(EventOutcome::ButtonSelected { context, index });
|
return Ok(EventOutcome::ButtonSelected { context, index });
|
||||||
@@ -83,9 +77,9 @@ pub async fn handle_navigation_event(
|
|||||||
Ok(EventOutcome::Ok(String::new()))
|
Ok(EventOutcome::Ok(String::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn move_up(app_state: &mut AppState, login_state: &mut LoginState, register_state: &mut RegisterState, admin_state: &mut AdminState) {
|
pub fn move_up(app_state: &mut AppState, login_state: &mut LoginState, register_state: &mut RegisterState, intro_state: &mut IntroState, admin_state: &mut AdminState) {
|
||||||
if app_state.ui.focus_outside_canvas && app_state.ui.show_login || app_state.ui.show_register{
|
if app_state.ui.focus_outside_canvas && app_state.ui.show_login || app_state.ui.show_register{
|
||||||
if app_state.general.selected_item == 0 {
|
if app_state.focused_button_index == 0 {
|
||||||
app_state.ui.focus_outside_canvas = false;
|
app_state.ui.focus_outside_canvas = false;
|
||||||
if app_state.ui.show_login {
|
if app_state.ui.show_login {
|
||||||
let last_field_index = login_state.fields().len().saturating_sub(1);
|
let last_field_index = login_state.fields().len().saturating_sub(1);
|
||||||
@@ -95,61 +89,51 @@ pub fn move_up(app_state: &mut AppState, login_state: &mut LoginState, register_
|
|||||||
register_state.set_current_field(last_field_index);
|
register_state.set_current_field(last_field_index);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app_state.general.selected_item = app_state.general.selected_item.saturating_sub(1);
|
app_state.focused_button_index = app_state.focused_button_index.saturating_sub(1);
|
||||||
}
|
}
|
||||||
} else if app_state.ui.show_intro {
|
} else if app_state.ui.show_intro {
|
||||||
app_state.ui.intro_state.previous_option();
|
intro_state.previous_option();
|
||||||
} else if app_state.ui.show_admin {
|
} else if app_state.ui.show_admin {
|
||||||
admin_nav::move_admin_list_up(app_state, admin_state);
|
admin_state.previous();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn move_down(app_state: &mut AppState, admin_state: &mut AdminState) {
|
pub fn move_down(app_state: &mut AppState, intro_state: &mut IntroState, admin_state: &mut AdminState) {
|
||||||
if app_state.ui.focus_outside_canvas && app_state.ui.show_login || app_state.ui.show_register {
|
if app_state.ui.focus_outside_canvas && app_state.ui.show_login || app_state.ui.show_register {
|
||||||
let num_general_elements = 2;
|
let num_general_elements = 2;
|
||||||
if app_state.general.selected_item < num_general_elements - 1 {
|
if app_state.focused_button_index < num_general_elements - 1 {
|
||||||
app_state.general.selected_item += 1;
|
app_state.focused_button_index += 1;
|
||||||
}
|
}
|
||||||
} else if app_state.ui.show_intro {
|
} else if app_state.ui.show_intro {
|
||||||
app_state.ui.intro_state.next_option();
|
intro_state.next_option();
|
||||||
} else if app_state.ui.show_admin {
|
} else if app_state.ui.show_admin {
|
||||||
// Assuming profile_tree.profiles is the list we're navigating
|
admin_state.next();
|
||||||
let profile_count = app_state.profile_tree.profiles.len();
|
|
||||||
if profile_count == 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
admin_nav::move_admin_list_down(app_state, admin_state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_option(app_state: &mut AppState) { // Remove option_count parameter
|
pub fn next_option(app_state: &mut AppState, intro_state: &mut IntroState) {
|
||||||
if app_state.ui.show_intro {
|
if app_state.ui.show_intro {
|
||||||
app_state.ui.intro_state.next_option();
|
intro_state.next_option();
|
||||||
} else {
|
} else {
|
||||||
// Get option count from state instead of parameter
|
// Get option count from state instead of parameter
|
||||||
let option_count = app_state.profile_tree.profiles.len();
|
let option_count = app_state.profile_tree.profiles.len();
|
||||||
app_state.general.current_option = (app_state.general.current_option + 1) % option_count;
|
app_state.focused_button_index = (app_state.focused_button_index + 1) % option_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn previous_option(app_state: &mut AppState) {
|
pub fn previous_option(app_state: &mut AppState, intro_state: &mut IntroState) {
|
||||||
if app_state.ui.show_intro {
|
if app_state.ui.show_intro {
|
||||||
app_state.ui.intro_state.previous_option();
|
intro_state.previous_option();
|
||||||
} else {
|
} else {
|
||||||
let option_count = app_state.profile_tree.profiles.len();
|
let option_count = app_state.profile_tree.profiles.len();
|
||||||
app_state.general.current_option = if app_state.general.current_option == 0 {
|
app_state.focused_button_index = if app_state.focused_button_index == 0 {
|
||||||
option_count.saturating_sub(1) // Wrap to last option
|
option_count.saturating_sub(1)
|
||||||
} else {
|
} else {
|
||||||
app_state.general.current_option - 1
|
app_state.focused_button_index - 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_sidebar(app_state: &mut AppState) {
|
|
||||||
app_state.ui.show_sidebar = !app_state.ui.show_sidebar;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn next_field(form_state: &mut FormState) {
|
pub fn next_field(form_state: &mut FormState) {
|
||||||
if !form_state.fields.is_empty() {
|
if !form_state.fields.is_empty() {
|
||||||
form_state.current_field = (form_state.current_field + 1) % form_state.fields.len();
|
form_state.current_field = (form_state.current_field + 1) % form_state.fields.len();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use crate::state::pages::form::FormState;
|
|||||||
use crate::state::pages::auth::AuthState;
|
use crate::state::pages::auth::AuthState;
|
||||||
use crate::state::pages::auth::LoginState;
|
use crate::state::pages::auth::LoginState;
|
||||||
use crate::state::pages::auth::RegisterState;
|
use crate::state::pages::auth::RegisterState;
|
||||||
|
use crate::state::pages::intro::IntroState;
|
||||||
use crate::state::pages::admin::AdminState;
|
use crate::state::pages::admin::AdminState;
|
||||||
use crate::state::app::state::AppState;
|
use crate::state::app::state::AppState;
|
||||||
use crate::state::pages::canvas_state::CanvasState;
|
use crate::state::pages::canvas_state::CanvasState;
|
||||||
@@ -24,6 +25,7 @@ use crate::modes::{
|
|||||||
};
|
};
|
||||||
use crate::config::binds::key_sequences::KeySequenceTracker;
|
use crate::config::binds::key_sequences::KeySequenceTracker;
|
||||||
use crate::modes::handlers::mode_manager::{ModeManager, AppMode};
|
use crate::modes::handlers::mode_manager::{ModeManager, AppMode};
|
||||||
|
use crate::state::app::state::AppView;
|
||||||
use crate::tui::functions::common::form::SaveOutcome;
|
use crate::tui::functions::common::form::SaveOutcome;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
@@ -70,6 +72,7 @@ impl EventHandler {
|
|||||||
auth_state: &mut AuthState,
|
auth_state: &mut AuthState,
|
||||||
login_state: &mut LoginState,
|
login_state: &mut LoginState,
|
||||||
register_state: &mut RegisterState,
|
register_state: &mut RegisterState,
|
||||||
|
intro_state: &mut IntroState,
|
||||||
admin_state: &mut AdminState,
|
admin_state: &mut AdminState,
|
||||||
app_state: &mut AppState,
|
app_state: &mut AppState,
|
||||||
total_count: u64,
|
total_count: u64,
|
||||||
@@ -78,6 +81,21 @@ impl EventHandler {
|
|||||||
let current_mode = ModeManager::derive_mode(app_state, self);
|
let current_mode = ModeManager::derive_mode(app_state, self);
|
||||||
app_state.update_mode(current_mode);
|
app_state.update_mode(current_mode);
|
||||||
|
|
||||||
|
// Determine the current view, including dynamic names
|
||||||
|
let current_view = {
|
||||||
|
let ui = &app_state.ui;
|
||||||
|
if ui.show_intro { AppView::Intro }
|
||||||
|
else if ui.show_login { AppView::Login }
|
||||||
|
else if ui.show_register { AppView::Register }
|
||||||
|
else if ui.show_admin { AppView::Admin }
|
||||||
|
else if ui.show_form {
|
||||||
|
let form_name = app_state.selected_profile.clone().unwrap_or_else(|| "Data Form".to_string());
|
||||||
|
AppView::Form(form_name)
|
||||||
|
}
|
||||||
|
else { AppView::Scratch }
|
||||||
|
};
|
||||||
|
app_state.ui.update_buffer_history(current_view);
|
||||||
|
|
||||||
// --- DIALOG MODALITY ---
|
// --- DIALOG MODALITY ---
|
||||||
if app_state.ui.dialog.dialog_show {
|
if app_state.ui.dialog.dialog_show {
|
||||||
if let Some(dialog_result) = dialog::handle_dialog_event(
|
if let Some(dialog_result) = dialog::handle_dialog_event(
|
||||||
@@ -99,6 +117,13 @@ impl EventHandler {
|
|||||||
);
|
);
|
||||||
return Ok(EventOutcome::Ok(message));
|
return Ok(EventOutcome::Ok(message));
|
||||||
}
|
}
|
||||||
|
if UiStateHandler::toggle_buffer_list(&mut app_state.ui, config, key_code, modifiers) {
|
||||||
|
let message = format!("Buffer {}",
|
||||||
|
if app_state.ui.show_buffer_list { "shown" } else { "hidden" }
|
||||||
|
);
|
||||||
|
return Ok(EventOutcome::Ok(message));
|
||||||
|
}
|
||||||
|
// --- End Global UI Toggles ---
|
||||||
|
|
||||||
match current_mode {
|
match current_mode {
|
||||||
AppMode::General => {
|
AppMode::General => {
|
||||||
@@ -109,6 +134,7 @@ impl EventHandler {
|
|||||||
app_state,
|
app_state,
|
||||||
login_state,
|
login_state,
|
||||||
register_state,
|
register_state,
|
||||||
|
intro_state,
|
||||||
admin_state,
|
admin_state,
|
||||||
&mut self.command_mode,
|
&mut self.command_mode,
|
||||||
&mut self.command_input,
|
&mut self.command_input,
|
||||||
@@ -119,7 +145,13 @@ impl EventHandler {
|
|||||||
let mut message = String::from("Selected"); // Default message
|
let mut message = String::from("Selected"); // Default message
|
||||||
match context {
|
match context {
|
||||||
UiContext::Intro => {
|
UiContext::Intro => {
|
||||||
intro::handle_intro_selection(app_state, index); // Pass index
|
intro::handle_intro_selection(app_state, index);
|
||||||
|
if app_state.ui.show_admin {
|
||||||
|
let profile_names = app_state.profile_tree.profiles.iter()
|
||||||
|
.map(|p| p.name.clone())
|
||||||
|
.collect();
|
||||||
|
admin_state.set_profiles(profile_names);
|
||||||
|
}
|
||||||
message = format!("Intro Option {} selected", index);
|
message = format!("Intro Option {} selected", index);
|
||||||
}
|
}
|
||||||
UiContext::Login => {
|
UiContext::Login => {
|
||||||
@@ -137,7 +169,7 @@ impl EventHandler {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
UiContext::Admin => {
|
UiContext::Admin => {
|
||||||
admin::handle_admin_selection(app_state);
|
admin::handle_admin_selection(app_state, admin_state);
|
||||||
|
|
||||||
message = format!("Admin Option {} selected", index);
|
message = format!("Admin Option {} selected", index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,34 @@
|
|||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use common::proto::multieko2::table_definition::ProfileTreeResponse;
|
use common::proto::multieko2::table_definition::ProfileTreeResponse;
|
||||||
use crate::components::IntroState;
|
|
||||||
use crate::modes::handlers::mode_manager::AppMode;
|
use crate::modes::handlers::mode_manager::AppMode;
|
||||||
use crate::ui::handlers::context::DialogPurpose;
|
use crate::ui::handlers::context::DialogPurpose;
|
||||||
|
|
||||||
|
/// Represents the distinct views or "buffers" the user can navigate.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub enum AppView {
|
||||||
|
Intro,
|
||||||
|
Login,
|
||||||
|
Register,
|
||||||
|
Admin,
|
||||||
|
Form(String),
|
||||||
|
Scratch,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AppView {
|
||||||
|
/// Returns the display name for the view.
|
||||||
|
pub fn display_name(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
AppView::Intro => "Intro",
|
||||||
|
AppView::Login => "Login",
|
||||||
|
AppView::Register => "Register",
|
||||||
|
AppView::Admin => "Admin Panel",
|
||||||
|
AppView::Form(name) => name.as_str(),
|
||||||
|
AppView::Scratch => "*scratch*",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct DialogState {
|
pub struct DialogState {
|
||||||
pub dialog_show: bool,
|
pub dialog_show: bool,
|
||||||
pub dialog_title: String,
|
pub dialog_title: String,
|
||||||
@@ -17,13 +41,15 @@ pub struct DialogState {
|
|||||||
|
|
||||||
pub struct UiState {
|
pub struct UiState {
|
||||||
pub show_sidebar: bool,
|
pub show_sidebar: bool,
|
||||||
|
pub show_buffer_list: bool,
|
||||||
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 show_login: bool,
|
||||||
pub show_register: bool,
|
pub show_register: bool,
|
||||||
pub intro_state: IntroState,
|
|
||||||
pub focus_outside_canvas: bool,
|
pub focus_outside_canvas: bool,
|
||||||
|
pub buffer_history: Vec<AppView>,
|
||||||
|
pub active_buffer_index: usize,
|
||||||
pub dialog: DialogState,
|
pub dialog: DialogState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +61,7 @@ pub struct AppState {
|
|||||||
pub profile_tree: ProfileTreeResponse,
|
pub profile_tree: ProfileTreeResponse,
|
||||||
pub selected_profile: Option<String>,
|
pub selected_profile: Option<String>,
|
||||||
pub current_mode: AppMode,
|
pub current_mode: AppMode,
|
||||||
|
pub focused_button_index: usize,
|
||||||
|
|
||||||
// UI preferences
|
// UI preferences
|
||||||
pub ui: UiState,
|
pub ui: UiState,
|
||||||
@@ -52,6 +79,7 @@ impl AppState {
|
|||||||
profile_tree: ProfileTreeResponse::default(),
|
profile_tree: ProfileTreeResponse::default(),
|
||||||
selected_profile: None,
|
selected_profile: None,
|
||||||
current_mode: AppMode::General,
|
current_mode: AppMode::General,
|
||||||
|
focused_button_index: 0,
|
||||||
ui: UiState::default(),
|
ui: UiState::default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -136,8 +164,10 @@ impl Default for UiState {
|
|||||||
show_form: false,
|
show_form: false,
|
||||||
show_login: false,
|
show_login: false,
|
||||||
show_register: false,
|
show_register: false,
|
||||||
intro_state: IntroState::new(),
|
show_buffer_list: false,
|
||||||
focus_outside_canvas: false,
|
focus_outside_canvas: false,
|
||||||
|
buffer_history: vec![AppView::Intro],
|
||||||
|
active_buffer_index: 0,
|
||||||
dialog: DialogState::default(),
|
dialog: DialogState::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,3 +186,20 @@ impl Default for DialogState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl UiState {
|
||||||
|
/// Updates the buffer history and active index.
|
||||||
|
pub fn update_buffer_history(&mut self, view: AppView) {
|
||||||
|
let existing_pos = self.buffer_history.iter().position(|v| v == &view);
|
||||||
|
|
||||||
|
match existing_pos {
|
||||||
|
Some(pos) => {
|
||||||
|
self.active_buffer_index = pos;
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
self.buffer_history.push(view.clone());
|
||||||
|
self.active_buffer_index = self.buffer_history.len() - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,4 +3,5 @@
|
|||||||
pub mod form;
|
pub mod form;
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod admin;
|
pub mod admin;
|
||||||
|
pub mod intro;
|
||||||
pub mod canvas_state;
|
pub mod canvas_state;
|
||||||
|
|||||||
@@ -34,5 +34,32 @@ impl AdminState {
|
|||||||
self.list_state.select(new_selection);
|
self.list_state.select(new_selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Selects the next profile in the list, wrapping around.
|
||||||
|
pub fn next(&mut self) {
|
||||||
|
if self.profiles.is_empty() {
|
||||||
|
self.list_state.select(None);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let i = match self.list_state.selected() {
|
||||||
|
Some(i) => if i >= self.profiles.len() - 1 { 0 } else { i + 1 },
|
||||||
|
None => 0,
|
||||||
|
};
|
||||||
|
self.list_state.select(Some(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Selects the previous profile in the list, wrapping around.
|
||||||
|
pub fn previous(&mut self) {
|
||||||
|
if self.profiles.is_empty() {
|
||||||
|
self.list_state.select(None);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let i = match self.list_state.selected() {
|
||||||
|
Some(i) => if i == 0 { self.profiles.len() - 1 } else { i - 1 },
|
||||||
|
None => self.profiles.len() - 1,
|
||||||
|
};
|
||||||
|
self.list_state.select(Some(i));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
25
client/src/state/pages/intro.rs
Normal file
25
client/src/state/pages/intro.rs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// src/state/pages/intro.rs
|
||||||
|
|
||||||
|
#[derive(Default, Clone, Debug)]
|
||||||
|
pub struct IntroState {
|
||||||
|
pub selected_option: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IntroState {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self::default()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn next_option(&mut self) {
|
||||||
|
if self.selected_option < 3 {
|
||||||
|
self.selected_option += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn previous_option(&mut self) {
|
||||||
|
if self.selected_option > 0 {
|
||||||
|
self.selected_option -= 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
use crate::state::app::state::AppState;
|
use crate::state::app::state::AppState;
|
||||||
|
use crate::state::pages::admin::AdminState;
|
||||||
|
|
||||||
pub fn handle_admin_selection(app_state: &mut AppState) {
|
pub fn handle_admin_selection(app_state: &mut AppState, admin_state: &AdminState) {
|
||||||
let profiles = &app_state.profile_tree.profiles;
|
let profiles = &app_state.profile_tree.profiles;
|
||||||
if !profiles.is_empty() && app_state.general.selected_item < profiles.len() {
|
if let Some(selected_index) = admin_state.get_selected_index() {
|
||||||
app_state.selected_profile = Some(profiles[app_state.general.selected_item].name.clone());
|
if let Some(profile) = profiles.get(selected_index) {
|
||||||
|
app_state.selected_profile = Some(profile.name.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ pub async fn back_to_main(
|
|||||||
|
|
||||||
// Reset focus state
|
// Reset focus state
|
||||||
app_state.ui.focus_outside_canvas = false;
|
app_state.ui.focus_outside_canvas = false;
|
||||||
app_state.general.selected_item = 0;
|
app_state.focused_button_index= 0;
|
||||||
|
|
||||||
"Returned to main menu".to_string()
|
"Returned to main menu".to_string()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ pub async fn back_to_main(
|
|||||||
|
|
||||||
// Reset focus state
|
// Reset focus state
|
||||||
app_state.ui.focus_outside_canvas = false;
|
app_state.ui.focus_outside_canvas = false;
|
||||||
app_state.general.selected_item = 0; // Reset intro selection
|
app_state.focused_button_index = 0;
|
||||||
|
|
||||||
"Returned to main menu".to_string()
|
"Returned to main menu".to_string()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
// src/tui/functions/intro.rs
|
||||||
use crate::state::app::state::AppState;
|
use crate::state::app::state::AppState;
|
||||||
|
|
||||||
pub fn handle_intro_selection(app_state: &mut AppState, index: usize) { // Add index parameter
|
pub fn handle_intro_selection(app_state: &mut AppState, index: usize) {
|
||||||
match index { // Use index directly
|
match index { // Use index directly
|
||||||
0 => { // Continue
|
0 => { // Continue
|
||||||
app_state.ui.show_form = true;
|
app_state.ui.show_form = true;
|
||||||
@@ -21,7 +22,7 @@ pub fn handle_intro_selection(app_state: &mut AppState, index: usize) { // Add i
|
|||||||
app_state.ui.show_intro = false;
|
app_state.ui.show_intro = false;
|
||||||
app_state.ui.show_register = true;
|
app_state.ui.show_register = true;
|
||||||
app_state.ui.focus_outside_canvas = false;
|
app_state.ui.focus_outside_canvas = false;
|
||||||
app_state.general.selected_item = 0;
|
app_state.focused_button_index = 0;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,4 +21,18 @@ impl UiStateHandler {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn toggle_buffer_list(
|
||||||
|
ui_state: &mut UiState,
|
||||||
|
config: &Config,
|
||||||
|
key: KeyCode,
|
||||||
|
modifiers: KeyModifiers,
|
||||||
|
) -> bool {
|
||||||
|
if let Some(action) = config.get_common_action(key, modifiers) {
|
||||||
|
if action == "toggle_buffer_list" {
|
||||||
|
ui_state.show_buffer_list = !ui_state.show_buffer_list;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
render_background,
|
render_background,
|
||||||
|
render_buffer_list,
|
||||||
render_command_line,
|
render_command_line,
|
||||||
render_status_line,
|
render_status_line,
|
||||||
|
intro::intro::render_intro,
|
||||||
handlers::sidebar::{self, calculate_sidebar_layout},
|
handlers::sidebar::{self, calculate_sidebar_layout},
|
||||||
form::form::render_form,
|
form::form::render_form,
|
||||||
admin::{admin_panel::AdminPanelState},
|
|
||||||
auth::{login::render_login, register::render_register},
|
auth::{login::render_login, register::render_register},
|
||||||
};
|
};
|
||||||
use crate::config::colors::themes::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
@@ -16,6 +17,7 @@ use crate::state::pages::form::FormState;
|
|||||||
use crate::state::pages::auth::AuthState;
|
use crate::state::pages::auth::AuthState;
|
||||||
use crate::state::pages::auth::LoginState;
|
use crate::state::pages::auth::LoginState;
|
||||||
use crate::state::pages::auth::RegisterState;
|
use crate::state::pages::auth::RegisterState;
|
||||||
|
use crate::state::pages::intro::IntroState;
|
||||||
use crate::state::app::state::AppState;
|
use crate::state::app::state::AppState;
|
||||||
use crate::state::pages::admin::AdminState;
|
use crate::state::pages::admin::AdminState;
|
||||||
|
|
||||||
@@ -25,6 +27,8 @@ pub fn render_ui(
|
|||||||
auth_state: &mut AuthState,
|
auth_state: &mut AuthState,
|
||||||
login_state: &LoginState,
|
login_state: &LoginState,
|
||||||
register_state: &RegisterState,
|
register_state: &RegisterState,
|
||||||
|
intro_state: &IntroState,
|
||||||
|
admin_state: &mut AdminState,
|
||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
is_edit_mode: bool,
|
is_edit_mode: bool,
|
||||||
total_count: u64,
|
total_count: u64,
|
||||||
@@ -37,18 +41,46 @@ pub fn render_ui(
|
|||||||
) {
|
) {
|
||||||
render_background(f, f.area(), theme);
|
render_background(f, f.area(), theme);
|
||||||
|
|
||||||
|
// Adjust layout based on whether buffer list is shown
|
||||||
|
let constraints = if app_state.ui.show_buffer_list {
|
||||||
|
vec![
|
||||||
|
Constraint::Length(1), // Buffer list
|
||||||
|
Constraint::Min(1), // Main content
|
||||||
|
Constraint::Length(1), // Status line
|
||||||
|
Constraint::Length(1), // Command line
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
vec![
|
||||||
|
Constraint::Min(1), // Main content
|
||||||
|
Constraint::Length(1), // Status line (no buffer list)
|
||||||
|
Constraint::Length(1), // Command line
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
let root = Layout::default()
|
let root = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints([
|
.constraints(constraints)
|
||||||
Constraint::Min(1),
|
|
||||||
Constraint::Length(1),
|
|
||||||
Constraint::Length(1),
|
|
||||||
])
|
|
||||||
.split(f.area());
|
.split(f.area());
|
||||||
|
|
||||||
let main_content_area = root[0];
|
let mut buffer_list_area = None;
|
||||||
|
let main_content_area;
|
||||||
|
let status_line_area;
|
||||||
|
let command_line_area;
|
||||||
|
|
||||||
|
// Assign areas based on layout
|
||||||
|
if app_state.ui.show_buffer_list {
|
||||||
|
buffer_list_area = Some(root[0]);
|
||||||
|
main_content_area = root[1];
|
||||||
|
status_line_area = root[2];
|
||||||
|
command_line_area = root[3];
|
||||||
|
} else {
|
||||||
|
main_content_area = root[0];
|
||||||
|
status_line_area = root[1];
|
||||||
|
command_line_area = root[2];
|
||||||
|
}
|
||||||
|
|
||||||
if app_state.ui.show_intro {
|
if app_state.ui.show_intro {
|
||||||
app_state.ui.intro_state.render(f, main_content_area, theme);
|
render_intro(f, intro_state, main_content_area, theme);
|
||||||
} else if app_state.ui.show_register {
|
} else if app_state.ui.show_register {
|
||||||
render_register(
|
render_register(
|
||||||
f,
|
f,
|
||||||
@@ -58,34 +90,20 @@ pub fn render_ui(
|
|||||||
app_state,
|
app_state,
|
||||||
register_state.current_field < 4
|
register_state.current_field < 4
|
||||||
);
|
);
|
||||||
}else if app_state.ui.show_login {
|
} else if app_state.ui.show_login {
|
||||||
render_login(
|
render_login(
|
||||||
f,
|
f,
|
||||||
main_content_area,
|
main_content_area,
|
||||||
theme,
|
theme,
|
||||||
login_state,
|
login_state,
|
||||||
app_state,
|
app_state,
|
||||||
login_state.current_field < 2
|
login_state.current_field < 2
|
||||||
);
|
);
|
||||||
} else if app_state.ui.show_admin {
|
} else if app_state.ui.show_admin {
|
||||||
// Create temporary AdminPanelState for rendering
|
crate::components::admin::admin_panel::render_admin_panel(
|
||||||
let mut admin_state = AdminPanelState::new(
|
|
||||||
app_state.profile_tree.profiles
|
|
||||||
.iter()
|
|
||||||
.map(|p| p.name.clone())
|
|
||||||
.collect()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Set the selected item - FIXED
|
|
||||||
if !admin_state.profiles.is_empty() {
|
|
||||||
let selected_index = admin_state.get_selected_index()
|
|
||||||
.unwrap_or(0)
|
|
||||||
.min(admin_state.profiles.len() - 1);
|
|
||||||
admin_state.list_state.select(Some(selected_index));
|
|
||||||
}
|
|
||||||
|
|
||||||
admin_state.render(
|
|
||||||
f,
|
f,
|
||||||
|
auth_state,
|
||||||
|
admin_state,
|
||||||
main_content_area,
|
main_content_area,
|
||||||
theme,
|
theme,
|
||||||
&app_state.profile_tree,
|
&app_state.profile_tree,
|
||||||
@@ -147,10 +165,14 @@ pub fn render_ui(
|
|||||||
total_count,
|
total_count,
|
||||||
current_position,
|
current_position,
|
||||||
);
|
);
|
||||||
} else{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render_status_line(f, root[1], current_dir, theme, is_edit_mode);
|
// Render buffer list if enabled and area is available
|
||||||
render_command_line(f, root[2], command_input, command_mode, theme, command_message);
|
if let Some(area) = buffer_list_area {
|
||||||
|
if app_state.ui.show_buffer_list {
|
||||||
|
render_buffer_list(f, area, theme, app_state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
render_status_line(f, status_line_area, current_dir, theme, is_edit_mode);
|
||||||
|
render_command_line(f, command_line_area, command_input, command_mode, theme, command_message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use crate::state::pages::auth::AuthState;
|
|||||||
use crate::state::pages::auth::LoginState;
|
use crate::state::pages::auth::LoginState;
|
||||||
use crate::state::pages::auth::RegisterState;
|
use crate::state::pages::auth::RegisterState;
|
||||||
use crate::state::pages::admin::AdminState;
|
use crate::state::pages::admin::AdminState;
|
||||||
|
use crate::state::pages::intro::IntroState;
|
||||||
use crate::state::app::state::AppState;
|
use crate::state::app::state::AppState;
|
||||||
// Import SaveOutcome
|
// Import SaveOutcome
|
||||||
use crate::tui::terminal::{EventReader, TerminalCore};
|
use crate::tui::terminal::{EventReader, TerminalCore};
|
||||||
@@ -21,30 +22,27 @@ use crossterm::cursor::SetCursorStyle;
|
|||||||
|
|
||||||
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()?;
|
||||||
|
let theme = Theme::from_str(&config.colors.theme);
|
||||||
let mut terminal = TerminalCore::new()?;
|
let mut terminal = TerminalCore::new()?;
|
||||||
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 mut auth_state = AuthState::default();
|
|
||||||
let mut register_state = RegisterState::default();
|
|
||||||
let mut login_state = LoginState::default();
|
|
||||||
let mut admin_state = AdminState::default();
|
|
||||||
|
|
||||||
// Initialize app_state first
|
let mut event_handler = EventHandler::new().await?;
|
||||||
|
let event_reader = EventReader::new();
|
||||||
|
|
||||||
|
let mut auth_state = AuthState::default();
|
||||||
|
let mut login_state = LoginState::default();
|
||||||
|
let mut register_state = RegisterState::default();
|
||||||
|
let mut intro_state = IntroState::default();
|
||||||
|
let mut admin_state = AdminState::default();
|
||||||
let mut app_state = AppState::new()?;
|
let mut app_state = AppState::new()?;
|
||||||
|
|
||||||
// Initialize app state with profile tree and table structure
|
// Initialize app state with profile tree and table structure
|
||||||
let column_names =
|
let column_names =
|
||||||
UiService::initialize_app_state(&mut grpc_client, &mut app_state)
|
UiService::initialize_app_state(&mut grpc_client, &mut app_state)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Initialize FormState with dynamic fields
|
|
||||||
let mut form_state = FormState::new(column_names);
|
let mut form_state = FormState::new(column_names);
|
||||||
|
|
||||||
// Initialize EventHandler (which now contains AuthClient)
|
|
||||||
let mut event_handler = EventHandler::new().await?;
|
|
||||||
let event_reader = EventReader::new();
|
|
||||||
|
|
||||||
// Fetch the total count of Adresar entries
|
// Fetch the total count of Adresar entries
|
||||||
UiService::initialize_adresar_count(&mut grpc_client, &mut app_state)
|
UiService::initialize_adresar_count(&mut grpc_client, &mut app_state)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -61,6 +59,8 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
&mut auth_state,
|
&mut auth_state,
|
||||||
&login_state,
|
&login_state,
|
||||||
®ister_state,
|
®ister_state,
|
||||||
|
&intro_state,
|
||||||
|
&mut admin_state,
|
||||||
&theme,
|
&theme,
|
||||||
is_edit_mode,
|
is_edit_mode,
|
||||||
app_state.total_count,
|
app_state.total_count,
|
||||||
@@ -120,6 +120,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
&mut auth_state,
|
&mut auth_state,
|
||||||
&mut login_state,
|
&mut login_state,
|
||||||
&mut register_state,
|
&mut register_state,
|
||||||
|
&mut intro_state,
|
||||||
&mut admin_state,
|
&mut admin_state,
|
||||||
&mut app_state,
|
&mut app_state,
|
||||||
total_count,
|
total_count,
|
||||||
|
|||||||
Reference in New Issue
Block a user