mailbox.js 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  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. var of_q = (res[1] == 0 ? "∞" : humanFileSize(res[1]));
  313. return humanFileSize(res[0]) + " / " + of_q;
  314. },
  315. "sortValue": function(value){
  316. res = value.split("/");
  317. return Number(res[0]);
  318. },
  319. },
  320. {"name":"spam_aliases","filterable": false,"title":lang.spam_aliases,"breakpoints":"xs sm md"},
  321. {"name":"tls_enforce_in","filterable": false,"title":lang.tls_enforce_in,"breakpoints":"all"},
  322. {"name":"tls_enforce_out","filterable": false,"title":lang.tls_enforce_out,"breakpoints":"all"},
  323. {"name":"quarantine_notification","filterable": false,"title":lang.quarantine_notification,"breakpoints":"all"},
  324. {"name":"in_use","filterable": false,"type":"html","title":lang.in_use,"sortValue": function(value){
  325. return Number($(value).find(".progress-bar").attr('aria-valuenow'));
  326. },
  327. },
  328. {"name":"messages","filterable": false,"title":lang.msg_num,"breakpoints":"xs sm md"},
  329. {"name":"rl","title":"RL","breakpoints":"xs sm md","style":{"width":"125px"}},
  330. {"name":"active","filterable": false,"title":lang.active},
  331. {"name":"action","filterable": false,"sortable": false,"style":{"min-width":"250px","text-align":"right"},"type":"html","title":lang.action,"breakpoints":"xs sm md"}
  332. ],
  333. "empty": lang.empty,
  334. "rows": $.ajax({
  335. dataType: 'json',
  336. url: '/api/v1/get/mailbox/all',
  337. jsonp: false,
  338. error: function () {
  339. console.log('Cannot draw mailbox table');
  340. },
  341. success: function (data) {
  342. $.each(data, function (i, item) {
  343. item.quota = item.quota_used + "/" + item.quota;
  344. item.max_quota_for_mbox = humanFileSize(item.max_quota_for_mbox);
  345. if (!item.rl) {
  346. item.rl = '∞';
  347. } else {
  348. item.rl = $.map(item.rl, function(e){
  349. return e;
  350. }).join('/1');
  351. }
  352. item.chkbox = '<input type="checkbox" data-id="mailbox" name="multi_select" value="' + encodeURIComponent(item.username) + '" />';
  353. item.tls_enforce_in = '<span class="text-' + (item.attributes.tls_enforce_in == 1 ? 'success' : 'danger') + ' glyphicon glyphicon-lock"></span>';
  354. item.tls_enforce_out = '<span class="text-' + (item.attributes.tls_enforce_out == 1 ? 'success' : 'danger') + ' glyphicon glyphicon-lock"></span>';
  355. if (item.attributes.quarantine_notification === 'never') {
  356. item.quarantine_notification = lang.never;
  357. } else if (item.attributes.quarantine_notification === 'hourly') {
  358. item.quarantine_notification = lang.hourly;
  359. } else if (item.attributes.quarantine_notification === 'daily') {
  360. item.quarantine_notification = lang.daily;
  361. } else if (item.attributes.quarantine_notification === 'weekly') {
  362. item.quarantine_notification = lang.weekly;
  363. }
  364. if (acl_data.login_as === 1) {
  365. item.action = '<div class="btn-group">' +
  366. '<a href="/edit/mailbox/' + encodeURIComponent(item.username) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
  367. '<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>' +
  368. '<a href="/index.php?duallogin=' + encodeURIComponent(item.username) + '" class="login_as btn btn-xs btn-success"><span class="glyphicon glyphicon-user"></span> Login</a>' +
  369. '</div>';
  370. }
  371. else {
  372. item.action = '<div class="btn-group">' +
  373. '<a href="/edit/mailbox/' + encodeURIComponent(item.username) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
  374. '<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>' +
  375. '</div>';
  376. }
  377. item.in_use = '<div class="progress">' +
  378. '<div class="progress-bar progress-bar-' + item.percent_class + ' role="progressbar" aria-valuenow="' + item.percent_in_use + '" aria-valuemin="0" aria-valuemax="100" ' +
  379. 'style="min-width:2em;width:' + item.percent_in_use + '%">' + item.percent_in_use + '%' + '</div></div>';
  380. item.username = escapeHtml(item.username);
  381. });
  382. }
  383. }),
  384. "paging": {
  385. "enabled": true,
  386. "limit": 5,
  387. "size": pagination_size
  388. },
  389. "state": {
  390. "enabled": true
  391. },
  392. "filtering": {
  393. "enabled": true,
  394. "delay": 100,
  395. "position": "left",
  396. "connectors": false,
  397. //"container": "#tab-mailboxes.panel",
  398. "placeholder": lang.filter_table
  399. },
  400. "components": {
  401. "filtering": FooTable.domainFilter
  402. },
  403. "sorting": {
  404. "enabled": true
  405. },
  406. "on": {
  407. "ready.ft.table": function(e, ft){
  408. table_mailbox_ready(ft, 'mailbox_table');
  409. }
  410. }
  411. });
  412. }
  413. function draw_resource_table() {
  414. ft_resource_table = FooTable.init('#resource_table', {
  415. "columns": [
  416. {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
  417. {"sorted": true,"name":"description","title":lang.description,"style":{"width":"250px"}},
  418. {"name":"kind","title":lang.kind},
  419. {"name":"domain","title":lang.domain,"breakpoints":"xs sm"},
  420. {"name":"multiple_bookings","filterable": false,"style":{"maxWidth":"150px","width":"140px"},"title":lang.multiple_bookings,"breakpoints":"xs sm"},
  421. {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active},
  422. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
  423. ],
  424. "empty": lang.empty,
  425. "rows": $.ajax({
  426. dataType: 'json',
  427. url: '/api/v1/get/resource/all',
  428. jsonp: false,
  429. error: function () {
  430. console.log('Cannot draw resource table');
  431. },
  432. success: function (data) {
  433. $.each(data, function (i, item) {
  434. if (item.multiple_bookings == '0') {
  435. item.multiple_bookings = '<span id="active-script" class="label label-success">' + lang.booking_0_short + '</span>';
  436. } else if (item.multiple_bookings == '-1') {
  437. item.multiple_bookings = '<span id="active-script" class="label label-warning">' + lang.booking_lt0_short + '</span>';
  438. } else {
  439. item.multiple_bookings = '<span id="active-script" class="label label-danger">' + lang.booking_custom_short + ' (' + item.multiple_bookings + ')</span>';
  440. }
  441. item.action = '<div class="btn-group">' +
  442. '<a href="/edit/resource/' + encodeURIComponent(item.name) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
  443. '<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>' +
  444. '</div>';
  445. item.chkbox = '<input type="checkbox" data-id="resource" name="multi_select" value="' + encodeURIComponent(item.name) + '" />';
  446. item.name = escapeHtml(item.name);
  447. });
  448. }
  449. }),
  450. "paging": {
  451. "enabled": true,
  452. "limit": 5,
  453. "size": pagination_size
  454. },
  455. "state": {
  456. "enabled": true
  457. },
  458. "filtering": {
  459. "enabled": true,
  460. "delay": 100,
  461. "position": "left",
  462. "connectors": false,
  463. "placeholder": lang.filter_table
  464. },
  465. "components": {
  466. "filtering": FooTable.domainFilter
  467. },
  468. "sorting": {
  469. "enabled": true
  470. },
  471. "on": {
  472. "ready.ft.table": function(e, ft){
  473. table_mailbox_ready(ft, 'resource_table');
  474. }
  475. }
  476. });
  477. }
  478. function draw_bcc_table() {
  479. ft_bcc_table = FooTable.init('#bcc_table', {
  480. "columns": [
  481. {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
  482. {"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
  483. {"name":"type","title":lang.bcc_type},
  484. {"name":"local_dest","title":lang.bcc_local_dest},
  485. {"name":"bcc_dest","title":lang.bcc_destinations},
  486. {"name":"domain","title":lang.domain,"breakpoints":"xs sm"},
  487. {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active},
  488. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
  489. ],
  490. "empty": lang.empty,
  491. "rows": $.ajax({
  492. dataType: 'json',
  493. url: '/api/v1/get/bcc/all',
  494. jsonp: false,
  495. error: function () {
  496. console.log('Cannot draw bcc table');
  497. },
  498. success: function (data) {
  499. $.each(data, function (i, item) {
  500. item.action = '<div class="btn-group">' +
  501. '<a href="/edit/bcc/' + item.id + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
  502. '<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>' +
  503. '</div>';
  504. item.chkbox = '<input type="checkbox" data-id="bcc" name="multi_select" value="' + item.id + '" />';
  505. item.local_dest = escapeHtml(item.local_dest);
  506. item.bcc_dest = escapeHtml(item.bcc_dest);
  507. if (item.type == 'sender') {
  508. item.type = '<span id="active-script" class="label label-success">Sender</span>';
  509. } else {
  510. item.type = '<span id="inactive-script" class="label label-warning">Recipient</span>';
  511. }
  512. });
  513. }
  514. }),
  515. "paging": {
  516. "enabled": true,
  517. "limit": 5,
  518. "size": pagination_size
  519. },
  520. "state": {
  521. "enabled": true
  522. },
  523. "filtering": {
  524. "enabled": true,
  525. "delay": 100,
  526. "position": "left",
  527. "connectors": false,
  528. "placeholder": lang.filter_table
  529. },
  530. "sorting": {
  531. "enabled": true
  532. },
  533. "on": {
  534. "ready.ft.table": function(e, ft){
  535. table_mailbox_ready(ft, 'bcc_table');
  536. }
  537. }
  538. });
  539. }
  540. function draw_recipient_map_table() {
  541. ft_recipient_map_table = FooTable.init('#recipient_map_table', {
  542. "columns": [
  543. {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
  544. {"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
  545. {"name":"recipient_map_old","title":lang.recipient_map_old},
  546. {"name":"recipient_map_new","title":lang.recipient_map_new},
  547. {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active},
  548. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":(role == "admin" ? lang.action : ""),"breakpoints":"xs sm"}
  549. ],
  550. "empty": lang.empty,
  551. "rows": $.ajax({
  552. dataType: 'json',
  553. url: '/api/v1/get/recipient_map/all',
  554. jsonp: false,
  555. error: function () {
  556. console.log('Cannot draw recipient map table');
  557. },
  558. success: function (data) {
  559. if (role == "admin") {
  560. $.each(data, function (i, item) {
  561. item.recipient_map_old = escapeHtml(item.recipient_map_old);
  562. item.recipient_map_new = escapeHtml(item.recipient_map_new);
  563. item.action = '<div class="btn-group">' +
  564. '<a href="/edit/recipient_map/' + item.id + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
  565. '<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>' +
  566. '</div>';
  567. item.chkbox = '<input type="checkbox" data-id="recipient_map" name="multi_select" value="' + item.id + '" />';
  568. });
  569. }
  570. }
  571. }),
  572. "paging": {
  573. "enabled": true,
  574. "limit": 5,
  575. "size": pagination_size
  576. },
  577. "state": {
  578. "enabled": true
  579. },
  580. "filtering": {
  581. "enabled": true,
  582. "delay": 100,
  583. "position": "left",
  584. "connectors": false,
  585. "placeholder": lang.filter_table
  586. },
  587. "sorting": {
  588. "enabled": true
  589. },
  590. "on": {
  591. "ready.ft.table": function(e, ft){
  592. table_mailbox_ready(ft, 'recipient_map_table');
  593. }
  594. }
  595. });
  596. }
  597. function draw_tls_policy_table() {
  598. ft_tls_policy_table = FooTable.init('#tls_policy_table', {
  599. "columns": [
  600. {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
  601. {"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
  602. {"name":"dest","title":lang.tls_map_dest},
  603. {"name":"policy","title":lang.tls_map_policy},
  604. {"name":"parameters","title":lang.tls_map_parameters},
  605. {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active},
  606. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":(role == "admin" ? lang.action : ""),"breakpoints":"xs sm"}
  607. ],
  608. "empty": lang.empty,
  609. "rows": $.ajax({
  610. dataType: 'json',
  611. url: '/api/v1/get/tls-policy-map/all',
  612. jsonp: false,
  613. error: function () {
  614. console.log('Cannot draw tls policy map table');
  615. },
  616. success: function (data) {
  617. if (role == "admin") {
  618. $.each(data, function (i, item) {
  619. item.dest = escapeHtml(item.dest);
  620. item.policy = '<b>' + escapeHtml(item.policy) + '</b>';
  621. if (item.parameters == '') {
  622. item.parameters = '<code>-</code>';
  623. } else {
  624. item.parameters = '<code>' + escapeHtml(item.parameters) + '</code>';
  625. }
  626. item.action = '<div class="btn-group">' +
  627. '<a href="/edit/tls_policy_map/' + item.id + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
  628. '<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>' +
  629. '</div>';
  630. item.chkbox = '<input type="checkbox" data-id="tls-policy-map" name="multi_select" value="' + item.id + '" />';
  631. });
  632. }
  633. }
  634. }),
  635. "paging": {
  636. "enabled": true,
  637. "limit": 5,
  638. "size": pagination_size
  639. },
  640. "state": {
  641. "enabled": true
  642. },
  643. "filtering": {
  644. "enabled": true,
  645. "delay": 100,
  646. "position": "left",
  647. "connectors": false,
  648. "placeholder": lang.filter_table
  649. },
  650. "sorting": {
  651. "enabled": true
  652. },
  653. "on": {
  654. "ready.ft.table": function(e, ft){
  655. table_mailbox_ready(ft, 'tls_policy_table');
  656. }
  657. }
  658. });
  659. }
  660. function draw_transport_maps_table() {
  661. ft_transport_maps_table = FooTable.init('#transport_maps_table', {
  662. "columns": [
  663. {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
  664. {"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
  665. {"name":"dest","title":lang.tls_map_dest},
  666. {"name":"parameters","title":lang.tls_map_parameters},
  667. {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active},
  668. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":(role == "admin" ? lang.action : ""),"breakpoints":"xs sm"}
  669. ],
  670. "empty": lang.empty,
  671. "rows": $.ajax({
  672. dataType: 'json',
  673. url: '/api/v1/get/transport-map/all',
  674. jsonp: false,
  675. error: function () {
  676. console.log('Cannot draw transport map table');
  677. },
  678. success: function (data) {
  679. if (role == "admin") {
  680. $.each(data, function (i, item) {
  681. item.dest = escapeHtml(item.dest);
  682. if (item.parameters == '') {
  683. item.parameters = '<code>-</code>';
  684. } else {
  685. item.parameters = '<code>' + escapeHtml(item.parameters) + '</code>';
  686. }
  687. item.action = '<div class="btn-group">' +
  688. '<a href="/edit/transport_map/' + item.id + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
  689. '<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>' +
  690. '</div>';
  691. item.chkbox = '<input type="checkbox" data-id="transport-map" name="multi_select" value="' + item.id + '" />';
  692. });
  693. }
  694. }
  695. }),
  696. "paging": {
  697. "enabled": true,
  698. "limit": 5,
  699. "size": pagination_size
  700. },
  701. "state": {
  702. "enabled": true
  703. },
  704. "filtering": {
  705. "enabled": true,
  706. "delay": 100,
  707. "position": "left",
  708. "connectors": false,
  709. "placeholder": lang.filter_table
  710. },
  711. "sorting": {
  712. "enabled": true
  713. },
  714. "on": {
  715. "ready.ft.table": function(e, ft){
  716. table_mailbox_ready(ft, 'transport_maps_table');
  717. }
  718. }
  719. });
  720. }
  721. function draw_alias_table() {
  722. ft_alias_table = FooTable.init('#alias_table', {
  723. "columns": [
  724. {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
  725. {"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
  726. {"sorted": true,"name":"address","title":lang.alias,"style":{"width":"250px"}},
  727. {"name":"goto","title":lang.target_address},
  728. {"name":"domain","title":lang.domain,"breakpoints":"xs sm"},
  729. {"name":"public_comment","title":lang.public_comment,"breakpoints":"all"},
  730. {"name":"private_comment","title":lang.private_comment,"breakpoints":"all"},
  731. {"name":"active","filterable": false,"style":{"maxWidth":"50px","width":"70px"},"title":lang.active},
  732. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
  733. ],
  734. "empty": lang.empty,
  735. "rows": $.ajax({
  736. dataType: 'json',
  737. url: '/api/v1/get/alias/all',
  738. jsonp: false,
  739. error: function () {
  740. console.log('Cannot draw alias table');
  741. },
  742. success: function (data) {
  743. $.each(data, function (i, item) {
  744. item.action = '<div class="btn-group">' +
  745. '<a href="/edit/alias/' + encodeURIComponent(item.id) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
  746. '<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>' +
  747. '</div>';
  748. item.chkbox = '<input type="checkbox" data-id="alias" name="multi_select" value="' + encodeURIComponent(item.id) + '" />';
  749. item.goto = escapeHtml(item.goto.replace(/,/g, " "));
  750. if (item.public_comment !== null) {
  751. item.public_comment = escapeHtml(item.public_comment);
  752. }
  753. else {
  754. item.public_comment = '-';
  755. }
  756. if (item.private_comment !== null) {
  757. item.private_comment = escapeHtml(item.private_comment);
  758. }
  759. else {
  760. item.private_comment = '-';
  761. }
  762. if (item.is_catch_all == 1) {
  763. item.address = '<div class="label label-default">Catch-All</div> ' + escapeHtml(item.address);
  764. }
  765. else {
  766. item.address = escapeHtml(item.address);
  767. }
  768. if (item.goto == "null@localhost") {
  769. item.goto = '⤷ <span style="font-size:12px" class="glyphicon glyphicon-trash" aria-hidden="true"></span>';
  770. }
  771. else if (item.goto == "spam@localhost") {
  772. item.goto = '<span class="label label-danger">Learn as spam</span>';
  773. }
  774. else if (item.goto == "ham@localhost") {
  775. item.goto = '<span class="label label-success">Learn as ham</span>';
  776. }
  777. if (item.in_primary_domain !== "") {
  778. item.domain = "↳ " + item.domain + " (" + item.in_primary_domain + ")";
  779. }
  780. });
  781. }
  782. }),
  783. "paging": {
  784. "enabled": true,
  785. "limit": 5,
  786. "size": pagination_size
  787. },
  788. "state": {
  789. "enabled": true
  790. },
  791. "filtering": {
  792. "enabled": true,
  793. "delay": 100,
  794. "position": "left",
  795. "connectors": false,
  796. "placeholder": lang.filter_table
  797. },
  798. "components": {
  799. "filtering": FooTable.domainFilter
  800. },
  801. "sorting": {
  802. "enabled": true
  803. },
  804. "on": {
  805. "ready.ft.table": function(e, ft){
  806. table_mailbox_ready(ft, 'alias_table');
  807. }
  808. }
  809. });
  810. }
  811. function draw_aliasdomain_table() {
  812. ft_aliasdomain_table = FooTable.init('#aliasdomain_table', {
  813. "columns": [
  814. {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
  815. {"sorted": true,"name":"alias_domain","title":lang.alias,"style":{"width":"250px"}},
  816. {"name":"target_domain","title":lang.target_domain},
  817. {"name":"active","filterable": false,"style":{"maxWidth":"50px","width":"70px"},"title":lang.active},
  818. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"250px","width":"250px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
  819. ],
  820. "empty": lang.empty,
  821. "rows": $.ajax({
  822. dataType: 'json',
  823. url: '/api/v1/get/alias-domain/all',
  824. jsonp: false,
  825. error: function () {
  826. console.log('Cannot draw alias domain table');
  827. },
  828. success: function (data) {
  829. $.each(data, function (i, item) {
  830. item.action = '<div class="btn-group">' +
  831. '<a href="/edit/aliasdomain/' + encodeURIComponent(item.alias_domain) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
  832. '<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>' +
  833. '<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>' +
  834. '</div>';
  835. item.chkbox = '<input type="checkbox" data-id="alias-domain" name="multi_select" value="' + encodeURIComponent(item.alias_domain) + '" />';
  836. });
  837. }
  838. }),
  839. "paging": {
  840. "enabled": true,
  841. "limit": 5,
  842. "size": pagination_size
  843. },
  844. "state": {
  845. "enabled": true
  846. },
  847. "filtering": {
  848. "enabled": true,
  849. "delay": 100,
  850. "position": "left",
  851. "connectors": false,
  852. "placeholder": lang.filter_table
  853. },
  854. "sorting": {
  855. "enabled": true
  856. },
  857. "on": {
  858. "ready.ft.table": function(e, ft){
  859. table_mailbox_ready(ft, 'aliasdomain_table');
  860. }
  861. }
  862. });
  863. }
  864. function draw_sync_job_table() {
  865. ft_syncjob_table = FooTable.init('#sync_job_table', {
  866. "columns": [
  867. {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
  868. {"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
  869. {"name":"user2","title":lang.owner},
  870. {"name":"server_w_port","title":"Server","breakpoints":"xs","style":{"word-break":"break-all"}},
  871. {"name":"exclude","title":lang.excludes,"breakpoints":"all"},
  872. {"name":"mins_interval","title":lang.mins_interval,"breakpoints":"all"},
  873. {"name":"last_run","title":lang.last_run,"breakpoints":"sm"},
  874. {"name":"log","title":"Log"},
  875. {"name":"active","filterable": false,"style":{"maxWidth":"70px","width":"70px"},"title":lang.active},
  876. {"name":"is_running","filterable": false,"style":{"maxWidth":"120px","width":"100px"},"title":lang.status},
  877. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
  878. ],
  879. "empty": lang.empty,
  880. "rows": $.ajax({
  881. dataType: 'json',
  882. url: '/api/v1/get/syncjobs/all/no_log',
  883. jsonp: false,
  884. error: function () {
  885. console.log('Cannot draw sync job table');
  886. },
  887. success: function (data) {
  888. $.each(data, function (i, item) {
  889. item.log = '<a href="#syncjobLogModal" data-toggle="modal" data-syncjob-id="' + encodeURIComponent(item.id) + '">Open logs</a>'
  890. item.user2 = escapeHtml(item.user2);
  891. if (!item.exclude > 0) {
  892. item.exclude = '-';
  893. } else {
  894. item.exclude = '<code>' + item.exclude + '</code>';
  895. }
  896. item.server_w_port = escapeHtml(item.user1) + '@' + item.host1 + ':' + item.port1;
  897. item.action = '<div class="btn-group">' +
  898. '<a href="/edit/syncjob/' + item.id + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
  899. '<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>' +
  900. '</div>';
  901. item.chkbox = '<input type="checkbox" data-id="syncjob" name="multi_select" value="' + item.id + '" />';
  902. if (item.is_running == 1) {
  903. item.is_running = '<span id="active-script" class="label label-success">' + lang.running + '</span>';
  904. } else {
  905. item.is_running = '<span id="inactive-script" class="label label-warning">' + lang.waiting + '</span>';
  906. }
  907. if (!item.last_run > 0) {
  908. item.last_run = lang.waiting;
  909. }
  910. });
  911. }
  912. }),
  913. "paging": {
  914. "enabled": true,
  915. "limit": 5,
  916. "size": pagination_size
  917. },
  918. "state": {
  919. "enabled": true
  920. },
  921. "filtering": {
  922. "enabled": true,
  923. "delay": 100,
  924. "position": "left",
  925. "connectors": false,
  926. "placeholder": lang.filter_table
  927. },
  928. "sorting": {
  929. "enabled": true
  930. },
  931. "on": {
  932. "ready.ft.table": function(e, ft){
  933. table_mailbox_ready(ft, 'sync_job_table');
  934. }
  935. }
  936. });
  937. }
  938. function draw_filter_table() {
  939. ft_filter_table = FooTable.init('#filter_table', {
  940. "columns": [
  941. {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
  942. {"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
  943. {"name":"active","style":{"maxWidth":"80px","width":"80px"},"title":lang.active},
  944. {"name":"filter_type","style":{"maxWidth":"80px","width":"80px"},"title":"Type"},
  945. {"sorted": true,"name":"username","title":lang.owner,"style":{"maxWidth":"550px","width":"350px"}},
  946. {"name":"script_desc","title":lang.description,"breakpoints":"xs"},
  947. {"name":"script_data","title":"Script","breakpoints":"all"},
  948. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
  949. ],
  950. "empty": lang.empty,
  951. "rows": $.ajax({
  952. dataType: 'json',
  953. url: '/api/v1/get/filters/all',
  954. jsonp: false,
  955. error: function () {
  956. console.log('Cannot draw filter table');
  957. },
  958. success: function (data) {
  959. $.each(data, function (i, item) {
  960. if (item.active_int == 1) {
  961. item.active = '<span id="active-script" class="label label-success">' + lang.active + '</span>';
  962. } else {
  963. item.active = '<span id="inactive-script" class="label label-warning">' + lang.inactive + '</span>';
  964. }
  965. item.script_data = '<pre style="margin:0px">' + escapeHtml(item.script_data) + '</pre>'
  966. item.filter_type = '<div class="label label-default">' + item.filter_type.charAt(0).toUpperCase() + item.filter_type.slice(1).toLowerCase() + '</div>'
  967. item.action = '<div class="btn-group">' +
  968. '<a href="/edit/filter/' + item.id + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
  969. '<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>' +
  970. '</div>';
  971. item.chkbox = '<input type="checkbox" data-id="filter_item" name="multi_select" value="' + item.id + '" />'
  972. });
  973. }
  974. }),
  975. "paging": {
  976. "enabled": true,
  977. "limit": 5,
  978. "size": pagination_size
  979. },
  980. "state": {
  981. "enabled": true
  982. },
  983. "filtering": {
  984. "enabled": true,
  985. "delay": 100,
  986. "position": "left",
  987. "connectors": false,
  988. "placeholder": lang.filter_table
  989. },
  990. "sorting": {
  991. "enabled": true
  992. },
  993. "on": {
  994. "ready.ft.table": function(e, ft){
  995. table_mailbox_ready(ft, 'filter_table');
  996. }
  997. }
  998. });
  999. };
  1000. draw_domain_table();
  1001. draw_mailbox_table();
  1002. draw_resource_table();
  1003. draw_alias_table();
  1004. draw_aliasdomain_table();
  1005. draw_sync_job_table();
  1006. draw_filter_table();
  1007. draw_bcc_table();
  1008. draw_recipient_map_table();
  1009. draw_tls_policy_table();
  1010. draw_transport_maps_table();
  1011. });