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

 {% translate "Authentication Portal" %}

{% endblock %} {% block jquery_code %} $(document).ready(function(){ $('[data-toggle="tooltip"]').tooltip(); }); var datatableCanRedraw = true; var aoColumns = [ { sTitle: "ID", name: "id", aTargets: [0], defaultContent: "", mData: "id", bVisible: false, }, { sTitle: '{% translate "Name" %}', name: "name", aTargets: [1], defaultContent: "", mData: "name" }, { sTitle: '{% translate "IDP" %}', name: "enable_external", aTargets: [2], defaultContent: "", mData: "enable_external", mRender: function(data, type, row) { if (data) return ""; else return ""; } }, { sTitle: '{% translate "Authentication type" %}', name: "auth_type", aTargets: [3], defaultContent: "", mData: "auth_type" }, { sTitle: '{% translate "Repositories" %}', name: "repositories", aTargets: [4], defaultContent: "", mData: "repositories", mRender: function(data, type, row) { result = ""; } }, { sTitle: '{% translate "Captcha" %}', name: "enable_captcha", aTargets: [5], defaultContent: "", mData: "enable_captcha", mRender: function(data, type, row) { if (row.enable_captcha) return ""; else return ""; } }, { sTitle: '{% translate "OTP repository" %}', name:"otp_repository", aTargets: [6], defaultContent: "", mData:"otp_repository", mRender: function(data, type, row) { if (!data) return ""; else return row.otp_repository; } }, { sTitle: '{% translate "Registration" %}', name: "enable_registration", aTargets: [7], defaultContent: "", mData: "enable_registration", mRender: function(data, type, row) { if (row.enable_registration) return ""; else return ""; } }, { sTitle: '{% translate "Action" %}', mData:"id", aTargets: [8], defaultContent: "", mRender: function(data, type, row) { let btns = [] btns.push('' ) btns.push('') return btns.join(" ") } } ]; var user_authentication_table = $("#user_authentication_list").dataTable({ bServerSide : true, order : [[1, 'desc']], iDisplayLength: 10, bProcessing : true, bSort : true, sAjaxSource : '', sServerMethod : 'POST', 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){ /* Events binding to edit a user authentication */ $(nRow).on('click', 'td', function(e) { if (e.target.tagName !== "TD") return; const url = "{% url 'portal.user_authentication.edit' %}" + aData.id /* Open a user authentication 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 a user authentication 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.user_authentication.edit' %}" + aData.id, '_blank'); } }); // /$(nRow).on('mousedown', 'td' }, // fnCreatedRow: function fnDrawCallback: function(settings){ datatableCanRedraw = true; }, // fnDrawCallback: function }); // var user_authentication_table = $("#user_authentication_list").dataTable /* Filter datatable only 1s after end of user input */ $(".dataTables_filter input") .off("keyup.DT input.DT") .bind("input", (delay(function (e) { user_authentication_table.fnFilter($(".dataTables_filter input").val()); }, 1000))); function delay(callback, ms) { var timer = 0; return function () { clearTimeout(timer); timer = setTimeout(function () { callback.apply(this, arguments); }, ms || 0); }; } /* Reload table data every 5 seconds if previous one answered */ setInterval(function(){ if(datatableCanRedraw == true) { datatableCanRedraw = false; user_authentication_table.fnDraw(false); } }, 5000) {% endblock %}