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 |
|
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 82 | function last_logins(action, days = 7) {
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 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"});
|
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 104 | var service = '<div class="label label-default">' + item.service.toUpperCase() + '</div>';
|
| 105 | var app_password = item.app_password ? ' <a href="/edit/app-passwd/' + item.app_password + '"><i class="bi bi-app-indicator"></i> ' + escapeHtml(item.app_password_name || "App") + '</a>' : '';
|
| 106 | var real_rip = item.real_rip.startsWith("Web") ? item.real_rip : '<a href="https://bgp.he.net/ip/' + item.real_rip + '" target="_blank">' + item.real_rip + "</a>";
|
| 107 | var ip_location = item.location ? ' <span class="flag-icon flag-icon-' + item.location.toLowerCase() + '"></span>' : '';
|
| 108 | var ip_data = real_rip + ip_location + app_password;
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 109 | $(".last-login").append('<li class="list-group-item">' + local_datetime + " " + service + " " + lang.from + " " + ip_data + "</li>");
|
| 110 | })
|
| 111 | $('.last-login').append('</ul>');
|
| 112 | }
|
| 113 | }
|
| 114 | })
|
| 115 | } else if (action == 'reset') {
|
| 116 | $.ajax({
|
| 117 | dataType: 'json',
|
| 118 | url: '/api/v1/get/reset-last-login/' + encodeURIComponent(mailcow_cc_username),
|
| 119 | jsonp: false,
|
| 120 | error: function () {
|
| 121 | console.log('cannot reset last logins');
|
| 122 | },
|
| 123 | success: function (data) {
|
| 124 | last_logins('get');
|
| 125 | }
|
| 126 | })
|
| 127 | }
|
| 128 | }
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 129 |
|
| 130 | function draw_tla_table() {
|
| 131 | ft_tla_table = FooTable.init('#tla_table', {
|
| 132 | "columns": [
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 133 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
| 134 | {"name":"address","title":lang.alias},
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 135 | {"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] | 136 | {"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 | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 137 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"220px","width":"220px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 138 | ],
|
| 139 | "empty": lang.empty,
|
| 140 | "rows": $.ajax({
|
| 141 | dataType: 'json',
|
| 142 | url: '/api/v1/get/time_limited_aliases',
|
| 143 | jsonp: false,
|
| 144 | error: function () {
|
| 145 | console.log('Cannot draw tla table');
|
| 146 | },
|
| 147 | success: function (data) {
|
| 148 | $.each(data, function (i, item) {
|
| 149 | if (acl_data.spam_alias === 1) {
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 150 | item.action = '<div class="btn-group footable-actions">' +
|
| 151 | '<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] | 152 | '</div>';
|
| 153 | item.chkbox = '<input type="checkbox" data-id="tla" name="multi_select" value="' + encodeURIComponent(item.address) + '" />';
|
| 154 | item.address = escapeHtml(item.address);
|
| 155 | }
|
| 156 | else {
|
| 157 | item.chkbox = '<input type="checkbox" disabled />';
|
| 158 | item.action = '<span>-</span>';
|
| 159 | }
|
| 160 | });
|
| 161 | }
|
| 162 | }),
|
| 163 | "paging": {
|
| 164 | "enabled": true,
|
| 165 | "limit": 5,
|
| 166 | "size": pagination_size
|
| 167 | },
|
| 168 | "state": {"enabled": true},
|
| 169 | "sorting": {
|
| 170 | "enabled": true
|
| 171 | },
|
| 172 | "toggleSelector": "table tbody span.footable-toggle"
|
| 173 | });
|
| 174 | }
|
| 175 | function draw_sync_job_table() {
|
| 176 | ft_syncjob_table = FooTable.init('#sync_job_table', {
|
| 177 | "columns": [
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 178 | {"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] | 179 | {"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
|
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 180 | {"name":"server_w_port","title":"Server","breakpoints":"xs sm md","style":{"word-break":"break-all"}},
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 181 | {"name":"enc1","title":lang.encryption,"breakpoints":"all"},
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 182 | {"name":"user1","title":lang.username},
|
| 183 | {"name":"exclude","title":lang.excludes,"breakpoints":"all"},
|
| 184 | {"name":"mins_interval","title":lang.interval + " (min)","breakpoints":"all"},
|
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 185 | {"name":"last_run","title":lang.last_run,"breakpoints":"xs sm md"},
|
| 186 | {"name":"exit_status","filterable": false,"title":lang.syncjob_last_run_result},
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 187 | {"name":"log","title":"Log"},
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 188 | {"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] | 189 | {"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] | 190 | {"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] | 191 | ],
|
| 192 | "empty": lang.empty,
|
| 193 | "rows": $.ajax({
|
| 194 | dataType: 'json',
|
| 195 | url: '/api/v1/get/syncjobs/' + encodeURIComponent(mailcow_cc_username) + '/no_log',
|
| 196 | jsonp: false,
|
| 197 | error: function () {
|
| 198 | console.log('Cannot draw sync job table');
|
| 199 | },
|
| 200 | success: function (data) {
|
| 201 | $.each(data, function (i, item) {
|
| 202 | item.user1 = escapeHtml(item.user1);
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 203 | 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] | 204 | if (!item.exclude > 0) {
|
| 205 | item.exclude = '-';
|
| 206 | } else {
|
| 207 | item.exclude = '<code>' + escapeHtml(item.exclude) + '</code>';
|
| 208 | }
|
| 209 | item.server_w_port = escapeHtml(item.user1 + '@' + item.host1 + ':' + item.port1);
|
| 210 | if (acl_data.syncjobs === 1) {
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 211 | item.action = '<div class="btn-group footable-actions">' +
|
| 212 | '<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>' +
|
| 213 | '<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] | 214 | '</div>';
|
| 215 | item.chkbox = '<input type="checkbox" data-id="syncjob" name="multi_select" value="' + item.id + '" />';
|
| 216 | }
|
| 217 | else {
|
| 218 | item.action = '<span>-</span>';
|
| 219 | item.chkbox = '<input type="checkbox" disabled />';
|
| 220 | }
|
| 221 | if (item.is_running == 1) {
|
| 222 | item.is_running = '<span id="active-script" class="label label-success">' + lang.running + '</span>';
|
| 223 | } else {
|
| 224 | item.is_running = '<span id="inactive-script" class="label label-warning">' + lang.waiting + '</span>';
|
| 225 | }
|
| 226 | if (!item.last_run > 0) {
|
| 227 | item.last_run = lang.waiting;
|
| 228 | }
|
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 229 | if (item.success == null) {
|
| 230 | item.success = '-';
|
| 231 | item.exit_status = '';
|
| 232 | } else {
|
| 233 | item.success = '<i class="text-' + (item.success == 1 ? 'success' : 'danger') + ' bi bi-' + (item.success == 1 ? 'check-lg' : 'x-lg') + '"></i>';
|
| 234 | }
|
| 235 | if (lang['syncjob_'+item.exit_status]) {
|
| 236 | item.exit_status = lang['syncjob_'+item.exit_status];
|
| 237 | } else if (item.success != '-') {
|
| 238 | item.exit_status = lang.syncjob_check_log;
|
| 239 | }
|
| 240 | item.exit_status = item.success + ' ' + item.exit_status;
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 241 | });
|
| 242 | }
|
| 243 | }),
|
| 244 | "paging": {
|
| 245 | "enabled": true,
|
| 246 | "limit": 5,
|
| 247 | "size": pagination_size
|
| 248 | },
|
| 249 | "state": {"enabled": true},
|
| 250 | "sorting": {
|
| 251 | "enabled": true
|
| 252 | },
|
| 253 | "toggleSelector": "table tbody span.footable-toggle"
|
| 254 | });
|
| 255 | }
|
| 256 | function draw_app_passwd_table() {
|
| 257 | ft_apppasswd_table = FooTable.init('#app_passwd_table', {
|
| 258 | "columns": [
|
| 259 | {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
| 260 | {"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
|
| 261 | {"name":"name","title":lang.app_name},
|
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 262 | {"name":"protocols","title":lang.allowed_protocols},
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 263 | {"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 | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 264 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"220px","width":"220px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 265 | ],
|
| 266 | "empty": lang.empty,
|
| 267 | "rows": $.ajax({
|
| 268 | dataType: 'json',
|
| 269 | url: '/api/v1/get/app-passwd/all',
|
| 270 | jsonp: false,
|
| 271 | error: function () {
|
| 272 | console.log('Cannot draw app passwd table');
|
| 273 | },
|
| 274 | success: function (data) {
|
| 275 | $.each(data, function (i, item) {
|
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 276 | item.name = escapeHtml(item.name)
|
| 277 | item.protocols = []
|
| 278 | if (item.imap_access == 1) { item.protocols.push("<code>IMAP</code>"); }
|
| 279 | if (item.smtp_access == 1) { item.protocols.push("<code>SMTP</code>"); }
|
| 280 | if (item.eas_access == 1) { item.protocols.push("<code>EAS/ActiveSync</code>"); }
|
| 281 | if (item.dav_access == 1) { item.protocols.push("<code>DAV</code>"); }
|
| 282 | if (item.pop3_access == 1) { item.protocols.push("<code>POP3</code>"); }
|
| 283 | if (item.sieve_access == 1) { item.protocols.push("<code>Sieve</code>"); }
|
| 284 | item.protocols = item.protocols.join(" ")
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 285 | if (acl_data.app_passwds === 1) {
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 286 | item.action = '<div class="btn-group footable-actions">' +
|
| 287 | '<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>' +
|
| 288 | '<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] | 289 | '</div>';
|
| 290 | item.chkbox = '<input type="checkbox" data-id="apppasswd" name="multi_select" value="' + item.id + '" />';
|
| 291 | }
|
| 292 | else {
|
| 293 | item.action = '<span>-</span>';
|
| 294 | item.chkbox = '<input type="checkbox" disabled />';
|
| 295 | }
|
| 296 | });
|
| 297 | }
|
| 298 | }),
|
| 299 | "paging": {
|
| 300 | "enabled": true,
|
| 301 | "limit": 5,
|
| 302 | "size": pagination_size
|
| 303 | },
|
| 304 | "state": {"enabled": true},
|
| 305 | "sorting": {
|
| 306 | "enabled": true
|
| 307 | },
|
| 308 | "toggleSelector": "table tbody span.footable-toggle"
|
| 309 | });
|
| 310 | }
|
| 311 | function draw_wl_policy_mailbox_table() {
|
| 312 | ft_wl_policy_mailbox_table = FooTable.init('#wl_policy_mailbox_table', {
|
| 313 | "columns": [
|
| 314 | {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
| 315 | {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
|
| 316 | {"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
|
| 317 | {"name":"object","title":"Scope"}
|
| 318 | ],
|
| 319 | "empty": lang.empty,
|
| 320 | "rows": $.ajax({
|
| 321 | dataType: 'json',
|
| 322 | url: '/api/v1/get/policy_wl_mailbox',
|
| 323 | jsonp: false,
|
| 324 | error: function () {
|
| 325 | console.log('Cannot draw mailbox policy wl table');
|
| 326 | },
|
| 327 | success: function (data) {
|
| 328 | $.each(data, function (i, item) {
|
| 329 | if (validateEmail(item.object)) {
|
| 330 | item.chkbox = '<input type="checkbox" data-id="policy_wl_mailbox" name="multi_select" value="' + item.prefid + '" />';
|
| 331 | }
|
| 332 | else {
|
| 333 | item.chkbox = '<input type="checkbox" disabled title="' + lang.spamfilter_table_domain_policy + '" />';
|
| 334 | }
|
| 335 | if (acl_data.spam_policy === 0) {
|
| 336 | item.chkbox = '<input type="checkbox" disabled />';
|
| 337 | }
|
| 338 | });
|
| 339 | }
|
| 340 | }),
|
| 341 | "state": {"enabled": true},
|
| 342 | "paging": {
|
| 343 | "enabled": true,
|
| 344 | "limit": 5,
|
| 345 | "size": pagination_size
|
| 346 | },
|
| 347 | "sorting": {
|
| 348 | "enabled": true
|
| 349 | }
|
| 350 | });
|
| 351 | }
|
| 352 | function draw_bl_policy_mailbox_table() {
|
| 353 | ft_bl_policy_mailbox_table = FooTable.init('#bl_policy_mailbox_table', {
|
| 354 | "columns": [
|
| 355 | {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
| 356 | {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
|
| 357 | {"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
|
| 358 | {"name":"object","title":"Scope"}
|
| 359 | ],
|
| 360 | "empty": lang.empty,
|
| 361 | "rows": $.ajax({
|
| 362 | dataType: 'json',
|
| 363 | url: '/api/v1/get/policy_bl_mailbox',
|
| 364 | jsonp: false,
|
| 365 | error: function () {
|
| 366 | console.log('Cannot draw mailbox policy bl table');
|
| 367 | },
|
| 368 | success: function (data) {
|
| 369 | $.each(data, function (i, item) {
|
| 370 | if (validateEmail(item.object)) {
|
| 371 | item.chkbox = '<input type="checkbox" data-id="policy_bl_mailbox" name="multi_select" value="' + item.prefid + '" />';
|
| 372 | }
|
| 373 | else {
|
| 374 | item.chkbox = '<input type="checkbox" disabled tooltip="' + lang.spamfilter_table_domain_policy + '" />';
|
| 375 | }
|
| 376 | if (acl_data.spam_policy === 0) {
|
| 377 | item.chkbox = '<input type="checkbox" disabled />';
|
| 378 | }
|
| 379 | });
|
| 380 | }
|
| 381 | }),
|
| 382 | "paging": {
|
| 383 | "enabled": true,
|
| 384 | "limit": 5,
|
| 385 | "size": pagination_size
|
| 386 | },
|
| 387 | "state": {"enabled": true},
|
| 388 | "sorting": {
|
| 389 | "enabled": true
|
| 390 | }
|
| 391 | });
|
| 392 | }
|
| 393 |
|
| 394 | $('body').on('click', 'span.footable-toggle', function () {
|
| 395 | event.stopPropagation();
|
| 396 | })
|
| 397 |
|
| 398 | draw_sync_job_table();
|
| 399 | draw_app_passwd_table();
|
| 400 | draw_tla_table();
|
| 401 | draw_wl_policy_mailbox_table();
|
| 402 | draw_bl_policy_mailbox_table();
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 403 | last_logins('get');
|
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 404 |
|
| 405 | // FIDO2 friendly name modal
|
| 406 | $('#fido2ChangeFn').on('show.bs.modal', function (e) {
|
| 407 | rename_link = $(e.relatedTarget)
|
| 408 | if (rename_link != null) {
|
| 409 | $('#fido2_cid').val(rename_link.data('cid'));
|
| 410 | $('#fido2_subject_desc').text(Base64.decode(rename_link.data('subject')));
|
| 411 | }
|
| 412 | })
|
| 413 |
|
| 414 | // Sieve data modal
|
| 415 | $('#userFilterModal').on('show.bs.modal', function(e) {
|
| 416 | $('#user_sieve_filter').text(lang.loading);
|
| 417 | $.ajax({
|
| 418 | dataType: 'json',
|
| 419 | url: '/api/v1/get/active-user-sieve/' + encodeURIComponent(mailcow_cc_username),
|
| 420 | jsonp: false,
|
| 421 | error: function () {
|
| 422 | console.log('Cannot get active sieve script');
|
| 423 | },
|
| 424 | complete: function (data) {
|
| 425 | if (data.responseText == '{}') {
|
| 426 | $('#user_sieve_filter').text(lang.no_active_filter);
|
| 427 | } else {
|
| 428 | $('#user_sieve_filter').text(JSON.parse(data.responseText));
|
| 429 | }
|
| 430 | }
|
| 431 | })
|
| 432 | });
|
| 433 | $('#userFilterModal').on('hidden.bs.modal', function () {
|
| 434 | $('#user_sieve_filter').text(lang.loading);
|
| 435 | });
|
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 436 | });
|