VRFS-1669 find session work
This commit is contained in:
parent
178bd52cd4
commit
73ba842c6a
|
|
@ -92,14 +92,23 @@
|
|||
// genre filter
|
||||
var genres = context.JK.GenreSelectorHelper.getSelectedGenres('#find-session-genre');
|
||||
if (genres !== null && genres.length > 0) {
|
||||
currentQuery.genres = genres.join(',');
|
||||
currentQuery.genre = genres.join(',');
|
||||
}
|
||||
|
||||
// date filter
|
||||
|
||||
var date = $('#session-date-filter').val();
|
||||
if (date !== null && date.length > 0) {
|
||||
console.log(date);
|
||||
currentQuery.day = context.JK.formatDateYYYYMMDD(date);
|
||||
// console.log("currentQuery.day=%o", currentQuery.day);
|
||||
currentQuery.timezone_offset = new Date().getTimezoneOffset();
|
||||
}
|
||||
|
||||
// language filter
|
||||
|
||||
var language = $('#session-language-filter').val();
|
||||
if (language !== null && language.length > 0) {
|
||||
currentQuery.lang = language;
|
||||
}
|
||||
|
||||
// keyword filter
|
||||
var keyword = $('#session-keyword-srch').val();
|
||||
|
|
@ -110,6 +119,8 @@
|
|||
// always set client ID (required on server)
|
||||
currentQuery.client_id = context.JK.clientId;
|
||||
|
||||
console.log("currentQuery = %o", currentQuery);
|
||||
|
||||
return currentQuery;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,10 +17,6 @@
|
|||
var showJoinLink = true;
|
||||
var showRsvpLink = true;
|
||||
|
||||
var totalLatency = 0.0;
|
||||
var latencyUsers = 0;
|
||||
var averageLatency = 0.0;
|
||||
|
||||
var LATENCY = {
|
||||
GOOD : {description: "GOOD", style: "latency-green", min: 0.0, max: 20.0},
|
||||
MEDIUM : {description: "MEDIUM", style: "latency-yellow", min: 20.0, max: 40.0},
|
||||
|
|
@ -33,10 +29,6 @@
|
|||
|
||||
function renderActiveSession(session, tbGroup) {
|
||||
|
||||
totalLatency = 0.0;
|
||||
latencyUsers = 0;
|
||||
averageLatency = 0.0;
|
||||
|
||||
$('#actionHeader', tbGroup).html('JOIN');
|
||||
|
||||
var i = 0;
|
||||
|
|
@ -46,6 +38,8 @@
|
|||
// "RSVPs" section
|
||||
var inSessionUsers = [];
|
||||
|
||||
showJoinLink = session.musician_access;
|
||||
|
||||
// render musicians who are already in the session
|
||||
if (session.active_music_session && "participants" in session.active_music_session) {
|
||||
for (i=0; i < session.active_music_session.participants.length; i++) {
|
||||
|
|
@ -60,6 +54,9 @@
|
|||
if (session.approved_rsvps) {
|
||||
for (i=0; i < session.approved_rsvps.length; i++) {
|
||||
if (!(session.approved_rsvps[i].id in inSessionUsers)) {
|
||||
if (session.approved_rsvps[i].id === context.JK.currentUserId) {
|
||||
showJoinLink = true;
|
||||
}
|
||||
var rsvpUserInfo = createRsvpUser(session.approved_rsvps[i], session);
|
||||
rsvpUsersHtml += rsvpUserInfo[0];
|
||||
latencyHtml += rsvpUserInfo[1];
|
||||
|
|
@ -74,9 +71,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
// use this to determine where to insert row
|
||||
averageLatency = totalLatency / latencyUsers;
|
||||
console.log("average latency = %o", averageLatency);
|
||||
// notation files
|
||||
if (session.music_notations) {
|
||||
for (i=0; i < session.music_notations.length; i++) {
|
||||
notationFileHtml += createNotationFile(session.music_notations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var sessionVals = buildSessionObject(session, notationFileHtml, rsvpUsersHtml, openSlotsHtml, latencyHtml);
|
||||
sessionVals.in_session_musicians = inSessionUsersHtml.length > 0 ? inSessionUsersHtml : 'N/A';
|
||||
|
|
@ -85,35 +85,30 @@
|
|||
var row = context.JK.fillTemplate($activeSessionTemplate.html(), sessionVals);
|
||||
$(tbGroup).append(row);
|
||||
|
||||
// TODO: find appropriate place to insert row based on sorting algorithm
|
||||
if (showJoinLink) {
|
||||
// wire up the Join Link to the T&Cs dialog
|
||||
var $parentRow = $('tr[id=' + session.id + ']', tbGroup);
|
||||
$('.join-link', $parentRow).click(function(evt) {
|
||||
if (!context.JK.JamServer.connected) {
|
||||
app.notifyAlert("Not Connected", 'To create or join a session, you must be connected to the server.');
|
||||
return false;
|
||||
}
|
||||
// If no FTUE, show that first.
|
||||
if (!context.JK.hasOneConfiguredDevice() || context.JK.TrackHelpers.getUserTracks(context.jamClient).length == 0) {
|
||||
app.afterFtue = function() { joinClick(session.id); };
|
||||
app.layout.startNewFtue();
|
||||
}
|
||||
else {
|
||||
joinClick(session.id);
|
||||
}
|
||||
|
||||
// wire up the Join Link to the T&Cs dialog
|
||||
var $parentRow = $('tr[id=' + session.id + ']', tbGroup);
|
||||
|
||||
$('.join-link', $parentRow).click(function(evt) {
|
||||
if (!context.JK.JamServer.connected) {
|
||||
app.notifyAlert("Not Connected", 'To create or join a session, you must be connected to the server.');
|
||||
return false;
|
||||
}
|
||||
// If no FTUE, show that first.
|
||||
if (!context.JK.hasOneConfiguredDevice() || context.JK.TrackHelpers.getUserTracks(context.jamClient).length == 0) {
|
||||
app.afterFtue = function() { joinClick(session.id); };
|
||||
app.layout.startNewFtue();
|
||||
}
|
||||
else {
|
||||
joinClick(session.id);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function renderInactiveSession(session, tbGroup) {
|
||||
|
||||
totalLatency = 0.0;
|
||||
latencyUsers = 0;
|
||||
averageLatency = 0.0;
|
||||
|
||||
var openSlots = false;
|
||||
var hasInvitation = false;
|
||||
var hasApprovedRsvp = false;
|
||||
|
|
@ -149,17 +144,13 @@
|
|||
// render pending invitations
|
||||
if (session.pending_invitations) {
|
||||
for (i=0; i < session.pending_invitations.length; i++) {
|
||||
if (session.pending_invitations[i] === context.JK.currentUserId) {
|
||||
if (session.pending_invitations[i].id === context.JK.currentUserId) {
|
||||
hasInvitation = true;
|
||||
}
|
||||
pendingInvitationsHtml += createPendingInvitation(session.pending_invitations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// use this to determine where to insert row
|
||||
averageLatency = totalLatency / latencyUsers;
|
||||
console.log("average latency = %o", averageLatency);
|
||||
|
||||
if ( (openRsvps || hasInvitation) && openSlots && !hasApprovedRsvp && !currentUserHasRsvp ) {
|
||||
showRsvpLink = true;
|
||||
}
|
||||
|
|
@ -167,6 +158,13 @@
|
|||
showRsvpLink = false;
|
||||
}
|
||||
|
||||
// notation files
|
||||
if (session.music_notations) {
|
||||
for (i=0; i < session.music_notations.length; i++) {
|
||||
notationFileHtml += createNotationFile(session.music_notations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var sessionVals = buildSessionObject(session, notationFileHtml, rsvpUsersHtml, openSlotsHtml, latencyHtml);
|
||||
sessionVals.pending_invitations = pendingInvitationsHtml.length > 0 ? pendingInvitationsHtml : 'N/A';
|
||||
sessionVals.rsvp_link_display_style = showRsvpLink ? "block" : "none";
|
||||
|
|
@ -188,7 +186,6 @@
|
|||
function buildSessionObject(session, notationFileHtml, rsvpUsersHtml, openSlotsHtml, latencyHtml) {
|
||||
return {
|
||||
id: session.id,
|
||||
averageLatency: averageLatency,
|
||||
name: session.name,
|
||||
description: session.description || "(No description)",
|
||||
notation_files: notationFileHtml.length > 0 ? notationFileHtml : 'N/A',
|
||||
|
|
@ -229,9 +226,7 @@
|
|||
};
|
||||
|
||||
var musicianHtml = context.JK.fillTemplate($musicianTemplate.html(), musicianVals);
|
||||
var latencyHtml = context.JK.fillTemplate($latencyTemplate.html(), createLatencyHtml(participant.user.latency));
|
||||
|
||||
latencyUsers++;
|
||||
var latencyHtml = context.JK.fillTemplate($latencyTemplate.html(), createLatency(participant.user));
|
||||
|
||||
return [musicianHtml, latencyHtml];
|
||||
}
|
||||
|
|
@ -265,34 +260,41 @@
|
|||
};
|
||||
|
||||
var musicianHtml = context.JK.fillTemplate($musicianTemplate.html(), musicianVals);
|
||||
var latencyHtml = context.JK.fillTemplate($latencyTemplate.html(), createLatencyHtml(user.latency));
|
||||
|
||||
latencyUsers++;
|
||||
var latencyHtml = context.JK.fillTemplate($latencyTemplate.html(), createLatency(user));
|
||||
|
||||
return [musicianHtml, latencyHtml];
|
||||
}
|
||||
|
||||
function createLatencyHtml(latency) {
|
||||
function createLatency(user) {
|
||||
var latencyStyle = LATENCY.UNREACHABLE.style, latencyDescription = LATENCY.UNREACHABLE.description
|
||||
|
||||
if (!latency || latency === 1000) {
|
||||
// 1000 is a magical number returned by new scoring API to indicate one or more people in the session have an unknown score
|
||||
latencyDescription = LATENCY.UNKNOWN.description;
|
||||
latencyStyle = LATENCY.UNKNOWN.style;
|
||||
if (user.id === context.JK.currentUserId) {
|
||||
latencyStyle = LATENCY.GOOD.style, latencyDescription = LATENCY.GOOD.description;
|
||||
}
|
||||
|
||||
else {
|
||||
totalLatency += latency;
|
||||
if (latency <= LATENCY.GOOD.max) {
|
||||
latencyDescription = LATENCY.GOOD.description;
|
||||
latencyStyle = LATENCY.GOOD.style;
|
||||
}
|
||||
else if (latency > LATENCY.MEDIUM.min && latency <= LATENCY.MEDIUM.max) {
|
||||
latencyDescription = LATENCY.MEDIUM.description;
|
||||
latencyStyle = LATENCY.MEDIUM.style;
|
||||
var latency = user.latency;
|
||||
console.log("latency = %o", latency);
|
||||
|
||||
if (!latency || latency === 1000) {
|
||||
// 1000 is a magical number returned by new scoring API to indicate one or more people in the session have an unknown score
|
||||
latencyDescription = LATENCY.UNKNOWN.description;
|
||||
latencyStyle = LATENCY.UNKNOWN.style;
|
||||
}
|
||||
else {
|
||||
latencyDescription = LATENCY.POOR.description;
|
||||
latencyStyle = LATENCY.POOR.style;
|
||||
latencyUsers++;
|
||||
totalLatency += latency;
|
||||
if (latency <= LATENCY.GOOD.max) {
|
||||
latencyDescription = LATENCY.GOOD.description;
|
||||
latencyStyle = LATENCY.GOOD.style;
|
||||
}
|
||||
else if (latency > LATENCY.MEDIUM.min && latency <= LATENCY.MEDIUM.max) {
|
||||
latencyDescription = LATENCY.MEDIUM.description;
|
||||
latencyStyle = LATENCY.MEDIUM.style;
|
||||
}
|
||||
else {
|
||||
latencyDescription = LATENCY.POOR.description;
|
||||
latencyStyle = LATENCY.POOR.style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -326,6 +328,15 @@
|
|||
return context.JK.fillTemplate($pendingInvitationsTemplate.html(), invitationVals);
|
||||
}
|
||||
|
||||
function createNotationFile(notation) {
|
||||
var notationVals = {
|
||||
file_url: notation.file_url,
|
||||
file_name: notation.file_name
|
||||
};
|
||||
|
||||
return context.JK.fillTemplate($notationFileTemplate.html(), notationVals);
|
||||
}
|
||||
|
||||
function joinClick(sessionId) {
|
||||
var hasInvitation = false;
|
||||
var session = null;
|
||||
|
|
|
|||
|
|
@ -507,10 +507,14 @@
|
|||
// returns Fri May 20, 2013
|
||||
context.JK.formatDate = function (dateString) {
|
||||
var date = new Date(dateString);
|
||||
|
||||
return days[date.getDay()] + ' ' + months[date.getMonth()] + ' ' + context.JK.padString(date.getDate(), 2) + ', ' + date.getFullYear();
|
||||
}
|
||||
|
||||
context.JK.formatDateYYYYMMDD = function(dateString) {
|
||||
var date = new Date(dateString);
|
||||
return date.getFullYear() + '-' + context.JK.padString((date.getMonth() + 1).toString(), 2) + '-' + context.JK.padString(date.getDate(), 2);
|
||||
}
|
||||
|
||||
context.JK.formatTime = function (dateString) {
|
||||
var date = new Date(dateString);
|
||||
return date.toLocaleTimeString();
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ table.findsession-table, table.local-recordings {
|
|||
white-space:normal;
|
||||
}
|
||||
|
||||
td.latency {
|
||||
text-align:center !important;
|
||||
}
|
||||
|
||||
.noborder {
|
||||
border-right:none;
|
||||
}
|
||||
|
|
@ -60,7 +64,6 @@ table.findsession-table, table.local-recordings {
|
|||
font-family:Arial, Helvetica, sans-serif;
|
||||
font-weight:200;
|
||||
font-size:11px;
|
||||
text-align:center;
|
||||
background-color:#868686;
|
||||
}
|
||||
|
||||
|
|
@ -70,10 +73,7 @@ table.findsession-table, table.local-recordings {
|
|||
font-family:Arial, Helvetica, sans-serif;
|
||||
font-weight:200;
|
||||
font-size:11px;
|
||||
text-align:center;
|
||||
background-color:#72a43b;
|
||||
display:inline-block;
|
||||
margin:auto;
|
||||
background-color:#71a43b;
|
||||
}
|
||||
|
||||
.latency-yellow {
|
||||
|
|
@ -82,7 +82,6 @@ table.findsession-table, table.local-recordings {
|
|||
font-family:Arial, Helvetica, sans-serif;
|
||||
font-weight:200;
|
||||
font-size:11px;
|
||||
text-align:center;
|
||||
background-color:#cc9900;
|
||||
}
|
||||
|
||||
|
|
@ -92,9 +91,7 @@ table.findsession-table, table.local-recordings {
|
|||
font-family:Arial, Helvetica, sans-serif;
|
||||
font-weight:200;
|
||||
font-size:11px;
|
||||
text-align:center !important;
|
||||
background-color:#980006;
|
||||
margin-top:15px;
|
||||
}
|
||||
|
||||
.avatar-tiny {
|
||||
|
|
|
|||
|
|
@ -68,10 +68,11 @@ else
|
|||
}
|
||||
|
||||
child(:music_notations => :music_notations) {
|
||||
node do |music_notation|
|
||||
attributes :id, :file_name, :file_url
|
||||
# note(:filename) { |music_notation| music_notation.filename }
|
||||
end
|
||||
attributes :id, :file_name
|
||||
|
||||
node do |music_notation|
|
||||
{ file_url: music_notation["file_url"] }
|
||||
end
|
||||
}
|
||||
|
||||
child({:invitations => :invitations}) {
|
||||
|
|
|
|||
|
|
@ -77,9 +77,9 @@
|
|||
|
||||
<!-- active session template -->
|
||||
<script type="text/template" id="template-active-session-row">
|
||||
<tr id="{id}" class="found-session" avg-latency="{averageLatency}">
|
||||
<tr id="{id}" class="found-session">
|
||||
<td width="30%">
|
||||
<table class="musicians" cellpadding="0" cellspacing="0" width="100%">
|
||||
<table class="musician-groups" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td>{name}</td>
|
||||
<td align="right" width="75">({genres})</td>
|
||||
|
|
@ -88,7 +88,7 @@
|
|||
<td colspan="2">{description}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Notation Files:</td>
|
||||
<td colspan="2">Notation Files:</td>
|
||||
<td>{notation_files}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
@ -148,9 +148,9 @@
|
|||
|
||||
<!-- inactive session template -->
|
||||
<script type="text/template" id="template-inactive-session-row">
|
||||
<tr id="{id}" class="found-session" avg-latency="{averageLatency}">
|
||||
<tr id="{id}" class="found-session">
|
||||
<td width="30%">
|
||||
<table class="musicians" cellpadding="0" cellspacing="0" width="100%">
|
||||
<table class="musician-groups" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td>{name}</td>
|
||||
<td align="right" width="75">({genres})</td>
|
||||
|
|
@ -219,7 +219,7 @@
|
|||
</script>
|
||||
|
||||
<script type="text/template" id="template-notation-files">
|
||||
<a href="{file_url}" rel="external">{file_name}</a>
|
||||
<a href="{file_url}" rel="external">{file_name}</a><br />
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="template-musician-info">
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@
|
|||
All slots are taken
|
||||
- else
|
||||
- @open_slots.each do |slot|
|
||||
.clearall.left.w65.h20.ib.mb10
|
||||
.clearall.left.w100.h20.ib.mb10
|
||||
.ib.h20
|
||||
%img.instrument-icon{'instrument-id' => slot.instrument_id, height:24, width:24}
|
||||
.f11.ml10.ib.h20
|
||||
|
|
|
|||
Loading…
Reference in New Issue