diff --git a/admin/app/views/admin/recordings/_claimed_recording_fields.html.haml b/admin/app/views/admin/recordings/_claimed_recording_fields.html.haml index 617084abf..6a68db880 100644 --- a/admin/app/views/admin/recordings/_claimed_recording_fields.html.haml +++ b/admin/app/views/admin/recordings/_claimed_recording_fields.html.haml @@ -6,7 +6,6 @@ = f.input :user_id, :as => :hidden, :input_html => { class: "jam_ruby_claimed_recording[user_id]" } = f.input :genre, collection: Genre.all, :member_label => :description = f.input :is_public - = f.input :is_downloadable = link_to_remove_association "Delete Claimed Recording", f, class: 'button', style: 'margin-left:10px' %div{style: 'display:none'} diff --git a/db/manifest b/db/manifest index f0f8fe03f..b0892ecfe 100755 --- a/db/manifest +++ b/db/manifest @@ -115,4 +115,5 @@ music_sessions_plays.sql plays_likes_counters.sql add_upright_bass.sql music_session_history_public.sql -track_claimed_recording.sql \ No newline at end of file +track_claimed_recording.sql +remove_is_downloadable.sql \ No newline at end of file diff --git a/db/up/remove_is_downloadable.sql b/db/up/remove_is_downloadable.sql new file mode 100644 index 000000000..7cd8bdc26 --- /dev/null +++ b/db/up/remove_is_downloadable.sql @@ -0,0 +1 @@ +ALTER TABLE claimed_recordings DROP COLUMN is_downloadable; \ No newline at end of file diff --git a/ruby/lib/jam_ruby/models/claimed_recording.rb b/ruby/lib/jam_ruby/models/claimed_recording.rb index bf01c096d..e7f8fbc4b 100644 --- a/ruby/lib/jam_ruby/models/claimed_recording.rb +++ b/ruby/lib/jam_ruby/models/claimed_recording.rb @@ -1,7 +1,7 @@ module JamRuby class ClaimedRecording < ActiveRecord::Base - attr_accessible :name, :description, :is_public, :is_downloadable, :genre_id, :recording_id, :user_id, as: :admin + attr_accessible :name, :description, :is_public, :genre_id, :recording_id, :user_id, as: :admin belongs_to :recording, :class_name => "JamRuby::Recording", :inverse_of => :claimed_recordings, :foreign_key => 'recording_id' belongs_to :user, :class_name => "JamRuby::User", :inverse_of => :claimed_recordings @@ -15,7 +15,6 @@ module JamRuby validates :name, no_profanity: true, length: {minimum: 3, maximum: 64}, presence: true validates :description, no_profanity: true, length: {maximum: 8000} validates :is_public, :inclusion => {:in => [true, false]} - validates :is_downloadable, :inclusion => {:in => [true, false]} validates :genre, presence: true validates :user, presence: true validates_uniqueness_of :user_id, :scope => :recording_id @@ -43,7 +42,6 @@ module JamRuby self.description = params[:description] unless params[:description].nil? self.genre = Genre.find(params[:genre]) unless params[:genre].nil? self.is_public = params[:is_public] unless params[:is_public].nil? - self.is_downloadable = params[:is_downloadable] unless params[:is_downloadable].nil? save end diff --git a/ruby/lib/jam_ruby/models/recording.rb b/ruby/lib/jam_ruby/models/recording.rb index 8102edb38..313e64297 100644 --- a/ruby/lib/jam_ruby/models/recording.rb +++ b/ruby/lib/jam_ruby/models/recording.rb @@ -3,7 +3,7 @@ module JamRuby self.primary_key = 'id' - attr_accessible :owner, :owner_id, :band, :band_id, :recorded_tracks_attributes, :mixes_attributes, :claimed_recordings_attributes, :name, :description, :genre, :is_public, :is_downloadable, :duration, as: :admin + attr_accessible :owner, :owner_id, :band, :band_id, :recorded_tracks_attributes, :mixes_attributes, :claimed_recordings_attributes, :name, :description, :genre, :is_public, :duration, as: :admin has_many :claimed_recordings, :class_name => "JamRuby::ClaimedRecording", :inverse_of => :recording, :foreign_key => 'recording_id', :dependent => :destroy has_many :users, :through => :recorded_tracks, :class_name => "JamRuby::User" @@ -140,7 +140,7 @@ module JamRuby # Called when a user wants to "claim" a recording. To do this, the user must have been one of the tracks in the recording. - def claim(user, name, description, genre, is_public, is_downloadable) + def claim(user, name, description, genre, is_public) unless self.users.exists?(user) raise PermissionError, "user was not in this session" @@ -153,7 +153,6 @@ module JamRuby claimed_recording.description = description claimed_recording.genre = genre claimed_recording.is_public = is_public - claimed_recording.is_downloadable = is_downloadable self.claimed_recordings << claimed_recording if claimed_recording.save diff --git a/ruby/spec/factories.rb b/ruby/spec/factories.rb index 18c28e6e7..2ffc495be 100644 --- a/ruby/spec/factories.rb +++ b/ruby/spec/factories.rb @@ -159,7 +159,6 @@ FactoryGirl.define do sequence(:name) { |n| "name-#{n}" } sequence(:description) { |n| "description-#{n}" } is_public true - is_downloadable true association :genre, factory: :genre association :user, factory: :user diff --git a/ruby/spec/jam_ruby/models/claimed_recording_spec.rb b/ruby/spec/jam_ruby/models/claimed_recording_spec.rb index f28e7a7e1..007da011c 100644 --- a/ruby/spec/jam_ruby/models/claimed_recording_spec.rb +++ b/ruby/spec/jam_ruby/models/claimed_recording_spec.rb @@ -5,11 +5,10 @@ def valid_claimed_recording @description = "description" @genre = Genre.first @is_public = true - @is_downloadable = true end def make_claim - @claimed_recording = @recording.claim(@user, @name, @description, @genre, @is_public, @is_downloadable) + @claimed_recording = @recording.claim(@user, @name, @description, @genre, @is_public) end describe ClaimedRecording do @@ -81,17 +80,6 @@ describe ClaimedRecording do end end - describe "update is_downloadable" do - it "with nil" do - valid_claimed_recording - @is_downloadable = nil - make_claim - @claimed_recording.errors.any?.should be_true - @claimed_recording.errors[:is_downloadable].length.should == 1 - @claimed_recording.errors[:is_downloadable].should == ["is not included in the list"] - end - end - describe "update genre" do it "with nil" do valid_claimed_recording @@ -107,7 +95,7 @@ describe ClaimedRecording do it "not valid" do valid_claimed_recording make_claim - duplicate = @recording.claim(@user, "name", "description", @genre, true, true) + duplicate = @recording.claim(@user, "name", "description", @genre, true) duplicate.valid?.should be_false duplicate.errors[:user_id].should == ['has already been taken'] end diff --git a/ruby/spec/jam_ruby/models/mix_spec.rb b/ruby/spec/jam_ruby/models/mix_spec.rb index 359100423..150b305e8 100755 --- a/ruby/spec/jam_ruby/models/mix_spec.rb +++ b/ruby/spec/jam_ruby/models/mix_spec.rb @@ -12,7 +12,7 @@ describe Mix do @music_session.save @recording = Recording.start(@music_session, @user) @recording.stop - @recording.claim(@user, "name", "description", Genre.first, true, true) + @recording.claim(@user, "name", "description", Genre.first, true) @recording.errors.any?.should be_false @mix = Mix.schedule(@recording) @mix.reload diff --git a/ruby/spec/jam_ruby/models/music_session_spec.rb b/ruby/spec/jam_ruby/models/music_session_spec.rb index b33a0612e..515dc33de 100644 --- a/ruby/spec/jam_ruby/models/music_session_spec.rb +++ b/ruby/spec/jam_ruby/models/music_session_spec.rb @@ -389,7 +389,7 @@ describe MusicSession do @recording.errors.any?.should be_false @recording.stop @recording.reload - @claimed_recording = @recording.claim(@user1, "name", "description", Genre.first, true, true) + @claimed_recording = @recording.claim(@user1, "name", "description", Genre.first, true) @claimed_recording.errors.any?.should be_false end @@ -422,7 +422,7 @@ describe MusicSession do it "allow a claimed recording to be started when already started by self" do @user2 = FactoryGirl.create(:user) - @claimed_recording2 = @recording.claim(@user1, "name", "description", Genre.first, true, true) + @claimed_recording2 = @recording.claim(@user1, "name", "description", Genre.first, true) @music_session.claimed_recording_start(@user1, @claimed_recording) @music_session.errors.any?.should be_false @music_session.claimed_recording_start(@user1, @claimed_recording2) diff --git a/ruby/spec/jam_ruby/models/musician_search_spec.rb b/ruby/spec/jam_ruby/models/musician_search_spec.rb index a5caab73e..d8d0427ba 100644 --- a/ruby/spec/jam_ruby/models/musician_search_spec.rb +++ b/ruby/spec/jam_ruby/models/musician_search_spec.rb @@ -119,7 +119,7 @@ describe 'Musician search' do recording.stop recording.reload genre = FactoryGirl.create(:genre) - recording.claim(usr, "name", "description", genre, true, true) + recording.claim(usr, "name", "description", genre, true) recording.reload recording end diff --git a/ruby/spec/jam_ruby/models/recorded_track_spec.rb b/ruby/spec/jam_ruby/models/recorded_track_spec.rb index f374bd489..7fb0add63 100644 --- a/ruby/spec/jam_ruby/models/recorded_track_spec.rb +++ b/ruby/spec/jam_ruby/models/recorded_track_spec.rb @@ -60,7 +60,7 @@ describe RecordedTrack do it "can be downloaded if there is a claimed recording" do @recorded_track = RecordedTrack.create_from_track(@track, @recording) - @recording.claim(@user, "my recording", "my description", Genre.first, true, true).errors.any?.should be_false + @recording.claim(@user, "my recording", "my description", Genre.first, true).errors.any?.should be_false @recorded_track.can_download?(@user).should be_true end diff --git a/ruby/spec/jam_ruby/models/recording_spec.rb b/ruby/spec/jam_ruby/models/recording_spec.rb index 6cf118e1e..609701bac 100644 --- a/ruby/spec/jam_ruby/models/recording_spec.rb +++ b/ruby/spec/jam_ruby/models/recording_spec.rb @@ -114,7 +114,7 @@ describe Recording do @recording.stop @recording.reload @genre = FactoryGirl.create(:genre) - @recording.claim(@user, "name", "description", @genre, true, true) + @recording.claim(@user, "name", "description", @genre, true) @recording.reload @recording.users.length.should == 1 @recording.users.first.should == @user @@ -126,7 +126,6 @@ describe Recording do @claimed_recording.description.should == "description" @claimed_recording.genre.should == @genre @claimed_recording.is_public.should == true - @claimed_recording.is_downloadable.should == true end it "should fail if a user who was not in the session claims a recording" do @@ -134,7 +133,7 @@ describe Recording do @recording.stop @recording.reload user2 = FactoryGirl.create(:user) - expect { @recording.claim(user2, "name", "description", @genre, true, true) }.to raise_error + expect { @recording.claim(user2, "name", "description", @genre, true) }.to raise_error end it "should allow editing metadata for claimed recordings" do @@ -142,15 +141,14 @@ describe Recording do @recording.stop @recording.reload @genre = FactoryGirl.create(:genre) - @claimed_recording = @recording.claim(@user, "name", "description", @genre, true, true) + @claimed_recording = @recording.claim(@user, "name", "description", @genre, true) @genre2 = FactoryGirl.create(:genre) - @claimed_recording.update_fields(@user, :name => "name2", :description => "description2", :genre => @genre2.id, :is_public => false, :is_downloadable => false) + @claimed_recording.update_fields(@user, :name => "name2", :description => "description2", :genre => @genre2.id, :is_public => false) @claimed_recording.reload @claimed_recording.name.should == "name2" @claimed_recording.description.should == "description2" @claimed_recording.genre.should == @genre2 @claimed_recording.is_public.should == false - @claimed_recording.is_downloadable.should == false end it "should only allow the owner to edit a claimed recording" do @@ -158,7 +156,7 @@ describe Recording do @recording.stop @recording.reload @genre = FactoryGirl.create(:genre) - @claimed_recording = @recording.claim(@user, "name", "description", @genre, true, true) + @claimed_recording = @recording.claim(@user, "name", "description", @genre, true) @user2 = FactoryGirl.create(:user) expect { @claimed_recording.update_fields(@user2, "name2") }.to raise_error end @@ -184,9 +182,9 @@ describe Recording do @recording.stop @recording.reload @genre = FactoryGirl.create(:genre) - @claimed_recording = @recording.claim(@user, "name", "description", @genre, true, true) + @claimed_recording = @recording.claim(@user, "name", "description", @genre, true) expect { @claimed_recordign.discard(@user2) }.to raise_error - @claimed_recording = @recording.claim(@user2, "name2", "description2", @genre, true, true) + @claimed_recording = @recording.claim(@user2, "name2", "description2", @genre, true) @claimed_recording.discard(@user2) @recording.reload @recording.claimed_recordings.length.should == 1 @@ -197,7 +195,7 @@ describe Recording do @recording.stop @recording.reload @genre = FactoryGirl.create(:genre) - @claimed_recording = @recording.claim(@user, "name", "description", @genre, true, true) + @claimed_recording = @recording.claim(@user, "name", "description", @genre, true) @claimed_recording.discard(@user) expect { Recording.find(@recording.id) }.to raise_error expect { ClaimedRecording.find(@claimed_recording.id) }.to raise_error @@ -209,7 +207,7 @@ describe Recording do @recording.stop @recording.reload @genre = FactoryGirl.create(:genre) - @recording.claim(@user, "Recording", "Recording Description", @genre, true, true) + @recording.claim(@user, "Recording", "Recording Description", @genre, true) uploads = Recording.list_uploads(@user) uploads["uploads"].length.should == 1 Recording.list_uploads(@user, 10, uploads["next"])["uploads"].length.should == 0 @@ -220,7 +218,7 @@ describe Recording do @recording.stop @recording.reload @genre = FactoryGirl.create(:genre) - @recording.claim(@user, "Recording", "Recording Description", @genre, true, true) + @recording.claim(@user, "Recording", "Recording Description", @genre, true) downloads = Recording.list_downloads(@user) downloads["downloads"].length.should == 0 @recorded_track = RecordedTrack.where(:recording_id => @recording.id)[0] @@ -232,7 +230,7 @@ describe Recording do it "should mark first_recording_at" do @recording = Recording.start(@music_session, @user) @recording.stop - @recording.claim(@user, "Recording", "Recording Description", Genre.first, true, true) + @recording.claim(@user, "Recording", "Recording Description", Genre.first, true) @user.first_recording_at.should be_nil @user.reload @user.first_recording_at.should_not be_nil diff --git a/ruby/spec/jam_ruby/resque/audiomixer_spec.rb b/ruby/spec/jam_ruby/resque/audiomixer_spec.rb index 5411acc39..4e3c4b5e6 100644 --- a/ruby/spec/jam_ruby/resque/audiomixer_spec.rb +++ b/ruby/spec/jam_ruby/resque/audiomixer_spec.rb @@ -159,7 +159,7 @@ describe AudioMixer do @music_session.save @recording = Recording.start(@music_session, @user) @recording.stop - @recording.claim(@user, "name", "description", Genre.first, true, true) + @recording.claim(@user, "name", "description", Genre.first, true) @recording.errors.any?.should be_false end diff --git a/web/app/assets/javascripts/ftue.js b/web/app/assets/javascripts/ftue.js index a183aea31..2823888ef 100644 --- a/web/app/assets/javascripts/ftue.js +++ b/web/app/assets/javascripts/ftue.js @@ -136,12 +136,10 @@ function renderStartNewFtueLatencyTesting() { setSaveButtonState($('#btn-ftue-2-save'), false); - // spinner hangs - //$('#ftue-2-spinner').show().css('display', 'inline-block'); } function renderStopNewFtueLatencyTesting() { - $('#ftue-2-spinner').hide(); + } function settingsInit() { diff --git a/web/app/assets/javascripts/recordingFinishedDialog.js b/web/app/assets/javascripts/recordingFinishedDialog.js index cb3f02818..688b6deef 100644 --- a/web/app/assets/javascripts/recordingFinishedDialog.js +++ b/web/app/assets/javascripts/recordingFinishedDialog.js @@ -1,241 +1,245 @@ -(function(context,$) { +(function (context, $) { - "use strict"; - context.JK = context.JK || {}; - context.JK.RecordingFinishedDialog = function(app) { - var logger = context.JK.logger; - var rest = context.JK.Rest(); - var playbackControls = null; - var recording = null; // deferred object + "use strict"; + context.JK = context.JK || {}; + context.JK.RecordingFinishedDialog = function (app) { + var logger = context.JK.logger; + var rest = context.JK.Rest(); + var playbackControls = null; + var recording = null; // deferred object - function resetForm() { + function resetForm() { - // remove all display errors - $('#recording-finished-dialog form .error-text').remove() - $('#recording-finished-dialog form .error').removeClass("error") - } - - function beforeShow() { - if(recording == null) { - alert("recording data should not be null"); - app.layout.closeDialog('recordingFinished'); - return false; - } - - resetForm(); - - var parentSelector = '#recording-finished-dialog div.genre-selector'; - context.JK.GenreSelectorHelper.render(parentSelector); - - // preset genre from 1st genre in current session - var currentOrLastSession = JK.CurrentSessionModel.getCurrentOrLastSession(); - if(currentOrLastSession && currentOrLastSession.genres.length > 0) { - var genreDescription = currentOrLastSession.genres[0]; - context.JK.GenreSelectorHelper.setSelectedGenres(parentSelector, [genreDescription]); - } - - var localResults = context.jamClient.GetLocalRecordingState({recordings: [recording]}); - - - if(localResults['error']) { - app.notify({ - title : "Unable to Open Recording for Playback", - text : localResults['error'], - icon_url: "/assets/content/icon_alert_big.png" - }); - } - else { - var localResult = localResults.recordings[0]; - if(localResult.aggregate_state == 'MISSING') { - app.notify({ - title : "Unable to Open Recording for Playback", - text : "All tracks associated with the recording are missing", - icon_url: "/assets/content/icon_alert_big.png" - }); - } - else if(localResult.aggregate_state == 'PARTIALLY_MISSING') { - app.notify({ - title : "Unable to Open Recording for Playback", - text: "Some tracks associated with the recording are missing", - icon_url: "/assets/content/icon_alert_big.png" - }) - } - else { - - // load recording - var openRecordingResult = context.jamClient.OpenRecording(recording); - - logger.debug("OpenRecording response: %o", openRecordingResult); - - if(openRecordingResult.error) { - app.notify({ - "title": "Can't Open Recording", - "text": openRecordingResult.error, - "icon_url": "/assets/content/icon_alert_big.png" - }); - } - - playbackControls.startMonitor(); - } - } - - } - - function afterHide() { - recording = null; - playbackControls.stopMonitor(); - context.jamClient.CloseRecording(); - } - - function discardRecording(e) { - - resetForm(); - registerDiscardRecordingHandlers(false); - - rest.discardRecording({ - id: recording.id - }) - .done(function() { - console.error("recording discarded by user. recordingId=%o", recording.id); - }) - .fail(function(jqXHR){ - console.error("recording discard by user failed. recordingId=%o. reason: %o", recording.id, jqXHR.responseText); - }) - .always(function() { - app.layout.closeDialog('recordingFinished') - registerDiscardRecordingHandlers(true); - }) - return false; - } - function claimRecording(e){ - - resetForm(); - registerClaimRecordingHandlers(false); - - var name = $('#recording-finished-dialog form input[name=name]').val(); - var description = $('#recording-finished-dialog form textarea[name=description]').val(); - var genre = $('#recording-finished-dialog form select[name=genre]').val(); - var is_public = $('#recording-finished-dialog form input[name=is_public]').is(':checked') - var is_downloadable = $('#recording-finished-dialog form input[name=is_downloadable]').is(':checked'); - - rest.claimRecording({ - id : recording.id, - name: name, - description: description, - genre: genre, - is_public: is_public, - is_downloadable: is_downloadable - }) - .done(function() { - app.layout.closeDialog('recordingFinished'); - context.JK.GA.trackMakeRecording(); - }) - .fail(function(jqXHR) { - if(jqXHR.status == 422) { - var errors = JSON.parse(jqXHR.responseText); - - var $name_errors = context.JK.format_errors('name', errors); - if($name_errors) $('#recording-finished-dialog form input[name=name]').closest('div.field').addClass('error').end().after($name_errors); - - var $description_errors = context.JK.format_errors('description', errors); - if($description_errors) $('#recording-finished-dialog form input[name=description]').closest('div.field').addClass('error').end().after($description_errors); - - var $genre_errors = context.JK.format_errors('genre', errors); - if($genre_errors) $('#recording-finished-dialog form select[name=genre]').closest('div.field').addClass('error').end().after($genre_errors); - - var $is_public_errors = context.JK.format_errors('is_public', errors); - if($is_public_errors) $('#recording-finished-dialog form input[name=is_public]').closest('div.field').addClass('error').end().after($is_public_errors); - - var $is_downloadable_errors = context.JK.format_errors('is_downloadable', errors); - if($is_downloadable_errors) $('#recording-finished-dialog form input[name=is_downloadable]').closest('div.field').addClass('error').end().after($is_downloadable_errors); - - var recording_error = context.JK.get_first_error('recording_id', errors); - - if (recording_error) context.JK.showErrorDialog(app, "Unable to claim recording.", recording_error); - } - else { - logger.error("unable to claim recording %o", arguments); - - context.JK.showErrorDialog(app, "Unable to claim recording.", jqXHR.responseText); - } - }) - .always(function() { - registerClaimRecordingHandlers(true); - }); - return false; - } - - function registerClaimRecordingHandlers(onOff) { - if(onOff) { - $('#keep-session-recording').on('click', claimRecording); - $('#recording-finished-dialog form').on('submit', claimRecording); - } - else { - $('#keep-session-recording').off('click', claimRecording) - $('#recording-finished-dialog form').off('submit', claimRecording); - } - - } - - function registerDiscardRecordingHandlers(onOff) { - if(onOff) { - $('#discard-session-recording').on('click', discardRecording); - } - else { - $('#discard-session-recording').off('click', discardRecording); - } - } - - function onPause() { - logger.debug("calling jamClient.SessionStopPlay"); - context.jamClient.SessionStopPlay(); - } - - function onPlay(e, data) { - logger.debug("calling jamClient.SessionStartPlay"); - context.jamClient.SessionStartPlay(data.playbackMode); - } - - function onChangePlayPosition(e, data) { - logger.debug("calling jamClient.SessionTrackSeekMs(" + data.positionMs + ")"); - context.jamClient.SessionTrackSeekMs(data.positionMs); - } - - function registerStaticEvents() { - registerClaimRecordingHandlers(true); - registerDiscardRecordingHandlers(true); - $(playbackControls) - .on('pause', onPause) - .on('play', onPlay) - .on('change-position', onChangePlayPosition); - } - - function setRecording(recordingData) { - if(recording != null) { - //XXX - prevent start/stop recording mashing; protect this dialog - logger.error("unable to set recording data over existing recording data. this coudld be due to start/stop recording mashing"); - return; - } - recording = recordingData; - } - - function initialize(){ - var dialogBindings = { - 'beforeShow' : beforeShow, - 'afterHide': afterHide - }; - - app.bindDialog('recordingFinished', dialogBindings); - - playbackControls = new context.JK.PlaybackControls($('#recording-finished-dialog .recording-controls')); - - registerStaticEvents(); - }; - - - this.initialize = initialize; - this.setRecording = setRecording; + // remove all display errors + $('#recording-finished-dialog form .error-text').remove() + $('#recording-finished-dialog form .error').removeClass("error") } + function beforeShow() { + if (recording == null) { + alert("recording data should not be null"); + app.layout.closeDialog('recordingFinished'); + return false; + } + + resetForm(); + + var parentSelector = '#recording-finished-dialog div.genre-selector'; + context.JK.GenreSelectorHelper.render(parentSelector); + + // preset genre from 1st genre in current session + var currentOrLastSession = JK.CurrentSessionModel.getCurrentOrLastSession(); + if (currentOrLastSession && currentOrLastSession.genres.length > 0) { + var genreDescription = currentOrLastSession.genres[0]; + context.JK.GenreSelectorHelper.setSelectedGenres(parentSelector, [genreDescription]); + } + + var localResults = context.jamClient.GetLocalRecordingState({recordings: [recording]}); + + + if (localResults['error']) { + app.notify({ + title: "Unable to Open Recording for Playback", + text: localResults['error'], + icon_url: "/assets/content/icon_alert_big.png" + }); + } + else { + var localResult = localResults.recordings[0]; + if (localResult.aggregate_state == 'MISSING') { + app.notify({ + title: "Unable to Open Recording for Playback", + text: "All tracks associated with the recording are missing", + icon_url: "/assets/content/icon_alert_big.png" + }); + } + else if (localResult.aggregate_state == 'PARTIALLY_MISSING') { + app.notify({ + title: "Unable to Open Recording for Playback", + text: "Some tracks associated with the recording are missing", + icon_url: "/assets/content/icon_alert_big.png" + }) + } + else { + + // load recording + var openRecordingResult = context.jamClient.OpenRecording(recording); + + logger.debug("OpenRecording response: %o", openRecordingResult); + + if (openRecordingResult.error) { + app.notify({ + "title": "Can't Open Recording", + "text": openRecordingResult.error, + "icon_url": "/assets/content/icon_alert_big.png" + }); + } + + playbackControls.startMonitor(); + } + } + + } + + function afterHide() { + recording = null; + playbackControls.stopMonitor(); + context.jamClient.CloseRecording(); + } + + function discardRecording(e) { + + resetForm(); + registerDiscardRecordingHandlers(false); + + rest.discardRecording({ + id: recording.id + }) + .done(function () { + console.error("recording discarded by user. recordingId=%o", recording.id); + }) + .fail(function (jqXHR) { + console.error("recording discard by user failed. recordingId=%o. reason: %o", recording.id, jqXHR.responseText); + }) + .always(function () { + app.layout.closeDialog('recordingFinished') + registerDiscardRecordingHandlers(true); + }) + return false; + } + + function claimRecording(e) { + + resetForm(); + registerClaimRecordingHandlers(false); + + var name = $('#recording-finished-dialog form input[name=name]').val(); + var description = $('#recording-finished-dialog form textarea[name=description]').val(); + var genre = $('#recording-finished-dialog form select[name=genre]').val(); + var is_public = $('#recording-finished-dialog form input[name=is_public]').is(':checked') + + rest.claimRecording({ + id: recording.id, + name: name, + description: description, + genre: genre, + is_public: is_public + }) + .done(function () { + app.layout.closeDialog('recordingFinished'); + context.JK.GA.trackMakeRecording(); + }) + .fail(function (jqXHR) { + if (jqXHR.status == 422) { + var errors = JSON.parse(jqXHR.responseText); + + var $name_errors = context.JK.format_errors('name', errors); + if ($name_errors) $('#recording-finished-dialog form input[name=name]').closest('div.field').addClass('error').end().after($name_errors); + + var $description_errors = context.JK.format_errors('description', errors); + if ($description_errors) $('#recording-finished-dialog form input[name=description]').closest('div.field').addClass('error').end().after($description_errors); + + var $genre_errors = context.JK.format_errors('genre', errors); + if ($genre_errors) $('#recording-finished-dialog form select[name=genre]').closest('div.field').addClass('error').end().after($genre_errors); + + var $is_public_errors = context.JK.format_errors('is_public', errors); + if ($is_public_errors) $('#recording-finished-dialog form input[name=is_public]').closest('div.field').addClass('error').end().after($is_public_errors); + + var recording_error = context.JK.get_first_error('recording_id', errors); + + if (recording_error) context.JK.showErrorDialog(app, "Unable to claim recording.", recording_error); + } + else { + logger.error("unable to claim recording %o", arguments); + + context.JK.showErrorDialog(app, "Unable to claim recording.", jqXHR.responseText); + } + }) + .always(function () { + registerClaimRecordingHandlers(true); + }); + return false; + } + + function registerClaimRecordingHandlers(onOff) { + if (onOff) { + $('#keep-session-recording').on('click', claimRecording); + $('#recording-finished-dialog form').on('submit', claimRecording); + } + else { + $('#keep-session-recording').off('click', claimRecording) + $('#recording-finished-dialog form').off('submit', claimRecording); + } + + } + + function registerDiscardRecordingHandlers(onOff) { + if (onOff) { + $('#discard-session-recording').on('click', discardRecording); + } + else { + $('#discard-session-recording').off('click', discardRecording); + } + } + + function onPause() { + logger.debug("calling jamClient.SessionStopPlay"); + context.jamClient.SessionStopPlay(); + } + + function onPlay(e, data) { + logger.debug("calling jamClient.SessionStartPlay"); + context.jamClient.SessionStartPlay(data.playbackMode); + } + + function onChangePlayPosition(e, data) { + logger.debug("calling jamClient.SessionTrackSeekMs(" + data.positionMs + ")"); + context.jamClient.SessionTrackSeekMs(data.positionMs); + } + + function registerStaticEvents() { + registerClaimRecordingHandlers(true); + registerDiscardRecordingHandlers(true); + $(playbackControls) + .on('pause', onPause) + .on('play', onPlay) + .on('change-position', onChangePlayPosition); + } + + function setRecording(recordingData) { + if (recording != null) { + //XXX - prevent start/stop recording mashing; protect this dialog + logger.error("unable to set recording data over existing recording data. this coudld be due to start/stop recording mashing"); + return; + } + recording = recordingData; + } + + function initializeButtons() { + var isPublic = $('#recording-finished-dialog input[name="is_public"]'); + + context.JK.checkbox(isPublic); + } + + function initialize() { + var dialogBindings = { + 'beforeShow': beforeShow, + 'afterHide': afterHide + }; + + app.bindDialog('recordingFinished', dialogBindings); + + playbackControls = new context.JK.PlaybackControls($('#recording-finished-dialog .recording-controls')); + + registerStaticEvents(); + + initializeButtons(); + }; + + + this.initialize = initialize; + this.setRecording = setRecording; + } + return this; -})(window,jQuery); \ No newline at end of file +})(window, jQuery); \ No newline at end of file diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js index b3e27859e..4ca652715 100644 --- a/web/app/assets/javascripts/utils.js +++ b/web/app/assets/javascripts/utils.js @@ -549,6 +549,14 @@ }); } + context.JK.checkbox = function($checkbox) { + $checkbox.iCheck({ + checkboxClass: 'icheckbox_minimal', + radioClass: 'iradio_minimal', + inheritClass: true + }); + } + context.JK.dropdown = function($select) { $select.each(function(index) { diff --git a/web/app/assets/javascripts/whatsNextDialog.js b/web/app/assets/javascripts/whatsNextDialog.js index 33c502b63..e7c5fd5f2 100644 --- a/web/app/assets/javascripts/whatsNextDialog.js +++ b/web/app/assets/javascripts/whatsNextDialog.js @@ -1,55 +1,64 @@ -(function(context,$) { +(function (context, $) { - "use strict"; - context.JK = context.JK || {}; - context.JK.WhatsNextDialog = function(app) { - var logger = context.JK.logger; - var rest = context.JK.Rest(); - var invitationDialog = null; + "use strict"; + context.JK = context.JK || {}; + context.JK.WhatsNextDialog = function (app) { + var logger = context.JK.logger; + var rest = context.JK.Rest(); + var invitationDialog = null; - function registerEvents() { + function registerEvents() { - $('#whatsnext-dialog a.facebook-invite').on('click', function(e) { - alert("This feature not yet implemented"); - }); + $('#whatsnext-dialog a.facebook-invite').on('click', function (e) { + invitationDialog.showFacebookDialog(e); + }); - $('#whatsnext-dialog a.google-invite').on('click', function(e) { - invitationDialog.showGoogleDialog(); - }); + $('#whatsnext-dialog a.google-invite').on('click', function (e) { + invitationDialog.showGoogleDialog(); + }); - $('#whatsnext-dialog a.email-invite').on('click', function(e) { - invitationDialog.showEmailDialog(); - }); - } - function beforeShow() { - } - - function beforeHide() { - var $dontShowWhatsNext = $('#show_whats_next'); - - if($dontShowWhatsNext.is(':checked')) { - rest.updateUser( {show_whats_next:false}) - } - - } - - function initialize(invitationDialogInstance) { - var dialogBindings = { - 'beforeShow' : beforeShow, - 'beforeHide': beforeHide - }; - - app.bindDialog('whatsNext', dialogBindings); - - registerEvents(); - - invitationDialog = invitationDialogInstance; - }; - - - this.initialize = initialize; + $('#whatsnext-dialog a.email-invite').on('click', function (e) { + invitationDialog.showEmailDialog(); + }); } - return this; -})(window,jQuery); \ No newline at end of file + function beforeShow() { + } + + function beforeHide() { + var $dontShowWhatsNext = $('#show_whats_next'); + + if ($dontShowWhatsNext.is(':checked')) { + rest.updateUser({show_whats_next: false}) + } + + } + + function initializeButtons() { + var dontShow = $('#show_whats_next'); + + context.JK.checkbox(dontShow); + } + + function initialize(invitationDialogInstance) { + var dialogBindings = { + 'beforeShow': beforeShow, + 'beforeHide': beforeHide + }; + + app.bindDialog('whatsNext', dialogBindings); + + registerEvents(); + + invitationDialog = invitationDialogInstance; + + initializeButtons(); + }; + + + this.initialize = initialize; + } + + return this; +})(window, jQuery); \ No newline at end of file diff --git a/web/app/assets/stylesheets/client/client.css b/web/app/assets/stylesheets/client/client.css index f4ae803ea..d92534feb 100644 --- a/web/app/assets/stylesheets/client/client.css +++ b/web/app/assets/stylesheets/client/client.css @@ -33,6 +33,7 @@ *= require ./account *= require ./search *= require ./ftue + *= require ./whatsNextDialog *= require ./invitationDialog *= require ./shareDialog *= require ./hoverBubble diff --git a/web/app/assets/stylesheets/client/recordingFinishedDialog.css.scss b/web/app/assets/stylesheets/client/recordingFinishedDialog.css.scss index 986d140a8..a96bfd3d5 100644 --- a/web/app/assets/stylesheets/client/recordingFinishedDialog.css.scss +++ b/web/app/assets/stylesheets/client/recordingFinishedDialog.css.scss @@ -1,11 +1,11 @@ #recording-finished-dialog { width:1000px; height:auto; - div[purpose=description], div[purpose=is_public], div[purpose=is_downloadable] { + div[purpose=description], div[purpose=is_public] { margin-top:20px; } - label[for=is_downloadable], label[for=is_public], label[for=playback-mode-preview-all], label[for=playback-mode-preview-me] { + label[for=is_public], label[for=playback-mode-preview-all], label[for=playback-mode-preview-me] { display:inline; } @@ -16,5 +16,12 @@ .icheckbuttons { margin-top:20px; } + + div[purpose=is_public] .icheckbox_minimal { + display:inline-block; + position:relative; + top:3px; + margin-right:3px; + } } diff --git a/web/app/assets/stylesheets/client/whatsNextDialog.css.scss b/web/app/assets/stylesheets/client/whatsNextDialog.css.scss new file mode 100644 index 000000000..8ae323ed3 --- /dev/null +++ b/web/app/assets/stylesheets/client/whatsNextDialog.css.scss @@ -0,0 +1,8 @@ +#whatsnext-dialog { + .icheckbox_minimal { + display:inline-block; + position:relative; + top:3px; + margin-right:3px; + } +} \ No newline at end of file diff --git a/web/app/controllers/api_recordings_controller.rb b/web/app/controllers/api_recordings_controller.rb index 12099ab48..d3c0158d0 100644 --- a/web/app/controllers/api_recordings_controller.rb +++ b/web/app/controllers/api_recordings_controller.rb @@ -70,7 +70,7 @@ class ApiRecordingsController < ApiController # claim will create a claimed recording for the creator def claim - claim = @recording.claim(current_user, params[:name], params[:description], Genre.find_by_id(params[:genre]), params[:is_public], params[:is_downloadable]) + claim = @recording.claim(current_user, params[:name], params[:description], Genre.find_by_id(params[:genre]), params[:is_public]) if claim.errors.any? response.status = :unprocessable_entity diff --git a/web/app/views/api_claimed_recordings/show.rabl b/web/app/views/api_claimed_recordings/show.rabl index 69ff50f5d..683c1bed9 100644 --- a/web/app/views/api_claimed_recordings/show.rabl +++ b/web/app/views/api_claimed_recordings/show.rabl @@ -4,7 +4,7 @@ object @claimed_recording -attributes :id, :name, :description, :is_public, :is_downloadable, :genre_id +attributes :id, :name, :description, :is_public, :genre_id node :share_url do |claimed_recording| unless claimed_recording.share_token.nil? diff --git a/web/app/views/api_music_sessions/show.rabl b/web/app/views/api_music_sessions/show.rabl index 766b2723c..95cac8103 100644 --- a/web/app/views/api_music_sessions/show.rabl +++ b/web/app/views/api_music_sessions/show.rabl @@ -50,7 +50,7 @@ end node(:claimed_recording, :if => lambda { |music_session| music_session.users.exists?(current_user) } ) do |music_session| child(:claimed_recording => :claimed_recording) { - attributes :id, :name, :description, :is_public, :is_downloadable + attributes :id, :name, :description, :is_public child(:recording => :recording) { attributes :id, :created_at, :duration diff --git a/web/app/views/api_recordings/show.rabl b/web/app/views/api_recordings/show.rabl index 23dd3ef6c..633816ba0 100644 --- a/web/app/views/api_recordings/show.rabl +++ b/web/app/views/api_recordings/show.rabl @@ -28,7 +28,7 @@ child(:comments => :comments) { child(:claimed_recordings => :claimed_recordings) { - attributes :id, :name, :description, :is_public, :is_downloadable, :genre_id + attributes :id, :name, :description, :is_public, :genre_id node :share_url do |claimed_recording| unless claimed_recording.share_token.nil? diff --git a/web/app/views/clients/_ftue.html.erb b/web/app/views/clients/_ftue.html.erb index 997d81534..0182705c3 100644 --- a/web/app/views/clients/_ftue.html.erb +++ b/web/app/views/clients/_ftue.html.erb @@ -119,7 +119,6 @@