Added ${esc(st.newUser.email)}, but the invitation couldn't be sent:
${esc(st.newUser.inviteError)}
Fix the email settings, then use Resend invitation in the list below.
` : st.newUser?.invited ? `
Added ${esc(st.newUser.email)} and sent the invitation. The link is valid for 3 days.
` : st.newUser ? `
Added ${esc(st.newUser.email)}.
${st.newUser.password ? `Their password is ${esc(st.newUser.password)}. Copy it now and send it securely; it won't be shown again.` : ''}
The private network${esc(plan.network.vnet)} (${esc(plan.network.subnet)}) is removed from Proxmox${plan.othersInNetwork.length ? ', unless you keep it (see below)' : ''}.
${others.length === 1 ? 'This server is' : 'These servers are'} still in the customer's network
but no longer theirs:
${others.map((g) => `
${g.vmid} ${esc(g.name)}
${g.owner ? `assigned to ${esc(g.owner)}` : 'not assigned'}
`).join('')}
They are not deleted. Proxmox can't remove a network that is in use, so either keep the
network, or first move ${others.length === 1 ? 'it' : 'them'} to another network (Hardware, Network Device).
`);
}
const keepNetWrap = document.getElementById('du-keepnet-wrap');
keepNetWrap.hidden = !others.length;
form.keepNetwork.checked = others.length > 0;
const keepWrap = document.getElementById('du-keep-wrap');
keepWrap.hidden = !assigned.length;
form.keepAssigned.checked = false;
form.confirm.value = '';
const ok = document.getElementById('du-ok');
ok.disabled = true;
const matches = () => form.confirm.value.trim().toLowerCase() === user.email.toLowerCase();
form.confirm.oninput = () => { ok.disabled = !matches(); };
form.confirm.onkeydown = (e) => {
if (e.key === 'Enter') { e.preventDefault(); if (matches()) dialog.close('ok'); }
};
dialog.returnValue = '';
dialog.showModal();
form.confirm.focus();
const confirmed = await new Promise((resolve) => {
dialog.addEventListener('close', () => resolve(dialog.returnValue === 'ok' && matches()), { once: true });
});
if (!confirmed) return;
try {
const q = new URLSearchParams();
if (form.keepAssigned.checked) q.set('keepAssigned', 'true');
if (form.keepNetwork.checked && !keepNetWrap.hidden) q.set('keepNetwork', 'true');
const qs = q.toString();
await api(`/api/admin/users/${user.id}${qs ? `?${qs}` : ''}`, { method: 'DELETE' });
toast(`Deleting ${user.email}`);
st.users = await api('/api/admin/users');
renderUsers();
watchDeletions();
} catch (err) { fail(err); }
}
/** Require / not require 2FA for a user, or reset it (lost phone). */
async function editTwoFactor(user) {
const dialog = document.getElementById('twofa-admin');
const form = document.getElementById('twofa-admin-form');
document.getElementById('ta-title').textContent = `Sign-in for ${user.email}`;
document.getElementById('ta-state').innerHTML = user.totpEnabled
? 'On The user has set it up.'
: user.totpRequired
? 'Required The user sets it up at the next sign-in.'
: 'Off The user signs in with password only.';
form.required.checked = user.totpRequired;
document.getElementById('ta-reset-box').hidden = !user.totpEnabled;
const pkBox = document.getElementById('ta-passkey-box');
pkBox.hidden = !user.passkeyCount;
document.getElementById('ta-passkey-count').textContent = `${user.passkeyCount} passkey${user.passkeyCount === 1 ? '' : 's'}`;
document.getElementById('ta-remove-passkeys').onclick = async () => {
if (!(await confirmAction(`Remove all passkeys of ${user.email}? They then sign in with password or single sign-on and can add new passkeys.`, 'Remove'))) return;
try {
await api(`/api/admin/users/${user.id}`, { method: 'PATCH', body: { removePasskeys: true } });
toast(`Passkeys removed for ${user.email}`);
dialog.close('reset');
} catch (err) { fail(err); }
};
const ssoBox = document.getElementById('ta-sso-box');
ssoBox.hidden = !user.ssoLinked;
document.getElementById('ta-sso-issuer').textContent = user.ssoIssuer ?? '';
document.getElementById('ta-unlink').onclick = async () => {
if (!(await confirmAction(`Unlink ${user.email} from single sign-on? The next single sign-on links the account again by verified email, or is refused.`, 'Unlink'))) return;
try {
await api(`/api/admin/users/${user.id}`, { method: 'PATCH', body: { unlinkSso: true } });
toast(`${user.email} unlinked from single sign-on`);
dialog.close('reset');
} catch (err) { fail(err); }
};
document.getElementById('ta-reset').onclick = async () => {
if (!(await confirmAction(`Reset two-factor authentication for ${user.email}? Their authenticator app and recovery codes stop working.`, 'Reset'))) return;
try {
await api(`/api/admin/users/${user.id}`, { method: 'PATCH', body: { resetTotp: true } });
toast(`Two-factor authentication reset for ${user.email}`);
dialog.close('reset');
} catch (err) { fail(err); }
};
dialog.returnValue = '';
dialog.showModal();
const result = await new Promise((resolve) => dialog.addEventListener('close', () => resolve(dialog.returnValue), { once: true }));
if (result === 'ok' && form.required.checked !== user.totpRequired) {
try {
await api(`/api/admin/users/${user.id}`, { method: 'PATCH', body: { totpRequired: form.required.checked } });
toast(form.required.checked ? `Two-factor authentication is now required for ${user.email}` : `Two-factor authentication is optional for ${user.email}`);
} catch (err) { fail(err); }
}
if (result === 'ok' || result === 'reset') {
st.users = await api('/api/admin/users');
renderUsers();
}
}
async function createUser(form) {
const email = form.email.value.trim();
const invite = form.invite.checked;
const password = invite ? undefined : form.password.value;
const isAdmin = form.isAdmin.checked;
const requireTotp = form.requireTotp.checked;
const generated = !invite && form.dataset.generated === password;
const button = form.querySelector('.btn.primary');
button.disabled = true;
try {
const r = await api('/api/admin/users', { method: 'POST', body: { email, password, isAdmin, requireTotp, invite } });
st.newUser = { email, password: generated ? password : null, invited: r.invited, inviteError: r.inviteError };
st.users = await api('/api/admin/users');
renderUsers();
} catch (err) {
fail(err);
button.disabled = false;
}
}
// ---- limits -----------------------------------------------------------
function editLimits(user) {
const dialog = document.getElementById('limits');
const form = document.getElementById('limits-form');
document.getElementById('limits-title').textContent = `Limits and expiry for ${user.email}`;
form.expiryMode.value = user.expiryMode ?? '';
form.expiryDays.value = user.expiryDays ?? 14;
form.expiryDate.value = user.expiryDate ?? '';
form.expirySelfExtend.checked = !!user.expirySelfExtend;
const showRule = () => {
document.getElementById('lim-exp-days').hidden = form.expiryMode.value !== 'after_creation';
document.getElementById('lim-exp-date').hidden = form.expiryMode.value !== 'fixed_date';
document.getElementById('lim-exp-extend').hidden = !form.expiryMode.value;
};
form.expiryMode.onchange = showRule;
showRule();
// Sensible starting values the first time self-service is switched on
const fresh = !user.canCreate && !user.maxServers && !user.maxCores;
form.canCreate.checked = user.canCreate;
form.maxServers.value = fresh ? 2 : user.maxServers;
form.maxCores.value = fresh ? 4 : user.maxCores;
form.maxMemoryGb.value = fresh ? 8 : +(user.maxMemoryMb / 1024).toFixed(1);
form.maxDiskGb.value = fresh ? 100 : user.maxDiskGb;
form.maxBackups.value = user.maxBackups ?? '';
const u = user.usage;
document.getElementById('limits-usage').textContent = u
? `In use now: ${u.servers} servers, ${u.cores} cores, ${gb(u.memoryMb)} memory, ${u.diskGb} GB disk.`
: `${user.servers} server${user.servers === 1 ? '' : 's'} assigned.`;
dialog.returnValue = '';
dialog.showModal();
return new Promise((resolve) => {
dialog.addEventListener('close', async () => {
if (dialog.returnValue !== 'ok') return resolve(false);
try {
await api(`/api/admin/users/${user.id}`, {
method: 'PATCH',
body: {
canCreate: form.canCreate.checked,
maxServers: Number(form.maxServers.value),
maxCores: Number(form.maxCores.value),
maxMemoryMb: Math.round(Number(form.maxMemoryGb.value) * 1024),
maxDiskGb: Number(form.maxDiskGb.value),
expiryMode: form.expiryMode.value || null,
...(form.expiryMode.value === 'after_creation' ? { expiryDays: Number(form.expiryDays.value) } : {}),
...(form.expiryMode.value === 'fixed_date' ? { expiryDate: form.expiryDate.value } : {}),
expirySelfExtend: form.expirySelfExtend.checked,
maxBackups: form.maxBackups.value === '' ? null : Number(form.maxBackups.value),
},
});
toast(`Limits and expiry saved for ${user.email}`);
resolve(true);
} catch (err) {
fail(err);
resolve(false);
}
}, { once: true });
});
}
// ---- templates --------------------------------------------------------
function renderTemplates() {
const body = root.querySelector('#admin-body');
if (!st.templates.length) {
body.innerHTML = `
No templates in the cluster
Customers create servers by cloning a Proxmox template. Prepare a VM with cloud-init,
convert it to a template in Proxmox and add it to the panel's pool; it then appears here.
`;
return;
}
body.innerHTML = `
Customers who may create servers can choose from the templates offered here.
Linux templates are set up with cloud-init, Windows templates through the QEMU guest agent.
ID
Template in Proxmox
Offered
Name shown to customers
Setup
Target storage
User
Network (cloud-init)
Save
${st.templates.map((t) => `
${t.vmid}
${esc(t.name)} ${esc(t.node)}
`).join('')}
Cloud-init: the customer chooses the user name (User is only the suggestion); Network is the
ipconfig0 value, e.g. ip=dhcp.
Guest agent (Windows): the template must be sysprep'd with the QEMU guest agent installed and enabled;
the panel sets the password of User (default Administrator) and the computer name.
`;
}
async function saveTemplate(row) {
const vmid = Number(row.dataset.template);
const field = (f) => row.querySelector(`[data-f="${f}"]`);
const offered = field('offered').checked;
const label = field('label').value.trim();
try {
if (!offered) {
await api(`/api/admin/templates/${vmid}`, { method: 'DELETE' });
toast(`Template ${vmid} is not offered`);
} else {
if (!label) {
field('label').focus();
return toast('Give the template a name customers will recognise', 'error');
}
await api(`/api/admin/templates/${vmid}`, {
method: 'PUT',
body: {
label,
storage: field('storage').value,
ciUser: field('ciUser').value.trim(),
ipconfig: field('ipconfig').value.trim(),
setup: field('setup').value,
},
});
toast(`${label} is offered to customers`);
}
const t = st.templates.find((x) => x.vmid === vmid);
Object.assign(t, { offered, label });
} catch (err) { fail(err); }
}
// ---- VPN --------------------------------------------------------------
function tailscaleSection() {
const ts = st.vpn.tailscale;
if (!ts?.enabled) return '';
const stateWord = { connected: 'Connected', installing: 'Connecting…', disconnecting: 'Disconnecting…', failed: 'Failed' };
const pill = { connected: 'pill-running', installing: 'pill-busy', disconnecting: 'pill-busy', failed: 'pill-failed' };
return `
Tailscale
Servers customers connected to their own tailnet. The panel doesn't
see or manage the customers' Tailscale accounts.
${ts.servers.length ? `
Customer
Server
Mode
Tailscale address
State
${ts.servers.map((x) => `
${esc(x.email)}
${x.vmid} ${esc(x.label ?? x.hostname ?? '')}
${x.mode === 'gateway' ? 'Gateway to private network' : 'Just this server'}
${esc(x.ip ?? '–')}
${stateWord[x.state] ?? esc(x.state)}
`).join('')}
` : '
No server is connected to Tailscale yet.
'}`;
}
function renderVpn() {
const { status, devices } = st.vpn;
const body = root.querySelector('#admin-body');
if (!status.enabled) {
body.innerHTML = `
WireGuard VPN is switched off
Set up the WireGuard gateway VM and set VPN_ENABLED=true,
VPN_GATEWAY_VMID and VPN_ENDPOINT in the panel's
.env. The documentation (Networking → WireGuard VPN) has the steps.
No VPN devices yet. Customers add them under “VPN access”.
'}
${tailscaleSection()}`;
}
// ---- expiry ---------------------------------------------------------------
const day = (iso) => new Date(iso).toLocaleDateString(undefined, { day: 'numeric', month: 'short', year: 'numeric' });
function expiryTag(v) {
const e = v.expiry;
if (!e) return '';
if (e.expired) {
return e.deleteAt
? `Expired · deleted ${esc(day(e.deleteAt))}`
: `Expired · your decision`;
}
return `Expires ${esc(day(e.expiresAt))}`;
}
/** Set, extend or remove a server's expiry. */
async function editServerExpiry(vm) {
const dialog = document.getElementById('expiry-dialog');
const form = document.getElementById('expiry-form');
document.getElementById('ex-title').textContent = `Expiry of ${vm.label || vm.name} (${vm.vmid})`;
const e = vm.expiry;
document.getElementById('ex-state').textContent = !e ? 'This server does not expire.'
: e.expired ? `Expired on ${day(e.expiredAt)}${e.deleteAt ? `; deleted on ${day(e.deleteAt)} unless extended` : '; assigned by you, so it is not deleted automatically'}.`
: `Expires on ${day(e.expiresAt)}.`;
form.date.value = e && !e.expired ? e.expiresAt.slice(0, 10) : '';
form.date.min = new Date(Date.now() + 86_400_000).toISOString().slice(0, 10);
document.getElementById('ex-remove').hidden = !e;
form.date.onkeydown = (ev) => { if (ev.key === 'Enter') { ev.preventDefault(); dialog.close('ok'); } };
dialog.returnValue = '';
dialog.showModal();
const result = await new Promise((resolve) => dialog.addEventListener('close', () => resolve(dialog.returnValue), { once: true }));
let body = null;
if (result === 'ok') body = form.date.value ? { expiresAt: form.date.value } : null;
if (result === 'plus7') body = { extendDays: 7 };
if (result === 'plus30') body = { extendDays: 30 };
if (result === 'remove') body = { expiresAt: null };
if (!body) return;
try {
const r = await api(`/api/admin/vms/${vm.vmid}/expiry`, { method: 'PUT', body });
toast(r.expiry ? `${vm.label || vm.name} now expires on ${day(r.expiry.expiresAt)}` : `${vm.label || vm.name} no longer expires`);
load({ quiet: true });
} catch (err) { fail(err); }
}
function expiryRuleText(u) {
if (u.expiryMode === 'after_creation') return `Servers expire ${u.expiryDays} days after creation`;
if (u.expiryMode === 'fixed_date') return `Servers expire on ${day(`${u.expiryDate}T12:00:00`)}`;
return '';
}
// ---- settings: email ----------------------------------------------------
function renderSettings() {
const e = st.email;
const me = getMe();
const ap = st.appearance;
root.querySelector('#admin-body').innerHTML = `
Appearance
The color scheme for everyone: this admin interface, the customer portal, the sign-in pages
and emails. Each scheme has a light and a dark variant; the panel follows each device's light/dark setting.
${ap.schemes.map((sc) => `
`).join('')}
Email ${e.configured ? 'Configured' : 'Not set up'}
Used to send invitations to new users. Settings are stored in the panel's database; the
password is kept encrypted and never shown again.
Windows updates
Customers can install Windows updates on their Windows servers from the server page
(Updates tab): security or all quality updates, optionally with a snapshot first and automatic restarts.
Feature upgrades and previews are never installed.
Backups
Customers back up their servers, restore them and — with a Proxmox Backup Server — download
single files from a backup (Backups tab on the server page). Backups go to the storage chosen here; the
panel uses the Proxmox API, so it never needs the backup server's credentials. Backups of your own Proxmox
backup jobs are shown to the customer too (from the day the server became theirs), but can't be deleted by them.
Server expiry
For customers or servers you give an expiry date (customer: Limits; server: the
clock button in Servers). Reminders by email, stopped at expiry, deleted after the grace period —
only servers the customer created; servers you assigned are only stopped.
${e.configured ? '' : '
Email is not set up: customers get no reminders, and nothing is deleted automatically (servers are only stopped).
'}
Send a test email
Checks the settings end to end: connection, encryption, sign-in and delivery.
`;
warnPlain();
}
// Plain SMTP with a password sends that password unencrypted
function warnPlain() {
const f = root.querySelector('#email-form');
if (!f) return;
root.querySelector('#email-warning').textContent = f.security.value === 'none' && f.username.value
? 'Without encryption the SMTP password travels unencrypted. Use this only for a mail relay inside your own network.'
: '';
}
root.addEventListener('input', (ev) => { if (ev.target.closest('#email-form')) warnPlain(); });
root.addEventListener('change', (ev) => {
const f = ev.target.closest('#email-form');
if (!f || ev.target.name !== 'security') return;
// suggest the usual port when it's still one of the defaults
const usual = { starttls: 587, tls: 465, none: 25 };
if ([587, 465, 25].includes(Number(f.port.value))) f.port.value = usual[f.security.value];
warnPlain();
});
root.addEventListener('submit', async (ev) => {
if (ev.target.id === 'email-form') {
ev.preventDefault();
const f = ev.target;
if (!f.reportValidity()) return;
const body = {
host: f.host.value.trim(),
port: Number(f.port.value),
security: f.security.value,
username: f.username.value.trim(),
fromName: f.fromName.value.trim(),
fromAddress: f.fromAddress.value.trim(),
panelUrl: f.panelUrl.value.trim(),
};
if (f.clearPassword?.checked) body.password = '';
else if (f.password.value) body.password = f.password.value;
try {
st.email = await api('/api/admin/settings/email', { method: 'PUT', body });
toast('Email settings saved');
renderSettings();
} catch (err) { fail(err); }
}
if (ev.target.id === 'backup-settings') {
ev.preventDefault();
const f = ev.target;
if (!f.reportValidity()) return;
try {
st.backups.settings = await api('/api/admin/settings/backups', {
method: 'PUT',
body: {
enabled: f.enabled.checked, storage: f.storage.value, maxPerServer: Number(f.maxPerServer.value),
schedules: f.schedules.checked, keepAfterDelete: f.keepAfterDelete.checked,
},
});
toast(st.backups.settings.enabled ? 'Backups are on for customers' : 'Backup settings saved');
renderSettings();
} catch (err) { fail(err); }
return;
}
if (ev.target.id === 'expiry-settings') {
ev.preventDefault();
const f = ev.target;
if (!f.reportValidity()) return;
try {
st.expiry = await api('/api/admin/settings/expiry', {
method: 'PUT',
body: {
reminderDays: f.reminderDays.value.split(/[ ,]+/).filter(Boolean).map(Number),
graceDays: Number(f.graceDays.value),
selfExtendDays: Number(f.selfExtendDays.value),
pauseDeletions: f.pauseDeletions.checked,
adminSummary: f.adminSummary.checked,
},
});
toast('Expiry settings saved');
renderSettings();
} catch (err) { fail(err); }
return;
}
if (ev.target.id === 'email-test') {
ev.preventDefault();
const f = ev.target;
if (!f.reportValidity()) return;
const b = f.querySelector('button');
b.disabled = true;
b.textContent = 'Sending…';
try {
await api('/api/admin/settings/email/test', { method: 'POST', body: { to: f.to.value.trim() } });
toast(`Test email sent to ${f.to.value.trim()}`);
} catch (err) { fail(err); }
b.disabled = false;
b.textContent = 'Send test email';
}
});
// ---- setup check ----------------------------------------------------------
const CHECK_MARK = { ok: '✓', warn: '!', error: '✕', info: 'i', skipped: '–' };
const CHECK_WORD = { ok: 'OK', warn: 'Warning', error: 'Error', info: 'Note', skipped: 'Not checked' };
function setupProblemCount(result) {
return result ? (result.summary.error ?? 0) + (result.summary.warn ?? 0) : 0;
}
function updateSetupBadge(result) {
st.setupProblems = setupProblemCount(result);
const tab = root.querySelector('[data-admin-tab="setup"]');
if (!tab) return;
tab.querySelector('.tab-count')?.remove();
if (st.setupProblems) tab.insertAdjacentHTML('beforeend', ` ${st.setupProblems}`);
}
async function runSetupCheck() {
st.setupRunning = true;
if (st.tab === 'setup') renderSetupCheck();
try {
st.setup = await api('/api/admin/setup-check/run', { method: 'POST' });
updateSetupBadge(st.setup.result);
} catch (err) {
fail(err);
} finally {
st.setupRunning = false;
if (st.tab === 'setup') renderSetupCheck();
}
}
function renderSetupCheck() {
const body = root.querySelector('#admin-body');
const data = st.setup ?? {};
const r = data.result;
if (!r) {
body.innerHTML = `
${st.setupRunning
? ' Checking Proxmox and the panel\'s configuration… this takes a few seconds.'
: 'No check has run yet.'}
The setup check only reads: it never changes anything in Proxmox. Commands under
“How to fix” are run by you on a Proxmox node (or the panel host).
`;
}
// ---- about --------------------------------------------------------------
function renderAbout() {
const a = st.about;
const u = a.update ?? {};
const date = (d) => (d ? new Date(d).toLocaleString() : '–');
const uptime = (sec) => {
const d = Math.floor(sec / 86400), h = Math.floor((sec % 86400) / 3600), m = Math.floor((sec % 3600) / 60);
return d ? `${d} d ${h} h` : h ? `${h} h ${m} min` : `${m} min`;
};
const ext = (href, text) => `${text}`;
const status = !u.checked
? `
Couldn't check for updates. ${esc(u.reason ?? '')}
`
: u.updateAvailable
? `
Version ${esc(u.latest.version)} is available${u.latest.publishedAt ? `, released ${esc(new Date(u.latest.publishedAt).toLocaleDateString())}` : ''}.
${ext(u.latest.url, "See what's new")}.
Portainer: Stacks, your stack, Update the stack with
Re-pull image and redeploy switched on.
UGREEN Docker app: Project, your project, redeploy it (it pulls the image again).
Command line:docker compose pull && docker compose up -d
If you pinned a release in PANEL_IMAGE, change the version
there first. Your data stays in the volume; database changes are applied automatically at start.