Skip to content

Commit 909fb55

Browse files
committed
0.0.1-beta-30 - move widgets to ui and cleanup help text
1 parent cfeb64c commit 909fb55

File tree

31 files changed

+153
-145
lines changed

31 files changed

+153
-145
lines changed
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
name: "Survival Guide"
2-
module_type: knowledge
3-
bus_topic: knowledge_survival
4-
template: "" # Empty template = won't show in dashboard
5-
6-
# Optional metadata
71
bindings:
8-
description: "Emergency survival procedures and protocols"
9-
version: "2.1"
10-
last_updated: "2024-01-15"
2+
description: Emergency survival procedures and protocols
3+
last_updated: 2024-01-15
4+
version: '2.1'
5+
bus_topic: knowledge_survival
6+
module_type: knowledge
7+
name: Survival Guide
8+
template: ''
Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,19 @@
1-
name: "Water Level"
2-
module_type: "monitoring"
3-
bus_topic: "a01" # ← Same topic as a01 for demo!
4-
template: "chart_card"
5-
61
bindings:
7-
a: 0 # Will receive same temperature data from a01
8-
b: 0
9-
c: 0
10-
11-
device_id: "w01"
12-
device_type: "water_sensor"
13-
firmware_version: "1.0.0"
14-
15-
display_name: "Water Level"
16-
unit_of_measure_label: "cm"
17-
18-
# Chart-specific settings
19-
chart_type: "sparkline" # ← Sparkline display
20-
21-
max_value: 100.0
22-
warn_threshold: 50.0
23-
danger_threshold: 20.0
24-
2+
a: 0.0
3+
b: 0.0
4+
c: 0.0
5+
chart_type: sparkline
6+
danger_threshold: 80.0
7+
device_id: w01
8+
device_type: water_sensor
9+
display_name: Water Level
10+
firmware_version: 1.0.0
2511
is_blinkable: false
2612
is_connected: true
27-
28-
# Internal state (managed by template)
29-
_chart_history: []
30-
31-
# NOTE: In production, this would monitor actual water level
32-
# For demo, it shows temperature data as sparkline
13+
max_value: 100.0
14+
unit_of_measure_label: cm
15+
warn_threshold: 50.0
16+
bus_topic: a01
17+
module_type: monitoring
18+
name: Water Level
19+
template: chart_card

src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::modules::{
3333
ModuleManagerView
3434
};
3535

