Skip to content

Commit dda2b60

Browse files
committed
[FEATURE]: add teansform to the logs table
Signed-off-by: Mahmoud <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com>
1 parent 0fb7906 commit dda2b60

File tree

6 files changed

+47
-7
lines changed

6 files changed

+47
-7
lines changed

logstable/cue.mod/module.cue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ language: {
55
source: {
66
kind: "git"
77
}
8+
deps: {
9+
"github.com/perses/shared/cue@v0": {
10+
v: "v0.53.0-rc.1"
11+
default: true
12+
}
13+
}

logstable/schemas/logstable.cue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313

1414
package model
1515

16+
import ("github.com/perses/shared/cue/common")
17+
1618
kind: "LogsTable"
1719
spec: close({
1820
allowWrap?: bool
1921
enableDetails?: bool
2022
showTime?: bool
23+
transforms?: [...common.#transform]
2124
})

logstable/src/LogsTable.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ import { PanelPlugin } from '@perses-dev/plugin-system';
1515
import { LogsTableComponent } from './LogsTableComponent';
1616
import { LogsTableOptions, LogsTableProps } from './model';
1717
import { LogsTableSettingsEditor } from './LogsTableSettingsEditor';
18+
import { LogsTableTransforms } from './components/LogsTableTransforms';
1819

1920
export const LogsTable: PanelPlugin<LogsTableOptions, LogsTableProps> = {
2021
PanelComponent: LogsTableComponent,
21-
panelOptionsEditorComponents: [{ label: 'Settings', content: LogsTableSettingsEditor }],
22+
panelOptionsEditorComponents: [
23+
{ label: 'Settings', content: LogsTableSettingsEditor },
24+
{ label: 'Transforms', content: LogsTableTransforms },
25+
],
2226
supportedQueryTypes: ['LogQuery'],
2327
createInitialOptions: () => ({
2428
showTime: true,

logstable/src/LogsTableSettingsEditor.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ import {
1717
ThresholdsEditor,
1818
ThresholdsEditorProps,
1919
} from '@perses-dev/components';
20-
import { LegendOptionsEditor, LegendOptionsEditorProps, OptionsEditorProps } from '@perses-dev/plugin-system';
20+
import { LegendOptionsEditor, LegendOptionsEditorProps } from '@perses-dev/plugin-system';
2121
import { ReactElement } from 'react';
22-
import { LogsTableOptions } from './model';
23-
24-
type LogsTableSettingsEditorProps = OptionsEditorProps<LogsTableOptions>;
22+
import { LogsTableSettingsEditorProps } from './model';
2523

2624
export function LogsTableSettingsEditor(props: LogsTableSettingsEditorProps): ReactElement {
2725
const { onChange, value } = props;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright The Perses Authors
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
import { TransformsEditor, TransformsEditorProps } from '@perses-dev/components';
15+
import { ReactElement } from 'react';
16+
import { LogsTableSettingsEditorProps } from '../model';
17+
18+
export const LogsTableTransforms = (props: LogsTableSettingsEditorProps): ReactElement => {
19+
const { onChange, value } = props;
20+
21+
const handleTransformsChange: TransformsEditorProps['onChange'] = (transforms) => {
22+
onChange({ ...value, transforms });
23+
};
24+
25+
return <TransformsEditor value={value.transforms ?? []} onChange={handleTransformsChange} />;
26+
};

logstable/src/model.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
import { LogData, ThresholdOptions } from '@perses-dev/core';
15-
import { PanelProps, LegendSpecOptions } from '@perses-dev/plugin-system';
14+
import { LogData, ThresholdOptions, Transform } from '@perses-dev/core';
15+
import { PanelProps, LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system';
1616

1717
export type LogsTableProps = PanelProps<LogsTableOptions, LogsQueryData>;
1818

@@ -27,4 +27,7 @@ export interface LogsTableOptions {
2727
enableDetails?: boolean;
2828
showTime?: boolean;
2929
showAll?: boolean;
30+
transforms?: Transform[];
3031
}
32+
33+
export type LogsTableSettingsEditorProps = OptionsEditorProps<LogsTableOptions>;

0 commit comments

Comments
 (0)