mailbox.js 46 KB

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