22
33<template >
44 <div
5- v-if =" menu.isVisible() || isFileOperationManagerActive"
65 class =" upload-menu"
76 :class =" menu.isMinimized() ? 'minimize' : ''"
87 >
98 <div class =" upload-menu-header" >
109 <ion-text class =" title-h4" >{{ $msTranslate('FoldersPage.ImportFile.title') }}</ion-text >
10+ <div v-show =" menu.isMinimized()" >
11+ <span v-if =" uploadProgressStatus && uploadProgressStatus.totalBytes === 0" >FILES SYNCED</span >
12+ <span v-if =" uploadProgressStatus && uploadProgressStatus.totalBytes > 0" >SYNCING...</span >
13+ </div >
1114 <div class =" menu-header-icons" >
1215 <ion-icon
1316 class =" menu-header-icons__item"
1417 :icon =" chevronDown"
1518 @click =" toggleMenu()"
1619 />
17- <ion-icon
18- v-if =" !isFileOperationManagerActive"
19- class =" menu-header-icons__item"
20- :icon =" close"
21- @click =" menu.hide()"
22- />
2320 </div >
2421 </div >
22+ <upload-status
23+ :rate-calculator =" rateCalculator as TransferRateCalculator"
24+ :status =" uploadProgressStatus"
25+ class =" upload-status"
26+ />
2527 <ion-list class =" upload-menu-tabs" >
2628 <ion-item
2729 class =" upload-menu-tabs__item button-medium"
8486</template >
8587
8688<script setup lang="ts">
89+ import { TransferRateCalculator } from ' @/common/transferRate' ;
8790import { FileOperationBase , FileOperationDownloadArchive , FileOperationImport } from ' @/components/files' ;
88- import { Path } from ' @/parsec' ;
91+ import UploadStatus from ' @/components/files/operations/UploadStatus.vue' ;
92+ import { getGlobalUploadProgress , Path , UploadProgress } from ' @/parsec' ;
8993import { navigateTo , Routes } from ' @/router' ;
9094import {
9195 FileOperationCopyData ,
@@ -99,7 +103,7 @@ import { FileEventRegistrationCanceller, FileOperationEventData, FileOperationEv
99103import { FileOperationManager , FileOperationManagerKey } from ' @/services/fileOperation/manager' ;
100104import useUploadMenu from ' @/services/fileUploadMenu' ;
101105import { IonButton , IonIcon , IonItem , IonList , IonText } from ' @ionic/vue' ;
102- import { chevronDown , close } from ' ionicons/icons' ;
106+ import { chevronDown } from ' ionicons/icons' ;
103107import { MsImage , NoImportInProgress } from ' megashark-lib' ;
104108import type { Component } from ' vue' ;
105109import { computed , inject , onMounted , onUnmounted , ref , Ref } from ' vue' ;
@@ -148,8 +152,11 @@ const currentItems = computed(() => {
148152});
149153
150154let canceller! : FileEventRegistrationCanceller ;
155+ let uploadProgressIntervalId: any = null ;
151156const isFileOperationManagerActive = ref (false );
152157const uploadMenuList = ref ();
158+ const uploadProgressStatus = ref <UploadProgress | undefined >(undefined );
159+ const rateCalculator = ref <TransferRateCalculator >(new TransferRateCalculator ());
153160
154161function toggleMenu(): void {
155162 if (menu .isMinimized ()) {
@@ -182,12 +189,27 @@ function getOperationComponent(item: OperationItem): Component {
182189 }
183190}
184191
192+ async function updateProgress(): Promise <void > {
193+ const result = await getGlobalUploadProgress ();
194+ if (result .ok ) {
195+ uploadProgressStatus .value = result .value ;
196+ if (result .value .totalBytes > 0 ) {
197+ rateCalculator .value .update (result .value .totalBytes );
198+ }
199+ } else {
200+ uploadProgressStatus .value = undefined ;
201+ rateCalculator .value .clear ();
202+ }
203+ }
204+
185205onMounted (async () => {
186206 canceller = await fileOperationManager .value .registerCallback (onFileOperationEvent );
207+ uploadProgressIntervalId = setInterval (updateProgress , 2000 );
187208});
188209
189210onUnmounted (async () => {
190211 canceller .cancel ();
212+ clearInterval (uploadProgressIntervalId );
191213});
192214
193215async function onFileOperationEvent(
@@ -207,7 +229,6 @@ async function onFileOperationEvent(
207229 switch (event ) {
208230 case FileOperationEvents .Added : {
209231 items .value .unshift ({ operationData: operationData , status: event , eventData: eventData , refreshKey: 0 });
210- menu .show ();
211232 menu .expand ();
212233 scrollToTop ();
213234 filter .value = undefined ;
@@ -490,7 +511,8 @@ function scrollToTop(): void {
490511
491512.minimize {
492513 .upload-menu-list ,
493- .upload-menu-tabs {
514+ .upload-menu-tabs ,
515+ .upload-status {
494516 height : 0 ;
495517 padding : 0 ;
496518 margin : 0 ;
0 commit comments