Skip to content

Commit

Permalink
International application based on laravel
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthWan committed Dec 17, 2024
1 parent c90e4d7 commit fb0b703
Show file tree
Hide file tree
Showing 17 changed files with 296 additions and 31 deletions.
61 changes: 61 additions & 0 deletions lang/en/pulse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

return [
'slow-requests' => [
'name' => 'Slow Requests',
],

'usage' => [
'name' => [
'requests' => 'Top 10 Users Making Requests',
'slow_requests' => 'Top 10 Users Experiencing Slow Endpoints',
'jobs' => 'Top 10 Users Dispatching Jobs',
'default' => 'Application Usage',
],
],

'slow-queries' => [
'name' => 'Slow Queries',
],

'slow-outgoing-requests' => [
'name' => 'Slow Outgoing Requests',
],

'slow-jobs' => [
'name' => 'Slow Jobs',
],

'servers' => [
'memory' => 'Memory',
'cpu' => 'CPU',
'storage' => 'Storage',
],

'queues' => [
'name' => 'Queues',
],

'period-selector' => [
'1h' => '1h',
'6h' => '6h',
'24h' => '24h',
'7d' => '7d',
],

'exceptions' => [
'name' => 'Exceptions',
],

'cache' => [
'name' => 'Cache',
],

'no-results' => 'No results',

'theme' => [
'dark' => 'Dark',
'light' => 'Light',
'system' => 'System',
],
];
61 changes: 61 additions & 0 deletions lang/zh_CN/pulse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

return [
'slow-requests' => [
'name' => '低效请求',
],

'usage' => [
'name' => [
'requests' => 'Top 10 用户请求',
'slow_requests' => 'Top 10 请求缓慢的用户',
'jobs' => 'Top 10 用户调度作业',
'default' => '应用程序使用',
],
],

'slow-queries' => [
'name' => '低效查询',
],

'slow-outgoing-requests' => [
'name' => '请求超时',
],

'slow-jobs' => [
'name' => '低效调度作业',
],

'servers' => [
'memory' => '内存',
'cpu' => 'CPU',
'storage' => '磁盘',
],

'queues' => [
'name' => '队列',
],

'period-selector' => [
'1h' => '1小时',
'6h' => '6小时',
'24h' => '24小时',
'7d' => '7天',
],

'exceptions' => [
'name' => '异常',
],

'cache' => [
'name' => '缓存',
],

'no-results' => '无结果',

'theme' => [
'dark' => '暗色',
'light' => '亮色',
'system' => '跟随',
],
];
61 changes: 61 additions & 0 deletions lang/zh_TW/pulse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

return [
'slow-requests' => [
'name' => '低效請求',
],

'usage' => [
'name' => [
'requests' => 'Top 10 用戶請求',
'slow_requests' => 'Top 10 請求緩慢的用戶',
'jobs' => 'Top 10 用戶調度作業',
'default' => '應用程式使用',
],
],

'slow-queries' => [
'name' => '低效查詢',
],

'slow-outgoing-requests' => [
'name' => '請求超時',
],

'slow-jobs' => [
'name' => '低效調度作業',
],

'servers' => [
'memory' => '记忆体',
'cpu' => 'CPU',
'storage' => '硬碟',
],

'queues' => [
'name' => '伫列',
],

'period-selector' => [
'1h' => '1小時',
'6h' => '6小時',
'24h' => '24小時',
'7d' => '7天',
],

'exceptions' => [
'name' => '例外',
],

'cache' => [
'name' => '快取',
],

'no-results' => '無結果',

'theme' => [
'dark' => '暗色',
'light' => '亮色',
'system' => '跟隨',
],
];
2 changes: 1 addition & 1 deletion resources/views/components/no-results.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div {{ $attributes->merge(['class' => 'h-full flex flex-col items-center justify-center p-4']) }}>
<x-pulse::icons.no-pulse class="h-8 w-8 stroke-gray-300 dark:stroke-gray-700" />
<p class="mt-2 text-sm text-gray-400 dark:text-gray-600">
No results
{{ __('pulse.no-results') }}
</p>
</div>
41 changes: 29 additions & 12 deletions resources/views/components/theme-switcher.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@php use Illuminate\Support\Facades\App; @endphp

