Initial commit
This commit is contained in:
0
app/assets/javascripts/channels/.keep
Normal file
0
app/assets/javascripts/channels/.keep
Normal file
45
app/assets/javascripts/channels/broadcasts.coffee
Normal file
45
app/assets/javascripts/channels/broadcasts.coffee
Normal file
@@ -0,0 +1,45 @@
|
||||
$(document).on "turbolinks:load", ->
|
||||
# Only connect if a broadcast-token meta tag is present
|
||||
broadcast_meta = document.querySelector("meta[name=broadcast-token]")
|
||||
return unless broadcast_meta
|
||||
|
||||
broadcastToken = broadcast_meta.getAttribute("content")
|
||||
|
||||
App.public = App.cable.subscriptions.create { channel: "BroadcastsChannel", token: broadcastToken },
|
||||
connected: ->
|
||||
# Called when the subscription is ready for use on the server
|
||||
|
||||
disconnected: ->
|
||||
# Called when the subscription has been terminated by the server
|
||||
|
||||
received: (data) ->
|
||||
return unless document.querySelector("meta[name=broadcast-token][content='#{broadcastToken}']")
|
||||
switch data.event
|
||||
when "broadcast_stream_update" then @refreshBroadcastVideo(data)
|
||||
when "stream_recording_ready" then @showBroadcastRecordings(data)
|
||||
when "file_upload_update" then @refreshFilesTab(data)
|
||||
|
||||
refreshBroadcastVideo: (data) ->
|
||||
$("#broadcast_updates").html data.status_content
|
||||
if data.streamer_status == 'recording' && data.status == 'active'
|
||||
$("#broadcast_video").html data.video_content
|
||||
new (Clappr.Player)(
|
||||
parentId: '#broadcast_video'
|
||||
source: data.playback_url
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
mute: true,
|
||||
autoPlay: true,
|
||||
hlsMinimumDvrSize: 1)
|
||||
if data.streamer_status == "idle" && data.status == "idle"
|
||||
$("#broadcast_video").html data.video_content
|
||||
|
||||
showBroadcastRecordings: (data) ->
|
||||
$(".flash-message").html data.flash_content
|
||||
$("#broadcast_recordings").html data.recordings_content
|
||||
$("#broadcast_recordings_nav").html data.recordings_nav_content
|
||||
|
||||
refreshFilesTab: (data) ->
|
||||
$("#broadcast_file_list").html data.files_content
|
||||
$("#broadcast_files_pagination").html data.pagination_content
|
||||
|
||||
25
app/assets/javascripts/channels/projects.coffee
Normal file
25
app/assets/javascripts/channels/projects.coffee
Normal file
@@ -0,0 +1,25 @@
|
||||
# TODO: Need to unsubscribe as project changes
|
||||
$(document).on "turbolinks:load", ->
|
||||
# Only connect if a project-id meta tag is present
|
||||
return unless meta = document.querySelector("meta[name=project-id]")
|
||||
# Get the id of the project to subscribe to
|
||||
projectId = meta.getAttribute("content")
|
||||
|
||||
App.projects = App.cable.subscriptions.create { channel: "ProjectsChannel", id: projectId },
|
||||
connected: ->
|
||||
# Called when the subscription is ready for use on the server
|
||||
|
||||
disconnected: ->
|
||||
# Called when the subscription has been terminated by the server
|
||||
|
||||
received: (data) ->
|
||||
switch data.event
|
||||
when "video_status_update" then @showVideoStatusUpdate(data.content)
|
||||
when "download_status_update" then @showDownloadStatusUpdate(data.content)
|
||||
when "conference_recording_ready" then @showDownloadStatusUpdate(data.content)
|
||||
|
||||
showVideoStatusUpdate: (content) ->
|
||||
$("[data-ujs-target='video-analysis-msg']").replaceWith content
|
||||
|
||||
showDownloadStatusUpdate: (content) ->
|
||||
$(".flash-message").html content
|
||||
Reference in New Issue
Block a user