mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Datasource/CloudWatch: Prevents hidden dataframe fields from displaying in tables (#24580)
* Datasource/CloudWatch: Prevents hidden dataframe fields from displaying in tables
This commit is contained in:
@@ -57,9 +57,9 @@ export class FieldCache {
|
||||
return types && types.length > 0;
|
||||
}
|
||||
|
||||
getFirstFieldOfType(type: FieldType): FieldWithIndex | undefined {
|
||||
getFirstFieldOfType(type: FieldType, includeHidden = false): FieldWithIndex | undefined {
|
||||
const fields = this.fieldByType[type];
|
||||
const firstField = fields.find(field => !(field.config.custom && field.config.custom['Hidden']));
|
||||
const firstField = fields.find(field => includeHidden || !field.config.custom?.hidden);
|
||||
return firstField;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ export interface Column {
|
||||
text: string; // For a Column, the 'text' is the field name
|
||||
filterable?: boolean;
|
||||
unit?: string;
|
||||
custom?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface TableData extends QueryResultBase {
|
||||
|
||||
@@ -83,8 +83,10 @@ class UnThemedLogDetails extends PureComponent<Props> {
|
||||
return (
|
||||
row.dataFrame.fields
|
||||
.map((field, index) => ({ ...field, index }))
|
||||
// Remove Id which we use for react key and entry field which we are showing as the log message.
|
||||
.filter((field, index) => 'id' !== field.name && row.entryFieldIndex !== index)
|
||||
// Remove Id which we use for react key and entry field which we are showing as the log message. Also remove hidden fields.
|
||||
.filter(
|
||||
(field, index) => !('id' === field.name || row.entryFieldIndex === index || field.config.custom?.hidden)
|
||||
)
|
||||
// Filter out fields without values. For example in elastic the fields are parsed from the document which can
|
||||
// have different structure per row and so the dataframe is pretty sparse.
|
||||
.filter(field => {
|
||||
|
||||
@@ -7,6 +7,7 @@ export interface TableFieldOptions {
|
||||
width: number;
|
||||
align: FieldTextAlignment;
|
||||
displayMode: TableCellDisplayMode;
|
||||
hidden?: boolean;
|
||||
}
|
||||
|
||||
export enum TableCellDisplayMode {
|
||||
|
||||
@@ -38,10 +38,13 @@ export function getColumns(data: DataFrame, availableWidth: number, columnMinWid
|
||||
const columns: Column[] = [];
|
||||
let fieldCountWithoutWidth = data.fields.length;
|
||||
|
||||
for (let fieldIndex = 0; fieldIndex < data.fields.length; fieldIndex++) {
|
||||
const field = data.fields[fieldIndex];
|
||||
for (const [fieldIndex, field] of data.fields.entries()) {
|
||||
const fieldTableOptions = (field.config.custom || {}) as TableFieldOptions;
|
||||
|
||||
if (fieldTableOptions.hidden) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fieldTableOptions.width) {
|
||||
availableWidth -= fieldTableOptions.width;
|
||||
fieldCountWithoutWidth -= 1;
|
||||
|
||||
Reference in New Issue
Block a user