Prevent reboot dialog enter reentry
This commit is contained in:
+43
-28
@@ -66,6 +66,7 @@
|
||||
wsReconnectTimer: null,
|
||||
wsReconnectDelay: 1000,
|
||||
pushDevicesLastRefresh: 0,
|
||||
rebootRequesting: false,
|
||||
lang: 'en',
|
||||
theme: 'dark',
|
||||
};
|
||||
@@ -513,8 +514,17 @@
|
||||
if (event.target === layer) onCancel();
|
||||
};
|
||||
const onKeydown = event => {
|
||||
if (event.key === 'Escape') onCancel();
|
||||
if (event.key === 'Enter' && (document.activeElement === input || !needsInput)) onOk();
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
onCancel();
|
||||
return;
|
||||
}
|
||||
if (event.key === 'Enter' && (document.activeElement === input || !needsInput)) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
onOk();
|
||||
}
|
||||
};
|
||||
|
||||
els.customDialogTitle.textContent = options.title || t('dialogConfirm');
|
||||
@@ -1576,34 +1586,37 @@
|
||||
}
|
||||
|
||||
async function requestReboot() {
|
||||
const phrase = await window.customPrompt(t('rebootPrompt'), {
|
||||
title: t('rebootTitle'),
|
||||
okText: t('next'),
|
||||
danger: true,
|
||||
placeholder: t('rebootPhrase'),
|
||||
autocomplete: 'off',
|
||||
});
|
||||
|
||||
if (phrase === null) return;
|
||||
if (String(phrase).trim() !== t('rebootPhrase')) {
|
||||
await window.customAlert(t('rebootPhraseMismatch'), {
|
||||
title: t('rebootCanceled'),
|
||||
danger: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const password = await window.customPrompt(t('passwordPrompt'), {
|
||||
title: t('adminConfirm'),
|
||||
okText: t('rebootButton'),
|
||||
danger: true,
|
||||
inputType: 'password',
|
||||
autocomplete: 'current-password',
|
||||
});
|
||||
|
||||
if (password === null) return;
|
||||
if (state.rebootRequesting) return;
|
||||
state.rebootRequesting = true;
|
||||
|
||||
try {
|
||||
const phrase = await window.customPrompt(t('rebootPrompt'), {
|
||||
title: t('rebootTitle'),
|
||||
okText: t('next'),
|
||||
danger: true,
|
||||
placeholder: t('rebootPhrase'),
|
||||
autocomplete: 'off',
|
||||
});
|
||||
|
||||
if (phrase === null) return;
|
||||
if (String(phrase).trim() !== t('rebootPhrase')) {
|
||||
await window.customAlert(t('rebootPhraseMismatch'), {
|
||||
title: t('rebootCanceled'),
|
||||
danger: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const password = await window.customPrompt(t('passwordPrompt'), {
|
||||
title: t('adminConfirm'),
|
||||
okText: t('rebootButton'),
|
||||
danger: true,
|
||||
inputType: 'password',
|
||||
autocomplete: 'current-password',
|
||||
});
|
||||
|
||||
if (password === null) return;
|
||||
|
||||
els.rebootBtn.disabled = true;
|
||||
notice(t('rebootSending'), 'info');
|
||||
await api('reboot', {
|
||||
@@ -1621,6 +1634,8 @@
|
||||
title: t('rebootFailed'),
|
||||
danger: true,
|
||||
});
|
||||
} finally {
|
||||
state.rebootRequesting = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -319,7 +319,7 @@ html[data-theme="light"] .btn.secondary{background:#d9e2ef;color:#172033}html[da
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/app.js?v=20260607_prefs1"></script>
|
||||
<script src="/assets/app.js?v=20260617_reboot_enter1"></script>
|
||||
<script src="/assets/wakelock.js?v=20260607_prefs1"></script>
|
||||
<script src="/push_subscribe.js?v=20260607_prefs1"></script>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user