fohrloop / dash-uploader

The alternative upload component for python Dash applications.
MIT License
144 stars 30 forks source link

du.UploadStatus objects for du.callback #68

Closed fohrloop closed 2 years ago

fohrloop commented 2 years ago

In the dash-uploader 0.7.0 update, the new (proposed) callback syntax is

@du.callback(
    output=Output('callback-output', 'children'),
    id='dash-uploader',
)
def get_a_list(status: du.UploadStatus):
    print(status.n_files_uploaded, status.n_files_total)
    return html.Ul([html.Li(x) for x in status.filenames])

du.UploadStatus attributes

The du.UploadStatus object could include

Goal: implement this UploadStatus class. It will serve as guide when implementing the props and state or the Upload_ReactComponent of the 0.7.0 release.

fohrloop commented 2 years ago

The status.mb_uploaded can be taken from flow.sizeUploaded(). The status.mb_total can be taken from flow.getSize().

fohrloop commented 2 years ago

The flow.timeRemaining() seems a bit unstable. The number given by the flow component will need some filtering before the value would be displayed to the user.

Here is a screen capture from situation where multiple files were "uploaded" (locally, no throttling). The timeRemaining() value jumped from 10s to ~20.000s when file was changed. This could be made working some day by keeping track of used time in the JS side and calculating longer time averages. As this is not priority right now, I'm dropping the attribute status.timeremaining from the list.

image