Allow keyboard input for keypad - #1138
Conversation
Until now, one had to click the buttons in the web interface to control the keypad. I've enabled keyboard input for this.
peternewman
left a comment
There was a problem hiding this comment.
Can you have a look at the readme here:
https://github.com/OpenLightingProject/ola/blob/master/javascript/new-src/README.md
You'll need to make the changes here:
https://github.com/OpenLightingProject/ola/blob/master/javascript/new-src/src/controllers/keypad_universe.js
Then rebuild and commit app.js, app.min.js and app.min.js.map using the instructions in the readme.
| case 'a': | ||
| $scope.input(' @ '); | ||
| break; | ||
| case '-': |
There was a problem hiding this comment.
I'd be inclined to leave out -, so we can do 1 THRU 10 - 5 + 15 in future, without confusing things.
There was a problem hiding this comment.
Ok, I did not know about that.
There was a problem hiding this comment.
It was popular on Strand, and probably other consoles. The above would select channels 1, 2, 3, 4, 6, 7, 8, 9, 10 and 15.
There was a problem hiding this comment.
Not quite intuitive 😉
I already thought about adding support for comma-separated lists of channels / channel ranges, but that would be another pull request.
There was a problem hiding this comment.
What else would you expect it to do (aside from maths)?
There was a problem hiding this comment.
The comma-separated list? I'd expect it to do something like this:
1 THRU 3, 9 @ FULL would set channels 1, 2, 3 and 9.
There was a problem hiding this comment.
I was meaning the Strand style. Your comma syntax would need 1 THRU 4, 6 THRU 10, 15 to get the same effect as my example.
There was a problem hiding this comment.
I admit I did not read closely enough, now I get how the syntax works. Nevertheless, sometimes commas might be better, e.g. 1 THRU 10, 50 THRU 60 @ FULL. But one does not forbid the other, so why not consider both?
There was a problem hiding this comment.
Yep, in that case a comma would be perfectly acceptable I'd think.
You can also do things like 1 THRU 10 - 3 THRU 5. I can't really think of a +/, equivalent for that that makes sense. I'm not sure in Strand land, but it might make sense to keep , for multiple entries at once, or we could use ; for that. So 1 @ 5, 2 @ 7 as one simultaneous statement.
|
Thanks for this! |
|
Should the directive also go into the file you mentioned? |
|
Possibly a question for @daveol but from my understanding of directives and given what he did with filters, I'd say make a new folder and put it in there, similar to this: I'm assuming that directive can be used to grab focus anywhere in the UI we might need to? |
|
Exactly. I'll do that then. |
* created new directives directory * removed '-' as 'THRU' shortcut * fix code style
|
Travis failed again because of the GitHub outage. |
| 'src/constants.js', | ||
| 'src/directives/autofocus.js', | ||
| 'src/factories/ola.js', | ||
| 'src/filters/start_form.js' |
There was a problem hiding this comment.
While we're here, can I be cheeky and get you to fix this, it's a typo and should be start_from.
| var key = $event.key; | ||
|
|
||
| if ($event.altKey || $event.ctrlKey || $event.metaKey | ||
| || ($event.which == 0 && key != 'Enter' && key != 'Backspace')) { |
There was a problem hiding this comment.
Can we put the or on the line above please (leave the ($event indented by one from the ( above).
| var key = $event.key; | ||
|
|
||
| if ($event.altKey || $event.ctrlKey || $event.metaKey | ||
| || ($event.which == 0 && key != 'Enter' && key != 'Backspace')) { |
There was a problem hiding this comment.
Is there a constant for this 0 or anything?
There was a problem hiding this comment.
$event.which is 0 for non-printable keys (like the F1 - F12 keys I had in mind). Those won't interfere with the input's value anyway, so we just exclude them.
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Allows an element to obtail focus whenever a variable is set to true. |
|
Here is what the old web UI used to do on the keypad front. It would be good to add > for THRU at least: |
|
Yeah, |
* Typo form -> from * Typo obtail -> obtain * indention * added '>' as 'THRU' shortcut
|
You'll need to add the new file here to fix Travis: https://github.com/OpenLightingProject/ola/blob/master/javascript/Makefile.mk#L22 |
| javascript/new-src/src/controllers/setting_universe.js \ | ||
| javascript/new-src/src/controllers/header.js \ | ||
| javascript/new-src/src/controllers/overview.js \ | ||
| javascript/new-src/src/directives/autofocus.js \ |
There was a problem hiding this comment.
You'll need to change start_from to form here too.
Can we fix the sorting please, by folder then file; so move factories and filters up (and above img).
There was a problem hiding this comment.
Sorry, I pushed the moment you commented. Wait for another commit ;)
|
Travis does still fail 😢 |
|
Yeah * did all channels before (min channel to max channel). |
|
Travis is now working again, there are a chunk of JS lint issues you'll need to fix please: |
|
jshint and jscs are don't agree on the case indentation. When I comply with one, the other fails. |
|
I'm inclined to say we should stick with jscs as you've currently done, as that's our own custom JS style, rather than a default one. So then it's just a case of stopping jshint complaining. It looks like this got resolved in jshint here, which should be in jshint 2.2.0 upwards: Which we're already running, so needs a little more digging. This is the first switch/case in our JS code, hence the issue. |
|
Actually I think it may be the {} block within the case @FloEdelmann . Have you tried removing that? |
|
I have actually never used |
|
I've taken the {} back out, as we need to fix our JCSC config instead. |
|
Travis should be fixed by OpenLightingProject/javascript-style#9 . |
|
As promised, now all green. |
|
Nice, thank you :) |
|
@daveol if you want to retrospectively review this, let us know if there are any issues. @FloEdelmann I realised I forgot to regenerate the JS after fixing lint issues and it looks like you did the same. Would you mind updating them and pushing a new PR please. |
|
Unfortunately, I won't find the time until maybe Monday. If it's still relevant then, just let me know. |
Regenerate JS after we forgot in #1138
Until now, one had to click the buttons in the web interface to control the keypad. I've enabled keyboard input for this.