From e01491aa862e09328aa4bc061b411a80a3622348 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Mon, 3 Mar 2014 23:11:54 -0600 Subject: [PATCH 1/5] * VRFS-1330 - load recordings again --- web/app/assets/javascripts/jquery.listenbroadcast.js | 5 +++++ web/app/assets/javascripts/session.js | 4 +++- web/app/assets/javascripts/sessionModel.js | 10 +++++----- web/app/views/users/_feed_music_session.html.haml | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/web/app/assets/javascripts/jquery.listenbroadcast.js b/web/app/assets/javascripts/jquery.listenbroadcast.js index 64fe302a6..125e7ea5c 100644 --- a/web/app/assets/javascripts/jquery.listenbroadcast.js +++ b/web/app/assets/javascripts/jquery.listenbroadcast.js @@ -38,6 +38,7 @@ var audioDomElement = null; var musicSessionId = null; var waitForBufferingTimeout = null; + var fanAccess = null; var retryAttempts = 0; var self = this; @@ -381,6 +382,10 @@ musicSessionId = $parent.attr('data-music-session'); if(!musicSessionId) throw "data-music-session must be specified on $parentElement"; + fanAccess = $parent.attr('fan-access'); + if(fanAccess === null) throw 'fan-access must be specified in $parentElement'; + fanAccess = $parent.attr('fan-access') === 'true' // coerce to boolean + $audio = $('audio', $parent); if($audio.length == 0) { diff --git a/web/app/assets/javascripts/session.js b/web/app/assets/javascripts/session.js index 89c11cdd0..262061289 100644 --- a/web/app/assets/javascripts/session.js +++ b/web/app/assets/javascripts/session.js @@ -186,7 +186,9 @@ }); }) }, 100); - + } + else if(sessionModel.id() && text == 'RebuildMediaControl') { + sessionModel.refreshCurrentSession(true); } } else if (type === 19) { // NO_VALID_AUDIO_CONFIG diff --git a/web/app/assets/javascripts/sessionModel.js b/web/app/assets/javascripts/sessionModel.js index 45f16d8a0..59b06530c 100644 --- a/web/app/assets/javascripts/sessionModel.js +++ b/web/app/assets/javascripts/sessionModel.js @@ -163,10 +163,10 @@ /** * Refresh the current session, and participants. */ - function refreshCurrentSession() { + function refreshCurrentSession(force) { // XXX use backend instead: https://jamkazam.atlassian.net/browse/VRFS-854 //logger.debug("SessionModel.refreshCurrentSession(" + currentSessionId +")"); - refreshCurrentSessionRest(sessionChanged); + refreshCurrentSessionRest(sessionChanged, force); } /** @@ -200,7 +200,7 @@ * Reload the session data from the REST server, calling * the provided callback when complete. */ - function refreshCurrentSessionRest(callback) { + function refreshCurrentSessionRest(callback, force) { var url = "/api/sessions/" + currentSessionId; if(requestingSessionRefresh) { // if someone asks for a refresh while one is going on, we ask for another to queue up @@ -213,7 +213,7 @@ type: "GET", url: url, success: function(response) { - if(currentTrackChanges < response.track_changes_counter) { + if(force === true || currentTrackChanges < response.track_changes_counter) { logger.debug("updating current track changes from %o to %o", currentTrackChanges, response.track_changes_counter) currentTrackChanges = response.track_changes_counter; sendClientParticipantChanges(currentSession, response); @@ -232,7 +232,7 @@ if(pendingSessionRefresh) { // and when the request is done, if we have a pending, fire it off again pendingSessionRefresh = false; - refreshCurrentSessionRest(sessionChanged); + refreshCurrentSessionRest(sessionChanged, force); } } }); diff --git a/web/app/views/users/_feed_music_session.html.haml b/web/app/views/users/_feed_music_session.html.haml index d65f880d2..119edeaa2 100644 --- a/web/app/views/users/_feed_music_session.html.haml +++ b/web/app/views/users/_feed_music_session.html.haml @@ -15,7 +15,7 @@ / timeline and controls .right.w40 / recording play controls - .session-controls{ class: (feed_item.is_over? ? 'ended' : 'inprogress'), 'data-music-session' => feed_item.id } + .session-controls{ class: (feed_item.is_over? ? 'ended' : 'inprogress'), 'data-music-session' => feed_item.id, 'fan-access' => feed_item.fan_access} / session status %a.left.play-button{href:'#'} = image_tag 'content/icon_playbutton.png', width:20, height:20, class:'play-icon' @@ -23,7 +23,7 @@ %audio{preload: 'none'} %source{src: feed_item.music_session.mount.url, type: feed_item.music_session.mount.resolve_string(:mime_type)} .session-status - = feed_item.is_over? ? 'SESSION ENDED' : 'SESSION IN PROGRESS' + = feed_item.is_over? ? 'SESSION ENDED' : (feed_item.fan_access ? 'SESSION IN PROGRESS' : 'PRIVATE SESSION') / current playback time = session_duration(feed_item, class: 'session-duration tick-duration recording-current', 'data-created-at' => feed_item.created_at.to_i) / end recording play controls From 9b8caedbb2abdbb4f5e3a8e4640db17e1f4d9166 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Mon, 3 Mar 2014 23:34:00 -0600 Subject: [PATCH 2/5] * VRFS-1309 - Edit link erroneously shown on non-you profiles --- web/app/assets/javascripts/profile.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/app/assets/javascripts/profile.js b/web/app/assets/javascripts/profile.js index e577b7826..4d21a70ab 100644 --- a/web/app/assets/javascripts/profile.js +++ b/web/app/assets/javascripts/profile.js @@ -377,10 +377,14 @@ $bioTextArea.val(user.biography); if(user.biography) { + $showBio.show(); if(isCurrentUser()) { $editBiographyButton.show(); } + else { + $editBiographyButton.hide(); + } $biographyText.text(user.biography).show(); } else { From 17088d49b5c41c214429f7d4ec8cbe2eb62198dd Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Tue, 4 Mar 2014 05:38:58 +0000 Subject: [PATCH 3/5] VRFS-1326 fixed integration of latest/buzz --- admin/app/admin/promo_latest.rb | 2 -- ruby/lib/jam_ruby/models/promotional.rb | 36 +++++++------------------ web/app/controllers/users_controller.rb | 4 +-- web/config/application.rb | 2 +- 4 files changed, 12 insertions(+), 32 deletions(-) diff --git a/admin/app/admin/promo_latest.rb b/admin/app/admin/promo_latest.rb index 3aae396c0..676aa8638 100644 --- a/admin/app/admin/promo_latest.rb +++ b/admin/app/admin/promo_latest.rb @@ -31,7 +31,6 @@ ActiveAdmin.register JamRuby::PromoLatest, :as => 'Latest' do def new @promo = JamRuby::PromoLatest.new @promo.aasm_state = 'active' - @latests = PromoLatest.latest_candidates super end @@ -42,7 +41,6 @@ ActiveAdmin.register JamRuby::PromoLatest, :as => 'Latest' do def edit @promo = resource - @latests = PromoLatest.latest_candidates super end diff --git a/ruby/lib/jam_ruby/models/promotional.rb b/ruby/lib/jam_ruby/models/promotional.rb index 660a768e6..407a30c1e 100644 --- a/ruby/lib/jam_ruby/models/promotional.rb +++ b/ruby/lib/jam_ruby/models/promotional.rb @@ -34,9 +34,11 @@ class JamRuby::Promotional < ActiveRecord::Base aasm_state end - def self.active(max_count=100) + def self.active(max_count=10) rel = self.where(:aasm_state => ACTIVE_STATE) - rel = rel.limit(mc) if 0 < (mc = max_count.to_i) + if 0 < (mc = max_count.to_i) + rel = rel.limit(mc) + end rel end @@ -82,31 +84,11 @@ class JamRuby::PromoLatest < JamRuby::Promotional attr_accessible :latest def music_session_history - @music_session_history ||= MusicSessionHistory.find_by_id(latest_id) + self.latest if self.latest.is_a? MusicSessionHistory end def recording - @recording ||= Recording.find_by_id(latest_id) - end - - def self.latest_candidates - recordings = Recording - .where('music_session_id IS NOT NULL') - .order('created_at DESC') - .limit(10) - sessions = MusicSession - .where("music_sessions.id NOT IN ('#{recordings.map(&:music_session_id).join("','")}')") - .order('created_at DESC') - .limit(10) - latests = (recordings + sessions).sort { |o1,o2| o2.created_at <=> o1.created_at } - latests.collect do |ll| - nm = if ll.is_a?(Recording) - "#{ll.class.name.demodulize}: #{ll.band.present? ? ll.band.name : ll.owner.name}" - else - "#{ll.class.name.demodulize}: #{ll.band.present? ? ll.band.name : ll.creator.name}" - end - { :name => nm, :id => ll.id, :record => ll } - end + self.latest if self.latest.is_a? Recording end def self.create_with_params(params) @@ -118,8 +100,8 @@ class JamRuby::PromoLatest < JamRuby::Promotional def update_with_params(params) if (latest_id = params[:latest_id]).present? - self.latest = Recording.where(:id => latest_id).limit(1).all[0] || - MusicSession.where(:id => latest_id).limit(1).all[0] + self.latest = Recording.where(:id => latest_id).limit(1).first || + MusicSessionHistory.where(:id => latest_id).limit(1).first end self.position = params[:position] self.aasm_state = params[:aasm_state] @@ -131,7 +113,7 @@ class JamRuby::PromoLatest < JamRuby::Promotional nm = if ll.is_a?(Recording) ll.band.present? ? ll.band.name : ll.owner.name else - ll.band.present? ? ll.band.name : ll.creator.name + ll.band.present? ? ll.band.name : ll.user.name end "#{ll.class.name.demodulize}: #{nm} (#{ll.created_at})" end diff --git a/web/app/controllers/users_controller.rb b/web/app/controllers/users_controller.rb index fa26ef533..0c3afbac2 100644 --- a/web/app/controllers/users_controller.rb +++ b/web/app/controllers/users_controller.rb @@ -206,10 +206,10 @@ class UsersController < ApplicationController Slide.new("bands", "web/carousel_bands.jpg", "http://www.youtube.com/embed/eaYNM7p6Z5s") ] - @promo_buzz = Promotional.where(:type => 'JamRuby::PromoBuzz', :aasm_state => :active).where('latest_id IS NOT NULL').order(:position) + @promo_buzz = PromoBuzz.active if Rails.application.config.use_promos_on_homepage - @promo_latest = Promotional.where(:type => 'JamRuby::PromoLatest', :aasm_state => :active).where('latest_id IS NOT NULL').order(:position).limit(10) + @promo_latest = PromoLatest.active else @promo_latest, start = Feed.index(nil, limit: 10) end diff --git a/web/config/application.rb b/web/config/application.rb index e8340ef5b..5d46abe26 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -213,6 +213,6 @@ if defined?(Bundler) config.send_join_session_email_notifications = true - config.use_promos_on_homepage = false + config.use_promos_on_homepage = true end end From 490b8ad06cc3e63cc5cef94b76eee5535c2c6213 Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Tue, 4 Mar 2014 05:47:32 +0000 Subject: [PATCH 4/5] VRFS-1326 added Latest ID column --- admin/app/admin/promo_latest.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/admin/app/admin/promo_latest.rb b/admin/app/admin/promo_latest.rb index 676aa8638..ec0c593ba 100644 --- a/admin/app/admin/promo_latest.rb +++ b/admin/app/admin/promo_latest.rb @@ -11,6 +11,7 @@ ActiveAdmin.register JamRuby::PromoLatest, :as => 'Latest' do index do column 'Latest' do |pp| pp.latest_display_name end + column 'Latest ID' do |pp| pp.latest_id end column 'State' do |pp| pp.aasm_state end column 'Position' do |pp| pp.position end column 'Updated' do |pp| pp.updated_at end From 5285078cf647dfe63525e296805ce1b916bdce6a Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 4 Mar 2014 00:00:01 -0600 Subject: [PATCH 5/5] * VRFS-1285 - hide play button if it can't be played, and show BROADCASTING OFFLINE or PRIVATE SESSION appropriaely --- .../lib/jam_ruby/models/music_session_history.rb | 4 ++++ .../assets/stylesheets/web/audioWidgets.css.scss | 13 +++++++++++++ web/app/helpers/feeds_helper.rb | 16 ++++++++++++++++ .../views/users/_feed_music_session.html.haml | 6 +++--- web/config/application.rb | 2 +- web/spec/features/welcome_spec.rb | 4 ++-- 6 files changed, 39 insertions(+), 6 deletions(-) diff --git a/ruby/lib/jam_ruby/models/music_session_history.rb b/ruby/lib/jam_ruby/models/music_session_history.rb index ecc7ce8dc..1bdc4676e 100644 --- a/ruby/lib/jam_ruby/models/music_session_history.rb +++ b/ruby/lib/jam_ruby/models/music_session_history.rb @@ -153,6 +153,10 @@ module JamRuby music_session.nil? || !session_removed_at.nil? end + def has_mount? + music_session && music_session.mount + end + def end_history self.update_attribute(:session_removed_at, Time.now) diff --git a/web/app/assets/stylesheets/web/audioWidgets.css.scss b/web/app/assets/stylesheets/web/audioWidgets.css.scss index 7efb81c0c..70ca73f4a 100644 --- a/web/app/assets/stylesheets/web/audioWidgets.css.scss +++ b/web/app/assets/stylesheets/web/audioWidgets.css.scss @@ -36,6 +36,19 @@ .play-button { outline: 0; } + + &.no-mount[fan-access="true"]{ + .play-button { + display:none; + } + } + + &[fan-access="false"]{ + .play-button { + display:none; + } + } + .session-status { font-size:18px; display:inline; diff --git a/web/app/helpers/feeds_helper.rb b/web/app/helpers/feeds_helper.rb index d62f816eb..4aa802046 100644 --- a/web/app/helpers/feeds_helper.rb +++ b/web/app/helpers/feeds_helper.rb @@ -15,6 +15,22 @@ module FeedsHelper end end + def session_text(music_session_history) + if music_session_history.is_over? + 'SESSION ENDED' + else + if music_session_history.fan_access + if music_session_history.music_session && music_session_history.music_session.mount + 'SESSION IN PROGRESS' + else + 'BROADCASTING OFFLINE' # if you see this in development, you need to set up icecast. If you see this in production, it's not healthy + end + else + 'PRIVATE SESSION' + end + end + end + def session_description(music_session_history) music_session_history.description end diff --git a/web/app/views/users/_feed_music_session.html.haml b/web/app/views/users/_feed_music_session.html.haml index 119edeaa2..98c911ed2 100644 --- a/web/app/views/users/_feed_music_session.html.haml +++ b/web/app/views/users/_feed_music_session.html.haml @@ -15,15 +15,15 @@ / timeline and controls .right.w40 / recording play controls - .session-controls{ class: (feed_item.is_over? ? 'ended' : 'inprogress'), 'data-music-session' => feed_item.id, 'fan-access' => feed_item.fan_access} + .session-controls{ class: "#{(feed_item.is_over? ? 'ended' : 'inprogress')} #{feed_item.has_mount? ? 'has-mount' : 'no-mount'}", 'data-music-session' => feed_item.id, 'fan-access' => feed_item.fan_access.to_s} / session status %a.left.play-button{href:'#'} = image_tag 'content/icon_playbutton.png', width:20, height:20, class:'play-icon' - - if feed_item.music_session && feed_item.music_session.mount + - if feed_item.has_mount? %audio{preload: 'none'} %source{src: feed_item.music_session.mount.url, type: feed_item.music_session.mount.resolve_string(:mime_type)} .session-status - = feed_item.is_over? ? 'SESSION ENDED' : (feed_item.fan_access ? 'SESSION IN PROGRESS' : 'PRIVATE SESSION') + = session_text(feed_item) / current playback time = session_duration(feed_item, class: 'session-duration tick-duration recording-current', 'data-created-at' => feed_item.created_at.to_i) / end recording play controls diff --git a/web/config/application.rb b/web/config/application.rb index 5d46abe26..e8340ef5b 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -213,6 +213,6 @@ if defined?(Bundler) config.send_join_session_email_notifications = true - config.use_promos_on_homepage = true + config.use_promos_on_homepage = false end end diff --git a/web/spec/features/welcome_spec.rb b/web/spec/features/welcome_spec.rb index db9921a62..c5b67d552 100644 --- a/web/spec/features/welcome_spec.rb +++ b/web/spec/features/welcome_spec.rb @@ -161,8 +161,8 @@ describe "Welcome", :js => true, :type => :feature, :capybara_feature => true d visit "/" find('h1', text: 'Play music together over the Internet as if in the same room') find('.feed-entry.music-session-history-entry .description', text: musicSessionHistory1.description) - find('.feed-entry.music-session-history-entry .session-status', text: 'SESSION IN PROGRESS') - find('.feed-entry.music-session-history-entry .session-controls.inprogress', text: 'SESSION IN PROGRESS') + find('.feed-entry.music-session-history-entry .session-status', text: 'BROADCASTING OFFLINE') + find('.feed-entry.music-session-history-entry .session-controls.inprogress', text: 'BROADCASTING OFFLINE') find('.feed-entry.music-session-history-entry .artist', text: musicSessionHistory1.user.name) should_not have_selector('.feed-entry.music-session-history-entry .musician-detail')