[Web] Show country of sasl ips

This commit is contained in:
andryyy
2021-06-06 11:57:15 +02:00
parent d7ecf899c8
commit a89fe53e4a
5 changed files with 73 additions and 11 deletions

View File

@@ -78,11 +78,11 @@ jQuery(function($){
}
})
function last_logins(action) {
function last_logins(action, lines = 5) {
if (action == 'get') {
$.ajax({
dataType: 'json',
url: '/api/v1/get/last-login/' + encodeURIComponent(mailcow_cc_username),
url: '/api/v1/get/last-login/' + encodeURIComponent(mailcow_cc_username) + '/' + lines,
jsonp: false,
error: function () {
console.log('error reading last logins');
@@ -99,14 +99,24 @@ jQuery(function($){
$.each(data.sasl, function (i, item) {
var datetime = new Date(item.datetime.replace(/-/g, "/"));
var local_datetime = datetime.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
if (item.service == "smtp") { service = '<div class="label label-default">' + item.service.toUpperCase() + '<i class="bi bi-chevron-compact-right"></i></div>'; }
else if (item.service == "imap") { service = '<div class="label label-default"><i class="bi bi-chevron-compact-left"></i> ' + item.service.toUpperCase() + '</div>'; }
else { service = '<div class="label label-default">' + item.service.toUpperCase() + '</div>'; }
if (item.location) {
ip_location = '<span class="lang-sm ip-location-flag" lang="' + item.location + '"></span>';
} else {
ip_location = '';
}
if (item.service == "smtp") {
service = '<div class="label label-default">' + item.service.toUpperCase() + '<i class="bi bi-chevron-compact-right"></i></div>';
} else if (item.service == "imap") {
service = '<div class="label label-default"><i class="bi bi-chevron-compact-left"></i> ' + item.service.toUpperCase() + '</div>';
} else {
service = '<div class="label label-default">' + item.service.toUpperCase() + '</div>';
}
if (item.real_rip.startsWith("Web")) {
real_rip = item.real_rip;
} else {
real_rip = '<a href="https://bgp.he.net/ip/' + item.real_rip + '" target="_blank">' + item.real_rip + '</a>';
real_rip = '<a href="https://bgp.he.net/ip/' + item.real_rip + '" target="_blank">' + item.real_rip + '</a> ';
}
real_rip = real_rip + ' ' + ip_location;
$('.last-login').append('<li class="list-group-item">' +
local_datetime + ' ' + service + ' ' + lang.from + ' ' +
real_rip +