Open aljohnso opened 7 years ago
$( document ).ready(function() { console.log("ready!"); CreateTable("Timers", "timers"); CreateTable("Meters","meters"); CreateTable("Counters","counters"); CreateTable("Histograms","histograms"); var table = $("#All").DataTable({//targets table and creates table "ajax": { "url":"/api/v0/metricsJSON", "dataSrc": function (data) { var timers = CleanRecords(data, "timers"); var meters = CleanRecords(data, "meters"); var counters = CleanRecords(data, "counters"); var histograms = CleanRecords(data, "histograms"); var all = timers.concat(meters).concat(counters).concat(histograms); var newData = {"data":all}; return flattenObject(newData); } }, "columns": [ {"data": "gaugeName"}, {"data": "count"} ], "initComplete": function() { bindModal("timers"); bindModal("meters"); bindModal("counters"); bindModal("histograms"); } }); $("#All tbody").on('click', 'tr', function () { getModal("timers", table.row( this ).id); getModal("meters", table.row( this ).id); getModal("counters", table.row( this ).id); getModal("histograms", table.row( this ).id); } ); // .on( 'order.dt', function () { // bindModal("timers"); // bindModal("meters"); // bindModal("counters"); // bindModal("histograms"); } ) // .on( 'search.dt', function () { // bindModal("timers"); // bindModal("meters"); // bindModal("counters"); // bindModal("histograms"); } ) // .on( 'page.dt', function () { // bindModal("timers"); // bindModal("meters"); // bindModal("counters"); // bindModal("histograms"); } ); makeHidenTables(); });
/**
* Parama tableID: the id of the table we which to create
* Parama dataType: the metric type
* returns: creates a table with modals yay
*/
function CreateTable(tableID, dataType) {
var table = $("#" + tableID).DataTable({//targets table and creates table
"ajax": {
"url":"/api/v0/metricsJSON",
"dataSrc": function (data) {
var timers = CleanRecords(data, dataType);
var newData = {"data":timers};
// console.log(newData); var newOutPutData = flattenObject(newData); return newOutPutData; } }, "columns": [ {"data": "gaugeName"}, {"data": "count"} ], "initComplete": function() { bindModal(dataType); } }) $("#" + tableID +" tbody").on('click', 'tr', function () { getModal(table.row( this ).data().gaugeType, table.row( this ).data().Name); } ); }
Such good docs! console.log("ready!"); $("#Timers").DataTable({//targets table and creates table "ajax": { "url":"/api/v0/metricsJSON", "dataSrc": function (data) { var timers = CleanRecords(data, "timers"); var newData = {"data":timers}; // console.log(newData); var newOutPutData = flattenObject(newData); return newOutPutData; } }, "columns": [ {"data": "gaugeName"}, {"data": "count"} ], "initComplete": function() { bindModal("timers"); } }) .on('click', 'tr', function () { bindModal("timers"); } );