Skip to content

Commit 398e3b7

Browse files
added loader for dashboard stats.
1 parent 40f0d3f commit 398e3b7

File tree

1 file changed

+61
-52
lines changed

1 file changed

+61
-52
lines changed

src/ui/layouts/Home.tsx

Lines changed: 61 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
icons,
1616
GhostButton,
1717
Paragraph,
18+
FullWidthSpinner,
1819
} from '../components';
1920
import { getTranslateByScope } from '../../services';
2021

@@ -66,11 +67,13 @@ export const Home: React.FC = () => {
6667
const stackComponentsTypes: any[] = useSelector(
6768
stackComponentSelectors.stackComponentTypes,
6869
);
70+
const [fetching, setFetching] = useState(false);
6971
const [dashboardData, setDashboardData] = useState('');
7072
const authToken = useSelector(sessionSelectors.authenticationToken);
7173

7274
useEffect(() => {
7375
const getDashboardData = async () => {
76+
setFetching(true);
7477
const { data } = await axios.get(
7578
`${process.env.REACT_APP_BASE_API_URL}/projects/${DEFAULT_PROJECT_NAME}/statistics`,
7679
{
@@ -79,7 +82,9 @@ export const Home: React.FC = () => {
7982
},
8083
},
8184
);
85+
8286
setDashboardData(data);
87+
setFetching(false);
8388
};
8489
getDashboardData();
8590
}, [authToken]);
@@ -114,62 +119,66 @@ export const Home: React.FC = () => {
114119
<H4 bold>{translate('subtitle')}</H4>
115120
</Box>
116121
</Col>
117-
<Row style={{ alignItems: 'center', marginLeft: '15px' }}>
118-
{data?.map((e, index) => (
119-
<Box
120-
onMouseEnter={() => handleMouseEnter(e)}
121-
onMouseLeave={handleMouseLeave}
122-
key={index}
123-
marginRight="xxl"
124-
style={{
125-
width: '220px',
126-
minHeight: '100px',
127-
border: '1px solid #C9CBD0',
128-
borderRadius: '6px',
129-
padding: '13px 14px',
130-
marginTop: '10px',
131-
cursor: 'pointer',
132-
backgroundColor:
133-
box === e.text && isHover ? '#431D93' : '#fff',
134-
}}
135-
onClick={() => {
136-
if (e.text === 'stacks') {
137-
push(routePaths.stacks.base);
138-
} else if (e.text === 'pipelines') {
139-
push(routePaths.pipelines.base);
140-
} else if (e.text === 'runs') {
141-
push(routePaths.pipelines.allRuns);
142-
} else if (e.text === 'components') {
143-
push(
144-
routePaths.stackComponents.base(
145-
stackComponentsTypes[0],
146-
),
147-
);
148-
}
149-
}}
150-
>
151-
<Paragraph
122+
{fetching ? (
123+
<FullWidthSpinner color="black" size="md" />
124+
) : (
125+
<Row style={{ alignItems: 'center', marginLeft: '15px' }}>
126+
{data?.map((e, index) => (
127+
<Box
128+
onMouseEnter={() => handleMouseEnter(e)}
129+
onMouseLeave={handleMouseLeave}
130+
key={index}
131+
marginRight="xxl"
152132
style={{
153-
fontSize: '24px',
154-
fontWeight: 'bold',
155-
color: box === e.text ? '#fff' : '#431D93',
133+
width: '220px',
134+
minHeight: '100px',
135+
border: '1px solid #C9CBD0',
136+
borderRadius: '6px',
137+
padding: '13px 14px',
138+
marginTop: '10px',
139+
cursor: 'pointer',
140+
backgroundColor:
141+
box === e.text && isHover ? '#431D93' : '#fff',
156142
}}
157-
>
158-
{e.value}
159-
</Paragraph>
160-
<Paragraph
161-
style={{
162-
fontSize: '14px',
163-
fontWeight: 'inherit',
164-
color: box === e.text ? '#fff' : '#646972',
165-
marginTop: '38px',
143+
onClick={() => {
144+
if (e.text === 'stacks') {
145+
push(routePaths.stacks.base);
146+
} else if (e.text === 'pipelines') {
147+
push(routePaths.pipelines.base);
148+
} else if (e.text === 'runs') {
149+
push(routePaths.pipelines.allRuns);
150+
} else if (e.text === 'components') {
151+
push(
152+
routePaths.stackComponents.base(
153+
stackComponentsTypes[0],
154+
),
155+
);
156+
}
166157
}}
167158
>
168-
Number of {e.text}
169-
</Paragraph>
170-
</Box>
171-
))}
172-
</Row>
159+
<Paragraph
160+
style={{
161+
fontSize: '24px',
162+
fontWeight: 'bold',
163+
color: box === e.text ? '#fff' : '#431D93',
164+
}}
165+
>
166+
{e.value}
167+
</Paragraph>
168+
<Paragraph
169+
style={{
170+
fontSize: '14px',
171+
fontWeight: 'inherit',
172+
color: box === e.text ? '#fff' : '#646972',
173+
marginTop: '38px',
174+
}}
175+
>
176+
Number of {e.text}
177+
</Paragraph>
178+
</Box>
179+
))}
180+
</Row>
181+
)}
173182

174183
<Col xs={12} lg={7}>
175184
<Box marginTop="xxxl">

0 commit comments

Comments
 (0)