Skip to content

Commit

Permalink
feat(Tracking): display traking info progress bar
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #74

fix

fix store log
  • Loading branch information
rahmonzoda committed Sep 3, 2018
1 parent 9b0c93b commit 1995497
Show file tree
Hide file tree
Showing 15 changed files with 302 additions and 26 deletions.
Expand Up @@ -11,6 +11,7 @@ import {
} from 'time-util';

import {
Percentage,
ProgressBarContainer,
} from './styled';

Expand All @@ -26,27 +27,34 @@ type Props = {
const ProgressBar: StatelessFunctionalComponent<Props> = ({
remaining,
loggedTotal,
}: Props): Node => (
<ProgressBarContainer>
{remaining > 0 &&
}: Props): Node => {
const percentage = Math.round((loggedTotal / (loggedTotal + remaining)) * 100);

return (
<ProgressBarContainer>
{remaining > 0 &&
<ProgressBarFill
name="remaining"
label="Remaining"
width={100}
color="#FFAB00"
time={stj(remaining)}
style={{ alignItems: 'flex-end' }}
/>
}
<ProgressBarFill
name="remaining"
label="Remaining"
width={100}
color="#FFAB00"
time={stj(remaining)}
style={{ alignItems: 'flex-end' }}
name="logged-total"
width={percentage}
label="Logged"
color="#B2D4FF"
time={stj(loggedTotal)}
style={(remaining === 0) ? { alignItems: 'flex-end' } : { alignItems: 'flex-start' }}
/>
}
<ProgressBarFill
name="logged-total"
width={(loggedTotal / (loggedTotal + remaining)) * 100}
label="Logged"
color="#B2D4FF"
time={stj(loggedTotal)}
style={(remaining === 0) ? { alignItems: 'flex-end' } : { alignItems: 'flex-start' }}
/>
</ProgressBarContainer>
);
{remaining > 0 &&
<Percentage>{percentage}%</Percentage>
}
</ProgressBarContainer>
);
};

export default ProgressBar;
Expand Up @@ -2,7 +2,7 @@
import styled from 'styled-components';

export const ProgressBarContainer = styled.div`
width: 94%;
width: 92%;
position: relative;
`;

Expand Down Expand Up @@ -39,3 +39,11 @@ export const TimeLabel = styled.span`
color: rgba(225, 225, 225, .7);
font-size: 10px;
`;

export const Percentage = styled.span`
color: rgba(225, 225, 225, .7);
font-size: 10px;
position: absolute;
right: -26px;
top: 20px;
`;
@@ -0,0 +1,86 @@
// @flow
import React from 'react';
import Tooltip from '@atlaskit/tooltip';

import type {
StatelessFunctionalComponent,
Node,
} from 'react';

import {
CircleStop,
CircleProgress,
CircleBackground,
} from './styled';

type Props = {
content?: Node,
percentage?: number,
onClick: () => {},
};

const CircularProgressBar: StatelessFunctionalComponent<Props> = ({
content,
percentage,
onClick,
}: Props): Node => {
// options
const sqSize = 60;
const strokeWidth = 5;

// SVG centers the stroke width on the radius, subtract out so circle fits in square
const radius = (sqSize - strokeWidth) / 2;
// Enclose cicle in a circumscribing square
const viewBox = `0 0 ${sqSize} ${sqSize}`;
// Arc length at 100% coverage is the circle circumference
const dashArray = radius * Math.PI * 2;
// Scale 100% coverage overlay with the actual percent
const dashOffset = dashArray - ((dashArray * percentage) / 100);

return (
<Tooltip
content={content}
position="left"
delay={200}
>
<svg
width={sqSize}
height={sqSize}
viewBox={viewBox}
onClick={onClick}
>
<CircleBackground
cx={sqSize / 2}
cy={sqSize / 2}
r={radius}
strokeWidth={`${strokeWidth}px`}
/>
<CircleProgress
cx={sqSize / 2}
cy={sqSize / 2}
r={radius}
strokeWidth={`${strokeWidth}px`}
transform={`rotate(-90 ${sqSize / 2} ${sqSize / 2})`}
style={{
strokeDasharray: dashArray,
strokeDashoffset: dashOffset,
}}
/>
<CircleStop
x="20"
y="20"
rx="1"
width="20"
height="20"
/>
</svg>
</Tooltip>
);
};

CircularProgressBar.defaultProps = {
content: null,
percentage: 0,
};

export default CircularProgressBar;
61 changes: 61 additions & 0 deletions app/containers/IssueView/TrackingBar/ProgressBar/ProgressBar.jsx
@@ -0,0 +1,61 @@
// @flow
import React from 'react';

import type {
StatelessFunctionalComponent,
Node,
} from 'react';
import type {
IssuesReports,
} from 'types';

import {
stj,
} from 'time-util';

import {
ProgressBarContainer,
} from './styled';

import CircularProgressBar from './CircularProgressBar';

type Props = {
time: number,
report: IssuesReports,
showLoggedOnStop: boolean,
onClick: () => {},
};

