-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathSummary.jsx
More file actions
173 lines (168 loc) · 5.5 KB
/
Summary.jsx
File metadata and controls
173 lines (168 loc) · 5.5 KB
1
2
3
4
5
6
7
8
9
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
'use client';
import HeatMap from './Charts/HeatMap';
import MultiLine from './Charts/MultiLine';
import HorizontalBar from './Charts/HorizontalBar';
import SimpleList from './Charts/SimpleList';
import Image from 'next/image';
import PunchCard from './Charts/PunchCard';
import { useRouter } from 'next/navigation';
import { formatNumber } from '@/utils/utils';
import Link from 'next/link';
import {
ArrowTopRightOnSquareIcon,
} from '@heroicons/react/20/solid';
function formatQuantityForInstallationsPerManager(value) {
return `${Math.round(value / 1000000)}M`
};
export default function Summary({
packages,
recent_releases,
emerging_repos,
needing_refresh,
hot_packages,
installations_per_installer
}) {
const router = useRouter();
const total_top_downloads = packages[1]
.map((p) => p.c)
.reduce((ps, a) => {
return Number(ps) + Number(a);
}, 0);
const total_hot_downloads = hot_packages[1]
.map((p) => p.z)
.reduce((ps, a) => {
return Number(ps) + Number(a);
}, 0);
return (
<div className='flex flex-col grow xl:grid xl:grid-cols-6 gap-6 min-w-[360px] mb-16'>
<div className='xl:col-span-3 h-[360px]'>
<HeatMap
data={recent_releases[1]}
title={
<div className='flex space-x-2'>
<Image alt='recent' src='/recent.svg' width={20} height={20} />
<span className='text-white font-bold space-x-0.5'>
Recent releases
</span>
</div>
}
subtitle={'On popular packages'}
onClick={(value) => {
router.push(`/dashboard/${value[1]}`);
}}
link={recent_releases[0]}
/>
</div>
<div className='justify-self align-self xl:col-span-3 h-[360px]'>
<HorizontalBar
data={packages[1]
.map((p) => {
return { x: p.project, y: p.c, name: 'counts' };
})}
header={
<div className='px-6 pt-4 pb-0 flex-row flex justify-between items-end'>
<div className='flex space-x-2'>
<Image alt='recent' src='/popular.svg' width={20} height={20} />
<span className='text-white font-bold space-x-0.5'>
Top Repos
</span>
</div>
<div className='flex flex-row justify-center items-center'>
<p
className={
'transition-all duration-300 ease-in-out hover:shadow-xl text-neutral-500 text-sm'
}>
{`${formatNumber(total_top_downloads)} downloads`}
</p>
<Link href={packages[0]} target='_blank' className='w-4 ml-2'>
<ArrowTopRightOnSquareIcon className='h-4 w-4 flex-none icon-hover' aria-hidden='true'/>
</Link>
</div>
</div>
}
onClick={(value) => {
router.push(`/dashboard/${value}`);
}}
/>
</div>
<div className='xl:col-span-2'>
<SimpleList
link_prefix={'/dashboard/'}
data={emerging_repos[1].map((p) => {
return {
title: p.name,
subtitle: `${formatNumber(
Number(p.c)
)} downloads in the last 3 months`
};
})}
title={
<div className='flex space-x-2'>
<Image alt='recent' src='/emerging.svg' width={20} height={20} />
<span className='text-white font-bold space-x-0.5'>
Emerging repos
</span>
</div>
}
subtitle={`Top ${emerging_repos[1].length}`}
link = {emerging_repos[0]}
/>
</div>
<div className='xl:col-span-2'>
<SimpleList
link_prefix={'/dashboard/'}
data={needing_refresh[1].map((p) => {
return {
title: p.name,
subtitle: `${formatNumber(
Number(p.c)
)} downloads, last updated on ${p.last_updated}`
};
})}
title={
<div className='flex space-x-2'>
<Image alt='recent' src='/refresh.svg' width={20} height={20} />
<span className='text-white font-bold space-x-0.5'>
Stable packages
</span>
</div>
}
subtitle={`Top ${needing_refresh[1].length}`}
link = {needing_refresh[0]}
/>
</div>
<div className='xl:col-span-2'>
<PunchCard
data={hot_packages[1]}
title={
<div className='flex space-x-2'>
<Image alt='recent' src='/hot.svg' width={20} height={20} />
<span className='text-white font-bold space-x-0.5'>
Hot packages
</span>
</div>
}
subtitle={`${formatNumber(total_hot_downloads)} downloads`}
stack={true}
labelMargin={200}
onClick={(value) => {
router.push(`/dashboard/${value[1]}`);
}}
scale='log'
link = {hot_packages[0]}
/>
</div>
<div className='xl:col-span-6 h-[360px]'>
<p className='text-2xl font-bold mb-5'>
Downloads by package manager over time
</p>
<MultiLine
link={installations_per_installer[0]}
data={installations_per_installer[1]}
disableBrush={true}
formatYAxis={formatQuantityForInstallationsPerManager}
/>
</div>
</div>
);
}