{% extends 'layout2.html' %} {% load i18n %} {% load static %} {% block css_include %} {% endblock %} {% block js_include %} {% endblock %} {% block content %}

 {% translate "Access Control" %}

{% endblock %} {% block jquery_code %} let authentication_access_control_clone_uri = "{% url 'portal.authentication_access_control.clone' %}" $(document).ready(function(){ $('[data-toggle="tooltip"]').tooltip(); }); var aoColumns = [ { sTitle: "ID", name: "id", aTargets: [0], defaultContent: "", mData: "id", bVisible: false, }, { sTitle: '{% translate "Enabled" %}', name: "enabled", aTargets: [1], defaultContent: "", mData: "enabled", mRender: function(data, type, row){ if (data) return ""; return ""; } }, { sTitle: '{% translate "Name" %}', name: "name", aTargets: [2], defaultContent: "", mData: "name" }, { sTitle: '{% translate "NB Rules" %}', name: "rules", aTargets: [3], defaultContent: "", mData: "rules", mRender: function(data, type, row) { if (data) return JSON.parse(data).length return "" } }, { sTitle: '{% translate "Action" %}', mData:"id", aTargets: [4], defaultContent: "", mRender: function(data, type, row) { return '' + ' '; } } ]; var authentication_access_control_table = $("#authentication_access_control_list").dataTable({ bServerSide : true, order : [[1, 'desc']], iDisplayLength: 10, bProcessing : true, bSort : true, sAjaxSource : '', aoColumnDefs: aoColumns, language: language_datatable, fnServerData : function(sSource, aoData, fnCallback){ var columns = []; for (var i in aoColumns){ if( aoColumns[i].bSearchable !== false && aoColumns[i].mData !== null ) columns.push(aoColumns[i].mData); } aoData.push({ name: 'columns', value: JSON.stringify(columns) }); $.ajax({ type : "POST", url : sSource, data : aoData, success: function(data, callback){ if (!data.status){ notify('error', "{% translate 'Error' %}", data.error); } else { fnCallback(data); } } }) // /$.ajax .fail( function( jqXHR, textStatus ) { notify('error', "{% translate 'Error' %}", jqXHR.responseText); }) // /$.fail .done( function( data ) { if (!data.status){ notify('error', "{% translate 'Error' %}", data.error); } else { fnCallback(data); } }); // /$.done }, // /fnServerData fnCreatedRow: function(nRow, aData, iDataIndex) { $(nRow).on('click', 'td', function(e) { if (e.target.tagName !== "TD") return; const url = "{% url 'portal.authentication_access_control.edit' %}" + aData.id /* Open edition in a new tab with ctrl click */ if (e.ctrlKey || e.metaKey) { window.open(url, '_blank'); } else { window.location.href = url; } }); // /$(nRow).on('click', 'td' /* Open edition in a new tab with middle click */ $(nRow).on('mousedown', 'td', function(e){ if (e.target.tagName === "TD" && e.button === 1) { window.open("{% url 'portal.authentication_access_control.edit' %}" + aData.id, '_blank'); } }); // /$(nRow).on('mousedown', 'td' $(nRow).find('.btn-clone').on('click', function(e) { e.stopPropagation(); let txt = $(this).html() $(this).html("") $(this).prop('disabled', true) let id = aData['id']; axios.post(authentication_access_control_clone_uri, {pk: id}) .then((response) => { notify('success', gettext('Success'), gettext("Authentication ACL cloned")) authentication_access_control_table.DataTable().fnDraw(); }) .then(() => { $(this).html(txt) $(this).prop('disabled', false) }) }) } }); {% endblock %}