Skip to content

Commit a52fe84

Browse files
committed
vmm: Optimize web UI
1 parent af2b906 commit a52fe84

4 files changed

Lines changed: 22 additions & 12 deletions

File tree

ra-rpc/src/openapi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ fn build_swagger_ui_html(spec_url: &str, cfg: &SwaggerUiConfig) -> String {
10351035
window.ui = SwaggerUIBundle({{
10361036
url: '{spec}',
10371037
dom_id: '#swagger-ui',
1038+
deepLinking: true,
10381039
presets: [
10391040
SwaggerUIBundle.presets.apis,
10401041
SwaggerUIStandalonePreset

vmm/src/console_v1.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,11 @@ <h2>Deploy a new instance</h2>
19941994
<textarea id="preLaunchScript" v-model="form.preLaunchScript" placeholder="Optional script executed before launch" rows="6"></textarea>
19951995
</div>
19961996

1997+
<div class="form-group full-width">
1998+
<label for="userConfig">User Config</label>
1999+
<textarea id="userConfig" v-model="form.user_config" placeholder="Optional user config placed at /dstack/.user-config in the CVM"></textarea>
2000+
</div>
2001+
19972002
<div class="form-group full-width" v-if="availableGpus.length > 0">
19982003
<gpu-config-editor
19992004
:available-gpus="availableGpus"
@@ -2003,11 +2008,6 @@ <h2>Deploy a new instance</h2>
20032008
/>
20042009
</div>
20052010

2006-
<div class="form-group full-width">
2007-
<label for="userConfig">User Config</label>
2008-
<textarea id="userConfig" v-model="form.user_config" placeholder="Optional user config placed at /dstack/.user-config in the CVM"></textarea>
2009-
</div>
2010-
20112011
<div class="form-group full-width">
20122012
<label>Features</label>
20132013
<div class="feature-checkboxes">

vmm/ui/src/components/CreateVmDialog.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ const CreateVmDialogComponent = {
109109
<textarea id="preLaunchScript" v-model="form.preLaunchScript" placeholder="Optional script executed before launch" rows="6"></textarea>
110110
</div>
111111
112+
<div class="form-group full-width">
113+
<label for="userConfig">User Config</label>
114+
<textarea id="userConfig" v-model="form.user_config" placeholder="Optional user config placed at /dstack/.user-config in the CVM"></textarea>
115+
</div>
116+
112117
<div class="form-group full-width" v-if="availableGpus.length > 0">
113118
<gpu-config-editor
114119
:available-gpus="availableGpus"
@@ -118,11 +123,6 @@ const CreateVmDialogComponent = {
118123
/>
119124
</div>
120125
121-
<div class="form-group full-width">
122-
<label for="userConfig">User Config</label>
123-
<textarea id="userConfig" v-model="form.user_config" placeholder="Optional user config placed at /dstack/.user-config in the CVM"></textarea>
124-
</div>
125-
126126
<div class="form-group full-width">
127127
<label>Features</label>
128128
<div class="feature-checkboxes">

vmm/ui/src/composables/useVmManager.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,19 @@ fi
391391
}
392392
}
393393

394-
function configGpu(form: { attachAllGpus: boolean; selectedGpus: string[] }): VmmTypes.IGpuConfig | undefined {
394+
function configGpu(form: { attachAllGpus: boolean; selectedGpus: string[] }, isUpdate: boolean = false): VmmTypes.IGpuConfig | undefined {
395395
if (form.attachAllGpus) {
396396
return { attach_mode: 'all' };
397397
}
398+
// For updates, always return a config when GPUs are being explicitly updated
399+
// Empty array means no GPUs should be attached
400+
if (isUpdate) {
401+
return {
402+
attach_mode: 'listed',
403+
gpus: (form.selectedGpus || []).map((slot: string) => ({ slot })),
404+
};
405+
}
406+
// For creation, return undefined if no GPUs are selected
398407
if (form.selectedGpus && form.selectedGpus.length > 0) {
399408
return {
400409
attach_mode: 'listed',
@@ -1042,7 +1051,7 @@ type CreateVmPayloadSource = {
10421051
body.user_config = updated.user_config;
10431052
body.update_ports = true;
10441053
body.ports = normalizePorts(updated.ports);
1045-
body.gpus = updateDialog.value.updateGpuConfig ? configGpu(updated) : undefined;
1054+
body.gpus = updateDialog.value.updateGpuConfig ? configGpu(updated, true) : undefined;
10461055

10471056
await vmmRpc.updateVm(body);
10481057
updateDialog.value.encryptedEnvs = [];

0 commit comments

Comments
 (0)