From 8e5bf1f8ab45d2d807d9f53b2e4dc5e002dbf52d Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Mon, 13 May 2013 23:46:49 -0400 Subject: [PATCH] VRFS-292 added Music Audio tab validations --- app/assets/javascripts/layout.js | 8 ++ app/assets/javascripts/session.js | 116 +++++++++++++++++++++++++--- app/views/clients/_session.html.erb | 24 +++++- 3 files changed, 133 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/layout.js b/app/assets/javascripts/layout.js index 823b870ea..89d348af2 100644 --- a/app/assets/javascripts/layout.js +++ b/app/assets/javascripts/layout.js @@ -522,6 +522,14 @@ changeToScreen(screen, data); }; + this.showDialog = function(dialog) { + showDialog(dialog); + }; + + this.close = function(evt) { + close(evt); + }; + /** * Given information on a grid, and a given card's grid settings, use the * margin options and return a list of [top, left, width, height] diff --git a/app/assets/javascripts/session.js b/app/assets/javascripts/session.js index 0e266f9c8..e68611234 100644 --- a/app/assets/javascripts/session.js +++ b/app/assets/javascripts/session.js @@ -11,6 +11,33 @@ var mixers = []; var myTrackCount = 0; + var instrument_map = { + 0: "acoustic guitar", + 1: "bass guitar", + 2: "computer", + 3: "drums", + 4: "electric guitar", + 5: "keyboard", + 6: "voice", + 7: "flute", + 8: "clarinet", + 9: "saxophone", + 10: "trumpet", + 11: "violin", + 12: "trombone", + 13: "banjo", + 14: "harmonica", + 15: "accordion", + 16: "french horn", + 17: "euphonium", + 18: "tuba", + 19: "oboe", + 20: "ukulele", + 21: "cello", + 22: "viola", + 23: "mandolin" + }; + // dialog variables var unusedAudioInputChannels = []; var track1AudioInputChannels = []; @@ -403,7 +430,7 @@ var newTrack = context.JK.fillTemplate(template, trackData); $destination.append(newTrack); $('div[mixer-id="' + trackData.mixerId + '"].track-icon-settings').click(function() { - initMusicAudioPanel(); + showMusicAudioPanel(); }); tracks[trackData.clientId] = new context.JK.SessionTrack(trackData.clientId); } @@ -695,16 +722,16 @@ // validate voice chat settings //if (validateVoiceChatSettings()) { setAudioInstructions(); - initMusicAudioPanel(); + showMusicAudioPanel(); //} }); $('#tab-configure-voice').click(function() { // validate audio settings - //if (validateAudioSettings()) { - initVoiceChatPanel(); + if (validateAudioSettings()) { + showVoiceChatPanel(); $('#instructions', 'div[layout-id="configure-audio"]').html(configure_voice_instructions); - //} + } }); // Track 1 Add @@ -738,7 +765,7 @@ }); $('.voicechat-settings').click(function() { - initVoiceChatPanel(); + showVoiceChatPanel(); }); $('#audio-drivers').change(function() { @@ -750,6 +777,10 @@ context.jamClient.TrackOpenControlPanel(); }); + $('#btn-cancel-new-audio').click(showOverlay); + + $('#btn-error-ok').click(showOverlay); + $('#btn-save-settings').click(saveSettings); $('#btn-cancel-settings').click(cancelSettings); @@ -759,9 +790,18 @@ }); } + function showOverlay() { + $('.dialog-overlay').show(); + } + function audioDriverChanged() { context.jamClient.TrackSetMusicDevice($('#audio-drivers').val()); + // refresh dialog + showMusicAudioPanel(); + } + + function configureDriverSettingsButton() { if (context.jamClient.TrackHasControlPanel()) { logger.debug("Showing DRIVER SETTINGS button..."); $('#btn-driver-settings').show(); @@ -772,7 +812,9 @@ } } - function initMusicAudioPanel() { + function showMusicAudioPanel() { + + configureDriverSettingsButton(); $('div[tab-id="music-audio"]').show(); $('div[tab-id="voice-chat"]').hide(); @@ -844,7 +886,7 @@ loadOptions($('#audio-output-selection'), usedAudioOutputChannels, "device_id", "name", -1); } - function initVoiceChatPanel() { + function showVoiceChatPanel() { $('div[tab-id="music-audio"]').hide(); $('div[tab-id="voice-chat"]').show(); @@ -893,7 +935,9 @@ usedChatInputChannels.push(val); } else if (assignment === 0) { - unusedAudioInputChannels.push(val); + if (!val.chat) { + unusedAudioInputChannels.push(val); + } } else if (assignment === -1) { @@ -914,7 +958,9 @@ } else if (assignment === 0) { - unusedAudioOutputChannels.push(val); + if (!val.chat) { + unusedAudioOutputChannels.push(val); + } } else if (assignment === -1) { @@ -960,6 +1006,9 @@ // update jam-db with settings // TODO: reload / refresh Session screen (instrument icons at minimum) + original_device_id = $('#audio-drivers').val(); + + $('div[layout-id="configure-audio"]').hide(); } function cancelSettings() { @@ -968,10 +1017,55 @@ } function validateAudioSettings() { + var isValid = true; + var noTrackErrMsg = 'You must assign at least one input port to each of your tracks. Please update your settings to correct this. If you want to delete a track, please return to the session screen and delete the track by clicking the "x" box in the upper right-hand corner of the track.'; + var noInstrumentErrMsg = 'You must specify what instrument is being played for each track. Please update your settings to correct this.'; + var outputErrMsg = 'You must assign two output ports for stereo session audio to hear music. Please update your settings to correct this.'; + + var errMsg; + // verify Track 1 Input and Instrument exist + if ($('#track1-input').val() == null) { + errMsg = noTrackErrMsg; + isValid = false; + } + + if (isValid) { + if ($('#track1-instrument').val() == null) { + errMsg = noInstrumentErrMsg; + isValid = false; + } + } + + // if Track 2 exists, verify Input and Instrument exist + if (isValid && myTrackCount > 1) { + if ($('#track2-input').val() == null) { + errMsg = noTrackErrMsg; + isValid = false; + } + + if (isValid && $('#track2-instrument').val() == null) { + errMsg = noInstrumentErrMsg; + isValid = false; + } + } // verify Session Audio Output exists - return true; + if (isValid && ($('#audio-output-selection').val() == null || ("#audio-output-selection :selected").length != 2)) { + errMsg = outputErrMsg; + isValid = false; + } + + if (!isValid) { + showErrorDialog(errMsg); + } + + return isValid; + } + + function showErrorDialog(msg) { + app.layout.showDialog('error-dialog'); + $('#error-msg', 'div[layout-id="error-dialog"]').html(msg); } function validateVoiceChatSettings() { diff --git a/app/views/clients/_session.html.erb b/app/views/clients/_session.html.erb index 0bf5ddbfa..6d4b7f22b 100644 --- a/app/views/clients/_session.html.erb +++ b/app/views/clients/_session.html.erb @@ -218,13 +218,13 @@




Track 1 Instrument:
-

Track 2 Instrument:
-
@@ -262,7 +262,7 @@

CANCEL  - UPDATE SETTINGS + UPDATE SETTINGS

@@ -330,13 +330,29 @@ To add a new audio device, you must exit your current session and test the device using the JamKazam automated test feature.

- CANCEL  + CANCEL  LEAVE SESSION & START TEST

+
+
+ <%= image_tag "content/icon_add.png", {:width => 19, :height => 19, :class => 'content-icon' } %> +

invalid settings

+
+
+ +

+
+ OK +
+
+
+
+ +