<script>
setDarkClass = () => {
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
Expand All @@ -12,6 +14,13 @@
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', setDarkClass)
</script>

<style>
.zh_CN {
white-space: nowrap;
font-size: 12px;
}
</style>

<div
class="relative"
x-data="{
Expand Down Expand Up @@ -41,22 +50,30 @@ class="block p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800"
:class="theme ? 'text-gray-700 dark:text-gray-300' : 'text-gray-400 dark:text-gray-600 hover:text-gray-500 focus:text-gray-500 dark:hover:text-gray-500 dark:focus:text-gray-500'"
@click="menu = ! menu"
>
<x-pulse::icons.sun class="block dark:hidden w-5 h-5" />
<x-pulse::icons.moon class="hidden dark:block w-5 h-5" />
<x-pulse::icons.sun class="block dark:hidden w-5 h-5"/>
<x-pulse::icons.moon class="hidden dark:block w-5 h-5"/>
</button>

<div x-show="menu" class="z-10 absolute origin-top-right right-0 bg-white dark:bg-gray-800 rounded-md ring-1 ring-gray-900/5 shadow-xl flex flex-col" style="display: none;" @click="menu = false">
<button class="flex items-center px-4 py-2 gap-3 hover:bg-gray-100 dark:hover:bg-gray-700" :class="theme === 'light' ? 'text-gray-900 dark:text-gray-100' : 'text-gray-500 dark:text-gray-400'" @click="lightMode()">
<x-pulse::icons.sun class="w-5 h-5" />
Light
<div x-show="menu"
class="{{ App::isLocale('zh_CN') ? 'zh_CN' : '' }} z-10 absolute origin-top-right right-0 bg-white dark:bg-gray-800 rounded-md ring-1 ring-gray-900/5 shadow-xl flex flex-col"
style="display: none;" @click="menu = false">
<button class="flex items-center px-4 py-2 gap-3 hover:bg-gray-100 dark:hover:bg-gray-700"
:class="theme === 'light' ? 'text-gray-900 dark:text-gray-100' : 'text-gray-500 dark:text-gray-400'"
@click="lightMode()">
<x-pulse::icons.sun class="w-5 h-5"/>
{{ __('pulse.theme.light') }}
</button>
<button class="flex items-center px-4 py-2 gap-3 hover:bg-gray-100 dark:hover:bg-gray-700" :class="theme === 'dark' ? 'text-gray-900 dark:text-gray-100' : 'text-gray-500 dark:text-gray-400'" @click="darkMode()">
<x-pulse::icons.moon class="w-5 h-5" />
Dark
<button class="flex items-center px-4 py-2 gap-3 hover:bg-gray-100 dark:hover:bg-gray-700"
:class="theme === 'dark' ? 'text-gray-900 dark:text-gray-100' : 'text-gray-500 dark:text-gray-400'"
@click="darkMode()">
<x-pulse::icons.moon class="w-5 h-5"/>
{{ __('pulse.theme.dark') }}
</button>
<button class="flex items-center px-4 py-2 gap-3 hover:bg-gray-100 dark:hover:bg-gray-700" :class="theme === undefined ? 'text-gray-900 dark:text-gray-100' : 'text-gray-500 dark:text-gray-400'" @click="systemMode()">
<x-pulse::icons.computer-desktop class="w-5 h-5" />
System
<button class="flex items-center px-4 py-2 gap-3 hover:bg-gray-100 dark:hover:bg-gray-700"
:class="theme === undefined ? 'text-gray-900 dark:text-gray-100' : 'text-gray-500 dark:text-gray-400'"
@click="systemMode()">
<x-pulse::icons.computer-desktop class="w-5 h-5"/>
{{ __('pulse.theme.system') }}
</button>
</div>
</div>
2 changes: 1 addition & 1 deletion resources/views/livewire/cache.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use('Illuminate\Support\Str')
<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
<x-pulse::card-header
name="Cache"
name="{{ __('pulse.cache.name') }}"
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 }}')};`"
details="past {{ $this->periodForHumans() }}"
>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/exceptions.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
<x-pulse::card-header
name="Exceptions"
name="{{ __('pulse.exceptions.name') }}"
x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
details="past {{ $this->periodForHumans() }}"
>
Expand Down
8 changes: 4 additions & 4 deletions resources/views/livewire/period-selector.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
}
}"
>
<button @click="setPeriod('1_hour')" class="p-1 font-semibold sm:text-lg {{ $period === '1_hour' ? 'text-gray-700 dark:text-gray-300' : 'text-gray-300 dark:text-gray-600 hover:text-gray-400 dark:hover:text-gray-500'}}">1h</button>
<button @click="setPeriod('6_hours')" class="p-1 font-semibold sm:text-lg {{ $period === '6_hours' ? 'text-gray-700 dark:text-gray-300' : 'text-gray-300 dark:text-gray-600 hover:text-gray-400 dark:hover:text-gray-500'}}">6h</button>
<button @click="setPeriod('24_hours')" class="p-1 font-semibold sm:text-lg {{ $period === '24_hours' ? 'text-gray-700 dark:text-gray-300' : 'text-gray-300 dark:text-gray-600 hover:text-gray-400 dark:hover:text-gray-500'}}">24h</button>
<button @click="setPeriod('7_days')" class="p-1 font-semibold sm:text-lg {{ $period === '7_days' ? 'text-gray-700 dark:text-gray-300' : 'text-gray-300 dark:text-gray-600 hover:text-gray-400 dark:hover:text-gray-500'}}">7d</button>
<button @click="setPeriod('1_hour')" class="p-1 font-semibold sm:text-lg {{ $period === '1_hour' ? 'text-gray-700 dark:text-gray-300' : 'text-gray-300 dark:text-gray-600 hover:text-gray-400 dark:hover:text-gray-500'}}">{{ __('pulse.period-selector.1h') }}</button>
<button @click="setPeriod('6_hours')" class="p-1 font-semibold sm:text-lg {{ $period === '6_hours' ? 'text-gray-700 dark:text-gray-300' : 'text-gray-300 dark:text-gray-600 hover:text-gray-400 dark:hover:text-gray-500'}}">{{ __('pulse.period-selector.6h') }}</button>
<button @click="setPeriod('24_hours')" class="p-1 font-semibold sm:text-lg {{ $period === '24_hours' ? 'text-gray-700 dark:text-gray-300' : 'text-gray-300 dark:text-gray-600 hover:text-gray-400 dark:hover:text-gray-500'}}">{{ __('pulse.period-selector.24h') }}</button>
<button @click="setPeriod('7_days')" class="p-1 font-semibold sm:text-lg {{ $period === '7_days' ? 'text-gray-700 dark:text-gray-300' : 'text-gray-300 dark:text-gray-600 hover:text-gray-400 dark:hover:text-gray-500'}}">{{ __('pulse.period-selector.7d') }}</button>
</div>
2 changes: 1 addition & 1 deletion resources/views/livewire/queues.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use('Illuminate\Support\Str')
<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
<x-pulse::card-header
name="Queues"
name="{{ __('pulse.queues.name') }}"
x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
details="past {{ $this->periodForHumans() }}"
>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/livewire/servers.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class="overflow-x-auto pb-px default:col-span-full default:lg:col-span-{{ $cols
<div class="grid grid-cols-[max-content,minmax(max-content,1fr),max-content,minmax(min-content,2fr),max-content,minmax(min-content,2fr),minmax(max-content,1fr)]">
<div></div>
<div></div>
<div class="text-xs uppercase text-left text-gray-500 dark:text-gray-400 font-bold">CPU</div>
<div class="text-xs uppercase text-left text-gray-500 dark:text-gray-400 font-bold">{{ __('pulse.servers.cpu') }}</div>
<div></div>
<div class="text-xs uppercase text-left text-gray-500 dark:text-gray-400 font-bold">Memory</div>
<div class="text-xs uppercase text-left text-gray-500 dark:text-gray-400 font-bold">{{ __('pulse.servers.memory') }}</div>
<div></div>
<div class="text-xs uppercase text-left text-gray-500 dark:text-gray-400 font-bold">Storage</div>
<div class="text-xs uppercase text-left text-gray-500 dark:text-gray-400 font-bold">{{ __('pulse.servers.storage') }}</div>
@foreach ($servers as $slug => $server)
<div wire:key="{{ $slug }}-indicator" class="flex items-center {{ $servers->count() > 1 ? 'py-2' : '' }}" title="{{ $server->updated_at->fromNow() }}">
@if ($server->recently_reported)
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/slow-jobs.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
<x-pulse::card-header
name="Slow Jobs"
name="{{ __('pulse.slow-jobs.name') }}"
x-bind:title="`Time: {{ number_format($time, 0) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
details="{{ is_array($config['threshold']) ? '' : $config['threshold'].'ms threshold, ' }}past {{ $this->periodForHumans() }}"
>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/slow-outgoing-requests.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use('Illuminate\Support\Str')
<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
<x-pulse::card-header
name="Slow Outgoing Requests"
name="{{ __('pulse.slow-outgoing-requests.name') }}"
x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
details="{{ is_array($config['threshold']) ? '' : $config['threshold'].'ms threshold, ' }}past {{ $this->periodForHumans() }}"
>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/slow-queries.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@endphp
<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
<x-pulse::card-header
name="Slow Queries"
name="{{ __('pulse.slow-queries.name') }}"
x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
details="{{ is_array($config['threshold']) ? '' : $config['threshold'].'ms threshold, ' }}past {{ $this->periodForHumans() }}"
>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/slow-requests.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
<x-pulse::card-header
name="Slow Requests"
name="{{ __('pulse.slow-requests.name') }}"
x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
details="{{ is_array($config['threshold']) ? '' : $config['threshold'].'ms threshold, ' }}past {{ $this->periodForHumans() }}"
>
Expand Down
8 changes: 4 additions & 4 deletions resources/views/livewire/usage.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
<x-pulse::card-header
:name="match ($this->type) {
'requests' => 'Top 10 Users Making Requests',
'slow_requests' => 'Top 10 Users Experiencing Slow Endpoints',
'jobs' => 'Top 10 Users Dispatching Jobs',
default => 'Application Usage'
'requests' => __('pulse.usage.name.requests'),
'slow_requests' => __('pulse.usage.name.slow_requests'),
'jobs' => __('pulse.usage.name.jobs'),
default => __('pulse.usage.name.default')
}"
x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
details="{{ $this->usage === 'slow_requests' ? (is_array($slowRequestsConfig['threshold']) ? '' : $slowRequestsConfig['threshold'].'ms threshold, ') : '' }}past {{ $this->periodForHumans() }}"
Expand Down
Loading

0 comments on commit fb0b703

Please sign in to comment.