Skip to content

Commit 51fa17f

Browse files
committed
v2.0.5
1 parent 2fa584f commit 51fa17f

6 files changed

Lines changed: 64 additions & 27 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Module for displaying information about servers. Supports displaying additional
1616

1717
Download the latest release and install it via the Flute CMS admin panel.
1818

19-
Current version: **2.0.4**
19+
Current version: **2.0.5**
2020

2121
## Authors
2222

Resources/assets/scss/modules/_monitoring-card.scss

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,19 +190,22 @@
190190
}
191191

192192
.card-play-btn {
193-
position: absolute;
194-
bottom: 12px;
195-
right: 12px;
196-
z-index: 4;
197-
width: 34px;
198-
height: 34px;
193+
width: 32px;
194+
height: 32px;
195+
padding: 0;
196+
margin: 0;
199197
display: flex;
200198
align-items: center;
201199
justify-content: center;
202-
border-radius: 50%;
200+
border-radius: 100px;
203201
background: var(--accent);
204202
color: var(--accent-950);
205-
transition: opacity var(--transition);
203+
border: 1px solid transparent;
204+
cursor: pointer;
205+
text-decoration: none;
206+
line-height: 1;
207+
box-sizing: border-box;
208+
transition: var(--transition);
206209

207210
&:hover {
208211
opacity: 0.85;
@@ -215,6 +218,15 @@
215218
}
216219
}
217220

221+
&:not(.monitoring-card-mode) .card-play-btn {
222+
position: absolute;
223+
bottom: 12px;
224+
right: 12px;
225+
z-index: 4;
226+
width: 34px;
227+
height: 34px;
228+
}
229+
218230
&-inactive {
219231
opacity: 0.5;
220232

Resources/views/components/server-card.blade.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@
6464
@endif
6565
</div>
6666
</div>
67-
@if (!$isInactive && !$hasError)
68-
<a href="{{ $steamConnect }}" class="card-play-btn" onclick="event.stopPropagation()"
69-
data-tooltip="{{ __($trans . '.actions.play') }}">
70-
<x-icon path="ph.regular.play" />
71-
</a>
72-
@endif
7367
<div class="card-hover-actions">
7468
<button class="card-copy-btn copyable" data-copy="connect {{ $connect }}" onclick="event.stopPropagation()"
7569
data-tooltip="{{ __($trans . '.actions.copy_ip') }}">
7670
<x-icon path="ph.regular.copy" />
7771
</button>
72+
@if (!$isInactive && !$hasError)
73+
<a href="{{ $steamConnect }}" class="card-play-btn" onclick="event.stopPropagation()"
74+
data-tooltip="{{ __($trans . '.actions.play') }}">
75+
<x-icon path="ph.regular.play" />
76+
</a>
77+
@endif
7878
</div>
7979
</div>
8080
@else

Services/MonitoringService.php

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ protected function processBatch(array $servers): void
361361
} catch (Exception $e) {
362362
$serverId = $this->getServerIdentifier($server);
363363
logs()->error("Error updating server status for {$serverId}: {$e->getMessage()}");
364+
364365
}
365366
}
366367
}
@@ -566,8 +567,8 @@ protected function getServerIdentifier(Server $server): string
566567

567568
protected function saveStatus(ServerStatus $status): void
568569
{
569-
$timezone = new DateTimeZone(config('app.timezone', 'UTC'));
570-
$now = new DateTimeImmutable('now', $timezone);
570+
$dbTimezone = $this->detectDatabaseTimezone();
571+
$now = new DateTimeImmutable('now', $dbTimezone);
571572

572573
$hourStart = $now->setTime((int) $now->format('H'), 0, 0);
573574
$hourEnd = $hourStart->modify('+1 hour');
@@ -586,12 +587,7 @@ protected function saveStatus(ServerStatus $status): void
586587
} catch (ConstrainException $e) {
587588
$this->fixAutoIncrement();
588589

589-
$existing = $this->findServerStatusInHourWindow($status->server->id, $hourStart, $hourEnd)
590-
?? ServerStatus::query()
591-
->where('server_id', $status->server->id)
592-
->orderBy('updated_at', 'DESC')
593-
->limit(1)
594-
->fetchOne();
590+
$existing = $this->findServerStatusInHourWindow($status->server->id, $hourStart, $hourEnd);
595591

596592
if ($existing !== null) {
597593
$this->copyServerStatusSnapshot($status, $existing);
@@ -604,6 +600,37 @@ protected function saveStatus(ServerStatus $status): void
604600
}
605601
}
606602

603+
private function detectDatabaseTimezone(): DateTimeZone
604+
{
605+
static $tz = null;
606+
607+
if ($tz !== null) {
608+
return $tz;
609+
}
610+
611+
try {
612+
$db = app(\Flute\Core\Database\DatabaseConnection::class)->getDbal()->database();
613+
$driver = $db->getDriver();
614+
$pdo = method_exists($driver, 'getPDO') ? $driver->getPDO() : null;
615+
616+
if ($pdo) {
617+
$result = $pdo->query("SELECT TIMESTAMPDIFF(SECOND, UTC_TIMESTAMP(), NOW())")->fetchColumn();
618+
$offsetSeconds = (int) $result;
619+
$sign = $offsetSeconds >= 0 ? '+' : '-';
620+
$hours = abs(intdiv($offsetSeconds, 3600));
621+
$minutes = abs(intdiv($offsetSeconds % 3600, 60));
622+
$tz = new DateTimeZone(sprintf('%s%02d:%02d', $sign, $hours, $minutes));
623+
624+
return $tz;
625+
}
626+
} catch (Throwable) {
627+
}
628+
629+
$tz = new DateTimeZone('UTC');
630+
631+
return $tz;
632+
}
633+
607634
private function fixAutoIncrement(): void
608635
{
609636
try {

database/Entities/ServerStatus.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Cycle\Annotated\Annotation\Relation\BelongsTo;
99
use Cycle\Annotated\Annotation\Table\Index;
1010
use DateTimeImmutable;
11-
use DateTimeZone;
1211
use Flute\Core\Database\Entities\Server;
1312

1413
#[Entity]
@@ -86,7 +85,6 @@ public function setAdditional(array $data): void
8685
*/
8786
public function touch(): void
8887
{
89-
$timezone = new DateTimeZone(config('app.timezone', 'UTC'));
90-
$this->updated_at = new DateTimeImmutable('now', $timezone);
88+
$this->updated_at = new DateTimeImmutable('now');
9189
}
9290
}

module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Monitoring",
3-
"version": "2.0.4",
3+
"version": "2.0.5",
44
"description": "Module for monitoring the servers",
55
"authors": ["Flames"],
66
"providers": ["Flute\\Modules\\Monitoring\\Providers\\MonitoringProvider"],

0 commit comments

Comments
 (0)