chore: stubbing ad-hoc-filter changes
This commit is contained in:
@@ -25,7 +25,13 @@ import {
|
||||
parseLogsFrame,
|
||||
} from '../../../features/logs/logsFrame';
|
||||
import { isSetDisplayedFields } from '../logs/types';
|
||||
import { TablePanel } from '../table/TablePanel';
|
||||
import {
|
||||
AdHocFilterItem,
|
||||
FILTER_FOR_OPERATOR,
|
||||
FILTER_OUT_OPERATOR,
|
||||
TableFilterActionCallback,
|
||||
TablePanel,
|
||||
} from '../table/TablePanel';
|
||||
import type { Options as TableOptions } from '../table/panelcfg.gen';
|
||||
|
||||
import type { Options as LogsTableOptions } from './panelcfg.gen';
|
||||
@@ -93,6 +99,7 @@ export const LogsTable = ({
|
||||
? options.setDisplayedFields
|
||||
: setDisplayedFields;
|
||||
|
||||
// Callbacks
|
||||
const onTableOptionsChange = useCallback(
|
||||
(options: TableOptions) => {
|
||||
console.log('onTableOptionsChange', options);
|
||||
@@ -124,6 +131,33 @@ export const LogsTable = ({
|
||||
[onFieldConfigChange]
|
||||
);
|
||||
|
||||
const handleOnCellFilterAdded: TableFilterActionCallback = (filter: AdHocFilterItem) => {
|
||||
const { value, key, operator } = filter;
|
||||
if (operator === FILTER_FOR_OPERATOR) {
|
||||
onClickFilterLabel(key, value);
|
||||
}
|
||||
|
||||
if (operator === FILTER_OUT_OPERATOR) {
|
||||
onClickFilterOutLabel(key, value);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @todo
|
||||
* Used by Logs details.
|
||||
*/
|
||||
const onClickFilterLabel = (key: string, value: string | number, frame?: DataFrame) => {
|
||||
console.log('onClickFilterLabel', key, value, frame);
|
||||
};
|
||||
|
||||
/**
|
||||
* @todo
|
||||
* Used by Logs details.
|
||||
*/
|
||||
const onClickFilterOutLabel = (key: string, value: string | number, frame?: DataFrame) => {
|
||||
console.log('onClickFilterOutLabel', key, value, frame);
|
||||
};
|
||||
|
||||
/**
|
||||
* Extract fields transform
|
||||
*/
|
||||
@@ -233,6 +267,7 @@ export const LogsTable = ({
|
||||
onFieldConfigChange={handleTableOnFieldConfigChange}
|
||||
replaceVariables={replaceVariables}
|
||||
onChangeTimeRange={onChangeTimeRange}
|
||||
onCellFilterAdded={handleOnCellFilterAdded}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -17,6 +17,7 @@ import { tableSuggestionsSupplier } from '../table/suggestions';
|
||||
import { LogsTable } from './LogsTable';
|
||||
import { Options } from './panelcfg.gen';
|
||||
|
||||
// @todo can we pull stuff from table module instead of manually adding?
|
||||
export const plugin = new PanelPlugin<Options, TableFieldConfig>(LogsTable)
|
||||
.setPanelChangeHandler(tablePanelChangedHandler)
|
||||
.useFieldConfig({
|
||||
|
||||
@@ -24,7 +24,16 @@ import { getActions } from '../../../features/actions/utils';
|
||||
import { hasDeprecatedParentRowIndex, migrateFromParentRowIndexToNestedFrames } from './migrations';
|
||||
import { Options } from './panelcfg.gen';
|
||||
|
||||
interface Props extends PanelProps<Options> {}
|
||||
/** @todo get yelled at by dataviz */
|
||||
export const FILTER_FOR_OPERATOR = '=';
|
||||
export const FILTER_OUT_OPERATOR = '!=';
|
||||
export type AdHocFilterOperator = typeof FILTER_FOR_OPERATOR | typeof FILTER_OUT_OPERATOR;
|
||||
export type AdHocFilterItem = { key: string; value: string; operator: AdHocFilterOperator };
|
||||
export type TableFilterActionCallback = (item: AdHocFilterItem) => void;
|
||||
|
||||
interface Props extends PanelProps<Options> {
|
||||
onCellFilterAdded?: TableFilterActionCallback;
|
||||
}
|
||||
|
||||
export function TablePanel(props: Props) {
|
||||
const { data, height, width, options, fieldConfig, id, timeRange, replaceVariables, transparent } = props;
|
||||
@@ -77,7 +86,7 @@ export function TablePanel(props: Props) {
|
||||
initialSortBy={options.sortBy}
|
||||
onSortByChange={(sortBy) => onSortByChange(sortBy, props)}
|
||||
onColumnResize={(displayName, resizedWidth) => onColumnResize(displayName, resizedWidth, props)}
|
||||
onCellFilterAdded={panelContext.onAddAdHocFilter}
|
||||
onCellFilterAdded={props.onCellFilterAdded ?? panelContext.onAddAdHocFilter}
|
||||
frozenColumns={options.frozenColumns?.left}
|
||||
enablePagination={options.enablePagination}
|
||||
cellHeight={options.cellHeight}
|
||||
|
||||
Reference in New Issue
Block a user