Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop

This commit is contained in:
Scott Comer 2014-03-02 23:17:05 -06:00
commit 8c65c272ec
13 changed files with 123 additions and 58 deletions

View File

@ -28,15 +28,20 @@
var audioProfiles = prettyPrintAudioProfiles(context.jamClient.TrackGetDevices());
var badAudioConfigs = context.JK.getBadAudioConfigs();
var template = context.JK.fillTemplate($('#template-account-main').html(), {
email: userDetail.email,
name: userDetail.name,
location : userDetail.location,
instruments : prettyPrintInstruments(userDetail.instruments),
photoUrl : context.JK.resolveAvatarUrl(userDetail.photo_url),
profiles : audioProfiles
validProfiles : audioProfiles,
invalidProfiles : badAudioConfigs.length > 0 ? badAudioConfigs.join(", ") : "N/A"
});
$('#account-content-scroller').html(template );
$('#account-content-scroller').html(template);
badAudioConfigs.join(", ");
}
function prettyPrintAudioProfiles(devices) {

View File

@ -30,21 +30,30 @@
function populateAccountAudio() {
// load Audio Driver dropdown
var devices = context.jamClient.TrackGetDevices();
$('#account-audio-content-scroller table tbody').html('');
var badAudioConfigs = context.JK.getBadAudioConfigs();
// render valid device profiles
var options = {
devices: devices
configurations: context.JK.getGoodAudioConfigs(),
valid: 1
}
var template = context._.template($('#template-account-audio').html(), options, {variable: 'data'});
appendAudio(template);
// render invalid device profiles
options = {
configurations: badAudioConfigs,
valid: 0
}
template = context._.template($('#template-account-audio').html(), options, {variable: 'data'});
appendAudio(template);
}
function appendAudio(template) {
$('#account-audio-content-scroller table tbody').replaceWith(template);
$('#account-audio-content-scroller table tbody').append(template);
}
function resetForm() {

View File

@ -186,7 +186,7 @@
context.JK.GA.trackSessionMusicians(context.JK.GA.SessionCreationTypes.create);
},
error: function() {
app.ajaxError(arguments);
app.notifyServerError(arguments0, "Unable to Create Session");
$('#btn-create-session').removeClass('button-disabled');
$('#btn-create-session').unbind('click', false);
}

View File

@ -140,6 +140,14 @@
return ['a'];
}
function FTUEGetAllAudioConfigurations() {
return ['a'];
}
function FTUEGetGoodAudioConfigurations() {
return ['a'];
}
function RegisterVolChangeCallBack(functionName) {
dbg('RegisterVolChangeCallBack');
}
@ -664,6 +672,8 @@
this.FTUEStartLatency = FTUEStartLatency;
this.FTUEGetExpectedLatency = FTUEGetExpectedLatency;
this.FTUEGetGoodConfigurationList = FTUEGetGoodConfigurationList;
this.FTUEGetAllAudioConfigurations = FTUEGetAllAudioConfigurations;
this.FTUEGetGoodAudioConfigurations = FTUEGetGoodAudioConfigurations;
// Session
this.SessionAddTrack = SessionAddTrack;

View File

@ -465,9 +465,14 @@
];
var optionsHtml = '';
var deviceOptionFunc = function (deviceKey, index, list) {
optionsHtml += '<option title="' + devices[deviceKey] + '" value="' + deviceKey + '">' +
devices[deviceKey] + '</option>';
optionsHtml += '<option title="' + devices[deviceKey] + '" value="' + deviceKey + '">' + devices[deviceKey] + '</option>';
};
var badDeviceOptionFunc = function(deviceKey, index, list) {
optionsHtml += '<option disabled="disabled" title="' + deviceKey + '" value="' + deviceKey + '">' + deviceKey + ' (unavailable)' + '</option>';
};
var badAudioConfigs = context.JK.getBadAudioConfigs();
for (var i = 0; i < funcs.length; i++) {
optionsHtml = '<option selected="selected" value="">Choose...</option>';
@ -476,10 +481,11 @@
$select.empty();
var sortedDeviceKeys = context._.keys(devices).sort();
context._.each(sortedDeviceKeys, deviceOptionFunc);
context._.each(badAudioConfigs, badDeviceOptionFunc);
$select.html(optionsHtml);
context.JK.dropdown($select);
$select.removeAttr("disabled");
$('[layout-wizard-step="2"] .settings-asio select').removeAttr("disabled").easyDropDown('enable')
$('[layout-wizard-step="2"] .settings-asio select').removeAttr("disabled").easyDropDown('enable');
// Set selects to lowest possible values to start:
$('#asio-framesize').val('2.5').change();
$('#asio-input-latency').val('0').change();
@ -505,6 +511,12 @@
drivers[driverKey] + '</option>';
};
var badDeviceOptionFunc = function(deviceKey, index, list) {
optionsHtml += '<option disabled="disabled" title="' + deviceKey + '" value="' + deviceKey + '">' + deviceKey + ' (unavailable)' + '</option>';
};
var badAudioConfigs = context.JK.getBadAudioConfigs();
var optionsHtml = '<option selected="selected" value="">Choose...</option>';
var selectors = [
'[layout-wizard-step="0"] .settings-2-device select',
@ -513,6 +525,7 @@
];
var sortedDeviceKeys = context._.keys(drivers).sort();
context._.each(sortedDeviceKeys, driverOptionFunc);
context._.each(badAudioConfigs, badDeviceOptionFunc);
$.each(selectors, function (index, selector) {
var $select = $(selector);
$select.empty();

View File

@ -106,7 +106,7 @@
} else {
rest.createEmailInvitations(emails, $('#txt-message').val())
.error(function() {
app.ajaxError(arguments);
app.ajaxError();
app.layout.closeDialog('inviteUsers');
}).success(function() {
app.notifyAlert('Invites sent', 'You sent '+emails.length.toString()+' email invites');

View File

@ -101,7 +101,7 @@
userId: val.id,
cssClass: css,
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
userName: val.name,
userName: val.name.length > 20 ? val.name.substring(0,20) + "..." : val.name,
status: val.online ? 'Available' : 'Offline',
extra_info: '',
hoverAction: val.musician ? "musician" : "fan",

View File

@ -642,7 +642,25 @@
var result = context.jamClient.FTUEGetGoodConfigurationList();
console.log("hasOneConfiguredDevice: ", result);
return result.length > 0;
}
};
context.JK.getGoodAudioConfigs = function() {
return context.jamClient.FTUEGetGoodAudioConfigurations();
};
context.JK.getBadAudioConfigs = function() {
var badAudioConfigs = [];
var allAudioConfigs = context.jamClient.FTUEGetAllAudioConfigurations();
var goodAudioConfigs = context.JK.getGoodAudioConfigs();
for (var i=0; i < allAudioConfigs.length; i++) {
if ($.inArray(allAudioConfigs[i], goodAudioConfigs) === -1) {
badAudioConfigs.push(allAudioConfigs[i]);
}
}
return badAudioConfigs;
};
/*

View File

@ -162,7 +162,13 @@
}
}
tr.invalid-profile {
background-color:red;
}
img.invalid-profile {
vertical-align:middle;
}
.button-grey {
margin-right:6px;

View File

@ -31,8 +31,16 @@
iu.save
iu
end
else
iu = InvitedUser.new
iu.sender = current_user
iu.save
@invited_users = [iu]
end
if err = @invited_users.detect {|iu| iu.errors.any? }
response.status = :unprocessable_entity
respond_with err
end
respond_with @invited_users, :responder => ApiResponder, :location => invitations_url(@invited_users)
end
end

View File

@ -106,7 +106,8 @@
</div>
<div class="account-mid audio">
<strong>Approved Profiles:</strong> <span class="audio-profiles-short">{profiles}</span>
<strong>Approved Profiles:</strong> <span class="audio-profiles-short">{validProfiles}</span><br />
<strong>Invalid Profiles:</strong> <span class="audio-profiles-short">{invalidProfiles}</span>
</div>
<div class="right">

View File

@ -34,25 +34,28 @@
</tbody>
</table>
<br clear="all" />
<div class="left"><a href="#" data-purpose="add-profile" class="button-orange">ADD NEW PROFILE</a></div><div class="right"><a href="javascript:history.go(-1)" class="button-grey">BACK</a></div>
</div>
<br clear="all" />
<br clear="all" />
<br clear="all" />
<br clear="all" />
<div class="ml35">
<img src="/assets/content/icon_alert_big.png" class="invalid-profile" width="15" height="15" /> &mdash; INVALID CONFIGURATION OR DEVICE NOT CONNECTED
</div>
</div>
</div>
<!-- end content scrolling area -->
</div>
<script type="text/template" id="template-account-audio">
<tbody>
{% var keys = Object.keys(data.devices); %}
{% for (var i = 0; i < keys.length; i++) { %}
<tr>
<td>{{data.devices[keys[i]]}}</td>
<td class="actions"><a href="#" data-id="{{keys[i]}}" data-purpose="delete-audio-profile" class="button-orange">DELETE</a></td>
</tr>
{% } %}
</tbody>
{% var configs = data.configurations; %}
{% for (var i = 0; i < configs.length; i++) { %}
<tr>
<td>{{configs[i]}} &nbsp; {% if (data.valid === 0) { %} <img src="/assets/content/icon_alert_big.png" width="15" height="15" class="invalid-profile" /> {% } %}</td>
<td class="actions"><a href="#" data-id="{{configs[i]}}" data-purpose="delete-audio-profile" class="button-orange">DELETE</a></td>
</tr>
{% } %}
</script>

View File

@ -25,17 +25,15 @@ describe "Invited Users API ", :type => :api do
end
it "create with no note" do
post '/api/invited_users.json', {:email => 'tester@jamkazam.com'}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(201)
post '/api/invited_users.json', {:emails => ['tester@jamkazam.com']}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(200)
UserMailer.deliveries.length.should == 1
# now fetch it's data
location_header = last_response.headers["Location"]
get location_header
# parse json and test
body = JSON.parse(last_response.body)
bodies = JSON.parse(last_response.body)
expect(bodies.size).to eq(1)
body = bodies[0]
body["id"].should_not be_nil
body["created_at"].should_not be_nil
body["email"].should == "tester@jamkazam.com"
@ -44,14 +42,12 @@ describe "Invited Users API ", :type => :api do
end
it "create with a note" do
post '/api/invited_users.json', {:email => 'tester@jamkazam.com', :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(201)
post '/api/invited_users.json', {:emails => ['tester@jamkazam.com'], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(200)
# now fetch it's data
location_header = last_response.headers["Location"]
get location_header
body = JSON.parse(last_response.body)
bodies = JSON.parse(last_response.body)
expect(bodies.length).to eq(1)
body = bodies[0]
body["id"].should_not be_nil
body["created_at"].should_not be_nil
body["email"].should == "tester@jamkazam.com"
@ -63,7 +59,7 @@ describe "Invited Users API ", :type => :api do
user.can_invite = false
user.save
post '/api/invited_users.json', {:email => 'tester@jamkazam.com', :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
post '/api/invited_users.json', {:emails => ['tester@jamkazam.com'], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(422)
body = JSON.parse(last_response.body)
body["errors"].should_not be_nil
@ -79,7 +75,7 @@ describe "Invited Users API ", :type => :api do
end
it "cant create with blank email" do
post '/api/invited_users.json', {:email => "", :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
post '/api/invited_users.json', {:emails => [""], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(422)
body = JSON.parse(last_response.body)
body["errors"].should_not be_nil
@ -87,7 +83,7 @@ describe "Invited Users API ", :type => :api do
end
it "cant create with invalid email" do
post '/api/invited_users.json', {:email => "blurp", :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
post '/api/invited_users.json', {:emails => ["blurp"], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(422)
body = JSON.parse(last_response.body)
body["errors"].should_not be_nil
@ -95,14 +91,12 @@ describe "Invited Users API ", :type => :api do
end
it "list" do
post '/api/invited_users.json', {:email => "tester@jamkazam.com", :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(201)
post '/api/invited_users.json', {:emails => ["tester@jamkazam.com"], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(200)
# now fetch it's data
location_header = last_response.headers["Location"]
get location_header
body = JSON.parse(last_response.body)
bodies = JSON.parse(last_response.body)
expect(bodies.length).to eq(1)
body = bodies[0]
id = body["id"]
get '/api/invited_users.json', "CONTENT_TYPE" => 'application/json'
@ -115,14 +109,12 @@ describe "Invited Users API ", :type => :api do
end
it "show" do
post '/api/invited_users.json', {:email => "tester@jamkazam.com", :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(201)
post '/api/invited_users.json', {:emails => ["tester@jamkazam.com"], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(200)
# now fetch it's data
location_header = last_response.headers["Location"]
get location_header
body = JSON.parse(last_response.body)
bodies = JSON.parse(last_response.body)
expect(bodies.length).to eq(1)
body = bodies[0]
id = body["id"]
get "/api/invited_users/#{id}.json", "CONTENT_TYPE" => 'application/json'