mirror of
https://github.com/mbirth/tcl_update_db.git
synced 2024-12-25 12:04:07 +00:00
Added version timeline.
This commit is contained in:
parent
3d02aaea3a
commit
01659d4cfd
@ -11,8 +11,12 @@ body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
body.timeline {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
main {
|
||||
overflow: scroll;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.panel {
|
||||
@ -60,3 +64,38 @@ tr:hover {
|
||||
td.fullonly {
|
||||
color: #88f;
|
||||
}
|
||||
|
||||
.release-card {
|
||||
background-color: white;
|
||||
border-radius: 12px 4px;
|
||||
width: 80%;
|
||||
margin: 20px auto;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.release-card .version {
|
||||
font-weight: bold;
|
||||
font-size: 1.5em;
|
||||
display: table-cell;
|
||||
}
|
||||
|
||||
.release-card .date {
|
||||
display: table-cell;
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
.release-card .date span {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.release-card .devices {
|
||||
display: table-cell;
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
.release-card .devices span {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.release-card .lastreleased {
|
||||
}
|
||||
|
@ -85,6 +85,21 @@ class SQLiteReader
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getAllVariantsByRef()
|
||||
{
|
||||
$sql = 'SELECT f.name AS family, m.name AS model, d.curef, d.name AS variant FROM families f LEFT JOIN models m ON f.familyId=m.familyId LEFT JOIN devices d ON m.modelId=d.modelId;';
|
||||
$sqlresult = $this->pdo->query($sql);
|
||||
$result = array();
|
||||
foreach ($sqlresult->fetchAll(\PDO::FETCH_ASSOC) as $row) {
|
||||
$result[$row['curef']] = array(
|
||||
'family' => $row['family'],
|
||||
'model' => $row['model'],
|
||||
'variant' => $row['variant'],
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getAllUpdates($curef, $which = self::BOTH)
|
||||
{
|
||||
$sql = 'SELECT * FROM updates u LEFT JOIN files f ON u.file_sha1=f.sha1 WHERE curef=?';
|
||||
@ -99,6 +114,29 @@ class SQLiteReader
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getAllUpdatesForFile($sha1)
|
||||
{
|
||||
$sql = 'SELECT * FROM updates u WHERE u.file_sha1=? ORDER BY pubDate ASC';
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$ok = $stmt->execute(array($sha1));
|
||||
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getAllFiles($which = self::BOTH)
|
||||
{
|
||||
$sql = 'SELECT * FROM files f';
|
||||
if ($which == self::OTA_ONLY) {
|
||||
$sql .= ' WHERE fv IS NOT null';
|
||||
} elseif ($which == self::FULL_ONLY) {
|
||||
$sql .= ' WHERE fv IS null';
|
||||
}
|
||||
$sql .= ' ORDER BY published_first DESC';
|
||||
$stmt = $this->pdo->query($sql);
|
||||
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getLatestUpdate($curef, $which = self::BOTH)
|
||||
{
|
||||
$sql = 'SELECT * FROM updates u LEFT JOIN files f ON u.file_sha1=f.sha1 WHERE curef=?';
|
||||
|
82
timeline.php
Executable file
82
timeline.php
Executable file
@ -0,0 +1,82 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>BlackBerry/TCL Firmware Timeline</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.8"/>
|
||||
<meta name="theme-color" content="#1b5e20"/>
|
||||
<link rel="stylesheet" href="node_modules/material-components-web/dist/material-components-web.css"/>
|
||||
<link rel="stylesheet" href="assets/material-icons.css"/>
|
||||
<link rel="stylesheet" href="assets/style.css"/>
|
||||
<script type="text/javascript" src="node_modules/material-components-web/dist/material-components-web.js"></script>
|
||||
</head>
|
||||
<body class="mdc-typography timeline">
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/lib/autoloader.php';
|
||||
|
||||
use \TclUpdates\SQLiteReader;
|
||||
|
||||
$db = new SQLiteReader();
|
||||
|
||||
$allVars = $db->getAllVariantsByRef();
|
||||
$unknowns = $db->getUnknownRefs();
|
||||
if (count($unknowns) > 0) {
|
||||
foreach ($unknowns as $uref) {
|
||||
$allVars[$uref] = array(
|
||||
'family' => 'Unknown',
|
||||
'model' => 'Model',
|
||||
'variant' => '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<header class="mdc-toolbar mdc-toolbar--fixed">
|
||||
<div class="mdc-toolbar__row">
|
||||
<section class="mdc-toolbar__section mdc-toolbar__section--shrink-to-fit mdc-toolbar__section--align-start">
|
||||
<span class="mdc-toolbar__title">BlackBerry/TCL Firmware Timeline</span>
|
||||
</section>
|
||||
</div>
|
||||
</header>
|
||||
<main>
|
||||
<div class="mdc-toolbar-fixed-adjust"></div>
|
||||
<?php
|
||||
|
||||
$allfiles = $db->getAllFiles($db::FULL_ONLY);
|
||||
foreach ($allfiles as $file) {
|
||||
$updates = $db->getAllUpdatesForFile($file['sha1']);
|
||||
$validRefs = array();
|
||||
$validDevs = array();
|
||||
foreach ($updates as $u) {
|
||||
$dev = $allVars[$u['curef']];
|
||||
$validRefs[] = $u['curef'];
|
||||
$validDevs[] = $dev['family'] . ' ' . $dev['model'];
|
||||
}
|
||||
$validDevs = array_unique($validDevs);
|
||||
sort($validDevs);
|
||||
$device = $allVars[$updates[0]['curef']];
|
||||
$date = new DateTime($file['published_first']);
|
||||
$date->setTimezone(new DateTimeZone('CET'));
|
||||
$dateLast = new DateTime($file['published_last']);
|
||||
$dateLast->setTimezone(new DateTimeZone('CET'));
|
||||
echo '<div class="mdc-card release-card">';
|
||||
echo '<div class="mdc-typography--body1">';
|
||||
echo '<div class="version">' . $file['tv'];
|
||||
if ($file['fv']) {
|
||||
echo '<span>(OTA from ' . $file['fv'] . ')</span>';
|
||||
}
|
||||
echo '</div>';
|
||||
echo '<div class="date"><span>' . $date->format('Y-m-d') . '</span> ' . $date->format('H:i.s') . ' CET</div>';
|
||||
echo '<div class="devices"><span>' . implode('</span> / <span>', $validDevs) . '</span></div>';
|
||||
echo '<div class="lastreleased">Last released: <span>' . $dateLast->format('Y-m-d H:i.s') . '</span></div>';
|
||||
echo '<div class="validfor">Valid for (order of release): <span>' . implode('</span>, <span>', $validRefs) . '</span></div>';
|
||||
#print_r($file);
|
||||
#print_r($updates);
|
||||
echo '</div></div>';
|
||||
}
|
||||
|
||||
?>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user