diff --git a/ui/src/logs/components/LogsTable.tsx b/ui/src/logs/components/LogsTable.tsx index 3c2c6d0880..fa5f6579c0 100644 --- a/ui/src/logs/components/LogsTable.tsx +++ b/ui/src/logs/components/LogsTable.tsx @@ -6,13 +6,13 @@ import {Grid, AutoSizer, InfiniteLoader} from 'react-virtualized' import {color} from 'd3-color' import FancyScrollbar from 'src/shared/components/FancyScrollbar' +import ExpandableMessage from 'src/logs/components/expandable_message/ExpandableMessage' import {getDeep} from 'src/utils/wrappers' import {colorForSeverity} from 'src/logs/utils/colors' import { ROW_HEIGHT, calculateRowCharWidth, - calculateMessageHeight, getColumnFromData, getValueFromData, getValuesFromData, @@ -73,13 +73,11 @@ interface State { visibleColumnsCount: number } -const calculateScrollTop = (currentMessageWidth, data, scrollToRow) => { - const rowCharLimit = calculateRowCharWidth(currentMessageWidth) - +const calculateScrollTop = scrollToRow => { return _.reduce( _.range(0, scrollToRow), - (acc, index) => { - return acc + calculateMessageHeight(index, data, rowCharLimit) + acc => { + return acc + ROW_HEIGHT }, 0 ) @@ -110,7 +108,7 @@ class LogsTable extends Component { } if (scrollToRow) { - scrollTop = calculateScrollTop(currentMessageWidth, data, scrollToRow) + scrollTop = calculateScrollTop(scrollToRow) } const scrollLeft = _.get(state, 'scrollLeft', 0) @@ -245,6 +243,7 @@ class LogsTable extends Component { autoHide={false} > { const result: any = { width, height, - rowHeight: this.calculateRowHeight, rowCount: this.rowCount(), scrollLeft, scrollTop, @@ -449,19 +447,13 @@ class LogsTable extends Component { return _.reduce( data, - (acc, __, index) => { - return ( - acc + - calculateMessageHeight(index, this.props.data, this.rowCharLimit) - ) + (acc, __) => { + return acc + ROW_HEIGHT }, 0 ) } - private calculateRowHeight = ({index}: {index: number}): number => - calculateMessageHeight(index, this.props.data, this.rowCharLimit) - private headerRenderer = ({key, style, columnIndex}) => { const column = getColumnFromData(this.props.data, columnIndex) const classes = 'logs-viewer--cell logs-viewer--cell-header' @@ -527,6 +519,10 @@ class LogsTable extends Component { title = formattedValue } + if (column === 'message') { + formattedValue = + } + const highlightRow = rowIndex === this.state.currentRow if (column === 'timestamp') { diff --git a/ui/src/logs/components/expandable_message/ExpandableMessage.scss b/ui/src/logs/components/expandable_message/ExpandableMessage.scss new file mode 100644 index 0000000000..a2430912fb --- /dev/null +++ b/ui/src/logs/components/expandable_message/ExpandableMessage.scss @@ -0,0 +1,46 @@ +/* + ExpandableMessage + ----------------------------------------------------------------------------- +*/ + +@import 'src/style/modules/influx-colors'; +@import 'src/style/modules/mixins'; +@import 'src/style/modules/variables'; + +.expandable--message { + display: flex; + min-height: 100%; + min-width: 100%; + align-items: center; + cursor: pointer; + + .expandable--text { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + display: block; + pointer-events: none; + } +} + +.collapsed--message { + display: none; +} + +.expanded--message { + display: block; + box-sizing: border-box; + position: absolute; + top: 0; + white-space: pre-wrap; + padding: $ix-marg-c; + width: 100%; + max-height: 300px; + overflow-y: auto; + background-color: $g5-pepper; + z-index: 100; + @extend %drop-shadow; + color: $g19-ghost; + border-radius: $radius; + cursor: text; +} \ No newline at end of file diff --git a/ui/src/logs/components/expandable_message/ExpandableMessage.tsx b/ui/src/logs/components/expandable_message/ExpandableMessage.tsx new file mode 100644 index 0000000000..1abced48ee --- /dev/null +++ b/ui/src/logs/components/expandable_message/ExpandableMessage.tsx @@ -0,0 +1,59 @@ +import React, {Component} from 'react' + +import './ExpandableMessage.scss' +import {ClickOutside} from 'src/shared/components/ClickOutside' + +interface State { + expanded: boolean +} + +interface Props { + formattedValue: string | JSX.Element +} + +export class ExpandableMessage extends Component { + constructor(props) { + super(props) + this.state = { + expanded: false, + } + } + + public render() { + const {formattedValue} = this.props + + return ( + + <> +
+
{formattedValue}
+
{formattedValue}
+
+ +
+ ) + } + + private get isExpanded() { + const {expanded} = this.state + if (expanded) { + return 'expanded--message' + } else { + return 'collapsed--message' + } + } + + private expand = () => { + this.setState({ + expanded: true, + }) + } + + private collapse = () => { + this.setState({ + expanded: false, + }) + } +} + +export default ExpandableMessage diff --git a/ui/src/style/pages/logs-viewer.scss b/ui/src/style/pages/logs-viewer.scss index 58adea4ea7..463d84f001 100644 --- a/ui/src/style/pages/logs-viewer.scss +++ b/ui/src/style/pages/logs-viewer.scss @@ -232,10 +232,6 @@ $logs-viewer-gutter: 60px; margin-right: 10px; } -.message--cell { - word-break: break-all; -} - // Table Cell Styles .logs-viewer--cell { font-size: 12px;