diff --git a/api.php b/api.php index 9b8fdc7..29cfd12 100644 --- a/api.php +++ b/api.php @@ -1612,6 +1612,14 @@ switch ($action) { if (!$branding) { $branding = ['found' => false, 'nimi' => 'Noxus Intra', 'primary_color' => '#0f3460', 'subtitle' => 'Hallintapaneeli', 'logo_url' => '']; } + // Tarkista onko yrityksellä integraatioita päällä + $hasIntegrations = false; + if ($activeCompanyId) { + $integrations = dbLoadIntegrations($activeCompanyId); + foreach ($integrations as $integ) { + if (!empty($integ['enabled'])) { $hasIntegrations = true; break; } + } + } echo json_encode([ 'authenticated' => true, 'user_id' => $_SESSION['user_id'], @@ -1626,6 +1634,7 @@ switch ($action) { 'branding' => $branding, 'enabled_modules' => $enabledModules, 'hidden_mailboxes' => $u ? ($u['hidden_mailboxes'] ?? []) : [], + 'has_integrations' => $hasIntegrations, ]); } else { echo json_encode(['authenticated' => false]); diff --git a/noxus-logo.svg b/noxus-logo.svg new file mode 100644 index 0000000..8b3533b --- /dev/null +++ b/noxus-logo.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + N + + + + + + NOXUS + + + + + + \ No newline at end of file diff --git a/script.js b/script.js index ce7f08c..5e1cb82 100644 --- a/script.js +++ b/script.js @@ -145,7 +145,7 @@ async function checkAuth() { currentUserSignatures = data.signatures || {}; currentHiddenMailboxes = data.hidden_mailboxes || []; if (data.branding) applyBranding(data.branding); - applyModules(data.enabled_modules || []); + applyModules(data.enabled_modules || [], data.has_integrations); showDashboard(); return; } @@ -242,7 +242,7 @@ async function switchCompany(companyId) { try { const auth = await apiCall('check_auth'); if (auth.branding) applyBranding(auth.branding); - applyModules(auth.enabled_modules || []); + applyModules(auth.enabled_modules || [], auth.has_integrations); currentUser.company_role = auth.company_role || ''; currentUserSignatures = auth.signatures || {}; currentHiddenMailboxes = auth.hidden_mailboxes || []; @@ -2872,7 +2872,14 @@ document.getElementById('btn-save-company-settings').addEventListener('click', a nimi, subtitle, primary_color, logo_url: comp?.logo_file ? 'api.php?action=company_logo&company_id=' + encodeURIComponent(currentCompanyDetail) + '&t=' + Date.now() : '' }); - applyModules(enabled_modules); + // Tarkista integraatiot API-tabin näkyvyydelle + try { + const integs = await apiCall('integrations'); + const hasIntegs = integs.some(i => i.enabled); + applyModules(enabled_modules, hasIntegs); + } catch (e2) { + applyModules(enabled_modules, false); + } } } catch (e) { alert(e.message); } }); @@ -6229,7 +6236,7 @@ document.getElementById('laitetila-edit-form')?.addEventListener('submit', async const ALL_MODULES = ['customers', 'support', 'leads', 'tekniikka', 'ohjeet', 'todo', 'documents', 'laitetilat', 'netadmin', 'archive', 'changelog', 'settings']; const DEFAULT_MODULES = ['customers', 'support', 'archive', 'changelog', 'settings']; -function applyModules(modules) { +function applyModules(modules, hasIntegrations) { // Yhteensopivuus: vanha 'devices' → 'tekniikka' if (modules && modules.includes('devices') && !modules.includes('tekniikka')) { modules = modules.map(m => m === 'devices' ? 'tekniikka' : m); @@ -6237,12 +6244,14 @@ function applyModules(modules) { // Jos tyhjä array → kaikki moduulit päällä (fallback) const enabled = (modules && modules.length > 0) ? modules : ALL_MODULES; const isAdminUser = isCurrentUserAdmin(); + const isSuperAdmin = currentUser?.role === 'superadmin'; ALL_MODULES.forEach(mod => { const tabBtn = document.querySelector(`.tab[data-tab="${mod}"]`); if (tabBtn) { - // settings-tabi näkyy vain adminille/superadminille + // settings/API-tabi: adminille/superadminille, ja vain jos integraatioita on päällä (superadmin näkee aina) if (mod === 'settings') { - tabBtn.style.display = (enabled.includes(mod) && isAdminUser) ? '' : 'none'; + const showSettings = enabled.includes(mod) && isAdminUser && (isSuperAdmin || hasIntegrations === true); + tabBtn.style.display = showSettings ? '' : 'none'; } else { tabBtn.style.display = enabled.includes(mod) ? '' : 'none'; }