# Description of Changes ### Summary - Added support for configuring UI languages via `settings.yml` (`languages` field). - Modified `LanguageService` to respect the configured languages, while ensuring British English (`en_GB`) is always enabled. - Updated Thymeleaf templates to dynamically display only the allowed languages. - Improved logging and refactored some list-to-set conversions for better efficiency. ### Why the Change? - Allows administrators to limit available UI languages instead of displaying all detected languages. - Provides better customization options and simplifies language management. ### Challenges Encountered - Ensuring backwards compatibility: If `languages` is empty, all languages remain enabled. - Handling `Set<String>` instead of `List<String>` in `LanguageService` for optimized lookups. --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [x] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [x] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [x] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing) for more details.
47 lines
1.7 KiB
Java
47 lines
1.7 KiB
Java
package stirling.software.SPDF.controller.web;
|
|
|
|
import java.util.List;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.core.Authentication;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import stirling.software.SPDF.config.security.database.DatabaseService;
|
|
import stirling.software.SPDF.utils.FileInfo;
|
|
|
|
@Controller
|
|
@Tag(name = "Database Management", description = "Database management and security APIs")
|
|
public class DatabaseWebController {
|
|
|
|
private final DatabaseService databaseService;
|
|
|
|
public DatabaseWebController(DatabaseService databaseService) {
|
|
this.databaseService = databaseService;
|
|
}
|
|
|
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
@GetMapping("/database")
|
|
public String database(HttpServletRequest request, Model model, Authentication authentication) {
|
|
String error = request.getParameter("error");
|
|
String confirmed = request.getParameter("infoMessage");
|
|
if (error != null) {
|
|
model.addAttribute("error", error);
|
|
} else if (confirmed != null) {
|
|
model.addAttribute("infoMessage", confirmed);
|
|
}
|
|
List<FileInfo> backupList = databaseService.getBackupList();
|
|
model.addAttribute("backupFiles", backupList);
|
|
String dbVersion = databaseService.getH2Version();
|
|
model.addAttribute("databaseVersion", dbVersion);
|
|
if ("Unknown".equalsIgnoreCase(dbVersion)) {
|
|
model.addAttribute("infoMessage", "notSupported");
|
|
}
|
|
return "database";
|
|
}
|
|
}
|