Files
chart-app/src/main/java/com/example/components/Fa.java
T
Pit Friedrich cfa644c0e1
CI / build-and-test (pull_request) Successful in 2m26s
fix: export widget data as CSV from the action menu (#28)
The ApexCharts toolbar stays hidden (DialectTheme), so the dashboard had no
export at all. Adds an "Als CSV exportieren" entry to the per-widget action
menu, served server-side from the same data the widget renders.

- CsvExport: the export table plus its CSV dialect (';' separator, CRLF,
  UTF-8 BOM, locale-formatted numbers) and file-name slugging.
- GridStackItem.setActionDownload: turns a menu entry's caption into an
  anchor over a DownloadHandler, so an entry can hand out a file.
- WidgetRegistry: keeps each widget's query, not only its result, so the
  Export hook re-runs it — an export always matches the current filter.
- DashboardView: builds the download on click; file name is widget title +
  period (revenue-trend-half-year.csv).

Chart image export is left as the follow-up the issue calls optional.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0124BiJikbhbiEsNfJxdWM69
2026-07-28 21:45:40 +02:00

48 lines
1.6 KiB
Java

package com.example.components;
import com.vaadin.flow.component.icon.FontIcon;
/**
* Font Awesome Free icon references, mirroring the ergonomics of
* {@code VaadinIcon.create()}. Backed by the {@code fa-*} CSS classes
* shipped in the bundled {@code @fortawesome/fontawesome-free} package.
*
* <p>Font Awesome paints glyphs via {@code content: var(--fa)} on
* {@code ::before}; the glyph-specific class (e.g. {@code fa-sun}) is what
* defines that {@code --fa} custom property, so both the family class
* ({@code fa-solid}) and the glyph class must be present.
*/
public enum Fa {
MOON("fa-solid", "fa-moon"),
SUN("fa-solid", "fa-sun"),
DASHBOARD("fa-solid", "fa-gauge-high"),
FORM("fa-solid", "fa-rectangle-list"),
TABLE("fa-solid", "fa-table"),
GLOBE("fa-solid", "fa-globe"),
SEARCH("fa-solid", "fa-magnifying-glass"),
GRID("fa-solid", "fa-table-cells-large"),
ADD("fa-solid", "fa-plus"),
REMOVE("fa-solid", "fa-trash"),
RESET("fa-solid", "fa-arrow-rotate-left"),
DRAG("fa-solid", "fa-grip-vertical"),
CLOSE("fa-solid", "fa-xmark"),
MENU("fa-solid", "fa-ellipsis-vertical"),
REFRESH("fa-solid", "fa-arrows-rotate"),
MAXIMIZE("fa-solid", "fa-expand"),
DUPLICATE("fa-solid", "fa-clone"),
EXPORT("fa-solid", "fa-file-csv"),
TREND_UP("fa-solid", "fa-arrow-trend-up"),
TREND_DOWN("fa-solid", "fa-arrow-trend-down");
private final String[] classes;
Fa(String... classes) {
this.classes = classes;
}
public FontIcon create() {
return new FontIcon(classes);
}
}