mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Allow AJAX based links.
This commit is contained in:
@@ -25,6 +25,8 @@ def enabled_applications():
|
||||
exts = Extension.objects.filter(enabled=True)
|
||||
for ext in exts:
|
||||
extclass = exts_pool.get_extension(ext.name)
|
||||
if extclass is None:
|
||||
continue
|
||||
if extclass.available_for_topredirection:
|
||||
result.append((ext.name, ext.name))
|
||||
return sorted(result, key=lambda e: e[0])
|
||||
|
||||
@@ -43,20 +43,20 @@ def extensions_menu(selection, user):
|
||||
def admin_menu(selection, user):
|
||||
entries = [
|
||||
{"name": "extensions",
|
||||
"class": "ajaxlink",
|
||||
"class": "ajaxnav",
|
||||
"url": "extensions/",
|
||||
"label": _("Extensions"),
|
||||
"img": ""},
|
||||
{"name": "info",
|
||||
"class": "ajaxlink",
|
||||
"class": "ajaxnav",
|
||||
"url": "info/",
|
||||
"label": _("Information")},
|
||||
{"name": "logs",
|
||||
"class": "ajaxlink",
|
||||
"class": "ajaxnav",
|
||||
"url": "logs/?sort_order=-date_created",
|
||||
"label": _("Logs")},
|
||||
{"name": "parameters",
|
||||
"class": "ajaxlink",
|
||||
"class": "ajaxnav",
|
||||
"url": "parameters/",
|
||||
"img": "",
|
||||
"label": _("Parameters")},
|
||||
@@ -99,11 +99,11 @@ def user_menu(user, selection):
|
||||
def uprefs_menu(selection, user):
|
||||
entries = [
|
||||
{"name": "profile",
|
||||
"class": "ajaxlink",
|
||||
"class": "ajaxnav",
|
||||
"url": "profile/",
|
||||
"label": _("Profile")},
|
||||
{"name": "preferences",
|
||||
"class": "ajaxlink",
|
||||
"class": "ajaxnav",
|
||||
"url": "preferences/",
|
||||
"label": _("Preferences")},
|
||||
]
|
||||
|
||||
@@ -101,7 +101,7 @@ def user_menu(target, user):
|
||||
return []
|
||||
return [
|
||||
{"name": "forward",
|
||||
"class": "ajaxlink",
|
||||
"class": "ajaxnav",
|
||||
"url": "forward/",
|
||||
"label": ugettext_lazy("Forward")}
|
||||
]
|
||||
|
||||
@@ -258,7 +258,8 @@ Identities.prototype = {
|
||||
|
||||
listen: function() {
|
||||
Admin.prototype.listen.call(this);
|
||||
$(document).on("click", "a.ajaxlink", $.proxy(this.page_loader, this));
|
||||
$(document).on("click", "a.ajaxnav", $.proxy(this.page_loader, this));
|
||||
$(document).on("click", "a.ajaxcall", $.proxy(this.send_call, this));
|
||||
},
|
||||
|
||||
page_loader: function(e) {
|
||||
@@ -271,6 +272,27 @@ Identities.prototype = {
|
||||
this.navobj.baseurl($link.attr("href")).update();
|
||||
},
|
||||
|
||||
/**
|
||||
* Send an ajax call.
|
||||
*/
|
||||
send_call: function(evt) {
|
||||
var $link = get_target(evt, "a");
|
||||
var $this = $(this);
|
||||
var method = $link.attr("data-call_method");
|
||||
|
||||
if (method === undefined) {
|
||||
method = "GET";
|
||||
}
|
||||
evt.preventDefault();
|
||||
$.ajax({
|
||||
url: $link.attr("href"),
|
||||
type: method,
|
||||
dataType: "json"
|
||||
}).done(function(data) {
|
||||
$this.reload_listing(data.respmsg);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Initialize the links embedded within a page.
|
||||
*
|
||||
|
||||
@@ -37,7 +37,7 @@ def domains_menu(selection, user):
|
||||
{"name": "domains",
|
||||
"label": _("List domains"),
|
||||
"img": "fa fa-user",
|
||||
"class": "ajaxlink navigation",
|
||||
"class": "ajaxnav navigation",
|
||||
"url": domain_list_url},
|
||||
{"name": "statistics",
|
||||
"label": _("Statistics"),
|
||||
@@ -89,12 +89,12 @@ def identities_menu(user, selection=None):
|
||||
{"name": "identities",
|
||||
"label": _("List identities"),
|
||||
"img": "fa fa-user",
|
||||
"class": "ajaxlink navigation",
|
||||
"class": "ajaxnav navigation",
|
||||
"url": "list/"},
|
||||
{"name": "quotas",
|
||||
"label": _("List quotas"),
|
||||
"img": "fa fa-hdd-o",
|
||||
"class": "ajaxlink navigation",
|
||||
"class": "ajaxnav navigation",
|
||||
"url": "quotas/"},
|
||||
{"name": "newaccount",
|
||||
"label": _("Add account"),
|
||||
|
||||
@@ -25,7 +25,7 @@ def menu(target, user):
|
||||
return []
|
||||
return [
|
||||
{"name": "autoreply",
|
||||
"class": "ajaxlink",
|
||||
"class": "ajaxnav",
|
||||
"url": "autoreply/",
|
||||
"label": ugettext_lazy("Auto-reply message")}
|
||||
]
|
||||
|
||||
@@ -23,7 +23,7 @@ TwocolsNav.prototype = {
|
||||
},
|
||||
|
||||
listen: function() {
|
||||
$("a.ajaxlink").click($.proxy(this.load_section, this));
|
||||
$("a.ajaxnav").click($.proxy(this.load_section, this));
|
||||
$(document).on("click", "#update", $.proxy(function(e) {
|
||||
simple_ajax_form_post(e, {
|
||||
formid: this.options.formid,
|
||||
@@ -130,7 +130,7 @@ TwocolsNav.prototype = {
|
||||
* Select an entry in the left menu based on current url.
|
||||
*/
|
||||
select_left_menu: function() {
|
||||
$("a.ajaxlink").parent().removeClass("active");
|
||||
$("a.ajaxnav").parent().removeClass("active");
|
||||
$("a[name=" + this.navobj.getbaseurl() + "]").parent().addClass("active");
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user