36-
use crate::widgets::{
36+
use crate::ui::widgets::{
3737
jukebox::{
3838
actor::JukeboxActor,
3939
widget::JukeboxWidget,

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub mod app;
44
pub mod ui;
55
pub mod modules;
66
pub mod util;
7-
pub mod widgets;
87

98
#[tokio::main]
109
async fn main() -> color_eyre::Result<()> {

src/modules/overseer/config_editor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,11 +924,11 @@ impl ConfigEditor {
924924
} else {
925925
// Show abbreviated help at bottom
926926
let help = if self.is_new_module && self.fields.len() == 2 {
927-
"↑/↓: Select | ←/→: Change Type | Enter: Continue | Esc: Cancel"
927+
"←/→: Change Type | Esc: Cancel"
928928
} else if self.is_editing {
929929
"Enter: Save | Esc: Cancel"
930930
} else {
931-
"↑/↓: Select | Enter: Edit | ←/→: Toggle | s: Save | Esc: Close"
931+
" ←/→: Toggle | s: Save | Esc: Close"
932932
};
933933

934934
buf.set_string(

src/modules/overseer/handler/new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl OverseerHandler {
6464
// Now do async refresh for things that need network/async ops
6565
handler.refresh_async_data_only();
6666

67-
handler.status_message = Some("Ready - Press 's' to scan for devices".to_string());
67+
handler.status_message = Some("Ready - Press '[s]' to scan for devices".to_string());
6868

6969
handler
7070
}

src/ui/mod.rs

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ pub mod document;
22
pub mod template;
33
pub mod screens;
44
pub mod style;
5+
pub mod widgets;
6+
57
mod components;
68

79
use ratatui::{
810
buffer::Buffer,
9-
layout::{Constraint, Direction, Layout, Rect},
11+
layout::Rect,
1012
widgets::Widget,
1113
};
12-
use crate::app::{App, AppMode};
13-
use crate::ui::screens::overview::render_overview;
14+
use crate::{
15+
app::{App, AppMode},
16+
ui::screens::overview::render_overview
17+
};
1418

1519
impl Widget for &mut App {
1620
fn render(self, area: Rect, buf: &mut Buffer) {
@@ -21,23 +25,3 @@ impl Widget for &mut App {
2125
}
2226
}
2327
}
24-
25-
fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
26-
let popup_layout = Layout::default()
27-
.direction(Direction::Vertical)
28-
.constraints([
29-
Constraint::Percentage((100 - percent_y) / 2),
30-
Constraint::Percentage(percent_y),
31-
Constraint::Percentage((100 - percent_y) / 2),
32-
])
33-
.split(r);
34-
35-
Layout::default()
36-
.direction(Direction::Horizontal)
37-
.constraints([
38-
Constraint::Percentage((100 - percent_x) / 2),
39-
Constraint::Percentage(percent_x),
40-
Constraint::Percentage((100 - percent_x) / 2),
41-
])
42-
.split(popup_layout[1])[1]
43-
}

src/ui/screens/overview/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn render_overview(app: &mut App, area: Rect, buf: &mut Buffer) {
4949

5050
let is_none_focused = matches!(app.overview_focus, OverviewFocus::None);
5151
let is_jukebox_focused = matches!(app.overview_focus, OverviewFocus::Jukebox);
52-
let is_wasteland_modules_list_focused = matches!(app.overview_focus, OverviewFocus::WastelandModules);
52+
let is_wasteland_modules_list_focused = matches!(app.overview_focus, OverviewFocus::WastelandModules);
5353
let is_wasteland_modules_list_view = matches!(app.wasteland_module_manager.current_view, ModuleManagerView::ModuleListView);
5454
let is_core_modules_list_focused = matches!(app.overview_focus, OverviewFocus::CoreModules);
5555
let is_core_modules_list_view = matches!(app.core_module_manager.current_view, ModuleManagerView::ModuleListView);
@@ -87,7 +87,7 @@ pub fn render_overview(app: &mut App, area: Rect, buf: &mut Buffer) {
8787
// Render wasteland modules
8888
let mut needs_redraw = false;
8989
{
90-
let is_focused: Option<bool> = if is_wasteland_modules_list_focused {
90+
let is_focused: Option<bool> = if is_wasteland_modules_list_focused {
9191
Some(true)
9292
} else if is_none_focused {
9393
None
@@ -194,29 +194,29 @@ pub fn render_overview(app: &mut App, area: Rect, buf: &mut Buffer) {
194194
if app.wasteland_module_manager.get_modules().is_empty() {
195195
"No wasteland modules found."
196196
} else if is_wasteland_modules_list_view {
197-
"←/→: Navigate Wasteland Modules"
197+
"[←]/[→] Navigate Wasteland Modules"
198198
} else {
199-
"Esc: Back to List"
199+
"[Esc] Back to List"
200200
}
201201
};
202202

203203
let core_help_text: &str = {
204204
if is_core_modules_list_view {
205-
"←/→: Navigate Core Modules"
205+
"[←]/[→] Navigate Core Modules"
206206
} else {
207-
"Esc: Back to List"
207+
"[Esc] Back to List"
208208
}
209209
};
210210

211211
let focus_hint = match app.overview_focus {
212-
OverviewFocus::None => "Tab: Focus Wasteland Modules".to_string(),
213-
OverviewFocus::WastelandModules => format!("{} Tab: Focus Messages", wasteland_help_text),
214-
OverviewFocus::Messages => "↑/↓: Scroll Messages • Tab: Focus Core Modules".to_string(),
215-
OverviewFocus::CoreModules => format!("{} Tab: Remove Overview Focus", core_help_text),
216-
OverviewFocus::Jukebox => "Space: Play/Pause • ←/→: Skip • +/-: Volume • m: Library Tab: Focus Next".to_string(),
212+
OverviewFocus::None => "[Tab] Focus Wasteland Modules".to_string(),
213+
OverviewFocus::WastelandModules => format!("{} [Tab] Focus Messages", wasteland_help_text),
214+
OverviewFocus::Messages => "[↑]/[↓] Scroll [Tab] Focus Core Modules".to_string(),
215+
OverviewFocus::CoreModules => format!("{} [Tab] Focus Jukebox", core_help_text),
216+
OverviewFocus::Jukebox => "[ ] ⏯ [←]/[→] ⏮/⏭ [+]/[-] 🔈 [m] Library [Tab] Remove Overview Focus".to_string(),
217217
};
218218

219-
let help_text = format!("{} Enter: Select • 'r': Refresh • 'q': Quit", focus_hint);
219+
let help_text = format!("{} [Enter] Select [r] Refresh [q] Quit", focus_hint);
220220

221221
let help = Paragraph::new(help_text)
222222
.block(

0 commit comments

Comments
 (0)