diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 9b2235032..2ffa8bb9f 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -43,6 +43,16 @@ }); } + function getSessionHistory(id) { + return $.ajax({ + type: "GET", + dataType: "json", + url: '/api/sessions/' + id + '/history', + contentType: 'application/json', + processData: false + }); + } + function addSessionComment(sessionId, userId, comment) { return $.ajax({ url: '/api/sessions/' + sessionId + "/comments", @@ -652,7 +662,6 @@ } function getClaimedRecordings(options) { - return $.ajax({ type: "GET", dataType: "json", @@ -662,6 +671,15 @@ }); } + function getClaimedRecording(id) { + return $.ajax({ + type: "GET", + dataType: "json", + contentType: 'application/json', + url: "/api/claimed_recordings/" + id + }); + } + function claimRecording(options) { var recordingId = options["id"]; @@ -757,6 +775,7 @@ this.getBandFollowing = getBandFollowing; this.getBands = getBands; this.updateSession = updateSession; + this.getSessionHistory = getSessionHistory; this.addSessionComment = addSessionComment; this.addSessionLike = addSessionLike; this.addRecordingComment = addRecordingComment; @@ -779,6 +798,7 @@ this.stopRecording = stopRecording; this.getRecording = getRecording; this.getClaimedRecordings = getClaimedRecordings; + this.getClaimedRecording = getClaimedRecording; this.claimRecording = claimRecording; this.startPlayClaimedRecording = startPlayClaimedRecording; this.stopPlayClaimedRecording = stopPlayClaimedRecording; diff --git a/web/app/assets/javascripts/shareDialog.js b/web/app/assets/javascripts/shareDialog.js index dff0ce41b..1b4e4f62e 100644 --- a/web/app/assets/javascripts/shareDialog.js +++ b/web/app/assets/javascripts/shareDialog.js @@ -2,18 +2,82 @@ "use strict"; context.JK = context.JK || {}; - context.JK.ShareDialog = function(app) { + context.JK.ShareDialog = function(app, entityId, entityType) { var logger = context.JK.logger; var rest = context.JK.Rest(); function registerEvents(onOff) { + if (onOff) { + } + else { + + } } function showDialog() { app.layout.showDialog('share-dialog'); } + function initDialog() { + + var fill = entityType === "session" ? "teal-fill" : "orange-fill"; + + $("#shareType").html(entityType); + + $("#divWidgetCodeHeader").addClass(fill); + $("#divWidgetPreviewHeader").addClass(fill); + $("#divWidgetPreview").addClass(entityType); + + // SESSION + if (entityType === "session") { + $("#lblWidgetCodeType").html('LIVE SESSION'); + $("#lblWidgetPreviewType").html('LIVE SESSION'); + + rest.getSessionHistory(entityId) + .done(function(response) { + var name, photoUrl; + + + }); + } + + // RECORDING + else { + $("#lblWidgetCodeType").html('RECORDING'); + $("#lblWidgetPreviewType").html('RECORDING'); + + rest.getClaimedRecording(entityId) + .done(function(response) { + var name, photoUrl; + + if (response.recording.band) { + name = response.recording.band.name; + photoUrl = context.JK.resolveBandAvatarUrl(response.recording.band.photo_url); + } + else { + name = response.recording.owner.name; + photoUrl = context.JK.resolveAvatarUrl(response.recording.owner.photo_url); + } + + console.log("band photo url=" + photoUrl); + $("#imgWidgetCodeAvatar").attr('src', photoUrl); + $("#imgWidgetPreviewAvatar").attr('src', photoUrl); + + $("#divWidgetPreviewTitle").html(response.recording.name); + + $("#spnWidgetCodeArtistName").html(name); + $("#spnWidgetPreviewArtistName").html(name); + + $.each(response.recording.recorded_tracks, function(index, val) { + $(".widget-members").append('
'); + $(".widget-members").append(''); + $(".widget-members").append('
'); + }); + }); + } + } + /*function showEmailDialog() { $('#invitation-dialog').show(); $('#invitation-textarea-container').show(); @@ -96,6 +160,8 @@ }; app.bindDialog('shareSessionRecording', dialogBindings); + + initDialog(); }; this.initialize = initialize; diff --git a/web/app/assets/stylesheets/client/client.css b/web/app/assets/stylesheets/client/client.css index 57f1af430..c31973f89 100644 --- a/web/app/assets/stylesheets/client/client.css +++ b/web/app/assets/stylesheets/client/client.css @@ -33,6 +33,7 @@ *= require ./ftue *= require ./invitationDialog *= require ./shareDialog + *= require ./hoverBubble *= require ./recordingFinishedDialog *= require ./localRecordingsDialog *= require ./createSession diff --git a/web/app/assets/stylesheets/client/hover.css.scss b/web/app/assets/stylesheets/client/hoverBubble.css.scss similarity index 100% rename from web/app/assets/stylesheets/client/hover.css.scss rename to web/app/assets/stylesheets/client/hoverBubble.css.scss diff --git a/web/app/assets/stylesheets/web/web.css b/web/app/assets/stylesheets/web/web.css index 98e7bd256..712b85f30 100644 --- a/web/app/assets/stylesheets/web/web.css +++ b/web/app/assets/stylesheets/web/web.css @@ -8,6 +8,7 @@ *= require client/dialog *= require client/invitationDialog *= require client/shareDialog +*= require client/hoverBubble *= require web/main *= require web/footer *= require web/recordings diff --git a/web/app/views/api_claimed_recordings/show.rabl b/web/app/views/api_claimed_recordings/show.rabl index 36c020610..f23967a14 100644 --- a/web/app/views/api_claimed_recordings/show.rabl +++ b/web/app/views/api_claimed_recordings/show.rabl @@ -8,9 +8,14 @@ attributes :id, :name, :description, :is_public, :is_downloadable, :genre_id child(:recording => :recording) { attributes :id, :created_at, :duration, :comment_count, :like_count, :play_count + child(:band => :band) { - attributes :id, :name - } + attributes :id, :name, :photo_url + } + + child(:owner => :owner) { + attributes :id, :name, :photo_url + } child(:mixes => :mixes) { attributes :id, :url, :is_completed @@ -20,14 +25,10 @@ child(:recording => :recording) { attributes :id, :fully_uploaded, :url, :client_track_id, :client_id, :instrument_id child(:user => :user) { - attributes :id, :first_name, :last_name, :city, :state, :country, :photo_url + attributes :id, :first_name, :last_name, :name, :city, :state, :country, :photo_url } } - child(:band => :band) { - attributes :id, :name, :photo_url - } - child(:comments => :comments) { attributes :comment, :created_at diff --git a/web/app/views/api_music_sessions/history_show.rabl b/web/app/views/api_music_sessions/history_show.rabl index 1a5f8ece7..d81ac8813 100644 --- a/web/app/views/api_music_sessions/history_show.rabl +++ b/web/app/views/api_music_sessions/history_show.rabl @@ -3,17 +3,17 @@ object @history attributes :music_session_id, :description, :genres child(:user => :creator) { - attributes :name, :photo_url + attributes :name, :photo_url } child(:band => :band) { - attributes :name, :photo_url + attributes :name, :photo_url } child(:music_session_user_histories => :users) { - attributes :instruments + attributes :instruments - child(:user => :user) { - attributes :name, :photo_url - } + child(:user => :user) { + attributes :name, :photo_url + } } \ No newline at end of file diff --git a/web/app/views/clients/_hoverBand.html.erb b/web/app/views/clients/_hoverBand.html.erb new file mode 100644 index 000000000..9a42e403a --- /dev/null +++ b/web/app/views/clients/_hoverBand.html.erb @@ -0,0 +1,52 @@ + + + + + + \ No newline at end of file diff --git a/web/app/views/clients/_hoverBubble.html.erb b/web/app/views/clients/_hoverBubble.html.erb index 6fb92a38e..4ef9c6edc 100644 --- a/web/app/views/clients/_hoverBubble.html.erb +++ b/web/app/views/clients/_hoverBubble.html.erb @@ -1,3 +1,232 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/app/views/clients/_hoverMusician.html.erb b/web/app/views/clients/_hoverMusician.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/web/app/views/clients/_hoverRecording.html.erb b/web/app/views/clients/_hoverRecording.html.erb new file mode 100644 index 000000000..12627f1b1 --- /dev/null +++ b/web/app/views/clients/_hoverRecording.html.erb @@ -0,0 +1,55 @@ + + + + + \ No newline at end of file diff --git a/web/app/views/clients/_hoverSession.html.erb b/web/app/views/clients/_hoverSession.html.erb new file mode 100644 index 000000000..b5e190b04 --- /dev/null +++ b/web/app/views/clients/_hoverSession.html.erb @@ -0,0 +1,49 @@ + + + + + + \ No newline at end of file diff --git a/web/app/views/clients/_shareDialog.html.erb b/web/app/views/clients/_shareDialog.html.erb index 394fe86ae..a92466340 100644 --- a/web/app/views/clients/_shareDialog.html.erb +++ b/web/app/views/clients/_shareDialog.html.erb @@ -1,6 +1,6 @@
-

share this session

+

share this

@@ -20,7 +20,9 @@ @@ -32,14 +34,14 @@

Share a Link:


- <%= true ? '' : "#{root_url}#{share_token}" %> + <% unless share_token.blank? %> + <%= "#{root_url}#{share_token}" %> + <% end %>

Get a Widget: