admin panel compiled
This commit is contained in:
@@ -6,6 +6,7 @@ pub mod canvas;
|
||||
pub mod sidebar;
|
||||
pub mod background;
|
||||
pub mod intro;
|
||||
pub mod admin_panel;
|
||||
|
||||
pub use command_line::render_command_line;
|
||||
pub use form::*;
|
||||
@@ -14,3 +15,4 @@ pub use canvas::*;
|
||||
pub use sidebar::*;
|
||||
pub use background::*;
|
||||
pub use intro::*;
|
||||
pub use admin_panel::*;
|
||||
|
||||
44
client/src/components/handlers/admin_panel.rs
Normal file
44
client/src/components/handlers/admin_panel.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
// src/components/handlers/admin_panel.rs
|
||||
use ratatui::{
|
||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||
style::Style,
|
||||
text::{Line, Span},
|
||||
widgets::{Block, BorderType, Borders, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
use crate::config::colors::Theme;
|
||||
|
||||
pub struct AdminPanelState;
|
||||
|
||||
impl AdminPanelState {
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
|
||||
pub fn render(&self, f: &mut Frame, area: Rect, theme: &Theme) {
|
||||
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), // Title
|
||||
Constraint::Min(1), // Content
|
||||
])
|
||||
.split(inner_area);
|
||||
|
||||
let title = Line::from(Span::styled("Admin Panel", Style::default().fg(theme.highlight)));
|
||||
let title_para = Paragraph::new(title)
|
||||
.alignment(Alignment::Center);
|
||||
f.render_widget(title_para, chunks[0]);
|
||||
|
||||
let content = Paragraph::new("Admin panel content goes here");
|
||||
f.render_widget(content, chunks[1]);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// src/client/ui/handlers/state.rs
|
||||
// src/state/state.rs
|
||||
|
||||
use std::env;
|
||||
use common::proto::multieko2::table_definition::ProfileTreeResponse;
|
||||
@@ -7,6 +7,7 @@ pub struct UiState {
|
||||
pub show_sidebar: bool,
|
||||
pub is_saved: bool,
|
||||
pub show_intro: bool,
|
||||
pub show_admin: bool,
|
||||
}
|
||||
|
||||
pub struct AppState {
|
||||
@@ -50,6 +51,7 @@ impl Default for UiState {
|
||||
show_sidebar: true,
|
||||
is_saved: false,
|
||||
show_intro: true,
|
||||
show_admin: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::components::{
|
||||
render_background,
|
||||
render_command_line,
|
||||
render_status_line,
|
||||
handlers::{sidebar::{self, calculate_sidebar_layout}, intro},
|
||||
handlers::{sidebar::{self, calculate_sidebar_layout}, intro, admin_panel::AdminPanelState},
|
||||
};
|
||||
use crate::config::colors::Theme;
|
||||
use ratatui::layout::{Constraint, Direction, Layout};
|
||||
@@ -24,6 +24,7 @@ pub fn render_ui(
|
||||
command_message: &str,
|
||||
app_state: &AppState,
|
||||
intro_state: &intro::IntroState,
|
||||
admin_panel_state: &AdminPanelState,
|
||||
) {
|
||||
render_background(f, f.area(), theme);
|
||||
|
||||
@@ -42,7 +43,11 @@ pub fn render_ui(
|
||||
.split(f.area());
|
||||
|
||||
let main_content_area = root[0];
|
||||
let (sidebar_area, form_area) = calculate_sidebar_layout(app_state.ui.show_sidebar, main_content_area);
|
||||
let (sidebar_area, form_area) = if app_state.ui.show_admin {
|
||||
(None, main_content_area)
|
||||
} else {
|
||||
calculate_sidebar_layout(app_state.ui.show_sidebar, main_content_area)
|
||||
};
|
||||
let available_width = form_area.width;
|
||||
|
||||
let form_constraint = if available_width >= 80 {
|
||||
@@ -74,7 +79,9 @@ pub fn render_ui(
|
||||
current_position,
|
||||
);
|
||||
|
||||
if let Some(sidebar_rect) = sidebar_area {
|
||||
if app_state.ui.show_admin {
|
||||
admin_panel_state.render(f, form_area, theme);
|
||||
} else if let Some(sidebar_rect) = sidebar_area {
|
||||
sidebar::render_sidebar(f, sidebar_rect, theme, &app_state.profile_tree);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::config::config::Config;
|
||||
use crate::ui::handlers::{form::FormState, render::render_ui};
|
||||
use crate::modes::handlers::event::EventHandler;
|
||||
use crate::state::state::AppState;
|
||||
use crate::components::handlers::intro::IntroState;
|
||||
use crate::components::handlers::{intro::IntroState, admin_panel::AdminPanelState};
|
||||
|
||||
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = Config::load()?;
|
||||
@@ -18,6 +18,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut command_handler = CommandHandler::new();
|
||||
let theme = Theme::from_str(&config.colors.theme);
|
||||
let mut intro_state = IntroState::new();
|
||||
let admin_panel_state = AdminPanelState::new();
|
||||
|
||||
// Fetch table structure at startup (one-time)
|
||||
// TODO: Later, consider implementing a live update for table structure changes.
|
||||
@@ -65,6 +66,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
&event_handler.command_message,
|
||||
&app_state,
|
||||
&intro_state,
|
||||
&admin_panel_state,
|
||||
);
|
||||
})?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user