mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
Reimplemented Quarantine on the basis of Listing.
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
var Quarantine = function(options) {
|
||||
this.initialize(options);
|
||||
Listing.call(this, options);
|
||||
};
|
||||
|
||||
Quarantine.prototype = {
|
||||
constructor: Quarantine,
|
||||
|
||||
defaults: {
|
||||
deflocation: "listing",
|
||||
defcallback: "listing_cb",
|
||||
sortable_selector: '.sortable'
|
||||
deflocation: "listing"
|
||||
},
|
||||
|
||||
initialize: function(options) {
|
||||
this.options = $.extend({}, this.defaults, options);
|
||||
Listing.prototype.initialize.call(this, options);
|
||||
this.options = $.extend({}, this.defaults, this.options);
|
||||
this.options.defcallback = $.proxy(this.listing_cb, this);
|
||||
this.navobj = new History(this.options);
|
||||
|
||||
this.register_navcallbacks();
|
||||
@@ -24,9 +24,6 @@ Quarantine.prototype = {
|
||||
$("#menubar").html(data.menu);
|
||||
$("#searchfield").searchbar({navobj: this.navobj});
|
||||
}
|
||||
if (data.navbar) {
|
||||
$("#bottom-bar-right").html(data.navbar);
|
||||
}
|
||||
if (data.listing != undefined) {
|
||||
$("#listing").html(data.listing);
|
||||
$("#listing").css({
|
||||
@@ -35,37 +32,7 @@ Quarantine.prototype = {
|
||||
overflow: "auto"
|
||||
});
|
||||
}
|
||||
var $sortables = $(this.options.sortable_selector);
|
||||
if ($sortables.length) {
|
||||
$(this.options.sortable_selector).sortable({
|
||||
onSortOrderChange: $.proxy(this.change_sort_order, this)
|
||||
});
|
||||
this.set_sort_order();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
set_sort_order: function() {
|
||||
var sort_order = this.navobj.getparam("order");
|
||||
var sort_dir;
|
||||
|
||||
if (!sort_order) {
|
||||
return;
|
||||
}
|
||||
if (sort_order[0] == '-') {
|
||||
sort_dir = "desc";
|
||||
sort_order = sort_order.substr(1);
|
||||
} else {
|
||||
sort_dir = 'asc';
|
||||
}
|
||||
$("th[data-sort_order=" + sort_order + "]").sortable('select', sort_dir);
|
||||
},
|
||||
|
||||
change_sort_order: function(sort_order, dir) {
|
||||
if (dir == "desc") {
|
||||
sort_order = "-" + sort_order;
|
||||
}
|
||||
this.navobj.setparam("order", sort_order).update();
|
||||
this.update_listing(data);
|
||||
},
|
||||
|
||||
listen: function() {
|
||||
@@ -77,19 +44,14 @@ Quarantine.prototype = {
|
||||
$.proxy(this.delete_selection, this));
|
||||
$(document).on("click", "a[name=viewrequests]",
|
||||
$.proxy(this.view_requests, this));
|
||||
$(document).on("click", "#bottom-bar a", $.proxy(this.load_page, this));
|
||||
|
||||
$(document).on("click", "a[name=release]", $.proxy(this.release, this));
|
||||
$(document).on("click", "a[name=delete]", $.proxy(this.delete, this));
|
||||
$(document).on("click", "a[name=headers]", $.proxy(this.headers, this));
|
||||
},
|
||||
|
||||
load_page: function(e) {
|
||||
e.preventDefault();
|
||||
var $link = $(e.target).parent();
|
||||
|
||||
Listing.prototype.load_page.apply(this, arguments);
|
||||
this.navobj.delparam("rcpt");
|
||||
this.navobj.parse_string($link.attr("href")).update();
|
||||
},
|
||||
|
||||
view_requests: function(e) {
|
||||
@@ -249,4 +211,6 @@ Quarantine.prototype = {
|
||||
$("body").notify("error", data.respmsg);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Quarantine.prototype = $.extend({}, Listing.prototype, Quarantine.prototype);
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
{% block pagetitle %}{% trans "Quarantine management" %}{% endblock %}
|
||||
{% block html_head %}
|
||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}amavis/css/quarantine.css" />
|
||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/jquery.sortable.css" />
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.htmltable.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.sortable.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/history.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/searchbar.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/listing.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}amavis/js/quarantine.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
@@ -15,6 +15,7 @@ from modoboa.admin.models import Mailbox
|
||||
from lib import *
|
||||
from templatetags.amextras import *
|
||||
from modoboa.lib.email_listing import parse_search_parameters
|
||||
from modoboa.lib.templatetags.libextras import pagination_bar
|
||||
from sql_listing import *
|
||||
|
||||
|
||||
@@ -41,7 +42,7 @@ def __back_to_listing(request):
|
||||
|
||||
def empty_quarantine(request):
|
||||
content = "<div class='alert alert-info'>%s</div>" % _("Empty quarantine")
|
||||
ctx = getctx("ok", level=2, listing=content, navbar="",
|
||||
ctx = getctx("ok", level=2, listing=content, paginbar="",
|
||||
menu=quar_menu(request.user))
|
||||
return HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
|
||||
|
||||
@@ -56,7 +57,7 @@ def _listing(request):
|
||||
if not len(request.user.get_domains()):
|
||||
return empty_quarantine(request)
|
||||
|
||||
order = request.GET.get("order", "-date")
|
||||
order = request.GET.get("sort_order", "-date")
|
||||
if not "navparams" in request.session:
|
||||
request.session["navparams"] = {}
|
||||
request.session["navparams"]["order"] = order
|
||||
@@ -97,8 +98,8 @@ def _listing(request):
|
||||
return empty_quarantine(request)
|
||||
|
||||
content = lst.fetch(request, page.id_start, page.id_stop)
|
||||
navbar = lst.render_navbar(page, "listing/?")
|
||||
ctx = getctx("ok", listing=content, navbar=navbar,
|
||||
paginbar = pagination_bar(page)
|
||||
ctx = getctx("ok", listing=content, paginbar=paginbar, page=page.number,
|
||||
menu=quar_menu(request.user))
|
||||
return HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
|
||||
|
||||
@@ -106,7 +107,8 @@ def _listing(request):
|
||||
@login_required
|
||||
def index(request):
|
||||
return _render(request, "amavis/index.html", dict(
|
||||
deflocation="listing/?order=-date", defcallback="listing_cb", selection="quarantine"
|
||||
deflocation="listing/?sort_order=-date",
|
||||
defcallback="listing_cb", selection="quarantine"
|
||||
))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user