Skip to content

Commit

Permalink
add adjustProgress function
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahd93 committed Sep 10, 2019
1 parent 12d98fa commit e46f5d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
18 changes: 12 additions & 6 deletions gsa/src/web/components/bar/progressbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ const Content = styled.div`
}
`;

export const adjustProgress = progress => {
if (parseInt(progress) > 100) {
progress = '100';
}
if (parseInt(progress) < 0) {
progress = '0';
}
return progress;
};

const Progress = styled.div`
height: 13px;
Expand All @@ -77,12 +87,8 @@ const Progress = styled.div`
background = 'gray';
}
if (progress > 100) {
progress = 100;
}
if (progress < 0) {
progress = 0;
}
progress = adjustProgress(progress);
return {
width: progress + '%',
background,
Expand Down
8 changes: 2 additions & 6 deletions gsa/src/web/components/bar/statusbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@ import {getTranslatableTaskStatus, TASK_STATUS} from 'gmp/models/task';

import PropTypes from 'web/utils/proptypes.js';

import ProgressBar from './progressbar';
import ProgressBar, {adjustProgress} from './progressbar';

const Span = styled.span`
white-space: nowrap;
`;

const StatusBar = ({status = 'Unknown', progress = '0'}) => {
if (progress > 100) {
progress = 100;
} else if (progress < 0) {
progress = 0;
}
progress = adjustProgress(progress);

let text = getTranslatableTaskStatus(status);
if (
Expand Down

0 comments on commit e46f5d9

Please sign in to comment.