Fix: macOS runner, scan hang, export sources, profile role filter/badge
This commit is contained in:
1 parent
9e940cd60a
commit
6e0aab788a
8 files changed
+119
-23
No files matched your search
+26
-5
@@ -335,7 +335,8 @@ function _openEditorForProfile(profile) {
|
||||
: (u.platform || 'm365') === 'google' ? '<span style="font-size:9px;padding:1px 5px;border-radius:10px;background:#EAF3DE;color:#3B6D11;font-weight:500">GWS</span>'
|
||||
: '<span style="font-size:9px;padding:1px 5px;border-radius:10px;background:#E6F1FB;color:#185FA5;font-weight:500">M365</span>';
|
||||
const roleBadge = u.userRole === 'student' ? t('role_student','Elev') : u.userRole === 'staff' ? t('role_staff','Ansat') : t('role_other','Anden');
|
||||
return `<label class="pmgmt-acct-row" data-uid="${_esc(u.id)}"><input type="checkbox" ${checked} data-uid="${_esc(u.id)}"><span style="flex:1;color:var(--color-text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${_esc(u.displayName)}</span>${platBadge}<span style="font-size:9px;padding:1px 5px;border-radius:10px;background:#D3D1C7;color:#444441">${roleBadge}</span></label>`;
|
||||
const roleOverrideStyle = u.roleOverride ? 'color:var(--color-text-info);outline:1px solid var(--color-border-info);' : '';
|
||||
return `<label class="pmgmt-acct-row" data-uid="${_esc(u.id)}" data-role="${_esc(u.userRole || 'other')}"><input type="checkbox" ${checked} data-uid="${_esc(u.id)}"><span style="flex:1;color:var(--color-text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${_esc(u.displayName)}</span>${platBadge}<button type="button" class="pmgmt-role-badge" data-uid="${_esc(u.id)}" onclick="_pmgmtCycleRole(this.getAttribute('data-uid'),event)" style="font-size:9px;padding:1px 5px;border-radius:10px;background:#D3D1C7;border:none;cursor:pointer;${roleOverrideStyle}">${roleBadge}</button></label>`;
|
||||
}).join('');
|
||||
|
||||
body.innerHTML = `
|
||||
@@ -503,6 +504,26 @@ function _pmgmtCloseEditor() {
|
||||
closeProfileMgmt();
|
||||
}
|
||||
|
||||
async function _pmgmtCycleRole(uid, event) {
|
||||
event.stopPropagation();
|
||||
if (typeof cycleUserRole !== 'function') return;
|
||||
await cycleUserRole(uid);
|
||||
// Refresh the badge inside the profile modal to reflect the new role
|
||||
const u = S._allUsers.find(function(u){ return u.id === uid; });
|
||||
if (!u) return;
|
||||
const lbl = document.querySelector('#pmgmtAcctList label[data-uid="' + uid.replace(/"/g, '\\"') + '"]');
|
||||
if (!lbl) return;
|
||||
const badge = lbl.querySelector('.pmgmt-role-badge');
|
||||
if (!badge) return;
|
||||
const roleText = u.userRole === 'student' ? t('role_student','Elev')
|
||||
: u.userRole === 'staff' ? t('role_staff','Ansat')
|
||||
: t('role_other','Anden');
|
||||
badge.textContent = roleText;
|
||||
lbl.dataset.role = u.userRole || 'other';
|
||||
badge.style.color = u.roleOverride ? 'var(--color-text-info)' : '';
|
||||
badge.style.outline = u.roleOverride ? '1px solid var(--color-border-info)' : '';
|
||||
}
|
||||
|
||||
function _pmgmtSelectAllAccounts(checked) {
|
||||
document.querySelectorAll('#pmgmtAcctList label input[type=checkbox]').forEach(function(cb) {
|
||||
if (cb.closest('label').style.display !== 'none') cb.checked = checked;
|
||||
@@ -541,10 +562,9 @@ function _pmgmtAddManual() {
|
||||
function _pmgmtFilterAccounts(q) {
|
||||
q = (q || '').toLowerCase();
|
||||
document.querySelectorAll('#pmgmtAcctList label').forEach(function(lbl) {
|
||||
var name = (lbl.querySelector('span') || {}).textContent || '';
|
||||
var uid = lbl.querySelector('input')?.dataset?.uid || '';
|
||||
var user = S._allUsers.find(u => u.id === uid);
|
||||
var roleOk = !_pmgmtRoleActive || (user && user.userRole === _pmgmtRoleActive);
|
||||
var name = (lbl.querySelector('span') || {}).textContent || '';
|
||||
var role = lbl.dataset.role || 'other';
|
||||
var roleOk = !_pmgmtRoleActive || role === _pmgmtRoleActive;
|
||||
var nameOk = !q || name.toLowerCase().includes(q);
|
||||
lbl.style.display = (roleOk && nameOk) ? '' : 'none';
|
||||
});
|
||||
@@ -698,6 +718,7 @@ window._peSetYear = _peSetYear;
|
||||
window._renderEditorSources = _renderEditorSources;
|
||||
window._pmgmtNewProfile = _pmgmtNewProfile;
|
||||
window._pmgmtCloseEditor = _pmgmtCloseEditor;
|
||||
window._pmgmtCycleRole = _pmgmtCycleRole;
|
||||
window._pmgmtSelectAllAccounts = _pmgmtSelectAllAccounts;
|
||||
window._pmgmtRoleFilter = _pmgmtRoleFilter;
|
||||
window._pmgmtAddManual = _pmgmtAddManual;
|
||||
|
||||
+15
-7
@@ -363,17 +363,17 @@ function _attachScanListeners(source) {
|
||||
source.addEventListener('scan_done', function(e) {
|
||||
var d = JSON.parse(e.data);
|
||||
console.log('[SSE] scan_done:', d);
|
||||
// Only close SSE if the user started this scan via the Scan button.
|
||||
// For scheduled scans, keep the SSE connection alive so future
|
||||
// scheduler events are still received.
|
||||
if (S._userStartedScan) {
|
||||
S._userStartedScan = false;
|
||||
if (S.es) { S.es.close(); S.es = null; }
|
||||
}
|
||||
S._srcPct.m365 = 100;
|
||||
S._m365ScanRunning = false;
|
||||
_renderProgressSegments();
|
||||
var _anyRunning = S._googleScanRunning || S._fileScanRunning;
|
||||
// Only close SSE once all concurrent scans have finished.
|
||||
// Closing early would drop google_scan_done / file_scan_done events and
|
||||
// leave the UI stuck in scanning state.
|
||||
if (S._userStartedScan && !_anyRunning) {
|
||||
S._userStartedScan = false;
|
||||
if (S.es) { S.es.close(); S.es = null; }
|
||||
}
|
||||
if (!_anyRunning) setLogLive('');
|
||||
document.getElementById('scanBtn').disabled = _anyRunning;
|
||||
document.getElementById('stopBtn').style.display = _anyRunning ? 'inline-block' : 'none';
|
||||
@@ -405,6 +405,10 @@ function _attachScanListeners(source) {
|
||||
S._googleScanRunning = false;
|
||||
_renderProgressSegments();
|
||||
if (!S._m365ScanRunning && !S._fileScanRunning) {
|
||||
if (S._userStartedScan) {
|
||||
S._userStartedScan = false;
|
||||
if (S.es) { S.es.close(); S.es = null; }
|
||||
}
|
||||
setLogLive('');
|
||||
document.getElementById('scanBtn').disabled = false;
|
||||
document.getElementById('stopBtn').style.display = 'none';
|
||||
@@ -429,6 +433,10 @@ function _attachScanListeners(source) {
|
||||
S._fileScanRunning = false;
|
||||
_renderProgressSegments();
|
||||
if (!S._m365ScanRunning && !S._googleScanRunning) {
|
||||
if (S._userStartedScan) {
|
||||
S._userStartedScan = false;
|
||||
if (S.es) { S.es.close(); S.es = null; }
|
||||
}
|
||||
setLogLive('');
|
||||
document.getElementById('scanBtn').disabled = false;
|
||||
document.getElementById('stopBtn').style.display = 'none';
|
||||
|
||||
Reference in new issue
Block a user