diff --git a/README.md b/README.md index dc2270345..5aace9610 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ Stirling-PDF currently supports 39 languages! | Korean (한국어) (ko_KR) | ![95%](https://geps.dev/progress/95) | | Norwegian (Norsk) (no_NB) | ![89%](https://geps.dev/progress/89) | | Persian (فارسی) (fa_IR) | ![90%](https://geps.dev/progress/90) | -| Polish (Polski) (pl_PL) | ![82%](https://geps.dev/progress/82) | +| Polish (Polski) (pl_PL) | ![98%](https://geps.dev/progress/98) | | Portuguese (Português) (pt_PT) | ![93%](https://geps.dev/progress/93) | | Portuguese Brazilian (Português) (pt_BR) | ![96%](https://geps.dev/progress/96) | | Romanian (Română) (ro_RO) | ![77%](https://geps.dev/progress/77) | diff --git a/src/main/java/stirling/software/SPDF/config/security/UserService.java b/src/main/java/stirling/software/SPDF/config/security/UserService.java index e585d6777..8df5975c1 100644 --- a/src/main/java/stirling/software/SPDF/config/security/UserService.java +++ b/src/main/java/stirling/software/SPDF/config/security/UserService.java @@ -204,6 +204,7 @@ public class UserService implements UserServiceInterface { user.setPassword(passwordEncoder.encode(password)); user.setEnabled(true); user.setAuthenticationType(AuthenticationType.WEB); + user.addAuthority(new Authority(Role.USER.getRoleId(), user)); userRepository.save(user); databaseService.exportDatabase(); } @@ -229,6 +230,22 @@ public class UserService implements UserServiceInterface { saveUser(username, password, role, false); } + public void saveUser(String username, String password, boolean firstLogin, boolean enabled) + throws IllegalArgumentException, SQLException, UnsupportedProviderException { + if (!isUsernameValid(username)) { + throw new IllegalArgumentException(getInvalidUsernameMessage()); + } + User user = new User(); + user.setUsername(username); + user.setPassword(passwordEncoder.encode(password)); + user.addAuthority(new Authority(Role.USER.getRoleId(), user)); + user.setEnabled(enabled); + user.setAuthenticationType(AuthenticationType.WEB); + user.setFirstLogin(firstLogin); + userRepository.save(user); + databaseService.exportDatabase(); + } + public void deleteUser(String username) { Optional userOpt = findByUsernameIgnoreCase(username); if (userOpt.isPresent()) { @@ -351,6 +368,7 @@ public class UserService implements UserServiceInterface { List notAllowedUserList = new ArrayList<>(); notAllowedUserList.add("ALL_USERS".toLowerCase()); + notAllowedUserList.add("anonymoususer"); boolean notAllowedUser = notAllowedUserList.contains(username.toLowerCase()); return (isValidSimpleUsername || isValidEmail) && !notAllowedUser; } diff --git a/src/main/resources/messages_pl_PL.properties b/src/main/resources/messages_pl_PL.properties index 7cde4c3ed..dcc4350e9 100644 --- a/src/main/resources/messages_pl_PL.properties +++ b/src/main/resources/messages_pl_PL.properties @@ -1036,10 +1036,10 @@ decrypt.unexpectedError=Wystąpił błąd podczas przetwarzania pliku. Spróbuj decrypt.serverError=Błąd serwera podczas odszyfrowywania: {0} decrypt.success=Plik został pomyślnie odszyfrowany. -#multiTool-advert -multiTool-advert.message=Ta funkcja jest również dostępna na naszej stronie narzędzia wielofunkcyjnego. Sprawdź ją, aby uzyskać lepszy interfejs zarządzania stronami i dodatkowe funkcje! +#multiTool-advert +multiTool-advert.message=Ta funkcja jest również dostępna na naszej stronie narzędzia wielofunkcyjnego. Sprawdź ją, aby uzyskać lepszy interfejs zarządzania stronami i dodatkowe funkcje! -#view pdf +#view pdf viewPdf.title=Przeglądaj/Edytuj PDF viewPdf.header=Podejrzyj PDF diff --git a/src/main/resources/static/js/usage.js b/src/main/resources/static/js/usage.js index a9c98ed9e..624e4ec78 100644 --- a/src/main/resources/static/js/usage.js +++ b/src/main/resources/static/js/usage.js @@ -27,7 +27,7 @@ function getChartColors() { } // Watch for theme changes and update chart if needed -function setupThemeChangeListener() { +function setupThemeChangeListener() { // Start observing theme changes document.addEventListener("modeChanged", (event) => { @@ -41,7 +41,7 @@ function setupThemeChangeListener() { } }, 100); }); - + // Also watch for system preference changes window .matchMedia('(prefers-color-scheme: dark)') @@ -60,22 +60,22 @@ function setupThemeChangeListener() { function filterData() { const includeHome = document.getElementById('hideHomeCheckbox').checked; const includeLogin = document.getElementById('hideLoginCheckbox').checked; - + filteredData = allEndpointData.filter(item => { if (!includeHome && item.endpoint === '/') return false; if (!includeLogin && item.endpoint === '/login') return false; return true; }); - + // Sort and calculate sortedData = [...filteredData].sort((a, b) => b.count - a.count); totalEndpoints = filteredData.length; totalVisits = filteredData.reduce((sum, item) => sum + item.count, 0); - + // Update stats document.getElementById('totalEndpoints').textContent = totalEndpoints.toLocaleString(); document.getElementById('totalVisits').textContent = totalVisits.toLocaleString(); - + // Update the chart with current limit const currentLimit = document.getElementById('currentlyShowing').textContent; const limit = (currentLimit === endpointStatsTranslations.all) @@ -96,33 +96,33 @@ async function fetchEndpointData() { ${endpointStatsTranslations.loading} `; chartContainer.appendChild(loadingDiv); - + // Also add animation to refresh button const refreshBtn = document.getElementById('refreshBtn'); refreshBtn.classList.add('refreshing'); refreshBtn.disabled = true; - + const response = await fetch('/api/v1/info/load/all'); if (!response.ok) { throw new Error('Network response was not ok'); } - + const data = await response.json(); allEndpointData = data; - + // Apply filters filterData(); - + // Remove loading state chartContainer.removeChild(loadingDiv); refreshBtn.classList.remove('refreshing'); refreshBtn.disabled = false; - + } catch (error) { console.error('Error fetching endpoint data:', error); // Show error message to user showError(endpointStatsTranslations.failedToLoad); - + // Reset refresh button const refreshBtn = document.getElementById('refreshBtn'); refreshBtn.classList.remove('refreshing'); @@ -141,24 +141,24 @@ function formatEndpointName(endpoint) { function updateTable(data) { const tableBody = document.getElementById('endpointTableBody'); tableBody.innerHTML = ''; - + data.forEach((item, index) => { const percentage = ((item.count / totalVisits) * 100).toFixed(2); const row = document.createElement('tr'); - + // Format endpoint for better readability let displayEndpoint = item.endpoint; if (displayEndpoint.length > 40) { displayEndpoint = displayEndpoint.substring(0, 37) + '...'; } - + row.innerHTML = ` ${index + 1} ${displayEndpoint} ${item.count.toLocaleString()} ${percentage}% `; - + tableBody.appendChild(row); }); } @@ -172,10 +172,10 @@ function updateChart(dataLimit) { const displayedPercentage = totalVisits > 0 ? ((displayedVisits / totalVisits) * 100).toFixed(2) : '0'; - + document.getElementById('displayedVisits').textContent = displayedVisits.toLocaleString(); document.getElementById('displayedPercentage').textContent = displayedPercentage; - + // If the limit equals the total filtered items, show "All"; otherwise "Top X" document.getElementById('currentlyShowing').textContent = (dataLimit === filteredData.length) @@ -303,30 +303,30 @@ function updateChart(dataLimit) { document.addEventListener('DOMContentLoaded', function() { // Set up theme change listener setupThemeChangeListener(); - + // Initial data fetch fetchEndpointData(); - + // Set up button event listeners document.getElementById('top10Btn').addEventListener('click', function() { updateChart(10); setActiveButton(this); }); - + document.getElementById('top20Btn').addEventListener('click', function() { updateChart(20); setActiveButton(this); }); - + document.getElementById('allBtn').addEventListener('click', function() { updateChart(filteredData.length); setActiveButton(this); }); - + document.getElementById('refreshBtn').addEventListener('click', function() { fetchEndpointData(); }); - + // Set up filter checkbox listeners document.getElementById('hideHomeCheckbox').addEventListener('change', filterData); document.getElementById('hideLoginCheckbox').addEventListener('change', filterData); @@ -350,14 +350,14 @@ function showError(message) { error ${message} `; - + chartContainer.innerHTML = ''; chartContainer.appendChild(errorDiv); - + // Add retry button functionality document.getElementById('errorRetryBtn').addEventListener('click', fetchEndpointData); }