wbstr / vaadin-multifileupload

12 stars 23 forks source link

After file selection for upload, hide the popup dialog panel #71

Open oikonomopo opened 5 years ago

oikonomopo commented 5 years ago

Hi nice add-on!

======= vaadin-multifileupload Version I am using version 2.0.3

<dependency>
    <groupId>com.wcs.wcslib</groupId>
    <artifactId>wcslib-vaadin-widget-multifileupload</artifactId>
    <version>2.0.3</version>
</dependency>

======= What it does now When i choose my files for upload, it open a popup dialog with upload status with progress bar for each file and cancel functionality. When uploading finishes the dialog closes.

======= What i want I would like after the file selections, instead of opening popup window (upload status / file upload progress bar etc), to skip this dialog and have just a spin/loading animation until upload finishes!

TCellClinicalServices commented 5 years ago

I also have this issue. The status panel is not getting closed until we explicitly close it.

oikonomopo commented 5 years ago

Found a temporary workaround! @TCellClinicalServices test if it works for you!

======= sample code (Fix: Close upload status window after all uploads finish)

...
private MultiFileUpload multiFileUpload;
private UploadStartedHandler uploadStartedHandler;
private UploadFinishedHandler uploadFinishedHandler;
private UploadStateWindow uploadStateWindow = new UploadStateWindow();
...
uploadStartedHandler = new UploadStartedHandler() {
    @Override
    public void handleUploadStarted() {

        // enable Polling Interval to one second
        // we need this or else upload status panel
            // hangs at last upload frequently
        // make the client browser poll the vaadin server, every 1 sec, for any UI changes.
        // sets Polling Interval to 1 second
        getUI().setPollInterval(1000);
    }
};
...
multiFileUpload = new MultiFileUpload(uploadStartedHandler, uploadFinishedHandler, uploadStateWindow, true);
...
// after all uploads
multiFileUpload.setAllUploadFinishedHandler(new AllUploadFinishedHandler() {
    @Override
    public void finished() {
        System.out.println("======= setAllUploadFinishedHandler");              
        filesHeaderListPanel.load(uploadedFiles);

        // disable Polling Interval
        getUI().setPollInterval(-1);
    }
});
...

======== vaadin & vaadin-multifileupload addon versions

<vaadin.version>7.7.6</vaadin.version>
<dependency>
    <groupId>com.wcs.wcslib</groupId>
    <artifactId>wcslib-vaadin-widget-multifileupload</artifactId>
    <version>2.0.3</version>
</dependency>
TCellClinicalServices commented 5 years ago

Thanks for the solution!

oikonomopo commented 5 years ago

Thanks for the solution!

according @evanzel 's comment at #38 : we should restore also the poll interval in AllUploadFinishedHandler. Keep in mind that the bug still occurs sometimes, when Push is enabled.

TCellClinicalServices commented 5 years ago

The above code is working but for the first time when we upload a file, its not getting opened until an action is done on the screen.

oikonomopo commented 5 years ago

The above code is working but for the first time when we upload a file, its not getting opened until an action is done on the screen.

_*I added the following code, not only in the component that uses the multi-upload component, but also on my "main" View component.

On your "main" View/Page, add on init/load method:

// make the client browser poll the vaadin server, every 1 sec, for any UI changes.
getUI().setPollInterval(1000);

And when leave current View disable it:

// disable Polling Interval
getUI().setPollInterval(-1);