-
Notifications
You must be signed in to change notification settings - Fork 208
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
Stops loading of blend-module when offset unavailable #654
Conversation
@jywarren please review. |
@Divy123 I think you should not interact with the DOM directly form the library. Instead maybe you can send the error to the ui somehow and let the ui handle it? |
Or you can get the number of steps in the ui and let or not let the user add beln module. |
Well we have already provided an option as offset for user to handle. |
But if the library is used without ui or in cli thn it is going to produce an error |
Also if you want to add the notification then you can remove the |
Since the callback is invoked immediately if offset step is not available, I don't think there should be any problem I don't think there should be an error. |
What if that notification is activated somehow and without cli the file doesnt find the notification and then goes crazy? |
Oh ok the notification is only activated if in browser is true. My mistake sorry. If that is so then you can maybe add the notification function to a different file? |
Maybe a util function which fires a custom event in the ui? The ui can listen for it and produce the appropriate notification? |
@Divy123 the css should be a class not id. The notifications can be given specific ids by the function later. |
The ids will have to be generated from the payload itself |
Well I don't think there is any need of id(s) as of now . It may be done later if needed. |
@jywarren please review. |
Ok
On 11-Jan-2019 9:00 PM, "Slytherin" <notifications@github.com> wrote:
@jywarren <https://github.com/jywarren> please review.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#654 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AhKOnyNJtXZuRTErVz3tqkdBLeq1rzfJks5vCK4qgaJpZM4Z7Uht>
.
|
@Divy123 can you please change the CSS to |
Sure @harshkhandeparkar . Thanks for your suggestions. 😄 |
@Divy123 I think $('.notification-styles').length will always be > 0 once the first notification has been shown. |
Any thing you suggest @harshkhandeparkar ? I think adding class to css was misleading. |
No, we add class only for styling not for the notification which is why ids exist. For referring to a single element in the whole DOM |
This is why we need to auto-generate ids for each notification as each of them has a different message but same styling. |
One more thing I didn't find any problem in the code when class was not added. |
That is because step removed notification and offset notification were not used together. It is going to create ambiguity even is both are given the same class or if both are given the same id. Therefore they have to be given the same class but different ids to refer to them individually without repeating any styles. |
@harshkhandeparkar sure I will look into. |
@Divy123 how about dynamically generating IDs based on input like maybe using |
Or actually no. |
@jywarren the work is done. Please review. |
src/modules/Blend/Module.js
Outdated
if (priorStep.output === undefined) { | ||
this.output = input; | ||
if(options.inBrowser) | ||
produceNotification("Offset Unavailable","unavailable-offset"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, interesting! could we have a generic notification function that is passed to the UI code like this:
UI.notify('message');
Then the UI would know what to do with it -- the CLI ui would print it out, but the HTML ui would display it. Does that make sense? We'd have to make sure each UI has a .notify()
function, and/or we'd have to check that it exists before using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure @jywarren that will be great to implement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please provide a bit more details?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So basically the UI we use is just one option -- we can pass in a different UI in the options when the sequencer is started up (see examples/index.html). Our default HTML ui is here: lib/defaultHtmlSequencerUi.js
So, we should think of how different UIs will handle notifications. The CLI is written here, and actually doesn't supply a UI, although really it should:
Line 4 in cfdb543
sequencer = ImageSequencer({ ui: false }); |
Perhaps we should add a new item to the UI spec as described here: https://github.com/publiclab/image-sequencer/#creating-a-user-interface
We could say all UIs can supply an optional notify()
or onNotify()
handler. Does this make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure . Great changes . Will love to work on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jywarren I have made the said changes. Please review.
@Divy124 I have another idea. You could use the same id for each notification toast but just change the text each time for each notification. How well would that work? |
That's a good idea but since I have provided different id's to different types of notifications that would do the work as same type of notificattions won't display at same time. |
Yes but if you do that like the way I suggested, it will be future proof. |
Append a notification to the dom and change its innerText to the notification message. Everytime the function is triggered, the same element's text can be changed and then it can be animated. |
No problem after that. No two elements with same id. No crowding of dom and no redundant styles. |
The idea is of course nice but as I told you that it is not possible for two notifications to pop up simultaneously so it won't do any bad. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small changes requested, thank you!!!! Great work! 👍 🎉
src/modules/Blend/Module.js
Outdated
@@ -24,6 +24,12 @@ module.exports = function Dynamic(options, UI, util) { | |||
// save first image's pixels | |||
var priorStep = this.getStep(options.offset); | |||
|
|||
if (priorStep.output === undefined) { | |||
this.output = input; | |||
UI.onNotify('Offset Unavailable','offset-notification'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, if we're going to use it like this, maybe best have it just be UI.notify(...)
, is that OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure..
@@ -69,6 +69,9 @@ if (program.saveSequence) { | |||
for (var output in step.info.outputs) { | |||
console.log("[" + program.step + "]: " + output + " = " + step[output]); | |||
} | |||
}, | |||
onNotify: function(msg) { | |||
console.log('\x1b[36m%s\x1b[0m','🌟 '+msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this overwrite the default in /src/ui/...? Just checking!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not much though providing a beautiful version in console.log
An effort to look it more like a notification.
examples/demo.css
Outdated
|
||
.savesequencemsg{ | ||
display: none; | ||
text-align: center; | ||
} | ||
|
||
#stepRemovedNotification { | ||
#offset-notification,#remove-notification { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make a generic reusable .notification
class here?
We can still leave the id
s for hiding/showing uniquely. But to have a generic style seems nice and then it can be reused for more things later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
@jywarren please review. |
This looks great. I think it's ready to be merged, and I'd like to ask if you're interested in developing a simple test for the UIs - to confirm that they have a Merging! |
Oh! Also, shall we update the READMEs to mention the |
Ya sure @jywarren I am working on it. |
@jywarren I am almost done. |
Fixes #649
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
rake test
@publiclab/reviewers
for help, in a comment belowIf tests do fail, click on the red
X
to learn why by reading the logs.Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software
Thanks!