Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1 | // Base64 functions
|
| 2 | 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}};
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 3 | $(document).ready(function() {
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 4 | // Spam score slider
|
| 5 | var spam_slider = $('#spam_score')[0];
|
| 6 | if (typeof spam_slider !== 'undefined') {
|
| 7 | noUiSlider.create(spam_slider, {
|
| 8 | start: user_spam_score,
|
| 9 | connect: [true, true, true],
|
| 10 | range: {
|
| 11 | 'min': [0], //stepsize is 50.000
|
| 12 | '50%': [10],
|
| 13 | '70%': [20, 5],
|
| 14 | '80%': [50, 10],
|
| 15 | '90%': [100, 100],
|
| 16 | '95%': [1000, 1000],
|
| 17 | 'max': [5000]
|
| 18 | },
|
| 19 | });
|
| 20 | var connect = spam_slider.querySelectorAll('.noUi-connect');
|
| 21 | var classes = ['c-1-color', 'c-2-color', 'c-3-color'];
|
| 22 | for (var i = 0; i < connect.length; i++) {
|
| 23 | connect[i].classList.add(classes[i]);
|
| 24 | }
|
| 25 | spam_slider.noUiSlider.on('update', function (values, handle) {
|
| 26 | $('.spam-ham-score').text('< ' + Math.round(values[0] * 10) / 10);
|
| 27 | $('.spam-spam-score').text(Math.round(values[0] * 10) / 10 + ' - ' + Math.round(values[1] * 10) / 10);
|
| 28 | $('.spam-reject-score').text('> ' + Math.round(values[1] * 10) / 10);
|
| 29 | $('#spam_score_value').val((Math.round(values[0] * 10) / 10) + ',' + (Math.round(values[1] * 10) / 10));
|
| 30 | });
|
| 31 | }
|
| 32 | // syncjobLogModal
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 33 | $('#syncjobLogModal').on('show.bs.modal', function(e) {
|
| 34 | var syncjob_id = $(e.relatedTarget).data('syncjob-id');
|
| 35 | $.ajax({
|
| 36 | url: '/inc/ajax/syncjob_logs.php',
|
| 37 | data: { id: syncjob_id },
|
| 38 | dataType: 'text',
|
| 39 | success: function(data){
|
| 40 | $(e.currentTarget).find('#logText').text(data);
|
| 41 | },
|
| 42 | error: function(xhr, status, error) {
|
| 43 | $(e.currentTarget).find('#logText').text(xhr.responseText);
|
| 44 | }
|
| 45 | });
|
| 46 | });
|
| 47 | $(".arrow-toggle").on('click', function(e) { e.preventDefault(); $(this).find('.arrow').toggleClass("animation"); });
|
| 48 | $("#pushover_delete").click(function() { return confirm(lang.delete_ays); });
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 49 |
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 50 | });
|
| 51 | jQuery(function($){
|
| 52 | // http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
| 53 | var entityMap = {
|
| 54 | '&': '&',
|
| 55 | '<': '<',
|
| 56 | '>': '>',
|
| 57 | '"': '"',
|
| 58 | "'": ''',
|
| 59 | '/': '/',
|
| 60 | '`': '`',
|
| 61 | '=': '='
|
| 62 | };
|
| 63 | function escapeHtml(string) {
|
| 64 | return String(string).replace(/[&<>"'`=\/]/g, function (s) {
|
| 65 | return entityMap[s];
|
| 66 | });
|
| 67 | }
|
| 68 | // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
|
| 69 | function validateEmail(email) {
|
| 70 | var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
| 71 | return re.test(email);
|
| 72 | }
|
| 73 | function unix_time_format(tm) {
|
| 74 | var date = new Date(tm ? tm * 1000 : 0);
|
| 75 | return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
|
| 76 | }
|
| 77 | acl_data = JSON.parse(acl);
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 78 |
|
| 79 | $('.clear-last-logins').on('click', function () {if (confirm(lang.delete_ays)) {last_logins('reset');}})
|
| 80 | $(".login-history").on('click', function(e) {e.preventDefault(); last_logins('get', $(this).data('days'));$(this).addClass('active').siblings().removeClass('active');});
|
| 81 |
|
| 82 | function last_logins(action, days = 1) {
|
| 83 | if (action == 'get') {
|
| 84 | $('.last-login').html('<i class="bi bi-hourglass"></i>' + lang.waiting);
|
| 85 | $.ajax({
|
| 86 | dataType: 'json',
|
| 87 | url: '/api/v1/get/last-login/' + encodeURIComponent(mailcow_cc_username) + '/' + days,
|
| 88 | jsonp: false,
|
| 89 | error: function () {
|
| 90 | console.log('error reading last logins');
|
| 91 | },
|
| 92 | success: function (data) {
|
| 93 | $('.last-login').html();
|
| 94 | if (data.ui.time) {
|
| 95 | $('.last-login').html('<i class="bi bi-person-fill"></i> ' + lang.last_ui_login + ': ' + unix_time_format(data.ui.time));
|
| 96 | } else {
|
| 97 | $('.last-login').text(lang.no_last_login);
|
| 98 | }
|
| 99 | if (data.sasl) {
|
| 100 | $('.last-login').append('<ul class="list-group">');
|
| 101 | $.each(data.sasl, function (i, item) {
|
| 102 | var datetime = new Date(item.datetime.replace(/-/g, "/"));
|
| 103 | var local_datetime = datetime.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
|
| 104 | item.app_password ? app_password = ' <a href="/edit/app-passwd/' + item.app_password + '">(App)</a>' : app_password = "", item.location ? ip_location = ' <span class="flag-icon flag-icon-' + item.location.toLowerCase() + '"></span>' : ip_location = "";
|
| 105 | "smtp" == item.service ? service = '<div class="label label-default">' + item.service.toUpperCase() + '<i class="bi bi-chevron-compact-right"></i></div>' : "imap" == item.service ? service = '<div class="label label-default"><i class="bi bi-chevron-compact-left"></i> ' + item.service.toUpperCase() + "</div>" : service = '<div class="label label-default">' + item.service.toUpperCase() + "</div>";
|
| 106 | item.real_rip.startsWith("Web") ? real_rip = item.real_rip : real_rip = '<a href="https://bgp.he.net/ip/' + item.real_rip + '" target="_blank">' + item.real_rip + "</a>";
|
| 107 | ip_data = real_rip + ip_location + app_password;
|
| 108 | $(".last-login").append('<li class="list-group-item">' + local_datetime + " " + service + " " + lang.from + " " + ip_data + "</li>");
|
| 109 | })
|
| 110 | $('.last-login').append('</ul>');
|
| 111 | }
|
| 112 | }
|
| 113 | })
|
| 114 | } else if (action == 'reset') {
|
| 115 | $.ajax({
|
| 116 | dataType: 'json',
|
| 117 | url: '/api/v1/get/reset-last-login/' + encodeURIComponent(mailcow_cc_username),
|
| 118 | jsonp: false,
|
| 119 | error: function () {
|
| 120 | console.log('cannot reset last logins');
|
| 121 | },
|
| 122 | success: function (data) {
|
| 123 | last_logins('get');
|
| 124 | }
|
| 125 | })
|
| 126 | }
|
| 127 | }
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 128 |
|
| 129 | function draw_tla_table() {
|
| 130 | ft_tla_table = FooTable.init('#tla_table', {
|
| 131 | "columns": [
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 132 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
| 133 | {"name":"address","title":lang.alias},
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 134 | {"name":"validity","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});},"title":lang.alias_valid_until,"style":{"width":"170px"}},
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 135 | {"sorted": true,"sortValue": function(value){res = new Date(value);return res.getTime();},"direction":"DESC","name":"created","formatter":function date_format(datetime) { var date = new Date(datetime.replace(/-/g, "/")); return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});},"title":lang.created_on,"style":{"width":"170px"}},
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 136 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
| 137 | ],
|
| 138 | "empty": lang.empty,
|
| 139 | "rows": $.ajax({
|
| 140 | dataType: 'json',
|
| 141 | url: '/api/v1/get/time_limited_aliases',
|
| 142 | jsonp: false,
|
| 143 | error: function () {
|
| 144 | console.log('Cannot draw tla table');
|
| 145 | },
|
| 146 | success: function (data) {
|
| 147 | $.each(data, function (i, item) {
|
| 148 | if (acl_data.spam_alias === 1) {
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 149 | item.action = '<div class="btn-group footable-actions">' +
|
| 150 | '<a href="#" data-action="delete_selected" data-id="single-tla" data-api-url="delete/time_limited_alias" data-item="' + encodeURIComponent(item.address) + '" class="btn btn-xs btn-danger"><i class="bi bi-trash"></i> ' + lang.remove + '</a>' +
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 151 | '</div>';
|
| 152 | item.chkbox = '<input type="checkbox" data-id="tla" name="multi_select" value="' + encodeURIComponent(item.address) + '" />';
|
| 153 | item.address = escapeHtml(item.address);
|
| 154 | }
|
| 155 | else {
|
| 156 | item.chkbox = '<input type="checkbox" disabled />';
|
| 157 | item.action = '<span>-</span>';
|
| 158 | }
|
| 159 | });
|
| 160 | }
|
| 161 | }),
|
| 162 | "paging": {
|
| 163 | "enabled": true,
|
| 164 | "limit": 5,
|
| 165 | "size": pagination_size
|
| 166 | },
|
| 167 | "state": {"enabled": true},
|
| 168 | "sorting": {
|
| 169 | "enabled": true
|
| 170 | },
|
| 171 | "toggleSelector": "table tbody span.footable-toggle"
|
| 172 | });
|
| 173 | }
|
| 174 | function draw_sync_job_table() {
|
| 175 | ft_syncjob_table = FooTable.init('#sync_job_table', {
|
| 176 | "columns": [
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 177 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 178 | {"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
|
| 179 | {"name":"server_w_port","title":"Server"},
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 180 | {"name":"enc1","title":lang.encryption,"breakpoints":"all"},
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 181 | {"name":"user1","title":lang.username},
|
| 182 | {"name":"exclude","title":lang.excludes,"breakpoints":"all"},
|
| 183 | {"name":"mins_interval","title":lang.interval + " (min)","breakpoints":"all"},
|
| 184 | {"name":"last_run","title":lang.last_run,"breakpoints":"all"},
|
| 185 | {"name":"log","title":"Log"},
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 186 | {"name":"active","filterable": false,"style":{"maxWidth":"70px","width":"70px"},"title":lang.active,"formatter": function(value){return 1==value?'<i class="bi bi-check-lg"></i>':0==value&&'<i class="bi bi-x-lg"></i>';}},
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 187 | {"name":"is_running","filterable": false,"style":{"maxWidth":"120px","width":"100px"},"title":lang.status},
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 188 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"260px","width":"260px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 189 | ],
|
| 190 | "empty": lang.empty,
|
| 191 | "rows": $.ajax({
|
| 192 | dataType: 'json',
|
| 193 | url: '/api/v1/get/syncjobs/' + encodeURIComponent(mailcow_cc_username) + '/no_log',
|
| 194 | jsonp: false,
|
| 195 | error: function () {
|
| 196 | console.log('Cannot draw sync job table');
|
| 197 | },
|
| 198 | success: function (data) {
|
| 199 | $.each(data, function (i, item) {
|
| 200 | item.user1 = escapeHtml(item.user1);
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 201 | item.log = '<a href="#syncjobLogModal" data-toggle="modal" data-syncjob-id="' + item.id + '">' + lang.open_logs + '</a>'
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 202 | if (!item.exclude > 0) {
|
| 203 | item.exclude = '-';
|
| 204 | } else {
|
| 205 | item.exclude = '<code>' + escapeHtml(item.exclude) + '</code>';
|
| 206 | }
|
| 207 | item.server_w_port = escapeHtml(item.user1 + '@' + item.host1 + ':' + item.port1);
|
| 208 | if (acl_data.syncjobs === 1) {
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 209 | item.action = '<div class="btn-group footable-actions">' +
|
| 210 | '<a href="/edit/syncjob/' + item.id + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' +
|
| 211 | '<a href="#" data-action="delete_selected" data-id="single-syncjob" data-api-url="delete/syncjob" data-item="' + item.id + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang.remove + '</a>' +
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 212 | '</div>';
|
| 213 | item.chkbox = '<input type="checkbox" data-id="syncjob" name="multi_select" value="' + item.id + '" />';
|
| 214 | }
|
| 215 | else {
|
| 216 | item.action = '<span>-</span>';
|
| 217 | item.chkbox = '<input type="checkbox" disabled />';
|
| 218 | }
|
| 219 | if (item.is_running == 1) {
|
| 220 | item.is_running = '<span id="active-script" class="label label-success">' + lang.running + '</span>';
|
| 221 | } else {
|
| 222 | item.is_running = '<span id="inactive-script" class="label label-warning">' + lang.waiting + '</span>';
|
| 223 | }
|
| 224 | if (!item.last_run > 0) {
|
| 225 | item.last_run = lang.waiting;
|
| 226 | }
|
| 227 | });
|
| 228 | }
|
| 229 | }),
|
| 230 | "paging": {
|
| 231 | "enabled": true,
|
| 232 | "limit": 5,
|
| 233 | "size": pagination_size
|
| 234 | },
|
| 235 | "state": {"enabled": true},
|
| 236 | "sorting": {
|
| 237 | "enabled": true
|
| 238 | },
|
| 239 | "toggleSelector": "table tbody span.footable-toggle"
|
| 240 | });
|
| 241 | }
|
| 242 | function draw_app_passwd_table() {
|
| 243 | ft_apppasswd_table = FooTable.init('#app_passwd_table', {
|
| 244 | "columns": [
|
| 245 | {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
| 246 | {"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
|
| 247 | {"name":"name","title":lang.app_name},
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 248 | {"name":"active","filterable": false,"style":{"maxWidth":"70px","width":"70px"},"title":lang.active,"formatter": function(value){return 1==value?'<i class="bi bi-check-lg"></i>':0==value&&'<i class="bi bi-x-lg"></i>';}},
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 249 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
| 250 | ],
|
| 251 | "empty": lang.empty,
|
| 252 | "rows": $.ajax({
|
| 253 | dataType: 'json',
|
| 254 | url: '/api/v1/get/app-passwd/all',
|
| 255 | jsonp: false,
|
| 256 | error: function () {
|
| 257 | console.log('Cannot draw app passwd table');
|
| 258 | },
|
| 259 | success: function (data) {
|
| 260 | $.each(data, function (i, item) {
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 261 | item.name = escapeHtml(item.name);
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 262 | if (acl_data.app_passwds === 1) {
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 263 | item.action = '<div class="btn-group footable-actions">' +
|
| 264 | '<a href="/edit/app-passwd/' + item.id + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' +
|
| 265 | '<a href="#" data-action="delete_selected" data-id="single-apppasswd" data-api-url="delete/app-passwd" data-item="' + item.id + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang.remove + '</a>' +
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 266 | '</div>';
|
| 267 | item.chkbox = '<input type="checkbox" data-id="apppasswd" name="multi_select" value="' + item.id + '" />';
|
| 268 | }
|
| 269 | else {
|
| 270 | item.action = '<span>-</span>';
|
| 271 | item.chkbox = '<input type="checkbox" disabled />';
|
| 272 | }
|
| 273 | });
|
| 274 | }
|
| 275 | }),
|
| 276 | "paging": {
|
| 277 | "enabled": true,
|
| 278 | "limit": 5,
|
| 279 | "size": pagination_size
|
| 280 | },
|
| 281 | "state": {"enabled": true},
|
| 282 | "sorting": {
|
| 283 | "enabled": true
|
| 284 | },
|
| 285 | "toggleSelector": "table tbody span.footable-toggle"
|
| 286 | });
|
| 287 | }
|
| 288 | function draw_wl_policy_mailbox_table() {
|
| 289 | ft_wl_policy_mailbox_table = FooTable.init('#wl_policy_mailbox_table', {
|
| 290 | "columns": [
|
| 291 | {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
| 292 | {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
|
| 293 | {"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
|
| 294 | {"name":"object","title":"Scope"}
|
| 295 | ],
|
| 296 | "empty": lang.empty,
|
| 297 | "rows": $.ajax({
|
| 298 | dataType: 'json',
|
| 299 | url: '/api/v1/get/policy_wl_mailbox',
|
| 300 | jsonp: false,
|
| 301 | error: function () {
|
| 302 | console.log('Cannot draw mailbox policy wl table');
|
| 303 | },
|
| 304 | success: function (data) {
|
| 305 | $.each(data, function (i, item) {
|
| 306 | if (validateEmail(item.object)) {
|
| 307 | item.chkbox = '<input type="checkbox" data-id="policy_wl_mailbox" name="multi_select" value="' + item.prefid + '" />';
|
| 308 | }
|
| 309 | else {
|
| 310 | item.chkbox = '<input type="checkbox" disabled title="' + lang.spamfilter_table_domain_policy + '" />';
|
| 311 | }
|
| 312 | if (acl_data.spam_policy === 0) {
|
| 313 | item.chkbox = '<input type="checkbox" disabled />';
|
| 314 | }
|
| 315 | });
|
| 316 | }
|
| 317 | }),
|
| 318 | "state": {"enabled": true},
|
| 319 | "paging": {
|
| 320 | "enabled": true,
|
| 321 | "limit": 5,
|
| 322 | "size": pagination_size
|
| 323 | },
|
| 324 | "sorting": {
|
| 325 | "enabled": true
|
| 326 | }
|
| 327 | });
|
| 328 | }
|
| 329 | function draw_bl_policy_mailbox_table() {
|
| 330 | ft_bl_policy_mailbox_table = FooTable.init('#bl_policy_mailbox_table', {
|
| 331 | "columns": [
|
| 332 | {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
| 333 | {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
|
| 334 | {"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
|
| 335 | {"name":"object","title":"Scope"}
|
| 336 | ],
|
| 337 | "empty": lang.empty,
|
| 338 | "rows": $.ajax({
|
| 339 | dataType: 'json',
|
| 340 | url: '/api/v1/get/policy_bl_mailbox',
|
| 341 | jsonp: false,
|
| 342 | error: function () {
|
| 343 | console.log('Cannot draw mailbox policy bl table');
|
| 344 | },
|
| 345 | success: function (data) {
|
| 346 | $.each(data, function (i, item) {
|
| 347 | if (validateEmail(item.object)) {
|
| 348 | item.chkbox = '<input type="checkbox" data-id="policy_bl_mailbox" name="multi_select" value="' + item.prefid + '" />';
|
| 349 | }
|
| 350 | else {
|
| 351 | item.chkbox = '<input type="checkbox" disabled tooltip="' + lang.spamfilter_table_domain_policy + '" />';
|
| 352 | }
|
| 353 | if (acl_data.spam_policy === 0) {
|
| 354 | item.chkbox = '<input type="checkbox" disabled />';
|
| 355 | }
|
| 356 | });
|
| 357 | }
|
| 358 | }),
|
| 359 | "paging": {
|
| 360 | "enabled": true,
|
| 361 | "limit": 5,
|
| 362 | "size": pagination_size
|
| 363 | },
|
| 364 | "state": {"enabled": true},
|
| 365 | "sorting": {
|
| 366 | "enabled": true
|
| 367 | }
|
| 368 | });
|
| 369 | }
|
| 370 |
|
| 371 | $('body').on('click', 'span.footable-toggle', function () {
|
| 372 | event.stopPropagation();
|
| 373 | })
|
| 374 |
|
| 375 | draw_sync_job_table();
|
| 376 | draw_app_passwd_table();
|
| 377 | draw_tla_table();
|
| 378 | draw_wl_policy_mailbox_table();
|
| 379 | draw_bl_policy_mailbox_table();
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 380 | last_logins('get');
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 381 |
|
| 382 | // FIDO2 friendly name modal
|
| 383 | $('#fido2ChangeFn').on('show.bs.modal', function (e) {
|
| 384 | rename_link = $(e.relatedTarget)
|
| 385 | if (rename_link != null) {
|
| 386 | $('#fido2_cid').val(rename_link.data('cid'));
|
| 387 | $('#fido2_subject_desc').text(Base64.decode(rename_link.data('subject')));
|
| 388 | }
|
| 389 | })
|
| 390 |
|
| 391 | // Sieve data modal
|
| 392 | $('#userFilterModal').on('show.bs.modal', function(e) {
|
| 393 | $('#user_sieve_filter').text(lang.loading);
|
| 394 | $.ajax({
|
| 395 | dataType: 'json',
|
| 396 | url: '/api/v1/get/active-user-sieve/' + encodeURIComponent(mailcow_cc_username),
|
| 397 | jsonp: false,
|
| 398 | error: function () {
|
| 399 | console.log('Cannot get active sieve script');
|
| 400 | },
|
| 401 | complete: function (data) {
|
| 402 | if (data.responseText == '{}') {
|
| 403 | $('#user_sieve_filter').text(lang.no_active_filter);
|
| 404 | } else {
|
| 405 | $('#user_sieve_filter').text(JSON.parse(data.responseText));
|
| 406 | }
|
| 407 | }
|
| 408 | })
|
| 409 | });
|
| 410 | $('#userFilterModal').on('hidden.bs.modal', function () {
|
| 411 | $('#user_sieve_filter').text(lang.loading);
|
| 412 | });
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 413 | });
|