50%
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user