@@ -12,6 +12,36 @@ import { fetchDbStats } from "redux/neurojson/neurojson.action";
1212import { DbStatsItem } from "redux/neurojson/types/neurojson.interface" ;
1313import { RootState } from "redux/store" ;
1414
15+ const iconStyle = {
16+ marginRight : 1 ,
17+ verticalAlign : "middle" ,
18+ color : Colors . lightGray ,
19+ fontSize : {
20+ xs : "2rem" ,
21+ sm : "2.5rem" ,
22+ } ,
23+ } ;
24+
25+ const numberTextStyle = {
26+ color : Colors . lightGreen ,
27+ fontWeight : "medium" ,
28+ textAlign : "center" ,
29+ fontSize : {
30+ xs : "1rem" ,
31+ sm : "1.4rem" ,
32+ } ,
33+ } ;
34+
35+ const labelTextStyle = {
36+ color : Colors . lightGreen ,
37+ fontWeight : "medium" ,
38+ textAlign : "center" ,
39+ fontSize : {
40+ xs : "0.6rem" ,
41+ sm : "0.9rem" ,
42+ } ,
43+ } ;
44+
1545// function for calculate links and size
1646const calculateLinksAndSize = ( dbStats : DbStatsItem [ ] | null ) => {
1747 if ( ! dbStats ) return { totalLinks : 0 , totalSizeTB : "0.00" } ;
@@ -46,6 +76,24 @@ const StatisticsBanner: React.FC = () => {
4676 dispatch ( fetchDbStats ( ) ) ;
4777 } , [ dispatch ] ) ;
4878
79+ const StatItem = ( {
80+ icon,
81+ number,
82+ label,
83+ } : {
84+ icon : React . ReactNode ;
85+ number : string ;
86+ label : string ;
87+ } ) => (
88+ < Box sx = { { display : "flex" , flexDirection : "row" , alignItems : "center" } } >
89+ < Box sx = { iconStyle } > { icon } </ Box >
90+ < Box >
91+ < Typography sx = { numberTextStyle } > { number } </ Typography >
92+ < Typography sx = { labelTextStyle } > { label } </ Typography >
93+ </ Box >
94+ </ Box >
95+ ) ;
96+
4997 return (
5098 < Box
5199 sx = { {
@@ -58,177 +106,35 @@ const StatisticsBanner: React.FC = () => {
58106 } }
59107 >
60108 { /* Databases */ }
61- < Box
62- sx = { {
63- display : "flex" ,
64- flexDirection : "row" ,
65- alignItems : "center" ,
66- } }
67- >
68- < StorageIcon
69- sx = { {
70- marginRight : 1 ,
71- verticalAlign : "middle" ,
72- color : Colors . lightGray ,
73- fontSize : "2.5rem" ,
74- } }
75- />
76- < Box >
77- < Typography
78- sx = { {
79- color : Colors . green ,
80- fontWeight : "bold" ,
81- textAlign : "center" ,
82- fontSize : "1.4rem" ,
83- } }
84- >
85- { databaseCount . toLocaleString ( ) }
86- </ Typography >
87- < Typography
88- sx = { {
89- color : Colors . green ,
90- fontWeight : "medium" ,
91- fontSize : "0.9rem" ,
92- textAlign : "center" ,
93- } }
94- >
95- Databases
96- </ Typography >
97- </ Box >
98- </ Box >
99-
109+ < StatItem
110+ icon = { < StorageIcon fontSize = "inherit" /> }
111+ number = { databaseCount . toLocaleString ( ) }
112+ label = "Databases"
113+ />
100114 { /* Datasets */ }
101- < Box sx = { { display : "flex" , flexDirection : "row" , alignItems : "center" } } >
102- < ContentPasteSearchIcon
103- sx = { {
104- marginRight : 1 ,
105- verticalAlign : "middle" ,
106- color : Colors . lightGray ,
107- fontSize : "2.5rem" ,
108- } }
109- />
110- < Box >
111- < Typography
112- sx = { {
113- color : Colors . green ,
114- fontWeight : "bold" ,
115- textAlign : "center" ,
116- fontSize : "1.4rem" ,
117- } }
118- >
119- { formatNumber ( datasetStat ?. num ) }
120- </ Typography >
121- < Typography
122- sx = { {
123- color : Colors . green ,
124- fontWeight : "medium" ,
125- fontSize : "0.9rem" ,
126- textAlign : "center" ,
127- } }
128- >
129- Datasets
130- </ Typography >
131- </ Box >
132- </ Box >
115+ < StatItem
116+ icon = { < ContentPasteSearchIcon fontSize = "inherit" /> }
117+ number = { formatNumber ( datasetStat ?. num ) }
118+ label = "Datasets"
119+ />
133120 { /* Subjects */ }
134- < Box sx = { { display : "flex" , flexDirection : "row" , alignItems : "center" } } >
135- < PeopleAltIcon
136- sx = { {
137- marginRight : 1 ,
138- verticalAlign : "middle" ,
139- color : Colors . lightGray ,
140- fontSize : "2.5rem" ,
141- } }
142- />
143- < Box >
144- < Typography
145- sx = { {
146- color : Colors . green ,
147- fontWeight : "bold" ,
148- textAlign : "center" ,
149- fontSize : "1.4rem" ,
150- } }
151- >
152- { formatNumber ( subjectStat ?. num ) }
153- </ Typography >
154- < Typography
155- sx = { {
156- color : Colors . green ,
157- fontWeight : "medium" ,
158- fontSize : "0.9rem" ,
159- textAlign : "center" ,
160- } }
161- >
162- Subjects
163- </ Typography >
164- </ Box >
165- </ Box >
121+ < StatItem
122+ icon = { < PeopleAltIcon fontSize = "inherit" /> }
123+ number = { formatNumber ( subjectStat ?. num ) }
124+ label = "Subjects"
125+ />
166126 { /* Links */ }
167- < Box sx = { { display : "flex" , flexDirection : "row" , alignItems : "center" } } >
168- < DatasetLinkedIcon
169- sx = { {
170- marginRight : 1 ,
171- verticalAlign : "middle" ,
172- color : Colors . lightGray ,
173- fontSize : "2.5rem" ,
174- } }
175- />
176- < Box >
177- < Typography
178- sx = { {
179- color : Colors . green ,
180- fontWeight : "bold" ,
181- textAlign : "center" ,
182- fontSize : "1.4rem" ,
183- } }
184- >
185- { totalLinks . toLocaleString ( ) ?? "-" }
186- </ Typography >
187- < Typography
188- sx = { {
189- color : Colors . green ,
190- fontWeight : "medium" ,
191- fontSize : "0.9rem" ,
192- textAlign : "center" ,
193- } }
194- >
195- Links
196- </ Typography >
197- </ Box >
198- </ Box >
127+ < StatItem
128+ icon = { < DatasetLinkedIcon fontSize = "inherit" /> }
129+ number = { formatNumber ( totalLinks ) }
130+ label = "Links"
131+ />
199132 { /* Size */ }
200- < Box sx = { { display : "flex" , flexDirection : "row" , alignItems : "center" } } >
201- < TopicIcon
202- sx = { {
203- marginRight : 1 ,
204- verticalAlign : "middle" ,
205- color : Colors . lightGray ,
206- fontSize : "2.5rem" ,
207- } }
208- />
209- < Box >
210- < Typography
211- sx = { {
212- color : Colors . green ,
213- fontWeight : "bold" ,
214- textAlign : "center" ,
215- fontSize : "1.4rem" ,
216- } }
217- >
218- { totalSizeTB ?? "-" } TB
219- </ Typography >
220- < Typography
221- sx = { {
222- color : Colors . green ,
223- fontWeight : "medium" ,
224- fontSize : "0.9rem" ,
225- textAlign : "center" ,
226- } }
227- >
228- Size
229- </ Typography >
230- </ Box >
231- </ Box >
133+ < StatItem
134+ icon = { < TopicIcon fontSize = "inherit" /> }
135+ number = { `${ totalSizeTB ?? "-" } TB` }
136+ label = "Size"
137+ />
232138 </ Box >
233139 ) ;
234140} ;
0 commit comments