diff --git a/web/app/assets/javascripts/react-components/FindSessionRow.js.jsx.coffee b/web/app/assets/javascripts/react-components/FindSessionRow.js.jsx.coffee index 13d4c4942..53bc1cc48 100644 --- a/web/app/assets/javascripts/react-components/FindSessionRow.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/FindSessionRow.js.jsx.coffee @@ -14,7 +14,7 @@ SessionUtils = context.JK.SessionUtils ui: null getInitialState: () -> - { rsvpToggle: false, openSlotToggle: false, userLatencies: [] } + { rsvpToggle: false, openSlotToggle: false, userLatencies: [], userLatenciesFailed: [] } createInstrument: (participant) -> @@ -29,26 +29,29 @@ SessionUtils = context.JK.SessionUtils instruments - createLatencyBadge: (participant) -> + createLatencyBadge: (userId) -> + logger.debug(">>>PARTICIPANT", userId) logger.debug(">>>userLatencies", @state.userLatencies) - latency = @state.userLatencies.find((latency) -> - latency.user_id == participant.id; + logger.debug(">>>userLatenciesFailed", @state.userLatenciesFailed) + latency = @state.userLatencies.find((userLatency) -> + userLatency.user_id == userId + ) + failed = @state.userLatenciesFailed.find((failedId) -> + failedId == userId ) - # latencyData = SessionUtils.changeLatencyDataStructure(latency) - # data = $.extend(latencyData, SessionUtils.createLatency(latencyData)) - # latency_text = data.latency_text - # latency_style = data.latency_text - `{latency_text}` + logger.debug(">>>latencies=====>>>>", latency) + logger.debug(">>>Failed=======>>>>>", failed) + `` createInSessionUser: (participant) -> instruments = @createInstrument(participant) - latencyBadge = @createLatencyBadge(participant) + latencyBadge = @createLatencyBadge(participant.user.id) - `` + `` createOpenSlot:(slot, isLast) -> @@ -115,9 +118,9 @@ SessionUtils = context.JK.SessionUtils moreLinkHtml = `{text}` - latencyBadge = @createLatencyBadge(user) + latencyBadge = @createLatencyBadge(user.id) - `` + `` inSessionUsersHtml: (session) -> inSessionUsers = [] @@ -410,8 +413,11 @@ SessionUtils = context.JK.SessionUtils createListenLink: () -> null - onLatencyUpdate: (userLatencies) -> - @setState(userLatencies: userLatencies) + onLatencyUpdate: (latencyResp) -> + if latencyResp.users + @setState(userLatencies: latencyResp.users) + else if latencyResp.user_ids + @setState(userLatenciesFailed: latencyResp.user_ids) render: () -> diff --git a/web/app/assets/javascripts/react-components/HoverUser.js.jsx.coffee b/web/app/assets/javascripts/react-components/HoverUser.js.jsx.coffee index 04a858e70..8238a19d7 100644 --- a/web/app/assets/javascripts/react-components/HoverUser.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/HoverUser.js.jsx.coffee @@ -11,7 +11,7 @@ MAX_MINUTES_SHOW_START = 15 render: () -> user = this.props.user - + latencyBadge = this.props.latencyBadge userId = user.id name = user.name avatar_url = context.JK.resolveAvatarUrl(user.photo_url) @@ -31,7 +31,7 @@ MAX_MINUTES_SHOW_START = 15
{this.props.instruments}
-
GOOD
+
{latencyBadge}
{this.props.more} ` diff --git a/web/app/assets/javascripts/react-components/LatencyBadge.js.jsx.coffee b/web/app/assets/javascripts/react-components/LatencyBadge.js.jsx.coffee new file mode 100644 index 000000000..337eb4007 --- /dev/null +++ b/web/app/assets/javascripts/react-components/LatencyBadge.js.jsx.coffee @@ -0,0 +1,78 @@ +LATENCY = { + ME : {description: "ME", style: "latency-me", min: -1, max: -1}, + GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0}, + MEDIUM : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0}, + POOR : {description: "POOR", style: "latency-poor", min: 70.0, max: 100}, + UNACCEPTABLE: {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100, max: 10000000}, + UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2}, + FAILED: {description: "FAILED", style: "latency-failed", min: -3, max: -3} + } + +@LatencyBadge = React.createClass({ + + render: () -> + latencyDescription = @props.failed + + # if @props.latency + # latency = @props.latency + # full_score = latency.ars.total_latency + # internet_score = parseInt(latency.internet_score); + # audio_latency = parseInt(latency.audio_latency); + + # latencyDescription = "XXXX" + # latencyStyle = "" + # iconName = "" + # description = "" + # latencyDetails = "" + + # # if !full_score || full_score <= LATENCY.UNKNOWN.max + # # latencyDescription = LATENCY.UNKNOWN.description + # # latencyStyle = LATENCY.UNKNOWN.style + # # iconName = "purple" + # # description = "missing" + # # latencyDetails = "" + # # else if full_score <= LATENCY.GOOD.max + # # latencyDescription = LATENCY.GOOD.description + # # latencyStyle = LATENCY.GOOD.style; + # # iconName = "green" + # # description = "good" + # # latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms" + # # else if full_score <= LATENCY.MEDIUM.max + # # latencyDescription = LATENCY.MEDIUM.description + # # latencyStyle = LATENCY.MEDIUM.style + # # iconName = "yellow" + # # description = "fair" + # # latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms" + # # else if full_score <= LATENCY.POOR.max + # # latencyDescription = LATENCY.POOR.description + # # latencyStyle = LATENCY.POOR.style + # # iconName = "red" + # # description = "poor" + # # latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms" + # # else if full_score > LATENCY.UNACCEPTABLE.min + # # latencyDescription = LATENCY.UNACCEPTABLE.description + # # latencyStyle = LATENCY.UNACCEPTABLE.style + # # iconName = "blue" + # # description = "unacceptable" + # # latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms" + + # else if @props.failed + # latencyDescription = LATENCY.FAILED.description + # latencyStyle = LATENCY.FAILED.style + # iconName = "gray" + # description = "failed" + # latencyDetails = "" + # else + # latencyDescription = @props + + # { + # latency_style: latencyStyle, + # latency_text: latencyDescription, + # icon_name: iconName, + # description: description, + # latency_details: latencyDetails + # } + + `{latencyDescription}` + +}) \ No newline at end of file diff --git a/web/spec/features/find_sessions_latency_badge_spec.rb b/web/spec/features/find_sessions_latency_badge_spec.rb index 8b9b9c40f..ae26455a9 100644 --- a/web/spec/features/find_sessions_latency_badge_spec.rb +++ b/web/spec/features/find_sessions_latency_badge_spec.rb @@ -63,8 +63,6 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur ) .to_return( body: creator_response_body, status: 200) - - fast_signin(finder_user, "/client#/findSession") wait_until_curtain_gone @@ -72,9 +70,12 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur find("a", text: "Open Jams").click expect(page).to have_selector("#sessions-active .found-session table.musicians-category tr", count: 2) - expect(page).to have_selector("div.latency-badge[data-user-id=\"#{creator_user.id}\"]", text: "GOOD") + #expect(page).to have_selector("div.latency-badge[data-user-id=\"#{creator_user.id}\"]", text: "GOOD") #expect(page).to have_selector("div.latency-badge[data-user-id=\"#{joiner_user.id}\"]", text: "GOOD") + + save_screenshot("find_session_latency.png") + # selector = "#sessions-active a[data-user-id=\"#{creator_user.id}\"][data-hoveraction=\"musician\"]" # find(selector, text: creator_user.name).hover_intent # find('h3', text: creator_user.name) @@ -91,6 +92,28 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur end end + xit "show FAIR" do + in_client(finder_user) do + creator_response_body = mock_latency_response([{ user: creator_user, ars_total_latency: 41.0, ars_internet_latency: 21.0, audio_latency: 20.0 }]) + + stub_request(:post, latency_data_uri) + .with( + :headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'} + ) + .to_return( body: creator_response_body, status: 200) + + fast_signin(finder_user, "/client#/findSession") + wait_until_curtain_gone + find("h1", text: "find a session") + find("a", text: "Open Jams").click + expect(page).to have_selector("#sessions-active .found-session table.musicians-category tr", count: 2) + + expect(page).to have_selector("div.latency-badge[data-user-id=\"#{creator_user.id}\"]", text: "FAIR") + #expect(page).to have_selector("div.latency-badge[data-user-id=\"#{joiner_user.id}\"]", text: "GOOD") + + end + end + end end \ No newline at end of file