[Web] Autodiscover returns given password decoded and trimed; Add sieve pre and post filters to UI; Move ajax called files; Rework log system: 100 entries per default, add more per click; Syncjobs: Do not read log to data attribute
This commit is contained in:
@@ -1,125 +1,10 @@
|
||||
var Base64 = {
|
||||
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
||||
encode: function(e) {
|
||||
var t = "";
|
||||
var n, r, i, s, o, u, a;
|
||||
var f = 0;
|
||||
e = Base64._utf8_encode(e);
|
||||
while (f < e.length) {
|
||||
n = e.charCodeAt(f++);
|
||||
r = e.charCodeAt(f++);
|
||||
i = e.charCodeAt(f++);
|
||||
s = n >> 2;
|
||||
o = (n & 3) << 4 | r >> 4;
|
||||
u = (r & 15) << 2 | i >> 6;
|
||||
a = i & 63;
|
||||
if (isNaN(r)) {
|
||||
u = a = 64
|
||||
} else if (isNaN(i)) {
|
||||
a = 64
|
||||
}
|
||||
t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) +
|
||||
this._keyStr.charAt(u) + this._keyStr.charAt(a)
|
||||
}
|
||||
return t
|
||||
},
|
||||
decode: function(e) {
|
||||
var t = "";
|
||||
var n, r, i;
|
||||
var s, o, u, a;
|
||||
var f = 0;
|
||||
e = e.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
||||
while (f < e.length) {
|
||||
s = this._keyStr.indexOf(e.charAt(f++));
|
||||
o = this._keyStr.indexOf(e.charAt(f++));
|
||||
u = this._keyStr.indexOf(e.charAt(f++));
|
||||
a = this._keyStr.indexOf(e.charAt(f++));
|
||||
n = s << 2 | o >> 4;
|
||||
r = (o & 15) << 4 | u >> 2;
|
||||
i = (u & 3) << 6 | a;
|
||||
t = t + String.fromCharCode(n);
|
||||
if (u != 64) {
|
||||
t = t + String.fromCharCode(r)
|
||||
}
|
||||
if (a != 64) {
|
||||
t = t + String.fromCharCode(i)
|
||||
}
|
||||
}
|
||||
t = Base64._utf8_decode(t);
|
||||
return t
|
||||
},
|
||||
_utf8_encode: function(e) {
|
||||
e = e.replace(/\r\n/g, "\n");
|
||||
var t = "";
|
||||
for (var n = 0; n < e.length; n++) {
|
||||
var r = e.charCodeAt(n);
|
||||
if (r < 128) {
|
||||
t += String.fromCharCode(r)
|
||||
} else if (r > 127 && r < 2048) {
|
||||
t += String.fromCharCode(r >> 6 | 192);
|
||||
t += String.fromCharCode(r & 63 | 128)
|
||||
} else {
|
||||
t += String.fromCharCode(r >> 12 | 224);
|
||||
t += String.fromCharCode(r >> 6 & 63 | 128);
|
||||
t += String.fromCharCode(r & 63 | 128)
|
||||
}
|
||||
}
|
||||
return t
|
||||
},
|
||||
_utf8_decode: function(e) {
|
||||
var t = "";
|
||||
var n = 0;
|
||||
var r = c1 = c2 = 0;
|
||||
while (n < e.length) {
|
||||
r = e.charCodeAt(n);
|
||||
if (r < 128) {
|
||||
t += String.fromCharCode(r);
|
||||
n++
|
||||
} else if (r > 191 && r < 224) {
|
||||
c2 = e.charCodeAt(n + 1);
|
||||
t += String.fromCharCode((r & 31) << 6 | c2 & 63);
|
||||
n += 2
|
||||
} else {
|
||||
c2 = e.charCodeAt(n + 1);
|
||||
c3 = e.charCodeAt(n + 2);
|
||||
t += String.fromCharCode((r & 15) << 12 | (c2 & 63) <<
|
||||
6 | c3 & 63);
|
||||
n += 3
|
||||
}
|
||||
}
|
||||
return t
|
||||
}
|
||||
}
|
||||
|
||||
// Base64 functions
|
||||
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(r){var t,e,o,a,h,n,c,d="",C=0;for(r=Base64._utf8_encode(r);C<r.length;)a=(t=r.charCodeAt(C++))>>2,h=(3&t)<<4|(e=r.charCodeAt(C++))>>4,n=(15&e)<<2|(o=r.charCodeAt(C++))>>6,c=63&o,isNaN(e)?n=c=64:isNaN(o)&&(c=64),d=d+this._keyStr.charAt(a)+this._keyStr.charAt(h)+this._keyStr.charAt(n)+this._keyStr.charAt(c);return d},decode:function(r){var t,e,o,a,h,n,c="",d=0;for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");d<r.length;)t=this._keyStr.indexOf(r.charAt(d++))<<2|(a=this._keyStr.indexOf(r.charAt(d++)))>>4,e=(15&a)<<4|(h=this._keyStr.indexOf(r.charAt(d++)))>>2,o=(3&h)<<6|(n=this._keyStr.indexOf(r.charAt(d++))),c+=String.fromCharCode(t),64!=h&&(c+=String.fromCharCode(e)),64!=n&&(c+=String.fromCharCode(o));return c=Base64._utf8_decode(c)},_utf8_encode:function(r){r=r.replace(/\r\n/g,"\n");for(var t="",e=0;e<r.length;e++){var o=r.charCodeAt(e);o<128?t+=String.fromCharCode(o):o>127&&o<2048?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t},_utf8_decode:function(r){for(var t="",e=0,o=c1=c2=0;e<r.length;)(o=r.charCodeAt(e))<128?(t+=String.fromCharCode(o),e++):o>191&&o<224?(c2=r.charCodeAt(e+1),t+=String.fromCharCode((31&o)<<6|63&c2),e+=2):(c2=r.charCodeAt(e+1),c3=r.charCodeAt(e+2),t+=String.fromCharCode((15&o)<<12|(63&c2)<<6|63&c3),e+=3);return t}};
|
||||
jQuery(function($){
|
||||
// http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
||||
var entityMap = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'/': '/',
|
||||
'`': '`',
|
||||
'=': '='
|
||||
};
|
||||
function escapeHtml(string) {
|
||||
return String(string).replace(/[&<>"'`=\/]/g, function (s) {
|
||||
return entityMap[s];
|
||||
});
|
||||
}
|
||||
function humanFileSize(bytes) {
|
||||
if(Math.abs(bytes) < 1024) {
|
||||
return bytes + ' B';
|
||||
}
|
||||
var units = ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB'];
|
||||
var u = -1;
|
||||
do {
|
||||
bytes /= 1024;
|
||||
++u;
|
||||
} while(Math.abs(bytes) >= 1024 && u < units.length - 1);
|
||||
return bytes.toFixed(1)+' '+units[u];
|
||||
}
|
||||
var entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};
|
||||
function escapeHtml(n){return String(n).replace(/[&<>"'`=\/]/g,function(n){return entityMap[n]})}
|
||||
function humanFileSize(i){if(Math.abs(i)<1024)return i+" B";var B=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],e=-1;do{i/=1024,++e}while(Math.abs(i)>=1024&&e<B.length-1);return i.toFixed(1)+" "+B[e]}
|
||||
$("#refresh_postfix_log").on('click', function(e) {
|
||||
e.preventDefault();
|
||||
draw_postfix_logs();
|
||||
@@ -148,54 +33,6 @@ jQuery(function($){
|
||||
e.preventDefault();
|
||||
$('#import_dkim_arrow').toggleClass("animation");
|
||||
});
|
||||
function draw_postfix_logs() {
|
||||
ft_postfix_logs = FooTable.init('#postfix_log', {
|
||||
"columns": [
|
||||
{"name":"time","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.time,"style":{"width":"170px"}},
|
||||
{"name":"priority","title":lang.priority,"style":{"width":"80px"}},
|
||||
{"name":"message","title":lang.message},
|
||||
],
|
||||
"rows": $.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/logs/postfix/1000',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('Cannot draw postfix log table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
item.message = escapeHtml(item.message);
|
||||
var danger_class = ["emerg", "alert", "crit", "err"];
|
||||
var warning_class = ["warning", "warn"];
|
||||
var info_class = ["notice", "info", "debug"];
|
||||
if (jQuery.inArray(item.priority, danger_class) !== -1) {
|
||||
item.priority = '<span class="label label-danger">' + item.priority + '</span>';
|
||||
}
|
||||
else if (jQuery.inArray(item.priority, warning_class) !== -1) {
|
||||
item.priority = '<span class="label label-warning">' + item.priority + '</span>';
|
||||
}
|
||||
else if (jQuery.inArray(item.priority, info_class) !== -1) {
|
||||
item.priority = '<span class="label label-info">' + item.priority + '</span>';
|
||||
}
|
||||
});
|
||||
}
|
||||
}),
|
||||
"empty": lang.empty,
|
||||
"paging": {
|
||||
"enabled": true,
|
||||
"limit": 5,
|
||||
"size": log_pagination_size
|
||||
},
|
||||
"filtering": {
|
||||
"enabled": true,
|
||||
"position": "left",
|
||||
"placeholder": lang.filter_table
|
||||
},
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
}
|
||||
});
|
||||
}
|
||||
function draw_autodiscover_logs() {
|
||||
ft_autodiscover_logs = FooTable.init('#autodiscover_log', {
|
||||
"columns": [
|
||||
@@ -212,33 +49,53 @@ jQuery(function($){
|
||||
console.log('Cannot draw autodiscover log table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
item.ua = '<span style="font-size:small">' + item.ua + '</span>';
|
||||
if (item.service == "activesync") {
|
||||
item.service = '<span class="label label-info">ActiveSync</span>';
|
||||
}
|
||||
else if (item.service == "imap") {
|
||||
item.service = '<span class="label label-success">IMAP, SMTP, Cal-/CardDAV</span>';
|
||||
}
|
||||
else {
|
||||
item.service = '<span class="label label-danger">' + item.service + '</span>';
|
||||
}
|
||||
});
|
||||
return process_table_data(data, 'autodiscover_log');
|
||||
}
|
||||
}),
|
||||
"empty": lang.empty,
|
||||
"paging": {
|
||||
"enabled": true,
|
||||
"limit": 5,
|
||||
"size": log_pagination_size
|
||||
},
|
||||
"filtering": {
|
||||
"enabled": true,
|
||||
"position": "left",
|
||||
"placeholder": lang.filter_table
|
||||
},
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
"paging": {"enabled": true,"limit": 5,"size": log_pagination_size},
|
||||
"filtering": {"enabled": true,"position": "left","placeholder": lang.filter_table},
|
||||
"sorting": {"enabled": true},
|
||||
"on": {"ready.ft.table": function(e, ft){
|
||||
heading = ft.$el.parents('.tab-pane').find('.panel-heading')
|
||||
$(heading).children('.log-lines').text(function(){
|
||||
var ft_paging = ft.use(FooTable.Paging)
|
||||
return ft_paging.totalRows;
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function draw_postfix_logs() {
|
||||
ft_postfix_logs = FooTable.init('#postfix_log', {
|
||||
"columns": [
|
||||
{"name":"time","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.time,"style":{"width":"170px"}},
|
||||
{"name":"priority","title":lang.priority,"style":{"width":"80px"}},
|
||||
{"name":"message","title":lang.message},
|
||||
],
|
||||
"rows": $.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/logs/postfix',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('Cannot draw postfix log table');
|
||||
},
|
||||
success: function (data) {
|
||||
return process_table_data(data, 'general_syslog');
|
||||
}
|
||||
}),
|
||||
"empty": lang.empty,
|
||||
"paging": {"enabled": true,"limit": 5,"size": log_pagination_size},
|
||||
"filtering": {"enabled": true,"position": "left","placeholder": lang.filter_table},
|
||||
"sorting": {"enabled": true},
|
||||
"on": {
|
||||
"ready.ft.table": function(e, ft){
|
||||
heading = ft.$el.parents('.tab-pane').find('.panel-heading')
|
||||
$(heading).children('.log-lines').text(function(){
|
||||
var ft_paging = ft.use(FooTable.Paging)
|
||||
return ft_paging.totalRows;
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -251,43 +108,27 @@ jQuery(function($){
|
||||
],
|
||||
"rows": $.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/logs/fail2ban/1000',
|
||||
url: '/api/v1/get/logs/fail2ban',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('Cannot draw fail2ban log table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
var danger_class = ["emerg", "alert", "crit", "err"];
|
||||
var warning_class = ["warning", "warn"];
|
||||
var info_class = ["notice", "info", "debug"];
|
||||
item.message = escapeHtml(item.message);
|
||||
if (jQuery.inArray(item.priority, danger_class) !== -1) {
|
||||
item.priority = '<span class="label label-danger">' + item.priority + '</span>';
|
||||
}
|
||||
else if (jQuery.inArray(item.priority, warning_class) !== -1) {
|
||||
item.priority = '<span class="label label-warning">' + item.priority + '</span>';
|
||||
}
|
||||
else if (jQuery.inArray(item.priority, info_class) !== -1) {
|
||||
item.priority = '<span class="label label-info">' + item.priority + '</span>';
|
||||
}
|
||||
});
|
||||
return process_table_data(data, 'general_syslog');
|
||||
}
|
||||
}),
|
||||
"empty": lang.empty,
|
||||
"paging": {
|
||||
"enabled": true,
|
||||
"limit": 5,
|
||||
"size": log_pagination_size
|
||||
},
|
||||
"filtering": {
|
||||
"enabled": true,
|
||||
"position": "left",
|
||||
"connectors": false,
|
||||
"placeholder": lang.filter_table
|
||||
},
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
"paging": {"enabled": true,"limit": 5,"size": log_pagination_size},
|
||||
"filtering": {"enabled": true,"position": "left","connectors": false,"placeholder": lang.filter_table},
|
||||
"sorting": {"enabled": true},
|
||||
"on": {
|
||||
"ready.ft.table": function(e, ft){
|
||||
heading = ft.$el.parents('.tab-pane').find('.panel-heading')
|
||||
$(heading).children('.log-lines').text(function(){
|
||||
var ft_paging = ft.use(FooTable.Paging)
|
||||
return ft_paging.totalRows;
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -300,48 +141,32 @@ jQuery(function($){
|
||||
],
|
||||
"rows": $.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/logs/sogo/1000',
|
||||
url: '/api/v1/get/logs/sogo',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('Cannot draw sogo log table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
var danger_class = ["emerg", "alert", "crit", "err"];
|
||||
var warning_class = ["warning", "warn"];
|
||||
var info_class = ["notice", "info", "debug"];
|
||||
item.message = escapeHtml(item.message);
|
||||
if (jQuery.inArray(item.priority, danger_class) !== -1) {
|
||||
item.priority = '<span class="label label-danger">' + item.priority + '</span>';
|
||||
}
|
||||
else if (jQuery.inArray(item.priority, warning_class) !== -1) {
|
||||
item.priority = '<span class="label label-warning">' + item.priority + '</span>';
|
||||
}
|
||||
else if (jQuery.inArray(item.priority, info_class) !== -1) {
|
||||
item.priority = '<span class="label label-info">' + item.priority + '</span>';
|
||||
}
|
||||
});
|
||||
return process_table_data(data, 'general_syslog');
|
||||
}
|
||||
}),
|
||||
"empty": lang.empty,
|
||||
"paging": {
|
||||
"enabled": true,
|
||||
"limit": 5,
|
||||
"size": log_pagination_size
|
||||
},
|
||||
"filtering": {
|
||||
"enabled": true,
|
||||
"position": "left",
|
||||
"connectors": false,
|
||||
"placeholder": lang.filter_table
|
||||
},
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
"paging": {"enabled": true,"limit": 5,"size": log_pagination_size},
|
||||
"filtering": {"enabled": true,"position": "left","connectors": false,"placeholder": lang.filter_table},
|
||||
"sorting": {"enabled": true},
|
||||
"on": {
|
||||
"ready.ft.table": function(e, ft){
|
||||
heading = ft.$el.parents('.tab-pane').find('.panel-heading')
|
||||
$(heading).children('.log-lines').text(function(){
|
||||
var ft_paging = ft.use(FooTable.Paging)
|
||||
return ft_paging.totalRows;
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function draw_dovecot_logs() {
|
||||
ft_postfix_logs = FooTable.init('#dovecot_log', {
|
||||
ft_dovecot_logs = FooTable.init('#dovecot_log', {
|
||||
"columns": [
|
||||
{"name":"time","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.time,"style":{"width":"170px"}},
|
||||
{"name":"priority","title":lang.priority,"style":{"width":"80px"}},
|
||||
@@ -349,43 +174,27 @@ jQuery(function($){
|
||||
],
|
||||
"rows": $.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/logs/dovecot/1000',
|
||||
url: '/api/v1/get/logs/dovecot',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('Cannot draw dovecot log table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
var danger_class = ["emerg", "alert", "crit", "err"];
|
||||
var warning_class = ["warning", "warn"];
|
||||
var info_class = ["notice", "info", "debug"];
|
||||
item.message = escapeHtml(item.message);
|
||||
if (jQuery.inArray(item.priority, danger_class) !== -1) {
|
||||
item.priority = '<span class="label label-danger">' + item.priority + '</span>';
|
||||
}
|
||||
else if (jQuery.inArray(item.priority, warning_class) !== -1) {
|
||||
item.priority = '<span class="label label-warning">' + item.priority + '</span>';
|
||||
}
|
||||
else if (jQuery.inArray(item.priority, info_class) !== -1) {
|
||||
item.priority = '<span class="label label-info">' + item.priority + '</span>';
|
||||
}
|
||||
});
|
||||
return process_table_data(data, 'general_syslog');
|
||||
}
|
||||
}),
|
||||
"empty": lang.empty,
|
||||
"paging": {
|
||||
"enabled": true,
|
||||
"limit": 5,
|
||||
"size": log_pagination_size
|
||||
},
|
||||
"filtering": {
|
||||
"enabled": true,
|
||||
"position": "left",
|
||||
"connectors": false,
|
||||
"placeholder": lang.filter_table
|
||||
},
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
"paging": {"enabled": true,"limit": 5,"size": log_pagination_size},
|
||||
"filtering": {"enabled": true,"position": "left","connectors": false,"placeholder": lang.filter_table},
|
||||
"sorting": {"enabled": true},
|
||||
"on": {
|
||||
"ready.ft.table": function(e, ft){
|
||||
heading = ft.$el.parents('.tab-pane').find('.panel-heading')
|
||||
$(heading).children('.log-lines').text(function(){
|
||||
var ft_paging = ft.use(FooTable.Paging)
|
||||
return ft_paging.totalRows;
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -407,30 +216,14 @@ jQuery(function($){
|
||||
console.log('Cannot draw domain admin table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
item.chkbox = '<input type="checkbox" data-id="domain_admins" name="multi_select" value="' + item.username + '" />';
|
||||
item.action = '<div class="btn-group">' +
|
||||
'<a href="/edit.php?domainadmin=' + encodeURI(item.username) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
|
||||
'<a href="#" id="delete_selected" data-id="single-domain-admin" data-api-url="delete/domain-admin" data-item="' + encodeURI(item.username) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
||||
'</div>';
|
||||
});
|
||||
return process_table_data(data, 'domainadminstable');
|
||||
}
|
||||
}),
|
||||
"empty": lang.empty,
|
||||
"paging": {
|
||||
"enabled": true,
|
||||
"limit": 5,
|
||||
"size": log_pagination_size
|
||||
"paging": {"enabled": true,"limit": 5,"size": log_pagination_size},
|
||||
"filtering": {"enabled": true,"position": "left","connectors": false,"placeholder": lang.filter_table
|
||||
},
|
||||
"filtering": {
|
||||
"enabled": true,
|
||||
"position": "left",
|
||||
"connectors": false,
|
||||
"placeholder": lang.filter_table
|
||||
},
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
}
|
||||
"sorting": {"enabled": true}
|
||||
});
|
||||
}
|
||||
function draw_fwd_hosts() {
|
||||
@@ -450,33 +243,16 @@ jQuery(function($){
|
||||
console.log('Cannot draw forwarding hosts table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
item.action = '<div class="btn-group">' +
|
||||
'<a href="#" id="delete_selected" data-id="single-fwdhost" data-api-url="delete/fwdhost" data-item="' + encodeURI(item.host) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
||||
'</div>';
|
||||
if (item.keep_spam == "yes") {
|
||||
item.keep_spam = lang.no;
|
||||
}
|
||||
else {
|
||||
item.keep_spam = lang.yes;
|
||||
}
|
||||
item.chkbox = '<input type="checkbox" data-id="fwdhosts" name="multi_select" value="' + item.host + '" />';
|
||||
});
|
||||
return process_table_data(data, 'forwardinghoststable');
|
||||
}
|
||||
}),
|
||||
"empty": lang.empty,
|
||||
"paging": {
|
||||
"enabled": true,
|
||||
"limit": 5,
|
||||
"size": log_pagination_size
|
||||
},
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
}
|
||||
"paging": {"enabled": true,"limit": 5,"size": log_pagination_size},
|
||||
"sorting": {"enabled": true}
|
||||
});
|
||||
}
|
||||
function draw_relayhosts() {
|
||||
ft_forwardinghoststable = FooTable.init('#relayhoststable', {
|
||||
ft_relayhoststable = FooTable.init('#relayhoststable', {
|
||||
"columns": [
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"name":"id","type":"text","title":"ID","style":{"width":"50px"}},
|
||||
@@ -494,115 +270,30 @@ jQuery(function($){
|
||||
console.log('Cannot draw forwarding hosts table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
item.action = '<div class="btn-group">' +
|
||||
'<a href="#" data-toggle="modal" id="miau" data-target="#testRelayhostModal" data-relayhost-id="' + encodeURI(item.id) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-stats"></span> Test</a>' +
|
||||
'<a href="/edit.php?relayhost=' + encodeURI(item.id) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
|
||||
'<a href="#" id="delete_selected" data-id="single-rlshost" data-api-url="delete/relayhost" data-item="' + encodeURI(item.id) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
||||
'</div>';
|
||||
item.chkbox = '<input type="checkbox" data-id="rlyhosts" name="multi_select" value="' + item.id + '" />';
|
||||
});
|
||||
return process_table_data(data, 'relayhoststable');
|
||||
}
|
||||
}),
|
||||
"empty": lang.empty,
|
||||
"paging": {
|
||||
"enabled": true,
|
||||
"limit": 5,
|
||||
"size": log_pagination_size
|
||||
},
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
}
|
||||
"paging": {"enabled": true,"limit": 5,"size": log_pagination_size},
|
||||
"sorting": {"enabled": true}
|
||||
});
|
||||
}
|
||||
function draw_rspamd_history() {
|
||||
ft_postfix_logs = FooTable.init('#rspamd_history', {
|
||||
"columns": [{
|
||||
"name":"unix_time",
|
||||
"formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},
|
||||
"title":lang.time,
|
||||
"style":{
|
||||
"width":"170px"
|
||||
}
|
||||
}, {
|
||||
"name": "ip",
|
||||
"title": "IP address",
|
||||
"breakpoints": "all",
|
||||
"style": {
|
||||
"minWidth": 88
|
||||
}
|
||||
}, {
|
||||
"name": "sender_mime",
|
||||
"title": "From",
|
||||
"breakpoints": "xs sm md",
|
||||
"style": {
|
||||
"minWidth": 100
|
||||
}
|
||||
}, {
|
||||
"name": "rcpt_mime",
|
||||
"title": "To",
|
||||
"breakpoints": "xs sm md",
|
||||
"style": {
|
||||
"minWidth": 100
|
||||
}
|
||||
}, {
|
||||
"name": "subject",
|
||||
"title": "Subject",
|
||||
"breakpoints": "all",
|
||||
"style": {
|
||||
"word-break": "break-all",
|
||||
"minWidth": 150
|
||||
}
|
||||
}, {
|
||||
"name": "action",
|
||||
"title": "Action",
|
||||
"style": {
|
||||
"minwidth": 82
|
||||
}
|
||||
}, {
|
||||
"name": "score",
|
||||
"title": "Score",
|
||||
"style": {
|
||||
"maxWidth": 110
|
||||
},
|
||||
}, {
|
||||
"name": "symbols",
|
||||
"title": "Symbols",
|
||||
"breakpoints": "all",
|
||||
}, {
|
||||
"name": "size",
|
||||
"title": "Msg size",
|
||||
"breakpoints": "all",
|
||||
"style": {
|
||||
"minwidth": 50,
|
||||
},
|
||||
"formatter": function(value) { return humanFileSize(value); }
|
||||
}, {
|
||||
"name": "scan_time",
|
||||
"title": "Scan time",
|
||||
"breakpoints": "all",
|
||||
"style": {
|
||||
"maxWidth": 72
|
||||
},
|
||||
}, {
|
||||
"name": "message-id",
|
||||
"title": "ID",
|
||||
"breakpoints": "all",
|
||||
"style": {
|
||||
"minWidth": 130,
|
||||
"overflow": "hidden",
|
||||
"textOverflow": "ellipsis",
|
||||
"wordBreak": "break-all",
|
||||
"whiteSpace": "normal"
|
||||
}
|
||||
}, {
|
||||
"name": "user",
|
||||
"title": "Authenticated user",
|
||||
"breakpoints": "xs sm md",
|
||||
"style": {
|
||||
"minWidth": 100
|
||||
}
|
||||
}],
|
||||
ft_rspamd_history = FooTable.init('#rspamd_history', {
|
||||
"columns": [
|
||||
{"name":"unix_time","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.time,"style":{"width":"170px"}},
|
||||
{"name": "ip","title": "IP address","breakpoints": "all","style": {"minWidth": 88}},
|
||||
{"name": "sender_mime","title": "From","breakpoints": "xs sm md","style": {"minWidth": 100}},
|
||||
{"name": "rcpt_mime","title": "To","breakpoints": "xs sm md","style": {"minWidth": 100}},
|
||||
{"name": "subject","title": "Subject","breakpoints": "all","style": {"word-break": "break-all","minWidth": 150}},
|
||||
{"name": "action","title": "Action","style": {"minwidth": 82}},
|
||||
{"name": "score","title": "Score","style": {"maxWidth": 110},},
|
||||
{"name": "symbols","title": "Symbols","breakpoints": "all",},
|
||||
{"name": "size","title": "Msg size","breakpoints": "all","style": {"minwidth": 50},"formatter": function(value){return humanFileSize(value);}},
|
||||
{"name": "scan_time","title": "Scan time","breakpoints": "all","style": {"maxWidth": 72},},
|
||||
{"name": "message-id","title": "ID","breakpoints": "all","style": {"minWidth": 130,"overflow": "hidden","textOverflow": "ellipsis","wordBreak": "break-all","whiteSpace": "normal"}},
|
||||
{"name": "user","title": "Authenticated user","breakpoints": "xs sm md","style": {"minWidth": 100}}
|
||||
],
|
||||
"rows": $.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/logs/rspamd-history',
|
||||
@@ -611,81 +302,146 @@ jQuery(function($){
|
||||
console.log('Cannot draw rspamd history table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
item.rcpt_mime = item.rcpt_mime.join(",​");
|
||||
Object.keys(item.symbols).map(function(key) {
|
||||
var sym = item.symbols[key];
|
||||
if (sym.score <= 0) {
|
||||
sym.score_formatted = '(<span class="text-success"><b>' + sym.score + '</b></span>)'
|
||||
}
|
||||
else {
|
||||
sym.score_formatted = '(<span class="text-danger"><b>' + sym.score + '</b></span>)'
|
||||
}
|
||||
var str = '<strong>' + key + '</strong> ' + sym.score_formatted;
|
||||
if (sym.options) {
|
||||
str += ' [' + sym.options.join(",") + "]";
|
||||
}
|
||||
item.symbols[key].str = str;
|
||||
});
|
||||
item.symbols = Object.keys(item.symbols).
|
||||
map(function(key) {
|
||||
return item.symbols[key];
|
||||
}).sort(function(e1, e2) {
|
||||
return Math.abs(e1.score) < Math.abs(e2.score);
|
||||
}).map(function(e) {
|
||||
return e.str;
|
||||
}).join("<br>\n");
|
||||
var scan_time = item.time_real.toFixed(3) + ' / ' + item.time_virtual.toFixed(3);
|
||||
item.scan_time = {
|
||||
"options": {
|
||||
"sortValue": item.time_real
|
||||
},
|
||||
"value": scan_time
|
||||
};
|
||||
if (item.action === 'clean' || item.action === 'no action') {
|
||||
item.action = "<div class='label label-success'>" + item.action + "</div>";
|
||||
} else if (item.action === 'rewrite subject' || item.action === 'add header' || item.action === 'probable spam') {
|
||||
item.action = "<div class='label label-warning'>" + item.action + "</div>";
|
||||
} else if (item.action === 'spam' || item.action === 'reject') {
|
||||
item.action = "<div class='label label-danger'>" + item.action + "</div>";
|
||||
} else {
|
||||
item.action = "<div class='label label-info'>" + item.action + "</div>";
|
||||
}
|
||||
var score_content;
|
||||
if (item.score < item.required_score) {
|
||||
score_content = "[ <span class='text-success'>" + item.score.toFixed(2) + " / " + item.required_score + "</span> ]";
|
||||
} else {
|
||||
score_content = "[ <span class='text-danger'>" + item.score.toFixed(2) + " / " + item.required_score + "</span> ]";
|
||||
}
|
||||
item.score = {
|
||||
"options": {
|
||||
"sortValue": item.score
|
||||
},
|
||||
"value": score_content
|
||||
};
|
||||
if (item.user == null) {
|
||||
item.user = "none";
|
||||
}
|
||||
});
|
||||
return process_table_data(data, 'rspamd_history');
|
||||
}
|
||||
}),
|
||||
"empty": lang.empty,
|
||||
"paging": {
|
||||
"enabled": true,
|
||||
"limit": 5,
|
||||
"size": log_pagination_size
|
||||
},
|
||||
"filtering": {
|
||||
"enabled": true,
|
||||
"position": "left",
|
||||
"connectors": false,
|
||||
"placeholder": lang.filter_table
|
||||
},
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
"paging": {"enabled": true,"limit": 5,"size": log_pagination_size},
|
||||
"filtering": {"enabled": true,"position": "left","connectors": false,"placeholder": lang.filter_table},
|
||||
"sorting": {"enabled": true},
|
||||
"on": {
|
||||
"ready.ft.table": function(e, ft){
|
||||
heading = ft.$el.parents('.tab-pane').find('.panel-heading')
|
||||
$(heading).children('.log-lines').text(function(){
|
||||
var ft_paging = ft.use(FooTable.Paging)
|
||||
return ft_paging.totalRows;
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function process_table_data(data, table) {
|
||||
if (table == 'rspamd_history') {
|
||||
$.each(data, function (i, item) {
|
||||
item.rcpt_mime = item.rcpt_mime.join(",​");
|
||||
Object.keys(item.symbols).map(function(key) {
|
||||
var sym = item.symbols[key];
|
||||
if (sym.score <= 0) {
|
||||
sym.score_formatted = '(<span class="text-success"><b>' + sym.score + '</b></span>)'
|
||||
}
|
||||
else {
|
||||
sym.score_formatted = '(<span class="text-danger"><b>' + sym.score + '</b></span>)'
|
||||
}
|
||||
var str = '<strong>' + key + '</strong> ' + sym.score_formatted;
|
||||
if (sym.options) {
|
||||
str += ' [' + sym.options.join(",") + "]";
|
||||
}
|
||||
item.symbols[key].str = str;
|
||||
});
|
||||
item.symbols = Object.keys(item.symbols).
|
||||
map(function(key) {
|
||||
return item.symbols[key];
|
||||
}).sort(function(e1, e2) {
|
||||
return Math.abs(e1.score) < Math.abs(e2.score);
|
||||
}).map(function(e) {
|
||||
return e.str;
|
||||
}).join("<br>\n");
|
||||
var scan_time = item.time_real.toFixed(3) + ' / ' + item.time_virtual.toFixed(3);
|
||||
item.scan_time = {
|
||||
"options": {
|
||||
"sortValue": item.time_real
|
||||
},
|
||||
"value": scan_time
|
||||
};
|
||||
if (item.action === 'clean' || item.action === 'no action') {
|
||||
item.action = "<div class='label label-success'>" + item.action + "</div>";
|
||||
} else if (item.action === 'rewrite subject' || item.action === 'add header' || item.action === 'probable spam') {
|
||||
item.action = "<div class='label label-warning'>" + item.action + "</div>";
|
||||
} else if (item.action === 'spam' || item.action === 'reject') {
|
||||
item.action = "<div class='label label-danger'>" + item.action + "</div>";
|
||||
} else {
|
||||
item.action = "<div class='label label-info'>" + item.action + "</div>";
|
||||
}
|
||||
var score_content;
|
||||
if (item.score < item.required_score) {
|
||||
score_content = "[ <span class='text-success'>" + item.score.toFixed(2) + " / " + item.required_score + "</span> ]";
|
||||
} else {
|
||||
score_content = "[ <span class='text-danger'>" + item.score.toFixed(2) + " / " + item.required_score + "</span> ]";
|
||||
}
|
||||
item.score = {
|
||||
"options": {
|
||||
"sortValue": item.score
|
||||
},
|
||||
"value": score_content
|
||||
};
|
||||
if (item.user == null) {
|
||||
item.user = "none";
|
||||
}
|
||||
});
|
||||
} else if (table == 'relayhoststable') {
|
||||
$.each(data, function (i, item) {
|
||||
item.action = '<div class="btn-group">' +
|
||||
'<a href="#" data-toggle="modal" id="miau" data-target="#testRelayhostModal" data-relayhost-id="' + encodeURI(item.id) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-stats"></span> Test</a>' +
|
||||
'<a href="/edit.php?relayhost=' + encodeURI(item.id) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
|
||||
'<a href="#" id="delete_selected" data-id="single-rlshost" data-api-url="delete/relayhost" data-item="' + encodeURI(item.id) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
||||
'</div>';
|
||||
item.chkbox = '<input type="checkbox" data-id="rlyhosts" name="multi_select" value="' + item.id + '" />';
|
||||
});
|
||||
} else if (table == 'forwardinghoststable') {
|
||||
$.each(data, function (i, item) {
|
||||
item.action = '<div class="btn-group">' +
|
||||
'<a href="#" id="delete_selected" data-id="single-fwdhost" data-api-url="delete/fwdhost" data-item="' + encodeURI(item.host) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
||||
'</div>';
|
||||
if (item.keep_spam == "yes") {
|
||||
item.keep_spam = lang.no;
|
||||
}
|
||||
else {
|
||||
item.keep_spam = lang.yes;
|
||||
}
|
||||
item.chkbox = '<input type="checkbox" data-id="fwdhosts" name="multi_select" value="' + item.host + '" />';
|
||||
});
|
||||
} else if (table == 'domainadminstable') {
|
||||
$.each(data, function (i, item) {
|
||||
item.chkbox = '<input type="checkbox" data-id="domain_admins" name="multi_select" value="' + item.username + '" />';
|
||||
item.action = '<div class="btn-group">' +
|
||||
'<a href="/edit.php?domainadmin=' + encodeURI(item.username) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
|
||||
'<a href="#" id="delete_selected" data-id="single-domain-admin" data-api-url="delete/domain-admin" data-item="' + encodeURI(item.username) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
||||
'</div>';
|
||||
});
|
||||
} else if (table == 'autodiscover_log') {
|
||||
$.each(data, function (i, item) {
|
||||
item.ua = '<span style="font-size:small">' + item.ua + '</span>';
|
||||
if (item.service == "activesync") {
|
||||
item.service = '<span class="label label-info">ActiveSync</span>';
|
||||
}
|
||||
else if (item.service == "imap") {
|
||||
item.service = '<span class="label label-success">IMAP, SMTP, Cal-/CardDAV</span>';
|
||||
}
|
||||
else {
|
||||
item.service = '<span class="label label-danger">' + item.service + '</span>';
|
||||
}
|
||||
});
|
||||
} else if (table == 'general_syslog') {
|
||||
$.each(data, function (i, item) {
|
||||
item.message = escapeHtml(item.message);
|
||||
var danger_class = ["emerg", "alert", "crit", "err"];
|
||||
var warning_class = ["warning", "warn"];
|
||||
var info_class = ["notice", "info", "debug"];
|
||||
if (jQuery.inArray(item.priority, danger_class) !== -1) {
|
||||
item.priority = '<span class="label label-danger">' + item.priority + '</span>';
|
||||
}
|
||||
else if (jQuery.inArray(item.priority, warning_class) !== -1) {
|
||||
item.priority = '<span class="label label-warning">' + item.priority + '</span>';
|
||||
}
|
||||
else if (jQuery.inArray(item.priority, info_class) !== -1) {
|
||||
item.priority = '<span class="label label-info">' + item.priority + '</span>';
|
||||
}
|
||||
});
|
||||
}
|
||||
return data
|
||||
};
|
||||
// Initial table drawings
|
||||
draw_postfix_logs();
|
||||
draw_autodiscover_logs();
|
||||
draw_dovecot_logs();
|
||||
@@ -695,7 +451,7 @@ jQuery(function($){
|
||||
draw_fwd_hosts();
|
||||
draw_relayhosts();
|
||||
draw_rspamd_history();
|
||||
|
||||
// Relayhost
|
||||
$('#testRelayhostModal').on('show.bs.modal', function (e) {
|
||||
$('#test_relayhost_result').text("-");
|
||||
button = $(e.relatedTarget)
|
||||
@@ -703,16 +459,6 @@ jQuery(function($){
|
||||
$('#relayhost_id').val(button.data('relayhost-id'));
|
||||
}
|
||||
})
|
||||
|
||||
$('#showDKIMprivKey').on('show.bs.modal', function (e) {
|
||||
$('#priv_key_pre').text("-");
|
||||
p_related = $(e.relatedTarget)
|
||||
if (p_related != null) {
|
||||
var decoded_key = Base64.decode((p_related.data('priv-key')));
|
||||
$('#priv_key_pre').text(decoded_key);
|
||||
}
|
||||
})
|
||||
|
||||
$('#test_relayhost').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
prev = $('#test_relayhost').text();
|
||||
@@ -730,7 +476,41 @@ jQuery(function($){
|
||||
}
|
||||
});
|
||||
})
|
||||
// DKIM private key modal
|
||||
$('#showDKIMprivKey').on('show.bs.modal', function (e) {
|
||||
$('#priv_key_pre').text("-");
|
||||
p_related = $(e.relatedTarget)
|
||||
if (p_related != null) {
|
||||
var decoded_key = Base64.decode((p_related.data('priv-key')));
|
||||
$('#priv_key_pre').text(decoded_key);
|
||||
}
|
||||
})
|
||||
|
||||
$('.add_log_lines').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var log_table= $(this).data("table")
|
||||
var new_nrows = ($(this).data("nrows") - 1)
|
||||
var post_process = $(this).data("post-process")
|
||||
var log_url = $(this).data("log-url")
|
||||
if (log_table === undefined || new_nrows === undefined || post_process === undefined || log_url === undefined) {
|
||||
console.log("no data-table or data-nrows or log_url or data-post-process attr found");
|
||||
return;
|
||||
}
|
||||
if (ft = FooTable.get($('#' + log_table))) {
|
||||
var heading = ft.$el.parents('.tab-pane').find('.panel-heading')
|
||||
var ft_paging = ft.use(FooTable.Paging)
|
||||
var load_rows = ft_paging.totalRows + '-' + (ft_paging.totalRows + new_nrows)
|
||||
$.get('/api/v1/get/logs/' + log_url + '/' + load_rows).then(function(data){
|
||||
if (data.length === undefined) { mailcow_alert_box(lang.no_new_rows, "info"); return; }
|
||||
var rows = process_table_data(data, post_process);
|
||||
var rows_now = (ft_paging.totalRows + data.length);
|
||||
$(heading).children('.log-lines').text(rows_now)
|
||||
mailcow_alert_box(data.length + lang.additional_rows, "success");
|
||||
ft.rows.load(rows, true);
|
||||
});
|
||||
}
|
||||
})
|
||||
// App links
|
||||
function add_table_row(table_id) {
|
||||
var row = $('<tr />');
|
||||
cols = '<td><input class="input-sm form-control" data-id="app_links" type="text" name="app" required></td>';
|
||||
@@ -739,17 +519,14 @@ jQuery(function($){
|
||||
row.append(cols);
|
||||
table_id.append(row);
|
||||
}
|
||||
|
||||
$('#app_link_table').on('click', 'tr a', function (e) {
|
||||
e.preventDefault();
|
||||
$(this).parents('tr').remove();
|
||||
});
|
||||
|
||||
$('#add_app_link_row').click(function() {
|
||||
add_table_row($('#app_link_table'));
|
||||
});
|
||||
});
|
||||
|
||||
$(window).load(function(){
|
||||
initial_width = $("#sidebar-admin").width();
|
||||
$("#scrollbox").css("width", initial_width);
|
||||
@@ -761,13 +538,10 @@ $(window).load(function(){
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function resizeScrollbox() {
|
||||
on_resize_width = $("#sidebar-admin").width();
|
||||
$("#scrollbox").removeAttr("style");
|
||||
$("#scrollbox").css("width", on_resize_width);
|
||||
}
|
||||
|
||||
$(window).on('resize', resizeScrollbox);
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', resizeScrollbox);
|
||||
|
||||
|
@@ -61,6 +61,11 @@ $(document).ready(function() {
|
||||
var id = $(this).data('id');
|
||||
var api_url = $(this).data('api-url');
|
||||
var api_attr = $(this).data('api-attr');
|
||||
if (typeof $(this).data('api-reload-window') !== 'undefined') {
|
||||
api_reload_window = $(this).data('api-reload-window');
|
||||
} else {
|
||||
api_reload_window = true;
|
||||
}
|
||||
// If clicked element #edit_selected is in a form with the same data-id as the button,
|
||||
// we merge all input fields by {"name":"value"} into api-attr
|
||||
if ($(this).closest("form").data('id') == id) {
|
||||
@@ -106,10 +111,10 @@ $(document).ready(function() {
|
||||
jsonp: false,
|
||||
complete: function(data) {
|
||||
var response = (data.responseText);
|
||||
// alert(response);
|
||||
// console.log(reponse.type);
|
||||
// console.log(reponse.msg);
|
||||
window.location = window.location.href.split("#")[0];
|
||||
response_obj = JSON.parse(response);
|
||||
if (api_reload_window === true) {
|
||||
window.location = window.location.href.split("#")[0];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ $(document).ready(function() {
|
||||
$("#textarea_alias_goto").removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
$("#script_data").numberedtextarea({allowTabChar: true});
|
||||
});
|
||||
|
||||
jQuery(function($){
|
||||
|
@@ -40,10 +40,61 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
// Log modal
|
||||
$('#logModal').on('show.bs.modal', function(e) {
|
||||
var logText = $(e.relatedTarget).data('log-text');
|
||||
$(e.currentTarget).find('#logText').html('<pre style="background:none;font-size:11px;line-height:1.1;border:0px">' + logText + '</pre>');
|
||||
$('#syncjobLogModal').on('show.bs.modal', function(e) {
|
||||
var syncjob_id = $(e.relatedTarget).data('syncjob-id');
|
||||
$.ajax({
|
||||
url: '/inc/ajax/syncjob_logs.php',
|
||||
data: { id: syncjob_id },
|
||||
dataType: 'text',
|
||||
success: function(data){
|
||||
$(e.currentTarget).find('#logText').text(data);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
$(e.currentTarget).find('#logText').text(xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Sieve data modal
|
||||
$('#sieveDataModal').on('show.bs.modal', function(e) {
|
||||
var sieveScript = $(e.relatedTarget).data('sieve-script');
|
||||
$(e.currentTarget).find('#sieveDataText').html('<pre style="font-size:14px;line-height:1.1">' + sieveScript + '</pre>');
|
||||
});
|
||||
|
||||
// Set line numbers for textarea
|
||||
$("#script_data").numberedtextarea({allowTabChar: true});
|
||||
// Disable submit button on script change
|
||||
$('#script_data').on('keyup', function() {
|
||||
$('#add_filter_btns > #add_item').attr({"disabled": true});
|
||||
$('#validation_msg').html('-');
|
||||
});
|
||||
|
||||
// Validate script data
|
||||
$("#validate_sieve").click(function( event ) {
|
||||
event.preventDefault();
|
||||
var script = $('#script_data').val();
|
||||
$.ajax({
|
||||
dataType: 'jsonp',
|
||||
url: "/inc/ajax/sieve_validation.php",
|
||||
type: "get",
|
||||
data: { script: script },
|
||||
complete: function(data) {
|
||||
var response = (data.responseText);
|
||||
response_obj = JSON.parse(response);
|
||||
if (response_obj.type == "success") {
|
||||
$('#add_filter_btns > #add_item').attr({"disabled": false});
|
||||
}
|
||||
mailcow_alert_box(response_obj.msg, response_obj.type);
|
||||
},
|
||||
});
|
||||
});
|
||||
// $(document).on('DOMNodeInserted', '#prefilter_table', function () {
|
||||
// $("#active-script").closest('td').css('background-color','#b0f0a0');
|
||||
// $("#inactive-script").closest('td').css('background-color','#b0f0a0');
|
||||
// });
|
||||
|
||||
|
||||
|
||||
});
|
||||
jQuery(function($){
|
||||
// http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
||||
@@ -87,7 +138,7 @@ jQuery(function($){
|
||||
function draw_domain_table() {
|
||||
ft_domain_table = FooTable.init('#domain_table', {
|
||||
"columns": [
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"sorted": true,"name":"domain_name","title":lang.domain,"style":{"width":"250px"}},
|
||||
{"name":"aliases","title":lang.aliases,"breakpoints":"xs sm"},
|
||||
{"name":"mailboxes","title":lang.mailboxes},
|
||||
@@ -152,7 +203,7 @@ jQuery(function($){
|
||||
function draw_mailbox_table() {
|
||||
ft_mailbox_table = FooTable.init('#mailbox_table', {
|
||||
"columns": [
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"sorted": true,"name":"username","style":{"word-break":"break-all","min-width":"120px"},"title":lang.username},
|
||||
{"name":"name","title":lang.fname,"style":{"word-break":"break-all","min-width":"120px"},"breakpoints":"xs sm"},
|
||||
{"name":"domain","title":lang.domain,"breakpoints":"xs sm"},
|
||||
@@ -222,7 +273,7 @@ jQuery(function($){
|
||||
function draw_resource_table() {
|
||||
ft_resource_table = FooTable.init('#resource_table', {
|
||||
"columns": [
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"sorted": true,"name":"description","title":lang.description,"style":{"width":"250px"}},
|
||||
{"name":"kind","title":lang.kind},
|
||||
{"name":"domain","title":lang.domain,"breakpoints":"xs sm"},
|
||||
@@ -267,7 +318,7 @@ jQuery(function($){
|
||||
function draw_alias_table() {
|
||||
ft_alias_table = FooTable.init('#alias_table', {
|
||||
"columns": [
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"sorted": true,"name":"address","title":lang.alias,"style":{"width":"250px"}},
|
||||
{"name":"goto","title":lang.target_address},
|
||||
{"name":"domain","title":lang.domain,"breakpoints":"xs sm"},
|
||||
@@ -320,7 +371,7 @@ jQuery(function($){
|
||||
function draw_aliasdomain_table() {
|
||||
ft_aliasdomain_table = FooTable.init('#aliasdomain_table', {
|
||||
"columns": [
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"sorted": true,"name":"alias_domain","title":lang.alias,"style":{"width":"250px"}},
|
||||
{"name":"target_domain","title":lang.target_domain},
|
||||
{"name":"active","filterable": false,"style":{"maxWidth":"50px","width":"70px"},"title":lang.active},
|
||||
@@ -363,7 +414,7 @@ jQuery(function($){
|
||||
function draw_sync_job_table() {
|
||||
ft_syncjob_table = FooTable.init('#sync_job_table', {
|
||||
"columns": [
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
|
||||
{"name":"user2","title":lang.owner},
|
||||
{"name":"server_w_port","title":"Server","breakpoints":"xs"},
|
||||
@@ -376,14 +427,14 @@ jQuery(function($){
|
||||
"empty": lang.empty,
|
||||
"rows": $.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/syncjobs/all',
|
||||
url: '/api/v1/get/syncjobs/all/no_log',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('Cannot draw sync job table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
item.log = '<a href="#logModal" data-toggle="modal" data-log-text="' + escapeHtml(item.returned_text) + '">Open logs</a>'
|
||||
item.log = '<a href="#syncjobLogModal" data-toggle="modal" data-syncjob-id="' + encodeURI(item.id) + '">Open logs</a>'
|
||||
item.exclude = '<code>' + item.exclude + '</code>'
|
||||
item.server_w_port = item.user1 + '@' + item.host1 + ':' + item.port1;
|
||||
item.action = '<div class="btn-group">' +
|
||||
@@ -399,16 +450,76 @@ jQuery(function($){
|
||||
"limit": 5,
|
||||
"size": pagination_size
|
||||
},
|
||||
"filtering": {
|
||||
"enabled": true,
|
||||
"position": "left",
|
||||
"placeholder": lang.filter_table
|
||||
},
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function draw_filter_table() {
|
||||
ft_filter_table = FooTable.init('#filter_table', {
|
||||
"columns": [
|
||||
{"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
|
||||
{"name":"active","style":{"maxWidth":"80px","width":"80px"},"title":lang.active},
|
||||
{"name":"filter_type","style":{"maxWidth":"80px","width":"80px"},"title":"Type"},
|
||||
{"sorted": true,"name":"username","title":lang.owner,"style":{"maxWidth":"550px","width":"350px"}},
|
||||
{"name":"script_desc","title":lang.description,"breakpoints":"xs"},
|
||||
{"name":"script_data","title":"Script","breakpoints":"all"},
|
||||
{"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
||||
],
|
||||
"empty": lang.empty,
|
||||
"rows": $.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/filters/all',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('Cannot draw filter table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
if (item.active_int == 1) {
|
||||
item.active = '<span id="active-script" class="label label-success">' + lang.active + '</span>';
|
||||
} else {
|
||||
item.active = '<span id="inactive-script" class="label label-warning">' + lang.inactive + '</span>';
|
||||
}
|
||||
item.script_data = '<pre style="margin:0px">' + escapeHtml(item.script_data) + '</pre>'
|
||||
item.filter_type = '<div class="label label-default">' + item.filter_type.charAt(0).toUpperCase() + item.filter_type.slice(1).toLowerCase() + '</div>'
|
||||
item.action = '<div class="btn-group">' +
|
||||
'<a href="/edit.php?filter=' + item.id + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
|
||||
'<a href="#" id="delete_selected" data-id="single-filter" data-api-url="delete/filter" data-item="' + encodeURI(item.id) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
||||
'</div>';
|
||||
item.chkbox = '<input type="checkbox" data-id="filter_item" name="multi_select" value="' + item.id + '" />'
|
||||
});
|
||||
}
|
||||
}),
|
||||
"paging": {
|
||||
"enabled": true,
|
||||
"limit": 5,
|
||||
"size": pagination_size
|
||||
},
|
||||
"filtering": {
|
||||
"enabled": true,
|
||||
"position": "left",
|
||||
"placeholder": lang.filter_table
|
||||
},
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
draw_domain_table();
|
||||
draw_mailbox_table();
|
||||
draw_resource_table();
|
||||
draw_alias_table();
|
||||
draw_aliasdomain_table();
|
||||
draw_sync_job_table();
|
||||
});
|
||||
draw_filter_table();
|
||||
|
||||
});
|
||||
|
1
data/web/js/numberedtextarea.min.js
vendored
Normal file
1
data/web/js/numberedtextarea.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e){function t(t,n){var a=e('<div class="numberedtextarea-wrapper"></div>').insertAfter(t);e(t).detach().appendTo(a)}function n(t,n){(t=e(t)).parents(".numberedtextarea-wrapper");var i=parseFloat(t.css("padding-left")),o=parseFloat(t.css("padding-top")),s=(parseFloat(t.css("padding-bottom")),e('<div class="numberedtextarea-line-numbers"></div>').insertAfter(t));t.css({paddingLeft:i+s.width()+"px"}).on("input propertychange change keyup paste",function(){a(t,n)}).on("scroll",function(){r(t,n)}),s.css({paddingLeft:i+"px",paddingTop:o+"px",lineHeight:t.css("line-height"),fontFamily:t.css("font-family"),width:s.width()-i+"px"}),t.trigger("change")}function a(t,n){var a=(t=e(t)).parent().find(".numberedtextarea-line-numbers"),r=t.val().split("\n").length,o=parseFloat(t.css("padding-bottom"));for(a.find(".numberedtextarea-number").remove(),i=1;i<=r;i++){var s=e('<div class="numberedtextarea-number numberedtextarea-number-'+i+'">'+i+"</div>").appendTo(a);i===r&&s.css("margin-bottom",o+"px")}}function r(t,n){(t=e(t)).parent().find(".numberedtextarea-line-numbers").scrollTop(t.scrollTop())}function o(e,t){if(e.focus(),"number"==typeof e.selectionStart){var n=e.value,a=e.selectionStart;e.value=n.slice(0,a)+t+n.slice(e.selectionEnd),e.selectionEnd=e.selectionStart=a+t.length}else if(void 0!==document.selection){var i=document.selection.createRange();i.text=t,i.collapse(!1),i.select()}}function s(t){e(t).keydown(function(e){if(9==e.which)return o(this,"\t"),!1}),e(t).keypress(function(e){if(9==e.which)return!1})}e.fn.numberedtextarea=function(a){var i=e.extend({color:null,borderColor:null,class:null,allowTabChar:!1},a);return this.each(function(){if("textarea"!==this.nodeName.toLowerCase())return console.log("This is not a <textarea>, so no way Jose..."),!1;t(this,i),n(this,i),i.allowTabChar&&e(this).allowTabChar()}),this},e.fn.allowTabChar=function(){return this.jquery&&this.each(function(){if(1==this.nodeType){var e=this.nodeName.toLowerCase();("textarea"==e||"input"==e&&"text"==this.type)&&s(this)}}),this}}(jQuery);
|
@@ -1,13 +1,19 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
// Log modal
|
||||
$('#logModal').on('show.bs.modal', function(e) {
|
||||
var logText = $(e.relatedTarget).data('log-text');
|
||||
$(e.currentTarget).find('#logText').html('<pre style="background:none;font-size:11px;line-height:1.1;border:0px">' + logText + '</pre>');
|
||||
$('#syncjobLogModal').on('show.bs.modal', function(e) {
|
||||
var syncjob_id = $(e.relatedTarget).data('syncjob-id');
|
||||
$.ajax({
|
||||
url: '/inc/ajax/syncjob_logs.php',
|
||||
data: { id: syncjob_id },
|
||||
dataType: 'text',
|
||||
success: function(data){
|
||||
$(e.currentTarget).find('#logText').text(data);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
$(e.currentTarget).find('#logText').text(xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
jQuery(function($){
|
||||
// http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
||||
var entityMap = {
|
||||
@@ -95,14 +101,14 @@ jQuery(function($){
|
||||
"empty": lang.empty,
|
||||
"rows": $.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/syncjobs/' + mailcow_cc_username,
|
||||
url: '/api/v1/get/syncjobs/' + mailcow_cc_username + '/no_log',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('Cannot draw sync job table');
|
||||
},
|
||||
success: function (data) {
|
||||
$.each(data, function (i, item) {
|
||||
item.log = '<a href="#logModal" data-toggle="modal" data-log-text="' + escapeHtml(item.returned_text) + '">Open logs</a>'
|
||||
item.log = '<a href="#syncjobLogModal" data-toggle="modal" data-syncjob-id="' + encodeURI(item.id) + '">Open logs</a>'
|
||||
item.exclude = '<code>' + item.exclude + '</code>'
|
||||
item.server_w_port = item.user1 + '@' + item.host1 + ':' + item.port1;
|
||||
if (acl_data.syncjobs === 1) {
|
||||
@@ -213,4 +219,27 @@ jQuery(function($){
|
||||
draw_tla_table();
|
||||
draw_wl_policy_mailbox_table();
|
||||
draw_bl_policy_mailbox_table();
|
||||
|
||||
// Sieve data modal
|
||||
$('#userFilterModal').on('show.bs.modal', function(e) {
|
||||
$('#user_sieve_filter').text(lang.loading);
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/active-user-sieve/' + mailcow_cc_username,
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('Cannot get active sieve script');
|
||||
},
|
||||
complete: function (data) {
|
||||
if (data.responseText == '{}') {
|
||||
$('#user_sieve_filter').text(lang.no_active_filter);
|
||||
} else {
|
||||
$('#user_sieve_filter').text(JSON.parse(data.responseText));
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
$('#userFilterModal').on('hidden.bs.modal', function () {
|
||||
$('#user_sieve_filter').text(lang.loading);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user