Options based on enum values

This commit is contained in:
Francesco 2023-10-14 11:24:49 +02:00
parent 49a81b47e2
commit e64a787b01
3 changed files with 5 additions and 4 deletions

View File

@ -87,7 +87,7 @@ public class DataExportController {
.header(HttpHeaders.CONTENT_DISPOSITION, .header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"export_" + schema.getJavaClass().getSimpleName() + ".xlsx\"") "attachment; filename=\"export_" + schema.getJavaClass().getSimpleName() + ".xlsx\"")
.body(toXlsx(sheetName, results, fields, raw)); .body(toXlsx(sheetName, results, fields, raw));
case JSON: case JSONL:
throw new DbAdminException("JSON TODO"); throw new DbAdminException("JSON TODO");
default: default:
throw new DbAdminException("Unable to detect export format"); throw new DbAdminException("Unable to detect export format");

View File

@ -1,5 +1,5 @@
package tech.ailef.dbadmin.external.dto; package tech.ailef.dbadmin.external.dto;
public enum DataExportFormat { public enum DataExportFormat {
CSV, XLSX, JSON; CSV, XLSX, JSONL;
} }

View File

@ -54,8 +54,9 @@
</div> </div>
<h5 class="fw-bold mt-3">Export format</h3> <h5 class="fw-bold mt-3">Export format</h3>
<select name="format" class="form-select"> <select name="format" class="form-select">
<option value="csv">CSV</option> <option th:each="format : ${T(tech.ailef.dbadmin.external.dto.DataExportFormat).values()}"
<option value="xlsx">XLSX</option> th:value="${format}" th:text="${format}">
</option>
</select> </select>
<div class="form-check mt-3"> <div class="form-check mt-3">
<input class="form-check-input" type="checkbox" <input class="form-check-input" type="checkbox"