Skip to content

Commit 8eacbd9

Browse files
authored
Merge pull request #402 from Dstack-TEE/vmm-ui-v1
vmm: Use new version of UI as default
2 parents 891434d + f13816d commit 8eacbd9

File tree

8 files changed

+75
-24
lines changed

8 files changed

+75
-24
lines changed
Lines changed: 12 additions & 2 deletions
Large diffs are not rendered by default.

vmm/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async fn run_external_api(app: App, figment: Figment, api_auth: ApiToken) -> Res
9999
})
100100
}));
101101
let external_api =
102-
ra_rpc::rocket_helper::mount_openapi_docs(external_api, openapi_doc, "/rpc-docs");
102+
ra_rpc::rocket_helper::mount_openapi_docs(external_api, openapi_doc, "/api-docs");
103103

104104
let _ = external_api
105105
.launch()

vmm/src/main_routes.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,29 @@ fn replace_title(app: &App, html: &str) -> String {
3636
html.replace("{{TITLE}}", &title)
3737
}
3838

39-
#[get("/")]
40-
async fn index(app: &State<App>) -> (ContentType, String) {
41-
let html = file_or_include_str!("console.html");
39+
fn render_console(html: String, app: &State<App>) -> (ContentType, String) {
4240
let html = replace_title(app, &html);
4341
(ContentType::HTML, html)
4442
}
4543

44+
#[get("/")]
45+
async fn index(app: &State<App>) -> (ContentType, String) {
46+
render_console(file_or_include_str!("console_v1.html"), app)
47+
}
48+
49+
#[get("/v1")]
50+
async fn v1(app: &State<App>) -> (ContentType, String) {
51+
index(app).await
52+
}
53+
4654
#[get("/beta")]
4755
async fn beta(app: &State<App>) -> (ContentType, String) {
48-
let html = file_or_include_str!("console_beta.html");
49-
let html = replace_title(app, &html);
50-
(ContentType::HTML, html)
56+
index(app).await
57+
}
58+
59+
#[get("/v0")]
60+
async fn v0(app: &State<App>) -> (ContentType, String) {
61+
render_console(file_or_include_str!("console_v0.html"), app)
5162
}
5263

5364
#[get("/res/<path>")]
@@ -171,5 +182,5 @@ fn vm_logs(
171182
}
172183

173184
pub fn routes() -> Vec<Route> {
174-
routes![index, beta, res, vm_logs]
185+
routes![index, v1, beta, v0, res, vm_logs]
175186
}

vmm/ui/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ This directory contains the source for the Vue-based VM management console.
88
# Install dev dependencies (installs protobufjs CLI)
99
npm install
1010

11-
# Build the beta console once
11+
# Build the console once
1212
npm run build
1313

14-
# Build continuously (writes beta console on changes)
14+
# Build continuously (writes console_v1 on changes)
1515
npm run watch
1616
```
1717

18-
The build step generates a single-file HTML artifact at `../src/console_beta.html`
19-
which is served by `dstack-vmm` under the `/beta` path. The existing
20-
`console.html` remains untouched so both versions can coexist.
18+
The build step generates a single-file HTML artifact at `../src/console_v1.html`
19+
which is served by `dstack-vmm` under `/` and `/v1`. The previous
20+
`console_v0.html` remains untouched so the legacy UI stays available under `/v0`.
2121

2222
The UI codebase is written in TypeScript. The build pipeline performs three steps:
2323

2424
1. `scripts/build_proto.sh` (borrowed from `phala-blockchain`) uses `pbjs/pbts` to regenerate static JS bindings for `vmm_rpc.proto`.
2525
2. `tsc` transpiles `src/**/*.ts` into `build/ts/`.
26-
3. `build.mjs` bundles the transpiled output together with the runtime assets into a single HTML page `console_beta.html`.
26+
3. `build.mjs` bundles the transpiled output together with the runtime assets into a single HTML page `console_v1.html`.

vmm/ui/build.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ async function build({ watch = false } = {}) {
204204
const distFile = path.join(DIST_DIR, 'index.html');
205205
await fs.writeFile(distFile, html);
206206

207-
const targetFile = path.resolve(ROOT, '../src/console_beta.html');
207+
const targetFile = path.resolve(ROOT, '../src/console_v1.html');
208208
await fs.writeFile(targetFile, html);
209209

210210
if (watch) {

vmm/ui/src/composables/useVmManager.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,16 @@ type CreateVmPayloadSource = {
12191219
systemMenu.value.show = false;
12201220
}
12211221

1222+
function openApiDocs() {
1223+
closeSystemMenu();
1224+
window.open('/api-docs/docs', '_blank', 'noopener');
1225+
}
1226+
1227+
function openLegacyUi() {
1228+
closeSystemMenu();
1229+
window.open('/v0', '_blank', 'noopener');
1230+
}
1231+
12221232
async function reloadVMs() {
12231233
try {
12241234
errorMessage.value = '';
@@ -1307,7 +1317,7 @@ type CreateVmPayloadSource = {
13071317
}
13081318

13091319
function showLogs(id: string, channel: string) {
1310-
window.open(`/logs?id=${encodeURIComponent(id)}&follow=false&ansi=false&lines=200&ch=${channel}`, '_blank');
1320+
window.open(`/logs?id=${encodeURIComponent(id)}&follow=true&ansi=false&lines=200&ch=${channel}`, '_blank');
13111321
}
13121322

13131323
function showDashboard(vm: VmListItem) {
@@ -1459,6 +1469,8 @@ type CreateVmPayloadSource = {
14591469
systemMenu,
14601470
toggleSystemMenu,
14611471
closeSystemMenu,
1472+
openApiDocs,
1473+
openLegacyUi,
14621474
reloadVMs,
14631475
};
14641476
}

vmm/ui/src/templates/app.html

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ <h1 class="app-title">dstack-vmm</h1>
1111
<span class="version-badge">v{{ version.version }}</span>
1212
</div>
1313
<div class="header-right">
14+
<button class="btn-primary" @click="showDeployDialog()">
15+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
16+
<path d="M8 3V13M3 8H13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
17+
</svg>
18+
Deploy Instance
19+
</button>
1420
<div class="system-menu">
1521
<button class="btn-icon system-menu-btn" @click="toggleSystemMenu($event)" title="System Menu">
1622
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
@@ -24,14 +30,22 @@ <h1 class="app-title">dstack-vmm</h1>
2430
</svg>
2531
Reload VMs
2632
</button>
33+
<button class="dropdown-item" @click="openApiDocs()">
34+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
35+
<path d="M3 3h8v8H3z" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/>
36+
<path d="M5 5h4M5 7h4M5 9h2" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/>
37+
</svg>
38+
API Docs
39+
</button>
40+
<button class="dropdown-item" @click="openLegacyUi()">
41+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
42+
<path d="M3 3h8v8H3z" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/>
43+
<path d="M4.5 6.5l1.5 1.5 3.5-3.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>
44+
</svg>
45+
Legacy UI
46+
</button>
2747
</div>
2848
</div>
29-
<button class="btn-primary" @click="showDeployDialog()">
30-
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
31-
<path d="M8 3V13M3 8H13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
32-
</svg>
33-
Deploy Instance
34-
</button>
3549
</div>
3650
</div>
3751
</header>
@@ -264,6 +278,10 @@ <h1 class="app-title">dstack-vmm</h1>
264278
<span class="detail-label">Disk Type</span>
265279
<span class="detail-value">{{ vm.configuration?.disk_type || 'virtio-pci' }}</span>
266280
</div>
281+
<div class="detail-item">
282+
<span class="detail-label">TEE</span>
283+
<span class="detail-value">{{ vm.configuration?.no_tee ? 'Disabled' : 'Enabled' }}</span>
284+
</div>
267285
<div class="detail-item" v-if="vm.configuration?.gpus && vm.configuration.gpus.length > 0">
268286
<span class="detail-label">GPUs</span>
269287
<div>

0 commit comments

Comments
 (0)