diff --git a/web/app/assets/javascripts/findSession.js b/web/app/assets/javascripts/findSession.js index 0eac9a7f0..d9ab23f3c 100644 --- a/web/app/assets/javascripts/findSession.js +++ b/web/app/assets/javascripts/findSession.js @@ -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; } diff --git a/web/app/assets/javascripts/sessionList.js b/web/app/assets/javascripts/sessionList.js index daec9824f..c02313117 100644 --- a/web/app/assets/javascripts/sessionList.js +++ b/web/app/assets/javascripts/sessionList.js @@ -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; diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js index 31ecbde41..586186111 100644 --- a/web/app/assets/javascripts/utils.js +++ b/web/app/assets/javascripts/utils.js @@ -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(); diff --git a/web/app/assets/stylesheets/client/sessionList.css.scss b/web/app/assets/stylesheets/client/sessionList.css.scss index 8ef59d363..db441a3ae 100644 --- a/web/app/assets/stylesheets/client/sessionList.css.scss +++ b/web/app/assets/stylesheets/client/sessionList.css.scss @@ -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 { diff --git a/web/app/views/api_music_sessions/show_history.rabl b/web/app/views/api_music_sessions/show_history.rabl index 9c721c72e..1472378cb 100644 --- a/web/app/views/api_music_sessions/show_history.rabl +++ b/web/app/views/api_music_sessions/show_history.rabl @@ -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}) { diff --git a/web/app/views/clients/_findSession.html.erb b/web/app/views/clients/_findSession.html.erb index 117e6f38d..62da6956b 100644 --- a/web/app/views/clients/_findSession.html.erb +++ b/web/app/views/clients/_findSession.html.erb @@ -77,9 +77,9 @@