Skip to content

Commit 1eb44cb

Browse files
damianpumarleiyre
andauthored
🐛 Fix progress and metrics (#5391)
Co-authored-by: Leire Aguirre <[email protected]>
1 parent 6cd6121 commit 1eb44cb

File tree

8 files changed

+172
-99
lines changed

8 files changed

+172
-99
lines changed

argilla-frontend/components/features/annotation/progress/AnnotationProgress.vue

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
<template>
1919
<div class="my-progress__container">
2020
<TeamProgress :datasetId="datasetId" />
21-
22-
<li class="my-progress__item">
23-
<span>
24-
<span
25-
class="color-bullet"
26-
:style="{ backgroundColor: RecordStatus.submitted.color }"
27-
></span>
28-
<label class="my-progress__name" v-text="RecordStatus.submitted.name" />
29-
</span>
30-
<span class="my-progress__counter" v-text="metrics.submitted" />
31-
</li>
21+
<StatusCounterSkeleton
22+
v-if="!metrics.hasMetrics"
23+
class="my-progress__status--skeleton"
24+
/>
25+
<StatusCounter
26+
v-else
27+
class="my-progress__status"
28+
:color="RecordStatus.submitted.color"
29+
:name="RecordStatus.submitted.name"
30+
:value="metrics.submitted"
31+
/>
3232
</div>
3333
</template>
3434

@@ -55,15 +55,8 @@ export default {
5555
</script>
5656

5757
<style lang="scss" scoped>
58-
$bullet-size: 8px;
59-
.color-bullet {
60-
display: inline-flex;
61-
height: $bullet-size;
62-
width: $bullet-size;
63-
margin-right: 4px;
64-
border-radius: $border-radius-rounded;
65-
}
66-
58+
$statusCounterMinWidth: 110px;
59+
$statusCounterMinHeight: 30px;
6760
.my-progress {
6861
&__container {
6962
width: 100%;
@@ -72,24 +65,11 @@ $bullet-size: 8px;
7265
justify-content: space-between;
7366
margin-right: $base-space * 2;
7467
}
75-
&__item {
76-
display: flex;
77-
flex-direction: row;
78-
gap: $base-space;
79-
padding: $base-space;
80-
width: auto;
81-
background: $black-3;
82-
border-radius: $border-radius;
83-
}
84-
&__name {
85-
text-transform: capitalize;
86-
color: $black-54;
87-
@include font-size(12px);
88-
}
89-
&__counter {
90-
font-weight: 600;
91-
color: $black-87;
92-
@include font-size(14px);
68+
&__status {
69+
&--skeleton {
70+
min-width: $statusCounterMinWidth;
71+
min-height: $statusCounterMinHeight;
72+
}
9373
}
9474
}
9575
</style>

argilla-frontend/components/features/annotation/progress/AnnotationProgressDetailed.vue

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,25 @@
1616
-->
1717

1818
<template>
19-
<div v-if="metrics.hasMetrics">
19+
<div>
2020
<ul class="my-progress__list">
21-
<li
22-
v-for="(status, index) in progressItems"
23-
:key="index"
24-
class="my-progress__list__item"
25-
>
26-
<span>
27-
<span
28-
class="color-bullet"
29-
:style="{ backgroundColor: status.color }"
30-
></span>
31-
<label class="my-progress__list__name" v-text="status.name" />
32-
</span>
33-
<span class="my-progress__list__counter" v-text="status.value" />
34-
</li>
21+
<template v-if="!metrics.hasMetrics">
22+
<StatusCounterSkeleton
23+
v-for="(status, index) in progressItems"
24+
:key="index"
25+
class="my-progress__status--skeleton"
26+
/>
27+
</template>
28+
<template v-else>
29+
<StatusCounter
30+
v-for="(status, index) in progressItems"
31+
:key="index"
32+
class="my-progress__status"
33+
:color="status.color"
34+
:name="status.name"
35+
:value="status.value"
36+
/>
37+
</template>
3538
</ul>
3639
<p class="team-progress__title" v-text="$t('metrics.progress.team')" />
3740
<TeamProgress
@@ -94,7 +97,7 @@ export default {
9497
</script>
9598

9699
<style lang="scss" scoped>
97-
$bullet-size: 8px;
100+
$statusCounterMinHeight: 60px;
98101
.my-progress {
99102
display: flex;
100103
align-items: center;
@@ -112,39 +115,23 @@ $bullet-size: 8px;
112115
font-weight: 500;
113116
}
114117
}
115-
.color-bullet {
116-
display: inline-flex;
117-
height: $bullet-size;
118-
width: $bullet-size;
119-
margin-right: 4px;
120-
border-radius: $border-radius-rounded;
121-
}
122118
123-
.my-progress__list {
124-
display: flex;
125-
list-style: none;
126-
gap: $base-space;
127-
padding-left: 0;
128-
margin-top: 0;
129-
margin-bottom: $base-space * 3;
130-
&__item {
131-
background: $black-3;
119+
.my-progress {
120+
&__list {
132121
display: flex;
133-
flex-direction: column;
122+
list-style: none;
134123
gap: $base-space;
135-
padding: $base-space;
136-
width: 100%;
137-
border-radius: $border-radius;
124+
padding-left: 0;
125+
margin-top: 0;
126+
margin-bottom: $base-space * 3;
138127
}
139-
&__name {
140-
text-transform: capitalize;
141-
color: $black-54;
142-
@include font-size(12px);
128+
&__status.status-counter {
129+
flex-direction: column;
130+
width: 100%;
143131
}
144-
&__counter {
145-
font-weight: 600;
146-
color: $black-87;
147-
@include font-size(14px);
132+
&__status--skeleton {
133+
@extend .my-progress__status;
134+
height: $statusCounterMinHeight;
148135
}
149136
}
150137
</style>

argilla-frontend/components/features/annotation/progress/TeamProgress.vue

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
<template>
22
<div class="team-progress">
3-
<BaseLinearProgress
3+
<BaseLinearProgressSkeleton
4+
v-if="!progress.hasMetrics"
45
class="team-progress__bar"
5-
:progress-ranges="progressRanges"
6-
:progress-max="progress.total"
7-
:show-tooltip="showTooltip"
8-
:tooltip-position-fixed="false"
9-
:show-percent-in-tooltip="false"
106
/>
11-
<span class="team-progress__percent"
12-
>{{ progress.percentage.completed }}%</span
13-
>
14-
<span v-if="visibleProgressValues" class="team-progress__info">
15-
{{ progress.completed }} of {{ progress.total }}
16-
</span>
7+
<template v-else>
8+
<BaseLinearProgress
9+
class="team-progress__bar"
10+
:progress-ranges="progressRanges"
11+
:progress-max="progress.total"
12+
:show-tooltip="showTooltip"
13+
:tooltip-position-fixed="false"
14+
:show-percent-in-tooltip="false"
15+
/>
16+
<span class="team-progress__percent"
17+
>{{ progress.percentage.completed }}%</span
18+
>
19+
<span v-if="visibleProgressValues" class="team-progress__info">
20+
{{ progress.completed }} of {{ progress.total }}
21+
</span>
22+
</template>
1723
</div>
1824
</template>
1925

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<li class="status-counter">
3+
<span>
4+
<span class="color-bullet" :style="{ backgroundColor: color }"></span>
5+
<label class="status-counter__name" v-text="name" />
6+
</span>
7+
<span class="status-counter__counter" v-text="value" />
8+
</li>
9+
</template>
10+
11+
<script>
12+
export default {
13+
props: {
14+
color: {
15+
type: String,
16+
required: true,
17+
},
18+
name: {
19+
type: String,
20+
required: true,
21+
},
22+
value: {
23+
type: Number,
24+
required: true,
25+
},
26+
},
27+
};
28+
</script>
29+
30+
<style scoped lang="scss">
31+
$bullet-size: 8px;
32+
.color-bullet {
33+
display: inline-flex;
34+
height: $bullet-size;
35+
width: $bullet-size;
36+
margin-right: 4px;
37+
border-radius: $border-radius-rounded;
38+
}
39+
.status-counter {
40+
display: flex;
41+
flex-direction: row;
42+
gap: $base-space;
43+
padding: $base-space;
44+
background: $black-3;
45+
border-radius: $border-radius;
46+
47+
&__name {
48+
text-transform: capitalize;
49+
color: $black-54;
50+
@include font-size(12px);
51+
}
52+
&__counter {
53+
font-weight: 600;
54+
color: $black-87;
55+
@include font-size(14px);
56+
}
57+
}
58+
</style>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<template>
2+
<div class="status-counter"></div>
3+
</template>
4+
5+
<style scoped lang="scss">
6+
$progressBackgroundColor: #f2f2f2;
7+
.status-counter {
8+
background: $black-3;
9+
border-radius: $border-radius;
10+
animation-duration: 0.5s;
11+
animation-fill-mode: forwards;
12+
animation-iteration-count: infinite;
13+
animation-name: skeletonBg;
14+
animation-timing-function: cubic-bezier(0.2, 0.7, 0.8, 0.7);
15+
background: linear-gradient(
16+
to right,
17+
$progressBackgroundColor 0%,
18+
darken($progressBackgroundColor, 3%) 50%,
19+
$progressBackgroundColor 100%
20+
);
21+
background-size: 200% 100%;
22+
23+
@keyframes skeletonBg {
24+
0% {
25+
background-position: 100% 0;
26+
}
27+
100% {
28+
background-position: -100% 0;
29+
}
30+
}
31+
}
32+
</style>

argilla-frontend/v1/domain/entities/dataset/Metrics.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ describe("Metrics", () => {
1010
expect(result).toBeTruthy();
1111
});
1212
it("should return false when there are no records", () => {
13-
const metrics = new Metrics(0, 0, 0, 0, 0);
13+
const metrics = new Metrics(
14+
undefined,
15+
undefined,
16+
undefined,
17+
undefined,
18+
undefined
19+
);
1420

1521
const result = metrics.hasMetrics;
1622

argilla-frontend/v1/domain/entities/dataset/Metrics.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ export class Metrics {
66
discarded: number;
77
};
88

9+
public readonly hasMetrics: boolean;
10+
911
constructor(
1012
public readonly total: number,
1113
public readonly submitted: number,
1214
public readonly discarded: number,
1315
public readonly draft: number,
1416
public readonly pending: number
1517
) {
18+
this.hasMetrics = total >= 0;
19+
1620
this.percentage = {
1721
pending: (this.pending * 100) / this.total,
1822
draft: (this.draft * 100) / this.total,
@@ -21,10 +25,6 @@ export class Metrics {
2125
};
2226
}
2327

24-
get hasMetrics() {
25-
return this.total > 0;
26-
}
27-
2828
get responded() {
2929
return this.submitted + this.discarded + this.draft;
3030
}

argilla-frontend/v1/domain/entities/dataset/Progress.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ export class Progress {
44
completed: string;
55
};
66

7+
public readonly hasMetrics: boolean;
8+
79
constructor(
810
public readonly total: number,
911
public readonly completed: number,
1012
public readonly pending: number
1113
) {
14+
this.hasMetrics = total >= 0;
15+
1216
this.percentage = {
1317
pending: ((this.pending * 100) / this.total).toFixed(2),
1418
completed: ((this.completed * 100) / this.total).toFixed(2),

0 commit comments

Comments
 (0)