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

 {% translate "Portal Templates" %}

{% endblock %} {% block jquery_code %} $(document).ready(function(){ $('[data-toggle="tooltip"]').tooltip(); }); let portal_template_clone_uri = "{% url 'portal.template.clone' %}"; var aoColumns = [ { sTitle: "ID", name: "id", aTargets: [0], defaultContent: "", mData: "id", bVisible: false, }, { sTitle: '{% translate "Name" %}', name: "name", aTargets: [1], defaultContent: "", mData: "name", sWidth: "90%", }, { sTitle: '{% translate "Action" %}', mData:"id", aTargets: [2], defaultContent: "", sWidth: "10%", mRender: function(data, type, row) { result = ' '; if( !row.internal ) { result += ''; } return result; } } ]; var portail_template_table = $("#portal_template_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 start a reputation_ctx */ /* Events binding to edit a portal template */ $(nRow).on('click', 'td', function(e) { if (e.target.tagName !== "TD") return; const url = "{% url 'portal.template.edit' %}" + aData.id /* Open a portal template edition in a new tab with ctrl click */ if (e.ctrlKey || e.metaKey) { window.open(url, '_blank'); } else { window.location.href = url; } }); /* Open a portal template 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.template.edit' %}" + aData.id, '_blank'); } }); $(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(portal_template_clone_uri, {pk: id}) .then((response) => { notify('success', gettext('Success'), gettext("Authentication ACL cloned")) portail_template_table.DataTable().fnDraw(); }) .then(() => { $(this).html(txt) $(this).prop('disabled', false) }) }) } // fnCreatedRow: function }); $('#image_list').DataTable({ language: language_datatable, "autoWidth": false, "order": [[1, 'asc']], "aoColumns": [ {'mData': 'preview', sWidth: "85%", 'name': 'preview', 'aTargets': [0], 'bSortable': false, 'mRender': function(data, type, row){ return ""; }}, {'mData': 'name', sWidth: "10%", 'name': 'name', 'aTargets': [1]}, {'mData': 'name', sWidth: "5%", 'name': 'action', 'aTargets': [2], 'bSortable': false, mRender: function(data, type, row) { return `` }}, ], fnCreatedRow: function(nRow, aData) { /* Events binding to edit a portal image */ $(nRow).on('click', 'td', function(e) { if (e.target.tagName !== "TD") return; const url = "{% url 'portal.image.edit' %}" + aData.id /* Open a portal image 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 portal image 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.image.edit' %}" + aData.id, '_blank'); } }); // /$(nRow).on('mousedown', 'td' } }); axios.get("/api/v1/portal/images/") .then((response) => { for (let image of response.data.res) { console.log(image) let data = { id: image.id, preview: image.create_preview_html, name: image.name, } $('#image_list').dataTable().fnAddData(data) } }) {% endblock %}