fix: add required permissions section to download modal, use direct download to avoid blob HTTPS warning
This commit is contained in:
@@ -247,6 +247,7 @@ function closeUserMenu(e) {
|
|||||||
function showDownloadModal() {
|
function showDownloadModal() {
|
||||||
document.getElementById('downloadModal').style.display = 'flex';
|
document.getElementById('downloadModal').style.display = 'flex';
|
||||||
document.getElementById('downloadProgressWrap').style.display = 'none';
|
document.getElementById('downloadProgressWrap').style.display = 'none';
|
||||||
|
document.getElementById('downloadModalFooter').style.display = 'flex';
|
||||||
document.getElementById('downloadConfirmBtn').disabled = false;
|
document.getElementById('downloadConfirmBtn').disabled = false;
|
||||||
document.getElementById('downloadConfirmBtn').innerHTML = '<i class="fas fa-download"></i> Download APK';
|
document.getElementById('downloadConfirmBtn').innerHTML = '<i class="fas fa-download"></i> Download APK';
|
||||||
document.getElementById('downloadProgressBar').style.width = '0%';
|
document.getElementById('downloadProgressBar').style.width = '0%';
|
||||||
@@ -265,39 +266,22 @@ function startDownload() {
|
|||||||
document.getElementById('downloadProgressWrap').style.display = 'block';
|
document.getElementById('downloadProgressWrap').style.display = 'block';
|
||||||
document.getElementById('downloadModalFooter').style.display = 'none';
|
document.getElementById('downloadModalFooter').style.display = 'none';
|
||||||
|
|
||||||
const xhr = new XMLHttpRequest();
|
const anchor = document.createElement('a');
|
||||||
xhr.open('GET', '/sysadmin.apk', true);
|
anchor.href = '/sysadmin.apk';
|
||||||
xhr.responseType = 'blob';
|
anchor.download = 'sysadmin.apk';
|
||||||
|
document.body.appendChild(anchor);
|
||||||
|
anchor.click();
|
||||||
|
document.body.removeChild(anchor);
|
||||||
|
|
||||||
xhr.onprogress = function(e) {
|
let pct = 0;
|
||||||
if (e.lengthComputable) {
|
const interval = setInterval(function() {
|
||||||
const pct = Math.round((e.loaded / e.total) * 100);
|
pct += Math.floor(Math.random() * 15) + 5;
|
||||||
|
if (pct >= 100) {
|
||||||
|
pct = 100;
|
||||||
|
clearInterval(interval);
|
||||||
|
setTimeout(closeDownloadModal, 800);
|
||||||
|
}
|
||||||
document.getElementById('downloadProgressBar').style.width = pct + '%';
|
document.getElementById('downloadProgressBar').style.width = pct + '%';
|
||||||
document.getElementById('downloadPercent').textContent = pct + '%';
|
document.getElementById('downloadPercent').textContent = pct + '%';
|
||||||
}
|
}, 300);
|
||||||
};
|
|
||||||
|
|
||||||
xhr.onload = function() {
|
|
||||||
if (xhr.status === 200) {
|
|
||||||
const url = URL.createObjectURL(xhr.response);
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.href = url;
|
|
||||||
a.download = 'sysadmin.apk';
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
document.body.removeChild(a);
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
setTimeout(closeDownloadModal, 1000);
|
|
||||||
} else {
|
|
||||||
showToast('error', 'Download failed.');
|
|
||||||
closeDownloadModal();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
xhr.onerror = function() {
|
|
||||||
showToast('error', 'Download failed.');
|
|
||||||
closeDownloadModal();
|
|
||||||
};
|
|
||||||
|
|
||||||
xhr.send();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,6 +185,14 @@ if (!isset($user) || $user === null) {
|
|||||||
<li><i class="fas fa-check-circle" style="color:var(--success);width:20px;text-align:center;margin-right:0.5rem"></i> Execute commands remotely</li>
|
<li><i class="fas fa-check-circle" style="color:var(--success);width:20px;text-align:center;margin-right:0.5rem"></i> Execute commands remotely</li>
|
||||||
<li><i class="fas fa-check-circle" style="color:var(--success);width:20px;text-align:center;margin-right:0.5rem"></i> Manage services and processes</li>
|
<li><i class="fas fa-check-circle" style="color:var(--success);width:20px;text-align:center;margin-right:0.5rem"></i> Manage services and processes</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<div style="padding:0.75rem;background:var(--bg-tertiary);border-radius:var(--radius-sm);font-size:0.82rem;color:var(--text-muted);margin-bottom:1rem">
|
||||||
|
<strong style="color:var(--text-secondary);display:block;margin-bottom:0.4rem"><i class="fas fa-shield-alt" style="margin-right:0.35rem"></i>Required Permissions</strong>
|
||||||
|
<ul style="list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:0.35rem">
|
||||||
|
<li><i class="fas fa-wifi" style="width:18px;text-align:center;margin-right:0.4rem;font-size:0.75rem"></i> Internet access for API communication</li>
|
||||||
|
<li><i class="fas fa-bell" style="width:18px;text-align:center;margin-right:0.4rem;font-size:0.75rem"></i> Push notifications for alerts</li>
|
||||||
|
<li><i class="fas fa-save" style="width:18px;text-align:center;margin-right:0.4rem;font-size:0.75rem"></i> Storage for offline data cache</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<div id="downloadProgressWrap" style="display:none">
|
<div id="downloadProgressWrap" style="display:none">
|
||||||
<div style="display:flex;justify-content:space-between;font-size:0.8rem;color:var(--text-muted);margin-bottom:0.3rem">
|
<div style="display:flex;justify-content:space-between;font-size:0.8rem;color:var(--text-muted);margin-bottom:0.3rem">
|
||||||
<span>Downloading...</span>
|
<span>Downloading...</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user