You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virt/web/public/cloud/rescue.js

20 lines
925 B
JavaScript

const runtimeUrl = new URL('/cloud/runtime.js', location.origin);
const assetVersion = new URL(import.meta.url).searchParams.get('v');
if (assetVersion) runtimeUrl.searchParams.set('v', assetVersion);
const {
bindPageCleanup, byId, initializeSession, openRescue, rescueAction,
selectVmByApiId, showError,
} = await import(runtimeUrl.href);
export async function initialize() {
try {
if (!await initializeSession('rescue')) return;
bindPageCleanup();
const vm = await selectVmByApiId(document.body.dataset.vmId || '');
byId('rescue-form')?.addEventListener('submit', event => { event.preventDefault(); void rescueAction('load'); });
byId('rescue-force-start')?.addEventListener('click', () => rescueAction('force-start'));
byId('rescue-exit')?.addEventListener('click', () => rescueAction('exit'));
await openRescue(vm);
} catch (error) { showError('cloud-page-error', error.message); }
}