Skip to content

A self-hosted media server and file management system

push all code

aminnausin7e384b0ba8fd
diff --git a/database/migrations/2024_12_19_011334_add_created_at_to_categories_videos_folders.php b/database/migrations/2024_12_19_011334_add_created_at_to_categories_videos_folders.php
new file mode 100644
index 00000000..74477c60
--- /dev/null
+++ b/database/migrations/2024_12_19_011334_add_created_at_to_categories_videos_folders.php
@@ -0,0 +1,45 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up() {
+ Schema::table('categories', function (Blueprint $table) {
+ $table->timestamp('created_at')->useCurrent()->nullable();
+ });
+
+ Schema::table('videos', function (Blueprint $table) {
+ $table->timestamp('created_at')->useCurrent()->nullable();
+ });
+
+ Schema::table('folders', function (Blueprint $table) {
+ $table->timestamp('created_at')->useCurrent()->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down() {
+ Schema::table('categories', function (Blueprint $table) {
+ $table->dropColumn('created_at');
+ });
+
+ Schema::table('videos', function (Blueprint $table) {
+ $table->dropColumn('created_at');
+ });
+
+ Schema::table('folders', function (Blueprint $table) {
+ $table->dropColumn('created_at');
+ });
+ }
+};
diff --git a/resources/js/components/pulse/Pulse.vue b/resources/js/components/pulse/Pulse.vue
new file mode 100644
index 00000000..10110098
--- /dev/null
+++ b/resources/js/components/pulse/Pulse.vue
@@ -0,0 +1,54 @@
+@use('Laravel\Pulse\Facades\Pulse')
+@props(['cols' => 12, 'fullWidth' => false])
+<!DOCTYPE html>
+<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+
+ <title inertia>Laravel Pulse</title>
+
+ <!-- Fonts -->
+ <link rel="preconnect" href="https://fonts.bunny.net">
+ <link href="https://fonts.bunny.net/css?family=figtree:300,400,500,600" rel="stylesheet" />
+ <link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACQFBMVEUAAAD6WlXyWmb2Wl77WlXxWmPqWmzpWmzdWnvhWnfjWnXUWojaWoDTWonMWpHLWpLAWqDCWp7CWp3DWp23Wqu7Wqe6WqisWrm2Wq2xWrPsWWalWsKsWrqkWsSGWumDWu2BWu97Wvd7WvZ6Wvh8WvZ5Wvn4Wlr4WlrxWmPyWmHyWmHwWmTpWm3qWmzqWmzpWm3gWnjhWnjgWnjRWovXWoTXWoTMWpHNWpDNWpDLWpPAWqDBWp/AWqDDWpzEWpvEWpvEWpvDWp23Wqy6Wqi6Wqi6Wqi7Wqe7Wqe6Wqe6WqiwWrWxWrOxWrSrWruxWrSyWrKxWrOwWrSlWsOnWsCnWr+mWsGnWr+oWr6oWr+nWsCaWtCaWtCaWs+aWtCdWs2fWsqeWsqeWsudWsyeWsueWsufWsmfWsqeWsucWs6aWtCaWs+aWtCZWtGUWteVWteXWtSVWtaUWteUWteVWteXWtSVWtaVWteUWteSWtqUWtiUWteUWtePWt6OWt+OWt+OWt+OWt+XWtSMWuKLWuOLWuKMWuGLWuOLWuOKWuSLWuOLWuKNWuCOWt+QWt2DWu2CWu+CWu6EWuuCWu6BWu+BWu+DWu17WvZ7Wvd7Wvd7Wvd7Wvd7Wvd8WvZ6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6Wvh6WvjhWnfXWoPNWo/EWpu7Wqe6WqexWrOnWr+oWr+eWsuUWteLWuOBWu97Wvd6Wvj///+vWn4hAAAAsHRSTlMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4NFbGpEEL28DVy/l0CpYoU0bUHM3EaNe/+2RoTwHNi0+PzOWz8sQWVj7VhI9beLsJTiI4xZWhmpsvY+Xjk6iZcuQcnaVIMt/JNk9j8xgs289wtuO9ESIeKi2ADWvyXGdjzn/jgjnEVKeZkBrP6/XEKvPA2iMgXgtIVW/74XDrVhwImyqMOGAsBFqm/VNAAAAABYktHRL/T27NVAAAAB3RJTUUH5wsQDgkSyLkAHwAAASpJREFUOMtjYBh2gJFJTZ2ZBY8CVg1NLW1WPArYdHT19Nlxy3NwGmwwNOLkwqmA29hk40ZTHl6cCvjMzDdtsrDkxyYnIGhlbSNka2e/2cFRGJsCESfnLS6irlvd3D08xbDIi0t4eW/z8fXb5h+wLVBSClOBdFDw9u0hoWE7wiO2R8rIoshFRcfExMTG7YxPSExKTklN25mekQkSAoOs7ByG3F1gkJdfsKuwqLiktKy8onIXHFRVM9TU1gFBfUNjU/Pu3S1yrW3tHZ1d3XUQUN/TC7dKvq9/z54JChMn7Zk8ZaqiHKY7laZN3ztjpqLyrL17Z89RweJTVeW5++bNV1ZesHDRYmVVbGGlvGTpsuXKyitWrlqtjDUmlJevWausrLxu/Wpl7ApGNgAAUsxoMcT6INsAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjMtMTEtMTZUMTQ6MDk6MTgrMDA6MDANsDzYAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIzLTExLTE2VDE0OjA5OjE4KzAwOjAwfO2EZAAAAFd6VFh0UmF3IHByb2ZpbGUgdHlwZSBpcHRjAAB4nOPyDAhxVigoyk/LzEnlUgADIwsuYwsTIxNLkxQDEyBEgDTDZAMjs1Qgy9jUyMTMxBzEB8uASKBKLgDqFxF08kI1lQAAAABJRU5ErkJggg==" rel="icon" type="image/x-icon">
+
+ {!! Pulse::css() !!}
+ @livewireStyles
+
+ {!! Pulse::js() !!}
+ @livewireScriptConfig
+ </head>
+ <body class="font-sans antialiased">
+ <div class="bg-gray-50 dark:bg-gray-950 min-h-screen">
+ <header class="px-5">
+ <div class="{{ $fullWidth ? '' : 'container' }} py-3 sm:py-5 mx-auto border-b border-gray-200 dark:border-gray-900">
+ <div class="flex items-center justify-between">
+ <div class="flex items-center">
+ <svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15.4566 6.75005C15.9683 6.75596 16.4047 7.09621 16.5001 7.56364L18.8747 19.2038L19.999 17.1682C20.1832 16.8347 20.5526 16.625 20.9559 16.625H31.1744C31.7684 16.625 32.25 17.0727 32.25 17.625C32.25 18.1773 31.7684 18.625 31.1744 18.625H21.6127L19.3581 22.7068C19.1483 23.0867 18.7021 23.3008 18.2475 23.2397C17.7928 23.1786 17.4301 22.8559 17.3445 22.4363L15.376 12.7868L13.1334 22.4607C13.0282 22.9146 12.6007 23.2414 12.1013 23.2498C11.6019 23.2582 11.162 22.9458 11.0393 22.4957L9.30552 16.1378L8.19223 18.0929C8.00581 18.4202 7.64002 18.625 7.2416 18.625H1.32563C0.731576 18.625 0.25 18.1773 0.25 17.625C0.25 17.0727 0.731576 16.625 1.32563 16.625H6.59398L8.71114 12.9071C8.9193 12.5415 9.34805 12.3328 9.78979 12.3821C10.2315 12.4313 10.5951 12.7283 10.7044 13.1292L11.9971 17.8695L14.3918 7.53929C14.4996 7.07421 14.9449 6.74414 15.4566 6.75005Z" fill="url(#paint0_linear_4_31)"/>
+ <defs>
+ <linearGradient id="paint0_linear_4_31" x1="16.25" y1="6.74997" x2="16.25" y2="23.25" gradientUnits="userSpaceOnUse">
+ <stop stop-color="#F85A5A"/>
+ <stop offset="0.828125" stop-color="#7A5AF8"/>
+ </linearGradient>
+ </defs>
+ </svg>
+ <span class="ml-2 text-lg sm:text-2xl text-gray-700 dark:text-gray-300 font-medium"><b class="font-bold">Laravel</b> Pulse</span>
+ </div>
+ <div class="flex items-center gap-3 sm:gap-6">
+ <livewire:pulse.period-selector />
+ <x-pulse::theme-switcher />
+ </div>
+ </div>
+ </div>
+ </header>
+
+ <main class="pt-6 px-6 pb-12">
+ <div {{ $attributes->merge(['class' => "mx-auto grid default:grid-cols-{$cols} default:gap-6" . ($fullWidth ? '' : ' container')]) }}>
+ {{ $slot }}
+ </div>
+ </main>
+ </div>
+ </body>
+</html>
diff --git a/resources/js/components/pulse/PulseCard.vue b/resources/js/components/pulse/PulseCard.vue
new file mode 100644
index 00000000..4e7d4a3b
--- /dev/null
+++ b/resources/js/components/pulse/PulseCard.vue
@@ -0,0 +1,11 @@
+<script setup lang="ts">
+const props = defineProps<{ cols?: number; rows?: number }>();
+</script>
+<template>
+ <!-- @props(['cols' => 6, 'rows' => 1]) -->
+ <section
+ :class="`flex flex-col p-3 sm:p-6 bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 rounded-xl shadow-sm ring-1 ring-gray-900/5 default:col-span-full default:lg:col-span-${props.cols ?? 6} default:row-span-${props.rows ?? 1}`"
+ >
+ <slot mame="slot"></slot>
+ </section>
+</template>
diff --git a/resources/js/components/pulse/PulseCardHeader.vue b/resources/js/components/pulse/PulseCardHeader.vue
new file mode 100644
index 00000000..465c99b5
--- /dev/null
+++ b/resources/js/components/pulse/PulseCardHeader.vue
@@ -0,0 +1,34 @@
+<script setup lang="ts">
+const props = defineProps<{ name?: string; title?: string; details?: string }>();
+</script>
+
+<template>
+ <!-- @props(['name' => '', 'title' => '', 'details' => null]) -->
+ <header class="flex flex-wrap justify-between items-center gap-4 mb-3 @md:mb-6">
+ <div class="flex-1 basis-0 flex-grow-[10000] max-w-full">
+ <div class="flex overflow-hidden gap-2 items-start">
+ <div class="[&>svg]:flex-shrink-0 [&>svg]:w-6 [&>svg]:h-6 [&>svg]:stroke-gray-400 [&>svg]:dark:stroke-gray-600">
+ <slot name="icon"></slot>
+ </div>
+ <hgroup class="flex flex-wrap items-baseline gap-x-2 overflow-hidden">
+ <!-- <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> -->
+ <h2 class="text-base font-bold text-gray-600 dark:text-gray-300 truncate" :title="props.title">
+ {{ props.name }}
+ </h2>
+ <p v-if="props.details" class="text-gray-400 dark:text-gray-600 font-medium truncate">
+ <small class="text-xs">{{ props.details }}</small>
+ </p>
+ </hgroup>
+ </div>
+ </div>
+ <!-- @if ($actions ?? false) -->
+ <div class="flex flex-grow">
+ <div class="w-full flex items-center gap-4">
+ <!-- {{ $actions }} -->
+ <slot name="actions"></slot>
+ </div>
+ </div>
+ <!-- @endif -->
+ </header>
+</template>
diff --git a/resources/js/components/pulse/PulseHttpMethod-Badge.vue b/resources/js/components/pulse/PulseHttpMethod-Badge.vue
new file mode 100644
index 00000000..7d80674e
--- /dev/null
+++ b/resources/js/components/pulse/PulseHttpMethod-Badge.vue
@@ -0,0 +1,24 @@
+<script setup lang="ts">
+const props = defineProps<{ method?: string }>();
+const colorClasses = getClasses();
+
+function getClasses() {
+ switch (props.method) {
+ case 'GET':
+ case 'OPTIONS':
+ return 'text-purple-400 dark:text-purple-300 bg-purple-50 dark:bg-purple-900 border-purple-200 dark:border-purple-700';
+ case 'POST':
+ case 'PUT':
+ case 'PATCH':
+ return 'text-blue-400 dark:text-blue-300 bg-blue-50 dark:bg-blue-900 border-blue-200 dark:border-blue-700';
+ case 'DELETE':
+ return 'text-red-400 dark:text-red-300 bg-red-50 dark:bg-red-900 border-red-200 dark:border-red-700';
+ default:
+ return 'text-gray-400 dark:text-gray-100 bg-gray-50 dark:bg-gray-700 border-gray-200 dark:border-gray-500';
+ }
+}
+</script>
+
+<template>
+ <span :class="`text-xs font-mono px-1 border rounded font-semibold ${colorClasses}`">{{ props.method }}</span>
+</template>
diff --git a/resources/js/components/pulse/PulseNoResults.vue b/resources/js/components/pulse/PulseNoResults.vue
new file mode 100644
index 00000000..44273e14
--- /dev/null
+++ b/resources/js/components/pulse/PulseNoResults.vue
@@ -0,0 +1,10 @@
+<script setup lang="ts">
+import IconNoPulse from '@/components/icons/IconNoPulse.vue';
+</script>
+
+<template>
+ <div class="h-full flex flex-col items-center justify-center p-4">
+ <IconNoPulse 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</p>
+ </div>
+</template>
diff --git a/resources/js/components/pulse/PulsePlaceholder.vue b/resources/js/components/pulse/PulsePlaceholder.vue
new file mode 100644
index 00000000..9226bc33
--- /dev/null
+++ b/resources/js/components/pulse/PulsePlaceholder.vue
@@ -0,0 +1,26 @@
+<script setup lang="ts">
+import PulseCard from './PulseCard.vue';
+</script>
+
+<x-pulse::card :cols="$cols ?? null" :rows="$rows ?? null" :class="$class ?? ''">
+ <div class="h-[30px] flex items-center w-full mb-3 @md:mb-6">
+ <div class="rounded bg-gray-50 dark:bg-gray-800 h-6 w-1/2 animate-pulse"></div>
+ </div>
+ <div class="space-y-4 h-56">
+ <div class="rounded bg-gray-50 dark:bg-gray-800 h-12 animate-pulse"></div>
+ <div class="rounded bg-gray-50 dark:bg-gray-800 h-12 animate-pulse"></div>
+ <div class="rounded bg-gray-50 dark:bg-gray-800 h-12 animate-pulse"></div>
+ </div>
+</x-pulse::card>
+<template>
+ <PulseCard>
+ <div class="h-[30px] flex items-center w-full mb-3 @md:mb-6">
+ <div class="rounded bg-gray-50 dark:bg-gray-800 h-6 w-1/2 animate-pulse"></div>
+ </div>
+ <div class="space-y-4 h-56">
+ <div class="rounded bg-gray-50 dark:bg-gray-800 h-12 animate-pulse"></div>
+ <div class="rounded bg-gray-50 dark:bg-gray-800 h-12 animate-pulse"></div>
+ <div class="rounded bg-gray-50 dark:bg-gray-800 h-12 animate-pulse"></div>
+ </div>
+ </PulseCard>
+</template>
diff --git a/resources/js/components/pulse/PulseScroll.vue b/resources/js/components/pulse/PulseScroll.vue
new file mode 100644
index 00000000..98bb5145
--- /dev/null
+++ b/resources/js/components/pulse/PulseScroll.vue
@@ -0,0 +1,29 @@
+@props(['expand' => false])
+<div
+ x-data="{
+ init() {
+ $nextTick(() => this.scroll())
+ },
+ scroll() {
+ const { content, fade } = this.$refs
+
+ if (! fade) {
+ return
+ }
+
+ const distanceToBottom = content.scrollHeight - (content.scrollTop + content.clientHeight)
+
+ if (distanceToBottom >= 24) {
+ fade.style.transform = `scaleY(1)`
+ } else {
+ fade.style.transform = `scaleY(${distanceToBottom / 24})`
+ }
+ }
+ }"
+ {{ $attributes->merge(['class' => '@container/scroll-wrapper flex-grow flex w-full overflow-hidden' . ($expand ? '' : ' basis-56'), ':class' => "loading && 'opacity-25 animate-pulse'"]) }}
+>
+ <div x-ref="content" class="flex-grow basis-full overflow-y-auto scrollbar:w-1.5 scrollbar:h-1.5 scrollbar:bg-transparent scrollbar-track:bg-gray-100 scrollbar-thumb:rounded scrollbar-thumb:bg-gray-300 scrollbar-track:rounded dark:scrollbar-track:bg-gray-500/10 dark:scrollbar-thumb:bg-gray-500/50 supports-scrollbars" @scroll.debounce.5ms="scroll">
+ {{ $slot }}
+ <div x-ref="fade" class="h-6 origin-bottom fixed bottom-0 left-0 right-0 bg-gradient-to-t from-white dark:from-gray-900 pointer-events-none" wire:ignore></div>
+ </div>
+</div>
diff --git a/resources/js/components/pulse/PulseSelect.vue b/resources/js/components/pulse/PulseSelect.vue
new file mode 100644
index 00000000..e5bc2eb3
--- /dev/null
+++ b/resources/js/components/pulse/PulseSelect.vue
@@ -0,0 +1,19 @@
+@use('Illuminate\Support\Str')
+@props([
+ 'id' => 'select-'.Str::random(),
+ 'label',
+ 'options',
+])
+<div {{ $attributes->only('class')->merge(['class' => 'flex border border-gray-200 dark:border-gray-700 overflow-hidden rounded-md focus-within:ring']) }}>
+ <label
+ for="{{ $id }}" class="px-3 flex items-center border-r border-gray-200 dark:border-gray-700 text-xs sm:text-sm text-gray-600 dark:text-gray-300 whitespace-nowrap bg-gray-100 dark:bg-gray-800/50">{{ $label }}</label>
+ <select
+ id="{{ $id }}"
+ {{ $attributes->except('class') }}
+ class="overflow-ellipsis w-full border-0 pl-3 pr-8 py-1 bg-gray-50 dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-xs sm:text-sm shadow-none focus:ring-0"
+ >
+ @foreach ($options as $value => $label)
+ <option value="{{ $value }}">{{ $label }}</option>
+ @endforeach
+ </select>
+</div>
diff --git a/resources/js/components/pulse/PulseServersPlaceholder.vue b/resources/js/components/pulse/PulseServersPlaceholder.vue
new file mode 100644
index 00000000..b5084482
--- /dev/null
+++ b/resources/js/components/pulse/PulseServersPlaceholder.vue
@@ -0,0 +1,10 @@
+@php
+$cols = ! empty($cols) ? $cols : 'full';
+$rows = ! empty($rows) ? $rows : 1;
+@endphp
+<section class="h-[52px] flex items-center justify-between default:col-span-full default:lg:col-span-{{ $cols }} default:row-span-{{ $rows }} {{ $class ?? '' }}">
+ <div class="mt-4 h-8 w-1/12 bg-gray-100 dark:bg-gray-900 rounded animate-pulse"></div>
+ <div class="mt-4 h-8 w-3/12 bg-gray-100 dark:bg-gray-900 rounded animate-pulse"></div>
+ <div class="mt-4 h-8 w-3/12 bg-gray-100 dark:bg-gray-900 rounded animate-pulse"></div>
+ <div class="mt-4 h-8 w-2/12 bg-gray-100 dark:bg-gray-900 rounded animate-pulse"></div>
+</section>
diff --git a/resources/js/components/pulse/PulseTable.vue b/resources/js/components/pulse/PulseTable.vue
new file mode 100644
index 00000000..a313d358
--- /dev/null
+++ b/resources/js/components/pulse/PulseTable.vue
@@ -0,0 +1,3 @@
+<table {{ $attributes->merge(['class' => 'w-full']) }}>
+ {{ $slot }}
+</table>
diff --git a/resources/js/components/pulse/PulseTd.vue b/resources/js/components/pulse/PulseTd.vue
new file mode 100644
index 00000000..5337b2c2
--- /dev/null
+++ b/resources/js/components/pulse/PulseTd.vue
@@ -0,0 +1,4 @@
+@props(['numeric' => false])
+<td {{ $attributes->merge(['class' => 'first:rounded-l-md last:rounded-r-md text-sm bg-gray-50 dark:bg-gray-800/50 first:pl-3 last:pr-3 px-1 @sm:px-3 py-3' . ($numeric ? ' text-right tabular-nums whitespace-nowrap' : '')]) }}>
+ {{ $slot }}
+</td>
diff --git a/resources/js/components/pulse/PulseTh.vue b/resources/js/components/pulse/PulseTh.vue
new file mode 100644
index 00000000..4671c303
--- /dev/null
+++ b/resources/js/components/pulse/PulseTh.vue
@@ -0,0 +1,3 @@
+<th {{ $attributes->merge(['class' => 'text-xs text-gray-500 uppercase py-2 first:pl-3 last:pr-3 px-1 @sm:px-3 default:text-left']) }}>
+ {{ $slot }}
+</th>
diff --git a/resources/js/components/pulse/PulseThead.vue b/resources/js/components/pulse/PulseThead.vue
new file mode 100644
index 00000000..44088b71
--- /dev/null
+++ b/resources/js/components/pulse/PulseThead.vue
@@ -0,0 +1,3 @@
+<thead class="sticky z-10 top-0 bg-white dark:bg-gray-900">
+ {{ $slot }}
+</thead>
diff --git a/resources/js/components/pulse/PulseThemeSwitcher.vue b/resources/js/components/pulse/PulseThemeSwitcher.vue
new file mode 100644
index 00000000..ab09b805
--- /dev/null
+++ b/resources/js/components/pulse/PulseThemeSwitcher.vue
@@ -0,0 +1,62 @@
+<script>
+setDarkClass = () => {
+ if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
+ document.documentElement.classList.add('dark')
+ } else {
+ document.documentElement.classList.remove('dark')
+ }
+}
+
+setDarkClass()
+
+window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', setDarkClass)
+</script>
+
+<div
+ class="relative"
+ x-data="{
+ menu: false,
+ theme: localStorage.theme,
+ darkMode() {
+ this.theme = 'dark'
+ localStorage.theme = 'dark'
+ setDarkClass()
+ },
+ lightMode() {
+ this.theme = 'light'
+ localStorage.theme = 'light'
+ setDarkClass()
+ },
+ systemMode() {
+ this.theme = undefined
+ localStorage.removeItem('theme')
+ setDarkClass()
+ },
+ }"
+ @click.outside="menu = false"
+>
+ <button
+ x-cloak
+ 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" />
+ </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
+ </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>
+ <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>
+ </div>
+</div>
diff --git a/resources/js/components/pulse/PulseUserCard.vue b/resources/js/components/pulse/PulseUserCard.vue
new file mode 100644
index 00000000..449dbebd
--- /dev/null
+++ b/resources/js/components/pulse/PulseUserCard.vue
@@ -0,0 +1,58 @@
+<script setup lang="ts">
+const props = defineProps<{ user?: any; name?: any; extra?: any; avatar?: any; stats?: any }>();
+</script>
+<template>
+ <div class="flex items-center justify-between p-3 gap-3 bg-gray-50 dark:bg-gray-800/50 rounded">
+ <div class="flex items-center gap-3 overflow-hidden">
+ <img
+ v-if="props.user.avatar ?? false"
+ src="props.user.avatar"
+ :alt="props.user.name"
+ loading="lazy"
+ class="rounded-full w-8 h-8 object-cover"
+ />
+
+ <div class="overflow-hidden">
+ <div class="text-sm text-gray-900 dark:text-gray-100 font-medium truncate" title="{{ $user->name ?? $name }}">
+ {{ user.name ?? name }}
+ </div>
+
+ <div class="text-xs text-gray-500 dark:text-gray-400 truncate" title="{{ $user->name ?? $extra }}">
+ {{ user.extra ?? extra }}
+ </div>
+ </div>
+ </div>
+
+ <div v-if="props.stats" class="text-xl text-gray-900 dark:text-gray-100 font-bold tabular-nums">
+ {{ props.stats }}
+ </div>
+ </div>
+</template>
+
+<!-- @props(['user' => null, 'name' => null, 'extra' => null, 'avatar' => null, 'stats' => null])
+
+<div {{ $attributes->merge(['class' => 'flex items-center justify-between p-3 gap-3 bg-gray-50 dark:bg-gray-800/50 rounded']) }}>
+ <div class="flex items-center gap-3 overflow-hidden">
+ @if (isset($avatar))
+ {{ $avatar }}
+ @elseif ($user->avatar ?? false)
+ <img src="{{ $user->avatar }}" alt="{{ $user->name }}" loading="lazy" class="rounded-full w-8 h-8 object-cover">
+ @endif
+
+ <div class="overflow-hidden">
+ <div class="text-sm text-gray-900 dark:text-gray-100 font-medium truncate" title="{{ $user->name ?? $name }}">
+ {{ $user->name ?? $name }}
+ </div>
+
+ <div class="text-xs text-gray-500 dark:text-gray-400 truncate" title="{{ $user->name ?? $extra }}">
+ {{ $user->extra ?? $extra }}
+ </div>
+ </div>
+ </div>
+
+ @if (isset($stats))
+ <div class="text-xl text-gray-900 dark:text-gray-100 font-bold tabular-nums">
+ {{ $stats }}
+ </div>
+ @endif
+</div> -->
diff --git a/resources/js/components/pulseCards/PulseQueues.vue b/resources/js/components/pulseCards/PulseQueues.vue
new file mode 100644
index 00000000..69b40067
--- /dev/null
+++ b/resources/js/components/pulseCards/PulseQueues.vue
@@ -0,0 +1,209 @@
+@use('Illuminate\Support\Str')
+<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
+ <x-pulse::card-header
+ name="Queues"
+ x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
+ details="past {{ $this->periodForHumans() }}"
+ >
+ <x-slot:icon>
+ <x-pulse::icons.queue-list />
+ </x-slot:icon>
+ <x-slot:actions>
+ <div class="flex flex-wrap gap-4">
+ <div class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div class="h-0.5 w-3 rounded-full bg-[rgba(107,114,128,0.5)]"></div>
+ Queued
+ </div>
+ <div class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div class="h-0.5 w-3 rounded-full bg-[rgba(147,51,234,0.5)]"></div>
+ Processing
+ </div>
+ <div class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div class="h-0.5 w-3 rounded-full bg-[#9333ea]"></div>
+ Processed
+ </div>
+ <div class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div class="h-0.5 w-3 rounded-full bg-[#eab308]"></div>
+ Released
+ </div>
+ <div class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div class="h-0.5 w-3 rounded-full bg-[#e11d48]"></div>
+ Failed
+ </div>
+ </div>
+ </x-slot:actions>
+ </x-pulse::card-header>
+
+ <x-pulse::scroll :expand="$expand" wire:poll.5s="">
+ @if ($queues->isEmpty())
+ <x-pulse::no-results />
+ @else
+ <div class="grid gap-3 mx-px mb-px">
+ @foreach ($queues as $queue => $readings)
+ <div wire:key="{{ $queue }}">
+ <h3 class="font-bold text-gray-700 dark:text-gray-300">
+ @if ($showConnection)
+ {{ $queue }}
+ @else
+ {{ Str::after($queue, ':') }}
+ @endif
+ </h3>
+ @php
+ $highest = $readings->flatten()->max();
+ @endphp
+
+ <div class="mt-3 relative">
+ <div class="absolute -left-px -top-2 max-w-fit h-4 flex items-center px-1 text-xs leading-none text-white font-bold bg-purple-500 rounded after:[--triangle-size:4px] after:border-l-purple-500 after:absolute after:right-[calc(-1*var(--triangle-size))] after:top-[calc(50%-var(--triangle-size))] after:border-t-[length:var(--triangle-size)] after:border-b-[length:var(--triangle-size)] after:border-l-[length:var(--triangle-size)] after:border-transparent">
+ @if ($config['sample_rate'] < 1)
+ <span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($highest) }}">~{{ number_format($highest * (1 / $config['sample_rate'])) }}</span>
+ @else
+ {{ number_format($highest) }}
+ @endif
+ </div>
+
+ <div
+ wire:ignore
+ class="h-14"
+ x-data="queueChart({
+ queue: '{{ $queue }}',
+ readings: @js($readings),
+ sampleRate: {{ $config['sample_rate'] }},
+ })"
+ >
+ <canvas x-ref="canvas" class="ring-1 ring-gray-900/5 dark:ring-gray-100/10 bg-gray-50 dark:bg-gray-800 rounded-md shadow-sm"></canvas>
+ </div>
+ </div>
+ </div>
+ @endforeach
+ </div>
+ @endif
+ </x-pulse::scroll>
+</x-pulse::card>
+
+@script
+<script>
+Alpine.data('queueChart', (config) => ({
+ init() {
+ let chart = new Chart(
+ this.$refs.canvas,
+ {
+ type: 'line',
+ data: {
+ labels: this.labels(config.readings),
+ datasets: [
+ {
+ label: 'Queued',
+ borderColor: 'rgba(107,114,128,0.5)',
+ data: this.scale(config.readings.queued),
+ order: 4,
+ },
+ {
+ label: 'Processing',
+ borderColor: 'rgba(147,51,234,0.5)',
+ data: this.scale(config.readings.processing),
+ order: 3,
+ },
+ {
+ label: 'Released',
+ borderColor: '#eab308',
+ data: this.scale(config.readings.released),
+ order: 2,
+ },
+ {
+ label: 'Processed',
+ borderColor: '#9333ea',
+ data: this.scale(config.readings.processed),
+ order: 1,
+ },
+ {
+ label: 'Failed',
+ borderColor: '#e11d48',
+ data: this.scale(config.readings.failed),
+ order: 0,
+ },
+ ],
+ },
+ options: {
+ maintainAspectRatio: false,
+ layout: {
+ autoPadding: false,
+ padding: {
+ top: 1,
+ },
+ },
+ datasets: {
+ line: {
+ borderWidth: 2,
+ borderCapStyle: 'round',
+ pointHitRadius: 10,
+ pointStyle: false,
+ tension: 0.2,
+ spanGaps: false,
+ segment: {
+ borderColor: (ctx) => ctx.p0.raw === 0 && ctx.p1.raw === 0 ? 'transparent' : undefined,
+ }
+ }
+ },
+ scales: {
+ x: {
+ display: false,
+ },
+ y: {
+ display: false,
+ min: 0,
+ max: this.highest(config.readings),
+ },
+ },
+ plugins: {
+ legend: {
+ display: false,
+ },
+ tooltip: {
+ mode: 'index',
+ position: 'nearest',
+ intersect: false,
+ callbacks: {
+ beforeBody: (context) => context
+ .map(item => `${item.dataset.label}: ${config.sampleRate < 1 ? '~' : ''}${item.formattedValue}`)
+ .join(', '),
+ label: () => null,
+ },
+ },
+ },
+ },
+ }
+ )
+
+ Livewire.on('queues-chart-update', ({ queues }) => {
+ if (chart === undefined) {
+ return
+ }
+
+ if (queues[config.queue] === undefined && chart) {
+ chart.destroy()
+ chart = undefined
+ return
+ }
+
+ chart.data.labels = this.labels(queues[config.queue])
+ chart.options.scales.y.max = this.highest(queues[config.queue])
+ chart.data.datasets[0].data = this.scale(queues[config.queue].queued)
+ chart.data.datasets[1].data = this.scale(queues[config.queue].processing)
+ chart.data.datasets[2].data = this.scale(queues[config.queue].released)
+ chart.data.datasets[3].data = this.scale(queues[config.queue].processed)
+ chart.data.datasets[4].data = this.scale(queues[config.queue].failed)
+ chart.update()
+ })
+ },
+ labels(readings) {
+ return Object.keys(readings.queued).map(formatDate)
+ },
+ scale(data) {
+ return Object.values(data).map(value => value * (1 / config.sampleRate ))
+ },
+ highest(readings) {
+ return Math.max(...Object.values(readings).map(dataset => Math.max(...Object.values(dataset)))) * (1 / config.sampleRate)
+ }
+}))
+</script>
+@endscript
diff --git a/resources/js/components/pulseCards/cache.blade.php b/resources/js/components/pulseCards/cache.blade.php
new file mode 100644
index 00000000..1e7b288d
--- /dev/null
+++ b/resources/js/components/pulseCards/cache.blade.php
@@ -0,0 +1,120 @@
+@use('Illuminate\Support\Str')
+<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
+ <x-pulse::card-header
+ name="Cache"
+ 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() }}"
+ >
+ <x-slot:icon>
+ <x-pulse::icons.rocket-launch />
+ </x-slot:icon>
+ <x-slot:actions>
+ @php
+ $count = count($config['groups']);
+ $message = sprintf(
+ "Keys may be normalized using groups.\n\nThere %s currently %d %s configured.",
+ $count === 1 ? 'is' : 'are',
+ $count,
+ Str::plural('group', $count)
+ );
+ @endphp
+ <button title="{{ $message }}" @click="alert(@js($message))">
+ <x-pulse::icons.information-circle class="w-5 h-5 stroke-gray-400 dark:stroke-gray-600" />
+ </button>
+ </x-slot:actions>
+ </x-pulse::card-header>
+
+ <x-pulse::scroll :expand="$expand" wire:poll.5s="">
+ @if ($allCacheInteractions->hits === 0 && $allCacheInteractions->misses === 0)
+ <x-pulse::no-results />
+ @else
+ <div class="flex flex-col gap-6">
+ <div class="grid grid-cols-3 gap-3 text-center">
+ <div class="flex flex-col justify-center @sm:block">
+ <span class="text-xl uppercase font-bold text-gray-700 dark:text-gray-300 tabular-nums">
+ @if ($config['sample_rate'] < 1)
+ <span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($allCacheInteractions->hits) }}">~{{ number_format($allCacheInteractions->hits * (1 / $config['sample_rate'])) }}</span>
+ @else
+ {{ number_format($allCacheInteractions->hits) }}
+ @endif
+ </span>
+ <span class="text-xs uppercase font-bold text-gray-500 dark:text-gray-400">
+ Hits
+ </span>
+ </div>
+ <div class="flex flex-col justify-center @sm:block">
+ <span class="text-xl uppercase font-bold text-gray-700 dark:text-gray-300 tabular-nums">
+ @if ($config['sample_rate'] < 1)
+ <span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($allCacheInteractions->misses) }}">~{{ number_format(($allCacheInteractions->misses) * (1 / $config['sample_rate'])) }}</span>
+ @else
+ {{ number_format($allCacheInteractions->misses) }}
+ @endif
+ </span>
+ <span class="text-xs uppercase font-bold text-gray-500 dark:text-gray-400">
+ Misses
+ </span>
+ </div>
+ <div class="flex flex-col justify-center @sm:block">
+ <span class="text-xl uppercase font-bold text-gray-700 dark:text-gray-300 tabular-nums">
+ {{ ((int) ($allCacheInteractions->hits / ($allCacheInteractions->hits + $allCacheInteractions->misses) * 10000)) / 100 }}%
+ </span>
+ <span class="text-xs uppercase font-bold text-gray-500 dark:text-gray-400">
+ Hit Rate
+ </span>
+ </div>
+ </div>
+ <div>
+ <x-pulse::table>
+ <colgroup>
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <x-pulse::thead>
+ <tr>
+ <x-pulse::th>Key</x-pulse::th>
+ <x-pulse::th class="text-right">Hits</x-pulse::th>
+ <x-pulse::th class="text-right">Misses</x-pulse::th>
+ <x-pulse::th class="text-right whitespace-nowrap">Hit Rate</x-pulse::th>
+ </tr>
+ </x-pulse::thead>
+ <tbody>
+ @foreach ($cacheKeyInteractions->take(100) as $interaction)
+ <tr wire:key="{{ $interaction->key }}-spacer" class="h-2 first:h-0"></tr>
+ <tr wire:key="{{ $interaction->key }}-row">
+ <x-pulse::td class="max-w-[1px]">
+ <code class="block text-xs text-gray-900 dark:text-gray-100 truncate" title="{{ $interaction->key }}">
+ {{ $interaction->key }}
+ </code>
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300 font-bold">
+ @if ($config['sample_rate'] < 1)
+ <span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($interaction->hits) }}">~{{ number_format($interaction->hits * (1 / $config['sample_rate'])) }}</span>
+ @else
+ {{ number_format($interaction->hits) }}
+ @endif
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300 font-bold">
+ @if ($config['sample_rate'] < 1)
+ <span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($interaction->misses) }}">~{{ number_format($interaction->misses * (1 / $config['sample_rate'])) }}</span>
+ @else
+ {{ number_format($interaction->misses) }}
+ @endif
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300 font-bold">
+ {{ ((int) ($interaction->hits / ($interaction->hits + $interaction->misses) * 10000)) / 100 }}%
+ </x-pulse::td>
+ </tr>
+ @endforeach
+ </tbody>
+ </x-pulse::table>
+
+ @if ($cacheKeyInteractions->count() > 100)
+ <div class="mt-2 text-xs text-gray-400 text-center">Limited to 100 entries</div>
+ @endif
+ </div>
+ </div>
+ @endif
+ </x-pulse::scroll>
+</x-pulse::card>
diff --git a/resources/js/components/pulseCards/exceptions.blade.php b/resources/js/components/pulseCards/exceptions.blade.php
new file mode 100644
index 00000000..2247e859
--- /dev/null
+++ b/resources/js/components/pulseCards/exceptions.blade.php
@@ -0,0 +1,74 @@
+<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
+ <x-pulse::card-header
+ name="Exceptions"
+ x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
+ details="past {{ $this->periodForHumans() }}"
+ >
+ <x-slot:icon>
+ <x-pulse::icons.bug-ant />
+ </x-slot:icon>
+ <x-slot:actions>
+ <x-pulse::select
+ wire:model.live="orderBy"
+ label="Sort by"
+ :options="[
+ 'count' => 'count',
+ 'latest' => 'latest',
+ ]"
+ @change="loading = true"
+ />
+ </x-slot:actions>
+ </x-pulse::card-header>
+
+ <x-pulse::scroll :expand="$expand" wire:poll.5s="">
+ <div class="min-h-full flex flex-col">
+ @if ($exceptions->isEmpty())
+ <x-pulse::no-results />
+ @else
+ <x-pulse::table>
+ <colgroup>
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <x-pulse::thead>
+ <tr>
+ <x-pulse::th>Type</x-pulse::th>
+ <x-pulse::th class="text-right">Latest</x-pulse::th>
+ <x-pulse::th class="text-right">Count</x-pulse::th>
+ </tr>
+ </x-pulse::thead>
+ <tbody>
+ @foreach ($exceptions->take(100) as $exception)
+ <tr wire:key="{{ $exception->class.$exception->location }}-spacer" class="h-2 first:h-0"></tr>
+ <tr wire:key="{{ $exception->class.$exception->location }}-row">
+ <x-pulse::td class="max-w-[1px]">
+ <code class="block text-xs text-gray-900 dark:text-gray-100 truncate" title="{{ $exception->class }}">
+ {{ $exception->class }}
+ </code>
+ <p class="mt-1 text-xs text-gray-500 dark:text-gray-400 truncate" title="{{ $exception->location }}">
+ {{ $exception->location }}
+ </p>
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300 font-bold">
+ {{ $exception->latest->ago(syntax: Carbon\CarbonInterface::DIFF_ABSOLUTE, short: true) }}
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300 font-bold">
+ @if ($config['sample_rate'] < 1)
+ <span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($exception->count) }}">~{{ number_format($exception->count * (1 / $config['sample_rate'])) }}</span>
+ @else
+ {{ number_format($exception->count) }}
+ @endif
+ </x-pulse::td>
+ </tr>
+ @endforeach
+ </tbody>
+ </x-pulse::table>
+ @endif
+
+ @if ($exceptions->count() > 100)
+ <div class="mt-2 text-xs text-gray-400 text-center">Limited to 100 entries</div>
+ @endif
+ </div>
+ </x-pulse::scroll>
+</x-pulse::card>
diff --git a/resources/js/components/pulseCards/period-selector.blade.php b/resources/js/components/pulseCards/period-selector.blade.php
new file mode 100644
index 00000000..282730dd
--- /dev/null
+++ b/resources/js/components/pulseCards/period-selector.blade.php
@@ -0,0 +1,19 @@
+<div class="flex"
+ x-data="{
+ setPeriod(period) {
+ let query = new URLSearchParams(window.location.search)
+ if (period === '1_hour') {
+ query.delete('period')
+ } else {
+ query.set('period', period)
+ }
+
+ window.location = `${location.pathname}?${query}`
+ }
+ }"
+>
+ <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>
+</div>
diff --git a/resources/js/components/pulseCards/queues.blade.php b/resources/js/components/pulseCards/queues.blade.php
new file mode 100644
index 00000000..69b40067
--- /dev/null
+++ b/resources/js/components/pulseCards/queues.blade.php
@@ -0,0 +1,209 @@
+@use('Illuminate\Support\Str')
+<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
+ <x-pulse::card-header
+ name="Queues"
+ x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
+ details="past {{ $this->periodForHumans() }}"
+ >
+ <x-slot:icon>
+ <x-pulse::icons.queue-list />
+ </x-slot:icon>
+ <x-slot:actions>
+ <div class="flex flex-wrap gap-4">
+ <div class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div class="h-0.5 w-3 rounded-full bg-[rgba(107,114,128,0.5)]"></div>
+ Queued
+ </div>
+ <div class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div class="h-0.5 w-3 rounded-full bg-[rgba(147,51,234,0.5)]"></div>
+ Processing
+ </div>
+ <div class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div class="h-0.5 w-3 rounded-full bg-[#9333ea]"></div>
+ Processed
+ </div>
+ <div class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div class="h-0.5 w-3 rounded-full bg-[#eab308]"></div>
+ Released
+ </div>
+ <div class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div class="h-0.5 w-3 rounded-full bg-[#e11d48]"></div>
+ Failed
+ </div>
+ </div>
+ </x-slot:actions>
+ </x-pulse::card-header>
+
+ <x-pulse::scroll :expand="$expand" wire:poll.5s="">
+ @if ($queues->isEmpty())
+ <x-pulse::no-results />
+ @else
+ <div class="grid gap-3 mx-px mb-px">
+ @foreach ($queues as $queue => $readings)
+ <div wire:key="{{ $queue }}">
+ <h3 class="font-bold text-gray-700 dark:text-gray-300">
+ @if ($showConnection)
+ {{ $queue }}
+ @else
+ {{ Str::after($queue, ':') }}
+ @endif
+ </h3>
+ @php
+ $highest = $readings->flatten()->max();
+ @endphp
+
+ <div class="mt-3 relative">
+ <div class="absolute -left-px -top-2 max-w-fit h-4 flex items-center px-1 text-xs leading-none text-white font-bold bg-purple-500 rounded after:[--triangle-size:4px] after:border-l-purple-500 after:absolute after:right-[calc(-1*var(--triangle-size))] after:top-[calc(50%-var(--triangle-size))] after:border-t-[length:var(--triangle-size)] after:border-b-[length:var(--triangle-size)] after:border-l-[length:var(--triangle-size)] after:border-transparent">
+ @if ($config['sample_rate'] < 1)
+ <span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($highest) }}">~{{ number_format($highest * (1 / $config['sample_rate'])) }}</span>
+ @else
+ {{ number_format($highest) }}
+ @endif
+ </div>
+
+ <div
+ wire:ignore
+ class="h-14"
+ x-data="queueChart({
+ queue: '{{ $queue }}',
+ readings: @js($readings),
+ sampleRate: {{ $config['sample_rate'] }},
+ })"
+ >
+ <canvas x-ref="canvas" class="ring-1 ring-gray-900/5 dark:ring-gray-100/10 bg-gray-50 dark:bg-gray-800 rounded-md shadow-sm"></canvas>
+ </div>
+ </div>
+ </div>
+ @endforeach
+ </div>
+ @endif
+ </x-pulse::scroll>
+</x-pulse::card>
+
+@script
+<script>
+Alpine.data('queueChart', (config) => ({
+ init() {
+ let chart = new Chart(
+ this.$refs.canvas,
+ {
+ type: 'line',
+ data: {
+ labels: this.labels(config.readings),
+ datasets: [
+ {
+ label: 'Queued',
+ borderColor: 'rgba(107,114,128,0.5)',
+ data: this.scale(config.readings.queued),
+ order: 4,
+ },
+ {
+ label: 'Processing',
+ borderColor: 'rgba(147,51,234,0.5)',
+ data: this.scale(config.readings.processing),
+ order: 3,
+ },
+ {
+ label: 'Released',
+ borderColor: '#eab308',
+ data: this.scale(config.readings.released),
+ order: 2,
+ },
+ {
+ label: 'Processed',
+ borderColor: '#9333ea',
+ data: this.scale(config.readings.processed),
+ order: 1,
+ },
+ {
+ label: 'Failed',
+ borderColor: '#e11d48',
+ data: this.scale(config.readings.failed),
+ order: 0,
+ },
+ ],
+ },
+ options: {
+ maintainAspectRatio: false,
+ layout: {
+ autoPadding: false,
+ padding: {
+ top: 1,
+ },
+ },
+ datasets: {
+ line: {
+ borderWidth: 2,
+ borderCapStyle: 'round',
+ pointHitRadius: 10,
+ pointStyle: false,
+ tension: 0.2,
+ spanGaps: false,
+ segment: {
+ borderColor: (ctx) => ctx.p0.raw === 0 && ctx.p1.raw === 0 ? 'transparent' : undefined,
+ }
+ }
+ },
+ scales: {
+ x: {
+ display: false,
+ },
+ y: {
+ display: false,
+ min: 0,
+ max: this.highest(config.readings),
+ },
+ },
+ plugins: {
+ legend: {
+ display: false,
+ },
+ tooltip: {
+ mode: 'index',
+ position: 'nearest',
+ intersect: false,
+ callbacks: {
+ beforeBody: (context) => context
+ .map(item => `${item.dataset.label}: ${config.sampleRate < 1 ? '~' : ''}${item.formattedValue}`)
+ .join(', '),
+ label: () => null,
+ },
+ },
+ },
+ },
+ }
+ )
+
+ Livewire.on('queues-chart-update', ({ queues }) => {
+ if (chart === undefined) {
+ return
+ }
+
+ if (queues[config.queue] === undefined && chart) {
+ chart.destroy()
+ chart = undefined
+ return
+ }
+
+ chart.data.labels = this.labels(queues[config.queue])
+ chart.options.scales.y.max = this.highest(queues[config.queue])
+ chart.data.datasets[0].data = this.scale(queues[config.queue].queued)
+ chart.data.datasets[1].data = this.scale(queues[config.queue].processing)
+ chart.data.datasets[2].data = this.scale(queues[config.queue].released)
+ chart.data.datasets[3].data = this.scale(queues[config.queue].processed)
+ chart.data.datasets[4].data = this.scale(queues[config.queue].failed)
+ chart.update()
+ })
+ },
+ labels(readings) {
+ return Object.keys(readings.queued).map(formatDate)
+ },
+ scale(data) {
+ return Object.values(data).map(value => value * (1 / config.sampleRate ))
+ },
+ highest(readings) {
+ return Math.max(...Object.values(readings).map(dataset => Math.max(...Object.values(dataset)))) * (1 / config.sampleRate)
+ }
+}))
+</script>
+@endscript
diff --git a/resources/js/components/pulseCards/slow-jobs.blade.php b/resources/js/components/pulseCards/slow-jobs.blade.php
new file mode 100644
index 00000000..3fa9c2e9
--- /dev/null
+++ b/resources/js/components/pulseCards/slow-jobs.blade.php
@@ -0,0 +1,78 @@
+<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
+ <x-pulse::card-header
+ name="Slow Jobs"
+ 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() }}"
+ >
+ <x-slot:icon>
+ <x-pulse::icons.command-line />
+ </x-slot:icon>
+ <x-slot:actions>
+ <x-pulse::select
+ wire:model.live="orderBy"
+ label="Sort by"
+ :options="[
+ 'slowest' => 'slowest',
+ 'count' => 'count',
+ ]"
+ @change="loading = true"
+ />
+ </x-slot:actions>
+ </x-pulse::card-header>
+
+ <x-pulse::scroll :expand="$expand" wire:poll.5s="">
+ @if ($slowJobs->isEmpty())
+ <x-pulse::no-results />
+ @else
+ <x-pulse::table>
+ <colgroup>
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <x-pulse::thead>
+ <tr>
+ <x-pulse::th>Job</x-pulse::th>
+ <x-pulse::th class="text-right">Count</x-pulse::th>
+ <x-pulse::th class="text-right">Slowest</x-pulse::th>
+ </tr>
+ </x-pulse::thead>
+ <tbody>
+ @foreach ($slowJobs->take(100) as $job)
+ <tr wire:key="{{ $job->job }}-spacer" class="h-2 first:h-0"></tr>
+ <tr wire:key="{{ $job->job }}-row">
+ <x-pulse::td class="max-w-[1px]">
+ <code class="block text-xs text-gray-900 dark:text-gray-100 truncate" title="{{ $job->job }}">
+ {{ $job->job }}
+ </code>
+ @if (is_array($config['threshold']))
+ <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
+ {{ $job->threshold }}ms threshold
+ </p>
+ @endif
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300 font-bold">
+ @if ($config['sample_rate'] < 1)
+ <span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($job->count) }}">~{{ number_format($job->count * (1 / $config['sample_rate'])) }}</span>
+ @else
+ {{ number_format($job->count) }}
+ @endif
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300">
+ @if ($job->slowest === null)
+ <strong>Unknown</strong>
+ @else
+ <strong>{{ number_format($job->slowest) ?: '<1' }}</strong> ms
+ @endif
+ </x-pulse::td>
+ </tr>
+ @endforeach
+ </tbody>
+ </x-pulse::table>
+ @endif
+
+ @if ($slowJobs->count() > 100)
+ <div class="mt-2 text-xs text-gray-400 text-center">Limited to 100 entries</div>
+ @endif
+ </x-pulse::scroll>
+</x-pulse::card>
diff --git a/resources/js/components/pulseCards/slow-outgoing-requests.blade.php b/resources/js/components/pulseCards/slow-outgoing-requests.blade.php
new file mode 100644
index 00000000..01957831
--- /dev/null
+++ b/resources/js/components/pulseCards/slow-outgoing-requests.blade.php
@@ -0,0 +1,102 @@
+@use('Illuminate\Support\Str')
+<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
+ <x-pulse::card-header
+ name="Slow Outgoing Requests"
+ x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
+ details="{{ is_array($config['threshold']) ? '' : $config['threshold'].'ms threshold, ' }}past {{ $this->periodForHumans() }}"
+ >
+ <x-slot:icon>
+ <x-pulse::icons.cloud-arrow-up />
+ </x-slot:icon>
+ <x-slot:actions>
+ @php
+ $count = count($config['groups']);
+ $message = sprintf(
+ "URIs may be normalized using groups.\n\nThere %s currently %d %s configured.",
+ $count === 1 ? 'is' : 'are',
+ $count,
+ Str::plural('group', $count)
+ );
+ @endphp
+ <button title="{{ $message }}" @click="alert(@js($message))">
+ <x-pulse::icons.information-circle class="w-5 h-5 stroke-gray-400 dark:stroke-gray-600" />
+ </button>
+
+ <x-pulse::select
+ wire:model.live="orderBy"
+ label="Sort by"
+ :options="[
+ 'slowest' => 'slowest',
+ 'count' => 'count',
+ ]"
+ @change="loading = true"
+ />
+ </x-slot:actions>
+ </x-pulse::card-header>
+
+ <x-pulse::scroll :expand="$expand" wire:poll.5s="">
+ @if ($slowOutgoingRequests->isEmpty())
+ <x-pulse::no-results />
+ @else
+ <x-pulse::table>
+ <colgroup>
+ <col width="0%" />
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <x-pulse::thead>
+ <tr>
+ <x-pulse::th>Method</x-pulse::th>
+ <x-pulse::th>URI</x-pulse::th>
+ <x-pulse::th class="text-right">Count</x-pulse::th>
+ <x-pulse::th class="text-right">Slowest</x-pulse::th>
+ </tr>
+ </x-pulse::thead>
+ <tbody>
+ @foreach ($slowOutgoingRequests->take(100) as $request)
+ <tr wire:key="{{ $request->method.$request->uri }}-spacer" class="h-2 first:h-0"></tr>
+ <tr wire:key="{{ $request->method.$request->uri }}-row">
+ <x-pulse::td>
+ <x-pulse::http-method-badge :method="$request->method" />
+ </x-pulse::td>
+ <x-pulse::td class="max-w-[1px]">
+ <div class="flex items-center" title="{{ $request->uri }}">
+ @if ($host = parse_url($request->uri, PHP_URL_HOST))
+ <img wire:ignore src="https://unavatar.io/{{ $host }}?fallback=false" loading="lazy" class="w-4 h-4 mr-2" onerror="this.style.display='none'" />
+ @endif
+ <code class="block text-xs text-gray-900 dark:text-gray-100 truncate">
+ {{ $request->uri }}
+ </code>
+ </div>
+ @if (is_array($config['threshold']))
+ <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
+ {{ $request->threshold }}ms threshold
+ </p>
+ @endif
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300 font-bold">
+ @if ($config['sample_rate'] < 1)
+ <span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($request->count) }}">~{{ number_format($request->count * (1 / $config['sample_rate'])) }}</span>
+ @else
+ {{ number_format($request->count) }}
+ @endif
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300">
+ @if ($request->slowest === null)
+ <strong>Unknown</strong>
+ @else
+ <strong>{{ number_format($request->slowest) ?: '<1' }}</strong> ms
+ @endif
+ </x-pulse::td>
+ </tr>
+ @endforeach
+ </tbody>
+ </x-pulse::table>
+
+ @if ($slowOutgoingRequests->count() > 100)
+ <div class="mt-2 text-xs text-gray-400 text-center">Limited to 100 entries</div>
+ @endif
+ @endif
+ </x-pulse::scroll>
+</x-pulse::card>
diff --git a/resources/js/components/pulseCards/slow-queries.blade.php b/resources/js/components/pulseCards/slow-queries.blade.php
new file mode 100644
index 00000000..a2a4cf36
--- /dev/null
+++ b/resources/js/components/pulseCards/slow-queries.blade.php
@@ -0,0 +1,104 @@
+@php
+use \Doctrine\SqlFormatter\HtmlHighlighter;
+use \Doctrine\SqlFormatter\SqlFormatter;
+
+if ($this->wantsHighlighting()) {
+ $sqlFormatter = new SqlFormatter(new HtmlHighlighter([
+ HtmlHighlighter::HIGHLIGHT_RESERVED => 'class="font-semibold"',
+ HtmlHighlighter::HIGHLIGHT_QUOTE => 'class="text-purple-200"',
+ HtmlHighlighter::HIGHLIGHT_BACKTICK_QUOTE => 'class="text-purple-200"',
+ HtmlHighlighter::HIGHLIGHT_BOUNDARY => 'class="text-cyan-200"',
+ HtmlHighlighter::HIGHLIGHT_NUMBER => 'class="text-orange-200"',
+ HtmlHighlighter::HIGHLIGHT_WORD => 'class="text-orange-200"',
+ HtmlHighlighter::HIGHLIGHT_VARIABLE => 'class="text-orange-200"',
+ HtmlHighlighter::HIGHLIGHT_ERROR => 'class="text-red-200"',
+ HtmlHighlighter::HIGHLIGHT_COMMENT => 'class="text-gray-400"',
+ ], false));
+}
+@endphp
+<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
+ <x-pulse::card-header
+ name="Slow Queries"
+ x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
+ details="{{ is_array($config['threshold']) ? '' : $config['threshold'].'ms threshold, ' }}past {{ $this->periodForHumans() }}"
+ >
+ <x-slot:icon>
+ <x-pulse::icons.circle-stack />
+ </x-slot:icon>
+ <x-slot:actions>
+ <x-pulse::select
+ wire:model.live="orderBy"
+ label="Sort by"
+ :options="[
+ 'slowest' => 'slowest',
+ 'count' => 'count',
+ ]"
+ @change="loading = true"
+ />
+ </x-slot:actions>
+ </x-pulse::card-header>
+
+ <x-pulse::scroll :expand="$expand" wire:poll.5s="">
+ @if ($slowQueries->isEmpty())
+ <x-pulse::no-results />
+ @else
+ <x-pulse::table>
+ <colgroup>
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <x-pulse::thead>
+ <tr>
+ <x-pulse::th>Query</x-pulse::th>
+ <x-pulse::th class="text-right">Count</x-pulse::th>
+ <x-pulse::th class="text-right">Slowest</x-pulse::th>
+ </tr>
+ </x-pulse::thead>
+ <tbody>
+ @foreach ($slowQueries->take(100) as $query)
+ <tr wire:key="{{ md5($query->sql.$query->location) }}-spacer" class="h-2 first:h-0"></tr>
+ <tr wire:key="{{ md5($query->sql.$query->location) }}-row">
+ <x-pulse::td class="!p-0 truncate max-w-[1px]">
+ <div class="relative">
+ <div class="bg-gray-700 dark:bg-gray-800 py-4 rounded-md text-gray-100 block text-xs whitespace-nowrap overflow-x-auto [scrollbar-color:theme(colors.gray.500)_transparent] [scrollbar-width:thin]">
+ <code class="px-3">{!! $this->wantsHighlighting() ? $sqlFormatter->highlight($query->sql) : $query->sql !!}</code>
+ @if ($query->location)
+ <p class="px-3 mt-3 text-xs leading-none text-gray-400 dark:text-gray-500">
+ {{ $query->location }}
+ </p>
+ @endif
+ @if (is_array($config['threshold']))
+ <p class="px-3 mt-3 text-xs leading-none text-gray-400 dark:text-gray-500">
+ {{ $query->threshold }}ms threshold
+ </p>
+ @endif
+ </div>
+ <div class="absolute top-0 right-0 bottom-0 rounded-r-md w-3 bg-gradient-to-r from-transparent to-gray-700 dark:to-gray-800 pointer-events-none"></div>
+ </div>
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300 font-bold">
+ @if ($config['sample_rate'] < 1)
+ <span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($query->count) }}">~{{ number_format($query->count * (1 / $config['sample_rate'])) }}</span>
+ @else
+ {{ number_format($query->count) }}
+ @endif
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300">
+ @if ($query->slowest === null)
+ <strong>Unknown</strong>
+ @else
+ <strong>{{ number_format($query->slowest) ?: '<1' }}</strong> ms
+ @endif
+ </x-pulse::td>
+ </tr>
+ @endforeach
+ </tbody>
+ </x-pulse::table>
+ @endif
+
+ @if ($slowQueries->count() > 100)
+ <div class="mt-2 text-xs text-gray-400 text-center">Limited to 100 entries</div>
+ @endif
+ </x-pulse::scroll>
+</x-pulse::card>
diff --git a/resources/js/components/pulseCards/slow-requests.blade.php b/resources/js/components/pulseCards/slow-requests.blade.php
new file mode 100644
index 00000000..c9497f2d
--- /dev/null
+++ b/resources/js/components/pulseCards/slow-requests.blade.php
@@ -0,0 +1,88 @@
+<x-pulse::card :cols="$cols" :rows="$rows" :class="$class">
+ <x-pulse::card-header
+ name="Slow Requests"
+ x-bind:title="`Time: {{ number_format($time) }}ms; Run at: ${formatDate('{{ $runAt }}')};`"
+ details="{{ is_array($config['threshold']) ? '' : $config['threshold'].'ms threshold, ' }}past {{ $this->periodForHumans() }}"
+ >
+ <x-slot:icon>
+ <x-pulse::icons.arrows-left-right />
+ </x-slot:icon>
+ <x-slot:actions>
+ <x-pulse::select
+ wire:model.live="orderBy"
+ label="Sort by"
+ :options="[
+ 'slowest' => 'slowest',
+ 'count' => 'count',
+ ]"
+ @change="loading = true"
+ />
+ </x-slot:actions>
+ </x-pulse::card-header>
+
+ <x-pulse::scroll :expand="$expand" wire:poll.5s="">
+ @if ($slowRequests->isEmpty())
+ <x-pulse::no-results />
+ @else
+ <x-pulse::table>
+ <colgroup>
+ <col width="0%" />
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <x-pulse::thead>
+ <tr>
+ <x-pulse::th>Method</x-pulse::th>
+ <x-pulse::th>Route</x-pulse::th>
+ <x-pulse::th class="text-right">Count</x-pulse::th>
+ <x-pulse::th class="text-right">Slowest</x-pulse::th>
+ </tr>
+ </x-pulse::thead>
+ <tbody>
+ @foreach ($slowRequests->take(100) as $slowRequest)
+ <tr wire:key="{{ $slowRequest->method.$slowRequest->uri }}-spacer" class="h-2 first:h-0"></tr>
+ <tr wire:key="{{ $slowRequest->method.$slowRequest->uri }}-row">
+ <x-pulse::td>
+ <x-pulse::http-method-badge :method="$slowRequest->method" />
+ </x-pulse::td>
+ <x-pulse::td class="overflow-hidden max-w-[1px]">
+ <code class="block text-xs text-gray-900 dark:text-gray-100 truncate" title="{{ $slowRequest->uri }}">
+ {{ $slowRequest->uri }}
+ </code>
+ @if ($slowRequest->action)
+ <p class="mt-1 text-xs text-gray-500 dark:text-gray-400 truncate" title="{{ $slowRequest->action }}">
+ {{ $slowRequest->action }}
+ </p>
+ @endif
+ @if (is_array($config['threshold']))
+ <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
+ {{ $slowRequest->threshold }}ms threshold
+ </p>
+ @endif
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300 font-bold">
+ @if ($config['sample_rate'] < 1)
+ <span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($slowRequest->count) }}">~{{ number_format($slowRequest->count * (1 / $config['sample_rate'])) }}</span>
+ @else
+ {{ number_format($slowRequest->count) }}
+ @endif
+ </x-pulse::td>
+ <x-pulse::td numeric class="text-gray-700 dark:text-gray-300">
+ @if ($slowRequest->slowest === null)
+ <strong>Unknown</strong>
+ @else
+ <strong>{{ number_format($slowRequest->slowest) ?: '<1' }}</strong> ms
+ @endif
+ </x-pulse::td>
+ </tr>
+ @endforeach
+ </tbody>
+ </x-pulse::table>
+
+ @if ($slowRequests->count() > 100)
+ <div class="mt-2 text-xs text-gray-400 text-center">Limited to 100 entries</div>
+ @endif
+ @endif
+ </x-pulse::scroll>
+</x-pulse::card>
diff --git a/resources/js/components/pulseCards/usage.blade.php b/resources/js/components/pulseCards/usage.blade.php
new file mode 100644
index 00000000..11aad64a
--- /dev/null
+++ b/resources/js/components/pulseCards/usage.blade.php
@@ -0,0 +1,72 @@
+<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'
+ }"
+ 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() }}"
+ >
+ <x-slot:icon>
+ <x-dynamic-component :component="'pulse::icons.' . match ($this->type) {
+ 'requests' => 'arrow-trending-up',
+ 'slow_requests' => 'clock',
+ 'jobs' => 'scale',
+ default => 'cursor-arrow-rays'
+ }" />
+ </x-slot:icon>
+ <x-slot:actions>
+ @if (! $this->type)
+ <x-pulse::select
+ wire:model.live="usage"
+ label="Top 10 users"
+ :options="[
+ 'requests' => 'making requests',
+ 'slow_requests' => 'experiencing slow endpoints',
+ 'jobs' => 'dispatching jobs',
+ ]"
+ class="flex-1"
+ @change="loading = true"
+ />
+ @endif
+ @if ($this->usage === 'slow_requests' && is_array($slowRequestsConfig['threshold']))
+ @php
+ $message = 'You have per-route thresholds configured.';
+ @endphp
+ <button title="{{ $message }}" @click="alert(@js($message))">
+ <x-pulse::icons.information-circle class="w-5 h-5 stroke-gray-400 dark:stroke-gray-600" />
+ </button>
+ @endif
+ </x-slot:actions>
+ </x-pulse::card-header>
+
+ <x-pulse::scroll :expand="$expand" wire:poll.5s="">
+ @if ($userRequestCounts->isEmpty())
+ <x-pulse::no-results />
+ @else
+ <div class="grid grid-cols-1 @lg:grid-cols-2 @3xl:grid-cols-3 @6xl:grid-cols-4 gap-2">
+ @php
+ $sampleRate = match($this->usage) {
+ 'requests' => $userRequestsConfig['sample_rate'],
+ 'slow_requests' => $slowRequestsConfig['sample_rate'],
+ 'jobs' => $jobsConfig['sample_rate'],
+ };
+ @endphp
+
+ @foreach ($userRequestCounts as $userRequestCount)
+ <x-pulse::user-card wire:key="{{ $userRequestCount->key }}" :user="$userRequestCount->user">
+ <x-slot:stats>
+ @if ($sampleRate < 1)
+ <span title="Sample rate: {{ $sampleRate }}, Raw value: {{ number_format($userRequestCount->count) }}">~{{ number_format($userRequestCount->count * (1 / $sampleRate)) }}</span>
+ @else
+ {{ number_format($userRequestCount->count) }}
+ @endif
+ </x-slot:stats>
+ </x-pulse::user-card>
+ @endforeach
+ </div>
+ @endif
+ </x-pulse::scroll>
+</x-pulse::card>