Skip to content

Commit 1734238

Browse files
author
Inger.Liepelt
committed
Integrate DollySpinner into BestillingProgresjon and DashboardPage for improved loading indicators
1 parent f20c25c commit 1734238

5 files changed

Lines changed: 43 additions & 19 deletions

File tree

apps/dolly-frontend/src/main/js/src/components/bestilling/statusListe/BestillingProgresjon/BestillingProgresjon.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
flex-direction: column;
2828
align-items: center;
2929
padding-top: 10px;
30+
margin-top: 30px;
3031

3132
div {
3233
display: flex;

apps/dolly-frontend/src/main/js/src/components/bestilling/statusListe/BestillingProgresjon/BestillingProgresjon.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Loading from '@/components/ui/loading/Loading'
33
import { ProgressBar } from '@navikt/ds-react'
44
import NavButton from '@/components/ui/button/NavButton/NavButton'
55
import Icon from '@/components/ui/icon/Icon'
6+
import DollySpinner from '@/components/ui/loading/DollySpinner'
67

78
import './BestillingProgresjon.less'
89
import { useBestillingStream } from '@/utils/hooks/useBestillingStream'
@@ -72,12 +73,15 @@ export const BestillingProgresjon = ({
7273
}, [bestillingStatus])
7374

7475
useEffect(() => {
75-
if (!sistOppdatert) return
76-
const elapsed = (Date.now() - new Date(sistOppdatert).getTime()) / 1000
77-
const grense = erOrganisasjon ? SECONDS_BEFORE_WARNING_ORG : SECONDS_BEFORE_WARNING
78-
if (elapsed > grense) {
76+
if (!sistOppdatert || timedOut) return
77+
const grense = (erOrganisasjon ? SECONDS_BEFORE_WARNING_ORG : SECONDS_BEFORE_WARNING) * 1000
78+
const remaining = grense - (Date.now() - new Date(sistOppdatert).getTime())
79+
if (remaining <= 0) {
7980
setTimedOut(true)
81+
return
8082
}
83+
const timeoutId = setTimeout(() => setTimedOut(true), remaining)
84+
return () => clearTimeout(timeoutId)
8185
}, [sistOppdatert, erOrganisasjon])
8286

8387
useEffect(() => {
@@ -167,8 +171,19 @@ export const BestillingProgresjon = ({
167171
</h5>
168172
<span>{isFerdig ? 'Ferdigstiller bestilling' : progress.text}</span>
169173
</div>
170-
<div style={{ marginTop: '10px' }}>
174+
<div style={{ position: 'relative', marginTop: '10px' }}>
171175
<ProgressBar value={progress.percent} size="small" aria-label="Bestillingsfremgang" />
176+
<div
177+
style={{
178+
position: 'absolute',
179+
top: '50%',
180+
left: `${progress.percent}%`,
181+
transform: 'translate(-50%, -50%) scaleX(-1)',
182+
pointerEvents: 'none',
183+
}}
184+
>
185+
<DollySpinner size={50} label="" />
186+
</div>
172187
</div>
173188
<div className="cancel-container">
174189
{timedOut && !erOrganisasjon && (

apps/dolly-frontend/src/main/js/src/components/ui/loading/Loading.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
.panel-loading-container {
2525
padding: 15px;
26-
border: 1px solid @color-bg-grey-border;
26+
display: flex;
27+
justify-content: center;
2728
}
2829

2930
.loading-white {
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react'
22
import './Loading.less'
33
import Spinner from './Spinner'
4+
import DollySpinner from './DollySpinner'
45

56
interface Loading {
67
label?: string
@@ -15,25 +16,30 @@ export default ({ onlySpinner, size, className, label, panel, fullpage }: Loadin
1516
if (onlySpinner) {
1617
return <Spinner size={size || 18} />
1718
}
18-
const Loader = () => (
19-
<div className={className ? className : 'loading-component'}>
20-
{label || 'Laster'}
21-
<Spinner size={size || 18} />
22-
</div>
23-
)
19+
if (fullpage) {
20+
return (
21+
<div className="fullpage-loading-container">
22+
<DollySpinner size={size || 160} label={label || 'Laster'} />
23+
</div>
24+
)
25+
}
2426
if (panel) {
2527
return (
2628
<div className="panel-loading-container">
27-
<Loader />
29+
<DollySpinner size={size || 120} label={label || 'Laster'} />
2830
</div>
2931
)
3032
}
31-
if (fullpage) {
33+
if (label) {
3234
return (
33-
<div className="fullpage-loading-container">
34-
<Loader />
35+
<div className={className ? className : 'panel-loading-container'}>
36+
<DollySpinner size={size || 80} label={label} />
3537
</div>
3638
)
3739
}
38-
return <Loader />
40+
return (
41+
<div className={className ? className : 'loading-component'}>
42+
<Spinner size={size || 18} />
43+
</div>
44+
)
3945
}

apps/dolly-frontend/src/main/js/src/pages/adminPages/Dashboard/DashboardPage.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
MonthlyTeamTrendSection,
1010
} from '@/pages/adminPages/Dashboard/dashboardMonthlySections'
1111
import { useErDollyAdmin } from '@/utils/DollyAdmin'
12-
import { Alert, Box, Loader, VStack } from '@navikt/ds-react'
12+
import { Alert, Box, VStack } from '@navikt/ds-react'
13+
import DollySpinner from '@/components/ui/loading/DollySpinner'
1314
import Highcharts from 'highcharts'
1415
import HighchartsAccessibility from 'highcharts/modules/accessibility'
1516
import { MONTH_SCOPE_ALL } from './dashboardUtils'
@@ -80,7 +81,7 @@ export default () => {
8081

8182
{d.isAnyLoading && (
8283
<Box aria-busy="true" aria-live="polite">
83-
<Loader size="xlarge" title="Laster dashboard-data..." />
84+
<DollySpinner size={120} label="Laster dashboard-data..." />
8485
</Box>
8586
)}
8687

0 commit comments

Comments
 (0)