* merging

This commit is contained in:
Seth Call 2014-02-24 16:57:01 +00:00
commit e4718652fd
45 changed files with 719 additions and 209 deletions

View File

@ -252,7 +252,7 @@ message SessionInvitation {
}
message SessionEnded {
optional string session_id = 1;
}
message JoinRequest {

View File

@ -123,6 +123,8 @@ require "jam_ruby/models/facebook_signup"
require "jam_ruby/models/recording_play"
require "jam_ruby/models/feed"
require "jam_ruby/models/jam_isp"
require "jam_ruby/models/geo_ip_blocks"
require "jam_ruby/models/geo_ip_locations"
include Jampb

View File

@ -92,78 +92,155 @@
def friend_request(email, msg)
subject = "You have a new friend request on JamKazam"
unique_args = {:type => "friend_request"}
send_notification(email, subject, msg, unique_args)
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def friend_request_accepted(email, msg)
subject = "You have a new friend on JamKazam"
unique_args = {:type => "friend_request_accepted"}
send_notification(email, subject, msg, unique_args)
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def new_user_follower(email, msg)
subject = "You have a new follower on JamKazam"
unique_args = {:type => "new_user_follower"}
send_notification(email, subject, msg, unique_args)
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def new_band_follower(email, msg)
subject = "Your band has a new follower on JamKazam"
unique_args = {:type => "new_band_follower"}
send_notification(email, subject, msg, unique_args)
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def session_invitation(email, msg)
subject = "You have been invited to a session on JamKazam"
unique_args = {:type => "session_invitation"}
send_notification(email, subject, msg, unique_args)
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def musician_session_join(email, msg)
subject = "Someone you know is in a session on JamKazam"
unique_args = {:type => "musician_session_join"}
send_notification(email, subject, msg, unique_args)
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def band_session_join(email, msg)
subject = "A band that you follow has joined a session"
unique_args = {:type => "band_session_join"}
send_notification(email, subject, msg, unique_args)
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def musician_recording_saved(email, msg)
subject = msg
unique_args = {:type => "musician_recording_saved"}
send_notification(email, subject, msg, unique_args)
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def band_recording_saved(email, msg)
subject = msg
unique_args = {:type => "band_recording_saved"}
send_notification(email, subject, msg, unique_args)
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def band_invitation(email, msg)
subject = "You have been invited to join a band on JamKazam"
unique_args = {:type => "band_invitation"}
send_notification(email, subject, msg, unique_args)
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def band_invitation_accepted(email, msg)
subject = "Your band invitation was accepted"
unique_args = {:type => "band_invitation_accepted"}
send_notification(email, subject, msg, unique_args)
end
def send_notification(email, subject, msg, unique_args)
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:bcc => email, :subject => subject) do |format|
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
# def send_notification(email, subject, msg, unique_args)
# @body = msg
# sendgrid_category "Notification"
# sendgrid_unique_args :type => unique_args[:type]
# mail(:to => email, :subject => subject) do |format|
# format.text
# format.html
# end
# end
#############################################################################################
end

View File

@ -56,7 +56,29 @@ module JamRuby
end
if ip_address
# todo turn ip_address string into a number, then fetch the locid and ispid and the other stuff...
# todo turn ip_address string into a number, then fetch the isp and block records
addr = JamIsp.ip_to_num(ip_address)
#puts("============= JamIsp.ip_to_num returns #{addr} for #{ip_address} =============")
isp = JamIsp.lookup(addr)
#puts("============= JamIsp.lookup returns #{isp.inspect} for #{addr} =============")
if isp.nil? then ispid = 0 else ispid = isp.coid end
block = GeoIpBlocks.lookup(addr)
#puts("============= GeoIpBlocks.lookup returns #{block.inspect} for #{addr} =============")
if block.nil? then locid = 0 else locid = block.locid end
location = GeoIpLocations.lookup(locid)
locidispid = 0
latitude = 0.0
longitude = 0.0
countrycode = 'US'
region = 'TX'
city = 'Austin'
# todo stuff this stuff into the connection records
end
sql =<<SQL
@ -168,14 +190,20 @@ SQL
ConnectionManager.active_record_transaction do |connection_manager|
conn = connection_manager.pg_conn
# todo turn ip_address string into a number, then fetch the isp and block records
addr = JamIsp.ip_to_num(ip_address)
puts("============= JamIsp returns #{addr} for #{ip_address} =============")
#puts("============= JamIsp.ip_to_num returns #{addr} for #{ip_address} =============")
isp = JamIsp.lookup(addr)
#puts("============= JamIsp.lookup returns #{isp.inspect} for #{addr} =============")
if isp.nil? then ispid = 0 else ispid = isp.coid end
puts("============= JamIsp returns #{ispid} for #{addr} =============")
# todo turn ip_address string into a number, then fetch the locid and ispid and the other stuff...
block = GeoIpBlocks.lookup(addr)
#puts("============= GeoIpBlocks.lookup returns #{block.inspect} for #{addr} =============")
if block.nil? then locid = 0 else locid = block.locid end
location = GeoIpLocations.lookup(locid)
locidispid = 0
latitude = 0.0
@ -184,7 +212,6 @@ SQL
region = 'TX'
city = 'Austin'
lock_connections(conn)
conn.exec("INSERT INTO connections (user_id, client_id, addr, locidispid, latitude, longitude, countrycode, region, city, aasm_state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",

View File

@ -48,6 +48,7 @@ module ValidationMessages
INVITE_REQUIRED = "You must be invited to join this session"
FANS_CAN_NOT_JOIN = "Fans can not join this session"
CANT_JOIN_RECORDING_SESSION = "is currently recording"
CANT_JOIN_MULTIPLE_SESSIONS = 'You cannot join more than one music session'
# recordings
ALREADY_BEING_RECORDED = "already being recorded"

View File

@ -300,6 +300,18 @@ module JamRuby
)
end
def session_ended(receiver_id, session_id)
session_ended = Jampb::SessionEnded.new(
:session_id => session_id
)
Jampb::ClientMessage.new(
:type => ClientMessage::Type::SESSION_ENDED,
:route_to => USER_TARGET_PREFIX + receiver_id,
:session_ended => session_ended
)
end
# create a join request session message
def join_request(join_request_id, session_id, photo_url, msg, notification_id, created_at)
req = Jampb::JoinRequest.new(

View File

@ -101,6 +101,17 @@ module JamRuby
if music_session.is_recording?
errors.add(:music_session, ValidationMessages::CANT_JOIN_RECORDING_SESSION)
end
unless user.admin?
num_sessions = Connection.where(:user_id => user_id)
.where(["(music_session_id IS NOT NULL) AND (aasm_state != ?)",EXPIRED_STATE.to_s])
.count
if 0 < num_sessions
errors.add(:music_session, ValidationMessages::CANT_JOIN_MULTIPLE_SESSIONS)
return false;
end
end
return true
end

View File

@ -0,0 +1,20 @@
module JamRuby
class GeoIpBlocks < ActiveRecord::Base
self.table_name = 'geoipblocks'
def self.lookup(ipnum)
GeoIpBlocks.select(:locid)
.where('geom && ST_MakePoint(?, 0) AND ? BETWEEN beginip AND endip', ipnum, ipnum)
.limit(1)
.first
end
def self.make_row(beginip, endip, locid)
c = ActiveRecord::Base.connection.raw_connection
c.prepare('blah', 'insert into geoipblocks (beginip, endip, locid, geom) values($1::bigint, $2::bigint, $3, ST_MakeEnvelope($1::bigint, -1, $2::bigint, 1))')
c.exec_prepared('blah', [beginip, endip, locid])
c.exec("deallocate blah")
end
end
end

View File

@ -0,0 +1,20 @@
module JamRuby
class GeoIpLocations < ActiveRecord::Base
self.table_name = 'geoiplocations'
def self.lookup(locid)
GeoIpLocations.select('locid, countrycode, region, city, latitude, longitude')
.where(:locid => locid)
.limit(1)
.first
end
def self.make_row(locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode)
c = ActiveRecord::Base.connection.raw_connection
c.prepare('blah', 'insert into geoiplocations (locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode, geog) values($1, $2, $3, $4, $5, $6, $7, $8, $9, ST_SetSRID(ST_MakePoint($7, $6), 4326)::geography)')
c.exec_prepared('blah', [locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode])
c.exec("deallocate blah")
end
end
end

View File

@ -172,6 +172,8 @@ module JamRuby
.first
hist.end_history if hist
Notification.send_session_ended(session_id)
end
def remove_non_alpha_num(token)

View File

@ -47,10 +47,6 @@ module JamRuby
@@mq_router = MQRouter.new
@@message_factory = MessageFactory.new
def delete_all(session_id)
Notification.delete_all "(session_id = '#{session_id}')"
end
################### HELPERS ###################
def retrieve_friends(connection, user_id)
friend_ids = []
@ -232,7 +228,7 @@ module JamRuby
@@mq_router.publish_to_user(friend_id, msg)
else
UserMailer.friend_request(friend.email, notification_msg)
UserMailer.friend_request(friend.email, notification_msg).deliver
end
end
@ -260,7 +256,7 @@ module JamRuby
@@mq_router.publish_to_user(user.id, msg)
else
UserMailer.friend_request_accepted(user.email, notification_msg)
UserMailer.friend_request_accepted(user.email, notification_msg).deliver
end
end
@ -287,7 +283,7 @@ module JamRuby
@@mq_router.publish_to_user(user.id, msg)
else
UserMailer.new_user_follower(user.email, notification_msg)
UserMailer.new_user_follower(user.email, notification_msg).deliver
end
end
end
@ -321,7 +317,7 @@ module JamRuby
@@mq_router.publish_to_user(bm.user_id, msg)
else
UserMailer.new_band_follower(bm.user.email, notification_msg)
UserMailer.new_band_follower(bm.user.email, notification_msg).deliver
end
end
end
@ -350,14 +346,22 @@ module JamRuby
@@mq_router.publish_to_user(receiver.id, msg)
else
UserMailer.session_invitation(receiver.email, notification_msg)
UserMailer.session_invitation(receiver.email, notification_msg).deliver
end
end
def send_session_ended(music_session, connection)
def send_session_ended(session_id)
# TODO: this should actually publish to all users who have a notification for this session
@@mq_router.server_publish_to_session(music_session, nil, sender = {:client_id => connection.client_id})
notifications = Notification.where(:session_id => session_id)
# publish to all users who have a notification for this session
# TODO: do this in BULK or in async block
notifications.each do |n|
msg = @@message_factory.session_ended(n.target_user_id, session_id)
@@mq_router.publish_to_user(n.target_user_id, msg)
end
Notification.delete_all "(session_id = '#{session_id}')"
end
def send_join_request(music_session, join_request, text)
@ -467,8 +471,8 @@ module JamRuby
follower_users = user_followers.map { |uf| uf.user }
friends_and_followers = friend_users.concat(follower_users).uniq
# remove anyone in the session
friends_and_followers = friends_and_followers - music_session.users
# remove anyone in the session and invited musicians
friends_and_followers = friends_and_followers - music_session.users - music_session.invited_musicians
notifications, online_ff, offline_ff = [], [], []
notification_msg = format_msg(NotificationTypes::MUSICIAN_SESSION_JOIN, user)
@ -478,6 +482,7 @@ module JamRuby
notification.description = NotificationTypes::MUSICIAN_SESSION_JOIN
notification.source_user_id = user.id
notification.target_user_id = ff.id
notification.session_id = music_session.id
notification.save
if ff.online
@ -499,7 +504,7 @@ module JamRuby
# send email notifications
unless offline_ff.empty?
UserMailer.musician_session_join(offline_ff.map! {|f| f.email}, notification_msg)
UserMailer.musician_session_join(offline_ff.map! {|f| f.email}, notification_msg).deliver
end
end
end
@ -519,6 +524,7 @@ module JamRuby
notification.band_id = band.id
notification.description = NotificationTypes::BAND_SESSION_JOIN
notification.target_user_id = follower.id
notification.session_id = music_session.id
notification.save
if follower.online
@ -540,7 +546,7 @@ module JamRuby
# send email notifications
unless offline_followers.empty?
UserMailer.band_session_join(offline_followers.map! {|f| f.email}, notification_msg)
UserMailer.band_session_join(offline_followers.map! {|f| f.email}, notification_msg).deliver
end
end
end
@ -562,9 +568,10 @@ module JamRuby
friends_and_followers.each do |ff|
notification = Notification.new
notification.description = NotificationTypes::MUSICIAN_SESSION_JOIN
notification.description = NotificationTypes::MUSICIAN_RECORDING_SAVED
notification.source_user_id = user.id
notification.target_user_id = ff.id
notification.recording_id = recording.id
notification.save
if ff.online
@ -585,7 +592,7 @@ module JamRuby
# send email notifications
unless offline_ff.empty?
UserMailer.musician_recording_saved(offline_ff.map! {|f| f.email}, notification_msg)
UserMailer.musician_recording_saved(offline_ff.map! {|f| f.email}, notification_msg).deliver
end
end
@ -620,7 +627,7 @@ module JamRuby
# send email notifications
unless offline_followers.empty?
UserMailer.band_recording_saved(offline_followers.map! {|f| f.email}, notification_msg)
UserMailer.band_recording_saved(offline_followers.map! {|f| f.email}, notification_msg).deliver
end
end
@ -704,7 +711,7 @@ module JamRuby
@@mq_router.publish_to_user(receiver.id, msg)
else
UserMailer.band_invitation(receiver.email, notification_msg)
UserMailer.band_invitation(receiver.email, notification_msg).deliver
end
end
@ -731,7 +738,7 @@ module JamRuby
@@mq_router.publish_to_user(receiver.id, msg)
else
UserMailer.band_invitation_accepted(receiver.email, notification_msg)
UserMailer.band_invitation_accepted(receiver.email, notification_msg).deliver
end
end

View File

@ -46,7 +46,6 @@ describe ConnectionManager do
end
it "can't create two client_ids of same value" do
client_id = "client_id1"
user_id = create_user("test", "user1", "user1@jamkazam.com")
@ -425,5 +424,36 @@ describe ConnectionManager do
assert_num_connections(client_id, 0)
end
it "join_music_session fails if user has music_session already active" do
user_id = create_user("test", "user11", "user11@jamkazam.com")
user = User.find(user_id)
music_session = MusicSession.find(create_music_session(user_id))
client_id = Faker::Number.number(20)
@connman.create_connection(user_id, client_id, "1.1.1.1")
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
client_id = Faker::Number.number(20)
@connman.create_connection(user_id, client_id, Faker::Internet.ip_v4_address)
music_session = MusicSession.find(create_music_session(user_id))
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
connection.errors.size.should == 1
connection.errors.get(:music_session).should == [ValidationMessages::CANT_JOIN_MULTIPLE_SESSIONS]
user.update_attribute(:admin, true)
client_id = Faker::Number.number(20)
@connman.create_connection(user_id, client_id, "1.1.1.1")
music_session = MusicSession.find(create_music_session(user_id))
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
client_id = Faker::Number.number(20)
@connman.create_connection(user_id, client_id, Faker::Internet.ip_v4_address)
music_session = MusicSession.find(create_music_session(user_id))
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
connection.errors.size.should == 0
end
end

View File

@ -0,0 +1,19 @@
require 'spec_helper'
describe GeoIpBlocks do
before do
GeoIpBlocks.delete_all
GeoIpBlocks.make_row(0x00000000, 0xffffffff, 17192)
end
it "count" do GeoIpBlocks.count.should == 1 end
let(:first) { GeoIpBlocks.lookup(0x01020304) }
let(:second) { GeoIpBlocks.lookup(0x02030405) }
let(:seventh) { GeoIpBlocks.lookup(9999999999) } # bogus
it "first.locid" do first.locid.should == 17192 end
it "second.locid" do second.locid.should == 17192 end
it "seventh" do seventh.should be_nil end
end

View File

@ -0,0 +1,36 @@
require 'spec_helper'
describe GeoIpLocations do
before do
GeoIpLocations.delete_all
GeoIpLocations.make_row(17192, 'US', 'TX', 'Austin', '78749', 30.2076, -97.8587, 635, '512')
GeoIpLocations.make_row(48086, 'MX', '28', 'Matamoros', '', 25.8833, -97.5000, nil, '')
end
it "count" do GeoIpLocations.count.should == 2 end
let(:first) { GeoIpLocations.lookup(17192) }
let(:second) { GeoIpLocations.lookup(48086) }
let(:third) { GeoIpLocations.lookup(999999) } # bogus
it "first" do
first.locid.should == 17192
first.countrycode.should eql('US')
first.region.should eql('TX')
first.city.should eql('Austin')
first.latitude.should == 30.2076
first.longitude.should == -97.8587
end
it "second" do
second.locid.should == 48086
second.countrycode.should eql('MX')
second.region.should eql('28')
second.city.should eql('Matamoros')
second.latitude.should == 25.8833
second.longitude.should == -97.5000
end
it "third" do third.should be_nil end
end

View File

@ -47,55 +47,53 @@
/****************** MAIN PORTION OF SCREEN *****************/
function addFollowing(isBand, id) {
var newFollowing = {};
var newFollowing = {};
if (!isBand) {
newFollowing.user_id = id;
}
else {
newFollowing.band_id = id;
}
if (!isBand) {
newFollowing.user_id = id;
}
else {
newFollowing.band_id = id;
}
rest.addFollowing(newFollowing)
.done(function() {
if (isBand) {
var newCount = parseInt($("#band-profile-follower-stats").text()) + 1;
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
$('#band-profile-follower-stats').html(newCount + text);
configureBandFollowingButton(true);
}
else {
configureMemberFollowingButton(true, id);
}
})
.fail(app.ajaxError);
rest.addFollowing(newFollowing)
.done(function() {
if (isBand) {
var newCount = parseInt($("#band-profile-follower-stats").text()) + 1;
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
$('#band-profile-follower-stats').html(newCount + text);
configureBandFollowingButton(true);
}
else {
configureMemberFollowingButton(true, id);
}
renderActive();
})
.fail(app.ajaxError);
}
function removeFollowing(isBand, id) {
var following = {};
following.target_entity_id = id;
rest.removeFollowing(following)
.done(function() {
renderActive(); // refresh stats
if (isBand) {
var newCount = parseInt($("#band-profile-follower-stats").text()) - 1;
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
$('#band-profile-follower-stats').html(newCount + text);
configureBandFollowingButton(false);
}
else {
configureMemberFollowingButton(false, id);
}
})
.fail(app.ajaxError);
rest.removeFollowing(id)
.done(function() {
if (isBand) {
var newCount = parseInt($("#band-profile-follower-stats").text()) - 1;
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
$('#band-profile-follower-stats').html(newCount + text);
configureBandFollowingButton(false);
}
else {
configureMemberFollowingButton(false, id);
}
renderActive();
})
.fail(app.ajaxError);
}
function configureBandFollowingButton(following) {
$('#btn-follow-band').unbind("click");
if (following) {
$('#btn-follow-band').text('STOP FOLLOWING');
$('#btn-follow-band').text('UNFOLLOW');
$('#btn-follow-band').click(function() {
removeFollowing(true, bandId);
return false;
@ -121,7 +119,7 @@
$btnFollowMember.unbind("click");
if (following) {
$btnFollowMember.text('UN-FOLLOW');
$btnFollowMember.text('UNFOLLOW');
$btnFollowMember.click(function() {
removeFollowing(false, userId);
return false;

View File

@ -49,20 +49,23 @@
});
var bandHtml = context.JK.fillTemplate(template, {
avatar_url: context.JK.resolveBandAvatarUrl(response.photo_url),
name: response.name,
location: response.location,
genres: genres.join(', '),
musicians: musicianHtml,
like_count: response.liker_count,
follower_count: response.follower_count,
recording_count: response.recording_count,
session_count: response.session_count,
biography: response.biography,
profile_url: "/client#/bandProfile/" + response.id
bandId: response.id,
avatar_url: context.JK.resolveBandAvatarUrl(response.photo_url),
name: response.name,
location: response.location,
genres: genres.join(', '),
musicians: musicianHtml,
like_count: response.liker_count,
follower_count: response.follower_count,
recording_count: response.recording_count,
session_count: response.session_count,
biography: response.biography,
followAction: response.is_following ? "removeBandFollowing" : "addBandFollowing",
profile_url: "/client#/bandProfile/" + response.id
});
$(hoverSelector).append('<h2>Band Detail</h2>' + bandHtml);
configureActionButtons(response);
})
.fail(function(xhr) {
if(xhr.status >= 500) {
@ -77,6 +80,20 @@
});
};
function configureActionButtons(band) {
var btnFollowSelector = "#btnFollow";
// if unauthenticated or authenticated user is viewing his own profile
if (!context.JK.currentUserId) {
$(btnFollowSelector, hoverSelector).hide();
}
else {
if (band.is_following) {
$(btnFollowSelector, hoverSelector).html('UNFOLLOW');
}
}
}
this.hideBubble = function() {
$(hoverSelector).hide();
};

View File

@ -56,12 +56,15 @@
location: response.location,
friend_count: response.friend_count,
follower_count: response.follower_count,
friendAction: response.is_friend ? "removeFanFriend" : (response.pending_friend_request ? "" : "sendFanFriendRequest"),
followAction: response.is_following ? "removeFanFollowing" : "addFanFollowing",
biography: response.biography,
followings: response.followings && response.followings.length > 0 ? followingHtml : "<tr><td>N/A</td></tr>",
profile_url: "/client#/profile/" + response.id
});
$(hoverSelector).append('<h2>Fan Detail</h2>' + fanHtml);
configureActionButtons(response);
})
.fail(function(xhr) {
if(xhr.status >= 500) {
@ -76,6 +79,33 @@
});
};
function configureActionButtons(user) {
var btnFriendSelector = "#btnFriend";
var btnFollowSelector = "#btnFollow";
if (!context.JK.currentUserId || context.JK.currentUserId === user.id) {
$(btnFriendSelector, hoverSelector).hide();
$(btnFollowSelector, hoverSelector).hide();
}
else {
if (user.is_friend) {
$(btnFriendSelector, hoverSelector).html('DISCONNECT');
}
if (user.is_following) {
$(btnFollowSelector, hoverSelector).html('UNFOLLOW');
$(btnFollowSelector, hoverSelector).click(function(evt) {
rest.removeFollowing(user.id);
});
}
if (user.pending_friend_request) {
$(btnFriendSelector, hoverSelector).hide();
}
}
}
this.hideBubble = function() {
$(hoverSelector).hide();
};

View File

@ -75,12 +75,15 @@
session_count: response.session_count,
session_display: sessionDisplayStyle,
session_id: sessionId,
friendAction: response.is_friend ? "removeMusicianFriend" : (response.pending_friend_request ? "" : "sendMusicianFriendRequest"),
followAction: response.is_following ? "removeMusicianFollowing" : "addMusicianFollowing",
biography: response.biography,
followings: response.followings && response.followings.length > 0 ? followingHtml : "<tr><td>N/A</td></tr>",
profile_url: "/client#/profile/" + response.id
});
$(hoverSelector).append('<h2>Musician Detail</h2>' + musicianHtml);
configureActionButtons(response);
})
.fail(function(xhr) {
if(xhr.status >= 500) {
@ -95,6 +98,28 @@
});
};
function configureActionButtons(user) {
var btnFriendSelector = "#btnFriend";
var btnFollowSelector = "#btnFollow";
// if unauthenticated or authenticated user is viewing his own profile
if (!context.JK.currentUserId || context.JK.currentUserId === user.id) {
$(btnFriendSelector, hoverSelector).hide();
$(btnFollowSelector, hoverSelector).hide();
}
else {
if (user.is_friend) {
$(btnFriendSelector, hoverSelector).html('DISCONNECT');
}
if (user.is_following) {
$(btnFollowSelector, hoverSelector).html('UNFOLLOW');
}
if (user.pending_friend_request) {
$(btnFriendSelector, hoverSelector).hide();
}
}
}
this.hideBubble = function() {
$(hoverSelector).hide();
};

View File

@ -55,6 +55,7 @@
});
$(hoverSelector).append('<h2>Recording Detail</h2>' + recordingHtml);
toggleActionButtons();
})
.fail(function(xhr) {
if(xhr.status >= 500) {
@ -69,6 +70,13 @@
});
};
function toggleActionButtons() {
if (!context.JK.currentUserId) {
$("#btnLike", hoverSelector).hide();
$("#btnShare", hoverSelector).hide();
}
}
this.hideBubble = function() {
$(hoverSelector).hide();
};

View File

@ -50,6 +50,7 @@
});
$(hoverSelector).append('<h2>Session Detail</h2>' + sessionHtml);
toggleActionButtons();
})
.fail(function(xhr) {
if(xhr.status >= 500) {
@ -64,6 +65,13 @@
});
};
function toggleActionButtons() {
if (!context.JK.currentUserId) {
$("#btnLike", hoverSelector).hide();
$("#btnShare", hoverSelector).hide();
}
}
this.hideBubble = function() {
$(hoverSelector).hide();
};

View File

@ -451,7 +451,7 @@
});
}
function removeLike(options) {
function removeLike(likableId, options) {
var id = getId(options);
return $.ajax({
type: "DELETE",
@ -476,15 +476,13 @@
});
}
function removeFollowing(options) {
function removeFollowing(followableId, options) {
var id = getId(options);
return $.ajax({
type: "DELETE",
dataType: "json",
contentType: 'application/json',
url: "/api/users/" + id + "/followings",
data: JSON.stringify(options),
url: "/api/users/" + id + "/followings/" + followableId,
processData: false
});
}

View File

@ -99,6 +99,7 @@
context.jamClient.OnLoggedIn(payload.user_id, payload.token);
$.cookie('client_id', payload.client_id);
app.initAfterConnect();
heartbeatMS = payload.heartbeat_interval * 1000;
logger.debug("jamkazam.js.loggedIn(): clientId now " + app.clientId + "; Setting up heartbeat every " + heartbeatMS + " MS");

View File

@ -193,10 +193,10 @@
function configureFriendButton() {
if (isFriend()) {
$('#btn-add-friend').text('REMOVE FRIEND');
$('#btn-add-friend').text('DISCONNECT');
}
else {
$('#btn-add-friend').text('ADD FRIEND');
$('#btn-add-friend').text('CONNECT');
}
}
@ -213,10 +213,7 @@
}
function removeFollowing(isBand, id) {
var following = {};
following.target_entity_id = id;
rest.removeFollowing(following)
rest.removeFollowing(id)
.done(function() {
if (!isBand) {
updateFollowingCount(-1);
@ -242,7 +239,7 @@
function configureFollowingButton() {
if (isFollowing()) {
$('#btn-follow-user').text('STOP FOLLOWING');
$('#btn-follow-user').text('UNFOLLOW');
}
else {
$('#btn-follow-user').text('FOLLOW');

View File

@ -117,23 +117,23 @@
selector = isSidebar ? '#sidebar-search-results' : '#search-results';
$(selector).append(invitationSentHtml);
// wire up button click handler if search result is not a friend or the current use
// wire up button click handler if search result is not a friend or the current user
if (isSidebar) {
var $sidebar = $('div[layout=sidebar] div[user-id=' + val.id + ']');
if (!val.is_friend && val.id !== context.JK.currentUserId) {
$sidebar.find('.btn-connect-friend').click(sendFriendRequest);
if (val.is_friend || val.pending_friend_request || val.id === context.JK.currentUserId) {
// hide the button if the search result is already a friend
$sidebar.find('.btn-connect-friend').hide();
}
else {
// hide the button if the search result is already a friend
$sidebar.find('.btn-connect-friend').hide();
$sidebar.find('.btn-connect-friend').click(sendFriendRequest);
}
}
else {
if (!val.is_friend && val.id !== context.JK.currentUserId) {
$('div[user-id=' + val.id + ']').find('.btn-connect-friend').click(sendFriendRequest);
if (val.is_friend || val.pending_friend_request || val.id === context.JK.currentUserId) {
$('div[user-id=' + val.id + ']').find('.btn-connect-friend').hide();
}
else {
$('div[user-id=' + val.id + ']').find('.btn-connect-friend').hide();
$('div[user-id=' + val.id + ']').find('.btn-connect-friend').click(sendFriendRequest);
}
}
resultDivVisibility(val, isSidebar);

View File

@ -143,6 +143,7 @@
var template = $('#template-notification-panel').html();
var notificationHtml = context.JK.fillTemplate(template, {
notificationId: val.notification_id,
sessionId: val.sessionId,
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
text: val.formatted_msg,
date: context.JK.formatDateTime(val.created_at)
@ -158,13 +159,14 @@
function initializeActions(payload, type) {
var $notification = $('li[notification-id=' + payload.notification_id + ']');
var $btnNotificationAction = '#btn-notification-action';
// wire up "x" button to delete notification
$notification.find('#img-delete-notification').click(deleteNotificationHandler);
// customize action buttons based on notification type
if (type === context.JK.MessageType.FRIEND_REQUEST) {
var $action_btn = $notification.find('#btn-notification-action');
var $action_btn = $notification.find($btnNotificationAction);
$action_btn.text('ACCEPT');
$action_btn.click(function() {
acceptFriendRequest({ "friend_request_id": payload.friend_request_id, "notification_id": payload.notification_id });
@ -180,7 +182,7 @@
}
else if (type === context.JK.MessageType.SESSION_INVITATION) {
var $action_btn = $notification.find('#btn-notification-action');
var $action_btn = $notification.find($btnNotificationAction);
$action_btn.text('JOIN');
$action_btn.click(function() {
openTerms({ "session_id": payload.session_id, "notification_id": payload.notification_id });
@ -188,7 +190,7 @@
}
else if (type === context.JK.MessageType.JOIN_REQUEST) {
var $action_btn = $notification.find('#btn-notification-action');
var $action_btn = $notification.find($btnNotificationAction);
$action_btn.text('APPROVE');
$action_btn.click(function() {
approveJoinRequest({ "join_request_id": payload.join_request_id, "notification_id": payload.notification_id });
@ -196,7 +198,7 @@
}
else if (type === context.JK.MessageType.JOIN_REQUEST_APPROVED) {
var $action_btn = $notification.find('#btn-notification-action');
var $action_btn = $notification.find($btnNotificationAction);
$action_btn.text('JOIN');
$action_btn.click(function() {
openTerms({ "session_id": payload.session_id, "notification_id": payload.notification_id });
@ -208,15 +210,17 @@
}
else if (type === context.JK.MessageType.MUSICIAN_SESSION_JOIN || type === context.JK.MessageType.BAND_SESSION_JOIN) {
var $action_btn = $notification.find('#btn-notification-action');
var $action_btn = $notification.find($btnNotificationAction);
$action_btn.text('LISTEN');
$action_btn.attr('href', '/sessions/' + payload.session_id);
$action_btn.attr('rel', 'external');
$action_btn.click(function() {
listenToSession({ "session_id": payload.session_id, "notification_id": payload.notification_id });
});
}
else if (type === context.JK.MessageType.MUSICIAN_RECORDING_SAVED || type === context.JK.MessageType.BAND_RECORDING_SAVED) {
var $action_btn = $notification.find('#btn-notification-action');
var $action_btn = $notification.find($btnNotificationAction);
$action_btn.text('LISTEN');
$action_btn.click(function() {
listenToRecording({ "recording_id": payload.recording_id, "notification_id": payload.notification_id });
@ -229,7 +233,7 @@
}
else if (type === context.JK.MessageType.BAND_INVITATION) {
var $action_btn = $notification.find('#btn-notification-action');
var $action_btn = $notification.find($btnNotificationAction);
$action_btn.text('ACCEPT');
$action_btn.click(function() {
acceptBandInvitation({ "band_invitation_id": payload.band_invitation_id, "band_id": payload.band_id, "notification_id": payload.notification_id });
@ -335,6 +339,7 @@
var template = $("#template-notification-panel").html();
var notificationHtml = context.JK.fillTemplate(template, {
notificationId: payload.notification_id,
sessionId: payload.session_id,
avatar_url: context.JK.resolveAvatarUrl(payload.photo_url),
text: sidebarText,
date: context.JK.formatDateTime(payload.created_at)
@ -553,8 +558,7 @@
var participants = [];
rest.getSession(payload.session_id).done(function(response) {
$.each(response.participants, function(index, val) {
logger.debug(val.user.photo_url + "," + val.user.name);
participants.push({"photo_url": val.user.photo_url, "name": val.user.name});
participants.push({"photo_url": context.JK.resolveAvatarUrl(val.user.photo_url), "name": val.user.name});
});
}).error(app.ajaxError);
@ -563,7 +567,7 @@
$.each(participants, function(index, val) {
if (index < 4) {
participantHtml += "<tr><td><img class='avatar-small' src='" + val.photo_url + "' /></td><td>" + val.name + "</td></tr>";
participantHtml += "<tr><td><img class='avatar-small' src='" + context.JK.resolveAvatarUrl(val.photo_url) + "' /></td><td>" + val.name + "</td></tr>";
}
});
@ -593,6 +597,17 @@
function registerSessionEnded() {
// TODO: this should clean up all notifications related to this session
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.SESSION_ENDED, function(header, payload) {
logger.debug("Handling SESSION_ENDED msg " + JSON.stringify(payload));
deleteSessionNotifications(payload.session_id);
});
}
// remove all notifications for this session
function deleteSessionNotifications(sessionId) {
console.log("sessionId=%o", sessionId);
$('li[session-id=' + sessionId + ']').hide();
decrementNotificationCount();
}
function registerJoinRequest() {
@ -681,13 +696,8 @@
var recordingId = payload.recording_id;
if(recordingId&& context.JK.CurrentSessionModel.recordingModel.isRecording(recordingId)) {
if(recordingId && context.JK.CurrentSessionModel.recordingModel.isRecording(recordingId)) {
context.JK.CurrentSessionModel.recordingModel.onServerStopRecording(recordingId);
/**app.notify({
"title": "Recording Stopped",
"text": payload.username + " has left the session.",
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
}); */
}
else {
app.notify({
@ -713,7 +723,8 @@
"ok_text": "LISTEN",
"ok_callback": listenToSession,
"ok_callback_args": {
"session_id": payload.session_id
"session_id": payload.session_id,
"notification_id": payload.notification_id
}
});
});
@ -734,7 +745,8 @@
"ok_text": "LISTEN",
"ok_callback": listenToSession,
"ok_callback_args": {
"session_id": payload.session_id
"session_id": payload.session_id,
"notification_id": payload.notification_id
}
});
});
@ -742,7 +754,7 @@
function listenToSession(args) {
deleteNotification(args.notification_id);
context.location = '/client#/session/' + args.session_id;
context.JK.popExternalLink('/recordings/' + args.session_id);
}
function registerMusicianRecordingSaved() {
@ -759,7 +771,8 @@
"ok_text": "LISTEN",
"ok_callback": listenToRecording,
"ok_callback_args": {
"recording_id": payload.recording_id
"recording_id": payload.recording_id,
"notification_id": payload.notification_id
}
});
});
@ -780,7 +793,8 @@
"ok_text": "LISTEN",
"ok_callback": listenToRecording,
"ok_callback_args": {
"recording_id": payload.recording_id
"recording_id": payload.recording_id,
"notification_id": payload.notification_id
}
});
});
@ -788,7 +802,7 @@
function listenToRecording(args) {
deleteNotification(args.notification_id);
context.location = '/client#/recording/' + args.recording_id;
context.JK.popExternalLink('/recordings/' + args.recording_id);
}
function registerRecordingStarted() {

View File

@ -549,6 +549,22 @@
});
}
context.JK.popExternalLink = function(href) {
if(!context.jamClient) {
return;
}
if (href) {
// make absolute if not already
if(href.indexOf('http') != 0 && href.indexOf('mailto') != 0) {
href = window.location.protocol + '//' + window.location.host + href;
}
context.jamClient.OpenSystemBrowser(href);
}
return false;
}
context.JK.checkbox = function($checkbox) {
$checkbox.iCheck({
checkboxClass: 'icheckbox_minimal',

View File

@ -41,6 +41,7 @@
*= require ./localRecordingsDialog
*= require ./serverErrorDialog
*= require ./leaveSessionWarning
*= require ./terms
*= require ./createSession
*= require ./genreSelector
*= require ./sessionList

View File

@ -0,0 +1,7 @@
#session-terms-conditions {
max-width:550px;
min-height:0;
p {
line-height:22px;
}
}

View File

@ -55,4 +55,8 @@
position:absolute;
top:3px;
right:4px;
}
#btnPlayPause {
position: relative;
}

View File

@ -16,4 +16,8 @@
font-size:15px;
color:#cccc00;
margin-left:20px;
}*/
}*/
#btnPlayPause {
position: relative;
}

View File

@ -1,6 +1,6 @@
class ApiUsersController < ApiController
before_filter :api_signed_in_user, :except => [:create, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring]
before_filter :api_signed_in_user, :except => [:create, :show, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring]
before_filter :auth_user, :only => [:session_settings_show, :session_history_index, :session_user_history_index, :update, :delete,
:liking_create, :liking_destroy, # likes
:following_create, :following_show, :following_destroy, # followings
@ -202,7 +202,7 @@ class ApiUsersController < ApiController
end
def liking_destroy
User.delete_liking(params[:id], params[:target_entity_id])
User.delete_liking(params[:id], params[:likable_id])
respond_with responder: ApiResponder, :status => 204
end
@ -230,7 +230,7 @@ class ApiUsersController < ApiController
end
def following_destroy
User.delete_following(params[:id], params[:target_entity_id])
User.delete_following(params[:id], params[:followable_id])
respond_with responder: ApiResponder, :status => 204
end

View File

@ -23,6 +23,10 @@ if @search.musicians_text_search?
musician.friends?(current_user)
end
node :pending_friend_request do |musician|
musician.pending_friend_request?(current_user)
end
child :musician_instruments => :instruments do
attributes :instrument_id, :description, :proficiency_level, :priority
end
@ -50,6 +54,10 @@ if @search.musicians_filter_search?
@search.is_follower?(musician)
end
node :pending_friend_request do |musician|
@search.pending_friend_request?(musician)
end
node :biography do |musician|
musician.biography.nil? ? "" : musician.biography
end
@ -112,6 +120,10 @@ if @search.fans_text_search?
node :is_friend do |fan|
fan.friends?(current_user)
end
node :pending_friend_request do |musician|
@search.pending_friend_request?(musician)
end
}
end

View File

@ -55,8 +55,6 @@
<div class="field">
<label for="current_password">Current Password:</label>
<input type="password" name="current_password" value="">
<br/>
<a id="account-forgot-password" href="#" class="small">Forgot Password?</a>
</div>
<div class="field">

View File

@ -5,25 +5,49 @@
<script type="text/javascript">
var rest = JK.Rest();
function addLike(bandId) {
rest.addLike({band_id: bandId})
// function addLike(bandId) {
// rest.addLike({band_id: bandId})
// .done(function(response) {
// $("#spnLikeCount", "#band-hover").html(parseInt($("#spnLikeCount", "#band-hover").text()) + 1);
// var $btnLikeSelector = $("#btnLike", "#band-hover");
// $btnLikeSelector.unbind("click");
// $btnLikeSelector.html("LIKED");
// });
// }
function addBandFollowing(bandId) {
rest.addFollowing({band_id: bandId})
.done(function(response) {
$("#spnLikeCount", "#band-hover").html(parseInt($("#spnLikeCount", "#band-hover").text()) + 1);
var $btnLikeSelector = $("#btnLike", "#band-hover");
$btnLikeSelector.unbind("click");
$btnLikeSelector.html("LIKED");
adjustBandFollowingCount(1);
var $btnFollowSelector = $("#btnFollow", "#band-hover");
$btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
removeBandFollowing(bandId);
});
$btnFollowSelector.html("UNFOLLOW");
});
}
function addFollowing(bandId) {
rest.addFollowing({band_id: bandId})
function removeBandFollowing(bandId) {
rest.removeFollowing(bandId)
.done(function(response) {
$("#spnFollowCount", "#band-hover").html(parseInt($("#spnFollowCount", "#band-hover").text()) + 1);
var $btnFollowSelector = $("#btnFollow", "#band-hover");
$btnFollowSelector.unbind("click");
$btnFollowSelector.html("STOP FOLLOWING");
adjustBandFollowingCount(-1);
var $btnFollowSelector = $("#btnFollow", "#band-hover");
$btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
addBandFollowing(bandId);
});
$btnFollowSelector.html("FOLLOW");
});
}
function adjustBandFollowingCount(value) {
$("#spnFollowCount", "#band-hover").text(parseInt($("#spnFollowCount", "#band-hover").text()) + value);
}
</script>
<script type="text/template" id="template-hover-band">
@ -33,7 +57,6 @@
<h3>{name}</h3>
<small>{location}<br /><strong>{genres}</strong></small><br />
<br clear="all" />
<span id="spnLikeCount">{like_count}</span> <img src="/assets/content/icon_like.png" align="absmiddle" />&nbsp;&nbsp;&nbsp;
<span id="spnFollowCount">{follower_count}</span> <img src="/assets/content/icon_followers.png" width="22" height="12" align="absmiddle" />&nbsp;&nbsp;&nbsp;
{recording_count} <img src="/assets/content/icon_recordings.png" width="12" height="13" align="absmiddle" />&nbsp;&nbsp;&nbsp;
{session_count} <img src="/assets/content/icon_session_tiny.png" width="12" height="12" align="absmiddle" />
@ -47,8 +70,8 @@
<br />
<div align="center">
<div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div>
<div class="left"><a class="button-orange">LIKE</a></div>
<div class="left"><a class="button-orange">FOLLOW</a></div>
<div class="left" style="display:none;"><a class="button-orange">LIKE</a></div>
<div class="left"><a id="btnFollow" onclick="{followAction}('{bandId}');" class="button-orange">FOLLOW</a></div>
</div>
<br /><br />
</div>

View File

@ -5,19 +5,58 @@
<script type="text/javascript">
var rest = JK.Rest();
function addFollowing(userId) {
function addFanFollowing(userId) {
rest.addFollowing({user_id: userId})
.done(function(response) {
$("#spnFollowCount", "#fan-hover").html(parseInt($("#spnFollowCount", "#fan-hover").text()) + 1);
var $btnFollowSelector = $("#btnFollow", "#fan-hover");
$btnFollowSelector.unbind("click");
$btnFollowSelector.html("STOP FOLLOWING");
adjustFanFollowingCount(1);
var $btnFollowSelector = $("#btnFollow", "#fan-hover");
$btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
removeFanFollowing(userId);
});
$btnFollowSelector.html("UNFOLLOW");
});
}
function sendFriendRequest(userId) {
rest.sendFriendRequest(JK.app, userId);
function removeFanFollowing(userId) {
rest.removeFollowing(userId)
.done(function(response) {
adjustFanFollowingCount(-1);
var $btnFollowSelector = $("#btnFollow", "#fan-hover");
$btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
addFanFollowing(userId);
});
$btnFollowSelector.html("FOLLOW");
});
}
function adjustFanFollowingCount(value) {
$("#spnFollowCount", "#fan-hover").text(parseInt($("#spnFollowCount", "#fan-hover").text()) + value);
}
function sendFanFriendRequest(userId) {
rest.sendFriendRequest(JK.app, userId);
$("#btnFriend", "#fan-hover").hide();
}
function removeFanFriend(userId) {
rest.removeFriend({friend_id: userId})
.done(function() {
var $btnFriendSelector = $("#btnFriend", "#fan-hover");
$btnFriendSelector.unbind("click");
$btnFriendSelector.attr('onclick', '');
$btnFriendSelector.html("CONNECT");
$btnFriendSelector.click(function() {
sendFanFriendRequest(userId);
});
});
}
</script>
<script type="text/template" id="template-hover-fan">
@ -38,8 +77,8 @@
<br />
<div align="center">
<div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div>
<div class="left"><a id="btnFriend" onclick="sendFriendRequest('{userId}');" class="button-orange">FRIEND</a></div>
<div class="left"><a id="btnFollow" onclick="addFollowing('{userId}');" class="button-orange">FOLLOW</a></div>
<div class="left"><a id="btnFriend" onclick="{friendAction}('{userId}');" class="button-orange">CONNECT</a></div>
<div class="left"><a id="btnFollow" onclick="{followAction}('{userId}');" class="button-orange">FOLLOW</a></div>
</div>
<br /><br />
</div>

View File

@ -5,28 +5,66 @@
<script type="text/javascript">
var rest = JK.Rest();
function addLike(userId) {
rest.addLike({user_id: userId})
.done(function(response) {
$("#spnLikeCount", "#musician-hover").html(parseInt($("#spnLikeCount", "#musician-hover").text()) + 1);
var $btnLikeSelector = $("#btnLike", "#musician-hover");
$btnLikeSelector.unbind("click");
$btnLikeSelector.html("LIKED");
});
}
// function addLike(userId) {
// rest.addLike({user_id: userId})
// .done(function(response) {
// $("#spnLikeCount", "#musician-hover").text(parseInt($("#spnLikeCount", "#musician-hover").text()) + 1);
// var $btnLikeSelector = $("#btnLike", "#musician-hover");
// $btnLikeSelector.unbind("click");
// $btnLikeSelector.html("LIKED");
// });
// }
function addFollowing(userId) {
function addMusicianFollowing(userId) {
rest.addFollowing({user_id: userId})
.done(function(response) {
$("#spnFollowCount", "#musician-hover").html(parseInt($("#spnFollowCount", "#musician-hover").text()) + 1);
var $btnFollowSelector = $("#btnFollow", "#musician-hover");
$btnFollowSelector.unbind("click");
$btnFollowSelector.html("UNFOLLOW");
adjustMusicianFollowingCount(1);
var $btnFollowSelector = $("#btnFollow", "#musician-hover");
$btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
removeMusicianFollowing(userId);
});
$btnFollowSelector.html("UNFOLLOW");
});
}
function sendFriendRequest(userId) {
function removeMusicianFollowing(userId) {
rest.removeFollowing(userId)
.done(function(response) {
adjustMusicianFollowingCount(-1);
var $btnFollowSelector = $("#btnFollow", "#musician-hover");
$btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
addMusicianFollowing(userId);
});
$btnFollowSelector.html("FOLLOW");
});
}
function adjustMusicianFollowingCount(value) {
$("#spnFollowCount", "#musician-hover").html(parseInt($("#spnFollowCount", "#musician-hover").html()) + value);
}
function sendMusicianFriendRequest(userId) {
rest.sendFriendRequest(JK.app, userId);
$("#btnFriend", "#musician-hover").hide();
}
function removeMusicianFriend(userId) {
rest.removeFriend({friend_id: userId})
.done(function() {
var $btnFriendSelector = $("#btnFriend", "#musician-hover");
$btnFriendSelector.unbind("click");
$btnFriendSelector.attr('onclick', '');
$btnFriendSelector.html("CONNECT");
$btnFriendSelector.click(function() {
sendMusicianFriendRequest(userId);
});
});
}
</script>
@ -54,9 +92,9 @@
<br />
<div align="center">
<div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div>
<div class="left"><a id="btnLike" onclick="addLike('{userId}');" class="button-orange">LIKE</a></div>
<div class="left"><a id="btnFriend" onclick="sendFriendRequest('{userId}');" class="button-orange">FRIEND</a></div>
<div class="left"><a id="btnFollow" onclick="addFollowing('{userId}');" class="button-orange">FOLLOW</a></div>
<div class="left" style="display:none;"><a id="btnLike" onclick="addLike('{userId}');" class="button-orange">LIKE</a></div>
<div class="left"><a id="btnFriend" onclick="{friendAction}('{userId}');" class="button-orange">CONNECT</a></div>
<div class="left"><a id="btnFollow" onclick="{followAction}('{userId}');" class="button-orange">FOLLOW</a></div>
</div>
<br /><br />
</div>

View File

@ -170,9 +170,9 @@
<!-- Friend panel template -->
<script type="text/template" id="template-friend-panel">
<li class="{cssClass}" user-id="{userId}" hoveraction="{hoverAction}" >
<div class="avatar-small"><img src="{avatar_url}" /></div>
<div class="friend-name">
<li class="{cssClass}">
<div class="avatar-small" user-id="{userId}" hoveraction="{hoverAction}"><img src="{avatar_url}" /></div>
<div class="friend-name" user-id="{userId}" hoveraction="{hoverAction}">
{userName}<br/>
<span class="friend-status">
{status} {extra_info}
@ -198,7 +198,7 @@
<!-- Notification panel template -->
<script type="text/template" id="template-notification-panel">
<li notification-id="{notificationId}">
<li session-id="{sessionId}" notification-id="{notificationId}">
<div class="avatar-small"><img src="{avatar_url}" /></div>
<div class="note-text">
{text}

View File

@ -1,5 +1,5 @@
<!-- Terms Dialog -->
<div class="dialog" layout="dialog" layout-id="terms" style="max-width:550px;">
<div class="dialog" layout="dialog" layout-id="terms" id="session-terms-conditions">
<div class="content-head">
<%= image_tag "content/icon_add.png", {:width => 19, :height => 19, :class => 'content-icon' } %>
<h1>Terms and Conditions</h1>
@ -9,12 +9,12 @@
I agree that intellectual property ownership of any musical works created during this session shall be governed by the terms of the <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/" target="_blank">Creative Commons CC BY-NC-SA license</a> in accordance with the <a rel="external" href="http://www.jamkazam.com/corp/terms" target="_blank">JamKazam Terms of Service</a>.
</span>
<br clear="left" /><br />
<div class="left">
<a id="btn-cancel-terms" layout-action="close" class="button-orange">CANCEL</a>
</div>
<div class="right">
<a id="btn-accept-terms" layout-action="close" class="button-orange">ACCEPT</a>
</div>
<div class="right">
<a id="btn-cancel-terms" layout-action="close" class="button-orange">CANCEL</a>
</div>
<br clear="all" />
</div>
</div>

View File

@ -103,9 +103,10 @@
JK.currentUserName = null;
<% end %>
// Some things can't be initialized until we're connected. Put them here.
function _initAfterConnect() {
if (this.didInitAfterConnect) return;
this.didInitAfterConnect = true
var recordingManager = new JK.RecordingManager();
@ -217,6 +218,7 @@
}
JK.app = JK.JamKazam();
JK.app.initAfterConnect = _initAfterConnect;
// If no jamClient (when not running in native client)
// create a fake one.
@ -241,12 +243,16 @@
// Run a check to see if we're logged in yet. Only after that should
// we initialize the other screens.
// TODO: There should be a timeout, and a "could not connect" message.
function testConnected() {
this.numCalls = (this.numCalls || 0) + 1;
if (JK.clientId) {
_initAfterConnect();
JK.app.initAfterConnect();
} else {
window.setTimeout(testConnected, 100);
if (50 <= this.numCalls) { // 5 second max
JK.notifyAlert('Server Error', 'Could not connect to server. Please try again later.')
} else {
window.setTimeout(testConnected, 100);
}
}
}
testConnected();

View File

@ -53,7 +53,7 @@
<div class="w100">
<div class="recording-controls">
<% if !@music_session.music_session.nil? && !@music_session.music_session.mount.blank? %>
<a class="left mr20" href="#">
<a id="btnPlayPause" class="left mr20">
<%= image_tag "content/icon_playbutton.png", {:id => "imgPlayPause", :width => 20, :height => 20, :alt => ""} %>
</a>
<% end %>
@ -140,7 +140,6 @@
$imgPlayPauseSelector.attr('src', playButtonPath);
}
});
});
})
});
</script>
<% end %>

View File

@ -52,7 +52,7 @@
<div class="w100">
<div class="recording-controls">
<% if @claimed_recording.has_mix? %>
<a id="btnPlayPause" class="left" href="#">
<a id="btnPlayPause" class="left">
<%= image_tag "content/icon_playbutton.png", {:id => "imgPlayPause", :width => 20, :height => 20, :alt => ""} %>
</a>
<% end %>

View File

@ -161,7 +161,7 @@ SampleApp::Application.routes.draw do
# user likes
match '/users/:id/likings' => 'api_users#liking_index', :via => :get, :as => 'api_user_liking_index'
match '/users/:id/likings' => 'api_users#liking_create', :via => :post
match '/users/:id/likings' => 'api_users#liking_destroy', :via => :delete
match '/users/:id/likings/:likable_id' => 'api_users#liking_destroy', :via => :delete
# user followers
match '/users/:id/followers' => 'api_users#follower_index', :via => :get, :as => 'api_user_follower_index'
@ -169,7 +169,7 @@ SampleApp::Application.routes.draw do
# user followings
match '/users/:id/followings' => 'api_users#following_index', :via => :get, :as => 'api_user_following_index'
match '/users/:id/followings' => 'api_users#following_create', :via => :post
match '/users/:id/followings' => 'api_users#following_destroy', :via => :delete
match '/users/:id/followings/:followable_id' => 'api_users#following_destroy', :via => :delete
# favorites
match '/users/:id/favorites' => 'api_users#favorite_index', :via => :get, :as => 'api_favorite_index'

View File

@ -36,13 +36,13 @@ describe "Session Recordings", :js => true, :type => :feature, :capybara_feature
# confirms that a formal leave (by hitting the 'Leave' button) will result in a good recording
it "creator starts and then leaves" do
start_recording_with(creator, [joiner1])
in_client(creator) do
find('#session-leave').trigger(:click)
find('#btn-accept-leave-session').trigger(:click)
expect(page).to have_selector('h2', text: 'feed')
end
formal_leave_by creator
check_recording_finished_for [creator, joiner1]
end
@ -74,12 +74,7 @@ describe "Session Recordings", :js => true, :type => :feature, :capybara_feature
it "creator starts with session leave to stop, with 3 total participants" do
start_recording_with(creator, [joiner1, joiner2])
in_client(creator) do
find('#session-leave').trigger(:click)
find('#btn-accept-leave-session').trigger(:click)
expect(page).to have_selector('h2', text: 'feed')
end
formal_leave_by creator
check_recording_finished_for [creator, joiner1, joiner2]
end

View File

@ -56,7 +56,7 @@ describe "User API", :type => :api do
def delete_user_like(authenticated_user, source_user, target_user)
login(authenticated_user.email, authenticated_user.password, 200, true)
delete "/api/users/#{source_user.id}/likings.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
delete "/api/users/#{source_user.id}/likings/#{target_user.id}.json", "CONTENT_TYPE" => 'application/json'
return last_response
end
@ -99,7 +99,7 @@ describe "User API", :type => :api do
def delete_user_following(authenticated_user, source_user, target_user)
login(authenticated_user.email, authenticated_user.password, 200, true)
delete "/api/users/#{source_user.id}/followings.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
delete "/api/users/#{source_user.id}/followings/#{target_user.id}.json", "CONTENT_TYPE" => 'application/json'
return last_response
end

View File

@ -208,6 +208,14 @@ def create_join_session(creator, joiners=[], genre=nil)
end
end
def formal_leave_by user
in_client(user) do
find('#session-leave').trigger(:click)
find('#btn-accept-leave-session').trigger(:click)
expect(page).to have_selector('h2', text: 'feed')
end
end
def start_recording_with(creator, joiners=[], genre=nil)
create_join_session(creator, joiners, genre)
in_client(creator) do