Added dark/white theme button for unprivileged users

This commit is contained in:
l3wiz 2021-06-21 13:15:07 +02:00
parent 1811f90867
commit 2149e76876
3 changed files with 15 additions and 5 deletions

View file

@ -1146,13 +1146,22 @@ print([[
end
-- Rende Toggle Dark theme menu button
if is_admin then
print([[
local theme_selector = ntop.getPref("ntopng.prefs.theme")
if(theme_selector ~= 'dark') then
print([[
<li class='dropdown-divider'></li>
<li>
<a class='dropdown-item toggle-dark-theme' href='#'><i class="fas fa-adjust"></i> ]].. i18n("toggle_dark_theme") ..[[</a>
</li>
]])
else
print([[
<li class='dropdown-divider'></li>
<li>
<a class='dropdown-item toggle-dark-theme' href='#'><i class="fas fa-adjust"></i> ]].. i18n("toggle_dark_theme") ..[[</a>
<a class='dropdown-item toggle-dark-theme' href='#'><i class="fas fa-adjust"></i> ]].. i18n("toggle_white_theme") ..[[</a>
</li>
]])
]])
end
-- Logout

View file

@ -30,7 +30,7 @@ if isAdministrator() then
-- does the user want to toggle theme?
local enabled = toboolean(_POST['toggle_dark_theme'])
-- set dark theme or the default one
ntop.setPref("ntopng.prefs.theme", (enabled and "dark" or ""))
ntop.setPref("ntopng.prefs.theme", (enabled and "dark" or "white"))
end
res.success = true
end