// eslint-disable-next-line
const ProgressBar: StatelessFunctionalComponent<Props> = ({
time,
report,
showLoggedOnStop,
onClick,
}: Props): Node => {
const { loggedTotal, originalestimate, remaining } = report;

let content = '';
let percentage = 0;
if (remaining > 0) {
percentage = Math.round(((loggedTotal + time) / originalestimate) * 100);
content = showLoggedOnStop ? `${stj(loggedTotal + time)} / ${percentage}%` : '';

if (percentage > 100) {
percentage = 100;
}
}

return (
<ProgressBarContainer>
<CircularProgressBar
percentage={percentage}
content={content}
onClick={onClick}
/>
</ProgressBarContainer>
);
};

export default ProgressBar;
33 changes: 33 additions & 0 deletions app/containers/IssueView/TrackingBar/ProgressBar/styled/index.jsx
@@ -0,0 +1,33 @@
/* eslint-disable no-confusing-arrow */
import styled from 'styled-components';
import {
Flex,
} from 'components';

export const ProgressBarContainer = styled(Flex).attrs({
alignCenter: true,
})`
position: absolute;
right: 20px;
bottom: 6px
cursor: pointer;
`;

export const CircleBackground = styled.circle`
fill: #172B4D;
stroke: white;
cursor: pointer;
`;

export const CircleProgress = styled.circle`
fill: none;
stroke: #FFAB00;
stroke-linecap: round;
stroke-linejoin: round;
cursor: pointer;
`;

export const CircleStop = styled.rect`
fill: white;
cursor: pointer;
`;
17 changes: 14 additions & 3 deletions app/containers/IssueView/TrackingBar/TrackingBar.jsx
Expand Up @@ -15,12 +15,15 @@ import type {
import type {
Issue,
Dispatch,
IssuesReports,
RemainingEstimate,
} from 'types';

import {
getUiState,
getSettingsState,
getTrackingIssue,
getTrackingIssueReport,
getTimerState,
} from 'selectors';
import {
Expand All @@ -37,17 +40,18 @@ import CameraIcon from '@atlaskit/icon/glyph/camera';
import Tooltip from '@atlaskit/tooltip';

import WorklogCommentDialog from './WorklogCommentDialog';
import ProgressBar from './ProgressBar/ProgressBar';
import {
IssueName,
Dot,
Time,
StopButton,
Container,
} from './styled';


type Props = {
time: number,
report: IssuesReports,
screenshotUploading: boolean,
screenshotsAllowed: boolean,
trackingIssue: Issue,
Expand All @@ -57,6 +61,7 @@ type Props = {
remainingEstimateReduceByValue: string,
dispatch: Dispatch,
isCommentDialogOpen: boolean,
showLoggedOnStop: boolean,
}

function addLeadingZero(s: number): string {
Expand All @@ -73,6 +78,7 @@ function getTimeString(time: number): string {

const TrackingBar: StatelessFunctionalComponent<Props> = ({
time,
report,
screenshotUploading,
screenshotsAllowed,
trackingIssue,
Expand All @@ -82,6 +88,7 @@ const TrackingBar: StatelessFunctionalComponent<Props> = ({
remainingEstimateReduceByValue,
dispatch,
isCommentDialogOpen,
showLoggedOnStop,
}: Props): Node => (
<Transition
appear
Expand Down Expand Up @@ -144,8 +151,10 @@ const TrackingBar: StatelessFunctionalComponent<Props> = ({
</Time>
</Flex>
<div className="worklog-edit-popup-shouldNotCLose">
<StopButton
alt="stop"
<ProgressBar
time={time}
report={report}
showLoggedOnStop={showLoggedOnStop}
onClick={() => {
if (screenshotUploading) {
// eslint-disable-next-line no-alert
Expand All @@ -165,6 +174,7 @@ const TrackingBar: StatelessFunctionalComponent<Props> = ({
function mapStateToProps(state) {
return {
time: getTimerState('time')(state),
report: getTrackingIssueReport(state),
screenshotUploading: false,
screenshotsAllowed: false,
trackingIssue: getTrackingIssue(state),
Expand All @@ -173,6 +183,7 @@ function mapStateToProps(state) {
remainingEstimateNewValue: getUiState('remainingEstimateNewValue')(state),
remainingEstimateReduceByValue: getUiState('remainingEstimateReduceByValue')(state),
isCommentDialogOpen: getUiState('isCommentDialogOpen')(state),
showLoggedOnStop: getSettingsState('localDesktopSettings')(state).showLoggedOnStop,
};
}

Expand Down
1 change: 1 addition & 0 deletions app/containers/IssueView/TrackingBar/styled/index.jsx
Expand Up @@ -6,6 +6,7 @@ import { stop, stopHover } from 'data/svg';
// background: #172B4D !important;
// background: linear-gradient(to right, rgb(255, 209, 72), rgb(255, 204, 77)) !important;
export const Container = styled.div`
position: relative;
display: flex;
flex-direction: row;
justify-content: space-between;
Expand Down

0 comments on commit 1995497

Please sign in to comment.