Skip to content

Commit

Permalink
Fix #63 Left column adjustable in trace detail
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffon committed Sep 14, 2017
1 parent 2258205 commit dc8f2d4
Show file tree
Hide file tree
Showing 10 changed files with 425 additions and 100 deletions.
12 changes: 6 additions & 6 deletions src/components/TracePage/TraceTimelineViewer/SpanBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ function SpanBar(props) {
}

SpanBar.propTypes = {
color: PropTypes.string.isRequired,
hintSide: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
onClick: PropTypes.func,
viewEnd: PropTypes.number.isRequired,
viewStart: PropTypes.number.isRequired,
rpc: PropTypes.shape({
viewStart: PropTypes.number,
viewEnd: PropTypes.number,
color: PropTypes.string,
}),
viewStart: PropTypes.number.isRequired,
viewEnd: PropTypes.number.isRequired,
color: PropTypes.string.isRequired,
hintSide: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
onClick: PropTypes.func,
setLongLabel: PropTypes.func,
setShortLabel: PropTypes.func,
};
Expand Down
21 changes: 14 additions & 7 deletions src/components/TracePage/TraceTimelineViewer/SpanBarRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function SpanBarRow(props) {
const {
className,
color,
columnDivision,
depth,
isChildrenExpanded,
isDetailExapnded,
Expand All @@ -40,11 +41,11 @@ export default function SpanBarRow(props) {
label,
onDetailToggled,
onChildrenToggled,
numTicks,
operationName,
rpc,
serviceName,
showErrorIcon,
ticks,
viewEnd,
viewStart,
} = props;
Expand Down Expand Up @@ -75,7 +76,7 @@ export default function SpanBarRow(props) {
${isFilteredOut ? 'is-filtered-out' : ''}
`}
>
<TimelineRow.Left className="span-name-column">
<TimelineRow.Cell className="span-name-column" width={columnDivision}>
<div className="span-name-wrapper" title={title}>
<SpanTreeOffset
level={depth + 1}
Expand Down Expand Up @@ -108,9 +109,14 @@ export default function SpanBarRow(props) {
</span>
</a>
</div>
</TimelineRow.Left>
<TimelineRow.Right className="span-view" style={{ cursor: 'pointer' }} onClick={onDetailToggled}>
<Ticks ticks={ticks} />
</TimelineRow.Cell>
<TimelineRow.Cell
className="span-view"
style={{ cursor: 'pointer' }}
width={1 - columnDivision}
onClick={onDetailToggled}
>
<Ticks numTicks={numTicks} />
<SpanBar
rpc={rpc}
viewStart={viewStart}
Expand All @@ -120,14 +126,15 @@ export default function SpanBarRow(props) {
longLabel={longLabel}
hintSide={hintSide}
/>
</TimelineRow.Right>
</TimelineRow.Cell>
</TimelineRow>
);
}

SpanBarRow.propTypes = {
className: PropTypes.string,
color: PropTypes.string.isRequired,
columnDivision: PropTypes.number.isRequired,
depth: PropTypes.number.isRequired,
isChildrenExpanded: PropTypes.bool.isRequired,
isDetailExapnded: PropTypes.bool.isRequired,
Expand All @@ -137,6 +144,7 @@ SpanBarRow.propTypes = {
onDetailToggled: PropTypes.func.isRequired,
onChildrenToggled: PropTypes.func.isRequired,
operationName: PropTypes.string.isRequired,
numTicks: PropTypes.number.isRequired,
rpc: PropTypes.shape({
viewStart: PropTypes.number,
viewEnd: PropTypes.number,
Expand All @@ -146,7 +154,6 @@ SpanBarRow.propTypes = {
}),
serviceName: PropTypes.string.isRequired,
showErrorIcon: PropTypes.bool.isRequired,
ticks: PropTypes.arrayOf(PropTypes.number).isRequired,
viewEnd: PropTypes.number.isRequired,
viewStart: PropTypes.number.isRequired,
};
Expand Down
10 changes: 6 additions & 4 deletions src/components/TracePage/TraceTimelineViewer/SpanDetailRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import './SpanDetailRow.css';

type SpanDetailRowProps = {
color: string,
columnDivision: number,
detailState: DetailState,
detailToggle: string => void,
isFilteredOut: boolean,
Expand All @@ -46,6 +47,7 @@ type SpanDetailRowProps = {
export default function SpanDetailRow(props: SpanDetailRowProps) {
const {
color,
columnDivision,
detailState,
detailToggle,
isFilteredOut,
Expand All @@ -58,7 +60,7 @@ export default function SpanDetailRow(props: SpanDetailRowProps) {
} = props;
return (
<TimelineRow className={`detail-row ${isFilteredOut ? 'is-filtered-out' : ''}`}>
<TimelineRow.Left>
<TimelineRow.Cell width={columnDivision}>
<div className="detail-row-name-column">
<SpanTreeOffset level={span.depth + 1} />
<span>
Expand All @@ -69,8 +71,8 @@ export default function SpanDetailRow(props: SpanDetailRowProps) {
/>
</span>
</div>
</TimelineRow.Left>
<TimelineRow.Right>
</TimelineRow.Cell>
<TimelineRow.Cell width={1 - columnDivision}>
<div className="p2 detail-info-wrapper" style={{ borderTopColor: color }}>
<SpanDetail
detailState={detailState}
Expand All @@ -82,7 +84,7 @@ export default function SpanDetailRow(props: SpanDetailRowProps) {
traceStartTime={traceStartTime}
/>
</div>
</TimelineRow.Right>
</TimelineRow.Cell>
</TimelineRow>
);
}
69 changes: 42 additions & 27 deletions src/components/TracePage/TraceTimelineViewer/Ticks.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @flow

// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -18,39 +20,52 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import PropTypes from 'prop-types';
import React from 'react';
import * as React from 'react';

import { formatDuration } from './utils';

import './Ticks.css';

export default function Ticks(props) {
const { labels, ticks } = props;
type TicksProps = {
endTime: number,
numTicks: number,
showLabels?: boolean,
startTime: number,
};

export default function Ticks(props: TicksProps) {
const { endTime, numTicks, showLabels, startTime } = props;

let labels: string[];
if (showLabels) {
labels = [];
const viewingDuration = endTime - startTime;
for (let i = 0; i < numTicks; i++) {
const durationAtTick = startTime + i / (numTicks - 1) * viewingDuration;
labels.push(formatDuration(durationAtTick));
}
}
const ticks: React.Node[] = [];
for (let i = 0; i < numTicks; i++) {
const portion = i / (numTicks - 1);
ticks.push(
<div
key={portion}
className="span-row-tick"
style={{
left: `${portion * 100}%`,
}}
>
{labels &&
<span className={`span-row-tick-label ${portion >= 1 ? 'is-end-anchor' : ''}`}>
{labels[i]}
</span>}
</div>
);
}
return (
<div>
{ticks.map((tick, i) =>
<div
key={tick}
className="span-row-tick"
style={{
left: `${tick * 100}%`,
}}
>
{labels &&
<span className={`span-row-tick-label ${tick >= 1 ? 'is-end-anchor' : ''}`}>
{labels[i]}
</span>}
</div>
)}
{ticks}
</div>
);
}

Ticks.propTypes = {
ticks: PropTypes.arrayOf(PropTypes.number).isRequired,
labels: PropTypes.arrayOf(PropTypes.string),
};

Ticks.defaultProps = {
labels: null,
};
124 changes: 124 additions & 0 deletions src/components/TracePage/TraceTimelineViewer/TimelineHeaderRow.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
Copyright (c) 2017 Uber Technologies, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

.TimelineColumnResizer {
bottom: 0;
left: 0;
position: absolute;
right: 0;
top: 0;
}

.TimelineColumnResizer--wrapper {
bottom: 0;
position: absolute;
top: 0;
}

.TimelineColumnResizer--dragger {
border-left: 1px solid transparent;
bottom: 0;
cursor: ew-resize;
position: fixed;
top: 0;
width: 5px;
}

.TimelineColumnResizer--dragger:hover {
border-left: 1px solid #999;
}

.TimelineColumnResizer--wrapper.isDraggingLeft > .TimelineColumnResizer--dragger {
border-left: 1px solid #808;
/* #808 === rgb(136, 0, 136) */
background: rgba(136, 0, 136, 0.05);
}

/* .TimelineColumnResizer--dragger.isDraggingRight,
.TimelineColumnResizer--dragger.isDraggingRight:hover { */

.TimelineColumnResizer--wrapper.isDraggingRight > .TimelineColumnResizer--dragger {
border-right: 1px solid #808;
/* #808 === rgb(136, 0, 136) */
background: rgba(136, 0, 136, 0.03);
}

.TimelineColumnResizer--dragger::before {
position: absolute;
top: 0;
bottom: 0;
left: -8px;
right: -5px;
content: " ";
}

.TimelineColumnResizer--wrapper.isDraggingLeft > .TimelineColumnResizer--dragger::before,
.TimelineColumnResizer--wrapper.isDraggingRight > .TimelineColumnResizer--dragger::before {
left: -2000px;
right: -2000px;
}

.TimelineColumnResizer--gripIcon {
position: absolute;
top: 0;
bottom: 0;
}

.TimelineColumnResizer--gripIcon::before,
.TimelineColumnResizer--gripIcon::after {
position: absolute;
content: " ";
top: 60%;
bottom: 10%;
right: 8px;
border-right: 1px solid #ccc;
}

.TimelineColumnResizer--gripIcon::after {
right: 4px;
}

.TimelineColumnResizer--wrapper:hover > .TimelineColumnResizer--gripIcon::before,
.TimelineColumnResizer--wrapper:hover > .TimelineColumnResizer--gripIcon::after {
border-right: 1px solid #999;
}
.TimelineColumnResizer--wrapper.isDraggingLeft > .TimelineColumnResizer--gripIcon::before,
.TimelineColumnResizer--wrapper.isDraggingRight > .TimelineColumnResizer--gripIcon::before,
.TimelineColumnResizer--wrapper.isDraggingLeft > .TimelineColumnResizer--gripIcon::after,
.TimelineColumnResizer--wrapper.isDraggingRight > .TimelineColumnResizer--gripIcon::after {
border-right: 1px solid rgba(136, 0, 136, 0.5);
}

.TimelineHeaderRow {
background: #e8e8e8;
border-bottom: 1px solid #ccc;
height: 38px;
overflow: hidden;
position: fixed;
width: 100%;
z-index: 2;
}

.TimelineHeaderRow--title {
padding: 0.5rem;
white-space: nowrap;
}
Loading

0 comments on commit dc8f2d4

Please sign in to comment.