Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Edit list of statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
Zelofff committed Mar 2, 2018
1 parent 8f06ed4 commit 2b7a6a5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
32 changes: 25 additions & 7 deletions frontend/src/components/ListOfStatuses.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
import React from 'react';
import PropTypes from 'prop-types';
import { updateTask } from '../utils';
import '../styles/ListOfStatuses.css';

import { ListGroup, Badge, Label, Well } from 'react-bootstrap';
import { ListGroup, Badge, Label, Well, ProgressBar, } from 'react-bootstrap';

const ListOfStatuses = ({ statuses, ...props }) => {
return (
<ListGroup {...props}>
{statuses.map(task => {
const bsStyle = task.status === 'in_progress' ? 'warning' : task.status === 'failed' ? 'danger' : task.status;
const status = task.status === 'in_progress' ? 'Загружается' : task.status === 'failed' ? 'Ошибка' : 'Успешно';
const date = new Date(task.uploaded_at).toLocaleString();
const newTask = updateTask(task);

return (
<div
key={task.id}
>
<Label bsStyle={bsStyle}>{status}</Label>
<Well >
Записей загружено: {task.uploaded_records}
<Badge pullRight>{date}</Badge>
<Label bsStyle="info">{task.exchange}</Label>
<Well>
<ProgressBar>
<ProgressBar
striped
active={task.status === 'in_progress'}
now={newTask.uploadStatus}
bsStyle={newTask.uploadBsStyle}
label={'Загрузка файла'}
/>
<ProgressBar
striped
active={task.status === 'in_progress'}
now={newTask.parseStatus}
bsStyle={newTask.parseBsStyle}
label={'Парсинг файла'}
/>
</ProgressBar>
<div>
Записей загружено: {task.uploaded_records}
<Badge pullRight>{date}</Badge>
</div>
</Well>
</div>
)
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,18 @@ export function createDiagramConfig(data, title, name) {
}
}

export function updateTask(task) {
const uploadStatus = task.update_profit_status === 'in_progress' ? 25 : 50;
const parseStatus = task.parse_status === 'in_progress' ? 25 : 50;
const uploadBsStyle = task.update_profit_status === 'in_progress' ? 'waning' : task.update_profit_status === 'success' ? 'success' : 'danger';
const parseBsStyle = task.parse_status === 'in_progress' ? 'waning' : task.parse_status === 'success' ? 'success' : 'danger';

return {
uploadStatus,
parseStatus,
uploadBsStyle,
parseBsStyle
}
}

// todo: Fully redo all Chart data sorting, selecting etc.

0 comments on commit 2b7a6a5

Please sign in to comment.