Skip to content

Commit 423bf6f

Browse files
committed
vmm-ui: Use new UI as default
1 parent be3a52c commit 423bf6f

File tree

7 files changed

+44
-15
lines changed

7 files changed

+44
-15
lines changed
Lines changed: 6 additions & 1 deletion
Large diffs are not rendered by default.

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,11 @@ type CreateVmPayloadSource = {
12241224
window.open('/api-docs/docs', '_blank', 'noopener');
12251225
}
12261226

1227+
function openLegacyUi() {
1228+
closeSystemMenu();
1229+
window.open('/v0', '_blank', 'noopener');
1230+
}
1231+
12271232
async function reloadVMs() {
12281233
try {
12291234
errorMessage.value = '';
@@ -1465,6 +1470,7 @@ type CreateVmPayloadSource = {
14651470
toggleSystemMenu,
14661471
closeSystemMenu,
14671472
openApiDocs,
1473+
openLegacyUi,
14681474
reloadVMs,
14691475
};
14701476
}

vmm/ui/src/templates/app.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ <h1 class="app-title">dstack-vmm</h1>
3737
</svg>
3838
API Docs
3939
</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>
4047
</div>
4148
</div>
4249
</div>

0 commit comments

Comments
 (0)