1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! Renders single reading on the sensors page.

use crate::templates::DATE_FORMAT;

// TODO: title should be human-readable.
markup::define! {
    Reading<'a>(reading: &'a crate::reading::Reading) {
        div."column"."is-one-quarter" {
            a[href = {format!("/sensors/{}", &reading.sensor)} ] {
                div.notification.reading.{reading.value.class()} {
                    p.title."is-6"[title = {&reading.sensor}] {
                        {&reading.sensor}
                    }
                    p.subtitle."is-7"[title = {&reading.timestamp.to_string()}] {
                        {&reading.timestamp.format(DATE_FORMAT).to_string()}
                    }
                    p."has-text-centered"."has-text-weight-bold"[title = {format!("{:?}", &reading.value)}] {
                        {&reading.value}
                    }
                }
            }
        }
    }
}