mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-16 05:36:03 +08:00
feat: added log attributes in the raw view old designs (#4423)
* feat: added log attributes in the raw view old designs * feat: support it in old explorer page
This commit is contained in:
parent
199d52b39f
commit
0626081eee
@ -13,6 +13,8 @@ import { useActiveLog } from 'hooks/logs/useActiveLog';
|
|||||||
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
|
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
|
||||||
// hooks
|
// hooks
|
||||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||||
|
import { FlatLogData } from 'lib/logs/flatLogData';
|
||||||
|
import { isEmpty, isUndefined } from 'lodash-es';
|
||||||
import {
|
import {
|
||||||
KeyboardEvent,
|
KeyboardEvent,
|
||||||
MouseEvent,
|
MouseEvent,
|
||||||
@ -39,10 +41,13 @@ function RawLogView({
|
|||||||
data,
|
data,
|
||||||
linesPerRow,
|
linesPerRow,
|
||||||
isTextOverflowEllipsisDisabled,
|
isTextOverflowEllipsisDisabled,
|
||||||
|
selectedFields = [],
|
||||||
}: RawLogViewProps): JSX.Element {
|
}: RawLogViewProps): JSX.Element {
|
||||||
const { isHighlighted, isLogsExplorerPage, onLogCopy } = useCopyLogLink(
|
const { isHighlighted, isLogsExplorerPage, onLogCopy } = useCopyLogLink(
|
||||||
data.id,
|
data.id,
|
||||||
);
|
);
|
||||||
|
const flattenLogData = useMemo(() => FlatLogData(data), [data]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
activeLog: activeContextLog,
|
activeLog: activeContextLog,
|
||||||
onSetActiveLog: handleSetActiveContextLog,
|
onSetActiveLog: handleSetActiveContextLog,
|
||||||
@ -62,12 +67,31 @@ function RawLogView({
|
|||||||
|
|
||||||
const severityText = data.severity_text ? `${data.severity_text} |` : '';
|
const severityText = data.severity_text ? `${data.severity_text} |` : '';
|
||||||
|
|
||||||
|
const updatedSelecedFields = useMemo(
|
||||||
|
() => selectedFields.filter((e) => e.name !== 'id'),
|
||||||
|
[selectedFields],
|
||||||
|
);
|
||||||
|
|
||||||
|
const attributesValues = updatedSelecedFields
|
||||||
|
.map((field) => flattenLogData[field.name])
|
||||||
|
.filter((attribute) => !isUndefined(attribute) && !isEmpty(attribute));
|
||||||
|
|
||||||
|
let attributesText = attributesValues.join(' | ');
|
||||||
|
|
||||||
|
if (attributesText.length > 0) {
|
||||||
|
attributesText += ' | ';
|
||||||
|
}
|
||||||
|
|
||||||
const text = useMemo(
|
const text = useMemo(
|
||||||
() =>
|
() =>
|
||||||
typeof data.timestamp === 'string'
|
typeof data.timestamp === 'string'
|
||||||
? `${dayjs(data.timestamp).format()} | ${severityText} ${data.body}`
|
? `${dayjs(data.timestamp).format()} | ${attributesText} ${severityText} ${
|
||||||
: `${dayjs(data.timestamp / 1e6).format()} | ${severityText} ${data.body}`,
|
data.body
|
||||||
[data.timestamp, data.body, severityText],
|
}`
|
||||||
|
: `${dayjs(
|
||||||
|
data.timestamp / 1e6,
|
||||||
|
).format()} | ${attributesText} ${severityText} ${data.body}`,
|
||||||
|
[data.timestamp, data.body, severityText, attributesText],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleClickExpand = useCallback(() => {
|
const handleClickExpand = useCallback(() => {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { IField } from 'types/api/logs/fields';
|
||||||
import { ILog } from 'types/api/logs/log';
|
import { ILog } from 'types/api/logs/log';
|
||||||
|
|
||||||
export interface RawLogViewProps {
|
export interface RawLogViewProps {
|
||||||
@ -6,6 +7,7 @@ export interface RawLogViewProps {
|
|||||||
isTextOverflowEllipsisDisabled?: boolean;
|
isTextOverflowEllipsisDisabled?: boolean;
|
||||||
data: ILog;
|
data: ILog;
|
||||||
linesPerRow: number;
|
linesPerRow: number;
|
||||||
|
selectedFields?: IField[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RawLogContentProps {
|
export interface RawLogContentProps {
|
||||||
|
@ -70,7 +70,12 @@ function LiveLogsList({ logs }: LiveLogsListProps): JSX.Element {
|
|||||||
(_: number, log: ILog): JSX.Element => {
|
(_: number, log: ILog): JSX.Element => {
|
||||||
if (options.format === 'raw') {
|
if (options.format === 'raw') {
|
||||||
return (
|
return (
|
||||||
<RawLogView key={log.id} data={log} linesPerRow={options.maxLines} />
|
<RawLogView
|
||||||
|
key={log.id}
|
||||||
|
data={log}
|
||||||
|
linesPerRow={options.maxLines}
|
||||||
|
selectedFields={selectedFields}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,12 @@ function LogsExplorerList({
|
|||||||
(_: number, log: ILog): JSX.Element => {
|
(_: number, log: ILog): JSX.Element => {
|
||||||
if (options.format === 'raw') {
|
if (options.format === 'raw') {
|
||||||
return (
|
return (
|
||||||
<RawLogView key={log.id} data={log} linesPerRow={options.maxLines} />
|
<RawLogView
|
||||||
|
key={log.id}
|
||||||
|
data={log}
|
||||||
|
linesPerRow={options.maxLines}
|
||||||
|
selectedFields={selectedFields}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,14 @@ function LogsTable(props: LogsTableProps): JSX.Element {
|
|||||||
const log = logs[index];
|
const log = logs[index];
|
||||||
|
|
||||||
if (viewMode === 'raw') {
|
if (viewMode === 'raw') {
|
||||||
return <RawLogView key={log.id} data={log} linesPerRow={linesPerRow} />;
|
return (
|
||||||
|
<RawLogView
|
||||||
|
key={log.id}
|
||||||
|
data={log}
|
||||||
|
linesPerRow={linesPerRow}
|
||||||
|
selectedFields={selected}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -5,6 +5,7 @@ export const MaxLinesFieldWrapper = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin-bottom: 1.125rem;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const MaxLinesInput = styled(InputNumber)`
|
export const MaxLinesInput = styled(InputNumber)`
|
||||||
|
@ -31,9 +31,7 @@ function OptionsMenu({
|
|||||||
{selectedOptionFormat === OptionFormatTypes.RAW && config?.maxLines && (
|
{selectedOptionFormat === OptionFormatTypes.RAW && config?.maxLines && (
|
||||||
<MaxLinesField config={config.maxLines} />
|
<MaxLinesField config={config.maxLines} />
|
||||||
)}
|
)}
|
||||||
{(selectedOptionFormat === OptionFormatTypes.LIST ||
|
{config?.addColumn && <AddColumnField config={config.addColumn} />}
|
||||||
selectedOptionFormat === OptionFormatTypes.TABLE) &&
|
|
||||||
config?.addColumn && <AddColumnField config={config.addColumn} />}
|
|
||||||
</OptionsContentWrapper>
|
</OptionsContentWrapper>
|
||||||
),
|
),
|
||||||
[config, selectedOptionFormat],
|
[config, selectedOptionFormat],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user