feat(ui): Symbol je Engine zeigt, ob sie eine Oberfläche mitbringt, und öffnet sie als Link (#1101)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GmHhg3Td16J38kAyDLzb39
This commit is contained in:
@ -149,6 +149,7 @@ pub(super) async fn engines_page(
|
||||
.into_iter()
|
||||
.map(|(name, info, start)| {
|
||||
let kind = art(&info.capabilities).1;
|
||||
let fenster = super::faehigkeiten::oberflaeche(&state.runtime.engine_frontend(&name), viewer.admin());
|
||||
let models: Vec<&String> = rows
|
||||
.iter()
|
||||
.filter(|(_, engine)| engine.as_deref() == Some(name.as_str()))
|
||||
@ -167,7 +168,7 @@ pub(super) async fn engines_page(
|
||||
&& state.runtime.engine_ui_port(&name).is_some() {
|
||||
format!(" <a href=\"/ui/engine/{}/\">Engine-Oberfläche</a>", name.bytes().map(|b| if b.is_ascii_alphanumeric() || b"-._~".contains(&b) { (b as char).to_string() } else { format!("%{b:02X}") }).collect::<String>())
|
||||
} else { String::new() };
|
||||
summary.push_str(&format!("<tr><th>{}<br><span class=\"muted klein\">{kind}</span></th><td>{health} · Fehler seit Start: {errors}{surface}</td><td>{}</td></tr>", esc(&name),
|
||||
summary.push_str(&format!("<tr><th>{} {fenster}<br><span class=\"muted klein\">{kind}</span></th><td>{health} · Fehler seit Start: {errors}{surface}</td><td>{}</td></tr>", esc(&name),
|
||||
if links.is_empty() { "Keine Modelle registriert.".into() } else { links }));
|
||||
let installed = match &start.executable {
|
||||
Some(path) if path.exists() => {
|
||||
@ -218,7 +219,7 @@ pub(super) async fn engines_page(
|
||||
}));
|
||||
}
|
||||
format!(
|
||||
"<section class=\"card engine\"><div class=\"zeile\"><h2>{name}</h2>\
|
||||
"<section class=\"card engine\"><div class=\"zeile\"><h2>{name}</h2>{fenster}\
|
||||
<span class=\"chip accent\">{mode}</span><span class=\"chip\">{kind}</span>{installed}\
|
||||
<span class=\"rechts muted\">{n} Modelle registriert</span></div>\
|
||||
<div class=\"chips\">{caps}</div>{start_details}</section>",
|
||||
|
||||
@ -164,6 +164,40 @@ fn titel(key: &str) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
/// Symbol „Engine bringt eine Oberfläche mit“ (Lucide `app-window`): mit Adresse als Link für Admins,
|
||||
/// sonst nur als Hinweis (die Engine hat eine Oberfläche, der Zugang fehlt oder ist nicht erlaubt).
|
||||
pub(super) fn oberflaeche(frontend: &nexus_adapter::Frontend, admin: bool) -> String {
|
||||
use nexus_adapter::Frontend;
|
||||
let (href, hinweis) = match frontend {
|
||||
Frontend::None => return String::new(),
|
||||
Frontend::Url(url) if admin => (
|
||||
Some(url.as_str()),
|
||||
"Oberfläche der Engine öffnen (eigene Adresse, ohne Anmeldung des Gateways)",
|
||||
),
|
||||
Frontend::Url(_) => (
|
||||
None,
|
||||
"Die Engine hat eine eigene Oberfläche (Zugang nur für Admins)",
|
||||
),
|
||||
Frontend::Managed => (
|
||||
None,
|
||||
"Die Engine hat eine eigene Oberfläche; der Zugang über das Gateway ist noch nicht gebaut",
|
||||
),
|
||||
};
|
||||
let svg = format!(
|
||||
"<svg class=\"fsym {} k-chat\" viewBox=\"0 0 24 24\" role=\"img\" aria-label=\"{h}\"><title>{h}</title>\
|
||||
<rect x=\"2\" y=\"4\" width=\"20\" height=\"16\" rx=\"2\"/><path d=\"M10 4v4\"/><path d=\"M2 8h20\"/><path d=\"M6 4v4\"/></svg>",
|
||||
if href.is_some() { "gemeldet" } else { "engine" },
|
||||
h = esc(hinweis),
|
||||
);
|
||||
match href {
|
||||
Some(url) => format!(
|
||||
"<a class=\"fenster\" href=\"{}\" target=\"_blank\" rel=\"noopener noreferrer\">{svg}</a>",
|
||||
esc(url)
|
||||
),
|
||||
None => format!("<span class=\"fenster\">{svg}</span>"),
|
||||
}
|
||||
}
|
||||
|
||||
fn symbol(key: &str, klasse: &str, hinweis: &str) -> String {
|
||||
format!(
|
||||
"<svg class=\"fsym {klasse} k-{key}\" viewBox=\"0 0 24 24\" role=\"img\" aria-label=\"{t}: {h}\"><title>{t}: {h}</title>{p}</svg>",
|
||||
@ -242,6 +276,21 @@ mod tests {
|
||||
assert!(engine_faehigkeiten(&c).contains("Sprachausgabe"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oberflaechen_symbol_ist_nur_fuer_admins_ein_link() {
|
||||
use nexus_adapter::Frontend;
|
||||
assert!(oberflaeche(&Frontend::None, true).is_empty());
|
||||
let url = Frontend::Url("http://192.168.12.4:8862".to_string());
|
||||
let admin = oberflaeche(&url, true);
|
||||
assert!(admin.contains("<a class=\"fenster\" href=\"http://192.168.12.4:8862\""));
|
||||
assert!(admin.contains("noopener") && admin.contains("_blank"));
|
||||
let nutzer = oberflaeche(&url, false);
|
||||
assert!(!nutzer.contains("href=") && nutzer.contains("nur für Admins"));
|
||||
// Verwaltete Engine: Symbol ja, Link nein (Weiterleitung fehlt, #1101).
|
||||
let verwaltet = oberflaeche(&Frontend::Managed, true);
|
||||
assert!(!verwaltet.contains("href=") && verwaltet.contains("noch nicht gebaut"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn icons_in_fester_reihenfolge() {
|
||||
assert!(capability_icons(&caps(false, false, false, false, false, false)).is_empty());
|
||||
|
||||
Reference in New Issue
Block a user