{% extends "base.html" %}
{% block content %}
CUCP |
rrc_setup |
initial_ctxt |
bearer_ctxt |
xnap_handover |
|
Attempts |
Success |
Failure |
Timeout |
Attempts |
Success |
Failure |
Timeout |
Attempts |
Success |
Failure |
Timeout |
Attempts |
Success |
Failure |
Timeout |
rrc_setup
Attempts |
Success |
Failure |
Timeout |
initial_ctxt
Attempts |
Success |
Failure |
Timeout |
bearer_ctxt
Attempts |
Success |
Failure |
Timeout |
xnap_handoverCaption
Attempts |
Success |
Failure |
Timeout |
{% endblock content %}
{% block js %}
$(document).ready(function () {
var jsonData = {{ cumulative_stats_list|safe }};
var table = $('#myTable').DataTable({
"data": jsonData,
scrollX: true,
"columns": [
{"data": "CUCP"},
{"data": "rrc_setup_Attempts.Count"},
{"data": "rrc_setup_Success.Count"},
{"data": "rrc_setup_Failure.Count"},
{"data": "rrc_setup_Timeout.Count"},
{"data": "initial_ctxt_Attempts.Count"},
{"data": "initial_ctxt_Success.Count"},
{"data": "initial_ctxt_Failure.Count"},
{"data": "initial_ctxt_Timeout.Count"},
{"data": "bearer_ctxt_Attempts.Count"},
{"data": "bearer_ctxt_Success.Count"},
{"data": "bearer_ctxt_Failure.Count"},
{"data": "bearer_ctxt_Timeout.Count"},
{"data": "xnap_handover_Attempts.Count"},
{"data": "xnap_handover_Success.Count"},
{"data": "xnap_handover_Failure.Count"},
{"data": "xnap_handover_Timeout.Count"},
],
"createdRow": function (row, data, dataIndex) {
$(row).addClass('crnti-row');
}
});
$('#collapsibleTables').hide();
$('#myTable tbody').on('click', 'tr.crnti-row', function () {
console.log('Row clicked');
var tr = $(this);
var row = table.row(tr);
var rowData = row.data();
console.log('Row Data:', rowData); // Check the structure of rowData
// Clear existing content
$('.collapsible-table tbody').empty();
var categoryToColumnNumber = {
'Attempts': 0,
'Success': 1,
'Failure': 2,
'Timeout': 3
};
// Iterate over each type (Attempts, Success, Failure, Timeout)
var categories = ['Attempts', 'Success', 'Failure', 'Timeout'];
for (var i = 0; i < categories.length; i++) {
var category = categories[i];
for (var key in rowData) {
if (rowData.hasOwnProperty(key) && key.endsWith('_' + category)) {
var categoryName = key.replace('_' + category, '');
var columnNumber;
if (category === 'Attempts') {
columnNumber = 0;
} else if (category === 'Success') {
columnNumber = 1;
} else if (category === 'Failure') {
columnNumber = 2;
} else if (category === 'Timeout') {
columnNumber = 3;
}
addCRNTIRows(categoryName, category, rowData[key].CRNTI, category);
updateTableCaption(categoryName, rowData.CUCP);
}
}
}
// Show the collapsible table
var collapsibleTables = $('#collapsibleTables');
var visibleTables = collapsibleTables.find('.collapsible-table:visible');
if (visibleTables.length === 0) {
collapsibleTables.show();
} else {
collapsibleTables.hide();
}
});
// Function to add CRNTI rows with links to a table body
function addCRNTIRows(categoryName, category, crntiObj, categoryHeader) {
var tableId = '#' + categoryName.toLowerCase();
if (crntiObj && crntiObj !== undefined && crntiObj.length > 0) {
var tbody = $(tableId).find('tbody'); // Get the existing tbody for the category
if (!tbody.length) {
// If tbody doesn't exist, create a new one
tbody = $('');
$(tableId).append(tbody);
}
// Check if the first row (header row) exists, if not, create it
var headerRow = tbody.find('tr:first');
if (!headerRow.length) {
headerRow = $('
');
tbody.append(headerRow);
// Use existing static headers directly
$(tableId + ' thead th').each(function () {
var columnHeader = $(this).text().trim();
headerRow.append('' + columnHeader + ' | ');
});
}
// Find the corresponding th element in the header row
var categoryCell = headerRow.find('th:contains(' + categoryHeader + ')');
// Iterate over each CRNTI in the crntiObj array
crntiObj.forEach(function (crnti, index) {
if (index > 0) {
// Add a separator if not the first CRNTI
categoryCell.append('; ');
}
// Split the CRNTI into two parts
var crntiParts = crnti.split('-');
var recordId = crntiParts[0];
var displayPart = crntiParts.slice(1).join('-')
// Create a link with data-identifier-id attribute
var crntiLink = $('', {
href: '/drawranflow/display-streaming-table/5G-SA/draw-sequence/' + recordId + '/',
'data-identifier-id': recordId,
text: displayPart,
click: function (event) {
event.preventDefault(); // Prevent default link behavior
var mainId = $(this).attr('data-identifier-id');
console.log(mainId);
var url = '/drawranflow/display-streaming-table/5G-SA/draw-sequence/' + mainId + '/';
window.location.href = url;
}
});
// Append the link to the categoryCell
categoryCell.append(crntiLink);
// Add separator if not the last CRNTI
if (index < crntiObj.length - 1) {
categoryCell.append('; ');
}
});
}
}
});
// Function to update the caption of the child table
function updateTableCaption(tableId, cucpValue) {
var tablehead = '#' + tableId.toLowerCase();
console.log("----tableId",tableId);
$(tablehead + 'Caption').text(tableId + ' - ' + cucpValue);
}
{% endblock %}