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

New web UI, store highest channel number used #1739

Open
wants to merge 8 commits into
base: 0.10
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines 29 to 31
Copy link
Member

Choose a reason for hiding this comment

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

Sort the file:

Suggested change
Stefan Krüger, added APA102 support to the SPI Plugin
Tobi Schäfer, for the MacPort files
Stefan S, improved timing with monotonic clock
Stefan Krüger, added APA102 support to the SPI Plugin
Stefan S, improved timing with monotonic clock
Tobi Schäfer, for the MacPort files

Christian Mouttet, various fixes
Copy link
Member

Choose a reason for hiding this comment

The 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.

7 changes: 5 additions & 2 deletions README.developer
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

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

Fix some grammar:

Suggested change
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.
The sources for the new UI are located in javascript/new-src. The built artifacts
are copied to olad/www/new/js/app.min.js.


Closure Compiler
----------------
Expand Down
1 change: 1 addition & 0 deletions javascript/new-src/src/controllers/universe.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ola.controller('universeCtrl',
'use strict';
$scope.dmx = [];
$scope.Universe = $routeParams.id;
$ola.resetHighestChannelNumberUsed();
Copy link
Member

Choose a reason for hiding this comment

The 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)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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. :)
I tried to to work with something like this $scope.highestChannelNumberUsed = 0 but I failed.

Copy link
Member

Choose a reason for hiding this comment

The 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) {
Expand Down
47 changes: 39 additions & 8 deletions javascript/new-src/src/factories/ola.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Copy link
Member

Choose a reason for hiding this comment

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

Would this help clarify your last sentence?

Suggested change
// Search for the highest channel in the array `dmx`
// Search for the new highest channel in the array `dmx`

// that having a value greater than MIN_CHANNEL_VALUE
Copy link
Member

Choose a reason for hiding this comment

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

Grammar wise we want either:

Suggested change
// that having a value greater than MIN_CHANNEL_VALUE
// that has a value greater than MIN_CHANNEL_VALUE

Or:

Suggested change
// that having a value greater than MIN_CHANNEL_VALUE
// having a value greater than MIN_CHANNEL_VALUE

// 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;
Copy link
Member

Choose a reason for hiding this comment

The 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);
Copy link
Member

Choose a reason for hiding this comment

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

This should probably call channelValueCheck to sanity check the value the field was set to. But then updateHighestChannelNumberUsed is just dmxConvert without the return, so perhaps we should just have one function?

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) {
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -118,6 +148,7 @@ ola.factory('$ola', ['$http', '$window', 'OLA',
}
})
.then(function(response) {
updateHighestChannelNumberUsed(response.data.dmx);
return response.data;
});
},
Expand Down Expand Up @@ -360,4 +391,4 @@ ola.factory('$ola', ['$http', '$window', 'OLA',
}
};
}
]);
]);
2 changes: 1 addition & 1 deletion olad/www/new/css/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading