forked from External/greenlight
* Fixed issue with recording length and sort * Made js run on any page with a table element on it * Scrutinizer fix
This commit is contained in:
parent
95a98f6574
commit
4d648534f7
|
@ -121,7 +121,7 @@ $(document).on('turbolinks:load', function(){
|
||||||
submit_update_request({
|
submit_update_request({
|
||||||
setting: "rename_header",
|
setting: "rename_header",
|
||||||
room_name: element.find('#user-text').text(),
|
room_name: element.find('#user-text').text(),
|
||||||
});
|
}, element.data('path'));
|
||||||
}
|
}
|
||||||
else if(element.is('#recording-title')){
|
else if(element.is('#recording-title')){
|
||||||
submit_update_request({
|
submit_update_request({
|
||||||
|
@ -129,27 +129,15 @@ $(document).on('turbolinks:load', function(){
|
||||||
record_id: element.data('recordid'),
|
record_id: element.data('recordid'),
|
||||||
record_name: element.find('text').text(),
|
record_name: element.find('text').text(),
|
||||||
room_uid: element.data('room-uid'),
|
room_uid: element.data('room-uid'),
|
||||||
});
|
}, element.data('path'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper for submitting ajax requests
|
// Helper for submitting ajax requests
|
||||||
var submit_update_request = function(data){
|
var submit_update_request = function(data, path){
|
||||||
var update_path = window.location.pathname
|
|
||||||
|
|
||||||
if ('room_uid' in data) {
|
|
||||||
update_path = $("body").data('relative-root')
|
|
||||||
|
|
||||||
if (!update_path.endsWith("/")) {
|
|
||||||
update_path += "/"
|
|
||||||
}
|
|
||||||
|
|
||||||
update_path += data.room_uid
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send ajax request for update
|
// Send ajax request for update
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: update_path,
|
url: path,
|
||||||
type: "PATCH",
|
type: "PATCH",
|
||||||
data: data,
|
data: data,
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,16 +15,14 @@
|
||||||
// with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
// with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
$(document).on('turbolinks:load', function(){
|
$(document).on('turbolinks:load', function(){
|
||||||
var controller = $("body").data('controller');
|
// Check if there is a table on this page
|
||||||
var action = $("body").data('action');
|
if ($("table").length) {
|
||||||
|
|
||||||
if(controller == "rooms" && action == "show" || controller == "rooms" && action == "update"){
|
|
||||||
|
|
||||||
// Choose active header
|
// Choose active header
|
||||||
// (Name, Length or Users)
|
// (Name, Length or Users)
|
||||||
$('th').each(function(){
|
$('th').each(function(){
|
||||||
if($(this).data("header")){
|
if($(this).data("header")){
|
||||||
$(this).on('click', function(){
|
$(this).on('click', function(){
|
||||||
set_active_header($(this).data("header"));
|
set_active_header($(this).data("header"));
|
||||||
sort_by($(this).data("header"), $(this).data('order'));
|
sort_by($(this).data("header"), $(this).data('order'));
|
||||||
});
|
});
|
||||||
|
@ -80,8 +78,14 @@ $(document).on('turbolinks:load', function(){
|
||||||
// Generalized function for sorting recordings
|
// Generalized function for sorting recordings
|
||||||
var sort_recordings = function(recording_list_tbody, order, recording_id){
|
var sort_recordings = function(recording_list_tbody, order, recording_id){
|
||||||
recording_list_tbody.find('tr').sort(function(a, b){
|
recording_list_tbody.find('tr').sort(function(a, b){
|
||||||
var a_val = $.trim($(a).find(recording_id).text());
|
var a_val, b_val;
|
||||||
var b_val = $.trim($(b).find(recording_id).text());
|
if (recording_id == "#recording-length") {
|
||||||
|
a_val = $.trim($(a).find(recording_id).data("full-length"));
|
||||||
|
b_val = $.trim($(b).find(recording_id).data("full-length"));
|
||||||
|
} else {
|
||||||
|
a_val = $.trim($(a).find(recording_id).text());
|
||||||
|
b_val = $.trim($(b).find(recording_id).text());
|
||||||
|
}
|
||||||
|
|
||||||
if(order === "asc"){
|
if(order === "asc"){
|
||||||
return a_val.localeCompare(b_val);
|
return a_val.localeCompare(b_val);
|
||||||
|
@ -89,6 +93,8 @@ $(document).on('turbolinks:load', function(){
|
||||||
else if(order === "desc"){
|
else if(order === "desc"){
|
||||||
return b_val.localeCompare(a_val);
|
return b_val.localeCompare(a_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}).appendTo(recording_list_tbody);
|
}).appendTo(recording_list_tbody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ module RecordingsHelper
|
||||||
|
|
||||||
len = valid_playbacks.first[:length]
|
len = valid_playbacks.first[:length]
|
||||||
if len > 60
|
if len > 60
|
||||||
"#{(len / 60).round} hrs"
|
"#{(len / 60).to_i} hrs #{len % 60} mins"
|
||||||
elsif len == 0
|
elsif len == 0
|
||||||
"< 1 min"
|
"< 1 min"
|
||||||
else
|
else
|
||||||
|
@ -42,4 +42,8 @@ module RecordingsHelper
|
||||||
def safe_recording_images(images)
|
def safe_recording_images(images)
|
||||||
Array.wrap(images)
|
Array.wrap(images)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def room_uid_from_bbb(bbb_id)
|
||||||
|
Room.find_by(bbb_id: bbb_id)[:uid]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div id="recording-title">
|
<div id="recording-title" class="form-inline edit_hover_class" data-recordid="<%= recording[:recordID] %>" data-room-uid="<%= room_uid_from_bbb(recording[:meetingID]) %>" data-path="<%= update_room_path(room_uid: room_uid_from_bbb(recording[:meetingID])) %>">
|
||||||
<text>
|
<text>
|
||||||
<% if recording[:metadata][:name] %>
|
<% if recording[:metadata][:name] %>
|
||||||
<%= recording[:metadata][:name] %>
|
<%= recording[:metadata][:name] %>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td id="recording-length" class="text-left">
|
<td id="recording-length" class="text-left" data-full-length="<%=recording[:playbacks].first[:length]%>">
|
||||||
<div class="small text-muted text-uppercase">
|
<div class="small text-muted text-uppercase">
|
||||||
<%= t("recording.table.length") %>
|
<%= t("recording.table.length") %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div id="recording-title" class="form-inline edit_hover_class" data-recordid="<%= recording[:recordID] %>" data-room-uid="<%= recording[:room_uid] %>">
|
<div id="recording-title" class="form-inline edit_hover_class" data-recordid="<%= recording[:recordID] %>" data-room-uid="<%= room_uid_from_bbb(recording[:meetingID]) %>" data-path="<%= update_room_path(room_uid: room_uid_from_bbb(recording[:meetingID])) %>">
|
||||||
<text id='recording-text'>
|
<text id='recording-text'>
|
||||||
<% if recording[:metadata][:name] %>
|
<% if recording[:metadata][:name] %>
|
||||||
<%= recording[:metadata][:name] %>
|
<%= recording[:metadata][:name] %>
|
||||||
|
|
Loading…
Reference in New Issue