summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs5
-rw-r--r--src/render/mod.rs12
2 files changed, 14 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 710fbda..36463a6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -104,10 +104,11 @@ fn unit_status(r: &mut Request) -> IronResult<Response> {
format!("Unit ({}) does not match {}",
unit_name, re))));
}
- let unit = unit::get_units(unit_name);
+ let ref unit = itry!(unit::get_units(unit_name))[0];
let log = itry!(journal::get_log(unit_name, 15));
Ok(Response::with((status::Ok,
- format!("{:?}\n{}", unit, log))))
+ Header(ContentType::html()),
+ render::unit_status(&unit, &log))))
}
fn main() {
diff --git a/src/render/mod.rs b/src/render/mod.rs
index f7ad1d1..75fd9b5 100644
--- a/src/render/mod.rs
+++ b/src/render/mod.rs
@@ -9,7 +9,7 @@ fn render_in_page<'a>(content: Box<RenderBox + 'a>) -> String {
html {
head {
title: "Systemhttpd";
- link(rel="stylesheet", type="text/css", href="static/main.css");
+ link(rel="stylesheet", type="text/css", href="/static/main.css");
}
body {
: content
@@ -65,3 +65,13 @@ pub fn system_status(sections: &[(String, Vec<&unit::Unit>)]) -> String {
};
render_in_page(b)
}
+
+pub fn unit_status(unit: &unit::Unit, log: &str) -> String {
+ render_in_page(box_html! {
+ h1 { :&unit.name }
+ p { : format_args!("{} ({})", &unit.active_state, &unit.sub_state) }
+ pre {
+ : log
+ }
+ })
+}