forked from External/greenlight
		
	Merge pull request #22 from zach-chai/recording_previews
recording previews
This commit is contained in:
		@@ -88,16 +88,30 @@
 | 
			
		||||
      },
 | 
			
		||||
      columns: [
 | 
			
		||||
        { title: "Date Recorded", data: "start_time" },
 | 
			
		||||
        { title: "Presentation", data: "previews"},
 | 
			
		||||
        { title: "Duration", data: "duration" },
 | 
			
		||||
        { title: "Views", data: "playbacks" },
 | 
			
		||||
        { title: "Actions", data: "id" }
 | 
			
		||||
      ],
 | 
			
		||||
      columnDefs: [
 | 
			
		||||
        {
 | 
			
		||||
          targets: 2,
 | 
			
		||||
          targets: 1,
 | 
			
		||||
          render: function(data, type, row) {
 | 
			
		||||
            if (type === 'display') {
 | 
			
		||||
              var str = "";
 | 
			
		||||
              var str = '';
 | 
			
		||||
              for(let i in data) {
 | 
			
		||||
                str += '<img height="50" width="50" src="'+data[i].url+'" alt="'+data[i].alt+'"></img> ';
 | 
			
		||||
              }
 | 
			
		||||
              return str;
 | 
			
		||||
            }
 | 
			
		||||
            return data;
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          targets: 3,
 | 
			
		||||
          render: function(data, type, row) {
 | 
			
		||||
            if (type === 'display') {
 | 
			
		||||
              var str = '';
 | 
			
		||||
              if (row.published) {
 | 
			
		||||
                for(let i in data) {
 | 
			
		||||
                  str += '<a href="'+data[i].url+'">'+data[i].type+'</a> ';
 | 
			
		||||
 
 | 
			
		||||
@@ -75,7 +75,53 @@ module BbbApi
 | 
			
		||||
    if meeting_id
 | 
			
		||||
      options[:meetingID] = (Digest::SHA1.hexdigest(Rails.application.secrets[:secret_key_base]+meeting_id)).to_s
 | 
			
		||||
    end
 | 
			
		||||
    bbb_safe_execute :get_recordings, options
 | 
			
		||||
    res = bbb_safe_execute :get_recordings, options
 | 
			
		||||
 | 
			
		||||
    # ensure recordings is an array
 | 
			
		||||
    if !res[:recordings]
 | 
			
		||||
      res[:recordings] = []
 | 
			
		||||
    elsif !res[:recordings].is_a? Array
 | 
			
		||||
      res[:recordings] = [res[:recordings]]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    res[:recordings].each do |recording|
 | 
			
		||||
      pref_preview = {}
 | 
			
		||||
 | 
			
		||||
      # create a playbacks attribute on recording for playback formats
 | 
			
		||||
      recording[:playbacks] = if !recording[:playback] || !recording[:playback][:format]
 | 
			
		||||
        []
 | 
			
		||||
      elsif recording[:playback][:format].is_a? Array
 | 
			
		||||
        recording[:playback][:format]
 | 
			
		||||
      else
 | 
			
		||||
        [recording[:playback][:format]]
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      recording[:playbacks].each_with_index do |playback, index|
 | 
			
		||||
        # create a previews attribute on playbacks for preview images
 | 
			
		||||
        playback[:previews] = if !playback[:preview] || !playback[:preview][:images] || !playback[:preview][:images][:image]
 | 
			
		||||
          []
 | 
			
		||||
        elsif playback[:preview][:images][:image].is_a? Array
 | 
			
		||||
          playback[:preview][:images][:image]
 | 
			
		||||
        else
 | 
			
		||||
          [playback[:preview][:images][:image]]
 | 
			
		||||
        end
 | 
			
		||||
        if playback[:type] == 'presentation' && playback[:previews].present?
 | 
			
		||||
          pref_preview[:presentation] = index
 | 
			
		||||
        elsif playback[:previews].present? && pref_preview[:other].blank?
 | 
			
		||||
          pref_preview[:other] = index
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      # create a previews attribute on recordings for preview images
 | 
			
		||||
      recording[:previews] = if pref_preview[:presentation]
 | 
			
		||||
        recording[:playbacks][pref_preview[:presentation]][:previews]
 | 
			
		||||
      elsif pref_preview[:other]
 | 
			
		||||
        recording[:playbacks][pref_preview[:other]][:previews]
 | 
			
		||||
      else
 | 
			
		||||
        []
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    res
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def bbb_update_recordings(id, published)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								app/views/bbb/_preview.jbuilder
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								app/views/bbb/_preview.jbuilder
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
json.url preview[:content]
 | 
			
		||||
json.width preview[:width]
 | 
			
		||||
json.height preview[:height]
 | 
			
		||||
json.alt preview[:alt]
 | 
			
		||||
@@ -2,22 +2,26 @@ json.partial! 'bbb', messageKey: @messageKey, message: @message, status: @status
 | 
			
		||||
unless @response.blank?
 | 
			
		||||
  json.is_owner current_user == @user
 | 
			
		||||
  json.recordings do
 | 
			
		||||
    unless @response.is_a? Array
 | 
			
		||||
      @response = [@response]
 | 
			
		||||
    end
 | 
			
		||||
    json.array!(@response) do |recording|
 | 
			
		||||
      json.id recording[:recordID]
 | 
			
		||||
      json.name recording[:name]
 | 
			
		||||
      json.start_time recording[:startTime]
 | 
			
		||||
      json.end_time recording[:endTime]
 | 
			
		||||
      json.published recording[:published]
 | 
			
		||||
      json.playbacks do
 | 
			
		||||
        unless recording[:playback][:format].is_a? Array
 | 
			
		||||
          recording[:playback][:format] = [recording[:playback][:format]]
 | 
			
		||||
      json.previews do
 | 
			
		||||
        json.array!(recording[:previews]) do |preview|
 | 
			
		||||
          json.partial! 'preview', preview: preview
 | 
			
		||||
        end
 | 
			
		||||
        json.array!(recording[:playback][:format]) do |playback|
 | 
			
		||||
      end
 | 
			
		||||
      json.playbacks do
 | 
			
		||||
        json.array!(recording[:playbacks]) do |playback|
 | 
			
		||||
          json.type playback[:type]
 | 
			
		||||
          json.url playback[:url]
 | 
			
		||||
          json.previews do
 | 
			
		||||
            json.array!(playback[:previews]) do |preview|
 | 
			
		||||
              json.partial! 'preview', preview: preview
 | 
			
		||||
            end
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user