From: bjoe2k4 Date: Sun, 8 Apr 2018 12:30:57 +0000 (+0200) Subject: [WebUI] Config: Load list on demand X-Git-Tag: 1.7.3~16^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F2156%2Fhead;p=rspamd.git [WebUI] Config: Load list on demand --- diff --git a/interface/js/app/config.js b/interface/js/app/config.js index 6955f5eaf..d10fd6a60 100644 --- a/interface/js/app/config.js +++ b/interface/js/app/config.js @@ -58,7 +58,8 @@ function($) { // @get maps id function getMaps(rspamd) { var items = []; - $('#listMaps').closest('.widget-box').hide(); + var $listmaps = $('#listMaps') + $listmaps.closest('.widget-box').hide(); $.ajax({ dataType: 'json', url: 'maps', @@ -70,45 +71,31 @@ function($) { rspamd.alertMessage('alert-modal alert-error', data.statusText); }, success: function (data) { - $('#listMaps').empty(); + $listmaps.empty(); $('#modalBody').empty(); + $tbody = $(''); $.each(data, function (i, item) { - var caption; - var label; - getMapById(rspamd, item); if ((item.editable === false || rspamd.read_only)) { - caption = 'View'; - label = 'Read'; + var label = 'Read'; } else { - caption = 'Edit'; - label = 'Read Write'; + var label = 'Read Write'; } - items.push('' + - '' + label + '' + - '' + - '' + item.uri + '' + - '' + - '' + - item.description + - '' + - ''); + var $tr = $(""); + $('' + label + '').appendTo($tr); + $span = $('' + item.uri + '').data("item",item); + $span.wrap("").parent().appendTo($tr); + $('' + item.description + '').appendTo($tr); + $tr.appendTo($tbody); }); - $('', { - html: items.join('') - }).appendTo('#listMaps'); - $('#listMaps').closest('.widget-box').show(); + $tbody.appendTo($listmaps); + $listmaps.closest('.widget-box').show(); } }); } // @get map by id function getMapById(rspamd, item) { - $.ajax({ + return $.ajax({ dataType: 'text', url: 'getmap', jsonp: false, @@ -124,7 +111,8 @@ function($) { if ((item.editable === false || rspamd.read_only)) { disabled = 'disabled="disabled"'; } - + + $("#"+item.map).remove(); $('