| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package funcapi |
| 4 | |
| 5 | // ColumnMeta defines UI metadata for a table column. |
| 6 | // This struct contains ONLY column display and visualization properties. |
| 7 | // |
| 8 | // What belongs here: How to render and display a column in the table. |
| 9 | // What does NOT belong here: Data access (SQL, BSON), parameters (sort options). |
| 10 | // |
| 11 | // Collectors embed this and add their own fields for: |
| 12 | // - Data access (SelectExpr, DBField, Value func, etc.) |
| 13 | // - Parameter-related metadata (sort options, filter options - these are method-specific) |
| 14 | type ColumnMeta struct { |
| 15 | // Identity |
| 16 | Name string // Column name/identifier in response (e.g., "execution_time") |
| 17 | Tooltip string // Hover tooltip text shown in UI (e.g., "Execution Time") |
| 18 | |
| 19 | // Type and Display |
| 20 | Type FieldType |
| 21 | Units string |
| 22 | Visible bool |
| 23 | Sortable bool // Can this column be sorted in the table UI? |
| 24 | Sticky bool |
| 25 | FullWidth bool |
| 26 | Wrap bool |
| 27 | |
| 28 | // Value Rendering |
| 29 | Transform FieldTransform |
| 30 | DecimalPoints int |
| 31 | Sort FieldSort // Default sort direction for this column |
| 32 | Summary FieldSummary |
| 33 | Filter FieldFilter |
| 34 | Visualization FieldVisual |
| 35 | |
| 36 | // Special Flags |
| 37 | UniqueKey bool |
| 38 | ExpandFilter bool |
| 39 | |
| 40 | // Chart configuration (nil = column is not a chart metric) |
| 41 | // Used by BuildCharts() and BuildDefaultCharts() |
| 42 | Chart *ChartOptions |
| 43 | |
| 44 | // GroupBy configuration (nil = column not available for grouping) |
| 45 | // Used by BuildGroupBy() and BuildDefaultCharts() |
| 46 | GroupBy *GroupByOptions |
| 47 | } |
| 48 | |
| 49 | // ChartOptions defines how a column participates in charts. |
| 50 | type ChartOptions struct { |
| 51 | Group string // Which chart this column belongs to (required) |
| 52 | Title string // Chart display title (defaults to Group if empty) |
| 53 | IsDefault bool // Include this chart in the default charts view |
| 54 | DefaultGroupBy string // GroupBy column name for this chart's default (optional, falls back to global) |
| 55 | } |
| 56 | |
| 57 | // GroupByOptions defines how a column participates in data grouping. |
| 58 | type GroupByOptions struct { |
| 59 | IsDefault bool // This is the default grouping column for charts |
| 60 | } |