This commit is contained in:
2025-12-23 07:50:08 +00:00
parent 4c3ea0059d
commit 7826c6ed24
12 changed files with 2008 additions and 98 deletions

View File

@@ -335,8 +335,50 @@
window.location.href = '/login?return=' + encodeURIComponent(window.location.pathname);
return;
}
// Hide create/update/delete buttons for viewer role
hideButtonsForViewer();
})();
// Get current user role
function getCurrentUserRole() {
try {
const userStr = localStorage.getItem('atlas_user');
if (userStr) {
const user = JSON.parse(userStr);
return (user.role || '').toLowerCase();
}
} catch (e) {
console.error('Error parsing user data:', e);
}
return '';
}
// Check if current user is viewer
function isViewer() {
return getCurrentUserRole() === 'viewer';
}
// Hide create/update/delete buttons for viewer role
function hideButtonsForViewer() {
if (isViewer()) {
// Hide create buttons
const createButtons = document.querySelectorAll('button[onclick*="showCreate"], button[onclick*="Create"], button[onclick*="Import"]');
createButtons.forEach(btn => {
if (btn.onclick && (btn.onclick.toString().includes('Create') || btn.onclick.toString().includes('Import'))) {
btn.style.display = 'none';
}
});
// Also hide by text content
document.querySelectorAll('button').forEach(btn => {
const text = btn.textContent || '';
if (text.includes('Create') || text.includes('Import')) {
btn.style.display = 'none';
}
});
}
}
let currentTab = 'pools';
function switchTab(tab) {