Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fbac7c18a | ||
|
|
5c4e3781fd |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "proxmox-spice-client",
|
"name": "proxmox-spice-client",
|
||||||
"version": "1.0.2",
|
"version": "1.0.4",
|
||||||
"description": "VDI SPICE Client f\u00fcr Proxmox",
|
"description": "VDI SPICE Client f\u00fcr Proxmox",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -229,6 +229,15 @@ ipcMain.handle('settings:browseViewerPath', async () => {
|
|||||||
return chosen;
|
return chosen;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Only one VM can be marked for autostart at a time — identified by
|
||||||
|
// host+vmid since the same vmid can exist on several hosts.
|
||||||
|
ipcMain.handle('settings:getAutoConnect', () => store.get('autoConnect', null));
|
||||||
|
|
||||||
|
ipcMain.handle('settings:setAutoConnect', (_e, target) => {
|
||||||
|
if (target) store.set('autoConnect', target);
|
||||||
|
else store.delete('autoConnect');
|
||||||
|
});
|
||||||
|
|
||||||
// ---------- SPICE helpers ----------
|
// ---------- SPICE helpers ----------
|
||||||
|
|
||||||
function buildVVFile(params, vmid, client) {
|
function buildVVFile(params, vmid, client) {
|
||||||
|
|||||||
@@ -17,5 +17,7 @@ contextBridge.exposeInMainWorld('api', {
|
|||||||
getViewerPath: () => ipcRenderer.invoke('settings:getViewerPath'),
|
getViewerPath: () => ipcRenderer.invoke('settings:getViewerPath'),
|
||||||
browseViewerPath: () => ipcRenderer.invoke('settings:browseViewerPath'),
|
browseViewerPath: () => ipcRenderer.invoke('settings:browseViewerPath'),
|
||||||
clearViewerPath: () => ipcRenderer.invoke('settings:clearViewerPath'),
|
clearViewerPath: () => ipcRenderer.invoke('settings:clearViewerPath'),
|
||||||
|
getAutoConnect: () => ipcRenderer.invoke('settings:getAutoConnect'),
|
||||||
|
setAutoConnect: (target) => ipcRenderer.invoke('settings:setAutoConnect', target),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -250,6 +250,20 @@ body.vms-page {
|
|||||||
|
|
||||||
.vm-info { flex: 1; min-width: 0; }
|
.vm-info { flex: 1; min-width: 0; }
|
||||||
|
|
||||||
|
.vm-autostart {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.35rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--muted);
|
||||||
|
cursor: pointer;
|
||||||
|
white-space: nowrap;
|
||||||
|
flex-shrink: 0;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vm-autostart input { cursor: pointer; }
|
||||||
|
|
||||||
.vm-name {
|
.vm-name {
|
||||||
font-size: 0.97rem;
|
font-size: 0.97rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
+49
-6
@@ -83,20 +83,37 @@ async function loadVMs() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderList(vms);
|
// Auto-connect the VM the user marked for autostart (only one at a time)
|
||||||
|
const autoConnect = await api.settings.getAutoConnect();
|
||||||
|
const autoMatch = autoConnect && vms.find(
|
||||||
|
(vm) => vm.host === autoConnect.host && String(vm.vmid) === String(autoConnect.vmid)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (autoMatch) {
|
||||||
|
showNotice(`Autostart-VM „${autoMatch.name}" markiert — verbinde …`);
|
||||||
|
await connectVM(autoMatch);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderList(vms, autoConnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadVMs();
|
loadVMs();
|
||||||
|
|
||||||
// ── Render ────────────────────────────────────────────────
|
// ── Render ────────────────────────────────────────────────
|
||||||
|
|
||||||
function renderList(vms) {
|
function renderList(vms, autoConnect) {
|
||||||
// Only show the host when there's more than one — single-host setups don't need the noise.
|
// Only show the host when there's more than one — single-host setups don't need the noise.
|
||||||
const multiHost = new Set(vms.map((vm) => vm.host)).size > 1;
|
const multiHost = new Set(vms.map((vm) => vm.host)).size > 1;
|
||||||
|
|
||||||
listEl.innerHTML = vms
|
listEl.innerHTML = vms
|
||||||
.map(
|
.map((vm) => {
|
||||||
(vm) => `
|
const isAutostart = !!(
|
||||||
|
autoConnect &&
|
||||||
|
autoConnect.host === vm.host &&
|
||||||
|
String(autoConnect.vmid) === String(vm.vmid)
|
||||||
|
);
|
||||||
|
return `
|
||||||
<div class="vm-card" data-vmid="${vm.vmid}">
|
<div class="vm-card" data-vmid="${vm.vmid}">
|
||||||
<div class="vm-info">
|
<div class="vm-info">
|
||||||
<div class="vm-name">${esc(vm.name)}</div>
|
<div class="vm-name">${esc(vm.name)}</div>
|
||||||
@@ -105,6 +122,17 @@ function renderList(vms) {
|
|||||||
Läuft · ${multiHost ? `Host: ${esc(vm.host)} · ` : ''}Node: ${esc(vm.node)} · ID: ${vm.vmid}
|
Läuft · ${multiHost ? `Host: ${esc(vm.host)} · ` : ''}Node: ${esc(vm.node)} · ID: ${vm.vmid}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<label class="vm-autostart" title="Beim Start automatisch mit dieser VM verbinden">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
class="autostart-checkbox"
|
||||||
|
data-vmid="${vm.vmid}"
|
||||||
|
data-host="${esc(vm.host)}"
|
||||||
|
data-name="${esc(vm.name)}"
|
||||||
|
${isAutostart ? 'checked' : ''}
|
||||||
|
>
|
||||||
|
Autostart
|
||||||
|
</label>
|
||||||
<button
|
<button
|
||||||
class="btn-connect"
|
class="btn-connect"
|
||||||
data-vmid="${vm.vmid}"
|
data-vmid="${vm.vmid}"
|
||||||
@@ -113,8 +141,8 @@ function renderList(vms) {
|
|||||||
data-name="${esc(vm.name)}"
|
data-name="${esc(vm.name)}"
|
||||||
>Verbinden</button>
|
>Verbinden</button>
|
||||||
</div>
|
</div>
|
||||||
`
|
`;
|
||||||
)
|
})
|
||||||
.join('');
|
.join('');
|
||||||
|
|
||||||
listEl.querySelectorAll('.btn-connect').forEach((btn) => {
|
listEl.querySelectorAll('.btn-connect').forEach((btn) => {
|
||||||
@@ -128,6 +156,21 @@ function renderList(vms) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
listEl.querySelectorAll('.autostart-checkbox').forEach((cb) => {
|
||||||
|
cb.addEventListener('change', async () => {
|
||||||
|
if (cb.checked) {
|
||||||
|
// Only one VM can be the autostart VM — uncheck any other.
|
||||||
|
listEl.querySelectorAll('.autostart-checkbox').forEach((other) => {
|
||||||
|
if (other !== cb) other.checked = false;
|
||||||
|
});
|
||||||
|
await api.settings.setAutoConnect({ host: cb.dataset.host, vmid: cb.dataset.vmid });
|
||||||
|
showNotice(`„${cb.dataset.name}" wird beim nächsten Start automatisch verbunden.`);
|
||||||
|
} else {
|
||||||
|
await api.settings.setAutoConnect(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
listEl.classList.remove('hidden');
|
listEl.classList.remove('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user