Skip to content
Permalink
Browse files

Give hotfix page the most basic datatables treatment

  • Loading branch information
Marlamin committed Jan 10, 2020
1 parent 5a927b4 commit 079f390c9429e5fb46e8942773cdeced9f4ff429
Showing with 52 additions and 14 deletions.
  1. +24 −0 dbc/hotfix_api.php
  2. +28 −14 dbc/hotfixes.php
@@ -0,0 +1,24 @@
<?php
require_once(__DIR__ . "/../inc/config.php");
header('Content-Type: application/json');

$start = (int)filter_input( INPUT_GET, 'start', FILTER_SANITIZE_NUMBER_INT );
$length = (int)filter_input( INPUT_GET, 'length', FILTER_SANITIZE_NUMBER_INT );

if(empty($_GET['draw']))
$_GET['draw'] = 0;

$returndata['draw'] = (int)$_GET['draw'];
$returndata['recordsTotal'] = $pdo->query("SELECT count(*) FROM wow_hotfixes")->fetchColumn();
$returndata['recordsFiltered'] = $returndata['recordsTotal'];

$dataq = $pdo->prepare("SELECT * FROM wow_hotfixes ORDER BY firstdetected DESC, pushID DESC LIMIT " . $start .", " . $length);
$dataq->execute();

$returndata['data'] = array();
while($row = $dataq->fetch()){
$returndata['data'][] = array($row['pushID'], $row['tableName'], $row['recordID'], $row['build'], $row['firstdetected']);
}

echo json_encode($returndata);
?>
@@ -1,23 +1,37 @@
<?php
require_once(__DIR__ . "/../inc/header.php");

$dbcs = [];
foreach($pdo->query("SELECT * FROM wow_dbc_tables") as $dbc){
$dbcs[$dbc['name']] = $dbc;
}
?>
<div class='container-fluid'>
<table class='table'>
<thead>
<tr><th>Push ID</th><th>Table name</th><th>Record ID</th><th>Build</th><th>First seen at</th></tr>
<?php
foreach($pdo->query("SELECT * FROM wow_hotfixes ORDER BY firstdetected DESC, pushID DESC") as $hotfix){
?>
<tr><td><?=$hotfix['pushID']?></td><td><?=$hotfix['tableName']?></td><td><?=$hotfix['recordID']?></td><td><?=$hotfix['build']?></td><td><?=$hotfix['firstdetected']?></td></tr>
<? } ?>
</table>
<table class='table' id='hotfixTable'>
<thead>
<tr><th>Push ID</th><th>Table name</th><th>Record ID</th><th>Build</th><th>First seen at</th></tr>
</thead>
<tbody>

</tbody>
</table>
</div>
<link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/css/dataTables.bootstrap4.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/js/dataTables.bootstrap4.min.js"></script>
<script src="https://cdn.datatables.net/plug-ins/1.10.19/pagination/input.js" crossorigin="anonymous"></script>
<script type='text/javascript'>
var table = $('#hotfixTable').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "/dbc/hotfix_api.php"
},
"pageLength": 25,
"displayStart": 0,
"autoWidth": true,
"pagingType": "input",
"orderMulti": false,
"ordering": false,
"searching": false,
"language": { "search": "<a class='btn btn-dark btn-sm btn-outline-primary' href='#' onClick='toggleFilters()' style='margin-right: 10px'>Toggle filters</a> Search: _INPUT_ " },
"search": { "search": "" }
});

</script>
<?php

0 comments on commit 079f390

Please sign in to comment.
You can’t perform that action at this time.