forked from External/greenlight
Merge pull request #32 from zach-chai/meeting_class
finish meeting class
This commit is contained in:
commit
18a1c0f835
|
@ -3,14 +3,14 @@
|
|||
var sessionStatusRefresh = function(url) {
|
||||
$.get(url + "/session_status_refresh", function(html) {
|
||||
$(".center-panel-wrapper").html(html);
|
||||
displayMeetingURL();
|
||||
displayRoomURL();
|
||||
});
|
||||
}
|
||||
|
||||
var initRooms = function() {
|
||||
App.messages = App.cable.subscriptions.create({
|
||||
channel: 'MeetingUpdatesChannel',
|
||||
encrypted_id: getEncryptedId()
|
||||
encrypted_id: Meeting.getInstance().getId()
|
||||
},
|
||||
{
|
||||
received: function(data) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var initRooms = function() {
|
||||
App.messages = App.cable.subscriptions.create({
|
||||
channel: 'RecordingUpdatesChannel',
|
||||
encrypted_id: getEncryptedId()
|
||||
encrypted_id: Meeting.getInstance().getId()
|
||||
},
|
||||
{
|
||||
received: function(data) {
|
||||
|
|
|
@ -16,11 +16,9 @@
|
|||
var init = function() {
|
||||
|
||||
$('.center-panel-wrapper').on ('click', '.meeting-join', function (event) {
|
||||
var url = $('.meeting-url').val();
|
||||
var name = $('.meeting-user-name').val();
|
||||
Meeting.getInstance().setURL(url);
|
||||
Meeting.getInstance().setName(name);
|
||||
var jqxhr = Meeting.getInstance().getjoinMeetingURL();
|
||||
var jqxhr = Meeting.getInstance().getJoinMeetingResponse();
|
||||
|
||||
jqxhr.done(function(data) {
|
||||
if (data.messageKey === 'wait_for_moderator') {
|
||||
|
@ -47,10 +45,10 @@
|
|||
});
|
||||
|
||||
$('.center-panel-wrapper').on ('click', '.meeting-url-copy', function (event) {
|
||||
meetingURL = $('.meeting-url');
|
||||
meetingURL.select();
|
||||
meetingURLInput = $('.meeting-url');
|
||||
meetingURLInput.select();
|
||||
document.execCommand("copy");
|
||||
meetingURL.blur();
|
||||
meetingURLInput.blur();
|
||||
});
|
||||
|
||||
// enable popovers
|
||||
|
@ -94,7 +92,7 @@
|
|||
};
|
||||
|
||||
var initRooms = function() {
|
||||
displayMeetingURL();
|
||||
displayRoomURL();
|
||||
|
||||
// initialize recordings datatable
|
||||
recordingsTable = $('#recordings').dataTable({
|
||||
|
@ -147,7 +145,7 @@
|
|||
targets: -1,
|
||||
render: function(data, type, row) {
|
||||
if (type === 'display') {
|
||||
var roomName = getEncryptedId();
|
||||
var roomName = Meeting.getInstance().getId();
|
||||
var published = row.published;
|
||||
var eye = getPublishClass(published);
|
||||
return '<button type="button" class="btn btn-default recording-update" data-published="'+published+'">' +
|
||||
|
@ -205,7 +203,7 @@
|
|||
return;
|
||||
}
|
||||
table = recordingsTable.api();
|
||||
$.get("/rooms/"+getEncryptedId()+"/recordings", function(data) {
|
||||
$.get("/rooms/"+Meeting.getInstance().getId()+"/recordings", function(data) {
|
||||
if (!data.is_owner) {
|
||||
table.column(-1).visible( false );
|
||||
}
|
||||
|
|
|
@ -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 getPublishClass = function(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 jqxhr = Meeting.getInstance().getjoinMeetingURL();
|
||||
var jqxhr = Meeting.getInstance().getJoinMeetingResponse();
|
||||
jqxhr.done(function(data) {
|
||||
if (data.messageKey === 'wait_for_moderator') {
|
||||
setTimeout(loopJoin, 5000);
|
||||
|
@ -92,11 +39,6 @@ var showAlert = function(html, timeout_delay) {
|
|||
}
|
||||
}
|
||||
|
||||
var displayMeetingURL = function() {
|
||||
meetingURL = $('.meeting-url');
|
||||
var link = window.location.protocol +
|
||||
'//' +
|
||||
window.location.hostname +
|
||||
meetingURL.data('path');
|
||||
meetingURL.val(link);
|
||||
var displayRoomURL = function() {
|
||||
$('.meeting-url').val(Meeting.getInstance().getURL());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue