Erweiterungen
This commit is contained in:
@@ -24,13 +24,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
public class AppUserView extends VerticalLayout {
|
||||
|
||||
private final AppUserService appUserService;
|
||||
private final AppDeviceService appDeviceService;
|
||||
private final Grid<AppUser> appUserGrid;
|
||||
|
||||
@Autowired
|
||||
public AppUserView(AppUserService appUserService, AppDeviceService appDeviceService) {
|
||||
this.appUserService = appUserService;
|
||||
this.appDeviceService = appDeviceService;
|
||||
|
||||
setSizeFull();
|
||||
setPadding(true);
|
||||
|
||||
@@ -23,8 +23,6 @@ public class ShowJobsView extends VerticalLayout {
|
||||
|
||||
private final DatePicker startDate = new DatePicker("Startdatum");
|
||||
private final DatePicker endDate = new DatePicker("Enddatum");
|
||||
private final Button applyFilter = new Button("Anwenden");
|
||||
private final Button exportButton = new Button("CSV Export");
|
||||
private final JobRepository jobRepository;
|
||||
private final Grid<Job> grid = new Grid<>(Job.class, false);
|
||||
|
||||
@@ -35,12 +33,14 @@ public class ShowJobsView extends VerticalLayout {
|
||||
setPadding(true);
|
||||
setSpacing(true);
|
||||
// Filterleiste mit Export-Button am rechten Rand
|
||||
Button applyFilter = new Button("Anwenden");
|
||||
HorizontalLayout leftFilters = new HorizontalLayout(startDate, endDate, applyFilter);
|
||||
leftFilters.setAlignItems(Alignment.END);
|
||||
|
||||
HorizontalLayout filterBar = new HorizontalLayout();
|
||||
filterBar.setWidthFull();
|
||||
filterBar.add(leftFilters);
|
||||
Button exportButton = new Button("CSV Export");
|
||||
filterBar.add(exportButton);
|
||||
filterBar.setJustifyContentMode(JustifyContentMode.BETWEEN);
|
||||
filterBar.setAlignItems(Alignment.END);
|
||||
@@ -64,6 +64,19 @@ public class ShowJobsView extends VerticalLayout {
|
||||
|
||||
grid.setMultiSort(true);
|
||||
grid.setSizeFull();
|
||||
|
||||
// Make grid rows clickable
|
||||
grid.setSelectionMode(Grid.SelectionMode.SINGLE);
|
||||
grid.getStyle().set("cursor", "pointer");
|
||||
|
||||
// Add click listener to navigate to job summary view
|
||||
grid.addItemClickListener(event -> {
|
||||
Job job = event.getItem();
|
||||
if (job != null && job.getId() != null) {
|
||||
getUI().ifPresent(ui -> ui.navigate("job_summary/" + job.getId().toHexString()));
|
||||
}
|
||||
});
|
||||
|
||||
add(grid);
|
||||
|
||||
loadData();
|
||||
@@ -90,10 +103,7 @@ public class ShowJobsView extends VerticalLayout {
|
||||
private void exportToCsv() {
|
||||
var items = grid.getListDataView().getItems().toList();
|
||||
|
||||
StreamResource resource = new StreamResource("auftraege.csv", () -> {
|
||||
java.io.ByteArrayInputStream stream = new java.io.ByteArrayInputStream(generateCsv(items).getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
return stream;
|
||||
});
|
||||
StreamResource resource = new StreamResource("auftraege.csv", () -> new java.io.ByteArrayInputStream(generateCsv(items).getBytes(java.nio.charset.StandardCharsets.UTF_8)));
|
||||
resource.setContentType("text/csv");
|
||||
resource.setCacheTime(0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user