dashboard: writeln! instead of push_str(format!)
This commit is contained in:
parent
8cf5d72798
commit
2e2989ef8c
1 changed files with 13 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
//! Hyperhive dashboard. Lists managed containers (with deep-links to each
|
||||
//! container's web UI), pending approvals, and the manager.
|
||||
|
||||
use std::fmt::Write as _;
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
@ -62,14 +63,16 @@ fn render_containers(containers: &[String], hostname: &str) -> String {
|
|||
out.push_str("<ul>\n");
|
||||
for container in containers {
|
||||
if container == MANAGER_NAME {
|
||||
out.push_str(&format!(
|
||||
"<li><span class=\"glyph\">▓█▓▒░</span> <a href=\"http://{hostname}:{MANAGER_PORT}/\">{container}</a> <span class=\"role role-m1nd\">m1nd</span> <span class=\"meta\">:{MANAGER_PORT}</span></li>\n",
|
||||
));
|
||||
let _ = writeln!(
|
||||
out,
|
||||
"<li><span class=\"glyph\">▓█▓▒░</span> <a href=\"http://{hostname}:{MANAGER_PORT}/\">{container}</a> <span class=\"role role-m1nd\">m1nd</span> <span class=\"meta\">:{MANAGER_PORT}</span></li>",
|
||||
);
|
||||
} else if let Some(name) = container.strip_prefix(AGENT_PREFIX) {
|
||||
let port = lifecycle::agent_web_port(name);
|
||||
out.push_str(&format!(
|
||||
"<li><span class=\"glyph\">▒░▒░░</span> <a href=\"http://{hostname}:{port}/\">{name}</a> <span class=\"role role-ag3nt\">ag3nt</span> <span class=\"meta\">{container} :{port}</span></li>\n",
|
||||
));
|
||||
let _ = writeln!(
|
||||
out,
|
||||
"<li><span class=\"glyph\">▒░▒░░</span> <a href=\"http://{hostname}:{port}/\">{name}</a> <span class=\"role role-ag3nt\">ag3nt</span> <span class=\"meta\">{container} :{port}</span></li>",
|
||||
);
|
||||
}
|
||||
}
|
||||
out.push_str("</ul>\n");
|
||||
|
|
@ -87,11 +90,12 @@ fn render_approvals(approvals: &[Approval]) -> String {
|
|||
out.push_str("<ul>\n");
|
||||
for a in approvals {
|
||||
let sha_short = &a.commit_ref[..a.commit_ref.len().min(12)];
|
||||
out.push_str(&format!(
|
||||
"<li><span class=\"glyph\">→</span> <span class=\"id\">#{id}</span> <span class=\"agent\">{agent}</span> <code>{sha_short}</code> <span class=\"meta\">approve via <code>hive-c0re approve {id}</code></span></li>\n",
|
||||
let _ = writeln!(
|
||||
out,
|
||||
"<li><span class=\"glyph\">→</span> <span class=\"id\">#{id}</span> <span class=\"agent\">{agent}</span> <code>{sha_short}</code> <span class=\"meta\">approve via <code>hive-c0re approve {id}</code></span></li>",
|
||||
id = a.id,
|
||||
agent = a.agent,
|
||||
));
|
||||
);
|
||||
}
|
||||
out.push_str("</ul>\n");
|
||||
out
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue