forked from External/greenlight
		
	finish meeting class
This commit is contained in:
		@@ -3,14 +3,14 @@
 | 
				
			|||||||
  var sessionStatusRefresh = function(url) {
 | 
					  var sessionStatusRefresh = function(url) {
 | 
				
			||||||
    $.get(url + "/session_status_refresh", function(html) {
 | 
					    $.get(url + "/session_status_refresh", function(html) {
 | 
				
			||||||
      $(".center-panel-wrapper").html(html);
 | 
					      $(".center-panel-wrapper").html(html);
 | 
				
			||||||
      displayMeetingURL();
 | 
					      displayRoomURL();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  var initRooms = function() {
 | 
					  var initRooms = function() {
 | 
				
			||||||
    App.messages = App.cable.subscriptions.create({
 | 
					    App.messages = App.cable.subscriptions.create({
 | 
				
			||||||
      channel: 'MeetingUpdatesChannel',
 | 
					      channel: 'MeetingUpdatesChannel',
 | 
				
			||||||
      encrypted_id: getEncryptedId()
 | 
					      encrypted_id: Meeting.getInstance().getId()
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      received: function(data) {
 | 
					      received: function(data) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@
 | 
				
			|||||||
  var initRooms = function() {
 | 
					  var initRooms = function() {
 | 
				
			||||||
    App.messages = App.cable.subscriptions.create({
 | 
					    App.messages = App.cable.subscriptions.create({
 | 
				
			||||||
      channel: 'RecordingUpdatesChannel',
 | 
					      channel: 'RecordingUpdatesChannel',
 | 
				
			||||||
      encrypted_id: getEncryptedId()
 | 
					      encrypted_id: Meeting.getInstance().getId()
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      received: function(data) {
 | 
					      received: function(data) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,11 +16,9 @@
 | 
				
			|||||||
  var init = function() {
 | 
					  var init = function() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $('.center-panel-wrapper').on ('click', '.meeting-join', function (event) {
 | 
					    $('.center-panel-wrapper').on ('click', '.meeting-join', function (event) {
 | 
				
			||||||
      var url = $('.meeting-url').val();
 | 
					 | 
				
			||||||
      var name = $('.meeting-user-name').val();
 | 
					      var name = $('.meeting-user-name').val();
 | 
				
			||||||
      Meeting.getInstance().setURL(url);
 | 
					 | 
				
			||||||
      Meeting.getInstance().setName(name);
 | 
					      Meeting.getInstance().setName(name);
 | 
				
			||||||
      var jqxhr = Meeting.getInstance().getjoinMeetingURL();
 | 
					      var jqxhr = Meeting.getInstance().getJoinMeetingResponse();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      jqxhr.done(function(data) {
 | 
					      jqxhr.done(function(data) {
 | 
				
			||||||
        if (data.messageKey === 'wait_for_moderator') {
 | 
					        if (data.messageKey === 'wait_for_moderator') {
 | 
				
			||||||
@@ -47,10 +45,10 @@
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $('.center-panel-wrapper').on ('click', '.meeting-url-copy', function (event) {
 | 
					    $('.center-panel-wrapper').on ('click', '.meeting-url-copy', function (event) {
 | 
				
			||||||
      meetingURL = $('.meeting-url');
 | 
					      meetingURLInput = $('.meeting-url');
 | 
				
			||||||
      meetingURL.select();
 | 
					      meetingURLInput.select();
 | 
				
			||||||
      document.execCommand("copy");
 | 
					      document.execCommand("copy");
 | 
				
			||||||
      meetingURL.blur();
 | 
					      meetingURLInput.blur();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // enable popovers
 | 
					    // enable popovers
 | 
				
			||||||
@@ -94,7 +92,7 @@
 | 
				
			|||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  var initRooms = function() {
 | 
					  var initRooms = function() {
 | 
				
			||||||
    displayMeetingURL();
 | 
					    displayRoomURL();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // initialize recordings datatable
 | 
					    // initialize recordings datatable
 | 
				
			||||||
    recordingsTable = $('#recordings').dataTable({
 | 
					    recordingsTable = $('#recordings').dataTable({
 | 
				
			||||||
@@ -147,7 +145,7 @@
 | 
				
			|||||||
          targets: -1,
 | 
					          targets: -1,
 | 
				
			||||||
          render: function(data, type, row) {
 | 
					          render: function(data, type, row) {
 | 
				
			||||||
            if (type === 'display') {
 | 
					            if (type === 'display') {
 | 
				
			||||||
              var roomName = getEncryptedId();
 | 
					              var roomName = Meeting.getInstance().getId();
 | 
				
			||||||
              var published = row.published;
 | 
					              var published = row.published;
 | 
				
			||||||
              var eye = getPublishClass(published);
 | 
					              var eye = getPublishClass(published);
 | 
				
			||||||
              return '<button type="button" class="btn btn-default recording-update" data-published="'+published+'">' +
 | 
					              return '<button type="button" class="btn btn-default recording-update" data-published="'+published+'">' +
 | 
				
			||||||
@@ -205,7 +203,7 @@
 | 
				
			|||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    table = recordingsTable.api();
 | 
					    table = recordingsTable.api();
 | 
				
			||||||
    $.get("/rooms/"+getEncryptedId()+"/recordings", function(data) {
 | 
					    $.get("/rooms/"+Meeting.getInstance().getId()+"/recordings", function(data) {
 | 
				
			||||||
      if (!data.is_owner) {
 | 
					      if (!data.is_owner) {
 | 
				
			||||||
        table.column(-1).visible( false );
 | 
					        table.column(-1).visible( false );
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										80
									
								
								app/assets/javascripts/meeting.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								app/assets/javascripts/meeting.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,80 @@
 | 
				
			|||||||
 | 
					// Meeting class
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var _meetingInstance = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Meeting {
 | 
				
			||||||
 | 
					  constructor(id, url, name) {
 | 
				
			||||||
 | 
					    this.id = id;
 | 
				
			||||||
 | 
					    this.url = url;
 | 
				
			||||||
 | 
					    this.name = name;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Gets the current instance or creates a new one
 | 
				
			||||||
 | 
					  static getInstance() {
 | 
				
			||||||
 | 
					    if (_meetingInstance) {
 | 
				
			||||||
 | 
					      return _meetingInstance;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    var id = $(".page-wrapper.rooms").data('room');
 | 
				
			||||||
 | 
					    var url = Meeting.buildURL();
 | 
				
			||||||
 | 
					    var name = $('.meeting-user-name').val();
 | 
				
			||||||
 | 
					    _meetingInstance = new Meeting(id, url, name);
 | 
				
			||||||
 | 
					    return _meetingInstance;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static buildURL() {
 | 
				
			||||||
 | 
					    return location.protocol +
 | 
				
			||||||
 | 
					      '//' +
 | 
				
			||||||
 | 
					      location.hostname +
 | 
				
			||||||
 | 
					      '/rooms/' +
 | 
				
			||||||
 | 
					      $('.rooms').data('room');
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Sends the end meeting request
 | 
				
			||||||
 | 
					  // Returns a response object
 | 
				
			||||||
 | 
					  endMeeting() {
 | 
				
			||||||
 | 
					    return $.ajax({
 | 
				
			||||||
 | 
					      url: this.url + "/end",
 | 
				
			||||||
 | 
					      type: 'DELETE'
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Makes a call to get the join meeting url
 | 
				
			||||||
 | 
					  // Returns a response object
 | 
				
			||||||
 | 
					  //    The response object contains the URL to join the meeting
 | 
				
			||||||
 | 
					  getJoinMeetingResponse() {
 | 
				
			||||||
 | 
					    return $.get(this.url + "/join?name=" + this.name, function() {
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  getId() {
 | 
				
			||||||
 | 
					    return this.id;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  getURL() {
 | 
				
			||||||
 | 
					    return this.url;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  getName() {
 | 
				
			||||||
 | 
					    return this.name;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  setName(name) {
 | 
				
			||||||
 | 
					    this.name = name;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  getModJoined() {
 | 
				
			||||||
 | 
					    return this.modJoined;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  setModJoined(modJoined) {
 | 
				
			||||||
 | 
					    this.modJoined = modJoined;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  getWaitingForMod() {
 | 
				
			||||||
 | 
					    return this.waitingForMod;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  setWaitingForMod(wMod) {
 | 
				
			||||||
 | 
					    this.waitingForMod = wMod;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -4,67 +4,14 @@ $.ajaxSetup({
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var getEncryptedId = function() {
 | 
					 | 
				
			||||||
  return $(".page-wrapper.rooms").data('room');
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
var PUBLISHED_CLASSES = ['fa-eye-slash', 'fa-eye']
 | 
					var PUBLISHED_CLASSES = ['fa-eye-slash', 'fa-eye']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var getPublishClass = function(published) {
 | 
					var getPublishClass = function(published) {
 | 
				
			||||||
  return PUBLISHED_CLASSES[+published];
 | 
					  return PUBLISHED_CLASSES[+published];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var meetingInstance = null;
 | 
					 | 
				
			||||||
class Meeting {
 | 
					 | 
				
			||||||
  constructor(url, name) {
 | 
					 | 
				
			||||||
    this.url = url;
 | 
					 | 
				
			||||||
    this.name = name;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static getInstance() {
 | 
					 | 
				
			||||||
    if (meetingInstance) {
 | 
					 | 
				
			||||||
      return meetingInstance;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    var url = $('.meeting-url').val();
 | 
					 | 
				
			||||||
    var name = $('.meeting-user-name').val();
 | 
					 | 
				
			||||||
    meetingInstance = new Meeting(url, name);
 | 
					 | 
				
			||||||
    return meetingInstance;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  getjoinMeetingURL() {
 | 
					 | 
				
			||||||
    return $.get(this.url + "/join?name=" + this.name, function() {
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  endMeeting() {
 | 
					 | 
				
			||||||
    return $.ajax({
 | 
					 | 
				
			||||||
      url: this.url + "/end",
 | 
					 | 
				
			||||||
      type: 'DELETE'
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  setURL(url) {
 | 
					 | 
				
			||||||
    this.url = url;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  setName(name) {
 | 
					 | 
				
			||||||
    this.name = name;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  setModJoined(modJoined) {
 | 
					 | 
				
			||||||
    this.modJoined = modJoined;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  getModJoined() {
 | 
					 | 
				
			||||||
    return this.modJoined;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  setWaitingForMod(wMod) {
 | 
					 | 
				
			||||||
    this.waitingForMod = wMod;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  getWaitingForMod() {
 | 
					 | 
				
			||||||
    return this.waitingForMod;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
var loopJoin = function() {
 | 
					var loopJoin = function() {
 | 
				
			||||||
  var jqxhr = Meeting.getInstance().getjoinMeetingURL();
 | 
					  var jqxhr = Meeting.getInstance().getJoinMeetingResponse();
 | 
				
			||||||
  jqxhr.done(function(data) {
 | 
					  jqxhr.done(function(data) {
 | 
				
			||||||
    if (data.messageKey === 'wait_for_moderator') {
 | 
					    if (data.messageKey === 'wait_for_moderator') {
 | 
				
			||||||
      setTimeout(loopJoin, 5000);
 | 
					      setTimeout(loopJoin, 5000);
 | 
				
			||||||
@@ -92,11 +39,6 @@ var showAlert = function(html, timeout_delay) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var displayMeetingURL = function() {
 | 
					var displayRoomURL = function() {
 | 
				
			||||||
  meetingURL = $('.meeting-url');
 | 
					  $('.meeting-url').val(Meeting.getInstance().getURL());
 | 
				
			||||||
  var link = window.location.protocol +
 | 
					 | 
				
			||||||
    '//' +
 | 
					 | 
				
			||||||
    window.location.hostname +
 | 
					 | 
				
			||||||
    meetingURL.data('path');
 | 
					 | 
				
			||||||
  meetingURL.val(link);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user