Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1 | $(document).ready(function() { |
| 2 | acl_data = JSON.parse(acl); |
| 3 | FooTable.domainFilter = FooTable.Filtering.extend({ |
| 4 | construct: function(instance){ |
| 5 | this._super(instance); |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 6 | this.def = lang.all_domains; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 7 | this.$domain = null; |
| 8 | }, |
| 9 | $create: function(){ |
| 10 | this._super(); |
| 11 | var self = this; |
| 12 | var domains = []; |
| 13 | |
| 14 | $.each(self.ft.rows.all, function(i, row){ |
| 15 | if((row.val().domain != null) && ($.inArray(row.val().domain, domains) === -1)) domains.push(row.val().domain); |
| 16 | }); |
| 17 | |
| 18 | $form_grp = $('<div/>', {'class': 'form-group'}) |
| 19 | .append($('<label/>', {'class': 'sr-only', text: 'Domain'})) |
| 20 | .prependTo(self.$form); |
| 21 | self.$domain = $('<select/>', { 'class': 'aform-control' }) |
| 22 | .on('change', {self: self}, self._onDomainDropdownChanged) |
| 23 | .append($('<option/>', {text: self.def})) |
| 24 | .appendTo($form_grp); |
| 25 | |
| 26 | $.each(domains, function(i, domain){ |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 27 | domainname = $($.parseHTML(domain)).data('domainname') |
| 28 | if (domainname !== undefined) { |
| 29 | self.$domain.append($('<option/>').text(domainname)); |
| 30 | } else { |
| 31 | self.$domain.append($('<option/>').text(domain)); |
| 32 | } |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 33 | }); |
| 34 | }, |
| 35 | _onDomainDropdownChanged: function(e){ |
| 36 | var self = e.data.self, |
| 37 | selected = $(this).val(); |
| 38 | if (selected !== self.def){ |
| 39 | self.addFilter('domain', selected, ['domain']); |
| 40 | } else { |
| 41 | self.removeFilter('domain'); |
| 42 | } |
| 43 | self.filter(); |
| 44 | }, |
| 45 | draw: function(){ |
| 46 | this._super(); |
| 47 | var domain = this.find('domain'); |
| 48 | if (domain instanceof FooTable.Filter){ |
| 49 | this.$domain.val(domain.query.val()); |
| 50 | } else { |
| 51 | this.$domain.val(this.def); |
| 52 | } |
| 53 | $(this.$domain).closest("select").selectpicker(); |
| 54 | } |
| 55 | }); |
| 56 | // Set paging |
| 57 | $('[data-page-size]').on('click', function(e){ |
| 58 | e.preventDefault(); |
| 59 | var new_size = $(this).data('page-size'); |
| 60 | var parent_ul = $(this).closest('ul'); |
| 61 | var table_id = $(parent_ul).data('table-id'); |
| 62 | FooTable.get('#' + table_id).pageSize(new_size); |
| 63 | //$(this).parent().addClass('active').siblings().removeClass('active') |
| 64 | heading = $(this).parents('.panel').find('.panel-heading') |
| 65 | var n_results = $(heading).children('.table-lines').text().split(' / ')[1]; |
| 66 | $(heading).children('.table-lines').text(function(){ |
| 67 | if (new_size > n_results) { |
| 68 | new_size = n_results; |
| 69 | } |
| 70 | return new_size + ' / ' + n_results; |
| 71 | }) |
| 72 | }); |
| 73 | // Clone mailbox mass actions |
| 74 | $("div").find("[data-actions-header='true'").each(function() { |
| 75 | $(this).html($(this).nextAll('.mass-actions-mailbox:first').html()); |
| 76 | }); |
| 77 | // Auto-fill domain quota when adding new domain |
| 78 | auto_fill_quota = function(domain) { |
| 79 | $.get("/api/v1/get/domain/" + domain, function(data){ |
| 80 | var result = $.parseJSON(JSON.stringify(data)); |
| 81 | def_new_mailbox_quota = ( result.def_new_mailbox_quota / 1048576); |
| 82 | max_new_mailbox_quota = ( result.max_new_mailbox_quota / 1048576); |
| 83 | if (max_new_mailbox_quota != '0') { |
| 84 | $('.addInputQuotaExhausted').hide(); |
| 85 | $("#quotaBadge").html('max. ' + max_new_mailbox_quota + ' MiB'); |
| 86 | $('#addInputQuota').attr({"disabled": false, "value": "", "type": "number", "max": max_new_mailbox_quota}); |
| 87 | $('#addInputQuota').val(def_new_mailbox_quota); |
| 88 | } |
| 89 | else { |
| 90 | $('.addInputQuotaExhausted').show(); |
| 91 | $("#quotaBadge").html('max. ' + max_new_mailbox_quota + ' MiB'); |
| 92 | $('#addInputQuota').attr({"disabled": true, "value": "", "type": "text", "value": "n/a"}); |
| 93 | $('#addInputQuota').val(max_new_mailbox_quota); |
| 94 | } |
| 95 | }); |
| 96 | } |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 97 | $('#addSelectDomain').on('change', function() { |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 98 | auto_fill_quota($('#addSelectDomain').val()); |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 99 | }); |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 100 | auto_fill_quota($('#addSelectDomain').val()); |
| 101 | $(".goto_checkbox").click(function( event ) { |
| 102 | $("form[data-id='add_alias'] .goto_checkbox").not(this).prop('checked', false); |
| 103 | if ($("form[data-id='add_alias'] .goto_checkbox:checked").length > 0) { |
| 104 | $('#textarea_alias_goto').prop('disabled', true); |
| 105 | } |
| 106 | else { |
| 107 | $("#textarea_alias_goto").removeAttr('disabled'); |
| 108 | } |
| 109 | }); |
| 110 | $('#addAliasModal').on('show.bs.modal', function(e) { |
| 111 | if ($("form[data-id='add_alias'] .goto_checkbox:checked").length > 0) { |
| 112 | $('#textarea_alias_goto').prop('disabled', true); |
| 113 | } |
| 114 | else { |
| 115 | $("#textarea_alias_goto").removeAttr('disabled'); |
| 116 | } |
| 117 | }); |
| 118 | // Log modal |
| 119 | $('#syncjobLogModal').on('show.bs.modal', function(e) { |
| 120 | var syncjob_id = $(e.relatedTarget).data('syncjob-id'); |
| 121 | $.ajax({ |
| 122 | url: '/inc/ajax/syncjob_logs.php', |
| 123 | data: { id: syncjob_id }, |
| 124 | dataType: 'text', |
| 125 | success: function(data){ |
| 126 | $(e.currentTarget).find('#logText').text(data); |
| 127 | }, |
| 128 | error: function(xhr, status, error) { |
| 129 | $(e.currentTarget).find('#logText').text(xhr.responseText); |
| 130 | } |
| 131 | }); |
| 132 | }); |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 133 | // Log modal |
| 134 | $('#dnsInfoModal').on('show.bs.modal', function(e) { |
| 135 | var domain = $(e.relatedTarget).data('domain'); |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 136 | $('.dns-modal-body').html('<center><i class="bi bi-arrow-repeat icon-spin"></i></center>'); |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 137 | $.ajax({ |
| 138 | url: '/inc/ajax/dns_diagnostics.php', |
| 139 | data: { domain: domain }, |
| 140 | dataType: 'text', |
| 141 | success: function(data){ |
| 142 | $('.dns-modal-body').html(data); |
| 143 | }, |
| 144 | error: function(xhr, status, error) { |
| 145 | $('.dns-modal-body').html(xhr.responseText); |
| 146 | } |
| 147 | }); |
| 148 | }); |
| 149 | // Sieve data modal |
| 150 | $('#sieveDataModal').on('show.bs.modal', function(e) { |
| 151 | var sieveScript = $(e.relatedTarget).data('sieve-script'); |
| 152 | $(e.currentTarget).find('#sieveDataText').html('<pre style="font-size:14px;line-height:1.1">' + sieveScript + '</pre>'); |
| 153 | }); |
| 154 | // Disable submit button on script change |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 155 | $('.textarea-code').on('keyup', function() { |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 156 | // Disable all "save" buttons, could be a "related button only" function, todo |
| 157 | $('.add_sieve_script').attr({"disabled": true}); |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 158 | }); |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 159 | // Validate script data |
| 160 | $(".validate_sieve").click(function( event ) { |
| 161 | event.preventDefault(); |
| 162 | var validation_button = $(this); |
| 163 | // Get script_data textarea content from form the button was clicked in |
| 164 | var script = $('textarea[name="script_data"]', $(this).parents('form:first')).val(); |
| 165 | $.ajax({ |
| 166 | dataType: 'json', |
| 167 | url: "/inc/ajax/sieve_validation.php", |
| 168 | type: "get", |
| 169 | data: { script: script }, |
| 170 | complete: function(data) { |
| 171 | var response = (data.responseText); |
| 172 | response_obj = JSON.parse(response); |
| 173 | if (response_obj.type == "success") { |
| 174 | $(validation_button).next().attr({"disabled": false}); |
| 175 | } |
| 176 | mailcow_alert_box(response_obj.msg, response_obj.type); |
| 177 | }, |
| 178 | }); |
| 179 | }); |
| 180 | // $(document).on('DOMNodeInserted', '#prefilter_table', function () { |
| 181 | // $("#active-script").closest('td').css('background-color','#b0f0a0'); |
| 182 | // $("#inactive-script").closest('td').css('background-color','#b0f0a0'); |
| 183 | // }); |
| 184 | $('#addResourceModal').on('shown.bs.modal', function() { |
| 185 | $("#multiple_bookings").val($("#multiple_bookings_select").val()); |
| 186 | if ($("#multiple_bookings").val() == "custom") { |
| 187 | $("#multiple_bookings_custom_div").show(); |
| 188 | $("#multiple_bookings").val($("#multiple_bookings_custom").val()); |
| 189 | } |
| 190 | }) |
| 191 | $("#multiple_bookings_select").change(function() { |
| 192 | $("#multiple_bookings").val($("#multiple_bookings_select").val()); |
| 193 | if ($("#multiple_bookings").val() == "custom") { |
| 194 | $("#multiple_bookings_custom_div").show(); |
| 195 | } |
| 196 | else { |
| 197 | $("#multiple_bookings_custom_div").hide(); |
| 198 | } |
| 199 | }); |
| 200 | $("#multiple_bookings_custom").bind ("change keypress keyup blur", function () { |
| 201 | $("#multiple_bookings").val($("#multiple_bookings_custom").val()); |
| 202 | }); |
| 203 | |
| 204 | |
| 205 | }); |
| 206 | jQuery(function($){ |
| 207 | // http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery |
| 208 | var entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="}; |
| 209 | function escapeHtml(n){return String(n).replace(/[&<>"'`=\/]/g,function(n){return entityMap[n]})} |
| 210 | // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript |
| 211 | 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]} |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 212 | function unix_time_format(i){return""==i?'<i class="bi bi-x-lg"></i>':new Date(i?1e3*i:0).toLocaleDateString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 213 | $(".refresh_table").on('click', function(e) { |
| 214 | e.preventDefault(); |
| 215 | var table_name = $(this).data('table'); |
| 216 | $('#' + table_name).find("tr.footable-empty").remove(); |
| 217 | draw_table = $(this).data('draw'); |
| 218 | eval(draw_table + '()'); |
| 219 | }); |
| 220 | function table_mailbox_ready(ft, name) { |
| 221 | if(is_dual) { |
| 222 | $('.login_as').data("toggle", "tooltip") |
| 223 | .attr("disabled", true) |
| 224 | .removeAttr("href") |
| 225 | .attr("title", "Dual login cannot be used twice") |
| 226 | .tooltip(); |
| 227 | } |
| 228 | $('.refresh_table').prop("disabled", false); |
| 229 | heading = ft.$el.parents('.panel').find('.panel-heading') |
| 230 | var ft_paging = ft.use(FooTable.Paging) |
| 231 | $(heading).children('.table-lines').text(function(){ |
| 232 | var total_rows = ft_paging.totalRows; |
| 233 | var size = ft_paging.size; |
| 234 | if (size > total_rows) { |
| 235 | size = total_rows; |
| 236 | } |
| 237 | return size + ' / ' + total_rows; |
| 238 | }) |
| 239 | } |
| 240 | function draw_domain_table() { |
| 241 | ft_domain_table = FooTable.init('#domain_table', { |
| 242 | "columns": [ |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 243 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 244 | {"sorted": true,"name":"domain_name","title":lang.domain,"style":{"width":"250px"}}, |
| 245 | {"name":"aliases","title":lang.aliases,"breakpoints":"xs sm"}, |
| 246 | {"name":"mailboxes","title":lang.mailboxes}, |
| 247 | {"name":"quota","style":{"whiteSpace":"nowrap"},"title":lang.domain_quota,"formatter": function(value){ |
| 248 | res = value.split("/"); |
| 249 | return humanFileSize(res[0]) + " / " + humanFileSize(res[1]); |
| 250 | }, |
| 251 | "sortValue": function(value){ |
| 252 | res = value.split("/"); |
| 253 | return Number(res[0]); |
| 254 | }}, |
| 255 | {"name":"stats","sortable": false,"style":{"whiteSpace":"nowrap"},"title":lang.stats,"formatter": function(value){ |
| 256 | res = value.split("/"); |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 257 | return '<i class="bi bi-files"></i> ' + res[0] + ' / ' + humanFileSize(res[1]); |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 258 | }}, |
| 259 | {"name":"def_quota_for_mbox","title":lang.mailbox_defquota,"breakpoints":"xs sm md","style":{"width":"125px"}}, |
| 260 | {"name":"max_quota_for_mbox","title":lang.mailbox_quota,"breakpoints":"xs sm","style":{"width":"125px"}}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 261 | {"name":"rl","title":"RL","breakpoints":"xs sm md lg","style":{"min-width":"100px","width":"100px"}}, |
| 262 | {"name":"backupmx","filterable": false,"style":{"min-width":"120px","width":"120px"},"title":lang.backup_mx,"breakpoints":"xs sm md lg","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] | 263 | {"name":"domain_admins","title":lang.domain_admins,"style":{"word-break":"break-all","min-width":"200px"},"breakpoints":"xs sm md lg","filterable":(role == "admin"),"visible":(role == "admin")}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 264 | {"name":"active","filterable": false,"style":{"min-width":"80px","width":"80px"},"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>';}}, |
| 265 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"240px","width":"240px"},"type":"html","title":lang.action,"breakpoints":"xs sm md"} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 266 | ], |
| 267 | "rows": $.ajax({ |
| 268 | dataType: 'json', |
| 269 | url: '/api/v1/get/domain/all', |
| 270 | jsonp: false, |
| 271 | error: function (data) { |
| 272 | console.log('Cannot draw domain table'); |
| 273 | }, |
| 274 | success: function (data) { |
| 275 | $.each(data, function (i, item) { |
| 276 | item.aliases = item.aliases_in_domain + " / " + item.max_num_aliases_for_domain; |
| 277 | item.mailboxes = item.mboxes_in_domain + " / " + item.max_num_mboxes_for_domain; |
| 278 | item.quota = item.quota_used_in_domain + "/" + item.max_quota_for_domain + "/" + item.bytes_total; |
| 279 | item.stats = item.msgs_total + "/" + item.bytes_total; |
| 280 | if (!item.rl) { |
| 281 | item.rl = '∞'; |
| 282 | } else { |
| 283 | item.rl = $.map(item.rl, function(e){ |
| 284 | return e; |
| 285 | }).join('/1'); |
| 286 | } |
| 287 | item.def_quota_for_mbox = humanFileSize(item.def_quota_for_mbox); |
| 288 | item.max_quota_for_mbox = humanFileSize(item.max_quota_for_mbox); |
| 289 | item.chkbox = '<input type="checkbox" data-id="domain" name="multi_select" value="' + encodeURIComponent(item.domain_name) + '" />'; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 290 | item.action = '<div class="btn-group footable-actions">'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 291 | if (role == "admin") { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 292 | item.action += '<a href="/edit/domain/' + encodeURIComponent(item.domain_name) + '" class="btn btn-xs btn-xs-third btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' + |
| 293 | '<a href="#" data-action="delete_selected" data-id="single-domain" data-api-url="delete/domain" data-item="' + encodeURIComponent(item.domain_name) + '" class="btn btn-xs btn-xs-third btn-danger"><i class="bi bi-trash"></i> ' + lang.remove + '</a>' + |
| 294 | '<a href="#dnsInfoModal" class="btn btn-xs btn-xs-third btn-info" data-toggle="modal" data-domain="' + encodeURIComponent(item.domain_name) + '"><i class="bi bi-globe2"></i> DNS</a></div>'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 295 | } |
| 296 | else { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 297 | item.action += '<a href="/edit/domain/' + encodeURIComponent(item.domain_name) + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' + |
| 298 | '<a href="#dnsInfoModal" class="btn btn-xs btn-xs-half btn-info" data-toggle="modal" data-domain="' + encodeURIComponent(item.domain_name) + '"><i class="bi bi-globe2"></i> DNS</a></div>'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 299 | } |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 300 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 301 | if (item.backupmx == 1) { |
| 302 | if (item.relay_unknown_only == 1) { |
| 303 | item.domain_name = '<div class="label label-info">Relay Non-Local</div> ' + item.domain_name; |
| 304 | } else if (item.relay_all_recipients == 1) { |
| 305 | item.domain_name = '<div class="label label-info">Relay All</div> ' + item.domain_name; |
| 306 | } else { |
| 307 | item.domain_name = '<div class="label label-info">Relay</div> ' + item.domain_name; |
| 308 | } |
| 309 | } |
| 310 | }); |
| 311 | } |
| 312 | }), |
| 313 | "empty": lang.empty, |
| 314 | "paging": { |
| 315 | "enabled": true, |
| 316 | "limit": 5, |
| 317 | "size": pagination_size |
| 318 | }, |
| 319 | "state": { |
| 320 | "enabled": true |
| 321 | }, |
| 322 | "filtering": { |
| 323 | "enabled": true, |
| 324 | "delay": 1200, |
| 325 | "position": "left", |
| 326 | "connectors": false, |
| 327 | "placeholder": lang.filter_table |
| 328 | }, |
| 329 | "sorting": { |
| 330 | "enabled": true |
| 331 | }, |
| 332 | "on": { |
| 333 | "destroy.ft.table": function(e, ft){ |
| 334 | $('.refresh_table').attr('disabled', 'true'); |
| 335 | }, |
| 336 | "ready.ft.table": function(e, ft){ |
| 337 | table_mailbox_ready(ft, 'domain_table'); |
| 338 | }, |
| 339 | "after.ft.filtering": function(e, ft){ |
| 340 | table_mailbox_ready(ft, 'domain_table'); |
| 341 | } |
| 342 | }, |
| 343 | "toggleSelector": "table tbody span.footable-toggle" |
| 344 | }); |
| 345 | } |
| 346 | function draw_mailbox_table() { |
| 347 | ft_mailbox_table = FooTable.init('#mailbox_table', { |
| 348 | "columns": [ |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 349 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 350 | {"sorted": true,"name":"username","style":{"word-break":"break-all","min-width":"120px"},"title":lang.username}, |
| 351 | {"name":"name","title":lang.fname,"style":{"word-break":"break-all","min-width":"120px"},"breakpoints":"xs sm md lg"}, |
| 352 | {"name":"domain","title":lang.domain,"breakpoints":"xs sm md lg"}, |
| 353 | {"name":"quota","style":{"whiteSpace":"nowrap"},"title":lang.domain_quota,"formatter": function(value){ |
| 354 | res = value.split("/"); |
| 355 | var of_q = (res[1] == 0 ? "∞" : humanFileSize(res[1])); |
| 356 | return humanFileSize(res[0]) + " / " + of_q; |
| 357 | }, |
| 358 | "sortValue": function(value){ |
| 359 | res = value.split("/"); |
| 360 | return Number(res[0]); |
| 361 | }, |
| 362 | }, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 363 | /* {"name":"spam_aliases","filterable": false,"title":lang.spam_aliases,"breakpoints":"all"}, */ |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 364 | {"name":"tls_enforce_in","filterable": false,"title":lang.tls_enforce_in,"breakpoints":"all"}, |
| 365 | {"name":"tls_enforce_out","filterable": false,"title":lang.tls_enforce_out,"breakpoints":"all"}, |
| 366 | {"name":"smtp_access","filterable": false,"title":"SMTP","breakpoints":"all"}, |
| 367 | {"name":"imap_access","filterable": false,"title":"IMAP","breakpoints":"all"}, |
| 368 | {"name":"pop3_access","filterable": false,"title":"POP3","breakpoints":"all"}, |
| 369 | {"name":"last_mail_login","breakpoints":"xs sm","title":lang.last_mail_login,"style":{"width":"170px"}, |
| 370 | "sortValue": function(value){ |
| 371 | res = value.split("/"); |
| 372 | return Math.max(res[0], res[1]); |
| 373 | }, |
| 374 | "formatter": function(value){ |
| 375 | res = value.split("/"); |
| 376 | return '<div class="label label-last-login">IMAP @ ' + unix_time_format(Number(res[0])) + '</div><br>' + |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 377 | '<div class="label label-last-login">POP3 @ ' + unix_time_format(Number(res[1])) + '</div><br>' + |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 378 | '<div class="label label-last-login">SMTP @ ' + unix_time_format(Number(res[2])) + '</div>'; |
| 379 | }}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 380 | {"name":"last_pw_change","filterable": false,"title":lang.last_pw_change,"breakpoints":"all"}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 381 | {"name":"quarantine_notification","filterable": false,"title":lang.quarantine_notification,"breakpoints":"all"}, |
| 382 | {"name":"quarantine_category","filterable": false,"title":lang.quarantine_category,"breakpoints":"all"}, |
| 383 | {"name":"in_use","filterable": false,"type":"html","title":lang.in_use,"sortValue": function(value){ |
| 384 | return Number($(value).find(".progress-bar-mailbox").attr('aria-valuenow')); |
| 385 | }, |
| 386 | }, |
| 387 | {"name":"messages","filterable": false,"title":lang.msg_num,"breakpoints":"xs sm md"}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 388 | /* {"name":"rl","title":"RL","breakpoints":"all","style":{"width":"125px"}}, */ |
| 389 | {"name":"active","filterable": false,"style":{"min-width":"80px","width":"80px"},"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>':2==value&&'—');}}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 390 | {"name":"action","filterable": false,"sortable": false,"style":{"min-width":"290px","text-align":"right"},"type":"html","title":lang.action,"breakpoints":"xs sm md"} |
| 391 | ], |
| 392 | "empty": lang.empty, |
| 393 | "rows": $.ajax({ |
| 394 | dataType: 'json', |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 395 | url: '/api/v1/get/mailbox/reduced', |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 396 | jsonp: false, |
| 397 | error: function () { |
| 398 | console.log('Cannot draw mailbox table'); |
| 399 | }, |
| 400 | success: function (data) { |
| 401 | $.each(data, function (i, item) { |
| 402 | item.quota = item.quota_used + "/" + item.quota; |
| 403 | item.max_quota_for_mbox = humanFileSize(item.max_quota_for_mbox); |
| 404 | item.last_mail_login = item.last_imap_login + '/' + item.last_pop3_login + '/' + item.last_smtp_login; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 405 | /* |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 406 | if (!item.rl) { |
| 407 | item.rl = '∞'; |
| 408 | } else { |
| 409 | item.rl = $.map(item.rl, function(e){ |
| 410 | return e; |
| 411 | }).join('/1'); |
| 412 | if (item.rl_scope === 'domain') { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 413 | item.rl = '<i class="bi bi-arrow-return-right"></i> ' + item.rl + ' (via ' + item.domain + ')'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 414 | } |
| 415 | } |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 416 | */ |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 417 | item.chkbox = '<input type="checkbox" data-id="mailbox" name="multi_select" value="' + encodeURIComponent(item.username) + '" />'; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 418 | if (item.attributes.passwd_update != '0') { |
| 419 | var last_pw_change = new Date(item.attributes.passwd_update.replace(/-/g, "/")); |
| 420 | item.last_pw_change = last_pw_change.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"}); |
| 421 | } else { |
| 422 | item.last_pw_change = '-'; |
| 423 | } |
| 424 | item.tls_enforce_in = '<i class="text-' + (item.attributes.tls_enforce_in == 1 ? 'success bi bi-lock-fill' : 'danger bi bi-unlock-fill') + '"></i>'; |
| 425 | item.tls_enforce_out = '<i class="text-' + (item.attributes.tls_enforce_out == 1 ? 'success bi bi-lock-fill' : 'danger bi bi-unlock-fill') + '"></i>'; |
| 426 | item.pop3_access = '<i class="text-' + (item.attributes.pop3_access == 1 ? 'success' : 'danger') + ' bi bi-' + (item.attributes.pop3_access == 1 ? 'check-lg' : 'x-lg') + '"></i>'; |
| 427 | item.imap_access = '<i class="text-' + (item.attributes.imap_access == 1 ? 'success' : 'danger') + ' bi bi-' + (item.attributes.imap_access == 1 ? 'check-lg' : 'x-lg') + '"></i>'; |
| 428 | item.smtp_access = '<i class="text-' + (item.attributes.smtp_access == 1 ? 'success' : 'danger') + ' bi bi-' + (item.attributes.smtp_access == 1 ? 'check-lg' : 'x-lg') + '"></i>'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 429 | if (item.attributes.quarantine_notification === 'never') { |
| 430 | item.quarantine_notification = lang.never; |
| 431 | } else if (item.attributes.quarantine_notification === 'hourly') { |
| 432 | item.quarantine_notification = lang.hourly; |
| 433 | } else if (item.attributes.quarantine_notification === 'daily') { |
| 434 | item.quarantine_notification = lang.daily; |
| 435 | } else if (item.attributes.quarantine_notification === 'weekly') { |
| 436 | item.quarantine_notification = lang.weekly; |
| 437 | } |
| 438 | if (item.attributes.quarantine_category === 'reject') { |
| 439 | item.quarantine_category = '<span class="text-danger">' + lang.q_reject + '</span>'; |
| 440 | } else if (item.attributes.quarantine_category === 'add_header') { |
| 441 | item.quarantine_category = '<span class="text-warning">' + lang.q_add_header + '</span>'; |
| 442 | } else if (item.attributes.quarantine_category === 'all') { |
| 443 | item.quarantine_category = lang.q_all; |
| 444 | } |
| 445 | if (acl_data.login_as === 1) { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 446 | var btnSize = 'btn-xs-third'; |
| 447 | if (ALLOW_ADMIN_EMAIL_LOGIN) btnSize = 'btn-xs-quart'; |
| 448 | |
| 449 | item.action = '<div class="btn-group footable-actions">' + |
| 450 | '<a href="/edit/mailbox/' + encodeURIComponent(item.username) + '" class="btn btn-xs ' + btnSize + ' btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' + |
| 451 | '<a href="#" data-action="delete_selected" data-id="single-mailbox" data-api-url="delete/mailbox" data-item="' + encodeURIComponent(item.username) + '" class="btn btn-xs ' + btnSize + ' btn-danger"><i class="bi bi-trash"></i> ' + lang.remove + '</a>' + |
| 452 | '<a href="/index.php?duallogin=' + encodeURIComponent(item.username) + '" class="login_as btn btn-xs ' + btnSize + ' btn-success"><i class="bi bi-person-fill"></i> Login</a>'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 453 | if (ALLOW_ADMIN_EMAIL_LOGIN) { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 454 | item.action += '<a href="/sogo-auth.php?login=' + encodeURIComponent(item.username) + '" class="login_as btn btn-xs ' + btnSize + ' btn-primary" target="_blank"><i class="bi bi-envelope-fill"></i> SOGo</a>'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 455 | } |
| 456 | item.action += '</div>'; |
| 457 | } |
| 458 | else { |
| 459 | item.action = '<div class="btn-group">' + |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 460 | '<a href="/edit/mailbox/' + encodeURIComponent(item.username) + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' + |
| 461 | '<a href="#" data-action="delete_selected" data-id="single-mailbox" data-api-url="delete/mailbox" data-item="' + encodeURIComponent(item.username) + '" 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] | 462 | '</div>'; |
| 463 | } |
| 464 | item.in_use = '<div class="progress">' + |
| 465 | '<div class="progress-bar-mailbox progress-bar progress-bar-' + item.percent_class + '" role="progressbar" aria-valuenow="' + item.percent_in_use + '" aria-valuemin="0" aria-valuemax="100" ' + |
| 466 | 'style="min-width:2em;width:' + item.percent_in_use + '%">' + item.percent_in_use + '%' + '</div></div>'; |
| 467 | item.username = escapeHtml(item.username); |
| 468 | }); |
| 469 | } |
| 470 | }), |
| 471 | "paging": { |
| 472 | "enabled": true, |
| 473 | "limit": 5, |
| 474 | "size": pagination_size |
| 475 | }, |
| 476 | "state": { |
| 477 | "enabled": true |
| 478 | }, |
| 479 | "filtering": { |
| 480 | "enabled": true, |
| 481 | "delay": 1200, |
| 482 | "position": "left", |
| 483 | "connectors": false, |
| 484 | //"container": "#tab-mailboxes.panel", |
| 485 | "placeholder": lang.filter_table |
| 486 | }, |
| 487 | "components": { |
| 488 | "filtering": FooTable.domainFilter |
| 489 | }, |
| 490 | "sorting": { |
| 491 | "enabled": true |
| 492 | }, |
| 493 | "on": { |
| 494 | "destroy.ft.table": function(e, ft){ |
| 495 | $('.refresh_table').attr('disabled', 'true'); |
| 496 | }, |
| 497 | "ready.ft.table": function(e, ft){ |
| 498 | table_mailbox_ready(ft, 'mailbox_table'); |
| 499 | }, |
| 500 | "after.ft.filtering": function(e, ft){ |
| 501 | table_mailbox_ready(ft, 'mailbox_table'); |
| 502 | } |
| 503 | }, |
| 504 | "toggleSelector": "table tbody span.footable-toggle" |
| 505 | }); |
| 506 | } |
| 507 | function draw_resource_table() { |
| 508 | ft_resource_table = FooTable.init('#resource_table', { |
| 509 | "columns": [ |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 510 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 511 | {"sorted": true,"name":"description","title":lang.description,"style":{"width":"250px"}}, |
| 512 | {"name":"name","title":lang.alias}, |
| 513 | {"name":"kind","title":lang.kind}, |
| 514 | {"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 515 | {"name":"multiple_bookings","filterable": false,"style":{"min-width":"150px","width":"140px"},"title":lang.multiple_bookings,"breakpoints":"xs sm"}, |
| 516 | {"name":"active","filterable": false,"style":{"min-width":"80px","width":"80px"},"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>';}}, |
| 517 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 518 | ], |
| 519 | "empty": lang.empty, |
| 520 | "rows": $.ajax({ |
| 521 | dataType: 'json', |
| 522 | url: '/api/v1/get/resource/all', |
| 523 | jsonp: false, |
| 524 | error: function () { |
| 525 | console.log('Cannot draw resource table'); |
| 526 | }, |
| 527 | success: function (data) { |
| 528 | $.each(data, function (i, item) { |
| 529 | if (item.multiple_bookings == '0') { |
| 530 | item.multiple_bookings = '<span id="active-script" class="label label-success">' + lang.booking_0_short + '</span>'; |
| 531 | } else if (item.multiple_bookings == '-1') { |
| 532 | item.multiple_bookings = '<span id="active-script" class="label label-warning">' + lang.booking_lt0_short + '</span>'; |
| 533 | } else { |
| 534 | item.multiple_bookings = '<span id="active-script" class="label label-danger">' + lang.booking_custom_short + ' (' + item.multiple_bookings + ')</span>'; |
| 535 | } |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 536 | item.action = '<div class="btn-group footable-actions">' + |
| 537 | '<a href="/edit/resource/' + encodeURIComponent(item.name) + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' + |
| 538 | '<a href="#" data-action="delete_selected" data-id="single-resource" data-api-url="delete/resource" data-item="' + item.name + '" 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] | 539 | '</div>'; |
| 540 | item.chkbox = '<input type="checkbox" data-id="resource" name="multi_select" value="' + encodeURIComponent(item.name) + '" />'; |
| 541 | item.name = escapeHtml(item.name); |
| 542 | }); |
| 543 | } |
| 544 | }), |
| 545 | "paging": { |
| 546 | "enabled": true, |
| 547 | "limit": 5, |
| 548 | "size": pagination_size |
| 549 | }, |
| 550 | "state": { |
| 551 | "enabled": true |
| 552 | }, |
| 553 | "filtering": { |
| 554 | "enabled": true, |
| 555 | "delay": 1200, |
| 556 | "position": "left", |
| 557 | "connectors": false, |
| 558 | "placeholder": lang.filter_table |
| 559 | }, |
| 560 | "components": { |
| 561 | "filtering": FooTable.domainFilter |
| 562 | }, |
| 563 | "sorting": { |
| 564 | "enabled": true |
| 565 | }, |
| 566 | "on": { |
| 567 | "destroy.ft.table": function(e, ft){ |
| 568 | $('.refresh_table').attr('disabled', 'true'); |
| 569 | }, |
| 570 | "ready.ft.table": function(e, ft){ |
| 571 | table_mailbox_ready(ft, 'resource_table'); |
| 572 | }, |
| 573 | "after.ft.filtering": function(e, ft){ |
| 574 | table_mailbox_ready(ft, 'resource_table'); |
| 575 | } |
| 576 | }, |
| 577 | "toggleSelector": "table tbody span.footable-toggle" |
| 578 | }); |
| 579 | } |
| 580 | function draw_bcc_table() { |
| 581 | ft_bcc_table = FooTable.init('#bcc_table', { |
| 582 | "columns": [ |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 583 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, |
| 584 | {"sorted": true,"name":"id","title":"ID","style":{"min-width":"60px","width":"60px","text-align":"center"}}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 585 | {"name":"type","title":lang.bcc_type}, |
| 586 | {"name":"local_dest","title":lang.bcc_local_dest}, |
| 587 | {"name":"bcc_dest","title":lang.bcc_destinations}, |
| 588 | {"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 589 | {"name":"active","filterable": false,"style":{"min-width":"80px","width":"80px"},"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>';}}, |
| 590 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 591 | ], |
| 592 | "empty": lang.empty, |
| 593 | "rows": $.ajax({ |
| 594 | dataType: 'json', |
| 595 | url: '/api/v1/get/bcc/all', |
| 596 | jsonp: false, |
| 597 | error: function () { |
| 598 | console.log('Cannot draw bcc table'); |
| 599 | }, |
| 600 | success: function (data) { |
| 601 | $.each(data, function (i, item) { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 602 | item.action = '<div class="btn-group footable-actions">' + |
| 603 | '<a href="/edit/bcc/' + item.id + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' + |
| 604 | '<a href="#" data-action="delete_selected" data-id="single-bcc" data-api-url="delete/bcc" 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] | 605 | '</div>'; |
| 606 | item.chkbox = '<input type="checkbox" data-id="bcc" name="multi_select" value="' + item.id + '" />'; |
| 607 | item.local_dest = escapeHtml(item.local_dest); |
| 608 | item.bcc_dest = escapeHtml(item.bcc_dest); |
| 609 | if (item.type == 'sender') { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 610 | item.type = '<span id="active-script" class="label label-success">' + lang.bcc_sender_map + '</span>'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 611 | } else { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 612 | item.type = '<span id="inactive-script" class="label label-warning">' + lang.bcc_rcpt_map + '</span>'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 613 | } |
| 614 | }); |
| 615 | } |
| 616 | }), |
| 617 | "paging": { |
| 618 | "enabled": true, |
| 619 | "limit": 5, |
| 620 | "size": pagination_size |
| 621 | }, |
| 622 | "state": { |
| 623 | "enabled": true |
| 624 | }, |
| 625 | "filtering": { |
| 626 | "enabled": true, |
| 627 | "delay": 1200, |
| 628 | "position": "left", |
| 629 | "connectors": false, |
| 630 | "placeholder": lang.filter_table |
| 631 | }, |
| 632 | "sorting": { |
| 633 | "enabled": true |
| 634 | }, |
| 635 | "on": { |
| 636 | "destroy.ft.table": function(e, ft){ |
| 637 | $('.refresh_table').attr('disabled', 'true'); |
| 638 | }, |
| 639 | "ready.ft.table": function(e, ft){ |
| 640 | table_mailbox_ready(ft, 'bcc_table'); |
| 641 | }, |
| 642 | "after.ft.filtering": function(e, ft){ |
| 643 | table_mailbox_ready(ft, 'bcc_table'); |
| 644 | } |
| 645 | }, |
| 646 | "toggleSelector": "table tbody span.footable-toggle" |
| 647 | }); |
| 648 | } |
| 649 | function draw_recipient_map_table() { |
| 650 | ft_recipient_map_table = FooTable.init('#recipient_map_table', { |
| 651 | "columns": [ |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 652 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, |
| 653 | {"sorted": true,"name":"id","title":"ID","style":{"min-width":"60px","width":"60px","text-align":"center"}}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 654 | {"name":"recipient_map_old","title":lang.recipient_map_old}, |
| 655 | {"name":"recipient_map_new","title":lang.recipient_map_new}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 656 | {"name":"active","filterable": false,"style":{"min-width":"80px","width":"80px"},"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>';}}, |
| 657 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"180px","width":"180px"},"type":"html","title":(role == "admin" ? lang.action : ""),"breakpoints":"xs sm"} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 658 | ], |
| 659 | "empty": lang.empty, |
| 660 | "rows": $.ajax({ |
| 661 | dataType: 'json', |
| 662 | url: '/api/v1/get/recipient_map/all', |
| 663 | jsonp: false, |
| 664 | error: function () { |
| 665 | console.log('Cannot draw recipient map table'); |
| 666 | }, |
| 667 | success: function (data) { |
| 668 | if (role == "admin") { |
| 669 | $.each(data, function (i, item) { |
| 670 | item.recipient_map_old = escapeHtml(item.recipient_map_old); |
| 671 | item.recipient_map_new = escapeHtml(item.recipient_map_new); |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 672 | item.action = '<div class="btn-group footable-actions">' + |
| 673 | '<a href="/edit/recipient_map/' + item.id + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' + |
| 674 | '<a href="#" data-action="delete_selected" data-id="single-recipient_map" data-api-url="delete/recipient_map" 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] | 675 | '</div>'; |
| 676 | item.chkbox = '<input type="checkbox" data-id="recipient_map" name="multi_select" value="' + item.id + '" />'; |
| 677 | }); |
| 678 | } |
| 679 | } |
| 680 | }), |
| 681 | "paging": { |
| 682 | "enabled": true, |
| 683 | "limit": 5, |
| 684 | "size": pagination_size |
| 685 | }, |
| 686 | "state": { |
| 687 | "enabled": true |
| 688 | }, |
| 689 | "filtering": { |
| 690 | "enabled": true, |
| 691 | "delay": 1200, |
| 692 | "position": "left", |
| 693 | "connectors": false, |
| 694 | "placeholder": lang.filter_table |
| 695 | }, |
| 696 | "sorting": { |
| 697 | "enabled": true |
| 698 | }, |
| 699 | "on": { |
| 700 | "destroy.ft.table": function(e, ft){ |
| 701 | $('.refresh_table').attr('disabled', 'true'); |
| 702 | }, |
| 703 | "ready.ft.table": function(e, ft){ |
| 704 | table_mailbox_ready(ft, 'recipient_map_table'); |
| 705 | }, |
| 706 | "after.ft.filtering": function(e, ft){ |
| 707 | table_mailbox_ready(ft, 'recipient_map_table'); |
| 708 | } |
| 709 | }, |
| 710 | "toggleSelector": "table tbody span.footable-toggle" |
| 711 | }); |
| 712 | } |
| 713 | function draw_tls_policy_table() { |
| 714 | ft_tls_policy_table = FooTable.init('#tls_policy_table', { |
| 715 | "columns": [ |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 716 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, |
| 717 | {"sorted": true,"name":"id","title":"ID","style":{"min-width":"60px","width":"60px","text-align":"center"}}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 718 | {"name":"dest","title":lang.tls_map_dest}, |
| 719 | {"name":"policy","title":lang.tls_map_policy}, |
| 720 | {"name":"parameters","title":lang.tls_map_parameters}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 721 | {"name":"active","filterable": false,"style":{"min-width":"80px","width":"80px"},"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>';}}, |
| 722 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"180px","width":"180px"},"type":"html","title":(role == "admin" ? lang.action : ""),"breakpoints":"xs sm"} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 723 | ], |
| 724 | "empty": lang.empty, |
| 725 | "rows": $.ajax({ |
| 726 | dataType: 'json', |
| 727 | url: '/api/v1/get/tls-policy-map/all', |
| 728 | jsonp: false, |
| 729 | error: function () { |
| 730 | console.log('Cannot draw tls policy map table'); |
| 731 | }, |
| 732 | success: function (data) { |
| 733 | if (role == "admin") { |
| 734 | $.each(data, function (i, item) { |
| 735 | item.dest = escapeHtml(item.dest); |
| 736 | item.policy = '<b>' + escapeHtml(item.policy) + '</b>'; |
| 737 | if (item.parameters == '') { |
| 738 | item.parameters = '<code>-</code>'; |
| 739 | } else { |
| 740 | item.parameters = '<code>' + escapeHtml(item.parameters) + '</code>'; |
| 741 | } |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 742 | item.action = '<div class="btn-group footable-actions">' + |
| 743 | '<a href="/edit/tls_policy_map/' + item.id + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' + |
| 744 | '<a href="#" data-action="delete_selected" data-id="single-tls-policy-map" data-api-url="delete/tls-policy-map" 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] | 745 | '</div>'; |
| 746 | item.chkbox = '<input type="checkbox" data-id="tls-policy-map" name="multi_select" value="' + item.id + '" />'; |
| 747 | }); |
| 748 | } |
| 749 | } |
| 750 | }), |
| 751 | "paging": { |
| 752 | "enabled": true, |
| 753 | "limit": 5, |
| 754 | "size": pagination_size |
| 755 | }, |
| 756 | "state": { |
| 757 | "enabled": true |
| 758 | }, |
| 759 | "filtering": { |
| 760 | "enabled": true, |
| 761 | "delay": 1200, |
| 762 | "position": "left", |
| 763 | "connectors": false, |
| 764 | "placeholder": lang.filter_table |
| 765 | }, |
| 766 | "sorting": { |
| 767 | "enabled": true |
| 768 | }, |
| 769 | "on": { |
| 770 | "destroy.ft.table": function(e, ft){ |
| 771 | $('.refresh_table').attr('disabled', 'true'); |
| 772 | }, |
| 773 | "ready.ft.table": function(e, ft){ |
| 774 | table_mailbox_ready(ft, 'tls_policy_table'); |
| 775 | }, |
| 776 | "after.ft.filtering": function(e, ft){ |
| 777 | table_mailbox_ready(ft, 'tls_policy_table'); |
| 778 | } |
| 779 | }, |
| 780 | "toggleSelector": "table tbody span.footable-toggle" |
| 781 | }); |
| 782 | } |
| 783 | function draw_alias_table() { |
| 784 | ft_alias_table = FooTable.init('#alias_table', { |
| 785 | "columns": [ |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 786 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, |
| 787 | {"name":"id","title":"ID","style":{"min-width":"60px","width":"60px","text-align":"center"}}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 788 | {"sorted": true,"name":"address","title":lang.alias,"style":{"width":"250px"}}, |
| 789 | {"name":"goto","title":lang.target_address}, |
| 790 | {"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, |
| 791 | {"name":"public_comment","title":lang.public_comment,"breakpoints":"all"}, |
| 792 | {"name":"private_comment","title":lang.private_comment,"breakpoints":"all"}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 793 | {"name":"sogo_visible","title":lang.sogo_visible,"formatter": function(value){return 1==value?'<i class="bi bi-check-lg"></i>':0==value&&'<i class="bi bi-x-lg"></i>';},"breakpoints":"all"}, |
| 794 | {"name":"active","filterable": false,"style":{"min-width":"80px","width":"80px"},"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>';}}, |
| 795 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 796 | ], |
| 797 | "empty": lang.empty, |
| 798 | "rows": $.ajax({ |
| 799 | dataType: 'json', |
| 800 | url: '/api/v1/get/alias/all', |
| 801 | jsonp: false, |
| 802 | error: function () { |
| 803 | console.log('Cannot draw alias table'); |
| 804 | }, |
| 805 | success: function (data) { |
| 806 | $.each(data, function (i, item) { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 807 | item.action = '<div class="btn-group footable-actions">' + |
| 808 | '<a href="/edit/alias/' + encodeURIComponent(item.id) + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' + |
| 809 | '<a href="#" data-action="delete_selected" data-id="single-alias" data-api-url="delete/alias" data-item="' + encodeURIComponent(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] | 810 | '</div>'; |
| 811 | item.chkbox = '<input type="checkbox" data-id="alias" name="multi_select" value="' + encodeURIComponent(item.id) + '" />'; |
| 812 | item.goto = escapeHtml(item.goto.replace(/,/g, " ")); |
| 813 | if (item.public_comment !== null) { |
| 814 | item.public_comment = escapeHtml(item.public_comment); |
| 815 | } |
| 816 | else { |
| 817 | item.public_comment = '-'; |
| 818 | } |
| 819 | if (item.private_comment !== null) { |
| 820 | item.private_comment = escapeHtml(item.private_comment); |
| 821 | } |
| 822 | else { |
| 823 | item.private_comment = '-'; |
| 824 | } |
| 825 | if (item.is_catch_all == 1) { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 826 | item.address = '<div class="label label-default">' + lang.catch_all + '</div> ' + escapeHtml(item.address); |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 827 | } |
| 828 | else { |
| 829 | item.address = escapeHtml(item.address); |
| 830 | } |
| 831 | if (item.goto == "null@localhost") { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 832 | item.goto = '⤷ <i class="bi bi-trash" style="font-size:12px"></i>'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 833 | } |
| 834 | else if (item.goto == "spam@localhost") { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 835 | item.goto = '<span class="label label-danger">' + lang.goto_spam + '</span>'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 836 | } |
| 837 | else if (item.goto == "ham@localhost") { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 838 | item.goto = '<span class="label label-success">' + lang.goto_ham + '</span>'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 839 | } |
| 840 | if (item.in_primary_domain !== "") { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 841 | item.domain = '<i data-domainname="' + item.domain + '" class="bi bi-info-circle-fill alias-domain-info text-info" data-toggle="tooltip" title="' + lang.target_domain + ': ' + item.in_primary_domain + '"></i> ' + item.domain; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 842 | } |
| 843 | }); |
| 844 | } |
| 845 | }), |
| 846 | "paging": { |
| 847 | "enabled": true, |
| 848 | "limit": 5, |
| 849 | "size": pagination_size |
| 850 | }, |
| 851 | "state": { |
| 852 | "enabled": true |
| 853 | }, |
| 854 | "filtering": { |
| 855 | "enabled": true, |
| 856 | "delay": 1200, |
| 857 | "position": "left", |
| 858 | "connectors": false, |
| 859 | "placeholder": lang.filter_table |
| 860 | }, |
| 861 | "components": { |
| 862 | "filtering": FooTable.domainFilter |
| 863 | }, |
| 864 | "sorting": { |
| 865 | "enabled": true |
| 866 | }, |
| 867 | "on": { |
| 868 | "destroy.ft.table": function(e, ft){ |
| 869 | $('.refresh_table').attr('disabled', 'true'); |
| 870 | }, |
| 871 | "ready.ft.table": function(e, ft){ |
| 872 | table_mailbox_ready(ft, 'alias_table'); |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 873 | $('.alias-domain-info').tooltip(); |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 874 | }, |
| 875 | "after.ft.filtering": function(e, ft){ |
| 876 | table_mailbox_ready(ft, 'alias_table'); |
| 877 | } |
| 878 | }, |
| 879 | "toggleSelector": "table tbody span.footable-toggle" |
| 880 | }); |
| 881 | } |
| 882 | |
| 883 | function draw_aliasdomain_table() { |
| 884 | ft_aliasdomain_table = FooTable.init('#aliasdomain_table', { |
| 885 | "columns": [ |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 886 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 887 | {"sorted": true,"name":"alias_domain","title":lang.alias,"style":{"width":"250px"}}, |
| 888 | {"name":"target_domain","title":lang.target_domain,"type":"html"}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 889 | {"name":"active","filterable": false,"style":{"min-width":"80px","width":"80px"},"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>';}}, |
| 890 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"250px","width":"250px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 891 | ], |
| 892 | "empty": lang.empty, |
| 893 | "rows": $.ajax({ |
| 894 | dataType: 'json', |
| 895 | url: '/api/v1/get/alias-domain/all', |
| 896 | jsonp: false, |
| 897 | error: function () { |
| 898 | console.log('Cannot draw alias domain table'); |
| 899 | }, |
| 900 | success: function (data) { |
| 901 | $.each(data, function (i, item) { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 902 | item.action = '<div class="btn-group footable-actions">' + |
| 903 | '<a href="/edit/aliasdomain/' + encodeURIComponent(item.alias_domain) + '" class="btn btn-xs btn-xs-third btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' + |
| 904 | '<a href="#" data-action="delete_selected" data-id="single-alias-domain" data-api-url="delete/alias-domain" data-item="' + encodeURIComponent(item.alias_domain) + '" class="btn btn-xs btn-xs-third btn-danger"><i class="bi bi-trash"></i> ' + lang.remove + '</a>' + |
| 905 | '<a href="#dnsInfoModal" class="btn btn-xs btn-xs-third btn-info" data-toggle="modal" data-domain="' + encodeURIComponent(item.alias_domain) + '"><i class="bi bi-globe2"></i> DNS</a></div>' + |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 906 | '</div>'; |
| 907 | item.chkbox = '<input type="checkbox" data-id="alias-domain" name="multi_select" value="' + encodeURIComponent(item.alias_domain) + '" />'; |
| 908 | if(item.parent_is_backupmx == '1') { |
| 909 | item.target_domain = '<span><a href="/edit/domain/' + item.target_domain + '">' + item.target_domain + '</a> <div class="label label-warning">' + lang.alias_domain_backupmx + '</div></span>'; |
| 910 | } else { |
| 911 | item.target_domain = '<span><a href="/edit/domain/' + item.target_domain + '">' + item.target_domain + '</a></span>'; |
| 912 | } |
| 913 | }); |
| 914 | } |
| 915 | }), |
| 916 | "paging": { |
| 917 | "enabled": true, |
| 918 | "limit": 5, |
| 919 | "size": pagination_size |
| 920 | }, |
| 921 | "state": { |
| 922 | "enabled": true |
| 923 | }, |
| 924 | "filtering": { |
| 925 | "enabled": true, |
| 926 | "delay": 1200, |
| 927 | "position": "left", |
| 928 | "connectors": false, |
| 929 | "placeholder": lang.filter_table |
| 930 | }, |
| 931 | "sorting": { |
| 932 | "enabled": true |
| 933 | }, |
| 934 | "on": { |
| 935 | "destroy.ft.table": function(e, ft){ |
| 936 | $('.refresh_table').attr('disabled', 'true'); |
| 937 | }, |
| 938 | "ready.ft.table": function(e, ft){ |
| 939 | table_mailbox_ready(ft, 'aliasdomain_table'); |
| 940 | }, |
| 941 | "after.ft.filtering": function(e, ft){ |
| 942 | table_mailbox_ready(ft, 'aliasdomain_table'); |
| 943 | } |
| 944 | }, |
| 945 | "toggleSelector": "table tbody span.footable-toggle" |
| 946 | }); |
| 947 | } |
| 948 | |
| 949 | function draw_sync_job_table() { |
| 950 | ft_syncjob_table = FooTable.init('#sync_job_table', { |
| 951 | "columns": [ |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 952 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"}, |
| 953 | {"sorted": true,"name":"id","title":"ID","style":{"min-width":"60px","width":"60px","text-align":"center"}}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 954 | {"name":"user2","title":lang.owner}, |
| 955 | {"name":"server_w_port","title":"Server","breakpoints":"xs sm md","style":{"word-break":"break-all"}}, |
| 956 | {"name":"exclude","title":lang.excludes,"breakpoints":"all"}, |
| 957 | {"name":"mins_interval","title":lang.mins_interval,"breakpoints":"all"}, |
| 958 | {"name":"last_run","title":lang.last_run,"breakpoints":"xs sm md"}, |
| 959 | {"name":"log","title":"Log"}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 960 | {"name":"active","filterable": false,"style":{"min-width":"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>';}}, |
| 961 | {"name":"is_running","filterable": false,"style":{"min-width":"120px","width":"100px"},"title":lang.status}, |
| 962 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 963 | ], |
| 964 | "empty": lang.empty, |
| 965 | "rows": $.ajax({ |
| 966 | dataType: 'json', |
| 967 | url: '/api/v1/get/syncjobs/all/no_log', |
| 968 | jsonp: false, |
| 969 | error: function () { |
| 970 | console.log('Cannot draw sync job table'); |
| 971 | }, |
| 972 | success: function (data) { |
| 973 | $.each(data, function (i, item) { |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 974 | item.log = '<a href="#syncjobLogModal" data-toggle="modal" data-syncjob-id="' + encodeURIComponent(item.id) + '">' + lang.open_logs + '</a>' |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 975 | item.user2 = escapeHtml(item.user2); |
| 976 | if (!item.exclude > 0) { |
| 977 | item.exclude = '-'; |
| 978 | } else { |
| 979 | item.exclude = '<code>' + item.exclude + '</code>'; |
| 980 | } |
| 981 | item.server_w_port = escapeHtml(item.user1) + '@' + item.host1 + ':' + item.port1; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 982 | item.action = '<div class="btn-group footable-actions">' + |
| 983 | '<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>' + |
| 984 | '<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] | 985 | '</div>'; |
| 986 | item.chkbox = '<input type="checkbox" data-id="syncjob" name="multi_select" value="' + item.id + '" />'; |
| 987 | if (item.is_running == 1) { |
| 988 | item.is_running = '<span id="active-script" class="label label-success">' + lang.running + '</span>'; |
| 989 | } else { |
| 990 | item.is_running = '<span id="inactive-script" class="label label-warning">' + lang.waiting + '</span>'; |
| 991 | } |
| 992 | if (!item.last_run > 0) { |
| 993 | item.last_run = lang.waiting; |
| 994 | } |
| 995 | }); |
| 996 | } |
| 997 | }), |
| 998 | "paging": { |
| 999 | "enabled": true, |
| 1000 | "limit": 5, |
| 1001 | "size": pagination_size |
| 1002 | }, |
| 1003 | "state": { |
| 1004 | "enabled": true |
| 1005 | }, |
| 1006 | "filtering": { |
| 1007 | "enabled": true, |
| 1008 | "delay": 1200, |
| 1009 | "position": "left", |
| 1010 | "connectors": false, |
| 1011 | "placeholder": lang.filter_table |
| 1012 | }, |
| 1013 | "sorting": { |
| 1014 | "enabled": true |
| 1015 | }, |
| 1016 | "on": { |
| 1017 | "destroy.ft.table": function(e, ft){ |
| 1018 | $('.refresh_table').attr('disabled', 'true'); |
| 1019 | }, |
| 1020 | "ready.ft.table": function(e, ft){ |
| 1021 | table_mailbox_ready(ft, 'sync_job_table'); |
| 1022 | }, |
| 1023 | "after.ft.filtering": function(e, ft){ |
| 1024 | table_mailbox_ready(ft, 'sync_job_table'); |
| 1025 | } |
| 1026 | }, |
| 1027 | "toggleSelector": "table tbody span.footable-toggle" |
| 1028 | }); |
| 1029 | } |
| 1030 | |
| 1031 | function draw_filter_table() { |
| 1032 | ft_filter_table = FooTable.init('#filter_table', { |
| 1033 | "columns": [ |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1034 | {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"}, |
| 1035 | {"name":"id","title":"ID","style":{"min-width":"60px","width":"60px","text-align":"center"}}, |
| 1036 | {"name":"active","style":{"min-width":"80px","width":"80px"},"title":lang.active}, |
| 1037 | {"name":"filter_type","style":{"min-width":"80px","width":"80px"},"title":"Type"}, |
| 1038 | {"sorted": true,"name":"username","title":lang.owner,"style":{"min-width":"550px","width":"350px"}}, |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1039 | {"name":"script_desc","title":lang.description,"breakpoints":"xs"}, |
| 1040 | {"name":"script_data","title":"Script","breakpoints":"all"}, |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1041 | {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1042 | ], |
| 1043 | "empty": lang.empty, |
| 1044 | "rows": $.ajax({ |
| 1045 | dataType: 'json', |
| 1046 | url: '/api/v1/get/filters/all', |
| 1047 | jsonp: false, |
| 1048 | error: function () { |
| 1049 | console.log('Cannot draw filter table'); |
| 1050 | }, |
| 1051 | success: function (data) { |
| 1052 | $.each(data, function (i, item) { |
| 1053 | if (item.active == 1) { |
| 1054 | item.active = '<span id="active-script" class="label label-success">' + lang.active + '</span>'; |
| 1055 | } else { |
| 1056 | item.active = '<span id="inactive-script" class="label label-warning">' + lang.inactive + '</span>'; |
| 1057 | } |
| 1058 | item.script_data = '<pre style="margin:0px">' + escapeHtml(item.script_data) + '</pre>' |
| 1059 | item.filter_type = '<div class="label label-default">' + item.filter_type.charAt(0).toUpperCase() + item.filter_type.slice(1).toLowerCase() + '</div>' |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1060 | item.action = '<div class="btn-group footable-actions">' + |
| 1061 | '<a href="/edit/filter/' + item.id + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' + |
| 1062 | '<a href="#" data-action="delete_selected" data-id="single-filter" data-api-url="delete/filter" data-item="' + encodeURIComponent(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] | 1063 | '</div>'; |
| 1064 | item.chkbox = '<input type="checkbox" data-id="filter_item" name="multi_select" value="' + item.id + '" />' |
| 1065 | }); |
| 1066 | } |
| 1067 | }), |
| 1068 | "paging": { |
| 1069 | "enabled": true, |
| 1070 | "limit": 5, |
| 1071 | "size": pagination_size |
| 1072 | }, |
| 1073 | "state": { |
| 1074 | "enabled": true |
| 1075 | }, |
| 1076 | "filtering": { |
| 1077 | "enabled": true, |
| 1078 | "delay": 1200, |
| 1079 | "position": "left", |
| 1080 | "connectors": false, |
| 1081 | "placeholder": lang.filter_table |
| 1082 | }, |
| 1083 | "sorting": { |
| 1084 | "enabled": true |
| 1085 | }, |
| 1086 | "on": { |
| 1087 | "destroy.ft.table": function(e, ft){ |
| 1088 | $('.refresh_table').attr('disabled', 'true'); |
| 1089 | }, |
| 1090 | "ready.ft.table": function(e, ft){ |
| 1091 | table_mailbox_ready(ft, 'filter_table'); |
| 1092 | }, |
| 1093 | "after.ft.filtering": function(e, ft){ |
| 1094 | table_mailbox_ready(ft, 'filter_table'); |
| 1095 | } |
| 1096 | }, |
| 1097 | "toggleSelector": "table tbody span.footable-toggle" |
| 1098 | }); |
| 1099 | }; |
| 1100 | |
| 1101 | $('body').on('click', 'span.footable-toggle', function () { |
| 1102 | event.stopPropagation(); |
| 1103 | }) |
| 1104 | |
| 1105 | draw_domain_table(); |
| 1106 | draw_mailbox_table(); |
| 1107 | draw_resource_table(); |
| 1108 | draw_alias_table(); |
| 1109 | draw_aliasdomain_table(); |
| 1110 | draw_sync_job_table(); |
| 1111 | draw_filter_table(); |
| 1112 | draw_bcc_table(); |
| 1113 | draw_recipient_map_table(); |
| 1114 | draw_tls_policy_table(); |
| 1115 | |
| 1116 | }); |