diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index e08c5260c..08e2f7bee 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -1949,7 +1949,7 @@ module JamRuby end def can_buy_test_drive? - lesson_purchases.where('lesson_package_type_id in (?)', LessonPackageType.test_drive_package_ids).where('created_at > ?', Rails.application.config.test_drive_wait_period_year.years.ago).count == 0 + lesson_purchases.where('lesson_package_type_id in (?)', LessonPackageType.test_drive_package_ids).where('created_at > ?', APP_CONFIG.test_drive_wait_period_year.years.ago).count == 0 end def lessons_with_teacher(teacher) diff --git a/web/app/assets/javascripts/dialog/configureTrackDialog.js b/web/app/assets/javascripts/dialog/configureTrackDialog.js index c7b908fbc..9b4f559dd 100644 --- a/web/app/assets/javascripts/dialog/configureTrackDialog.js +++ b/web/app/assets/javascripts/dialog/configureTrackDialog.js @@ -20,6 +20,7 @@ var $btnCancel = null; var $btnAddNewGear = null; var $btnUpdateTrackSettings = null; + var $btnCloseJamBlasterConfig = null; var configureTracksHelper = null; var voiceChatHelper = null; @@ -244,7 +245,10 @@ } function afterShow() { - sessionUtils.SessionPageEnter(); + + if (!window.JamBlasterStore.pairedJamBlaster) { + sessionUtils.SessionPageEnter(); + } window.JamBlasterActions.resyncBonjour() @@ -258,7 +262,9 @@ function afterHide() { voiceChatHelper.beforeHide(); - sessionUtils.SessionPageLeave(); + if(!window.JamBlasterStore.pairedJamBlaster) { + sessionUtils.SessionPageLeave(); + } } function initialize() { diff --git a/web/app/assets/javascripts/react-components/ConfigureTracksDialogContents.js.jsx.coffee b/web/app/assets/javascripts/react-components/ConfigureTracksDialogContents.js.jsx.coffee index b9469858e..a017a860e 100644 --- a/web/app/assets/javascripts/react-components/ConfigureTracksDialogContents.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/ConfigureTracksDialogContents.js.jsx.coffee @@ -3,90 +3,102 @@ JamBlasterActions = @JamBlasterActions @ConfigureTracksDialogContents = React.createClass({ - mixins: [Reflux.listenTo(@AppStore, "onAppInit"), Reflux.listenTo(@JamBlasterStore, "onJamBlasterChanged")] + mixins: [Reflux.listenTo(@AppStore, "onAppInit"), Reflux.listenTo(@JamBlasterStore, "onJamBlasterChanged")] - onAppInit: (@app) -> + onAppInit: (@app) -> - onJamBlasterChanged: (jamblasterState) -> - @setState(jamblasterState) + onJamBlasterChanged: (jamblasterState) -> + @setState(jamblasterState) - getInitialState: () -> - { - timer: null, - pairing: false, - pairStart: null, - allJamBlasters: [], - pairingTimeout: false, - paired: false, - userJamBlasters: [], - localJamBlasters: [] - } + getInitialState: () -> + { + timer: null, + pairing: false, + pairStart: null, + allJamBlasters: [], + pairingTimeout: false, + paired: false, + userJamBlasters: [], + localJamBlasters: [] + } + + closeDialog: (e) -> + e.preventDefault() + if !this.state.waitingOnTracks + @app.layout.closeDialog('configure-tracks') - render: () -> - pairedJamBlaster = this.state.pairedJamBlaster - hasPairedJamBlaster = pairedJamBlaster? + render: () -> + pairedJamBlaster = this.state.pairedJamBlaster + hasPairedJamBlaster = pairedJamBlaster? - if hasPairedJamBlaster - `` - else - `
-
- Inputs & Outputs - Voice Chat -
-
+ if hasPairedJamBlaster + `
+ + +
+ CLOSE +
+
` + else + `
+
+ Inputs & Outputs + Voice Chat +
+
Choose your audio device. Drag and drop to assign input ports to tracks, and specify the instrument for each track. Drag and drop to assign a pair of output ports for session stereo audio monitoring. -
-
-
- - -
-
-
-
-
Select Voice Chat Option
-
- - -

Use Music Microphone

- -

I am already using a microphone to capture my vocal or instrumental music, so I can talk with other - musicians using that microphone

-
-
- - -

Use Chat Microphone

- -

I am not using a microphone for acoustic instruments or vocals, so use the input selected to the right - for voice chat during my sessions

-
-
-
-
-
Voice Chat Input
-
-
-
-
-
-
GAIN
-
-
-
-
+
+ - -
` +
+
+
+
+
Select Voice Chat Option
+
+ + +

Use Music Microphone

+ +

I am already using a microphone to capture my vocal or instrumental music, so I can talk with other + musicians using that microphone

+
+
+ + +

Use Chat Microphone

+ +

I am not using a microphone for acoustic instruments or vocals, so use the input selected to the + right + for voice chat during my sessions

+
+
+
+
+
Voice Chat Input
+
+
+
+
+
+
GAIN
+
+
+
+
+
+
+ +
+ ADD NEW AUDIO GEAR + CANCEL + SAVE SETTINGS +
+
` } ) diff --git a/web/app/assets/javascripts/react-components/JamBlasterScreen.js.jsx.coffee b/web/app/assets/javascripts/react-components/JamBlasterScreen.js.jsx.coffee index c2e74dac5..1a62c0ce1 100644 --- a/web/app/assets/javascripts/react-components/JamBlasterScreen.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/JamBlasterScreen.js.jsx.coffee @@ -35,7 +35,7 @@ JamBlasterActions = @JamBlasterActions @setState(jamblasterState) componentDidMount: () -> - @checkboxes = [{selector: 'input.dhcp', stateKey: 'dhcp'}] + @checkboxes = [{selector: 'input.dhcp', stateKey: 'userdhcp'}] @root = $(@getDOMNode()) @iCheckify() @@ -279,14 +279,17 @@ JamBlasterActions = @JamBlasterActions onSaveNetworkSettings: (e) -> e.preventDefault() - JamBlasterActions.saveNetworkSettings({ + settings = { dhcp: this.state.userdhcp, addr: this.state.useraddr, gateway: this.state.usergateway, subnet: this.state.usersubnet, dns1: this.state.userdns1, dns2: this.state.userdns2 - }) + } + + logger.debug("saving network settings", settings) + JamBlasterActions.saveNetworkSettings(settings) @networkStale = true usb: () -> diff --git a/web/app/assets/javascripts/react-components/JamBlasterTrackConfig.js.jsx.coffee b/web/app/assets/javascripts/react-components/JamBlasterTrackConfig.js.jsx.coffee index 37eb40144..d86690ba3 100644 --- a/web/app/assets/javascripts/react-components/JamBlasterTrackConfig.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/JamBlasterTrackConfig.js.jsx.coffee @@ -53,7 +53,7 @@ JamBlasterActions = @JamBlasterActions value = $(e.target).val() name = $(e.target).attr('name') - console.log("checkbox changed: ", value) + console.log("checkbox changed: ", checked, value) if $(e.target).attr('type') == 'checkbox' state = {} @@ -70,7 +70,7 @@ JamBlasterActions = @JamBlasterActions JamBlasterActions.updateAudio(name, value) instrumentChanged: (key, e) -> - value = $(e.target).val() + value = $(e.target).val() state = {} state[key] = value @setState(state) @@ -97,6 +97,7 @@ JamBlasterActions = @JamBlasterActions hasPairedJamBlaster = pairedJamBlaster? masterDisabled = this.props.disabled + if !hasPairedJamBlaster return `
You have no paired JamBlaster currently. If you've paired the JamBlaster in the past, be sure it's plugged in @@ -108,7 +109,7 @@ JamBlasterActions = @JamBlasterActions for instrument in context.JK.server_to_client_instrument_alpha instruments.push(``) - console.log("JAMBLASTERTRACKCONFIG", pairedJamBlaster ) + #console.log("JAMBLASTERTRACKCONFIG", pairedJamBlaster) combined = @state.combined track1Active = @state.track1Active @@ -118,80 +119,98 @@ JamBlasterActions = @JamBlasterActions track1Phantom = @state.track1Phantom track2Phantom = @state.track2Phantom micActive = @state.micActive - track1Instrument = context.JK.convertClientInstrumentToServer(@state.track1Instrument) - track2Instrument = context.JK.convertClientInstrumentToServer(@state.track2Instrument) + track1Instrument = @state.track1Instrument #context.JK.convertClientInstrumentToServer(@state.track1Instrument) + track2Instrument = @state.track2Instrument #context.JK.convertClientInstrumentToServer(@state.track2Instrument) - console.log("track1Active", track1Active) + if this.state.waitingOnTracks + contents = `
+
+
+
+

Please wait as the JamBlaster reconfigures it's settings.

+
` + else + contents = `
+
+

Input 1

+ +
+

Type

+ +
+
+ +
+
+ +
+
+
+ +
+

Power

+ +
+ +
+
+
+

Instrument

+ +
+
+
+

Input 2

+ +
+

Type

+ +
+
+ +
+
+ +
+
+
+ +
+

Power

+ +
+ +
+
+
+

Instrument

+ +
+
+
+ +
+ +
+
` `
-
-

Input 1

-
-

Type

- -
-
- -
-
- -
-
-
- -
-

Power

- -
- -
-
-
-

Instrument

- -
-
-
-

Input 2

- -
-

Type

- -
-
- -
-
- -
-
-
- -
-

Power

- -
- -
-
-
-

Instrument

- -
-
-
- -
- -
+ {contents}
` }) \ No newline at end of file diff --git a/web/app/assets/javascripts/react-components/SessionMasterOtherTracks.js.jsx.coffee b/web/app/assets/javascripts/react-components/SessionMasterOtherTracks.js.jsx.coffee index 598415295..74089e429 100644 --- a/web/app/assets/javascripts/react-components/SessionMasterOtherTracks.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/SessionMasterOtherTracks.js.jsx.coffee @@ -15,6 +15,9 @@ context = window for participant in session.otherParticipants() + if participant.is_jamblaster + continue + name = participant.user.name; if participant.tracks.length > 0 diff --git a/web/app/assets/javascripts/react-components/SessionOtherTracks.js.jsx.coffee b/web/app/assets/javascripts/react-components/SessionOtherTracks.js.jsx.coffee index 275de1f11..7ab60ff13 100644 --- a/web/app/assets/javascripts/react-components/SessionOtherTracks.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/SessionOtherTracks.js.jsx.coffee @@ -16,6 +16,9 @@ MixerActions = context.MixerActions for participant in session.otherParticipants() + if participant.is_jamblaster + continue + if participant.client_id == @app.clientId participant.user.possessive = "Your" participant.self = true diff --git a/web/app/assets/javascripts/react-components/actions/JamBlasterActions.js.coffee b/web/app/assets/javascripts/react-components/actions/JamBlasterActions.js.coffee index 82215844c..d601e6531 100644 --- a/web/app/assets/javascripts/react-components/actions/JamBlasterActions.js.coffee +++ b/web/app/assets/javascripts/react-components/actions/JamBlasterActions.js.coffee @@ -6,5 +6,6 @@ context = window saveNetworkSettings: {}, pairState: {}, setAutoPair: {}, - updateAudio: {} + updateAudio: {}, + jamblasterTracksUpdated: {} }) diff --git a/web/app/assets/javascripts/react-components/stores/CallbackStore.js.coffee b/web/app/assets/javascripts/react-components/stores/CallbackStore.js.coffee index 43f545ecf..65bb1d115 100644 --- a/web/app/assets/javascripts/react-components/stores/CallbackStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/CallbackStore.js.coffee @@ -4,6 +4,9 @@ logger = context.JK.logger SessionActions = @SessionActions JamBlasterActions = @JamBlasterActions +#window.StupidCallback: () => +# alert("STUPID CALLBACK") + @CallbackStore = Reflux.createStore( { init: () -> @@ -12,13 +15,18 @@ JamBlasterActions = @JamBlasterActions onAppInit: (@app) -> if context.jamClient.RegisterGenericCallBack? - context.jamClient.RegisterGenericCallBack('CallbackActions.genericCallback') + console.log("REGISTERING GENERIC CALLBACK") + context.jamClient.RegisterGenericCallBack('CallbackStore.onGenericCallback') + #context.jamClient.RegisterGenericCallBack('StupidCallback') onGenericCallback: (map) -> + console.log("GENERIC CALLBACK CALLED: ", map) if map.cmd == 'join_session' SessionActions.joinSession(map['music_session_id']) else if map.cmd == 'client_pair_state' JamBlasterActions.pairState(map) + else if map.cmd == 'jamblaster_tracks_updated' + JamBlasterActions.jamblasterTracksUpdated() } ) diff --git a/web/app/assets/javascripts/react-components/stores/JamBlasterStore.js.coffee b/web/app/assets/javascripts/react-components/stores/JamBlasterStore.js.coffee index 4dc38b1f1..0bc2d4511 100644 --- a/web/app/assets/javascripts/react-components/stores/JamBlasterStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/JamBlasterStore.js.coffee @@ -9,6 +9,7 @@ logger = context.JK.logger userJamBlasters: [] localJamBlasters: [] allJamBlasters: [] + waitingOnTracks: false init: () -> # Register with the app store to get @app @@ -18,8 +19,11 @@ logger = context.JK.logger postSimpleChange: (result, msg) -> if result - @lastClientTrackState = null - @getLocalClients(@userJamBlasters) + setTimeout(()=> + @lastClientTrackState = null + @getLocalClients(@userJamBlasters) + , 1000) + else context.JK.Banner.showAlert('unable to update the JamBlaster', msg) @@ -55,6 +59,16 @@ logger = context.JK.logger @postSimpleChange(result, 'Unable to set the phantom power for Track 2') return + #else if name == 'track1Instrument' + # result = context.jamClient.set48vAndLineInstState({input2_48V: value}) + # @postSimpleChange(result, 'Unable to set the phantom power for Track 2') + # return + + #else if name == 'track1Instrument' + # result = context.jamClient.set48vAndLineInstState({input2_48V: value}) + # @postSimpleChange(result, 'Unable to set the phantom power for Track 2') + # return + audio = $.extend({}, @pairedJamBlaster.tracks) if name == 'inputTypeTrack1' @@ -68,6 +82,7 @@ logger = context.JK.logger else if name == 'micActive' audio.has_chat = value + #track1Active = @pairedJamBlaster.tracks.track1Active #if name == 'track1Active' # track1Active = value @@ -78,6 +93,10 @@ logger = context.JK.logger track1Active = true track2Active = true + has_chat = true + + + audio.has_chat = true combined = @pairedJamBlaster.tracks.combined if name == 'combined' @@ -90,10 +109,17 @@ logger = context.JK.logger if name == 'track2Instrument' track2Instrument = @convertToClientInstrument(value) + if !track1Instrument + track1Instrument = context.JK.server_to_client_instrument_map.Other.client_id + if !track2Instrument + track2Instrument = context.JK.server_to_client_instrument_map.Other.client_id + + if combined # user has chosen to combine both inputs into one track. stereo=true is the key flag her audio.track1 = {stereo: true, left: true, inst: track1Instrument} + delete audio.track2 # backend will treat null as present else @@ -105,21 +131,42 @@ logger = context.JK.logger else if track1Active #(means track) audio.track1 = {stereo: false, left: true, inst: track1Instrument} + delete audio.track2 # backend will treat null as present else # input2Active audio.track2 = {stereo: false, right: true, inst: track2Instrument} + delete audio.track1 # backend will treat null as present logger.debug("updating JamBlaster track state", audio) context.jamClient.setJbTrackState(audio); - @lastClientTrackState = null - #@waitOnTracksDone() + @waitOnTracks() else context.JK.Banner.showAlert('no paired JamBlaster', 'it seems your JamBlaster has become disconnected. Please ensure it is powered on and connected via an ethernet cable.') - waitOnTracksDone: () -> - @waitingOnTracksDone = true - @waitingOnTracksInterval = setInterval() + waitOnTracks: () -> + @lastClientTrackState = null + @waitingOnTracks = true + if @waitingOnTracksTimeout + clearTimeout(@waitingOnTracksTimeout) + @changed() + @waitingOnTracksTimeout = setTimeout(() => + @waitingOnTracksTimeout = null + if @waitingOnTracks + @waitingOnTracks = false + @changed() + context.JK.Banner.showAlert('something went wrong', 'A notice that the changes were finally applied has not been sent. Leave the session, restart the JamBlaster, and get into a session again.') + , 10000) + + # called from backend after track thrashing + jamblasterTracksUpdated: () -> + if @waitingOnTracksTimeout + clearTimeout(@waitingOnTracksTimeout) + @waitingOnTracksTimeout = null + @waitingOnTracks = false + @getLocalClients(@userJamBlasters) + @changed() + convertToClientInstrument: (instrumentId) -> clientInstrumentId = null if instrumentId != null && instrumentId != '' @@ -167,8 +214,11 @@ logger = context.JK.logger else context.JK.Banner.showAlert('network settings updated', 'Please reboot the JamBlaster.') # it will be refreshed by backend - @onClearNetworkState() - @onResyncBonjour() + setTimeout(()=> + @onClearNetworkState() + @onResyncBonjour() + , 1000) + onResyncBonjour: () -> @@ -293,7 +343,7 @@ logger = context.JK.logger # combined track1 = client.tracks.track1 - track2 = client.tracks.track1 + track2 = client.tracks.track2 if track1? client.tracks.combined = track1.stereo @@ -368,8 +418,12 @@ logger = context.JK.logger @refreshingBonjour = false @changed() + get48vAndLineState: () -> + @phantomAndLineState = context.jamClient.get48vAndLineInstState() + console.log("get48vAndLineInstState", @phantomAndLineState) + changed: () -> - @trigger({userJamBlasters: @userJamBlasters, allJamBlasters: @clients, localJamBlasters: @localClients, refreshingBonjour: @refreshingBonjour, pairedJamBlaster: @pairedJamBlaster}) + @trigger({userJamBlasters: @userJamBlasters, allJamBlasters: @clients, localJamBlasters: @localClients, refreshingBonjour: @refreshingBonjour, pairedJamBlaster: @pairedJamBlaster, waitingOnTracks: @waitingOnTracks}) } ) diff --git a/web/app/assets/stylesheets/client/react-components/JamBlasterTrackConfig.scss b/web/app/assets/stylesheets/client/react-components/JamBlasterTrackConfig.scss index 795d928cb..5161120a6 100644 --- a/web/app/assets/stylesheets/client/react-components/JamBlasterTrackConfig.scss +++ b/web/app/assets/stylesheets/client/react-components/JamBlasterTrackConfig.scss @@ -77,4 +77,16 @@ margin-bottom:10px; } } + + .waiting-on-tracks { + text-align:center; + } + .spinner-large { + width:200px; + height:200px; + line-height: 200px; + position:relative; + margin:25px auto; + display:inline-block; + } } \ No newline at end of file diff --git a/web/app/assets/stylesheets/client/user_dropdown.scss b/web/app/assets/stylesheets/client/user_dropdown.scss index b8a211f7e..130d9fcf9 100644 --- a/web/app/assets/stylesheets/client/user_dropdown.scss +++ b/web/app/assets/stylesheets/client/user_dropdown.scss @@ -78,7 +78,7 @@ .userinfo ul { clear:both; - background: scale-lightness($ColorUIBackground, 10%); + background: #4A4A4A; display:none; position:relative; } @@ -87,6 +87,6 @@ display:block; margin: 2px; padding: 2px; - background: scale-lightness($ColorUIBackground, 20%); + background: #4A4A4A; } diff --git a/web/app/views/api_music_sessions/show.rabl b/web/app/views/api_music_sessions/show.rabl index b4885c850..4fc73ea8a 100644 --- a/web/app/views/api_music_sessions/show.rabl +++ b/web/app/views/api_music_sessions/show.rabl @@ -50,7 +50,7 @@ else child(:connections => :participants) { collection @music_sessions, :object_root => false - attributes :ip_address, :client_id, :joined_session_at, :audio_latency, :id, :metronome_open + attributes :ip_address, :client_id, :joined_session_at, :audio_latency, :id, :metronome_open, :is_jamblaster node :user do |connection| { :id => connection.user.id, :photo_url => connection.user.photo_url, :name => connection.user.name, :is_friend => connection.user.friends?(current_user), :connection_state => connection.aasm_state } diff --git a/web/spec/support/app_config.rb b/web/spec/support/app_config.rb index 5bf127301..a635f0020 100644 --- a/web/spec/support/app_config.rb +++ b/web/spec/support/app_config.rb @@ -151,6 +151,9 @@ def web_config def email_partners_alias "partner-dev@jamkazam.com" end + def test_drive_wait_period_year + 1 + end end klass.new end