-
Notifications
You must be signed in to change notification settings - Fork 204
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
New web UI, store highest channel number used #1739
base: 0.10
Are you sure you want to change the base?
Changes from all commits
34a7769
6d7a9af
f5faaec
da36879
8f443cb
4eacc64
1f57145
c5b8700
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 |
---|---|---|
|
@@ -29,3 +29,4 @@ Contributors: | |
Stefan Krüger, added APA102 support to the SPI Plugin | ||
Tobi Schäfer, for the MacPort files | ||
Stefan S, improved timing with monotonic clock | ||
Christian Mouttet, various fixes | ||
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. Can you sort your name entry too please (which avoids any issues with who did the most). Feel free to change the top line to be "Contributors (in alphabetical order):" or similar. |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -197,8 +197,11 @@ Please follow the Sun Java style guide. | |||||||||
Javascript | ||||||||||
=============================================================================== | ||||||||||
|
||||||||||
Javascript is used for the olad web UI. Instructions for building the | ||||||||||
javascript can be found in javascript/README. | ||||||||||
Javascript is used for the olad web UIs. Instructions for building the | ||||||||||
original UI's Javascript can be found in javascript/README. | ||||||||||
|
||||||||||
The sources for the new UI is located in javascript/new-src. The built artifacts | ||||||||||
is copied to olad/www/new/js/app.min.js. | ||||||||||
Comment on lines
+203
to
+204
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(); | ||
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)? 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. :) 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,29 @@ | |||||||||
ola.factory('$ola', ['$http', '$window', 'OLA', | ||||||||||
function($http, $window, OLA) { | ||||||||||
'use strict'; | ||||||||||
// holds the highest channel that was used by faders or the keypad | ||||||||||
var highestChannelNumberUsed = 0; | ||||||||||
peternewman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
// Search for the highest channel in the array `dmx` | ||||||||||
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. Would this help clarify your last sentence?
Suggested change
|
||||||||||
// that having a value greater than MIN_CHANNEL_VALUE | ||||||||||
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. Grammar wise we want either:
Suggested change
Or:
Suggested change
|
||||||||||
// and update `highestChannelNumberUsed` if needed. | ||||||||||
// | ||||||||||
// Only channels higher than the current `highestChannelNumberUsed` | ||||||||||
// will be checked. | ||||||||||
var updateHighestChannelNumberUsed = function(dmx) { | ||||||||||
for (var channel = dmx.length; channel > highestChannelNumberUsed; | ||||||||||
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--) { | ||||||||||
|
||||||||||
var value = parseInt(dmx[channel - 1], 10); | ||||||||||
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. This should probably call |
||||||||||
if (value > OLA.MIN_CHANNEL_VALUE) { | ||||||||||
// if `Math.max` changed `highestChannelNumberUsed` | ||||||||||
// the for-loop will be terminated | ||||||||||
highestChannelNumberUsed = $window.Math.max( | ||||||||||
highestChannelNumberUsed, channel); | ||||||||||
} | ||||||||||
} | ||||||||||
}; | ||||||||||
|
||||||||||
// 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 +75,27 @@ 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; | ||||||||||
|
||||||||||
highestChannelNumberUsed = $window.Math.max( | ||||||||||
highestChannelNumberUsed, channel); | ||||||||||
} | ||||||||||
} | ||||||||||
return integers.join(','); | ||||||||||
}; | ||||||||||
return { | ||||||||||
resetHighestChannelNumberUsed: function() { | ||||||||||
highestChannelNumberUsed = 0; | ||||||||||
}, | ||||||||||
get: { | ||||||||||
ItemList: function() { | ||||||||||
return $http.get('/json/universe_plugin_list') | ||||||||||
|
@@ -118,6 +148,7 @@ ola.factory('$ola', ['$http', '$window', 'OLA', | |||||||||
} | ||||||||||
}) | ||||||||||
.then(function(response) { | ||||||||||
updateHighestChannelNumberUsed(response.data.dmx); | ||||||||||
return response.data; | ||||||||||
}); | ||||||||||
}, | ||||||||||
|
@@ -360,4 +391,4 @@ ola.factory('$ola', ['$http', '$window', 'OLA', | |||||||||
} | ||||||||||
}; | ||||||||||
} | ||||||||||
]); | ||||||||||
]); |
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: