Summary.tsx 3.53 KB
Newer Older
1
2
3
4
5
6
7
8
import * as React from 'react';
import Grid from 'material-ui/Grid';
import Paper from 'material-ui/Paper';
import Divider from 'material-ui/Divider';

import { Dataset } from 'model/dataset.model';
import { Creator, CreatorRole } from 'model/creator.model';
import { Partner } from 'model/partner.model';
Matija Obreza's avatar
Matija Obreza committed
9
import { PartnerLink } from 'ui/catalog/Links';
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

interface ISummaryProps extends React.ClassAttributes<any> {
    classes: any;
    dataset: Dataset;
    creators: Creator[];
    owner: Partner;
}

class Summary extends React.Component<ISummaryProps, any> {

    protected renderName = (creators) => {
        if (! creators || creators.length === 0) {
          return null;
        }

        const creator: Creator = creators.find((e) => e.role === CreatorRole.CONTACT);

        if (creator) {
            return `${creator.fullName}`;
        } else {
          return null;
        }
    }

    public render() {
Maxim Babichev's avatar
Maxim Babichev committed
35
        const { creators, dataset = new Dataset(), owner } = this.props;
36
37

        return (
Maxim Babichev's avatar
Maxim Babichev committed
38
            <Paper square>
Maxim Babichev's avatar
Maxim Babichev committed
39
                <div className="pl-20 pr-20 pt-20 pb-20">
Maxim Babichev's avatar
Maxim Babichev committed
40
                    <h4 className="green font-bold m-0" style={ { fontSize: '1.286rem' } }>
41
                        SUMMARY
Maxim Babichev's avatar
Maxim Babichev committed
42
                    </h4>
43
44
                </div>
                <Divider/>
Maxim Babichev's avatar
Maxim Babichev committed
45
46
                <div>
                    <Grid container spacing={ 0 } className="pt-20 pb-10">
47
                        <Grid item xs={ 12 }>
Maxim Babichev's avatar
Maxim Babichev committed
48
                            <div className="pt-15 pb-15 pl-20 pr-20 mb-10 even-row">
Maxim Babichev's avatar
Maxim Babichev committed
49
                                <h4 className="font-bold mb-15">
Matija Obreza's avatar
Matija Obreza committed
50
                                    Number of accessions assessed in the dataset
Maxim Babichev's avatar
Maxim Babichev committed
51
                                </h4>
Matija Obreza's avatar
Matija Obreza committed
52
                                <h1 className="font-bold m-0">
53
                                    { dataset.accessionCount }
Maxim Babichev's avatar
Maxim Babichev committed
54
                                </h1>
55
56
57
                            </div>
                        </Grid>
                        <Grid item xs={ 12 }>
Maxim Babichev's avatar
Maxim Babichev committed
58
                            <div className="pt-15 pb-15 pl-20 pr-20 mb-10 even-row">
Maxim Babichev's avatar
Maxim Babichev committed
59
                                <h4 className="font-bold mb-15">
Matija Obreza's avatar
Matija Obreza committed
60
                                    Number of traits observed in the dataset
Maxim Babichev's avatar
Maxim Babichev committed
61
                                </h4>
Matija Obreza's avatar
Matija Obreza committed
62
                                <h1 className="font-bold m-0">
63
                                    { dataset.descriptorCount }
Maxim Babichev's avatar
Maxim Babichev committed
64
                                </h1>
65
66
67
                            </div>
                        </Grid>
                        <Grid item xs={ 12 }>
Maxim Babichev's avatar
Maxim Babichev committed
68
                            <div className="pt-15 pb-15 pl-20 pr-20 mb-10 even-row">
Maxim Babichev's avatar
Maxim Babichev committed
69
                                <h4 className="font-bold mb-15">
70
                                    Data provider
Maxim Babichev's avatar
Maxim Babichev committed
71
                                </h4>
Maxim Babichev's avatar
Maxim Babichev committed
72
                                <h6 className="font-bold m-0">
Matija Obreza's avatar
Matija Obreza committed
73
                                    <PartnerLink to={ owner } />
Maxim Babichev's avatar
Maxim Babichev committed
74
                                </h6>
75
76
77
                            </div>
                        </Grid>
                        <Grid item xs={ 12 }>
Maxim Babichev's avatar
Maxim Babichev committed
78
                            <div className="pt-15 pb-15 pl-20 pr-20 mb-10 even-row">
Maxim Babichev's avatar
Maxim Babichev committed
79
                                <h4 className="font-bold mb-15">
80
                                    Contact
Maxim Babichev's avatar
Maxim Babichev committed
81
                                </h4>
Maxim Babichev's avatar
Maxim Babichev committed
82
                                <h6 className="">
83
                                    { this.renderName(creators) }
Maxim Babichev's avatar
Maxim Babichev committed
84
                                </h6>
85
86
87
88
89
90
91
92
93
                            </div>
                        </Grid>
                    </Grid>
                </div>
            </Paper>
        );
    }
}

Maxim Babichev's avatar
Maxim Babichev committed
94
export default Summary;