Improve dashboard and add task info to show the informatoin
This commit is contained in:
Родитель
8814292af5
Коммит
359735792e
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
|
||||
$migrate = function() {
|
||||
mysql_query("ALTER TABLE `control_task_queue` ADD `output` LONGTEXT NOT NULL AFTER `finish`;") or die(mysql_error());
|
||||
};
|
||||
|
||||
$rollback = function() {
|
||||
mysql_query("ALTER TABLE `control_task_queue` DROP `output`;") or die(mysql_error());
|
||||
};
|
|
@ -1,4 +1,38 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="content-language" content="en">
|
||||
<title>ARE WE FAST YET?</title>
|
||||
<link rel="stylesheet" title="Default Stylesheet" type="text/css" href="style.css">
|
||||
<link rel="shortcut icon" href="//www.arewefastyet.com/awfy_favicon.png">
|
||||
<link href='//fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
|
||||
<script type="text/javascript" src="jquery/jquery-1.8.3.min.js"></script>
|
||||
<script type="text/javascript" src="jquery/jquery.ba-hashchange.min.js"></script>
|
||||
<script type="text/javascript" src="flot/jquery.flot.js"></script>
|
||||
<script type="text/javascript" src="flot/jquery.flot.selection.js"></script>
|
||||
<script type="text/javascript" src="data.php?file=master.js"></script>
|
||||
<script type="text/javascript" src="awfy.js"></script>
|
||||
<script type="text/javascript" src="frontpage.js"></script>
|
||||
<script type="text/javascript" src="tooltip.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<div class='container'>
|
||||
<h1><a href='#'>AreWeFastYet</a></h1>
|
||||
<div class='rightSide'>
|
||||
<div><a href="http://h4writer.com"><span>Blog</span></a></div>
|
||||
<div><a href="/overview"><span>Overview</span></a></div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class='dashboard_content'>
|
||||
<?php
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
require_once("internals.php");
|
||||
require_once("lib/DB/Mode.php");
|
||||
|
@ -95,6 +129,15 @@ while($unit = mysql_fetch_object($qUnits)) {
|
|||
|
||||
$queue = new TaskQueue($unit->id);
|
||||
echo "<td>";
|
||||
if ($task = $queue->last_finished_task()) {
|
||||
if (time() - $task->finish_time() > 60*60*24)
|
||||
echo "<span style='color:red'>";
|
||||
else
|
||||
echo "<span>";
|
||||
} else {
|
||||
echo "<span>";
|
||||
}
|
||||
|
||||
if ($queue->has_active_task()) {
|
||||
$active = $queue->get_active_task();
|
||||
echo "Running";
|
||||
|
@ -104,6 +147,7 @@ while($unit = mysql_fetch_object($qUnits)) {
|
|||
} else {
|
||||
echo "Not running";
|
||||
}
|
||||
echo "</span>";
|
||||
|
||||
echo "<td>";
|
||||
if ($queue->has_queued_tasks()) {
|
||||
|
@ -135,12 +179,22 @@ while($unit = mysql_fetch_object($qUnits)) {
|
|||
}
|
||||
|
||||
echo "<td>";
|
||||
if ($last = $queue->last_finished_task()) {
|
||||
echo "Finished ";
|
||||
echo "<span title='".date("G:i d/m/Y", $last->finish_time())."'>".time_ago($last->finish_time())." ago, </span>";
|
||||
echo "(took ".time_diff($last->start_time(), $last->finish_time()).")";
|
||||
if ($last->hasError()) {
|
||||
echo "<br />unsuccesfull (error: ".htmlspecialchars($last->error()).")";
|
||||
if ($tasks = $queue->last_tasks()) {
|
||||
$tasks = array_reverse($tasks);
|
||||
foreach ($tasks as $task) {
|
||||
$color = "grey";
|
||||
if ($task->hasError()) {
|
||||
$color = "red";
|
||||
} elseif ($task->finish_time() > 0) {
|
||||
if ($task->finish_time() - $task->start_time() < 5*60)
|
||||
$color = "red";
|
||||
else
|
||||
$color = "green";
|
||||
} elseif ($task->start_time() > 0) {
|
||||
$color = "black";
|
||||
}
|
||||
echo "<a href='task_info.php?id={$task->id}' style='color:{$color}'>({$task->control_tasks_id()})</a> ";
|
||||
echo "</font>";
|
||||
}
|
||||
} else {
|
||||
echo "/";
|
||||
|
@ -149,3 +203,7 @@ while($unit = mysql_fetch_object($qUnits)) {
|
|||
|
||||
}
|
||||
echo "</table>";
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -23,6 +23,10 @@ class QueuedTask extends DB {
|
|||
$this->updateString("error", empty($error) ? "unknown error" : $error);
|
||||
}
|
||||
|
||||
function setOutput($output) {
|
||||
$this->updateString("output", $output);
|
||||
}
|
||||
|
||||
function task() {
|
||||
return $this->select("task");
|
||||
}
|
||||
|
@ -51,6 +55,10 @@ class QueuedTask extends DB {
|
|||
return $this->select("control_tasks_id");
|
||||
}
|
||||
|
||||
function output() {
|
||||
return $this->select("output");
|
||||
}
|
||||
|
||||
function hasError() {
|
||||
return $this->select("error") != "";
|
||||
}
|
||||
|
|
|
@ -53,6 +53,18 @@ class TaskQueue {
|
|||
return $tasks;
|
||||
}
|
||||
|
||||
function last_tasks($limit = 10) {
|
||||
$qTask = mysql_query("SELECT id
|
||||
FROM control_task_queue
|
||||
WHERE control_unit_id = {$this->unit_id}
|
||||
ORDER BY id DESC LIMIT $limit") or die(mysql_error());
|
||||
$tasks = Array();
|
||||
while ($task = mysql_fetch_object($qTask)) {
|
||||
$tasks[] = QueuedTask::FromId($task->id);
|
||||
}
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
function last_finished_task() {
|
||||
$qTask = mysql_query("SELECT id
|
||||
FROM control_task_queue
|
||||
|
|
|
@ -362,6 +362,13 @@ header {
|
|||
.graph-container {
|
||||
margin: auto;
|
||||
}
|
||||
@media (max-width: 1600px) .graph-row .graph-container {
|
||||
display: block;
|
||||
|
||||
.task_content {
|
||||
padding: 15px;
|
||||
width: 1200px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
.task_content pre {
|
||||
overflow: auto;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ if ($unit = GET_int("unit")) {
|
|||
|
||||
$task = new QueuedTask($task_id);
|
||||
$task->setFinished();
|
||||
if (isset($_POST["output"]))
|
||||
$task->setOutput($_POST["output"]);
|
||||
|
||||
die();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="content-language" content="en">
|
||||
<title>ARE WE FAST YET?</title>
|
||||
<link rel="stylesheet" title="Default Stylesheet" type="text/css" href="style.css">
|
||||
<link rel="shortcut icon" href="//www.arewefastyet.com/awfy_favicon.png">
|
||||
<link href='//fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
|
||||
<script type="text/javascript" src="jquery/jquery-1.8.3.min.js"></script>
|
||||
<script type="text/javascript" src="jquery/jquery.ba-hashchange.min.js"></script>
|
||||
<script type="text/javascript" src="flot/jquery.flot.js"></script>
|
||||
<script type="text/javascript" src="flot/jquery.flot.selection.js"></script>
|
||||
<script type="text/javascript" src="data.php?file=master.js"></script>
|
||||
<script type="text/javascript" src="awfy.js"></script>
|
||||
<script type="text/javascript" src="frontpage.js"></script>
|
||||
<script type="text/javascript" src="tooltip.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<div class='container'>
|
||||
<h1><a href='#'>AreWeFastYet</a></h1>
|
||||
<div class='rightSide'>
|
||||
<div><a href="http://h4writer.com"><span>Blog</span></a></div>
|
||||
<div><a href="/overview"><span>Overview</span></a></div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class='task_content'>
|
||||
<?php
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
require_once("internals.php");
|
||||
|
||||
require_once("lib/RetriggerController.php");
|
||||
require_once("lib/DB/TaskQueue.php");
|
||||
require_once("lib/DB/QueuedTask.php");
|
||||
require_once("lib/Slack.php");
|
||||
|
||||
init_database();
|
||||
|
||||
function time_ago($ptime, $reference = null) {
|
||||
if (!$reference)
|
||||
$reference = time();
|
||||
$etime = $reference - $ptime;
|
||||
|
||||
if ($etime < 1) {
|
||||
return '0 seconds';
|
||||
}
|
||||
|
||||
$interval = array( 12 * 30 * 24 * 60 * 60 => 'year',
|
||||
30 * 24 * 60 * 60 => 'month',
|
||||
24 * 60 * 60 => 'day',
|
||||
60 * 60 => 'hour',
|
||||
60 => 'minute',
|
||||
1 => 'second'
|
||||
);
|
||||
|
||||
foreach ($interval as $secs => $str) {
|
||||
$d = $etime / $secs;
|
||||
if ($d >= 1) {
|
||||
$r = round($d);
|
||||
return $r . ' ' . $str . ($r > 1 ? 's' : '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function print_time($timestamp) {
|
||||
if ($timestamp == 0)
|
||||
return "";
|
||||
return "<span title='".date("G:i d/m/Y", $timestamp)."'>".time_ago($timestamp)." ago</span>";
|
||||
}
|
||||
|
||||
if ($task_id = GET_int("id")) {
|
||||
|
||||
$task = new QueuedTask($task_id);
|
||||
|
||||
echo "<h1>Task ".$task->id."</h1>";
|
||||
echo "Available from: ".print_time($task->available_time())."</br>";
|
||||
echo "Started time: ".print_time($task->start_time())."</br>";
|
||||
echo "Finished time: ".print_time($task->finish_time())."</br>";
|
||||
|
||||
echo "<h2>Task: </h2>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars($task->task());
|
||||
echo "</pre>";
|
||||
|
||||
if ($error = $task->error()) {
|
||||
echo "<h2>Error: </h2>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars($task->error());
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
echo "<h2>Output: </h2>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars($task->output());
|
||||
echo "</pre>";
|
||||
|
||||
die();
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче