diff --git a/web/app/assets/javascripts/react-components/ChatWindow.js.jsx.coffee b/web/app/assets/javascripts/react-components/ChatWindow.js.jsx.coffee index 1dbf0a639..210959bed 100644 --- a/web/app/assets/javascripts/react-components/ChatWindow.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/ChatWindow.js.jsx.coffee @@ -52,13 +52,23 @@ SessionStore = @SessionStore notationClicked: (music_notation, e) -> e.preventDefault() - context.JK.popExternalLink("/api/music_notations/#{music_notation.id}?target=_blank") + rest.getMusicNotation(music_notation.id).done((response) => + context.JK.popExternalLink(response.url) + ) + .fail((jqXHR) => + context.JK.Banner.showAlert('Unable to fetch URL for music notation. Error: ' + jqXHR.responseText) + ) audioClicked: (music_notation, e) -> e.preventDefault() - context.JK.popExternalLink("/api/music_notations/#{music_notation.id}?target=_blank") - + rest.getMusicNotation(music_notation.id).done((response) => + context.JK.popExternalLink(response.url) + ) + .fail((jqXHR) => + context.JK.Banner.showAlert('Unable to fetch URL for audio. Error: ' + jqXHR.responseText) + ) + recordingClicked: (recording, e) -> e.preventDefault() context.JK.popExternalLink("/recordings/#{recording.id}") diff --git a/web/app/controllers/api_music_notations_controller.rb b/web/app/controllers/api_music_notations_controller.rb index 7ebd12932..1de842c12 100644 --- a/web/app/controllers/api_music_notations_controller.rb +++ b/web/app/controllers/api_music_notations_controller.rb @@ -72,7 +72,7 @@ class ApiMusicNotationsController < ApiController if '_blank'==params[:target] redirect_to @music_notation.sign_url else - render :text => @music_notation.sign_url + render :json => {url: @music_notation.sign_url} end end