-
Notifications
You must be signed in to change notification settings - Fork 226
New web UI, store highest channel number used #1739
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
base: 0.10
Are you sure you want to change the base?
Changes from 5 commits
34a7769
6d7a9af
f5faaec
da36879
8f443cb
4eacc64
1f57145
c5b8700
02faeaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -200,6 +200,9 @@ Javascript | |||||||||
| Javascript is used for the olad web UI. Instructions for building the | ||||||||||
| javascript can be found in javascript/README. | ||||||||||
|
cmouttet marked this conversation as resolved.
Outdated
|
||||||||||
|
|
||||||||||
| The sources for the new UI is located in javascript/new-src. The built artifact | ||||||||||
|
cmouttet marked this conversation as resolved.
Outdated
|
||||||||||
| is copied to olad/www/new/js/app.min.js. | ||||||||||
|
Comment on lines
+203
to
+204
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix some grammar:
Suggested change
|
||||||||||
|
|
||||||||||
| Closure Compiler | ||||||||||
| ---------------- | ||||||||||
|
|
||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ ola.controller('universeCtrl', | |
| 'use strict'; | ||
| $scope.dmx = []; | ||
| $scope.Universe = $routeParams.id; | ||
| $ola.resetHighestChannelNumberUsed(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're better off calling a function here than just initialising a scope variable then are we (like the DMX array)?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not very familiar with JavaScript. My home is Java on the backend. :)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it seems like $scope should work if you change it everywhere, but only within one controller, or there's $rootScope, or our $ola might be able to take a variable. Otherwise @daveol or @FloEdelmann might be able to help, all this whizzy JavaScript library stuff isn't really my area of expertise either unfortunately. |
||
|
|
||
| var interval = $interval(function() { | ||
| $ola.get.Dmx($scope.Universe).then(function(data) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,19 @@ | |
| ola.factory('$ola', ['$http', '$window', 'OLA', | ||
| function($http, $window, OLA) { | ||
| 'use strict'; | ||
| var highestChannelNumberUsed = 0; | ||
|
peternewman marked this conversation as resolved.
|
||
|
|
||
| var updateHighestChannelNumberUsed = function(dmx) { | ||
| for (var channel = dmx.length; channel > highestChannelNumberUsed; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A comment might be nice here, just so we don't automatically assume it's iterating from dmx.length to zero as I did. Something like "we only care about checking channels higher than our existing highest" or similar maybe. |
||
| channel--) { | ||
|
|
||
| if ((dmx[channel - 1] > OLA.MIN_CHANNEL_VALUE) && | ||
| (highestChannelNumberUsed < channel)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it did say (which as below I don't think it needs to, swapping the two variables around so it matches the for loop would be less confusing).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When using |
||
| highestChannelNumberUsed = channel; | ||
| } | ||
|
cmouttet marked this conversation as resolved.
Outdated
|
||
| } | ||
| }; | ||
|
|
||
| // TODO(Dave_o): once olad supports json post data postEncode | ||
| // can go away and the header in post requests too. | ||
| var postEncode = function(data) { | ||
|
|
@@ -52,20 +65,28 @@ ola.factory('$ola', ['$http', '$window', 'OLA', | |
| return i; | ||
| }; | ||
| var dmxConvert = function(dmx) { | ||
| var strip = true; | ||
| var integers = []; | ||
| for (var i = OLA.MAX_CHANNEL_NUMBER; i >= OLA.MIN_CHANNEL_NUMBER; i--) { | ||
| var value = channelValueCheck(dmx[i - 1]); | ||
| for (var channel = OLA.MAX_CHANNEL_NUMBER; | ||
| channel >= OLA.MIN_CHANNEL_NUMBER; | ||
| channel--) { | ||
|
|
||
| var value = channelValueCheck(dmx[channel - 1]); | ||
| if (value > OLA.MIN_CHANNEL_VALUE || | ||
| !strip || | ||
| i === OLA.MIN_CHANNEL_NUMBER) { | ||
| integers[i - 1] = value; | ||
| strip = false; | ||
| channel <= highestChannelNumberUsed) { | ||
|
|
||
| integers[channel - 1] = value; | ||
|
|
||
| if (highestChannelNumberUsed < channel) { | ||
| highestChannelNumberUsed = channel; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again would $window.Math.max be easier?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it works. Thanks. |
||
| } | ||
| } | ||
| return integers.join(','); | ||
| }; | ||
| return { | ||
| resetHighestChannelNumberUsed: function() { | ||
| highestChannelNumberUsed = 0; | ||
| }, | ||
| get: { | ||
| ItemList: function() { | ||
| return $http.get('/json/universe_plugin_list') | ||
|
|
@@ -118,6 +139,7 @@ ola.factory('$ola', ['$http', '$window', 'OLA', | |
| } | ||
| }) | ||
| .then(function(response) { | ||
| updateHighestChannelNumberUsed(response.data.dmx); | ||
| return response.data; | ||
| }); | ||
| }, | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Sort the file: