* VRFS-1253 - working in a basic sense with pagination

This commit is contained in:
Seth Call 2014-03-09 18:04:56 +00:00
parent eea0001ab3
commit 000dd3fdd0
16 changed files with 1418 additions and 431 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -24,6 +24,8 @@
//= require jquery.clipboard
//= require jquery.timeago
//= require jquery.easydropdown
//= require jquery.scrollTo
//= require jquery.infinitescroll
//= require globals
//= require AAB_message_factory
//= require AAC_underscore

View File

@ -1,377 +1,483 @@
(function(context,$) {
(function (context, $) {
"use strict";
"use strict";
context.JK = context.JK || {};
context.JK.FindSessionScreen = function(app) {
var CATEGORY = {
INVITATION : {index: 0, id: "table#sessions-invitations"},
FRIEND : {index: 1, id: "table#sessions-friends"},
OTHER : {index: 2, id: "table#sessions-other"}
};
var logger = context.JK.logger;
var rest = context.JK.Rest();
var sessionLatency;
var sessions = {};
var invitationSessionGroup = {};
var friendSessionGroup = {};
var otherSessionGroup = {};
var sessionCounts = [0, 0, 0];
var sessionList;
// for unit tests
function getCategoryEnum() {
return CATEGORY;
}
function removeSpinner() {
$('<div[layout-id=findSession] .content .spinner').remove();// remove any existing spinners
}
function addSpinner() {
removeSpinner();
$('<div[layout-id=findSession] .content').append('<div class="spinner spinner-large"></div>')
}
function loadSessions(queryString) {
addSpinner();
// squelch nulls and undefines
queryString = !!queryString ? queryString : "";
if(gon.use_cached_session_scores) {
rest.findScoredSessions(app.clientId, queryString)
.done(afterLoadScoredSessions)
.always(removeSpinner)
.fail(app.ajaxError)
}
else {
rest.findSessions(queryString)
.done(afterLoadSessions)
.fail(app.ajaxError)
.always(removeSpinner)
}
}
function search() {
logger.debug("Searching for sessions...");
clearResults();
var queryString = '';
// genre filter
var genres = context.JK.GenreSelectorHelper.getSelectedGenres('#find-session-genre');
if (genres !== null && genres.length > 0) {
queryString += "genres=" + genres.join(',');
}
// keyword filter
var keyword = $('#session-keyword-srch').val();
if (keyword !== null && keyword.length > 0 && keyword !== 'Search by Keyword') {
if (queryString.length > 0) {
queryString += "&";
}
queryString += "keyword=" + $('#session-keyword-srch').val();
}
loadSessions(queryString);
}
function refreshDisplay() {
var priorVisible;
var INVITATION = 'div#sessions-invitations';
var FRIEND = 'div#sessions-friends';
var OTHER = 'div#sessions-other';
// INVITATION
//logger.debug("sessionCounts[CATEGORY.INVITATION.index]=" + sessionCounts[CATEGORY.INVITATION.index]);
if (sessionCounts[CATEGORY.INVITATION.index] === 0) {
priorVisible = false;
$(INVITATION).hide();
}
else {
priorVisible = true;
$(INVITATION).show();
}
// FRIEND
if (!priorVisible) {
$(FRIEND).removeClass('mt35');
}
//logger.debug("sessionCounts[CATEGORY.FRIEND.index]=" + sessionCounts[CATEGORY.FRIEND.index]);
if (sessionCounts[CATEGORY.FRIEND.index] === 0) {
priorVisible = false;
$(FRIEND).hide();
}
else {
priorVisible = true;
$(FRIEND).show();
}
// OTHER
if (!priorVisible) {
$(OTHER).removeClass('mt35');
}
//logger.debug("sessionCounts[CATEGORY.OTHER.index]=" + sessionCounts[CATEGORY.OTHER.index]);
if (sessionCounts[CATEGORY.OTHER.index] === 0) {
$(OTHER).hide();
}
else {
$(OTHER).show();
}
}
function afterLoadScoredSessions(sessionList) {
// display the 'no sessions' banner if appropriate
var $noSessionsFound = $('#sessions-none-found');
if(sessionList.length == 0) {
$noSessionsFound.show();
}
else {
$noSessionsFound.hide();
}
$.each(sessionList, function(i, session) {
sessions[session.id] = session;
session.latencyInfo
});
$.each(sessionList, function(i, session) {
renderSession(session.id);
})
context.JK.GA.trackFindSessions(sessionList.length);
}
function afterLoadSessions(sessionList) {
// display the 'no sessions' banner if appropriate
var $noSessionsFound = $('#sessions-none-found');
if(sessionList.length == 0) {
$noSessionsFound.show();
}
else {
$noSessionsFound.hide();
}
startSessionLatencyChecks(sessionList);
context.JK.GA.trackFindSessions(sessionList.length);
}
function startSessionLatencyChecks(sessionList) {
logger.debug("Starting latency checks on " + sessionList.length + " sessions");
sessionLatency.subscribe(app.clientId, latencyResponse);
$.each(sessionList, function(index, session) {
sessions[session.id] = session;
sessionLatency.sessionPings(session);
});
}
function containsInvitation(session) {
var i, invitation = null;
if (session !== undefined) {
if ("invitations" in session) {
// user has invitations for this session
for (i=0; i < session.invitations.length; i++) {
invitation = session.invitations[i];
// session contains an invitation for this user
if (invitation.receiver_id == context.JK.currentUserId) {
return true;
}
}
}
}
return false;
}
function containsFriend(session) {
var i, participant = null;
if (session !== undefined) {
if ("participants" in session) {
for (i=0; i < session.participants.length; i++) {
participant = session.participants[i];
// this session participant is a friend
if (participant !== null && participant !== undefined && participant.user.is_friend) {
return true;
}
}
}
}
return false;
}
function latencyResponse(sessionId) {
logger.debug("Received latency response for session " + sessionId);
renderSession(sessionId);
}
/**
* Not used normally. Allows modular unit testing
* of the renderSession method without having to do
* as much heavy setup.
*/
function setSession(session) {
invitationSessionGroup[session.id] = session;
}
/**
* Render a single session line into the table.
* It will be inserted at the appropriate place according to the
* sortScore in sessionLatency.
*/
function renderSession(sessionId) {
// store session in the appropriate bucket and increment category counts
var session = sessions[sessionId];
if (containsInvitation(session)) {
invitationSessionGroup[sessionId] = session;
sessionCounts[CATEGORY.INVITATION.index]++;
}
else if (containsFriend(session)) {
friendSessionGroup[sessionId] = session;
sessionCounts[CATEGORY.FRIEND.index]++;
}
else {
otherSessionGroup[sessionId] = session;
sessionCounts[CATEGORY.OTHER.index]++;
}
// hack to prevent duplicate rows from being rendered when filtering
var sessionAlreadyRendered = false;
var $tbGroup;
logger.debug('Rendering session ID = ' + sessionId);
if (invitationSessionGroup[sessionId] != null) {
$tbGroup = $(CATEGORY.INVITATION.id);
if ($("table#sessions-invitations tr[id='" + sessionId + "']").length > 0) {
sessionAlreadyRendered = true;
}
}
else if (friendSessionGroup[sessionId] != null) {;
$tbGroup = $(CATEGORY.FRIEND.id);
if ($("table#sessions-friends tr[id='" + sessionId + "']").length > 0) {
sessionAlreadyRendered = true;
}
}
else if (otherSessionGroup[sessionId] != null) {
$tbGroup = $(CATEGORY.OTHER.id);
if ($("table#sessions-other tr[id='" + sessionId + "']").length > 0) {
sessionAlreadyRendered = true;
}
}
else {
logger.debug('ERROR: No session with ID = ' + sessionId + ' found.');
return;
}
if (!sessionAlreadyRendered) {
var row = sessionList.renderSession(session, sessionLatency, $tbGroup, $('#template-session-row').html(), $('#template-musician-info').html());
}
refreshDisplay();
}
function beforeShow(data) {
context.JK.GenreSelectorHelper.render('#find-session-genre');
}
function afterShow(data) {
clearResults();
refreshDisplay();
loadSessions();
}
function clearResults() {
$('table#sessions-invitations').children(':not(:first-child)').remove();
$('table#sessions-friends').children(':not(:first-child)').remove();
$('table#sessions-other').children(':not(:first-child)').remove();
sessionCounts = [0, 0, 0];
sessions = {};
invitationSessionGroup = {};
friendSessionGroup = {};
otherSessionGroup = {};
}
function deleteSession(evt) {
var sessionId = $(evt.currentTarget).attr("action-id");
if (sessionId) {
$.ajax({
type: "DELETE",
url: "/api/sessions/" + sessionId,
error: app.ajaxError
}).done(loadSessions);
}
}
function events() {
$('#session-keyword-srch').focus(function() {
$(this).val('');
});
$("#session-keyword-srch").keypress(function(evt) {
if (evt.which === 13) {
evt.preventDefault();
search();
}
});
$('#btn-refresh').on("click", search);
}
/**
* Initialize, providing an instance of the SessionLatency class.
*/
function initialize(latency) {
var screenBindings = {
'beforeShow': beforeShow,
'afterShow': afterShow
};
app.bindScreen('findSession', screenBindings);
if (latency) {
sessionLatency = latency;
}
else {
logger.warn("No sessionLatency provided.");
}
sessionList = new context.JK.SessionList(app);
events();
}
this.initialize = initialize;
this.renderSession = renderSession;
this.afterShow = afterShow;
// Following exposed for easier testing.
this.setSession = setSession;
this.clearResults = clearResults;
this.getCategoryEnum = getCategoryEnum;
return this;
context.JK = context.JK || {};
context.JK.FindSessionScreen = function (app) {
var CATEGORY = {
INVITATION: {index: 0, id: "table#sessions-invitations"},
FRIEND: {index: 1, id: "table#sessions-friends"},
OTHER: {index: 2, id: "table#sessions-other"}
};
})(window,jQuery);
var logger = context.JK.logger;
var rest = context.JK.Rest();
var sessionLatency;
var sessions = {};
var invitationSessionGroup = {};
var friendSessionGroup = {};
var otherSessionGroup = {};
var sessionCounts = [0, 0, 0];
var sessionList;
var currentQuery = defaultQuery();
var currentPage = 0;
var LIMIT = 20;
var $next = null;
var $scroller = null;
var $noMoreSessions = null;
function defaultQuery() {
return {offset:currentPage * LIMIT, limit:LIMIT, page:currentPage};
}
// for unit tests
function getCategoryEnum() {
return CATEGORY;
}
function removeSpinner() {
$('<div[layout-id=findSession] .content .spinner').remove();// remove any existing spinners
}
function addSpinner() {
removeSpinner();
$('<div[layout-id=findSession] .content').append('<div class="spinner spinner-large"></div>')
}
function loadSessionsOriginal() {
addSpinner();
rest.findSessions(currentQuery)
.done(afterLoadSessions)
.fail(app.ajaxError)
.always(removeSpinner)
}
function loadSessionsNew() {
addSpinner();
rest.findScoredSessions(app.clientId, currentQuery)
.done(function(response) { afterLoadScoredSessions(response); })
.always(function(){ removeSpinner(); })
.fail(app.ajaxError)
}
function loadSessions() {
if (gon.use_cached_session_scores) {
loadSessionsNew();
}
else {
loadSessionsOriginal();
}
}
function buildQuery() {
currentQuery = defaultQuery();
// genre filter
var genres = context.JK.GenreSelectorHelper.getSelectedGenres('#find-session-genre');
if (genres !== null && genres.length > 0) {
currentQuery.genres = genres.join(',');
}
// keyword filter
var keyword = $('#session-keyword-srch').val();
if (keyword !== null && keyword.length > 0 && keyword !== 'Search by Keyword') {
currentQuery.keyword = $('#session-keyword-srch').val();
}
return currentQuery;
}
function search() {
logger.debug("Searching for sessions...");
clearResults();
buildQuery();
refreshDisplay();
loadSessions();
}
function refreshDisplay() {
var priorVisible;
var INVITATION = 'div#sessions-invitations';
var FRIEND = 'div#sessions-friends';
var OTHER = 'div#sessions-other';
// INVITATION
//logger.debug("sessionCounts[CATEGORY.INVITATION.index]=" + sessionCounts[CATEGORY.INVITATION.index]);
if (sessionCounts[CATEGORY.INVITATION.index] === 0) {
priorVisible = false;
$(INVITATION).hide();
}
else {
priorVisible = true;
$(INVITATION).show();
}
// FRIEND
if (!priorVisible) {
$(FRIEND).removeClass('mt35');
}
//logger.debug("sessionCounts[CATEGORY.FRIEND.index]=" + sessionCounts[CATEGORY.FRIEND.index]);
if (sessionCounts[CATEGORY.FRIEND.index] === 0) {
priorVisible = false;
$(FRIEND).hide();
}
else {
priorVisible = true;
$(FRIEND).show();
}
// OTHER
if (!priorVisible) {
$(OTHER).removeClass('mt35');
}
//logger.debug("sessionCounts[CATEGORY.OTHER.index]=" + sessionCounts[CATEGORY.OTHER.index]);
if (sessionCounts[CATEGORY.OTHER.index] === 0) {
$(OTHER).hide();
}
else {
$(OTHER).show();
}
}
function afterLoadScoredSessions(sessionList) {
// display the 'no sessions' banner if appropriate
var $noSessionsFound = $('#sessions-none-found');
if (currentPage == 0 && sessionList.length == 0) {
$noSessionsFound.show();
}
else {
$noSessionsFound.hide();
}
// update pager so infinitescroll can do it's thing
//$next.attr('href', '/api/sessions/nindex/' + app.clientId + '?' + $.param(currentQuery))
/**
// XXX
if(sessionList.length > 0) {
for(var i = 0; i < 20; i++) {
var copied = $.extend(true, {}, sessionList[0]);
copied.id = 'session_' + i;
sessionList.push(copied);
}
}
*/
$.each(sessionList, function (i, session) {
sessions[session.id] = session;
});
$.each(sessionList, function (i, session) {
renderSession(session.id);
});
if(sessionList.length < LIMIT) {
// if we less results than asked for, end searching
$scroller.infinitescroll('pause');
if(currentPage > 0) {
$noMoreSessions.show();
}
}else {
currentPage++;
buildQuery();
registerInfiniteScroll();
}
context.JK.GA.trackFindSessions(sessionList.length);
}
function afterLoadSessions(sessionList) {
// display the 'no sessions' banner if appropriate
var $noSessionsFound = $('#sessions-none-found');
if (sessionList.length == 0) {
$noSessionsFound.show();
}
else {
$noSessionsFound.hide();
}
startSessionLatencyChecks(sessionList);
context.JK.GA.trackFindSessions(sessionList.length);
}
function startSessionLatencyChecks(sessionList) {
logger.debug("Starting latency checks on " + sessionList.length + " sessions");
sessionLatency.subscribe(app.clientId, latencyResponse);
$.each(sessionList, function (index, session) {
sessions[session.id] = session;
sessionLatency.sessionPings(session);
});
}
function containsInvitation(session) {
var i, invitation = null;
if (session !== undefined) {
if ("invitations" in session) {
// user has invitations for this session
for (i = 0; i < session.invitations.length; i++) {
invitation = session.invitations[i];
// session contains an invitation for this user
if (invitation.receiver_id == context.JK.currentUserId) {
return true;
}
}
}
}
return false;
}
function containsFriend(session) {
var i, participant = null;
if (session !== undefined) {
if ("participants" in session) {
for (i = 0; i < session.participants.length; i++) {
participant = session.participants[i];
// this session participant is a friend
if (participant !== null && participant !== undefined && participant.user.is_friend) {
return true;
}
}
}
}
return false;
}
function latencyResponse(sessionId) {
logger.debug("Received latency response for session " + sessionId);
renderSession(sessionId);
}
/**
* Not used normally. Allows modular unit testing
* of the renderSession method without having to do
* as much heavy setup.
*/
function setSession(session) {
invitationSessionGroup[session.id] = session;
}
/**
* Render a single session line into the table.
* It will be inserted at the appropriate place according to the
* sortScore in sessionLatency.
*/
function renderSession(sessionId) {
// store session in the appropriate bucket and increment category counts
var session = sessions[sessionId];
if (containsInvitation(session)) {
invitationSessionGroup[sessionId] = session;
sessionCounts[CATEGORY.INVITATION.index]++;
}
else if (containsFriend(session)) {
friendSessionGroup[sessionId] = session;
sessionCounts[CATEGORY.FRIEND.index]++;
}
else {
otherSessionGroup[sessionId] = session;
sessionCounts[CATEGORY.OTHER.index]++;
}
// hack to prevent duplicate rows from being rendered when filtering
var sessionAlreadyRendered = false;
var $tbGroup;
logger.debug('Rendering session ID = ' + sessionId);
if (invitationSessionGroup[sessionId] != null) {
$tbGroup = $(CATEGORY.INVITATION.id);
if ($("table#sessions-invitations tr[id='" + sessionId + "']").length > 0) {
sessionAlreadyRendered = true;
}
}
else if (friendSessionGroup[sessionId] != null) {
;
$tbGroup = $(CATEGORY.FRIEND.id);
if ($("table#sessions-friends tr[id='" + sessionId + "']").length > 0) {
sessionAlreadyRendered = true;
}
}
else if (otherSessionGroup[sessionId] != null) {
$tbGroup = $(CATEGORY.OTHER.id);
if ($("table#sessions-other tr[id='" + sessionId + "']").length > 0) {
sessionAlreadyRendered = true;
}
}
else {
logger.debug('ERROR: No session with ID = ' + sessionId + ' found.');
return;
}
if (!sessionAlreadyRendered) {
var row = sessionList.renderSession(session, sessionLatency, $tbGroup, $('#template-session-row').html(), $('#template-musician-info').html());
}
refreshDisplay();
}
function beforeShow(data) {
context.JK.GenreSelectorHelper.render('#find-session-genre');
}
function afterShow(data) {
clearResults();
buildQuery();
refreshDisplay();
loadSessions();
}
function clearResults() {
currentPage = 0;
$noMoreSessions.hide();
$scroller.infinitescroll('resume');
$('table#sessions-invitations').children(':not(:first-child)').remove();
$('table#sessions-friends').children(':not(:first-child)').remove();
$('table#sessions-other').children(':not(:first-child)').remove();
sessionCounts = [0, 0, 0];
sessions = {};
invitationSessionGroup = {};
friendSessionGroup = {};
otherSessionGroup = {};
}
function deleteSession(evt) {
var sessionId = $(evt.currentTarget).attr("action-id");
if (sessionId) {
$.ajax({
type: "DELETE",
url: "/api/sessions/" + sessionId,
error: app.ajaxError
}).done(loadSessions);
}
}
function tempDebugStuff() {
if (gon.allow_both_find_algos && context.JK.currentUserAdmin) {
// show extra Refresh button, and distinguish between them
$('#btn-refresh-other').show().click(function() {
clearResults();
buildQuery();
refreshDisplay();
if(gon.use_cached_session_scores) {
loadSessionsOriginal();
}
else {
loadSessionsNew();
}
});
$('#btn-refresh').find('.extra').text(gon.use_cached_session_scores ? ' (new way)' : ' (old way)')
$('#btn-refresh-other').find('.extra').text(gon.use_cached_session_scores ? ' (old way)' : ' (new way)')
}
}
function registerInfiniteScroll() {
if(gon.use_cached_session_scores) {
$scroller.infinitescroll({
behavior: 'local',
navSelector: '#findSession .btn-next-wrapper',
nextSelector: '#findSession .btn-next',
binder: $scroller,
dataType: 'json',
appendCallback: false,
debug: true,
prefill: false,
bufferPx:100,
loading: {
msg: $('<div class="infinite-scroll-loader">Loading ...</div>'),
img: '/assets/shared/spinner.gif'
},
path: function(page) {
return '/api/sessions/nindex/' + app.clientId + '?' + $.param(buildQuery());
}
},function(json, opts) {
// Get current page
//currentPage = opts.state.currPage;
// Do something with JSON data, create DOM elements, etc ..
afterLoadScoredSessions(json);
});
}
}
function events() {
$('#session-keyword-srch').focus(function () {
$(this).val('');
});
$("#session-keyword-srch").keypress(function (evt) {
if (evt.which === 13) {
evt.preventDefault();
search();
}
});
$('#btn-refresh').on("click", search);
tempDebugStuff();
}
/**
* Initialize, providing an instance of the SessionLatency class.
*/
function initialize(latency) {
var screenBindings = {
'beforeShow': beforeShow,
'afterShow': afterShow
};
app.bindScreen('findSession', screenBindings);
if (latency) {
sessionLatency = latency;
}
else {
logger.warn("No sessionLatency provided.");
}
sessionList = new context.JK.SessionList(app);
$next = $('#findSession .btn-next')
$scroller = $('#findSession .content-body-scroller');
$noMoreSessions = $('#end-of-session-list');
events();
}
this.initialize = initialize;
this.renderSession = renderSession;
this.afterShow = afterShow;
// Following exposed for easier testing.
this.setSession = setSession;
this.clearResults = clearResults;
this.getCategoryEnum = getCategoryEnum;
return this;
};
})(window, jQuery);

View File

@ -34,17 +34,17 @@
});
}
function findSessions(queryString) {
function findSessions(query) {
return $.ajax({
type: "GET",
url: "/api/sessions?" + queryString
url: "/api/sessions?" + $.param(query)
});
}
function findScoredSessions(clientId, queryString) {
function findScoredSessions(clientId, query) {
return $.ajax({
type: "GET",
url: "/api/sessions/nindex/" + clientId + "?" + queryString
url: "/api/sessions/nindex/" + clientId + "?" + $.param(query)
});
}

View File

@ -61,7 +61,7 @@
else {
latencyDescription = LATENCY.POOR.description;
latencyStyle = LATENCY.POOR.style;
showJoinLink = false;
//showJoinLink = false;
}
}

View File

@ -1,4 +1,4 @@
div[layout-id="findSession"] {
#findSession {
th, td { margin: 4px; padding:4px; }
@ -11,36 +11,53 @@ div[layout-id="findSession"] {
bottom: 0;
right: 0;
}
}
.session-filter {
width:100%;
padding-top: 11px;
padding-bottom: 11px;
background-color:#4c4c4c;
min-height:20px;
overflow-x:visible;
vertical-align:middle;
}
.content-body-scroller {
overflow:auto !important;
}
.session-filter select {
background-color:#c5c5c5;
border:none;
-webkit-box-shadow: inset 2px 2px 3px 0px #888;
box-shadow: inset 2px 2px 3px 0px #888;
color:#666;
}
.session-filter {
width:100%;
padding-top: 11px;
padding-bottom: 11px;
background-color:#4c4c4c;
min-height:20px;
overflow-x:visible;
vertical-align:middle;
}
#sessions-none-found {
color:#CCCCCC;
display:none;
overflow: none;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
text-align:center;
height:20px;
.session-filter select {
background-color:#c5c5c5;
border:none;
-webkit-box-shadow: inset 2px 2px 3px 0px #888;
box-shadow: inset 2px 2px 3px 0px #888;
color:#666;
}
#sessions-none-found {
color:#CCCCCC;
display:none;
overflow: none;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
text-align:center;
height:20px;
}
#end-of-session-list {
display:none;
overflow: visibility;
margin:40px auto 10px;
width:100%;
height:20px;
text-align:center;
}
.btn-next {
display:none;
}
}

View File

@ -485,6 +485,14 @@ input[type="text"], input[type="password"]{
background-size: 50% 50%;
}
.infinite-scroll-loader {
position:absolute;
overflow:hidden;
height:14px;
text-align: center;
margin:auto;
width:100%;
}
// disable text selection for the in-session panel, ftue, and arbitrary elements marked with .no-selection-range
div[layout-id=session], div[layout-id=ftue], .no-selection-range {

View File

@ -26,6 +26,7 @@ class ClientsController < ApplicationController
gon.isNativeClient = @nativeClient
gon.use_cached_session_scores = Rails.application.config.use_cached_session_scores
gon.allow_both_find_algos = Rails.application.config.allow_both_find_algos
if current_user
render :layout => 'client'

View File

@ -1,5 +1,5 @@
<!-- Find Session Screen -->
<div layout="screen" layout-id="findSession" class="screen secondary">
<div layout="screen" layout-id="findSession" id="findSession" class="screen secondary">
<div class="content">
<div class="content-head">
<div class="content-icon">
@ -27,7 +27,9 @@
<input id="session-keyword-srch" type="text" name="search" placeholder="Search by Keyword" />
</div>
<div class="right mr10">
<a id="btn-refresh" href="/client#/findSession" style="text-decoration:none;" class="button-grey">REFRESH</a>
<!-- can be removed once new find session is stable-->
<a id="btn-refresh-other" href="/client#/findSession" style="display:none;text-decoration:none;" class="button-grey">REFRESH<span class="extra"></span></a>
<a id="btn-refresh" href="/client#/findSession" style="text-decoration:none;" class="button-grey">REFRESH<span class="extra"></span></a>
</div>
</div>
</div>
@ -42,14 +44,18 @@
<div id="sessions-other" class="mt35">
<%= render :partial => "sessionList", :locals => {:title => "other sessions", :category => "sessions-other"} %>
</div>
<span class="btn-next-wrapper"><a href="/api/sessions/nindex/clientid?page=1" class="btn-next">Next</a></span>
</div>
</div>
</form>
<div id="sessions-none-found">
There are currently no public sessions.
</div>
<div id="end-of-session-list">
No more sessions.
</div>
</div>
</div>
</div>
@ -57,7 +63,7 @@
<!-- Session Row Template -->
<script type="text/template" id="template-session-row">
<tr id="{id}" data-sortScore="{sortScore}">
<tr id="{id}" class="found-session" data-sortScore="{sortScore}">
<td width="100">{genres}</td>
<td width="25%">{description}</td>
<td width="20%">

View File

@ -98,11 +98,13 @@
JK.currentUserAvatarUrl = JK.resolveAvatarUrl('<%= current_user.photo_url %>');
JK.currentUserName = '<%= current_user.name %>';
JK.currentUserMusician = '<%= current_user.musician %>';
JK.currentUserAdmin = <%= current_user.admin %>;
<% else %>
JK.currentUserId = null;
JK.currentUserAvatarUrl = null;
JK.currentUserName = null;
JK.currentUserMusician = null;
JK.currentUserAdmin = false;
<% end %>
// Some things can't be initialized until we're connected. Put them here.

View File

@ -107,8 +107,8 @@ if defined?(Bundler)
config.websocket_gateway_connect_time_stale = 2
config.websocket_gateway_connect_time_expire = 5
else
config.websocket_gateway_connect_time_stale = 300
config.websocket_gateway_connect_time_expire = 6000
config.websocket_gateway_connect_time_stale = 12 # 12 matches production
config.websocket_gateway_connect_time_expire = 20 # 20 matches production
end
config.websocket_gateway_internal_debug = false
config.websocket_gateway_port = 6767 + ENV['JAM_INSTANCE'].to_i
@ -216,6 +216,7 @@ if defined?(Bundler)
config.use_promos_on_homepage = false
# should we use the new FindSessions API that has server-side scores
config.use_cached_session_scores = false
config.use_cached_session_scores = true
config.allow_both_find_algos = false
end
end

View File

@ -68,8 +68,8 @@ SampleApp::Application.configure do
# it's nice to have even admin accounts (which all the default ones are) generate GA data for testing
config.ga_suppress_admin = false
config.websocket_gateway_connect_time_stale = 16
config.websocket_gateway_connect_time_expire = 26
config.websocket_gateway_connect_time_stale = 12 # 12 matches production
config.websocket_gateway_connect_time_expire = 20 # 20 matches production
config.audiomixer_path = ENV['AUDIOMIXER_PATH'] || audiomixer_workspace_path || "/var/lib/audiomixer/audiomixer/audiomixerapp"
@ -79,5 +79,6 @@ SampleApp::Application.configure do
# set CREATE_SESSION_AGREEMENT=0 if you don't want the autoclick behavior
config.autocheck_create_session_agreement = ENV['CREATE_SESSION_AGREEMENT'] ? ENV['CREATE_SESSION_AGREEMENT'] == "1" : true
config.send_join_session_email_notifications = false
config.send_join_session_email_notifications = true
end

View File

@ -68,6 +68,6 @@ SampleApp::Application.configure do
config.use_promos_on_homepage = false
config.use_cached_session_scores = false
config.use_cached_session_scores = true
end

View File

@ -9,13 +9,10 @@ if Rails.env == "development" && Rails.application.config.bootstrap_dev_users
User.create_dev_user("Peter", "Walker", "peter@jamkazam.com", "jam123", "Austin", "TX", "US", nil, 'http://www.jamkazam.com/assets/avatars/avatar_peter.jpg')
User.create_dev_user("Peter", "Walker", "peter2@jamkazam.com", "jam123", "Austin", "TX", "US", nil, 'http://www.jamkazam.com/assets/avatars/avatar_peter.jpg')
User.create_dev_user("David", "Wilson", "david@jamkazam.com", "jam123", "Austin", "TX", "US", nil, 'http://www.jamkazam.com/assets/avatars/avatar_david.jpg')
User.create_dev_user("Jonathon", "Wilson", "jonathon@jamkazam.com", "jam123", "Bozeman", "MT", "US", [{:instrument_id => "keyboard", :proficiency_level => 4, :priority => 1}], 'http://www.jamkazam.com/assets/avatars/avatar_jonathon.jpg')
User.create_dev_user("Jonathan", "Kolyer", "jonathan@jamkazam.com", "jam123", "Austin", "TX", "US", nil, nil)
User.create_dev_user("Oswald", "Becca", "os@jamkazam.com", "jam123", "Austin", "TX", "US", nil, nil)
User.create_dev_user("Anthony", "Davis", "anthony@jamkazam.com", "jam123", "Austin", "TX", "US", nil, nil)
User.create_dev_user("George", "Currie", "george@jamkazam.com", "jam123", "Austin", "TX", "US", nil, nil)
User.create_dev_user("Chris", "Doughty", "chris@jamkazam.com", "jam123", "Austin", "TX", "US", nil, nil)
User.create_dev_user("Daniel", "Weigh", "daniel@jamkazam.com", "jam123", "Austin", "TX", "US", nil, nil)
end

View File

@ -1,6 +1,6 @@
require 'spec_helper'
describe "Find Session", :js => true, :type => :feature, :capybara_feature => true do
describe "Find Session", :js => true, :type => :feature, :capybara_feature => true, :slow => true do
subject { page }
@ -15,22 +15,54 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
before(:each) do
UserMailer.deliveries.clear
MusicSession.delete_all
sign_in_poltergeist user
visit "/client#/findSession"
end
# when no sessions have been created:
it "shows there are no sessions" do
MusicSession.delete_all
sign_in_poltergeist user
visit "/client#/findSession"
# verify no sessions are found
expect(page).to have_selector('#sessions-none-found')
end
it "finds another public session", :slow => true do
it "finds another public session" do
create_join_session(user, [finder])
end
describe "listing behavior" do
describe "one slush session" do
before do
@session1 = FactoryGirl.create(:single_user_session)
end
it "find general population user" do
find('#btn-refresh').trigger(:click)
sleep 1
find('div#sessions-other')
page.all('div#sessions-other .found-session').count.should == 1
end
describe "tons of slush sessions" do
before do
20.times do
FactoryGirl.create(:single_user_session)
end
end
it "find many general users" do
find('#btn-refresh').trigger(:click)
sleep 1
find('div#sessions-other')
page.all('div#sessions-other .found-session').count.should == 20
# attempt to scroll down--the end of session list should show, and there should now be 21 items
page.execute_script('jQuery("#findSession .content-body-scroller").scrollTo("100%",100)') #scroll to the bottom of the element
find('#end-of-session-list')
page.all('div#sessions-other .found-session').count.should == 21
end
end
end
end
end

File diff suppressed because one or more lines are too long