add max width to column
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Johannes Heuel
2022-10-20 12:02:25 +02:00
parent ea30f57ea9
commit 126145ede7

View File

@@ -4,12 +4,12 @@ use zoidberg_lib::types::{Job, Worker};
// TODO: write nicer frontend
pub fn render(jobs: &[Job], workers: &[Worker]) -> String {
let jobs_html: String = String::from("<table class=\"table is-hoverable\">")
+ "<thead><tr><th><td>ID</td><td>command</td><td>status</td></th></tr></thead><tbody>"
+ "<thead><tr><th>ID</th><th style=\"width: 150px;\">command</th><th>status</th></tr></thead><tbody>"
+ &jobs
.iter()
.map(|j| {
format!(
"<tr><th></th><td>{}</td><td>{}</td><td>{}</td></tr>",
"<tr><td>{}</td><td>{}</td><td>{}</td></tr>",
j.id, j.cmd, j.status
)
})
@@ -18,7 +18,7 @@ pub fn render(jobs: &[Job], workers: &[Worker]) -> String {
+ "</tbody></table>";
let workers_html: String = String::from("<table class=\"table is-hoverable\">")
+ "<thead><tr><th><td>ID</td><td>last heartbeat</td></th></tr></thead><tbody>"
+ "<thead><tr><th>ID</th><th>last heartbeat</th></tr></thead><tbody>"
+ &workers
.iter()
.map(|w| {
@@ -27,12 +27,19 @@ pub fn render(jobs: &[Job], workers: &[Worker]) -> String {
} else {
String::from("")
};
format!("<tr><th></th><td>{}</td><td>{}</td></tr>", w.id, ts)
format!("<tr><td>{}</td><td>{}</td></tr>", w.id, ts)
})
.collect::<Vec<String>>()
.join("\n")
+ "</tbody></table>";
let style = r#"<style>
td {
max-width: 40vw;
word-wrap: break-word;
}
</style>"#;
let _debug_html = r#"<style>
*:not(path):not(g) {{
color: hsla(210, 100%, 100%, 0.9) !important;
@@ -56,6 +63,7 @@ pub fn render(jobs: &[Job], workers: &[Worker]) -> String {
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
{}
{}
</head>
<body>
<section class="section">
@@ -83,7 +91,7 @@ pub fn render(jobs: &[Job], workers: &[Worker]) -> String {
</body>
</html>
"#,
_debug_html, jobs_html, workers_html
style, _debug_html, jobs_html, workers_html
);
page
}