Skip to content

Commit c3b1eee

Browse files
committed
Cache card
1 parent 5dd3cd2 commit c3b1eee

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

dist/pulse.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/pulse.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
11
import Chart from 'chart.js/auto';
22

3+
const formatDate = (value) => {
4+
if (value.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/) === null) {
5+
throw new Error(`Unknown date format [${value}].`);
6+
}
7+
8+
const [date, time] = value.split(' ')
9+
const [year, month, day] = date.split('-').map(Number)
10+
const [hour, minute, second] = time.split(':').map(Number)
11+
12+
return new Date(
13+
Date.UTC(year, month - 1, day, hour, minute, second, 0)
14+
).toLocaleString(undefined, {
15+
year: "2-digit",
16+
day: "2-digit",
17+
month: "2-digit",
18+
hourCycle: "h24",
19+
hour: "2-digit",
20+
minute: "2-digit",
21+
second: "2-digit",
22+
timeZoneName: "short"
23+
});
24+
}
25+
326
window.Chart = Chart;
27+
window.formatDate = formatDate

resources/views/components/card-header.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</div>
99
@endif
1010
<hgroup class="flex flex-wrap items-baseline gap-x-2 overflow-hidden">
11-
<h2 class="text-base font-bold text-gray-600 dark:text-gray-300 truncate" title="{{ $title }}">{{ $name }}</h2>
11+
<h2 class="text-base font-bold text-gray-600 dark:text-gray-300 truncate" @if($attributes->has('x-bind:title')) x-bind:title="{{ $attributes->get('x-bind:title') }}" @else title="{{ $title }}" @endif>{{ $name }}</h2>
1212
@if ($details)
1313
<p class="text-gray-400 dark:text-gray-600 font-medium truncate"><small class="text-xs">{{ $details }}</small></p>
1414
@endif

resources/views/livewire/cache.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
33
<x-pulse::card-header
44
name="Cache"
5-
title="Global Time: {{ number_format($allTime) }}ms; Global run at: {{ $allRunAt }}; Key Time: {{ number_format($keyTime) }}ms; Key run at: {{ $keyRunAt }};"
5+
x-bind:title="`Global Time: {{ number_format($allTime) }}ms; Global run at: ${formatDate('{{ $allRunAt }}')}; Key Time: {{ number_format($keyTime) }}ms; Key run at: ${formatDate('{{ $keyRunAt }}')};`"
66
details="past {{ $this->periodForHumans() }}"
77
>
88
<x-slot:icon>

0 commit comments

Comments
 (0)