2020-07-11 17:08:28 +00:00
|
|
|
use crate::demo::App;
|
2020-04-13 23:04:07 +00:00
|
|
|
use tui::{
|
|
|
|
backend::Backend,
|
|
|
|
layout::{Constraint, Direction, Layout, Rect},
|
2020-07-11 17:08:28 +00:00
|
|
|
style::{Color, Modifier, Style},
|
2020-04-13 23:04:07 +00:00
|
|
|
symbols,
|
2020-05-10 13:44:30 +00:00
|
|
|
text::{Span, Spans},
|
2020-04-13 23:04:07 +00:00
|
|
|
widgets::canvas::{Canvas, Line, Map, MapResolution, Rectangle},
|
|
|
|
widgets::{
|
2020-09-27 22:28:26 +00:00
|
|
|
Axis, BarChart, Block, Borders, Chart, Dataset, Gauge, LineGauge, List, ListItem,
|
|
|
|
Paragraph, Row, Sparkline, Table, Tabs, Wrap,
|
2020-04-13 23:04:07 +00:00
|
|
|
},
|
|
|
|
Frame,
|
2018-08-12 17:44:52 +00:00
|
|
|
};
|
2016-10-09 17:46:53 +00:00
|
|
|
|
2019-12-15 20:38:18 +00:00
|
|
|
pub fn draw<B: Backend>(f: &mut Frame<B>, app: &mut App) {
|
|
|
|
let chunks = Layout::default()
|
|
|
|
.constraints([Constraint::Length(3), Constraint::Min(0)].as_ref())
|
|
|
|
.split(f.size());
|
2020-05-10 13:44:30 +00:00
|
|
|
let titles = app
|
|
|
|
.tabs
|
|
|
|
.titles
|
|
|
|
.iter()
|
2020-07-11 17:08:28 +00:00
|
|
|
.map(|t| Spans::from(Span::styled(*t, Style::default().fg(Color::Green))))
|
2020-05-10 13:44:30 +00:00
|
|
|
.collect();
|
|
|
|
let tabs = Tabs::new(titles)
|
2019-12-15 20:38:18 +00:00
|
|
|
.block(Block::default().borders(Borders::ALL).title(app.title))
|
2020-07-11 17:08:28 +00:00
|
|
|
.highlight_style(Style::default().fg(Color::Yellow))
|
2019-12-15 20:38:18 +00:00
|
|
|
.select(app.tabs.index);
|
|
|
|
f.render_widget(tabs, chunks[0]);
|
|
|
|
match app.tabs.index {
|
|
|
|
0 => draw_first_tab(f, app, chunks[1]),
|
|
|
|
1 => draw_second_tab(f, app, chunks[1]),
|
|
|
|
_ => {}
|
|
|
|
};
|
2016-10-09 17:46:53 +00:00
|
|
|
}
|
|
|
|
|
2019-12-15 20:38:18 +00:00
|
|
|
fn draw_first_tab<B>(f: &mut Frame<B>, app: &mut App, area: Rect)
|
2018-11-04 17:49:30 +00:00
|
|
|
where
|
|
|
|
B: Backend,
|
|
|
|
{
|
2018-08-12 17:44:52 +00:00
|
|
|
let chunks = Layout::default()
|
|
|
|
.constraints(
|
|
|
|
[
|
2020-09-27 22:28:26 +00:00
|
|
|
Constraint::Length(9),
|
|
|
|
Constraint::Min(8),
|
2018-08-12 17:44:52 +00:00
|
|
|
Constraint::Length(7),
|
2018-09-23 18:59:51 +00:00
|
|
|
]
|
2018-12-07 15:17:33 +00:00
|
|
|
.as_ref(),
|
|
|
|
)
|
|
|
|
.split(area);
|
2018-08-12 22:27:56 +00:00
|
|
|
draw_gauges(f, app, chunks[0]);
|
|
|
|
draw_charts(f, app, chunks[1]);
|
|
|
|
draw_text(f, chunks[2]);
|
2017-05-21 09:13:24 +00:00
|
|
|
}
|
|
|
|
|
2019-12-15 20:38:18 +00:00
|
|
|
fn draw_gauges<B>(f: &mut Frame<B>, app: &mut App, area: Rect)
|
2018-11-04 17:49:30 +00:00
|
|
|
where
|
|
|
|
B: Backend,
|
|
|
|
{
|
2018-08-12 17:44:52 +00:00
|
|
|
let chunks = Layout::default()
|
2020-09-27 22:28:26 +00:00
|
|
|
.constraints(
|
|
|
|
[
|
|
|
|
Constraint::Length(2),
|
|
|
|
Constraint::Length(3),
|
|
|
|
Constraint::Length(1),
|
|
|
|
]
|
|
|
|
.as_ref(),
|
|
|
|
)
|
2018-08-12 17:44:52 +00:00
|
|
|
.margin(1)
|
2018-08-12 22:27:56 +00:00
|
|
|
.split(area);
|
2019-12-15 20:38:18 +00:00
|
|
|
let block = Block::default().borders(Borders::ALL).title("Graphs");
|
|
|
|
f.render_widget(block, area);
|
|
|
|
|
2020-04-13 23:04:07 +00:00
|
|
|
let label = format!("{:.2}%", app.progress * 100.0);
|
2019-12-15 20:38:18 +00:00
|
|
|
let gauge = Gauge::default()
|
2018-08-12 17:44:52 +00:00
|
|
|
.block(Block::default().title("Gauge:"))
|
2020-07-11 17:08:28 +00:00
|
|
|
.gauge_style(
|
2018-08-12 17:44:52 +00:00
|
|
|
Style::default()
|
|
|
|
.fg(Color::Magenta)
|
|
|
|
.bg(Color::Black)
|
2020-07-11 17:08:28 +00:00
|
|
|
.add_modifier(Modifier::ITALIC | Modifier::BOLD),
|
2018-12-07 15:17:33 +00:00
|
|
|
)
|
2020-05-10 13:44:30 +00:00
|
|
|
.label(label)
|
2020-04-13 23:04:07 +00:00
|
|
|
.ratio(app.progress);
|
2019-12-15 20:38:18 +00:00
|
|
|
f.render_widget(gauge, chunks[0]);
|
|
|
|
|
|
|
|
let sparkline = Sparkline::default()
|
2018-08-12 17:44:52 +00:00
|
|
|
.block(Block::default().title("Sparkline:"))
|
|
|
|
.style(Style::default().fg(Color::Green))
|
2020-04-13 23:04:07 +00:00
|
|
|
.data(&app.sparkline.points)
|
|
|
|
.bar_set(if app.enhanced_graphics {
|
|
|
|
symbols::bar::NINE_LEVELS
|
|
|
|
} else {
|
|
|
|
symbols::bar::THREE_LEVELS
|
|
|
|
});
|
2019-12-15 20:38:18 +00:00
|
|
|
f.render_widget(sparkline, chunks[1]);
|
2020-09-27 22:28:26 +00:00
|
|
|
|
|
|
|
let line_gauge = LineGauge::default()
|
|
|
|
.block(Block::default().title("LineGauge:"))
|
|
|
|
.gauge_style(Style::default().fg(Color::Magenta))
|
|
|
|
.line_set(if app.enhanced_graphics {
|
|
|
|
symbols::line::THICK
|
|
|
|
} else {
|
|
|
|
symbols::line::NORMAL
|
|
|
|
})
|
|
|
|
.ratio(app.progress);
|
|
|
|
f.render_widget(line_gauge, chunks[2]);
|
2017-05-21 09:13:24 +00:00
|
|
|
}
|
|
|
|
|
2019-12-15 20:38:18 +00:00
|
|
|
fn draw_charts<B>(f: &mut Frame<B>, app: &mut App, area: Rect)
|
2018-11-04 17:49:30 +00:00
|
|
|
where
|
|
|
|
B: Backend,
|
|
|
|
{
|
2018-08-12 17:44:52 +00:00
|
|
|
let constraints = if app.show_chart {
|
|
|
|
vec![Constraint::Percentage(50), Constraint::Percentage(50)]
|
2017-05-21 09:13:24 +00:00
|
|
|
} else {
|
2018-08-12 17:44:52 +00:00
|
|
|
vec![Constraint::Percentage(100)]
|
2017-05-21 09:13:24 +00:00
|
|
|
};
|
2018-08-12 17:44:52 +00:00
|
|
|
let chunks = Layout::default()
|
|
|
|
.constraints(constraints)
|
2017-05-21 09:13:24 +00:00
|
|
|
.direction(Direction::Horizontal)
|
2018-08-12 22:27:56 +00:00
|
|
|
.split(area);
|
2018-08-12 17:44:52 +00:00
|
|
|
{
|
|
|
|
let chunks = Layout::default()
|
|
|
|
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
|
2018-08-12 22:27:56 +00:00
|
|
|
.split(chunks[0]);
|
2018-08-12 17:44:52 +00:00
|
|
|
{
|
|
|
|
let chunks = Layout::default()
|
|
|
|
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
|
|
|
|
.direction(Direction::Horizontal)
|
2018-08-12 22:27:56 +00:00
|
|
|
.split(chunks[0]);
|
2019-12-15 20:38:18 +00:00
|
|
|
|
|
|
|
// Draw tasks
|
2020-05-10 13:44:30 +00:00
|
|
|
let tasks: Vec<ListItem> = app
|
|
|
|
.tasks
|
|
|
|
.items
|
|
|
|
.iter()
|
|
|
|
.map(|i| ListItem::new(vec![Spans::from(Span::raw(*i))]))
|
|
|
|
.collect();
|
2019-12-15 20:38:18 +00:00
|
|
|
let tasks = List::new(tasks)
|
2018-08-12 17:44:52 +00:00
|
|
|
.block(Block::default().borders(Borders::ALL).title("List"))
|
2020-07-11 17:08:28 +00:00
|
|
|
.highlight_style(Style::default().add_modifier(Modifier::BOLD))
|
2020-04-14 16:02:48 +00:00
|
|
|
.highlight_symbol("> ");
|
2019-12-15 20:38:18 +00:00
|
|
|
f.render_stateful_widget(tasks, chunks[0], &mut app.tasks.state);
|
|
|
|
|
|
|
|
// Draw logs
|
2020-07-11 17:08:28 +00:00
|
|
|
let info_style = Style::default().fg(Color::Blue);
|
|
|
|
let warning_style = Style::default().fg(Color::Yellow);
|
|
|
|
let error_style = Style::default().fg(Color::Magenta);
|
|
|
|
let critical_style = Style::default().fg(Color::Red);
|
2020-05-10 13:44:30 +00:00
|
|
|
let logs: Vec<ListItem> = app
|
|
|
|
.logs
|
|
|
|
.items
|
|
|
|
.iter()
|
|
|
|
.map(|&(evt, level)| {
|
|
|
|
let s = match level {
|
2018-09-07 20:24:52 +00:00
|
|
|
"ERROR" => error_style,
|
|
|
|
"CRITICAL" => critical_style,
|
|
|
|
"WARNING" => warning_style,
|
|
|
|
_ => info_style,
|
2020-05-10 13:44:30 +00:00
|
|
|
};
|
|
|
|
let content = vec![Spans::from(vec![
|
|
|
|
Span::styled(format!("{:<9}", level), s),
|
|
|
|
Span::raw(evt),
|
|
|
|
])];
|
|
|
|
ListItem::new(content)
|
|
|
|
})
|
|
|
|
.collect();
|
2019-12-15 20:38:18 +00:00
|
|
|
let logs = List::new(logs).block(Block::default().borders(Borders::ALL).title("List"));
|
|
|
|
f.render_stateful_widget(logs, chunks[1], &mut app.logs.state);
|
2018-08-12 17:44:52 +00:00
|
|
|
}
|
2019-12-15 20:38:18 +00:00
|
|
|
|
|
|
|
let barchart = BarChart::default()
|
2018-08-12 17:44:52 +00:00
|
|
|
.block(Block::default().borders(Borders::ALL).title("Bar chart"))
|
2019-02-10 21:35:44 +00:00
|
|
|
.data(&app.barchart)
|
2018-08-12 17:44:52 +00:00
|
|
|
.bar_width(3)
|
|
|
|
.bar_gap(2)
|
2020-04-13 23:04:07 +00:00
|
|
|
.bar_set(if app.enhanced_graphics {
|
|
|
|
symbols::bar::NINE_LEVELS
|
|
|
|
} else {
|
|
|
|
symbols::bar::THREE_LEVELS
|
|
|
|
})
|
2018-08-12 17:44:52 +00:00
|
|
|
.value_style(
|
|
|
|
Style::default()
|
|
|
|
.fg(Color::Black)
|
|
|
|
.bg(Color::Green)
|
2020-07-11 17:08:28 +00:00
|
|
|
.add_modifier(Modifier::ITALIC),
|
2018-12-07 15:17:33 +00:00
|
|
|
)
|
|
|
|
.label_style(Style::default().fg(Color::Yellow))
|
2020-07-11 17:08:28 +00:00
|
|
|
.bar_style(Style::default().fg(Color::Green));
|
2019-12-15 20:38:18 +00:00
|
|
|
f.render_widget(barchart, chunks[1]);
|
2018-08-12 17:44:52 +00:00
|
|
|
}
|
|
|
|
if app.show_chart {
|
2020-05-10 13:44:30 +00:00
|
|
|
let x_labels = vec![
|
|
|
|
Span::styled(
|
|
|
|
format!("{}", app.signals.window[0]),
|
2020-07-11 17:08:28 +00:00
|
|
|
Style::default().add_modifier(Modifier::BOLD),
|
2020-05-10 13:44:30 +00:00
|
|
|
),
|
|
|
|
Span::raw(format!(
|
|
|
|
"{}",
|
|
|
|
(app.signals.window[0] + app.signals.window[1]) / 2.0
|
|
|
|
)),
|
|
|
|
Span::styled(
|
|
|
|
format!("{}", app.signals.window[1]),
|
2020-07-11 17:08:28 +00:00
|
|
|
Style::default().add_modifier(Modifier::BOLD),
|
2020-05-10 13:44:30 +00:00
|
|
|
),
|
2019-12-15 20:38:18 +00:00
|
|
|
];
|
2020-05-10 13:44:30 +00:00
|
|
|
let datasets = vec![
|
2019-12-15 20:38:18 +00:00
|
|
|
Dataset::default()
|
|
|
|
.name("data2")
|
2020-04-13 23:04:07 +00:00
|
|
|
.marker(symbols::Marker::Dot)
|
2019-12-15 20:38:18 +00:00
|
|
|
.style(Style::default().fg(Color::Cyan))
|
|
|
|
.data(&app.signals.sin1.points),
|
|
|
|
Dataset::default()
|
|
|
|
.name("data3")
|
2020-04-13 23:04:07 +00:00
|
|
|
.marker(if app.enhanced_graphics {
|
|
|
|
symbols::Marker::Braille
|
|
|
|
} else {
|
|
|
|
symbols::Marker::Dot
|
|
|
|
})
|
2019-12-15 20:38:18 +00:00
|
|
|
.style(Style::default().fg(Color::Yellow))
|
|
|
|
.data(&app.signals.sin2.points),
|
|
|
|
];
|
2020-05-10 13:44:30 +00:00
|
|
|
let chart = Chart::new(datasets)
|
2018-08-12 17:44:52 +00:00
|
|
|
.block(
|
|
|
|
Block::default()
|
2020-05-10 13:44:30 +00:00
|
|
|
.title(Span::styled(
|
|
|
|
"Chart",
|
2020-07-11 17:08:28 +00:00
|
|
|
Style::default()
|
2020-05-10 13:44:30 +00:00
|
|
|
.fg(Color::Cyan)
|
2020-07-11 17:08:28 +00:00
|
|
|
.add_modifier(Modifier::BOLD),
|
2020-05-10 13:44:30 +00:00
|
|
|
))
|
2018-08-12 17:44:52 +00:00
|
|
|
.borders(Borders::ALL),
|
2018-12-07 15:17:33 +00:00
|
|
|
)
|
|
|
|
.x_axis(
|
2018-08-12 17:44:52 +00:00
|
|
|
Axis::default()
|
|
|
|
.title("X Axis")
|
|
|
|
.style(Style::default().fg(Color::Gray))
|
2019-02-10 21:35:44 +00:00
|
|
|
.bounds(app.signals.window)
|
2020-05-10 13:44:30 +00:00
|
|
|
.labels(x_labels),
|
2018-12-07 15:17:33 +00:00
|
|
|
)
|
|
|
|
.y_axis(
|
2018-08-12 17:44:52 +00:00
|
|
|
Axis::default()
|
|
|
|
.title("Y Axis")
|
|
|
|
.style(Style::default().fg(Color::Gray))
|
|
|
|
.bounds([-20.0, 20.0])
|
2020-05-10 13:44:30 +00:00
|
|
|
.labels(vec![
|
2020-07-11 17:08:28 +00:00
|
|
|
Span::styled("-20", Style::default().add_modifier(Modifier::BOLD)),
|
2020-05-10 13:44:30 +00:00
|
|
|
Span::raw("0"),
|
2020-07-11 17:08:28 +00:00
|
|
|
Span::styled("20", Style::default().add_modifier(Modifier::BOLD)),
|
2020-05-10 13:44:30 +00:00
|
|
|
]),
|
|
|
|
);
|
2019-12-15 20:38:18 +00:00
|
|
|
f.render_widget(chart, chunks[1]);
|
2018-08-12 17:44:52 +00:00
|
|
|
}
|
2016-10-09 17:46:53 +00:00
|
|
|
}
|
2016-11-07 14:57:46 +00:00
|
|
|
|
2018-11-04 17:49:30 +00:00
|
|
|
fn draw_text<B>(f: &mut Frame<B>, area: Rect)
|
|
|
|
where
|
|
|
|
B: Backend,
|
|
|
|
{
|
2020-05-10 13:44:30 +00:00
|
|
|
let text = vec![
|
|
|
|
Spans::from("This is a paragraph with several lines. You can change style your text the way you want"),
|
|
|
|
Spans::from(""),
|
|
|
|
Spans::from(vec![
|
|
|
|
Span::from("For example: "),
|
2020-07-11 17:08:28 +00:00
|
|
|
Span::styled("under", Style::default().fg(Color::Red)),
|
2020-05-10 13:44:30 +00:00
|
|
|
Span::raw(" "),
|
2020-07-11 17:08:28 +00:00
|
|
|
Span::styled("the", Style::default().fg(Color::Green)),
|
2020-05-10 13:44:30 +00:00
|
|
|
Span::raw(" "),
|
2020-07-11 17:08:28 +00:00
|
|
|
Span::styled("rainbow", Style::default().fg(Color::Blue)),
|
2020-05-10 13:44:30 +00:00
|
|
|
Span::raw("."),
|
|
|
|
]),
|
|
|
|
Spans::from(vec![
|
|
|
|
Span::raw("Oh and if you didn't "),
|
2020-07-11 17:08:28 +00:00
|
|
|
Span::styled("notice", Style::default().add_modifier(Modifier::ITALIC)),
|
2020-05-10 13:44:30 +00:00
|
|
|
Span::raw(" you can "),
|
2020-07-11 17:08:28 +00:00
|
|
|
Span::styled("automatically", Style::default().add_modifier(Modifier::BOLD)),
|
2020-05-10 13:44:30 +00:00
|
|
|
Span::raw(" "),
|
2020-07-11 17:08:28 +00:00
|
|
|
Span::styled("wrap", Style::default().add_modifier(Modifier::REVERSED)),
|
2020-05-10 13:44:30 +00:00
|
|
|
Span::raw(" your "),
|
2020-07-11 17:08:28 +00:00
|
|
|
Span::styled("text", Style::default().add_modifier(Modifier::UNDERLINED)),
|
2020-05-10 13:44:30 +00:00
|
|
|
Span::raw(".")
|
|
|
|
]),
|
|
|
|
Spans::from(
|
|
|
|
"One more thing is that it should display unicode characters: 10€"
|
|
|
|
),
|
2018-08-12 20:13:32 +00:00
|
|
|
];
|
2020-05-10 13:44:30 +00:00
|
|
|
let block = Block::default().borders(Borders::ALL).title(Span::styled(
|
|
|
|
"Footer",
|
2020-07-11 17:08:28 +00:00
|
|
|
Style::default()
|
2020-05-10 13:44:30 +00:00
|
|
|
.fg(Color::Magenta)
|
2020-07-11 17:08:28 +00:00
|
|
|
.add_modifier(Modifier::BOLD),
|
2020-05-10 13:44:30 +00:00
|
|
|
));
|
|
|
|
let paragraph = Paragraph::new(text).block(block).wrap(Wrap { trim: true });
|
2019-12-15 20:38:18 +00:00
|
|
|
f.render_widget(paragraph, area);
|
2017-05-21 09:13:24 +00:00
|
|
|
}
|
|
|
|
|
2019-12-15 20:38:18 +00:00
|
|
|
fn draw_second_tab<B>(f: &mut Frame<B>, app: &mut App, area: Rect)
|
2018-11-04 17:49:30 +00:00
|
|
|
where
|
|
|
|
B: Backend,
|
|
|
|
{
|
2018-08-12 17:44:52 +00:00
|
|
|
let chunks = Layout::default()
|
|
|
|
.constraints([Constraint::Percentage(30), Constraint::Percentage(70)].as_ref())
|
2016-11-07 14:57:46 +00:00
|
|
|
.direction(Direction::Horizontal)
|
2018-08-12 17:44:52 +00:00
|
|
|
.split(area);
|
|
|
|
let up_style = Style::default().fg(Color::Green);
|
2019-03-10 16:43:56 +00:00
|
|
|
let failure_style = Style::default()
|
|
|
|
.fg(Color::Red)
|
2020-07-11 17:08:28 +00:00
|
|
|
.add_modifier(Modifier::RAPID_BLINK | Modifier::CROSSED_OUT);
|
2018-09-23 18:59:51 +00:00
|
|
|
let rows = app.servers.iter().map(|s| {
|
|
|
|
let style = if s.status == "Up" {
|
|
|
|
up_style
|
|
|
|
} else {
|
|
|
|
failure_style
|
|
|
|
};
|
2020-11-15 21:47:00 +00:00
|
|
|
Row::new(vec![s.name, s.location, s.status]).style(style)
|
2018-09-23 18:59:51 +00:00
|
|
|
});
|
2020-11-15 21:47:00 +00:00
|
|
|
let table = Table::new(rows)
|
|
|
|
.header(
|
|
|
|
Row::new(vec!["Server", "Location", "Status"])
|
2020-11-29 21:39:39 +00:00
|
|
|
.style(Style::default().fg(Color::Yellow))
|
|
|
|
.bottom_margin(1),
|
2020-11-15 21:47:00 +00:00
|
|
|
)
|
2018-09-23 18:59:51 +00:00
|
|
|
.block(Block::default().title("Servers").borders(Borders::ALL))
|
2019-07-10 10:39:10 +00:00
|
|
|
.widths(&[
|
|
|
|
Constraint::Length(15),
|
|
|
|
Constraint::Length(15),
|
|
|
|
Constraint::Length(10),
|
2019-12-15 20:38:18 +00:00
|
|
|
]);
|
|
|
|
f.render_widget(table, chunks[0]);
|
2016-11-07 14:57:46 +00:00
|
|
|
|
2019-12-15 20:38:18 +00:00
|
|
|
let map = Canvas::default()
|
2018-08-12 17:44:52 +00:00
|
|
|
.block(Block::default().title("World").borders(Borders::ALL))
|
|
|
|
.paint(|ctx| {
|
|
|
|
ctx.draw(&Map {
|
|
|
|
color: Color::White,
|
|
|
|
resolution: MapResolution::High,
|
|
|
|
});
|
|
|
|
ctx.layer();
|
2019-01-14 20:14:57 +00:00
|
|
|
ctx.draw(&Rectangle {
|
2020-03-03 08:27:28 +00:00
|
|
|
x: 0.0,
|
|
|
|
y: 30.0,
|
|
|
|
width: 10.0,
|
|
|
|
height: 10.0,
|
2019-01-14 20:14:57 +00:00
|
|
|
color: Color::Yellow,
|
|
|
|
});
|
2018-08-12 17:44:52 +00:00
|
|
|
for (i, s1) in app.servers.iter().enumerate() {
|
|
|
|
for s2 in &app.servers[i + 1..] {
|
|
|
|
ctx.draw(&Line {
|
|
|
|
x1: s1.coords.1,
|
|
|
|
y1: s1.coords.0,
|
|
|
|
y2: s2.coords.0,
|
|
|
|
x2: s2.coords.1,
|
|
|
|
color: Color::Yellow,
|
2017-09-10 21:03:27 +00:00
|
|
|
});
|
2018-08-12 17:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for server in &app.servers {
|
|
|
|
let color = if server.status == "Up" {
|
|
|
|
Color::Green
|
|
|
|
} else {
|
|
|
|
Color::Red
|
|
|
|
};
|
|
|
|
ctx.print(server.coords.1, server.coords.0, "X", color);
|
|
|
|
}
|
2018-12-07 15:17:33 +00:00
|
|
|
})
|
2020-04-13 23:04:07 +00:00
|
|
|
.marker(if app.enhanced_graphics {
|
|
|
|
symbols::Marker::Braille
|
|
|
|
} else {
|
|
|
|
symbols::Marker::Dot
|
|
|
|
})
|
2018-12-07 15:17:33 +00:00
|
|
|
.x_bounds([-180.0, 180.0])
|
2019-12-15 20:38:18 +00:00
|
|
|
.y_bounds([-90.0, 90.0]);
|
|
|
|
f.render_widget(map, chunks[1]);
|
2016-11-07 14:57:46 +00:00
|
|
|
}
|