Skip to content

Commit b303805

Browse files
committed
feat: customize site name for VMM
1 parent 9304e6d commit b303805

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

vmm/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ pub struct Config {
265265
/// The URL of the KMS server
266266
pub kms_url: String,
267267

268+
/// Node name (optional, used as prefix in UI title)
269+
#[serde(default)]
270+
pub node_name: String,
271+
268272
/// CVM configuration
269273
pub cvm: CvmConfig,
270274
/// Gateway configuration

vmm/src/console.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<head>
1111
<meta charset="UTF-8">
1212
<meta name="viewport" content="width=device-width, initial-scale=1.0">
13-
<title>dstack VM Management Console</title>
13+
<title>{{TITLE}}</title>
1414
<script src="https://unpkg.com/vue@3.0.0/dist/vue.global.js"></script>
1515
<script src="/res/x25519.js"></script>
1616
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"

vmm/src/main_routes.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,15 @@ macro_rules! file_or_include_str {
2828
}
2929

3030
#[get("/")]
31-
async fn index() -> (ContentType, String) {
32-
(ContentType::HTML, file_or_include_str!("console.html"))
31+
async fn index(app: &State<App>) -> (ContentType, String) {
32+
let html = file_or_include_str!("console.html");
33+
let title = if app.config.node_name.is_empty() {
34+
"dstack VM Management Console".to_string()
35+
} else {
36+
format!("{} - dstack VM Management Console", app.config.node_name)
37+
};
38+
let html = html.replace("{{TITLE}}", &title);
39+
(ContentType::HTML, html)
3340
}
3441

3542
#[get("/res/<path>")]

0 commit comments

Comments
 (0)