|
2 | 2 |
|
3 | 3 | <template> |
4 | 4 | <div class="upload-status"> |
5 | | - <template v-if="status && status.totalBytes === 0"> |
| 5 | + <template v-if="status.totalBytes > 0"> |
| 6 | + <div> |
| 7 | + {{ $msTranslate({ key: 'FoldersPage.ImportFile.syncing.filesLeft', count: status.totalFiles }) }} |
| 8 | + {{ $msTranslate(formatETA(rateCalculator.getEta(status.totalBytes))) }} |
| 9 | + </div> |
| 10 | + </template> |
| 11 | + <template v-else> |
6 | 12 | <ion-icon |
7 | 13 | :icon="checkmarkCircle" |
8 | 14 | class="upload-status__icon checkmark-icon" |
|
14 | 20 | @click="$emit('close')" |
15 | 21 | /> |
16 | 22 | </template> |
17 | | - <template v-else-if="status && status.totalBytes > 0"> |
18 | | - <transition |
19 | | - name="step-fade" |
20 | | - mode="out-in" |
21 | | - > |
22 | | - <div |
23 | | - class="upload-status-step" |
24 | | - :key="stepIndex" |
25 | | - > |
26 | | - <ion-icon |
27 | | - :icon="currentStep.icon" |
28 | | - class="upload-status-step__icon step-icon" |
29 | | - /> |
30 | | - <ion-text class="title-h5 upload-status-step__text">{{ $msTranslate(currentStep.label) }}</ion-text> |
31 | | - </div> |
32 | | - </transition> |
33 | | - </template> |
34 | 23 | </div> |
35 | 24 | </template> |
36 | 25 |
|
37 | 26 | <script setup lang="ts"> |
38 | 27 | import { TransferRateCalculator } from '@/common/transferRate'; |
39 | 28 | import { UploadProgress } from '@/parsec'; |
| 29 | +import { formatETA } from '@/services/translation'; |
40 | 30 | import { IonIcon, IonText } from '@ionic/vue'; |
41 | | -import { checkmarkCircle, close, cloudUpload, lockClosed, reader, shieldCheckmark } from 'ionicons/icons'; |
42 | | -import { computed, onUnmounted, ref, watch } from 'vue'; |
43 | | -
|
44 | | -const UPLOAD_STEP_DURATION = 4000; |
45 | | -const UPLOAD_STEPS = [ |
46 | | - { icon: reader, label: 'FoldersPage.ImportFile.syncing.step1' }, |
47 | | - { icon: lockClosed, label: 'FoldersPage.ImportFile.syncing.step2' }, |
48 | | - { icon: shieldCheckmark, label: 'FoldersPage.ImportFile.syncing.step3' }, |
49 | | - { icon: cloudUpload, label: 'FoldersPage.ImportFile.syncing.step4' }, |
50 | | -]; |
51 | | -
|
52 | | -const stepIndex = ref(0); |
53 | | -let stepIntervalId: ReturnType<typeof setInterval> | null = null; |
54 | | -
|
55 | | -const currentStep = computed(() => UPLOAD_STEPS[stepIndex.value]); |
| 31 | +import { checkmarkCircle, close } from 'ionicons/icons'; |
56 | 32 |
|
57 | | -function startStepCycle(): void { |
58 | | - stepIndex.value = 0; |
59 | | - stepIntervalId = setInterval(() => { |
60 | | - if (stepIndex.value === UPLOAD_STEPS.length - 1) { |
61 | | - stepIndex.value = 0; |
62 | | - } else { |
63 | | - stepIndex.value += 1; |
64 | | - } |
65 | | - }, UPLOAD_STEP_DURATION); |
66 | | -} |
67 | | -
|
68 | | -function stopStepCycle(): void { |
69 | | - if (stepIntervalId !== null) { |
70 | | - clearInterval(stepIntervalId); |
71 | | - stepIntervalId = null; |
72 | | - } |
73 | | -} |
74 | | -
|
75 | | -const props = defineProps<{ |
76 | | - status?: UploadProgress; |
| 33 | +defineProps<{ |
| 34 | + status: UploadProgress; |
77 | 35 | rateCalculator: TransferRateCalculator; |
78 | 36 | }>(); |
79 | 37 |
|
80 | 38 | defineEmits<{ |
81 | | - (e: 'close'): boolean; |
| 39 | + (e: 'close'): void; |
82 | 40 | }>(); |
83 | | -
|
84 | | -watch( |
85 | | - () => props.status, |
86 | | - (newValue) => { |
87 | | - if (newValue && newValue.totalBytes > 0) { |
88 | | - if (!stepIntervalId) { |
89 | | - startStepCycle(); |
90 | | - } |
91 | | - } else { |
92 | | - stopStepCycle(); |
93 | | - } |
94 | | - }, |
95 | | -); |
96 | | -
|
97 | | -onUnmounted(() => { |
98 | | - stopStepCycle(); |
99 | | -}); |
100 | 41 | </script> |
101 | 42 |
|
102 | 43 | <style scoped lang="scss"> |
@@ -161,14 +102,4 @@ onUnmounted(() => { |
161 | 102 | margin-left: auto; |
162 | 103 | } |
163 | 104 | } |
164 | | -
|
165 | | -.step-fade-enter-active, |
166 | | -.step-fade-leave-active { |
167 | | - transition: opacity 0.3s ease; |
168 | | -} |
169 | | -
|
170 | | -.step-fade-enter-from, |
171 | | -.step-fade-leave-to { |
172 | | - opacity: 0; |
173 | | -} |
174 | 105 | </style> |
0 commit comments