Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add loading spinner to download icon #17175

Merged
merged 10 commits into from
Jul 30, 2015
Merged

Add loading spinner to download icon #17175

merged 10 commits into from
Jul 30, 2015

Conversation

MorrisJobke
Copy link
Contributor

  • vanishes after 2 seconds

Same like #17160 but for the file list.

I still don't like that it vanishes after the hardcoded 7 seconds. I searched a lot and tried many JS events to somehow detect, that the download is started but nothing worked.

cc @owncloud/designers @LukasReschke @craigpg @bobboule

@MorrisJobke
Copy link
Contributor Author

I tested this locally, but it feels very hacky :(

@oparoz @rullzer @Xenopathic Any ideas how to solve this better?


var icon = $(context.$file).find('.fileactions .action-download img');
var sourceImage = icon.attr('src');
icon.attr('src', sourceImage.replace('actions/download.svg', 'loading-small.gif'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideal would be to work with CSS classes and have them define the icon.
But I guess you were short on time ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the action icons, I remember... not flexible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#17175 (comment)

I don't want to break backwards compatibility here.

@PVince81
Copy link
Contributor

Another idea, still a bit hacky, is to delete the img element and insert a new one with the image.

Or, the elegant but out of scope approach: improve FileActions to be able to show a spinner for ANY action (could be used for when loading the sharing dialog, delete, etc)

@MorrisJobke
Copy link
Contributor Author

I tried events like beforeunload and unload but both are triggered at the redirect in JS. Then the browser window adds the spinner as favicon. Once the download starts the spinner is gone. Does anybody know how I can check for this "loading state" from JS? I tried window.location.href but it is always the old url (even if it is set during OC.redirect).

@MorrisJobke
Copy link
Contributor Author

Or, the elegant but out of scope approach: improve FileActions to be able to show a spinner for ANY action (could be used for when loading the sharing dialog, delete, etc)

Ah ... didn't though about this. But it sounds nice :)

I also thought about adding a element that gets an icon class applied and not adding an <img> tag, because then you only need to switch the css class ;)

@MorrisJobke
Copy link
Contributor Author

To test this add sleep(5) to apps/files/ajax/download.php ;)

@oparoz
Copy link
Contributor

oparoz commented Jun 25, 2015

Interesting problem... The main problem seems to be that we don't have a 100% control over the sending mechanism. Otherwise, it would be easy to use a cookie.

@karlitschek
Copy link
Contributor

i like it 👍

@MorrisJobke
Copy link
Contributor Author

Interesting problem... The main problem seems to be that we don't have a 100% control over the sending mechanism. Otherwise, it would be easy to use a cookie.

There is a somewhat hackish way to check if a download request already came back (and therefore the download is shown in the browser):

  • send a random string within the download redirect
  • on the server check for availability of the parameter and set the random string to a predefined cookie name (short TTL - a few seconds up to a minute - needs to be bigger than the time between two checks within the JS code - see next steps)
  • once the response is read by the browser it will set the cookie
  • the JS can check periodically if this cookie is set to the previous send value and then knows, that the download started.

@PVince81
Copy link
Contributor

Argh... sounds almost like a project on its own.

@MorrisJobke
Copy link
Contributor Author

Argh... sounds almost like a project on its own.

Yes. Definetely something for a separate PR.

@@ -599,6 +605,13 @@ a.action>img {
opacity: 1;
display:inline;
}
#fileList tr a.action.disabled {
background: none;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because usually disabled links have a grey background.

@MorrisJobke
Copy link
Contributor Author

Now the button has doesn't highlight on hover and can't be clicked a second time. (@craigpg requested this as an UX enhancement)

@owncloud/designers please have a look at this.

@MorrisJobke
Copy link
Contributor Author

We maybe want to decrease the time to two seconds (download then should be started)

@MorrisJobke
Copy link
Contributor Author

It now looks like this:

bildschirmfoto von 2015-06-26 10-24-40

@jancborchardt
Copy link
Member

@MorrisJobke the »disabled« look makes it a bit hard to see. I would keep the same opacity that it has when hovered / just clicked to make the feedback properly visible.

@jancborchardt
Copy link
Member

Otherwise awesome! :)

@MorrisJobke
Copy link
Contributor Author

@bboule I added the download spinner to the multiselect download button. Please retest.

@LukasReschke
Copy link
Member

It's a little bit confusing that the spinner also spins when the download has already been completed.

@MorrisJobke
Copy link
Contributor Author

It's a little bit confusing that the spinner also spins when the download has already been completed.

The proper fix for this is #17175 (comment) 🙈

@MorrisJobke
Copy link
Contributor Author

@LukasReschke I reduced the timeout to 2 seconds.

@MorrisJobke
Copy link
Contributor Author

@MorrisJobke the »disabled« look makes it a bit hard to see. I would keep the same opacity that it has when hovered / just clicked to make the feedback properly visible.

Done.

@DeepDiver1975 DeepDiver1975 added this to the 8.2-next milestone Jun 29, 2015
@PVince81
Copy link
Contributor

@MorrisJobke now it looks great ! Sorry that I still found a few things to comment on, but you're close to perfection now 😉

@MorrisJobke
Copy link
Contributor Author

@PVince81 I highly appreciate your comments 😃

@MorrisJobke MorrisJobke force-pushed the add-download-feedback branch from 44190ee to 43afa4c Compare July 15, 2015 09:14
@MorrisJobke
Copy link
Contributor Author

@PVince81 Should I move the functions to the proposed places?

@PVince81
Copy link
Contributor

@MorrisJobke yes please. This one #17175 (comment)

@scrutinizer-notifier
Copy link

A new inspection was created.

@MorrisJobke
Copy link
Contributor Author

The function is now moved :)

@rullzer @Xenopathic @jancborchardt Happy testing & reviewing :)

@ghost
Copy link

ghost commented Jul 22, 2015

🚀 Test PASSed.🚀
chuck

@jancborchardt
Copy link
Member

File download doesn’t work for me (folders work fine). Get redirected to http://127.0.0.1/owncloud/index.php/apps/files/ajax/download.php?dir=%2F&files=856.pdf&downloadStartSecret=ik90c30y1sn
and this error shows up:

"message":"Call to a member function isReadable() on null
at \/home\/jan\/owncloud\/lib\/private\/files\/storage\/wrapper\/encryption.php#288"
"url":"\/owncloud\/index.php\/apps\/files\/ajax\/download.php?dir=%2F&files=856.pdf&downloadStartSecret=ik90c30y1sn"}

@MorrisJobke
Copy link
Contributor Author

File download doesn’t work for me

Mmmh. Works here. Which browser?

@rullzer
Copy link
Contributor

rullzer commented Jul 27, 2015

Working as expected here in firefox and chromium.
👍

@MorrisJobke
Copy link
Contributor Author

@jancborchardt ping

@PVince81 Can you have a final look at the changes and maybe also test if this works for you?

OCA.Files.FileActions.updateFileActionSpinner(downloadFileaction, false);
};

OCA.Files.FileActions.updateFileActionSpinner(downloadFileaction, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, here you can use "self.updateFileActionSpinner(...)". But you need to add var self = this; at the top of the original method. See an example here: https://github.com/owncloud/core/blob/master/apps/files/js/filelist.js#L619

Feel free to leave it now. Just a hint for next time 😄

@PVince81
Copy link
Contributor

The code looks great now, thanks @MorrisJobke.

Something that hacky needs to be tested in IE8 too.

@PVince81
Copy link
Contributor

It looks like the spinner only appears if the browser is configured with an automatic save location. If you configure it to always show the "save as" dialog, no spinner is shown.
I assume the spinner was designed for the former case ?

@PVince81
Copy link
Contributor

Okay, Chromium 43 shows the spinner before showing the save dialog, which is nice.
However Firefox 39 and IE8 never show the spinner.

@PVince81
Copy link
Contributor

IE9 shows the spinner.

Fine by me to merge 👍

@MorrisJobke do you intend to add a spinner later to the "Download" button on the top right of the public link page ?

@MorrisJobke
Copy link
Contributor Author

@MorrisJobke do you intend to add a spinner later to the "Download" button on the top right of the public link page ?

Yes. Separate PR

MorrisJobke added a commit that referenced this pull request Jul 30, 2015
Add loading spinner to download icon
@MorrisJobke MorrisJobke merged commit 5699fff into master Jul 30, 2015
@MorrisJobke MorrisJobke deleted the add-download-feedback branch July 30, 2015 14:34
@MorrisJobke MorrisJobke removed their assignment Oct 5, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Aug 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants