Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop

This commit is contained in:
Brian Smith 2014-03-04 01:03:39 -05:00
commit 171a2371a7
12 changed files with 67 additions and 42 deletions

View File

@ -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
@ -31,7 +32,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 +42,6 @@ ActiveAdmin.register JamRuby::PromoLatest, :as => 'Latest' do
def edit
@promo = resource
@latests = PromoLatest.latest_candidates
super
end

View File

@ -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)

View File

@ -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

View File

@ -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) {

View File

@ -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 {

View File

@ -186,7 +186,9 @@
});
})
}, 100);
}
else if(sessionModel.id() && text == 'RebuildMediaControl') {
sessionModel.refreshCurrentSession(true);
}
}
else if (type === 19) { // NO_VALID_AUDIO_CONFIG

View File

@ -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);
}
}
});

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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 }
.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' : 'SESSION IN PROGRESS'
= 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

View File

@ -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')