import React, { Component } from 'react'; import { connect } from 'react-redux'; import { getTasksAsync } from '../../../actions/tasks.actions'; import { Layout, Empty, Button, Modal, Col, Row } from 'antd'; import Title from 'antd/lib/typography/Title'; import './dashboard-content.scss'; const { Content } = Layout; const { confirm } = Modal; class DashboardContent extends Component { hostUrl: string | undefined; apiUrl: string | undefined; constructor(props: any) { super(props); this.state = {}; this.hostUrl = process.env.REACT_APP_API_HOST_URL; this.apiUrl = process.env.REACT_APP_API_FULL_URL; } render() { return( <> { this.props.tasks.length ? this.renderTasks() : this.renderPlaceholder() } ); } private renderPlaceholder() { return ( ) } private renderTasks() { return( { this.props.tasks.map( (task: any) => (
{ `${task.name}: ${task.mode}` } Task cover Jobs { task.jobs.map( (job: any) => ( {`${this.hostUrl}?id=${job.id}`} ) ) }
) ) }
); } private createTask = () => { console.log('Create task'); } private onUpdateTask = (task: any) => { console.log('Update task'); } private onDeleteTask = (task: any) => { const self = this; confirm({ title: 'Do you want to delete this task?', okText: 'Yes', okType: 'danger', centered: true, onOk(closeFunction: Function) { return task.delete().then( () => { self.props.dispatch(getTasksAsync()); closeFunction(); }, ); }, cancelText: 'No', onCancel() { return; }, }); } private onDumpAnnotation = () => { console.log('Dump annotatio'); } private onUploadAnnotation = () => { console.log('Upload annotation'); } } const mapStateToProps = (state: any) => { return state.tasks; }; export default connect(mapStateToProps)(DashboardContent);