NEW PAGE ADD TABLE
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
// src/components/admin.rs
|
// src/components/admin.rs
|
||||||
pub mod admin_panel;
|
pub mod admin_panel;
|
||||||
pub mod admin_panel_admin;
|
pub mod admin_panel_admin;
|
||||||
|
pub mod add_table;
|
||||||
|
|
||||||
pub use admin_panel::*;
|
pub use admin_panel::*;
|
||||||
pub use admin_panel_admin::*;
|
pub use admin_panel_admin::*;
|
||||||
|
pub use add_table::*;
|
||||||
|
|||||||
32
client/src/components/admin/add_table.rs
Normal file
32
client/src/components/admin/add_table.rs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// src/components/admin/add_table.rs
|
||||||
|
use crate::config::colors::themes::Theme;
|
||||||
|
use ratatui::{
|
||||||
|
layout::{Alignment, Rect},
|
||||||
|
style::{Style, Stylize},
|
||||||
|
widgets::{Block, Borders, Paragraph},
|
||||||
|
Frame,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Renders a placeholder page for adding tables.
|
||||||
|
pub fn render_add_table_page(
|
||||||
|
f: &mut Frame,
|
||||||
|
area: Rect,
|
||||||
|
theme: &Theme,
|
||||||
|
) {
|
||||||
|
let block = Block::default()
|
||||||
|
.title(" Add New Table ")
|
||||||
|
.borders(Borders::ALL)
|
||||||
|
.border_style(Style::default().fg(theme.accent))
|
||||||
|
.style(Style::default().bg(theme.bg));
|
||||||
|
|
||||||
|
let inner_area = block.inner(area);
|
||||||
|
|
||||||
|
let text = Paragraph::new("This is the placeholder page for adding a new table.\n\nDrawing canvas coming soon!")
|
||||||
|
.style(Style::default().fg(theme.fg))
|
||||||
|
.alignment(Alignment::Center);
|
||||||
|
|
||||||
|
f.render_widget(block, area);
|
||||||
|
f.render_widget(text, inner_area);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ use crate::state::app::buffer::AppView;
|
|||||||
pub fn get_view_layer(view: &AppView) -> u8 {
|
pub fn get_view_layer(view: &AppView) -> u8 {
|
||||||
match view {
|
match view {
|
||||||
AppView::Intro => 1,
|
AppView::Intro => 1,
|
||||||
AppView::Login | AppView::Register | AppView::Admin => 2,
|
AppView::Login | AppView::Register | AppView::Admin | AppView::AddTable => 2,
|
||||||
AppView::Form(_) | AppView::Scratch => 3,
|
AppView::Form(_) | AppView::Scratch => 3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,17 @@ use crate::state::{
|
|||||||
pages::admin::{AdminFocus, AdminState},
|
pages::admin::{AdminFocus, AdminState},
|
||||||
};
|
};
|
||||||
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
||||||
|
use crate::state::app::buffer::AppView;
|
||||||
|
use crate::state::app::buffer::BufferState;
|
||||||
|
|
||||||
/// Handles navigation events specifically for the Admin Panel view.
|
/// Handles navigation events specifically for the Admin Panel view.
|
||||||
/// Returns true if the event was handled, false otherwise.
|
/// Returns true if the event was handled, false otherwise.
|
||||||
pub fn handle_admin_navigation(
|
pub fn handle_admin_navigation(
|
||||||
key: KeyEvent,
|
key: KeyEvent,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
app_state: &AppState, // Read-only access needed for counts
|
app_state: &AppState,
|
||||||
admin_state: &mut AdminState, // Mutable to change focus/selection
|
admin_state: &mut AdminState,
|
||||||
|
buffer_state: &mut BufferState,
|
||||||
command_message: &mut String,
|
command_message: &mut String,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let action = config.get_general_action(key.code, key.modifiers);
|
let action = config.get_general_action(key.code, key.modifiers);
|
||||||
@@ -157,8 +160,8 @@ pub fn handle_admin_navigation(
|
|||||||
// TODO: Trigger action for Button 1
|
// TODO: Trigger action for Button 1
|
||||||
}
|
}
|
||||||
AdminFocus::Button2 => {
|
AdminFocus::Button2 => {
|
||||||
*command_message = "Action: Add Table (Not Implemented)".to_string();
|
buffer_state.update_history(AppView::AddTable);
|
||||||
// TODO: Trigger action for Button 2
|
*command_message = "Navigating to Add Table page...".to_string();
|
||||||
}
|
}
|
||||||
AdminFocus::Button3 => {
|
AdminFocus::Button3 => {
|
||||||
*command_message = "Action: Change Table (Not Implemented)".to_string();
|
*command_message = "Action: Change Table (Not Implemented)".to_string();
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ impl EventHandler {
|
|||||||
else if ui.show_login { AppView::Login }
|
else if ui.show_login { AppView::Login }
|
||||||
else if ui.show_register { AppView::Register }
|
else if ui.show_register { AppView::Register }
|
||||||
else if ui.show_admin { AppView::Admin }
|
else if ui.show_admin { AppView::Admin }
|
||||||
|
else if ui.show_add_table { AppView::AddTable }
|
||||||
else if ui.show_form {
|
else if ui.show_form {
|
||||||
let form_name = app_state.selected_profile.clone().unwrap_or_else(|| "Data Form".to_string());
|
let form_name = app_state.selected_profile.clone().unwrap_or_else(|| "Data Form".to_string());
|
||||||
AppView::Form(form_name)
|
AppView::Form(form_name)
|
||||||
@@ -168,6 +169,7 @@ impl EventHandler {
|
|||||||
config,
|
config,
|
||||||
app_state,
|
app_state,
|
||||||
admin_state,
|
admin_state,
|
||||||
|
buffer_state,
|
||||||
&mut self.command_message,
|
&mut self.command_message,
|
||||||
) {
|
) {
|
||||||
return Ok(EventOutcome::Ok(self.command_message.clone()));
|
return Ok(EventOutcome::Ok(self.command_message.clone()));
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ pub enum AppView {
|
|||||||
Login,
|
Login,
|
||||||
Register,
|
Register,
|
||||||
Admin,
|
Admin,
|
||||||
|
AddTable,
|
||||||
Form(String),
|
Form(String),
|
||||||
Scratch,
|
Scratch,
|
||||||
}
|
}
|
||||||
@@ -18,7 +19,8 @@ impl AppView {
|
|||||||
AppView::Intro => "Intro",
|
AppView::Intro => "Intro",
|
||||||
AppView::Login => "Login",
|
AppView::Login => "Login",
|
||||||
AppView::Register => "Register",
|
AppView::Register => "Register",
|
||||||
AppView::Admin => "Admin Panel",
|
AppView::Admin => "Admin_panel",
|
||||||
|
AppView::AddTable => "Add_table",
|
||||||
AppView::Form(name) => name.as_str(),
|
AppView::Form(name) => name.as_str(),
|
||||||
AppView::Scratch => "*scratch*",
|
AppView::Scratch => "*scratch*",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ pub struct UiState {
|
|||||||
pub show_buffer_list: bool,
|
pub show_buffer_list: bool,
|
||||||
pub show_intro: bool,
|
pub show_intro: bool,
|
||||||
pub show_admin: bool,
|
pub show_admin: bool,
|
||||||
|
pub show_add_table: 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,
|
||||||
@@ -134,6 +135,7 @@ impl Default for UiState {
|
|||||||
show_sidebar: false,
|
show_sidebar: false,
|
||||||
show_intro: true,
|
show_intro: true,
|
||||||
show_admin: false,
|
show_admin: false,
|
||||||
|
show_add_table: false,
|
||||||
show_form: false,
|
show_form: false,
|
||||||
show_login: false,
|
show_login: false,
|
||||||
show_register: false,
|
show_register: false,
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
app_state.ui.show_login = false;
|
app_state.ui.show_login = false;
|
||||||
app_state.ui.show_register = false;
|
app_state.ui.show_register = false;
|
||||||
app_state.ui.show_admin = false;
|
app_state.ui.show_admin = false;
|
||||||
|
app_state.ui.show_add_table = false;
|
||||||
app_state.ui.show_form = false;
|
app_state.ui.show_form = false;
|
||||||
match active_view {
|
match active_view {
|
||||||
AppView::Intro => app_state.ui.show_intro = true,
|
AppView::Intro => app_state.ui.show_intro = true,
|
||||||
@@ -79,6 +80,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.collect();
|
.collect();
|
||||||
admin_state.set_profiles(profile_names);
|
admin_state.set_profiles(profile_names);
|
||||||
}
|
}
|
||||||
|
AppView::AddTable => app_state.ui.show_add_table = true,
|
||||||
AppView::Form(_) => app_state.ui.show_form = true,
|
AppView::Form(_) => app_state.ui.show_form = true,
|
||||||
AppView::Scratch => {} // Or show a scratchpad component
|
AppView::Scratch => {} // Or show a scratchpad component
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user