phpmyadmin/libraries/classes/Controllers/Server/Status/MonitorController.php
Maurício Meneghini Fauth 62d16a07ee
Replace jqPlot with Chart.js in /server/status/queries
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-04-06 18:52:43 -03:00

75 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server\Status;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Server\Status\Data;
use PhpMyAdmin\Server\SysInfo\SysInfo;
use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
use function is_numeric;
use function microtime;
class MonitorController extends AbstractController
{
public function __construct(
ResponseRenderer $response,
Template $template,
Data $data,
private DatabaseInterface $dbi,
) {
parent::__construct($response, $template, $data);
}
public function __invoke(ServerRequest $request): void
{
$GLOBALS['errorUrl'] = Url::getFromRoute('/');
if ($this->dbi->isSuperUser()) {
$this->dbi->selectDb('mysql');
}
$this->addScriptFiles([
'vendor/jquery/jquery.tablesorter.js',
'jquery.sortable-table.js',
'vendor/jqplot/jquery.jqplot.js',
'vendor/jqplot/plugins/jqplot.pieRenderer.js',
'vendor/jqplot/plugins/jqplot.enhancedPieLegendRenderer.js',
'vendor/jqplot/plugins/jqplot.canvasTextRenderer.js',
'vendor/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js',
'vendor/jqplot/plugins/jqplot.dateAxisRenderer.js',
'vendor/jqplot/plugins/jqplot.highlighter.js',
'vendor/jqplot/plugins/jqplot.cursor.js',
'jqplot/plugins/jqplot.byteFormatter.js',
'server/status/monitor.js',
'chart.js',// Needed by createProfilingChart in server/status/monitor.js
]);
$form = [
'server_time' => (int) (microtime(true) * 1000),
'server_os' => SysInfo::getOs(),
'is_superuser' => $this->dbi->isSuperUser(),
'server_db_isLocal' => $this->data->dbIsLocal,
];
$javascriptVariableNames = [];
foreach ($this->data->status as $name => $value) {
if (! is_numeric($value)) {
continue;
}
$javascriptVariableNames[] = $name;
}
$this->render('server/status/monitor/index', [
'javascript_variable_names' => $javascriptVariableNames,
'form' => $form,
]);
}
}