plexpy/data/interfaces/default/js/tables/user_ips.js
Tim d6b646323f Move everything to Bootstrap 3. (WIP)
Styling changes.
Remove old unused css.
Some code cleanup on notification handler.
2015-08-02 16:46:35 +02:00

117 lines
No EOL
3.8 KiB
JavaScript

user_ip_table_options = {
"destroy": true,
"language": {
"search": "Search: ",
"lengthMenu":"Show _MENU_ entries per page",
"info":"Showing _START_ to _END_ of _TOTAL_ results",
"infoEmpty":"Showing 0 to 0 of 0 entries",
"infoFiltered":"(filtered from _MAX_ total entries)",
"emptyTable": "No data in table",
},
"stateSave": true,
"pagingType": "bootstrap",
"processing": false,
"serverSide": true,
"pageLength": 10,
"order": [ 0, 'desc'],
"autoWidth": false,
"columnDefs": [
{
"targets": [0],
"data":"last_seen",
"render": function ( data, type, full ) {
return moment(data, "X").fromNow();
},
"searchable": false,
"width": "15%",
"className": "no-wrap"
},
{
"targets": [1],
"data":"ip_address",
"width": "15%",
"className": "modal-control no-wrap",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData) {
if (isPrivateIP(cellData)) {
if (cellData != '') {
$(td).html(cellData);
} else {
$(td).html('n/a');
}
} else {
$(td).html('<a href="javascript:void(0)" data-toggle="modal" data-target="#ip-info-modal"><span data-toggle="ip-tooltip" data-placement="left" title="IP Address Info" id="ip-info"><i class="fa fa-map-marker"></i></span>&nbsp' + cellData +'</a>');
}
} else {
$(td).html('n/a');
}
},
"width": "15%"
},
{
"targets": [2],
"data":"play_count",
"width": "10%",
"className": "hidden-xs"
},
{
"targets": [3],
"data":"platform",
"width": "15%",
"className": "hidden-xs"
},
{
"targets": [4],
"data":"last_watched",
"width": "30%",
"className": "hidden-sm hidden-xs"
}
],
"drawCallback": function (settings) {
// Jump to top of page
// $('html,body').scrollTop(0);
$('#ajaxMsg').fadeOut();
},
"preDrawCallback": function(settings) {
var msg = "<div class='msg'><i class='fa fa-refresh fa-spin'></i>&nbspFetching rows...</div>";
showMsg(msg, false, false, 0)
}
}
$('#user_ip_table').on('mouseenter', 'td.modal-control span', function () {
$(this).tooltip();
});
$('#user_ip_table').on('click', 'td.modal-control', function () {
var tr = $(this).parents('tr');
var row = user_ip_table.row( tr );
var rowData = row.data();
function getUserLocation(ip_address) {
if (isPrivateIP(ip_address)) {
return "n/a"
} else {
$.ajax({
url: 'http://ip-api.com/json/' + ip_address,
cache: true,
async: true,
type: 'GET',
dataType: 'json',
success: function(data) {
$('#modal_header_ip_address').html(ip_address);
$('#country').html(data.country);
$('#city').html(data.city);
$('#region').html(data.regionName);
$('#timezone').html(data.timezone);
$('#lat').html(data.lat);
$('#lon').html(data.lon);
$('#isp').html(data.isp);
$('#org').html(data.org);
$('#as').html(data.as);
}
});
}
}
getUserLocation(rowData['ip_address']);
});