Skip to content

Commit 42b1159

Browse files
committed
fix: improve table templating and styling
Signed-off-by: Kevin Pfeifer <kevin.pfeifer@sunlime.at>
1 parent d7664e9 commit 42b1159

File tree

3 files changed

+177
-110
lines changed

3 files changed

+177
-110
lines changed

css/style.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,24 @@
316316
.cpu-wrapper {
317317
width: 100%;
318318
}
319+
320+
.server-info-table table {
321+
width: 100%;
322+
}
323+
324+
.server-info-table td {
325+
padding: 6px;
326+
}
327+
328+
.server-info__tag-wrapper {
329+
display: flex;
330+
flex-wrap: wrap;
331+
}
332+
333+
.server-info__php-extension-tag {
334+
display: inline-block;
335+
margin: 2px;
336+
padding: 2px 12px;
337+
border-radius: 16px;
338+
border: 1px solid var(--color-main-text);
339+
}

lib/PhpStatistics.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ protected function getAPCuStatus(): array {
101101
/**
102102
* Get all loaded php extensions
103103
*
104-
* @return array of strings with the names of the loaded extensions
104+
* @return array|null of strings with the names of the loaded extensions
105105
*/
106106
protected function getLoadedPhpExtensions(): ?array {
107-
return (function_exists('get_loaded_extensions') ? get_loaded_extensions() : null);
107+
if (!function_exists('get_loaded_extensions')) {
108+
return null;
109+
}
110+
$extensions = get_loaded_extensions();
111+
sort($extensions);
112+
113+
return $extensions;
108114
}
109115
}

templates/settings-admin.php

Lines changed: 148 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,34 @@ function FormatMegabytes(int $byte): string {
5757
<img class="infoicon" src="<?php p(image_path('core', 'actions/screen.svg')); ?>">
5858
<?php p($_['hostname']); ?>
5959
</h2>
60-
<p><?php p($l->t('Operating System:')); ?> <strong id="numFilesStorage"><?php p($_['osname']); ?></strong></p>
61-
<p><?php p($l->t('CPU:')); ?> <strong id="numFilesStorage"><?php p($cpu->getName()) ?></strong> (<?= $cpu->getThreads() ?> <?php p($l->t('threads')); ?>)</p>
62-
<p><?php p($l->t('Memory:')); ?>
63-
<?php if ($memory->getMemTotal() > 0): ?> <strong id="numFilesStorage"><?php p(FormatMegabytes($memory->getMemTotal())) ?></strong></p>
64-
<?php endif; ?>
65-
<p><?php p($l->t('Server time:')); ?> <strong id="numFilesStorage"><span class="info" id="servertime"></span></strong></p>
66-
<p><?php p($l->t('Uptime:')); ?> <strong id="numFilesStorage"><span class="info" id="uptime"></span></strong></p>
60+
<div class="server-info-table">
61+
<table>
62+
<tbody>
63+
<tr>
64+
<td><?php p($l->t('Operating System:')); ?></td>
65+
<td class="info"><?php p($_['osname']); ?></td>
66+
</tr>
67+
<tr>
68+
<td><?php p($l->t('CPU:')); ?></td>
69+
<td class="info"><?php p($cpu->getName()) ?></strong> (<?= $cpu->getThreads() ?> <?php p($l->t('threads')); ?>)</td>
70+
</tr>
71+
<?php if ($memory->getMemTotal() > 0): ?>
72+
<tr>
73+
<td><?php p($l->t('Memory:')); ?></td>
74+
<td class="info"><?php p(FormatMegabytes($memory->getMemTotal())) ?></td>
75+
</tr>
76+
<?php endif; ?>
77+
<tr>
78+
<td><?php p($l->t('Server time:')); ?></td>
79+
<td><span class="info" id="servertime"></span></td>
80+
</tr>
81+
<tr>
82+
<td><?php p($l->t('Uptime:')); ?></td>
83+
<td><span class="info" id="uptime"></span></td>
84+
</tr>
85+
</tbody>
86+
</table>
87+
</div>
6788
</div>
6889

6990
<?php if (count($thermalZones) > 0): ?>
@@ -335,93 +356,110 @@ function FormatMegabytes(int $byte): string {
335356
<img class="infoicon" src="<?php p(image_path('core', 'actions/screen.svg')); ?>">
336357
<?php p($l->t('PHP')); ?>
337358
</h2>
338-
<div class="infobox">
339-
<div class="phpinfo-wrapper">
340-
<p>
341-
<?php p($l->t('Version:')); ?>
342-
<em id="phpVersion"><?php p($_['php']['version']); ?></em>
343-
</p>
344-
<p>
345-
<?php p($l->t('Memory limit:')); ?>
346-
<em id="phpMemLimit"><?php p($_['php']['memory_limit']); ?></em>
347-
</p>
348-
<p>
349-
<?php p($l->t('Max execution time:')); ?>
350-
<em id="phpMaxExecTime"><?php p($_['php']['max_execution_time']); ?></em>
351-
</p>
352-
<p>
353-
<?php p($l->t('Upload max size:')); ?>
354-
<em id="phpUploadMaxSize"><?php p($_['php']['upload_max_filesize']); ?></em>
355-
</p>
356-
<p>
357-
<?php p($l->t('OPcache Revalidate Frequency:')); ?>
358-
<em id="phpOpcacheRevalidateFreq"><?php p($_['php']['opcache_revalidate_freq']); ?></em>
359-
</p>
360-
<p>
361-
<?php p($l->t('Extensions:')); ?>
362-
<em id="phpExtensions"><?php p($_['php']['extensions'] !== null ? implode(', ', $_['php']['extensions']) : $l->t('Unable to list extensions')); ?></em>
363-
</p>
364-
<?php if ($phpinfo): ?>
365-
<p>
366-
<a target="_blank" href="<?= $_['phpinfoUrl'] ?>"><?php p($l->t('Show phpinfo')) ?></a>
367-
</p>
368-
<?php endif; ?>
369-
</div>
370-
</div>
359+
<div class="server-info-table">
360+
<table>
361+
<tbody>
362+
<tr>
363+
<td><?php p($l->t('Version:')); ?></td>
364+
<td class="info"><?php p($_['php']['version']); ?></td>
365+
</tr>
366+
<tr>
367+
<td><?php p($l->t('Memory limit:')); ?></td>
368+
<td class="info"><?php p($_['php']['memory_limit'] / 1024 / 1024); ?> <?php p($l->t('MB')); ?></td>
369+
</tr>
370+
<tr>
371+
<td><?php p($l->t('Max execution time:')); ?></td>
372+
<td class="info"><?php p($_['php']['max_execution_time']); ?> <?php p($l->t('seconds')); ?></td>
373+
</tr>
374+
<tr>
375+
<td><?php p($l->t('Upload max size:')); ?></td>
376+
<td class="info"><?php p($_['php']['upload_max_filesize'] / 1024 / 1024); ?> <?php p($l->t('MB')); ?></td>
377+
</tr>
378+
<tr>
379+
<td><?php p($l->t('OPcache Revalidate Frequency:')); ?></td>
380+
<td class="info"><?php p($_['php']['opcache_revalidate_freq']); ?> <?php p($l->t('seconds')); ?></td>
381+
</tr>
382+
<tr>
383+
<td><?php p($l->t('Extensions:')); ?></td>
384+
<td class="info"><div class="server-info__tag-wrapper"><?php
385+
if ($_['php']['extensions'] !== null):
386+
foreach ($_['php']['extensions'] as $extension):?>
387+
<span class="server-info__php-extension-tag"><?= $extension ?></span>
388+
<?php
389+
endforeach;
390+
else:
391+
$l->t('Unable to list extensions');
392+
endif;
393+
?>
394+
</div></td>
395+
</tr>
396+
<?php if ($phpinfo): ?>
397+
<tr>
398+
<td><?php p($l->t('PHP Info:')); ?></td>
399+
<td>
400+
<a class="info" target="_blank" href="<?= $_['phpinfoUrl'] ?>"><?php p($l->t('Show phpinfo')) ?></a>
401+
</td>
402+
</tr>
403+
<?php endif; ?>
404+
</tbody>
405+
</table>
406+
</div>
371407
<?php if ($_['fpm'] !== false): ?>
372408
<h2><?php p($l->t('FPM worker pool')); ?></h2>
373-
<div class="infobox">
374-
<div class="fpm-wrapper">
375-
<p>
376-
<?php p($l->t('Pool name:')); ?>
377-
<em id="fpmPool"><?php p($_['fpm']['pool']); ?></em>
378-
</p>
379-
<p>
380-
<?php p($l->t('Pool type:')); ?>
381-
<em id="fpmType"><?php p($_['fpm']['process-manager']); ?></em>
382-
</p>
383-
<p>
384-
<?php p($l->t('Start time:')); ?>
385-
<em id="fpmStartTime"><?php p($_['fpm']['start-time']); ?></em>
386-
</p>
387-
<p>
388-
<?php p($l->t('Accepted connections:')); ?>
389-
<em id="fpmAcceptedConn"><?php p($_['fpm']['accepted-conn']); ?></em>
390-
</p>
391-
<p>
392-
<?php p($l->t('Total processes:')); ?>
393-
<em id="fpmTotalProcesses"><?php p($_['fpm']['total-processes']); ?></em>
394-
</p>
395-
<p>
396-
<?php p($l->t('Active processes:')); ?>
397-
<em id="fpmActiveProcesses"><?php p($_['fpm']['active-processes']); ?></em>
398-
</p>
399-
<p>
400-
<?php p($l->t('Idle processes:')); ?>
401-
<em id="fpmIdleProcesses"><?php p($_['fpm']['idle-processes']); ?></em>
402-
</p>
403-
<p>
404-
<?php p($l->t('Listen queue:')); ?>
405-
<em id="fpmListenQueue"><?php p($_['fpm']['listen-queue']); ?></em>
406-
</p>
407-
<p>
408-
<?php p($l->t('Slow requests:')); ?>
409-
<em id="fpmSlowRequests"><?php p($_['fpm']['slow-requests']); ?></em>
410-
</p>
411-
<p>
412-
<?php p($l->t('Max listen queue:')); ?>
413-
<em id="fpmMaxListenQueue"><?php p($_['fpm']['max-listen-queue']); ?></em>
414-
</p>
415-
<p>
416-
<?php p($l->t('Max active processes:')); ?>
417-
<em id="fpmMaxActiveProcesses"><?php p($_['fpm']['max-active-processes']); ?></em>
418-
</p>
419-
<p>
420-
<?php p($l->t('Max children reached:')); ?>
421-
<em id="fpmMaxChildrenReached"><?php p($_['fpm']['max-children-reached']); ?></em>
422-
</p>
423-
</div>
424-
</div>
409+
<div class="server-info-table">
410+
<table>
411+
<tbody>
412+
<tr>
413+
<td><?php p($l->t('Pool name:')); ?></td>
414+
<td class="info"><?php p($_['fpm']['pool']); ?></td>
415+
</tr>
416+
<tr>
417+
<td><?php p($l->t('Pool type:')); ?></td>
418+
<td class="info"><?php p($_['fpm']['process-manager']); ?></td>
419+
</tr>
420+
<tr>
421+
<td><?php p($l->t('Start time:')); ?></td>
422+
<td class="info"><?php p($_['fpm']['start-time']); ?></td>
423+
</tr>
424+
<tr>
425+
<td><?php p($l->t('Accepted connections:')); ?></td>
426+
<td class="info"><?php p($_['fpm']['accepted-conn']); ?></td>
427+
</tr>
428+
<tr>
429+
<td><?php p($l->t('Total processes:')); ?></td>
430+
<td class="info"><?php p($_['fpm']['total-processes']); ?></td>
431+
</tr>
432+
<tr>
433+
<td><?php p($l->t('Active processes:')); ?></td>
434+
<td class="info"><?php p($_['fpm']['active-processes']); ?></td>
435+
</tr>
436+
<tr>
437+
<td><?php p($l->t('Idle processes:')); ?></td>
438+
<td class="info"><?php p($_['fpm']['idle-processes']); ?></td>
439+
</tr>
440+
<tr>
441+
<td><?php p($l->t('Listen queue:')); ?></td>
442+
<td class="info"><?php p($_['fpm']['listen-queue']); ?></td>
443+
</tr>
444+
<tr>
445+
<td><?php p($l->t('Slow requests:')); ?></td>
446+
<td class="info"><?php p($_['fpm']['slow-requests']); ?></td>
447+
</tr>
448+
<tr>
449+
<td><?php p($l->t('Max listen queue:')); ?></td>
450+
<td class="info"><?php p($_['fpm']['max-listen-queue']); ?></td>
451+
</tr>
452+
<tr>
453+
<td><?php p($l->t('Max active processes:')); ?></td>
454+
<td class="info"><?php p($_['fpm']['max-active-processes']); ?></td>
455+
</tr>
456+
<tr>
457+
<td><?php p($l->t('Max children reached:')); ?></td>
458+
<td class="info"><?php p($_['fpm']['max-children-reached']); ?></td>
459+
</tr>
460+
</tbody>
461+
</table>
462+
</div>
425463
<?php endif; ?>
426464
</div>
427465

@@ -431,22 +469,24 @@ function FormatMegabytes(int $byte): string {
431469
<img class="infoicon" src="<?php p(image_path('core', 'actions/screen.svg')); ?>">
432470
<?php p($l->t('Database')); ?>
433471
</h2>
434-
<div class="infobox">
435-
<div class="database-wrapper">
436-
<p>
437-
<?php p($l->t('Type:')); ?>
438-
<em id="databaseType"><?php p($_['database']['type']); ?></em>
439-
</p>
440-
<p>
441-
<?php p($l->t('Version:')); ?>
442-
<em id="databaseVersion"><?php p($_['database']['version']); ?></em>
443-
</p>
444-
<p>
445-
<?php p($l->t('Size:')); ?>
446-
<em id="databaseSize"><?php p($_['database']['size']); ?></em>
447-
</p>
448-
</div>
449-
</div>
472+
<div class="server-info-table">
473+
<table>
474+
<tbody>
475+
<tr>
476+
<td><?php p($l->t('Type:')); ?></td>
477+
<td class="info"><?php p($_['database']['type']); ?></td>
478+
</tr>
479+
<tr>
480+
<td><?php p($l->t('Version:')); ?></td>
481+
<td class="info"><?php p($_['database']['version']); ?></td>
482+
</tr>
483+
<tr>
484+
<td><?php p($l->t('Size:')); ?></td>
485+
<td class="info"><?php p($_['database']['size'] / 1024 / 1024); ?> <?php p($l->t('MB')); ?></td>
486+
</tr>
487+
</tbody>
488+
</table>
489+
</div>
450490
</div>
451491
</div>
452492
</div>

0 commit comments

Comments
 (0)