Skip to content

Commit 42f6b18

Browse files
Timezone switch on status page (#191) (#233)
Co-authored-by: James Brooks <james@alt-three.com>
1 parent 280f2bf commit 42f6b18

14 files changed

Lines changed: 42 additions & 33 deletions

File tree

resources/lang/de/settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'site_name_label' => 'Seitenname',
66
'about_this_site_label' => 'Über diese Seite',
77
'timezone_label' => 'Zeitzone',
8+
'timezone_other' => 'Andere',
89
'incident_days_label' => 'Vorfalltage',
910
'major_outage_threshold_label' => 'Schwellenwert für schwere Ausfälle',
1011
'refresh_rate_label' => 'Automatisch Seite neuladen',

resources/lang/de_AT/settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'site_name_label' => 'Seitenname',
66
'about_this_site_label' => 'Über diese Seite',
77
'timezone_label' => 'Zeitzone',
8+
'timezone_other' => 'Andere',
89
'incident_days_label' => 'Vorfalltage',
910
'major_outage_threshold_label' => 'Schwellenwert für schwere Ausfälle',
1011
'refresh_rate_label' => 'Automatisch Seite neuladen',

resources/lang/de_CH/settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'site_name_label' => 'Seitenname',
66
'about_this_site_label' => 'Über diese Seite',
77
'timezone_label' => 'Zeitzone',
8+
'timezone_other' => 'Andere',
89
'incident_days_label' => 'Vorfalltage',
910
'major_outage_threshold_label' => 'Schwellenwert für schwere Ausfälle',
1011
'refresh_rate_label' => 'Automatisch Seite neuladen',

resources/lang/en/settings.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
'manage_cachet' => [
55
'site_name_label' => 'Site Name',
66
'about_this_site_label' => 'About This Site',
7+
'timezone_label' => 'Timezone',
8+
'timezone_other' => 'Other',
9+
'browser_default' => 'Browser Default',
710
'incident_days_label' => 'Incident Days',
811
'major_outage_threshold_label' => 'Major Outage Threshold',
912
'refresh_rate_label' => 'Automatically Refresh Page',
@@ -29,7 +32,7 @@
2932
'locale_label' => 'Locale',
3033
'timezone_label' => 'Timezone',
3134
'toggles' => [
32-
'show_timezone' => 'Show Timezone',
35+
'show_timezone' => 'Show timezone on status page',
3336
],
3437
],
3538
'manage_theme' => [

resources/lang/nl/settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
'site_name_label' => 'Pagina naam',
66
'about_this_site_label' => 'Over deze site',
77
'timezone_label' => 'Tijdzone',
8+
'timezone_other' => 'Overig',
9+
'browser_default' => 'Gebruik browserstandaard',
810
'incident_days_label' => 'Incidentendagen',
911
'major_outage_threshold_label' => 'Drempel voor ernstige storingen',
1012
'refresh_rate_label' => 'Pagina automatisch opnieuw laden',

resources/lang/ph/settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'site_name_label' => 'Pangalan ng Site',
66
'about_this_site_label' => 'Tungkol sa Site na Ito',
77
'timezone_label' => 'Oras na Rehiyon',
8+
'timezone_other' => 'Iba pang mga oras',
89
'incident_days_label' => 'Mga Araw ng Insidente',
910
'major_outage_threshold_label' => 'Limitasyon ng Malaking Pagka-aberya',
1011
'refresh_rate_label' => 'Awtomatikong I-refresh ang Pahina',

resources/lang/pt_BR/settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'site_name_label' => 'Nome do Site',
66
'about_this_site_label' => 'Sobre Este Site',
77
'timezone_label' => 'Fuso Horário',
8+
'timezone_other' => 'Outro',
89
'incident_days_label' => 'Dias de Incidentes',
910
'major_outage_threshold_label' => 'Limite de Indisponibilidade Total',
1011
'refresh_rate_label' => 'Atualizar Página Automaticamente',

resources/views/components/footer.blade.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@
1111
</div>
1212
@endif
1313
@if($showTimezone)
14-
<div>
15-
{!! preg_replace(
14+
<div id="cachet-footer-timezone" data-timezone="{{ $timezone }}" data-label=""></div>
15+
<script defer async>
16+
document.addEventListener('DOMContentLoaded', function () {
17+
const timeZoneLabel = '{!! preg_replace(
1618
'/\*(.*?)\*/',
1719
'<span class="font-semibold">$1</span>',
18-
__('cachet::cachet.all_times_shown_in', ['timezone' => $timezone])
19-
) !!}
20-
</div>
20+
__('cachet::cachet.all_times_shown_in', ['timezone' => ':timezone:'])
21+
) !!}'
22+
let footerTimeZone = document.getElementById('cachet-footer-timezone').dataset.timezone;
23+
if (footerTimeZone === '-') {
24+
footerTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
25+
}
26+
document.getElementById('cachet-footer-timezone').innerHTML = timeZoneLabel.replace(':timezone:', footerTimeZone);
27+
});
28+
</script>
2129
@endif
2230
</footer>
2331
@endif

resources/views/components/incident.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
{{ \Cachet\Facades\CachetView::renderHook(\Cachet\View\RenderHook::STATUS_PAGE_INCIDENTS_BEFORE) }}
88
<div class="relative flex flex-col gap-5" x-data="{ forDate: new Date(@js($date)) }">
9-
<h3 class="text-xl font-semibold"><time datetime="{{ $date }}" x-text="forDate.toLocaleDateString()"></time></h3>
9+
<h3 class="text-xl font-semibold"><time datetime="{{ $date }}" x-text="forDate.toLocaleDateString(@if($appSettings->timezone !== '-')undefined, {timeZone: '{{$appSettings->timezone}}'}@endif )"></time></h3>
1010
@forelse($incidents as $incident)
1111
<div x-data="{ timestamp: new Date(@js($incident->timestamp)) }" class="bg-white border divide-y rounded-lg ml-9 dark:divide-zinc-700 dark:border-zinc-700 dark:bg-white/5">
1212
<div @class([
@@ -32,7 +32,7 @@
3232
@endauth
3333
</div>
3434
<span class="text-xs text-zinc-500 dark:text-zinc-400">
35-
{{ $incident->timestamp->diffForHumans() }} — <time datetime="{{ $incident->timestamp->toW3cString() }}" x-text="timestamp.toLocaleString()"></time>
35+
{{ $incident->timestamp->diffForHumans() }} — <time datetime="{{ $incident->timestamp->toW3cString() }}" x-text="timestamp.toLocaleString(@if($appSettings->timezone !== '-')undefined, {timeZone: '{{$appSettings->timezone}}'}@endif )"></time>
3636
</span>
3737
</div>
3838
<div class="flex justify-start sm:justify-end">
@@ -53,7 +53,7 @@
5353
<x-cachet::incident-update-status :status="$update->status" />
5454
<h3 class="text-lg font-semibold">{{ $update->status->getLabel() }}</h3>
5555
<span class="text-xs text-zinc-500 dark:text-zinc-400">
56-
{{ $update->created_at->diffForHumans() }} — <time datetime="{{ $update->created_at->toW3cString() }}" x-text="timestamp.toLocaleString()"></time>
56+
{{ $update->created_at->diffForHumans() }} — <time datetime="{{ $update->created_at->toW3cString() }}" x-text="timestamp.toLocaleString(@if($appSettings->timezone !== '-')undefined, {timeZone: '{{$appSettings->timezone}}'}@endif )"></time>
5757
</span>
5858
<div class="prose-sm md:prose prose-zinc dark:prose-invert prose-a:text-accent-content prose-a:underline prose-p:leading-normal">{!! $update->formattedMessage() !!}</div>
5959
</div>
@@ -62,7 +62,7 @@
6262
<x-cachet::incident-update-status :status="IncidentStatusEnum::unknown" />
6363

6464
<span class="text-xs text-zinc-500 dark:text-zinc-400">
65-
{{ $incident->timestamp->diffForHumans() }} — <time datetime="{{ $incident->timestamp->toW3cString() }}" x-text="timestamp.toLocaleString()"></time>
65+
{{ $incident->timestamp->diffForHumans() }} — <time datetime="{{ $incident->timestamp->toW3cString() }}" x-text="timestamp.toLocaleString(@if($appSettings->timezone !== '-')undefined, {timeZone: '{{$appSettings->timezone}}'}@endif )"></time>
6666
</span>
6767
<div class="prose-sm md:prose prose-zinc dark:prose-invert prose-a:text-accent-content prose-a:underline prose-p:leading-normal">{!! $incident->formattedMessage() !!}</div>
6868
</div>

resources/views/components/schedule.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</h3>
1212
</div>
1313
<span class="text-xs text-zinc-500 dark:text-zinc-400">
14-
{{ $schedule->scheduled_at->diffForHumans() }} — <time datetime="{{ $schedule->scheduled_at->toW3cString() }}" x-text="timestamp.toLocaleString()"></time>
14+
{{ $schedule->scheduled_at->diffForHumans() }} — <time datetime="{{ $schedule->scheduled_at->toW3cString()}}" x-text="timestamp.toLocaleString(@if($appSettings->timezone !== '-')undefined, {timeZone: '{{$appSettings->timezone}}'}@endif )"></time>
1515
</span>
1616
</div>
1717

@@ -30,7 +30,7 @@
3030
@foreach ($schedule->updates as $update)
3131
<div class="relative py-4" x-data="{ timestamp: new Date(@js($update->created_at)) }">
3232
<span class="text-xs text-zinc-500 dark:text-zinc-400">
33-
{{ $update->created_at->diffForHumans() }} — <time datetime="{{ $update->created_at->toW3cString() }}" x-text="timestamp.toLocaleString()"></time>
33+
{{ $update->created_at->diffForHumans() }} — <time datetime="{{ $update->created_at->toW3cString() }}" x-text="timestamp.toLocaleString(@if($appSettings->timezone !== '-')undefined, {timeZone: '{{$appSettings->timezone}}'}@endif )"></time>
3434
</span>
3535
<div class="prose-sm md:prose prose-zinc dark:prose-invert prose-a:text-accent-content prose-a:underline prose-p:leading-normal">{!! $update->formattedMessage() !!}</div>
3636
</div>

0 commit comments

Comments
 (0)