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

Notify Users for the failure in loading Image via external URL #1813

Merged
merged 7 commits into from
Feb 19, 2021

Conversation

vivek-30
Copy link

Fixes #1808.
Now image can be rendered through URL as well.

@vivek-30 vivek-30 requested a review from a team as a code owner February 16, 2021 14:48
@gitpod-io
Copy link

gitpod-io bot commented Feb 16, 2021

@vivek-30
Copy link
Author

Working Clip -

Screen.Recording.2021-02-16.at.8.05.58.PM.mov

@vivek-30
Copy link
Author

@jywarren , @harshkhandeparkar , @daemon1024 please have a look 😊

@@ -57,7 +57,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
<div class="col-md-8 cal collapse in step-column">\
<div class="load load-spin" style="display:none;"><i class="fa fa-circle-o-notch fa-spin"></i></div>\
<div class="step-image">\
<a class="cal collapse in"><img class="img-thumbnail step-thumbnail"/></a>\
<a class="cal collapse in"><img class="img-thumbnail step-thumbnail" crossorigin="anonymous" /></a>\
Copy link
Member

Choose a reason for hiding this comment

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

Was this the only thing missing? It was working before but maybe browsers increased security requirements? Wow!

Do you think we can still run a test for this? We could pull in a remote image from a static source and use looks-same to compare it.

Copy link
Author

Choose a reason for hiding this comment

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

Ok sir i will try to run this one.
BTW i have one more approach to tackle this problem. We can create a local directory and once we place a url to load the image we can use that url to download the image in that directory and can render image directly from local folder this will remove the overhead of cross-origin.
What's your view?

Copy link
Author

@vivek-30 vivek-30 Feb 16, 2021

Choose a reason for hiding this comment

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

Actually previously this was the error in the console when image failed to load-

Uncaught Security Error: Failed to execute ‘toDataURL’ on ‘HTMLCanvasElement’: tainted canvases may not be exported.

But after setting crossorigin=anonymous this error disappeared.

@jywarren
Copy link
Member

jywarren commented Feb 16, 2021 via email

@vivek-30
Copy link
Author

@jywarren i think the problem is still unresolved 😥 .while writing the test i tried one more time to import a image but it failed
and reason is pretty clear and obvious (CORS Error) -

Screenshot 2021-02-17 at 8 39 59 PM

@vivek-30
Copy link
Author

Possible solutions -

  1. use cors-anywhere proxy
  2. create our own proxy

for handling of these requests.

But sir if you have some other approach for this please let me know 😊

@jywarren
Copy link
Member

jywarren commented Feb 17, 2021 via email

@vivek-30
Copy link
Author

sure sir, that sounds great!!!
I will find a way to accomplish this ☺️

@jywarren
Copy link
Member

jywarren commented Feb 17, 2021 via email

@vivek-30
Copy link
Author

That will look nice 😊 .
BTW something similar can be done for #1310 as well right?.

@jywarren
Copy link
Member

jywarren commented Feb 17, 2021 via email

@vivek-30
Copy link
Author

@jywarren finally after investing a decent amount of time on this i have completed this task successfully 😃 and tested it as well with both desktop and mobile view.
Hope you like this ☺️

@vivek-30 vivek-30 changed the title Load image via URL Notify Users for the failure in loading Image via external URL Feb 18, 2021
@@ -347,7 +347,18 @@ a.name-header{
left: 10%;
top: 30px;
}
#update-prompt-modal.show {

#notify-box {
Copy link
Member

Choose a reason for hiding this comment

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

Wow cool, it looks like you created a custom alert box style, was there a reason why the bootstrap styles didn't work for you? Thanks!!!

Copy link
Author

@vivek-30 vivek-30 Feb 18, 2021

Choose a reason for hiding this comment

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

There is no special reason for this .But the thing which took me to create a custom one is because toast is available in bootstrap version v4 and currently we have v3 so either we have to use cdn links or update it which i feel not to do so just for a notification prompt.
But it worth having this custom Toast. right?

Copy link
Author

Choose a reason for hiding this comment

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

@jywarren sir is it ok😊

Copy link
Member

Choose a reason for hiding this comment

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

OK, that makes sense! And, it looks nice, good work!

image

Let's do this: let's use a classname instead of an ID so it can be more easily reused, and let's also use the same classname as the Bootstrap 4 code -- that way if we upgrade in the future, it'll be a relatively easy change where we remove our custom style and switch over. How does that sound?

Thank you for your help on this!!!

Copy link
Author

Choose a reason for hiding this comment

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

That sounds perfect!! . And sir you are right we should make this code a little bit more general in nature for further reusability. i will change it now 😊 .

Copy link
Author

Choose a reason for hiding this comment

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

BTW i was just planning to provide you a visual for the changes i have made so that you can judge it better ,but before that you send this pick isn't it funny

@vivek-30
Copy link
Author

@jywarren please have a look at these changes now ☺️ .

@@ -358,7 +358,17 @@ a.name-header{
background:#c3c3c3;
}

#update-prompt-modal.show,#notify-box {
/* Bootstrap class for display none remove it after updating to version v4 */
Copy link
Member

Choose a reason for hiding this comment

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

very nicely done!

@jywarren jywarren merged commit 3b85779 into publiclab:main Feb 19, 2021
@jywarren
Copy link
Member

Nicely done and many thanks!!!!

@vivek-30
Copy link
Author

@jywarren Thank you so much sir ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Import Images from URL
2 participants