Skip to content

A self-hosted media server and file management system

feat: finish translating all pulse components to vue

aminnausina999b8bce842
diff --git a/app/Http/Controllers/Api/V1/AnalyticsController.php b/app/Http/Controllers/Api/V1/AnalyticsController.php
index 8754a127..bef62f06 100644
--- a/app/Http/Controllers/Api/V1/AnalyticsController.php
+++ b/app/Http/Controllers/Api/V1/AnalyticsController.php
@@ -12,7 +12,6 @@ use App\Models\Video;
use App\Traits\HasPeriod;
use App\Traits\HttpResponses;
use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Auth;
class AnalyticsController extends Controller {
use HasPeriod;
diff --git a/app/Jobs/IndexFiles.php b/app/Jobs/IndexFiles.php
index b2433eef..2ed67404 100755
--- a/app/Jobs/IndexFiles.php
+++ b/app/Jobs/IndexFiles.php
@@ -602,5 +602,4 @@ class IndexFiles implements ShouldBeUnique, ShouldQueue {
return 'Generated ' . $count . ' ' . $type . ' Changes';
}
}
-class BatchCancelledException extends \Exception {
-}
+class BatchCancelledException extends \Exception {}
diff --git a/package-lock.json b/package-lock.json
index 521c86d7..2a5abf72 100755
--- a/package-lock.json
+++ b/package-lock.json
@@ -4,6 +4,7 @@
"requires": true,
"packages": {
"": {
+ "name": "mediaServer",
"dependencies": {
"@tanstack/vue-query": "^5.77.2",
"@types/lodash": "^4.17.13",
@@ -885,9 +886,9 @@
}
},
"node_modules/@eslint/config-array/node_modules/brace-expansion": {
- "version": "1.1.11",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
- "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "version": "1.1.12",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
+ "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -956,9 +957,9 @@
}
},
"node_modules/@eslint/eslintrc/node_modules/brace-expansion": {
- "version": "1.1.11",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
- "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "version": "1.1.12",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
+ "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -3098,9 +3099,9 @@
"license": "ISC"
},
"node_modules/brace-expansion": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
- "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
+ "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -4360,9 +4361,9 @@
}
},
"node_modules/eslint/node_modules/brace-expansion": {
- "version": "1.1.11",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
- "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "version": "1.1.12",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
+ "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
"dev": true,
"license": "MIT",
"dependencies": {
diff --git a/resources/js/components/cards/DashboardCard.vue b/resources/js/components/cards/DashboardCard.vue
index c22f24e3..88ae2542 100644
--- a/resources/js/components/cards/DashboardCard.vue
+++ b/resources/js/components/cards/DashboardCard.vue
@@ -19,16 +19,19 @@ const props = withDefaults(
</script>
<template>
<div
- :class="`flex col-span-${cols} row-span-${rows} flex-col gap-2 p-3 rounded-xl shadow-lg dark:bg-primary-dark-800/70 bg-white ring-1 ring-gray-900/5 w-full ${props.class ?? ''}`"
+ :class="[
+ `flex col-span-full sm:col-span-${cols} row-span-${rows} flex-col gap-2 p-3 rounded-xl shadow-lg dark:bg-primary-dark-800/70 bg-white ring-1 ring-gray-900/5 w-full`,
+ props.class,
+ ]"
>
- <header class="flex flex-wrap justify-between items-center gap-4 mb-3 @md:mb-6">
+ <header class="flex flex-wrap justify-between items-center gap-4 mb-3">
<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-600/80 [&>svg]:dark:stroke-neutral-400/80 text-gray-400 dark:text-neutral-400/80">
<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" :title="props.title">
+ <h2 class="text-base font-bold text-gray-600 dark:text-neutral-300 truncate" :title="props.title">
{{ props.name }}
</h2>
<p v-if="props.details" class="text-gray-600/80 dark:text-neutral-400/80 font-medium truncate">
@@ -37,12 +40,10 @@ const props = withDefaults(
</hgroup>
</div>
</div>
- <div class="flex flex-grow">
- <div class="w-full flex items-center gap-4">
- <slot name="actions"></slot>
- </div>
+ <div class="flex flex-grow items-center">
+ <slot name="actions"></slot>
</div>
</header>
- <slot name="slot"></slot>
+ <slot></slot>
</div>
</template>
diff --git a/resources/js/components/dashboard/DashboardAnalytics.vue b/resources/js/components/dashboard/DashboardAnalytics.vue
index 842c503c..b5965b8d 100644
--- a/resources/js/components/dashboard/DashboardAnalytics.vue
+++ b/resources/js/components/dashboard/DashboardAnalytics.vue
@@ -1,8 +1,9 @@
<script setup lang="ts">
-import type { BreadCrumbItem, PulseResponse } from '@/types/types';
+import type { BreadCrumbItem } from '@/types/types';
+import type { PulseResponse } from '@/types/pulseTypes';
-import { useGetPulse, useGetSiteAnalytics } from '@/service/queries';
import { computed, ref, useTemplateRef, watch } from 'vue';
+import { useGetPulse, useGetSiteAnalytics } from '@/service/queries';
import { handleStartTask } from '@/service/taskService';
import { periodForHumans } from '@/service/pulseUtil';
@@ -21,6 +22,12 @@ import ProiconsArrowSync from '~icons/proicons/arrow-sync';
import ProiconsHome2 from '~icons/proicons/home-2';
import ProiconsBolt from '~icons/proicons/bolt';
import ProiconsAdd from '~icons/proicons/add';
+import PulseExceptions from '../pulseCards/PulseExceptions.vue';
+import PulseSlowRequests from '../pulseCards/PulseSlowRequests.vue';
+import PulseSlowJobs from '../pulseCards/PulseSlowJobs.vue';
+import PulseSlowOutgoingRequests from '../pulseCards/PulseSlowOutgoingRequests.vue';
+import PulseSlowQueries from '../pulseCards/PulseSlowQueries.vue';
+import PulseCache from '../pulseCards/PulseCache.vue';
const validPeriods: { key: string; value: string }[] = [
{ key: '1h', value: '1_hour' },
@@ -97,20 +104,24 @@ watch(
<template #icon>
<LucideChartNoAxesCombined class="w-6 h-6" />
</template>
- <template #slot>
- <span v-for="(stat, index) in stats?.changes" :key="index" class="flex gap-2 capitalize items-center flex-wrap">
- <h3 class="text-sm dark:text-slate-400 text-slate-500 w-full text-nowrap">{{ stat.title }}</h3>
- <span>
- <h3 class="text-lg">{{ stat.count ?? 0 }}</h3>
- </span>
- <h4 :class="`text-sm ${stat.change >= 0 ? 'text-green-700 dark:text-green-600' : 'text-rose-500'} ml-auto`">
- {{ `${stat.change === 0 ? 'no change' : `${stat.change >= 0 ? '+' : '-'}${stat.change}`}` }}
- </h4>
+ <span v-for="(stat, index) in stats?.changes" :key="index" class="flex gap-2 capitalize items-center flex-wrap">
+ <h3 class="text-sm dark:text-neutral-400 text-neutral-500 w-full text-nowrap">{{ stat.title }}</h3>
+ <span>
+ <h3 class="text-lg">{{ stat.count ?? 0 }}</h3>
</span>
- </template>
+ <h4 :class="`text-sm ${stat.change >= 0 ? 'text-green-700 dark:text-green-600' : 'text-rose-500'} ml-auto`">
+ {{ `${stat.change === 0 ? 'no change' : `${stat.change >= 0 ? '+' : '-'}${stat.change}`}` }}
+ </h4>
+ </span>
</DashboardCard>
<PulseUsage :pulseData="pulseData" :isLoading="pulseLoading" :period="period" :rows="4" />
<PulseQueues :pulseData="pulseData" :isLoading="pulseLoading" :period="period" :rows="2" />
- <PulseRequests :pulseData="pulseData" :isLoading="pulseLoading" :period="period" :rows="2" />
+ <PulseRequests v-if="pulseData" :pulseData="pulseData" :isLoading="pulseLoading" :period="period" :rows="2" />
+ <PulseSlowRequests v-if="pulseData" :pulse-data="pulseData" :is-loading="pulseLoading" :period="period" :rows="2" cols="3" />
+ <PulseSlowJobs v-if="pulseData" :pulse-data="pulseData" :is-loading="pulseLoading" :period="period" :rows="2" :cols="3" />
+ <PulseSlowQueries v-if="pulseData" :pulse-data="pulseData" :is-loading="pulseLoading" :period="period" :rows="2" :cols="3" />
+ <PulseCache v-if="pulseData" :pulse-data="pulseData" :is-loading="pulseLoading" :period="period" :rows="2" :cols="3" />
+ <PulseExceptions :pulse-data="pulseData" :is-loading="pulseLoading" :period="period" :rows="2" />
+ <PulseSlowOutgoingRequests v-if="pulseData" :pulse-data="pulseData" :is-loading="pulseLoading" :period="period" :rows="2" />
</span>
</template>
diff --git a/resources/js/components/pulse/PulseCard.vue b/resources/js/components/pulse/PulseCard.vue
index 6807f6e4..30e0412b 100644
--- a/resources/js/components/pulse/PulseCard.vue
+++ b/resources/js/components/pulse/PulseCard.vue
@@ -1,6 +1,6 @@
<script setup lang="ts">
-const props = withDefaults(defineProps<{ cols?: number; rows?: number }>(), {
- cols: 6,
+const props = withDefaults(defineProps<{ cols?: number | string; rows?: number }>(), {
+ cols: 'full',
rows: 1,
});
</script>
diff --git a/resources/js/components/pulse/PulseScroll.vue b/resources/js/components/pulse/PulseScroll.vue
index c383e962..ff10d047 100644
--- a/resources/js/components/pulse/PulseScroll.vue
+++ b/resources/js/components/pulse/PulseScroll.vue
@@ -30,7 +30,7 @@ onMounted(async () => {
@scroll.passive="scroll"
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"
>
- <slot name="slot"></slot>
+ <slot></slot>
<div 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/PulseTable.vue b/resources/js/components/pulse/PulseTable.vue
index a313d358..4bbf1b81 100644
--- a/resources/js/components/pulse/PulseTable.vue
+++ b/resources/js/components/pulse/PulseTable.vue
@@ -1,3 +1,5 @@
-<table {{ $attributes->merge(['class' => 'w-full']) }}>
- {{ $slot }}
-</table>
+<template>
+ <table class="w-full">
+ <slot></slot>
+ </table>
+</template>
diff --git a/resources/js/components/pulse/PulseTd.vue b/resources/js/components/pulse/PulseTd.vue
index 5337b2c2..42561d66 100644
--- a/resources/js/components/pulse/PulseTd.vue
+++ b/resources/js/components/pulse/PulseTd.vue
@@ -1,4 +1,13 @@
-@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>
+<script setup lang="ts">
+withDefaults(defineProps<{ numeric?: boolean }>(), { numeric: false });
+</script>
+<template>
+ <td
+ :class="[
+ 'first:rounded-l-md last:rounded-r-md text-sm dark:bg-primary-dark-800 bg-primary-900 ring-1 ring-gray-900/5 first:pl-3 last:pr-3 px-1 sm:px-3 py-3',
+ { 'text-right tabular-nums whitespace-nowrap': numeric },
+ ]"
+ >
+ <slot></slot>
+ </td>
+</template>
diff --git a/resources/js/components/pulse/PulseTh.vue b/resources/js/components/pulse/PulseTh.vue
index 4671c303..07d501d6 100644
--- a/resources/js/components/pulse/PulseTh.vue
+++ b/resources/js/components/pulse/PulseTh.vue
@@ -1,3 +1,5 @@
-<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>
+<template>
+ <th class="text-xs text-neutral-500 uppercase py-2 first:pl-3 last:pr-3 px-1 sm:px-3">
+ <slot> </slot>
+ </th>
+</template>
diff --git a/resources/js/components/pulse/PulseThead.vue b/resources/js/components/pulse/PulseThead.vue
index 44088b71..369db90b 100644
--- a/resources/js/components/pulse/PulseThead.vue
+++ b/resources/js/components/pulse/PulseThead.vue
@@ -1,3 +1,5 @@
-<thead class="sticky z-10 top-0 bg-white dark:bg-gray-900">
- {{ $slot }}
-</thead>
+<template>
+ <thead class="sticky z-10 top-0 bg-white dark:bg-[#222225]">
+ <slot></slot>
+ </thead>
+</template>
diff --git a/resources/js/components/pulse/PulseUserCard.vue b/resources/js/components/pulse/PulseUserCard.vue
index 27d19059..c56340ac 100644
--- a/resources/js/components/pulse/PulseUserCard.vue
+++ b/resources/js/components/pulse/PulseUserCard.vue
@@ -4,7 +4,7 @@ const props = defineProps<{ user: { name: string; extra?: any; avatar?: string }
<template>
<div class="flex items-center justify-between p-4 gap-2 rounded-md dark:bg-primary-dark-800 bg-primary-900 ring-1 ring-gray-900/5 shadow-sm ring-inset">
<div class="flex items-center gap-3 overflow-hidden">
- <img v-if="props.user?.avatar" :src="props.user.avatar" :alt="props.user.name" loading="lazy" class="rounded-full w-8 h-8 object-cover" />
+ <img v-if="props.user?.avatar && props.user.extra !== ''" :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">
diff --git a/resources/js/components/pulseCards/PulseCache.vue b/resources/js/components/pulseCards/PulseCache.vue
new file mode 100644
index 00000000..b117826d
--- /dev/null
+++ b/resources/js/components/pulseCards/PulseCache.vue
@@ -0,0 +1,162 @@
+<script setup lang="ts">
+import type { PulseResponse } from '@/types/pulseTypes';
+
+import { format_number, periodForHumans } from '@/service/pulseUtil';
+import { computed } from 'vue';
+
+import IconInformationCircle from '@/components/icons/IconInformationCircle.vue';
+import IconRocketLaunch from '@/components/icons/IconRocketLaunch.vue';
+import PulseNoResults from '@/components/pulse/PulseNoResults.vue';
+import DashboardCard from '@/components/cards/DashboardCard.vue';
+import PulseScroll from '@/components/pulse/PulseScroll.vue';
+import PulseTable from '@/components/pulse/PulseTable.vue';
+import PulseThead from '@/components/pulse/PulseThead.vue';
+import PulseTd from '@/components/pulse/PulseTd.vue';
+import PulseTh from '@/components/pulse/PulseTh.vue';
+
+const validPeriods = ['1_hour', '6_hours', '24_hours', '7_days'];
+
+const props = withDefaults(
+ defineProps<{
+ cols?: number | string;
+ rows?: number;
+ class?: string;
+ pulseData: PulseResponse;
+ isLoading?: boolean;
+ period: string;
+ }>(),
+ {
+ cols: 'full',
+ rows: 4,
+ },
+);
+
+const cacheKeyInteractions = computed(() => {
+ return props.pulseData.cache?.cacheKeyInteractions ?? [];
+});
+
+const config = computed(() => {
+ return props.pulseData.cache.config;
+});
+</script>
+<template>
+ <DashboardCard
+ :rows="rows"
+ :cols="cols"
+ :class="props.class"
+ name="Cache"
+ :title="`Time: ${format_number(pulseData.slow_outgoing_requests?.time ?? 0)}ms; Run at: ${pulseData.slow_outgoing_requests?.runAt ? new Date(pulseData.slow_outgoing_requests?.runAt).toLocaleDateString() : ''};`"
+ :details="`past ${validPeriods.indexOf(period) !== -1 ? periodForHumans(period) : periodForHumans(validPeriods[0])}`"
+ >
+ <template #icon>
+ <IconRocketLaunch />
+ </template>
+
+ <template #actions>
+ <button
+ :title="`Keys may be normalized using groups.\n\nThere ${Object.keys(config.groups).length === 1 ? 'is' : 'are'} currently ${Object.keys(config.groups).length} ${Object.keys(config.groups).length === 1 ? 'group' : 'groups'} configured.`"
+ >
+ <IconInformationCircle class="w-5 h-5 stroke-gray-400 dark:stroke-gray-600" />
+ </button>
+ </template>
+
+ <PulseScroll :expand="false" :loading="isLoading ?? false">
+ <PulseNoResults v-if="pulseData.cache.allCacheInteractions.hits === 0 && pulseData.cache.allCacheInteractions.misses === 0" />
+ <div class="flex flex-col gap-6" v-else>
+ <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">
+ <span
+ v-if="config.sample_rate < 1"
+ :title="`Sample rate: ${config.sample_rate}, Raw value: ${format_number(pulseData.cache.allCacheInteractions.hits)}`"
+ >
+ ~{{ format_number(pulseData.cache.allCacheInteractions.hits * (1 / config.sample_rate)) }}
+ </span>
+ <template v-else>
+ {{ format_number(pulseData.cache.allCacheInteractions.hits) }}
+ </template>
+ </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">
+ <span
+ v-if="config.sample_rate < 1"
+ :title="`Sample rate: ${config.sample_rate}, Raw value: ${format_number(pulseData.cache.allCacheInteractions.misses)}`"
+ >
+ ~{{ format_number(pulseData.cache.allCacheInteractions.misses * (1 / config.sample_rate)) }}
+ </span>
+ <template v-else>
+ {{ format_number(pulseData.cache.allCacheInteractions.misses) }}
+ </template>
+ </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">
+ {{
+ Math.floor(
+ (pulseData.cache.allCacheInteractions.hits / (pulseData.cache.allCacheInteractions.hits + pulseData.cache.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>
+ <PulseTable>
+ <colgroup>
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <PulseThead>
+ <tr>
+ <PulseTh class="text-left">Key</PulseTh>
+ <PulseTh class="text-right">Hits</PulseTh>
+ <PulseTh class="text-right">Misses</PulseTh>
+ <PulseTh class="text-right whitespace-nowrap">Hit Rate</PulseTh>
+ </tr>
+ </PulseThead>
+ <tbody class="">
+ <template v-for="(interaction, index) in cacheKeyInteractions.slice(0, 100)" :key="index">
+ <tr class="h-2 first:h-0"></tr>
+ <tr>
+ <PulseTd class="max-w-[1px]">
+ <code class="block text-xs text-gray-900 dark:text-gray-100 truncate" :title="interaction.key">
+ {{ interaction.key }}
+ </code>
+ </PulseTd>
+
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300 font-bold">
+ <span v-if="config.sample_rate < 1" :title="`Sample rate: ${config.sample_rate}, Raw value: ${format_number(interaction.hits)}`">
+ ~{{ format_number(interaction.hits * (1 / config.sample_rate)) }}
+ </span>
+ <template v-else>
+ {{ format_number(interaction.hits) }}
+ </template>
+ </PulseTd>
+
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300 font-bold">
+ <span v-if="config.sample_rate < 1" :title="`Sample rate: ${config.sample_rate}, Raw value: ${format_number(interaction.misses)}`">
+ ~{{ format_number(interaction.misses * (1 / config.sample_rate)) }}
+ </span>
+ <template v-else>
+ {{ format_number(interaction.misses) }}
+ </template>
+ </PulseTd>
+
+ <PulseTd :numeric="true" class="text-gray-700 dark:text-gray-300 font-bold">
+ {{ Math.floor((interaction.hits / (interaction.hits + interaction.misses)) * 10000) / 100 }}%
+ </PulseTd>
+ </tr>
+ </template>
+ </tbody>
+ </PulseTable>
+ <div v-if="cacheKeyInteractions.length > 100" class="mt-2 text-xs text-neutral-400 text-center">Limited to 100 entries</div>
+ </div>
+ </div>
+ </PulseScroll>
+ </DashboardCard>
+</template>
diff --git a/resources/js/components/pulseCards/PulseExceptions.vue b/resources/js/components/pulseCards/PulseExceptions.vue
new file mode 100644
index 00000000..a6e6659f
--- /dev/null
+++ b/resources/js/components/pulseCards/PulseExceptions.vue
@@ -0,0 +1,138 @@
+<script setup lang="ts">
+import type { PulseResponse } from '@/types/pulseTypes';
+
+import { format_number, periodForHumans } from '@/service/pulseUtil';
+import { computed, ref } from 'vue';
+import { sortObject } from '@/service/sort/baseSort';
+import { toTimeSpan } from '@/service/util';
+
+import PulseNoResults from '@/components/pulse/PulseNoResults.vue';
+import DashboardCard from '@/components/cards/DashboardCard.vue';
+import PulseScroll from '@/components/pulse/PulseScroll.vue';
+import InputSelect from '@/components/pinesUI/InputSelect.vue';
+import IconBugAnt from '@/components/icons/IconBugAnt.vue';
+import PulseTable from '@/components/pulse/PulseTable.vue';
+import PulseThead from '@/components/pulse/PulseThead.vue';
+import PulseTd from '@/components/pulse/PulseTd.vue';
+import PulseTh from '@/components/pulse/PulseTh.vue';
+
+const validPeriods = ['1_hour', '6_hours', '24_hours', '7_days'];
+
+const exceptionOptions = [
+ { value: 'count', title: 'count' },
+ { value: 'latest', title: 'latest' },
+];
+
+const props = withDefaults(
+ defineProps<{
+ cols?: number | string;
+ rows?: number;
+ class?: string;
+ pulseData?: PulseResponse;
+ isLoading?: boolean;
+ period: string;
+ }>(),
+ {
+ cols: 'full',
+ rows: 4,
+ },
+);
+
+const sort = ref<{ value: 'count' | 'latest'; title: string }>({
+ value: 'count',
+ title: 'count',
+});
+
+const handleSetSort = (newSortKey: { value: 'count' | 'latest'; title: string }) => {
+ sort.value = newSortKey;
+};
+
+const exceptions = computed(() => {
+ const list = props.pulseData?.exceptions?.exceptions ?? [];
+ const sortKey = sort.value.value as keyof (typeof list)[0];
+
+ return [...list]
+ .map((val) => {
+ return { ...val, count: parseFloat(val.count) };
+ })
+ .sort(sortObject(sortKey, sortKey === 'count' ? -1 : 1, ['latest']));
+});
+</script>
+<template>
+ <DashboardCard
+ :rows="rows"
+ :cols="cols"
+ :class="props.class"
+ name="Exceptions"
+ :title="`Time: ${format_number(pulseData?.exceptions?.time ?? 0)}ms; Run at: ${pulseData?.exceptions?.runAt ? new Date(pulseData?.exceptions?.runAt).toLocaleDateString() : ''};`"
+ :details="`past ${validPeriods.indexOf(period) !== -1 ? periodForHumans(period) : periodForHumans(validPeriods[0])}`"
+ >
+ <template #icon>
+ <IconBugAnt />
+ </template>
+
+ <template #actions>
+ <label
+ class="capitalize whitespace-nowrap h-10 flex items-center justify-between w-full py-2 p-3 text-left rounded-l-md shadow-sm text-sm ring-inset ring-1 ring-neutral-200 dark:ring-neutral-700 text-gray-900 dark:text-neutral-100 bg-primary-800 dark:bg-neutral-900"
+ >Sort By</label
+ >
+ <InputSelect
+ :placeholder="'None'"
+ :options="exceptionOptions"
+ class="flex-1 rounded-l-none capitalize !w-full !whitespace-nowrap"
+ title="Select usage type"
+ @selectItem="handleSetSort"
+ :defaultItem="0"
+ />
+ </template>
+
+ <PulseScroll :expand="false" :loading="isLoading ?? false">
+ <div class="min-h-full flex flex-col">
+ <PulseNoResults v-if="exceptions.length === 0" />
+ <PulseTable v-else>
+ <colgroup>
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <PulseThead>
+ <tr>
+ <PulseTh class="text-left">Type</PulseTh>
+ <PulseTh class="text-right">Latest</PulseTh>
+ <PulseTh class="text-right">Count</PulseTh>
+ </tr>
+ </PulseThead>
+ <tbody class="">
+ <template v-for="(exception, index) in exceptions.slice(0, 100)" :key="index">
+ <tr class="h-2 first:h-0"></tr>
+ <tr>
+ <PulseTd class="max-w-[1px]">
+ <code class="block text-xs text-neutral-900 dark:text-neutral-100 truncate" :title="exception.class">
+ {{ exception.class }}
+ </code>
+ <p class="mt-1 text-xs text-neutral-500 dark:text-neutral-400 truncate" :title="exception.location">
+ {{ exception.location }}
+ </p>
+ </PulseTd>
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300 font-bold">
+ {{ toTimeSpan(new Date(exception.latest), ' EST', true) }}
+ </PulseTd>
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300 font-bold">
+ <span
+ v-if="pulseData?.exceptions?.config.sample_rate && pulseData.exceptions.config.sample_rate < 1"
+ :title="`Sample rate: ${pulseData?.exceptions?.config.sample_rate}, Raw value: ${format_number(exception.count)}`"
+ >~{{ format_number(exception.count * (1 / pulseData.exceptions.config.sample_rate)) }}</span
+ >
+ <template v-else>
+ {{ format_number(exception.count) }}
+ </template>
+ </PulseTd>
+ </tr>
+ </template>
+ </tbody>
+ </PulseTable>
+ <div v-if="exceptions.length > 100" class="mt-2 text-xs text-neutral-400 text-center">Limited to 100 entries</div>
+ </div>
+ </PulseScroll>
+ </DashboardCard>
+</template>
diff --git a/resources/js/components/pulseCards/PulseQueues.vue b/resources/js/components/pulseCards/PulseQueues.vue
index 07935cda..9bcfb5fd 100644
--- a/resources/js/components/pulseCards/PulseQueues.vue
+++ b/resources/js/components/pulseCards/PulseQueues.vue
@@ -1,8 +1,8 @@
<script setup lang="ts">
-import type { PulseQueueResponse, PulseResponse } from '@/types/types';
+import type { PulseResponse } from '@/types/pulseTypes';
import { format_number, periodForHumans, pulseFormatDate, getMaxReading } from '@/service/pulseUtil';
-import { ref, watch } from 'vue';
+import { computed } from 'vue';
import PulseLineChart from '@/components/charts/PulseLineChart.vue';
import PulseNoResults from '@/components/pulse/PulseNoResults.vue';
@@ -27,20 +27,12 @@ const props = withDefaults(
},
);
-const queues = ref<{ [key: string]: PulseQueueResponse }>();
-
+const queues = computed(() => {
+ return props.pulseData?.queues?.queues ?? {};
+});
function scale(data: { [key: string]: any }) {
return Object.values(data).map((value) => value * (1 / (props.pulseData?.queues?.config.sample_rate ?? 1)));
}
-
-watch(
- () => props.pulseData,
- () => {
- if (props.pulseData?.queues) {
- queues.value = props.pulseData.queues.queues;
- }
- },
-);
</script>
<template>
<DashboardCard
@@ -54,155 +46,151 @@ watch(
<IconQueueList />
</template>
<template #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="flex flex-wrap gap-4 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div class="flex items-center gap-2">
<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="flex items-center gap-2">
<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="flex items-center gap-2 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="flex items-center gap-2">
<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="flex items-center gap-2">
<div class="h-0.5 w-3 rounded-full bg-[#e11d48]"></div>
Failed
</div>
</div>
</template>
- <template #slot>
- <PulseScroll :expand="true" :loading="isLoading ?? true">
- <template #slot>
- <PulseNoResults v-if="!queues || (Object.keys(queues)?.length ?? 0) == 0" />
- <div v-else-if="queues" class="grid gap-3 mx-px mb-px">
- <div v-for="queue in Object.keys(queues)" :key="queue">
- <h3 class="font-bold text-gray-700 dark:text-gray-300">
- <template v-if="pulseData?.queues?.showConnection">
- {{ queue }}
- </template>
- <template v-else>
- {{ queue.substring(queue.indexOf(':') + 1) }}
- </template>
- </h3>
- <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"
- >
- <span
- v-if="pulseData?.queues?.config.sample_rate && pulseData.queues.config.sample_rate < 1"
- :title="`Sample rate: ${pulseData.queues.config.sample_rate}, Raw value: ${format_number(getMaxReading(queues[queue]))}`"
- >~{{ format_number(getMaxReading(queues[queue]) * (1 / pulseData.queues.config.sample_rate)) }}</span
- >
- <template v-else>
- {{ format_number(getMaxReading(queues[queue])) }}
- </template>
- </div>
+ <PulseScroll :expand="true" :loading="isLoading ?? true">
+ <PulseNoResults v-if="!queues || (Object.keys(queues)?.length ?? 0) == 0" />
+ <div v-else-if="queues" class="grid gap-3 mx-px mb-px">
+ <div v-for="queue in Object.keys(queues)" :key="queue">
+ <h3 class="font-bold text-neutral-700 dark:text-neutral-300">
+ <template v-if="pulseData?.queues?.showConnection">
+ {{ queue }}
+ </template>
+ <template v-else>
+ {{ queue.substring(queue.indexOf(':') + 1) }}
+ </template>
+ </h3>
+ <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"
+ >
+ <span
+ v-if="pulseData?.queues?.config.sample_rate && pulseData.queues.config.sample_rate < 1"
+ :title="`Sample rate: ${pulseData.queues.config.sample_rate}, Raw value: ${format_number(getMaxReading(queues[queue]))}`"
+ >~{{ format_number(getMaxReading(queues[queue]) * (1 / pulseData.queues.config.sample_rate)) }}</span
+ >
+ <template v-else>
+ {{ format_number(getMaxReading(queues[queue])) }}
+ </template>
+ </div>
- <div class="h-14">
- <PulseLineChart
- :class="' dark:!bg-primary-dark-800 !bg-primary-900 '"
- :chart-data="{
- labels: Object.keys(queues[queue].queued).map((v) => pulseFormatDate(v)),
- datasets: [
- {
- label: 'Queued',
- borderColor: 'rgba(107,114,128,0.5)',
- data: scale(queues[queue].queued),
- order: 4,
- },
- {
- label: 'Processing',
- borderColor: 'rgba(147,51,234,0.5)',
- data: scale(queues[queue].processing),
- order: 3,
- },
- {
- label: 'Released',
- borderColor: '#eab308',
- data: scale(queues[queue].released),
- order: 2,
- },
- {
- label: 'Processed',
- borderColor: '#9333ea',
- data: scale(queues[queue].processed),
- order: 1,
- },
- {
- label: 'Failed',
- borderColor: '#e11d48',
- data: scale(queues[queue].failed),
- order: 0,
- },
- ],
- }"
- :chart-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: any) => (ctx.p0.raw === 0 && ctx.p1.raw === 0 ? 'transparent' : undefined),
- },
- },
- },
- scales: {
- x: {
- display: false,
- },
- y: {
- display: false,
- min: 0,
- max: getMaxReading(queues[queue]),
- },
+ <div class="h-14">
+ <PulseLineChart
+ :class="' dark:!bg-primary-dark-800 !bg-primary-900 '"
+ :chart-data="{
+ labels: Object.keys(queues[queue].queued).map((v) => pulseFormatDate(v)),
+ datasets: [
+ {
+ label: 'Queued',
+ borderColor: 'rgba(107,114,128,0.5)',
+ data: scale(queues[queue].queued),
+ order: 4,
+ },
+ {
+ label: 'Processing',
+ borderColor: 'rgba(147,51,234,0.5)',
+ data: scale(queues[queue].processing),
+ order: 3,
+ },
+ {
+ label: 'Released',
+ borderColor: '#eab308',
+ data: scale(queues[queue].released),
+ order: 2,
+ },
+ {
+ label: 'Processed',
+ borderColor: '#9333ea',
+ data: scale(queues[queue].processed),
+ order: 1,
+ },
+ {
+ label: 'Failed',
+ borderColor: '#e11d48',
+ data: scale(queues[queue].failed),
+ order: 0,
+ },
+ ],
+ }"
+ :chart-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: any) => (ctx.p0.raw === 0 && ctx.p1.raw === 0 ? 'transparent' : undefined),
},
- plugins: {
- legend: {
- display: false,
- },
- tooltip: {
- mode: 'index',
- position: 'nearest',
- intersect: false,
- callbacks: {
- beforeBody: (context: any[]) => {
- return context
- .map((item) => {
- return `${item.dataset.label}: ${(pulseData?.queues?.config.sample_rate ?? 2) < 1 ? '~' : ''}${item.formattedValue}`;
- })
- .join(', ');
- },
- label: () => null,
- },
+ },
+ },
+ scales: {
+ x: {
+ display: false,
+ },
+ y: {
+ display: false,
+ min: 0,
+ max: getMaxReading(queues[queue]),
+ },
+ },
+ plugins: {
+ legend: {
+ display: false,
+ },
+ tooltip: {
+ mode: 'index',
+ position: 'nearest',
+ intersect: false,
+ callbacks: {
+ beforeBody: (context: any[]) => {
+ return context
+ .map((item) => {
+ return `${item.dataset.label}: ${(pulseData?.queues?.config.sample_rate ?? 2) < 1 ? '~' : ''}${item.formattedValue}`;
+ })
+ .join(', ');
},
+ label: () => null,
},
- }"
- />
- </div>
- </div>
+ },
+ },
+ }"
+ />
</div>
</div>
- </template>
- </PulseScroll>
- </template>
+ </div>
+ </div>
+ </PulseScroll>
</DashboardCard>
</template>
diff --git a/resources/js/components/pulseCards/PulseRequests.vue b/resources/js/components/pulseCards/PulseRequests.vue
index 4a258726..ab0f31c6 100644
--- a/resources/js/components/pulseCards/PulseRequests.vue
+++ b/resources/js/components/pulseCards/PulseRequests.vue
@@ -1,8 +1,8 @@
<script setup lang="ts">
-import type { PulseResponse, PulseRquestsResponse } from '@/types/types';
+import type { PulseResponse } from '@/types/pulseTypes';
import { format_number, periodForHumans, pulseFormatDate, getMaxReading } from '@/service/pulseUtil';
-import { ref, watch } from 'vue';
+import { computed } from 'vue';
import IconArrowsLeftRight from '@/components/icons/IconArrowsLeftRight.vue';
import PulseLineChart from '@/components/charts/PulseLineChart.vue';
@@ -17,7 +17,7 @@ const props = withDefaults(
cols?: number | string;
rows?: number;
class?: string;
- pulseData?: PulseResponse;
+ pulseData: PulseResponse;
isLoading?: boolean;
period: string;
}>(),
@@ -27,20 +27,17 @@ const props = withDefaults(
},
);
-const requests = ref<{ [key: string]: PulseRquestsResponse }>();
+const requests = computed(() => {
+ return props.pulseData?.requests.requests ?? {};
+});
+
+const config = computed(() => {
+ return props.pulseData.requests.config;
+});
function scale(data: { [key: string]: any }) {
- return Object.values(data).map((value) => value * (1 / (props.pulseData?.requests?.config.sample_rate ?? 1)));
+ return Object.values(data).map((value) => value * (1 / (config.value.sample_rate ?? 1)));
}
-
-watch(
- () => props.pulseData,
- () => {
- if (props.pulseData?.requests) {
- requests.value = props.pulseData.requests.requests;
- }
- },
-);
</script>
<template>
<DashboardCard
@@ -55,141 +52,137 @@ watch(
</template>
<template #actions>
<div class="flex flex-wrap gap-4">
- <div v-if="pulseData?.requests?.config.record_informational" class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div v-if="config.record_informational" 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" style="background-color: rgba(29, 153, 172, 0.5)"></div>
Informational
</div>
- <div v-if="pulseData?.requests?.config.record_successful" class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div v-if="config.record_successful" 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>
Successful
</div>
- <div v-if="pulseData?.requests?.config.record_redirection" class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div v-if="config.record_redirection" 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>
Redirection
</div>
- <div v-if="pulseData?.requests?.config.record_client_error" class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div v-if="config.record_client_error" 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>
Client Error
</div>
- <div v-if="pulseData?.requests?.config.record_server_error" class="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 font-medium">
+ <div v-if="config.record_server_error" 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>
Server Error
</div>
</div>
</template>
- <template #slot>
- <PulseScroll :expand="true" :loading="isLoading ?? true">
- <template #slot>
- <PulseNoResults v-if="!requests || (Object.keys(requests)?.length ?? 0) == 0" />
- <div v-else-if="requests" class="grid gap-3 mx-px mb-px">
- <div v-for="request in Object.keys(requests)" :key="request">
- <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"
- >
- <span
- v-if="pulseData?.requests?.config.sample_rate && pulseData.requests.config.sample_rate < 1"
- :title="`Sample rate: ${pulseData.requests.config.sample_rate}, Raw value: ${format_number(getMaxReading(requests[request]))}`"
- >~{{ format_number(getMaxReading(requests[request]) * (1 / pulseData.requests.config.sample_rate)) }}</span
- >
- <template v-else>
- {{ format_number(getMaxReading(requests[request])) }}
- </template>
- </div>
+ <PulseScroll :expand="true" :loading="isLoading ?? true">
+ <PulseNoResults v-if="!requests || (Object.keys(requests)?.length ?? 0) == 0" />
+ <div v-else-if="requests" class="grid gap-3 mx-px mb-px">
+ <div v-for="request in Object.keys(requests)" :key="request">
+ <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"
+ >
+ <span
+ v-if="config.sample_rate && pulseData.requests.config.sample_rate < 1"
+ :title="`Sample rate: ${pulseData.requests.config.sample_rate}, Raw value: ${format_number(getMaxReading(requests[request]))}`"
+ >~{{ format_number(getMaxReading(requests[request]) * (1 / pulseData.requests.config.sample_rate)) }}</span
+ >
+ <template v-else>
+ {{ format_number(getMaxReading(requests[request])) }}
+ </template>
+ </div>
- <div class="h-14">
- <PulseLineChart
- :class="' dark:!bg-primary-dark-800 !bg-primary-900 '"
- :chart-data="{
- labels: Object.keys(requests[request][Object.keys(requests[request])[0]]).map((v) => pulseFormatDate(v)),
- datasets: [
- {
- label: 'Server Error',
- borderColor: '#e11d48',
- data: scale(requests[request].server_error),
- },
- {
- label: 'Client Error',
- borderColor: '#eab308',
- data: scale(requests[request].client_error),
- },
- {
- label: 'Successful',
- borderColor: '#9333ea',
- data: scale(requests[request].successful),
- },
- {
- label: 'Informational',
- borderColor: 'rgba(29,153,172,0.5)',
- data: scale(requests[request].informational),
- },
- {
- label: 'Redirection',
- borderColor: 'rgba(107,114,128,0.5)',
- data: scale(requests[request].redirection),
- },
- ],
- }"
- :chart-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: any) => (ctx.p0.raw === 0 && ctx.p1.raw === 0 ? 'transparent' : undefined),
- },
- },
- },
- scales: {
- x: {
- display: false,
- },
- y: {
- display: false,
- min: 0,
- max: getMaxReading(requests[request]),
- },
+ <div class="h-14">
+ <PulseLineChart
+ :class="' dark:!bg-primary-dark-800 !bg-primary-900 '"
+ :chart-data="{
+ labels: Object.keys(requests[request][Object.keys(requests[request])[0]]).map((v) => pulseFormatDate(v)),
+ datasets: [
+ {
+ label: 'Server Error',
+ borderColor: '#e11d48',
+ data: scale(requests[request].server_error),
+ },
+ {
+ label: 'Client Error',
+ borderColor: '#eab308',
+ data: scale(requests[request].client_error),
+ },
+ {
+ label: 'Successful',
+ borderColor: '#9333ea',
+ data: scale(requests[request].successful),
+ },
+ {
+ label: 'Informational',
+ borderColor: 'rgba(29,153,172,0.5)',
+ data: scale(requests[request].informational),
+ },
+ {
+ label: 'Redirection',
+ borderColor: 'rgba(107,114,128,0.5)',
+ data: scale(requests[request].redirection),
+ },
+ ],
+ }"
+ :chart-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: any) => (ctx.p0.raw === 0 && ctx.p1.raw === 0 ? 'transparent' : undefined),
},
- plugins: {
- legend: {
- display: false,
- },
- tooltip: {
- mode: 'index',
- position: 'nearest',
- intersect: false,
- callbacks: {
- beforeBody: (context: any[]) => {
- return context
- .map((item) => {
- return `${item.dataset.label}: ${(pulseData?.queues?.config.sample_rate ?? 2) < 1 ? '~' : ''}${item.formattedValue}`;
- })
- .join(', ');
- },
- label: () => null,
- },
+ },
+ },
+ scales: {
+ x: {
+ display: false,
+ },
+ y: {
+ display: false,
+ min: 0,
+ max: getMaxReading(requests[request]),
+ },
+ },
+ plugins: {
+ legend: {
+ display: false,
+ },
+ tooltip: {
+ mode: 'index',
+ position: 'nearest',
+ intersect: false,
+ callbacks: {
+ beforeBody: (context: any[]) => {
+ return context
+ .map((item) => {
+ return `${item.dataset.label}: ${(pulseData?.queues?.config.sample_rate ?? 2) < 1 ? '~' : ''}${item.formattedValue}`;
+ })
+ .join(', ');
},
+ label: () => null,
},
- }"
- />
- </div>
- </div>
+ },
+ },
+ }"
+ />
</div>
</div>
- </template>
- </PulseScroll>
- </template>
+ </div>
+ </div>
+ </PulseScroll>
</DashboardCard>
</template>
diff --git a/resources/js/components/pulseCards/PulseServers.vue b/resources/js/components/pulseCards/PulseServers.vue
index 996d8a93..dff50715 100644
--- a/resources/js/components/pulseCards/PulseServers.vue
+++ b/resources/js/components/pulseCards/PulseServers.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import type { PulseResponse, PulseServerResponse } from '@/types/types.ts';
+import type { PulseResponse, PulseServerResponse } from '@/types/pulseTypes';
import { format_number, friendlyFileSize } from '@/service/pulseUtil';
import { toTimeSpan } from '@/service/util';
diff --git a/resources/js/components/pulseCards/PulseSlowJobs.vue b/resources/js/components/pulseCards/PulseSlowJobs.vue
new file mode 100644
index 00000000..2c7fda2e
--- /dev/null
+++ b/resources/js/components/pulseCards/PulseSlowJobs.vue
@@ -0,0 +1,136 @@
+<script setup lang="ts">
+import type { PulseResponse } from '@/types/pulseTypes';
+
+import { format_number, periodForHumans } from '@/service/pulseUtil';
+import { computed, ref } from 'vue';
+import { sortObject } from '@/service/sort/baseSort';
+
+import IconCommandLine from '@/components/icons/IconCommandLine.vue';
+import PulseNoResults from '@/components/pulse/PulseNoResults.vue';
+import DashboardCard from '@/components/cards/DashboardCard.vue';
+import PulseScroll from '@/components/pulse/PulseScroll.vue';
+import InputSelect from '@/components/pinesUI/InputSelect.vue';
+import PulseTable from '@/components/pulse/PulseTable.vue';
+import PulseThead from '@/components/pulse/PulseThead.vue';
+import PulseTd from '@/components/pulse/PulseTd.vue';
+import PulseTh from '@/components/pulse/PulseTh.vue';
+
+const validPeriods = ['1_hour', '6_hours', '24_hours', '7_days'];
+
+const exceptionOptions = [
+ { value: 'slowest', title: 'slowest' },
+ { value: 'count', title: 'count' },
+];
+
+const props = withDefaults(
+ defineProps<{
+ cols?: number | string;
+ rows?: number;
+ class?: string;
+ pulseData: PulseResponse;
+ isLoading?: boolean;
+ period: string;
+ }>(),
+ {
+ cols: 'full',
+ rows: 4,
+ },
+);
+
+const sort = ref<{ value: 'count' | 'slowest'; title: string }>({
+ value: 'slowest',
+ title: 'slowest',
+});
+
+const handleSetSort = (newSortKey: { value: 'count' | 'slowest'; title: string }) => {
+ sort.value = newSortKey;
+};
+
+const slowJobs = computed(() => {
+ const list = props.pulseData.slow_jobs.slowJobs ?? [];
+ const sortKey = sort.value.value as keyof (typeof list)[0];
+
+ return [...list].sort(sortObject(sortKey, -1, []));
+});
+
+const config = computed(() => {
+ return props.pulseData.slow_jobs.config;
+});
+</script>
+<template>
+ <DashboardCard
+ :rows="rows"
+ :cols="cols"
+ :class="props.class"
+ name="Slow Jobs"
+ :title="`Time: ${format_number(pulseData.slow_jobs.time ?? 0)}ms; Run at: ${pulseData.slow_jobs.runAt ? new Date(pulseData.slow_jobs.runAt).toLocaleDateString() : ''};`"
+ :details="`${config.threshold ?? 1000}ms threshold, past ${validPeriods.indexOf(period) !== -1 ? periodForHumans(period) : periodForHumans(validPeriods[0])}`"
+ >
+ <template #icon>
+ <IconCommandLine />
+ </template>
+
+ <template #actions>
+ <label
+ class="capitalize whitespace-nowrap h-10 flex items-center justify-between w-full py-2 p-3 text-left rounded-l-md shadow-sm text-sm ring-inset ring-1 ring-neutral-200 dark:ring-neutral-700 text-neutral-900 dark:text-neutral-100 bg-primary-800 dark:bg-neutral-900"
+ >Sort By</label
+ >
+ <InputSelect
+ :placeholder="'None'"
+ :options="exceptionOptions"
+ class="flex-1 rounded-l-none capitalize !w-full !whitespace-nowrap"
+ title="Select usage type"
+ @selectItem="handleSetSort"
+ :defaultItem="0"
+ />
+ </template>
+
+ <PulseScroll :expand="false" :loading="isLoading ?? false">
+ <div class="min-h-full flex flex-col">
+ <PulseNoResults v-if="slowJobs.length === 0" />
+ <PulseTable v-else>
+ <colgroup>
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <PulseThead>
+ <tr>
+ <PulseTh class="text-left">job</PulseTh>
+ <PulseTh class="text-right">Count</PulseTh>
+ <PulseTh class="text-right">Slowest</PulseTh>
+ </tr>
+ </PulseThead>
+ <tbody class="">
+ <template v-for="(slowJob, index) in slowJobs.slice(0, 100)" :key="index">
+ <tr class="h-2 first:h-0"></tr>
+ <tr>
+ <PulseTd class="max-w-[1px]">
+ <code class="block text-xs text-gray-900 dark:text-gray-100 truncate" :title="slowJob.job">
+ {{ slowJob.job }}
+ </code>
+ <p v-if="Array.isArray(config?.threshold)" class="mt-1 text-xs text-gray-500 dark:text-gray-400">{{ slowJob.threshold }}ms threshold</p>
+ </PulseTd>
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300 font-bold">
+ <span v-if="config.sample_rate < 1" :title="`Sample rate: ${config.sample_rate}, Raw value: ${format_number(slowJob.count)}`"
+ >~{{ format_number(slowJob.count * (1 / config.sample_rate)) }}</span
+ >
+ <template v-else>
+ {{ format_number(slowJob.count) }}
+ </template>
+ </PulseTd>
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300">
+ <strong v-if="!slowJob.slowest">Unknown</strong>
+ <template v-else>
+ <strong>{{ format_number(slowJob.slowest) ?? '<1' }}</strong> ms
+ </template>
+ </PulseTd>
+ </tr>
+ </template>
+ </tbody>
+ </PulseTable>
+ <div v-if="slowJobs.length > 100" class="mt-2 text-xs text-neutral-400 text-center">Limited to 100 entries</div>
+ </div>
+ </PulseScroll>
+ </DashboardCard>
+</template>
diff --git a/resources/js/components/pulseCards/PulseSlowOutgoingRequests.vue b/resources/js/components/pulseCards/PulseSlowOutgoingRequests.vue
new file mode 100644
index 00000000..ce51891b
--- /dev/null
+++ b/resources/js/components/pulseCards/PulseSlowOutgoingRequests.vue
@@ -0,0 +1,168 @@
+<script setup lang="ts">
+import type { PulseResponse } from '@/types/pulseTypes';
+
+import { format_number, periodForHumans } from '@/service/pulseUtil';
+import { computed, ref } from 'vue';
+import { sortObject } from '@/service/sort/baseSort';
+
+import IconInformationCircle from '@/components/icons/IconInformationCircle.vue';
+import PulseHttpMethodBadge from '@/components/pulse/PulseHttpMethod-Badge.vue';
+import IconCloudArrowUp from '@/components/icons/IconCloudArrowUp.vue';
+import PulseNoResults from '@/components/pulse/PulseNoResults.vue';
+import DashboardCard from '@/components/cards/DashboardCard.vue';
+import PulseScroll from '@/components/pulse/PulseScroll.vue';
+import InputSelect from '@/components/pinesUI/InputSelect.vue';
+import PulseTable from '@/components/pulse/PulseTable.vue';
+import PulseThead from '@/components/pulse/PulseThead.vue';
+import PulseTd from '@/components/pulse/PulseTd.vue';
+import PulseTh from '@/components/pulse/PulseTh.vue';
+
+const validPeriods = ['1_hour', '6_hours', '24_hours', '7_days'];
+
+const exceptionOptions = [
+ { value: 'slowest', title: 'slowest' },
+ { value: 'count', title: 'count' },
+];
+
+const props = withDefaults(
+ defineProps<{
+ cols?: number | string;
+ rows?: number;
+ class?: string;
+ pulseData: PulseResponse;
+ isLoading?: boolean;
+ period: string;
+ }>(),
+ {
+ cols: 'full',
+ rows: 4,
+ },
+);
+
+const sort = ref<{ value: 'count' | 'slowest'; title: string }>({
+ value: 'slowest',
+ title: 'slowest',
+});
+
+const handleSetSort = (newSortKey: { value: 'count' | 'slowest'; title: string }) => {
+ sort.value = newSortKey;
+};
+
+const slowOutgoingRequests = computed(() => {
+ const list = props.pulseData.slow_outgoing_requests?.slowOutgoingRequests ?? [];
+ const sortKey = sort.value.value as keyof (typeof list)[0];
+
+ return [...list].sort(sortObject(sortKey, -1, []));
+});
+
+const config = computed(() => {
+ return props.pulseData.slow_outgoing_requests.config;
+});
+
+function getDomainFromUrl(input: string): string | null {
+ try {
+ return new URL(input).hostname;
+ } catch {
+ return null;
+ }
+}
+</script>
+<template>
+ <DashboardCard
+ :rows="rows"
+ :cols="cols"
+ :class="props.class"
+ name="Slow Outgoing Requests"
+ :title="`Time: ${format_number(pulseData.slow_outgoing_requests?.time ?? 0)}ms; Run at: ${pulseData.slow_outgoing_requests?.runAt ? new Date(pulseData.slow_outgoing_requests?.runAt).toLocaleDateString() : ''};`"
+ :details="`${config?.threshold ?? 1000}ms threshold, past ${validPeriods.indexOf(period) !== -1 ? periodForHumans(period) : periodForHumans(validPeriods[0])}`"
+ >
+ <template #icon>
+ <IconCloudArrowUp />
+ </template>
+
+ <template #actions>
+ <button
+ :title="`URIs may be normalized using groups.\n\nThere ${config.groups.length === 1 ? 'is' : 'are'} currently ${config.groups.length} ${config.groups.length === 1 ? 'group' : 'groups'} configured.`"
+ >
+ <IconInformationCircle class="w-5 h-5 stroke-gray-400 dark:stroke-gray-600" />
+ </button>
+ <label
+ class="capitalize whitespace-nowrap h-10 flex items-center justify-between w-full py-2 p-3 text-left rounded-l-md shadow-sm text-sm ring-inset ring-1 ring-neutral-200 dark:ring-neutral-700 text-neutral-900 dark:text-neutral-100 bg-primary-800 dark:bg-neutral-900"
+ >Sort By</label
+ >
+ <InputSelect
+ :placeholder="'None'"
+ :options="exceptionOptions"
+ class="flex-1 rounded-l-none capitalize !w-full !whitespace-nowrap"
+ title="Select usage type"
+ @selectItem="handleSetSort"
+ :defaultItem="0"
+ />
+ </template>
+
+ <PulseScroll :expand="false" :loading="isLoading ?? false">
+ <div class="min-h-full flex flex-col">
+ <PulseNoResults v-if="slowOutgoingRequests.length === 0" />
+ <PulseTable v-else>
+ <colgroup>
+ <col width="0%" />
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <PulseThead>
+ <tr>
+ <PulseTh class="text-left">Method</PulseTh>
+ <PulseTh class="text-left">URI</PulseTh>
+ <PulseTh class="text-right">Count</PulseTh>
+ <PulseTh class="text-right">Slowest</PulseTh>
+ </tr>
+ </PulseThead>
+ <tbody class="">
+ <template v-for="(slowRequest, index) in slowOutgoingRequests.slice(0, 100)" :key="index">
+ <tr class="h-2 first:h-0"></tr>
+ <tr>
+ <PulseTd>
+ <PulseHttpMethodBadge :method="slowRequest.method" />
+ </PulseTd>
+ <PulseTd class="max-w-[1px]">
+ <div class="flex items-center" :title="slowRequest.uri">
+ <img
+ v-once
+ v-if="getDomainFromUrl(slowRequest.uri)"
+ :src="`https://unavatar.io/${getDomainFromUrl(slowRequest.uri)}?fallback=false`"
+ loading="lazy"
+ class="w-4 h-4 mr-2"
+ onerror="this.style.display='none'"
+ />
+ <code class="block text-xs text-gray-900 dark:text-gray-100 truncate">
+ {{ slowRequest.uri }}
+ </code>
+ </div>
+ <p v-if="Array.isArray(config?.threshold)" class="mt-1 text-xs text-neutral-500 dark:text-neutral-400">
+ {{ slowRequest.threshold }}ms threshold
+ </p>
+ </PulseTd>
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300 font-bold">
+ <span v-if="config.sample_rate < 1" :title="`Sample rate: ${config.sample_rate}, Raw value: ${format_number(slowRequest.count)}`">
+ ~{{ format_number(slowRequest.count * (1 / config.sample_rate)) }}
+ </span>
+ <template v-else>
+ {{ format_number(slowRequest.count) }}
+ </template>
+ </PulseTd>
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300">
+ <strong v-if="!slowRequest.slowest">Unknown</strong>
+ <template v-else>
+ <strong>{{ format_number(slowRequest.slowest) ?? '<1' }}</strong> ms
+ </template>
+ </PulseTd>
+ </tr>
+ </template>
+ </tbody>
+ </PulseTable>
+ <div v-if="slowOutgoingRequests.length > 100" class="mt-2 text-xs text-neutral-400 text-center">Limited to 100 entries</div>
+ </div>
+ </PulseScroll>
+ </DashboardCard>
+</template>
diff --git a/resources/js/components/pulseCards/PulseSlowQueries.vue b/resources/js/components/pulseCards/PulseSlowQueries.vue
new file mode 100644
index 00000000..060ce7f5
--- /dev/null
+++ b/resources/js/components/pulseCards/PulseSlowQueries.vue
@@ -0,0 +1,155 @@
+<script setup lang="ts">
+import type { PulseResponse } from '@/types/pulseTypes';
+
+import { format_number, periodForHumans } from '@/service/pulseUtil';
+import { computed, ref } from 'vue';
+import { sortObject } from '@/service/sort/baseSort';
+
+import IconCircleStack from '@/components/icons/IconCircleStack.vue';
+import PulseNoResults from '@/components/pulse/PulseNoResults.vue';
+import DashboardCard from '@/components/cards/DashboardCard.vue';
+import PulseScroll from '@/components/pulse/PulseScroll.vue';
+import InputSelect from '@/components/pinesUI/InputSelect.vue';
+import PulseTable from '@/components/pulse/PulseTable.vue';
+import PulseThead from '@/components/pulse/PulseThead.vue';
+import PulseTd from '@/components/pulse/PulseTd.vue';
+import PulseTh from '@/components/pulse/PulseTh.vue';
+
+const validPeriods = ['1_hour', '6_hours', '24_hours', '7_days'];
+
+const exceptionOptions = [
+ { value: 'slowest', title: 'slowest' },
+ { value: 'count', title: 'count' },
+];
+
+const props = withDefaults(
+ defineProps<{
+ cols?: number | string;
+ rows?: number;
+ class?: string;
+ pulseData: PulseResponse;
+ isLoading?: boolean;
+ period: string;
+ }>(),
+ {
+ cols: 'full',
+ rows: 4,
+ },
+);
+
+const sort = ref<{ value: 'count' | 'slowest'; title: string }>({
+ value: 'slowest',
+ title: 'slowest',
+});
+
+const handleSetSort = (newSortKey: { value: 'count' | 'slowest'; title: string }) => {
+ sort.value = newSortKey;
+};
+
+const slowQueries = computed(() => {
+ const list = props.pulseData.slow_queries.slowQueries ?? [];
+ const sortKey = sort.value.value as keyof (typeof list)[0];
+
+ return [...list].sort(sortObject(sortKey, -1, []));
+});
+
+const config = computed(() => {
+ return props.pulseData.slow_queries.config;
+});
+</script>
+<template>
+ <DashboardCard
+ :rows="rows"
+ :cols="cols"
+ :class="props.class"
+ name="Slow Queries"
+ :title="`Time: ${format_number(pulseData.slow_queries.time ?? 0)}ms; Run at: ${pulseData.slow_queries.runAt ? new Date(pulseData.slow_queries.runAt).toLocaleDateString() : ''};`"
+ :details="`${config.threshold ?? 1000}ms threshold, past ${validPeriods.indexOf(period) !== -1 ? periodForHumans(period) : periodForHumans(validPeriods[0])}`"
+ >
+ <template #icon>
+ <IconCircleStack />
+ </template>
+
+ <template #actions>
+ <label
+ class="capitalize whitespace-nowrap h-10 flex items-center justify-between w-full py-2 p-3 text-left rounded-l-md shadow-sm text-sm ring-inset ring-1 ring-neutral-200 dark:ring-neutral-700 text-neutral-900 dark:text-neutral-100 bg-primary-800 dark:bg-neutral-900"
+ >
+ Sort By
+ </label>
+ <InputSelect
+ :placeholder="'None'"
+ :options="exceptionOptions"
+ class="flex-1 rounded-l-none capitalize !w-full !whitespace-nowrap"
+ title="Select usage type"
+ @selectItem="handleSetSort"
+ :defaultItem="0"
+ />
+ </template>
+
+ <PulseScroll :expand="false" :loading="isLoading ?? false">
+ <div class="min-h-full flex flex-col">
+ <PulseNoResults v-if="slowQueries.length === 0" />
+ <PulseTable v-else>
+ <colgroup>
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <PulseThead>
+ <tr>
+ <PulseTh class="text-left">Query</PulseTh>
+ <PulseTh class="text-right">Count</PulseTh>
+ <PulseTh class="text-right">Slowest</PulseTh>
+ </tr>
+ </PulseThead>
+ <tbody class="">
+ <template v-for="(query, index) in slowQueries.slice(0, 100)" :key="index">
+ <tr class="h-2 first:h-0"></tr>
+ <tr>
+ <PulseTd 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="whitespace-nowrap px-3" v-html="query.sql"></code>
+ <p v-if="query.location" class="px-3 mt-3 leading-none text-gray-400 dark:text-gray-500">
+ {{ query.location }}
+ </p>
+ <p v-if="Array.isArray(config?.threshold)" class="px-3 mt-3 leading-none text-gray-400 dark:text-gray-500">
+ {{ query.threshold }}ms threshold
+ </p>
+ </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>
+ </PulseTd>
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300 font-bold">
+ <span v-if="config.sample_rate < 1" :title="`Sample rate: ${config.sample_rate}, Raw value: ${format_number(query.count)}`">
+ ~{{ format_number(query.count * (1 / config.sample_rate)) }}
+ </span>
+ <template v-else>
+ {{ format_number(query.count) }}
+ </template>
+ </PulseTd>
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300">
+ <strong v-if="!query.slowest">Unknown</strong>
+ <template v-else>
+ <strong>{{ format_number(query.slowest) ?? '<1' }}</strong> ms
+ </template>
+ </PulseTd>
+ </tr>
+ </template>
+ </tbody>
+ </PulseTable>
+ <div v-if="slowQueries.length > 100" class="mt-2 text-xs text-neutral-400 text-center">Limited to 100 entries</div>
+ </div>
+ </PulseScroll>
+ </DashboardCard>
+</template>
+
+@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
diff --git a/resources/js/components/pulseCards/PulseSlowRequests.vue b/resources/js/components/pulseCards/PulseSlowRequests.vue
new file mode 100644
index 00000000..28d425ad
--- /dev/null
+++ b/resources/js/components/pulseCards/PulseSlowRequests.vue
@@ -0,0 +1,147 @@
+<script setup lang="ts">
+import type { PulseResponse } from '@/types/pulseTypes';
+
+import { format_number, periodForHumans } from '@/service/pulseUtil';
+import { computed, ref } from 'vue';
+import { sortObject } from '@/service/sort/baseSort';
+
+import PulseHttpMethodBadge from '@/components/pulse/PulseHttpMethod-Badge.vue';
+import IconArrowsLeftRight from '@/components/icons/IconArrowsLeftRight.vue';
+import PulseNoResults from '@/components/pulse/PulseNoResults.vue';
+import DashboardCard from '@/components/cards/DashboardCard.vue';
+import PulseScroll from '@/components/pulse/PulseScroll.vue';
+import InputSelect from '@/components/pinesUI/InputSelect.vue';
+import PulseTable from '@/components/pulse/PulseTable.vue';
+import PulseThead from '@/components/pulse/PulseThead.vue';
+import PulseTd from '@/components/pulse/PulseTd.vue';
+import PulseTh from '@/components/pulse/PulseTh.vue';
+
+const validPeriods = ['1_hour', '6_hours', '24_hours', '7_days'];
+
+const exceptionOptions = [
+ { value: 'slowest', title: 'slowest' },
+ { value: 'count', title: 'count' },
+];
+
+const props = withDefaults(
+ defineProps<{
+ cols?: number | string;
+ rows?: number;
+ class?: string;
+ pulseData: PulseResponse;
+ isLoading?: boolean;
+ period: string;
+ }>(),
+ {
+ cols: 'full',
+ rows: 4,
+ },
+);
+
+const sort = ref<{ value: 'count' | 'slowest'; title: string }>({
+ value: 'slowest',
+ title: 'slowest',
+});
+
+const handleSetSort = (newSortKey: { value: 'count' | 'slowest'; title: string }) => {
+ sort.value = newSortKey;
+};
+
+const requests = computed(() => {
+ const list = props.pulseData.slow_requests?.slowRequests ?? [];
+ const sortKey = sort.value.value as keyof (typeof list)[0];
+
+ return [...list].sort(sortObject(sortKey, -1, []));
+});
+
+const config = computed(() => {
+ return props.pulseData.slow_requests.config;
+});
+</script>
+<template>
+ <DashboardCard
+ :rows="rows"
+ :cols="cols"
+ :class="props.class"
+ name="Slow Requests"
+ :title="`Time: ${format_number(pulseData.slow_requests?.time ?? 0)}ms; Run at: ${pulseData.slow_requests?.runAt ? new Date(pulseData.slow_requests?.runAt).toLocaleDateString() : ''};`"
+ :details="`${pulseData.slow_requests.config?.threshold ?? 1000}ms threshold, past ${validPeriods.indexOf(period) !== -1 ? periodForHumans(period) : periodForHumans(validPeriods[0])}`"
+ >
+ <template #icon>
+ <IconArrowsLeftRight />
+ </template>
+
+ <template #actions>
+ <label
+ class="capitalize whitespace-nowrap h-10 flex items-center justify-between w-full py-2 p-3 text-left rounded-l-md shadow-sm text-sm ring-inset ring-1 ring-neutral-200 dark:ring-neutral-700 text-neutral-900 dark:text-neutral-100 bg-primary-800 dark:bg-neutral-900"
+ >Sort By</label
+ >
+ <InputSelect
+ :placeholder="'None'"
+ :options="exceptionOptions"
+ class="flex-1 rounded-l-none capitalize !w-full !whitespace-nowrap"
+ title="Select usage type"
+ @selectItem="handleSetSort"
+ :defaultItem="0"
+ />
+ </template>
+
+ <PulseScroll :expand="false" :loading="isLoading ?? false">
+ <div class="min-h-full flex flex-col">
+ <PulseNoResults v-if="requests.length === 0" />
+ <PulseTable v-else>
+ <colgroup>
+ <col width="0%" />
+ <col width="100%" />
+ <col width="0%" />
+ <col width="0%" />
+ </colgroup>
+ <PulseThead>
+ <tr>
+ <PulseTh class="text-left">Method</PulseTh>
+ <PulseTh class="text-left">Route</PulseTh>
+ <PulseTh class="text-right">Count</PulseTh>
+ <PulseTh class="text-right">Slowest</PulseTh>
+ </tr>
+ </PulseThead>
+ <tbody class="">
+ <template v-for="(slowRequest, index) in requests.slice(0, 100)" :key="index">
+ <tr class="h-2 first:h-0"></tr>
+ <tr>
+ <PulseTd>
+ <PulseHttpMethodBadge :method="slowRequest.method" />
+ </PulseTd>
+ <PulseTd class="overflow-hidden max-w-[1px]">
+ <code class="block text-xs text-neutral-900 dark:text-neutral-100 truncate" :title="slowRequest.uri">
+ {{ slowRequest.uri }}
+ </code>
+ <p v-if="slowRequest.action" class="mt-1 text-xs text-neutral-500 dark:text-neutral-400 truncate" :title="slowRequest.action">
+ {{ slowRequest.action }}
+ </p>
+ <p v-if="Array.isArray(config?.threshold)" class="mt-1 text-xs text-neutral-500 dark:text-neutral-400">
+ {{ slowRequest.threshold }}ms threshold
+ </p>
+ </PulseTd>
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300 font-bold">
+ <span v-if="config.sample_rate < 1" :title="`Sample rate: ${config.sample_rate}, Raw value: ${format_number(slowRequest.count)}`">
+ ~{{ format_number(slowRequest.count * (1 / config.sample_rate)) }}
+ </span>
+ <template v-else>
+ {{ format_number(slowRequest.count) }}
+ </template>
+ </PulseTd>
+ <PulseTd :numeric="true" class="text-neutral-700 dark:text-neutral-300">
+ <strong v-if="!slowRequest.slowest">Unknown</strong>
+ <template v-else>
+ <strong>{{ format_number(slowRequest.slowest) ?? '<1' }}</strong> ms
+ </template>
+ </PulseTd>
+ </tr>
+ </template>
+ </tbody>
+ </PulseTable>
+ <div v-if="requests.length > 100" class="mt-2 text-xs text-neutral-400 text-center">Limited to 100 entries</div>
+ </div>
+ </PulseScroll>
+ </DashboardCard>
+</template>
diff --git a/resources/js/components/pulseCards/PulseUsage.vue b/resources/js/components/pulseCards/PulseUsage.vue
index 477f3887..a615560b 100644
--- a/resources/js/components/pulseCards/PulseUsage.vue
+++ b/resources/js/components/pulseCards/PulseUsage.vue
@@ -1,18 +1,18 @@
<script setup lang="ts">
-import type { PulseResponse, PulseUsageResponse } from '@/types/types';
+import type { PulseResponse } from '@/types/pulseTypes';
import { format_number, periodForHumans } from '@/service/pulseUtil';
-import { ref, watch } from 'vue';
+import { computed, ref } from 'vue';
-import DashboardCard from '@/components/cards/DashboardCard.vue';
-import PulseNoResults from '@/components/pulse/PulseNoResults.vue';
-import PulseScroll from '@/components/pulse/PulseScroll.vue';
import IconCursorArrowRays from '@/components/icons/IconCursorArrowRays.vue';
import IconArrowTrendingUp from '@/components/icons/IconArrowTrendingUp.vue';
+import PulseNoResults from '@/components/pulse/PulseNoResults.vue';
+import PulseUserCard from '@/components/pulse/PulseUserCard.vue';
+import DashboardCard from '@/components/cards/DashboardCard.vue';
+import InputSelect from '@/components/pinesUI/InputSelect.vue';
+import PulseScroll from '@/components/pulse/PulseScroll.vue';
import IconClock from '@/components/icons/IconClock.vue';
import IconScale from '@/components/icons/IconScale.vue';
-import InputSelect from '@/components/pinesUI/InputSelect.vue';
-import PulseUserCard from '@/components/pulse/PulseUserCard.vue';
const requestOptions = [
{ value: 'requests', title: 'making requests', key: 'userRequestsConfig' },
@@ -37,7 +37,17 @@ const props = withDefaults(
},
);
-const userRequestCounts = ref<PulseUsageResponse[]>();
+const userRequestCounts = computed(() => {
+ switch (type.value.value) {
+ case 'requests':
+ return props.pulseData?.usage.userRequestCounts ?? [];
+ case 'slow_requests':
+ return props.pulseData?.usage.slowRequestsCounts ?? [];
+ default:
+ return props.pulseData?.usage.jobsCounts ?? [];
+ }
+});
+
const type = ref<{ value: 'requests' | 'slow_requests' | 'jobs'; title: string; key: string }>({
value: 'requests',
title: 'making requests',
@@ -58,17 +68,6 @@ const sampleRate = () => {
return props.pulseData?.usage.jobsConfig.sample_rate ?? 1;
}
};
-
-watch([() => props.pulseData, type], () => {
- if (props.pulseData?.usage) {
- userRequestCounts.value =
- type.value.value === 'requests'
- ? (props.pulseData.usage.userRequestCounts ?? [])
- : type.value.value === 'slow_requests'
- ? (props.pulseData.usage.slowRequestsCounts ?? [])
- : (props.pulseData.usage.jobsCounts ?? []);
- }
-});
</script>
<template>
<DashboardCard
@@ -102,24 +101,20 @@ watch([() => props.pulseData, type], () => {
</span>
</template>
- <template #slot>
- <PulseScroll :expand="false" :loading="isLoading ?? false">
- <template #slot>
- <PulseNoResults v-if="userRequestCounts?.length === 0" />
- <div v-else class="grid grid-cols-1 @lg:grid-cols-2 @3xl:grid-cols-3 @6xl:grid-cols-4 gap-2 overflow-visible">
- <PulseUserCard v-for="userRequestCount in userRequestCounts" :key="userRequestCount.key" :user="userRequestCount.user">
- <template #stats>
- <span v-if="sampleRate() < 1" title="Sample rate: {{ $sampleRate }}, Raw value: {{ number_format($userRequestCount->count) }}"
- >~{{ format_number(userRequestCount.count * (1 / sampleRate())) }}</span
- >
- <template v-else>
- {{ format_number(userRequestCount.count) }}
- </template>
- </template>
- </PulseUserCard>
- </div>
- </template>
- </PulseScroll>
- </template>
+ <PulseScroll :expand="false" :loading="isLoading ?? false">
+ <PulseNoResults v-if="userRequestCounts?.length === 0" />
+ <div v-else class="grid grid-cols-1 @lg:grid-cols-2 @3xl:grid-cols-3 6xl:grid-cols-2 gap-2 overflow-visible">
+ <PulseUserCard v-for="userRequestCount in userRequestCounts" :key="userRequestCount.key" :user="userRequestCount.user">
+ <template #stats>
+ <span v-if="sampleRate() < 1" :title="`Sample rate: ${sampleRate()}, Raw value: ${format_number(userRequestCount.count)}`"
+ >~{{ format_number(userRequestCount.count * (1 / sampleRate())) }}</span
+ >
+ <template v-else>
+ {{ format_number(userRequestCount.count) }}
+ </template>
+ </template>
+ </PulseUserCard>
+ </div>
+ </PulseScroll>
</DashboardCard>
</template>
diff --git a/resources/js/components/pulseCards/cache.blade.php b/resources/js/components/pulseCards/cache.blade.php
deleted file mode 100644
index 1e7b288d..00000000
--- a/resources/js/components/pulseCards/cache.blade.php
+++ /dev/null
@@ -1,120 +0,0 @@
-@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
deleted file mode 100644
index 2247e859..00000000
--- a/resources/js/components/pulseCards/exceptions.blade.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<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/queues.blade.php b/resources/js/components/pulseCards/queues.blade.php
deleted file mode 100644
index 69b40067..00000000
--- a/resources/js/components/pulseCards/queues.blade.php
+++ /dev/null
@@ -1,209 +0,0 @@
-@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
deleted file mode 100644
index 3fa9c2e9..00000000
--- a/resources/js/components/pulseCards/slow-jobs.blade.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<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
deleted file mode 100644
index 01957831..00000000
--- a/resources/js/components/pulseCards/slow-outgoing-requests.blade.php
+++ /dev/null
@@ -1,102 +0,0 @@
-@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
deleted file mode 100644
index a2a4cf36..00000000
--- a/resources/js/components/pulseCards/slow-queries.blade.php
+++ /dev/null
@@ -1,104 +0,0 @@
-@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
deleted file mode 100644
index c9497f2d..00000000
--- a/resources/js/components/pulseCards/slow-requests.blade.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<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/service/queries.ts b/resources/js/service/queries.ts
index 02d0868f..b52b8a08 100644
--- a/resources/js/service/queries.ts
+++ b/resources/js/service/queries.ts
@@ -1,5 +1,6 @@
import type { CategoryResource, FolderResource, TaskResource, UserResource } from '@/types/resources';
-import type { AppManifest, PulseResponse, TaskStatsResponse } from '@/types/types.ts';
+import type { AppManifest, TaskStatsResponse } from '@/types/types.ts';
+import type { PulseResponse } from '@/types/pulseTypes';
import type { Session } from '@/types/model';
import type { Ref } from 'vue';
diff --git a/resources/js/service/util.ts b/resources/js/service/util.ts
index 8cfb3af0..7dfce0a7 100644
--- a/resources/js/service/util.ts
+++ b/resources/js/service/util.ts
@@ -6,7 +6,7 @@ export function toTitleCase(str: string) {
});
}
-export function toTimeSpan(rawDate: Date | string, timeZoneName = ' EST') {
+export function toTimeSpan(rawDate: Date | string, timeZoneName = ' EST', short?: boolean) {
if (!rawDate) return '';
if (typeof rawDate === 'string') {
rawDate = new Date(rawDate + timeZoneName);
@@ -21,18 +21,25 @@ export function toTimeSpan(rawDate: Date | string, timeZoneName = ' EST') {
let timeSpan: string;
+ const units = { weeks: short ? 'w' : ' week', days: short ? 'd' : ' day', hours: short ? 'h' : ' hour' };
+
+ const handlePlural = (val: number) => {
+ return short ? '' : toPlural(val);
+ };
+
if (weeks > 0) {
- timeSpan = `${weeks} week${toPlural(weeks)} ago`;
+ timeSpan = `${weeks}${units.weeks}${handlePlural(weeks)}`;
} else if (days > 0) {
- timeSpan = `${days} day${toPlural(days)} ago`;
+ timeSpan = `${days}${units.days}${handlePlural(days)}`;
} else if (hours > 0) {
- timeSpan = `${hours} hour${toPlural(hours)} ago`;
+ timeSpan = `${hours}${units.hours}${handlePlural(hours)}`;
} else if (minutes > 0) {
timeSpan = `${minutes}m ago`;
} else {
- timeSpan = `${Math.max(1, seconds)}s ago`;
+ timeSpan = `${Math.max(1, seconds)}s`;
}
+ if (!short) timeSpan += ' ago';
return timeSpan;
}
diff --git a/resources/js/types/pulseTypes.ts b/resources/js/types/pulseTypes.ts
new file mode 100644
index 00000000..692a694c
--- /dev/null
+++ b/resources/js/types/pulseTypes.ts
@@ -0,0 +1,205 @@
+export interface PulseResponse {
+ cache: {
+ allTime: number;
+ allRunAt: string;
+ allCacheInteractions: {
+ hits: number;
+ misses: number;
+ };
+ keyTime: number;
+ keyRunAt: string;
+ cacheKeyInteractions: PulseCacheKeyInteractionResponse[];
+ config: {
+ enabled: boolean;
+ groups: { [key: string]: string };
+ ignore: string[];
+ sample_rate: number;
+ };
+ };
+ exceptions: {
+ config: {
+ enabled: boolean;
+ sample_rate: number;
+ location: boolean;
+ ignore: string[];
+ };
+ exceptions: PulseExceptionsResponse[];
+ time: number;
+ runAt: string;
+ };
+ queues: {
+ queues: { [key: string]: PulseQueueResponse };
+ showConnection: boolean;
+ time: number;
+ runAt: string;
+ config: {
+ enabled: boolean;
+ sample_rate: number;
+ ignore: any[];
+ };
+ };
+ requests: {
+ requests: { [key: string]: PulseRequestResponse };
+ showConnection: boolean;
+ time: number;
+ runAt: string;
+ config: {
+ sample_rate: number;
+ record_informational: boolean;
+ record_successful: boolean;
+ record_redirection: boolean;
+ record_client_error: boolean;
+ record_server_error: boolean;
+ };
+ };
+ servers: {
+ servers: { [key: string]: PulseServerResponse };
+ time: number;
+ runAt: string;
+ };
+ slow_jobs: {
+ config: {
+ enabled: boolean;
+ ignore: string[];
+ sample_rate: number;
+ threshold: number;
+ };
+ runAt: string;
+ time: number;
+ slowJobs: PulseSlowJobResponse[];
+ };
+ slow_outgoing_requests: {
+ config: {
+ enabled: boolean;
+ groups: string[];
+ ignore: string[];
+ sample_rate: number;
+ threshold: number;
+ };
+ runAt: string;
+ time: number;
+ slowOutgoingRequests: PulseSlowOutgoingRequestResponse[];
+ };
+ slow_queries: {
+ config: {
+ enabled: boolean;
+ ignore: string[];
+ location: boolean;
+ max_query_length: number | null;
+ sample_rate: number;
+ threshold: number;
+ };
+ runAt: string;
+ time: number;
+ slowQueries: PulseSlowQueryResponse[];
+ };
+ slow_requests: {
+ config: {
+ threshold: number;
+ sample_rate: number;
+ };
+ time: number;
+ runAt: string;
+ slowRequests: PulseSlowRequestResponse[];
+ };
+ usage: {
+ userRequestCounts: PulseUsageResponse[];
+ slowRequestsCounts: PulseUsageResponse[];
+ jobsCounts: PulseUsageResponse[];
+ time: number;
+ runAt: string;
+ userRequestsConfig: {
+ enabled: boolean;
+ sample_rate: number;
+ ignore: any[];
+ };
+ slowRequestsConfig: {
+ enabled: boolean;
+ sample_rate: number;
+ threshold: 1000;
+ ignore: any[];
+ };
+ jobsConfig: {
+ enabled: boolean;
+ sample_rate: number;
+ ignore: any[];
+ };
+ };
+}
+
+export interface PulseServerResponse {
+ name: string;
+ cpu_current: number;
+ cpu: { [key: string]: string };
+ memory_current: number;
+ memory_total: number;
+ memory: { [key: string]: string };
+ storage: { directory: string; total: number; used: number }[];
+ updated_at: string;
+ recently_reported: boolean;
+ runAt: string;
+ time: number;
+}
+
+export interface PulseCacheKeyInteractionResponse {
+ key: string;
+ hits: number;
+ misses: number;
+}
+
+export interface PulseQueueResponse {
+ [key: string]: { [key: string]: string | null };
+}
+
+export interface PulseRequestResponse {
+ [key: string]: { [key: string]: string | null };
+}
+
+export interface PulseSlowRequestResponse {
+ action: string;
+ count: number;
+ method: string;
+ slowest: number;
+ threshold: number;
+ uri: string;
+}
+
+export interface PulseSlowJobResponse {
+ job: string;
+ count: number;
+ slowest: number;
+ threshold: number;
+}
+
+export interface PulseSlowQueryResponse {
+ count: number;
+ location: string;
+ slowest: number;
+ sql: string;
+ threshold: number;
+}
+
+export interface PulseSlowOutgoingRequestResponse {
+ count: number;
+ method: string;
+ slowest: number;
+ threshold: number;
+ uri: string;
+}
+
+export interface PulseUsageResponse {
+ key: number;
+ user: {
+ name: string;
+ extra: string;
+ avatar?: string;
+ };
+ count: number;
+}
+
+export interface PulseExceptionsResponse {
+ class: string;
+ count: string;
+ latest: string;
+ location: string;
+}
diff --git a/resources/js/types/types.ts b/resources/js/types/types.ts
index 47881a08..1e53fc4c 100644
--- a/resources/js/types/types.ts
+++ b/resources/js/types/types.ts
@@ -22,110 +22,6 @@ export interface HttpResponse {
data: string | number | string[] | number[] | null;
}
-export interface PulseResponse {
- cache: {
- allTime: number;
- allRunAt: string;
- allCacheInteractions: {
- hits: number;
- misses: number;
- };
- keyTime: number;
- keyRunAt: string;
- cacheKeyInteractions: [];
- };
- exceptions?: any;
- queues?: {
- queues: { [key: string]: PulseQueueResponse };
- showConnection: boolean;
- time: number;
- runAt: string;
- config: {
- enabled: boolean;
- sample_rate: number;
- ignore: any[];
- };
- };
- requests?: {
- requests: { [key: string]: PulseRquestsResponse };
- showConnection: boolean;
- time: number;
- runAt: string;
- config: {
- sample_rate: number;
- record_informational: boolean;
- record_successful: boolean;
- record_redirection: boolean;
- record_client_error: boolean;
- record_server_error: boolean;
- };
- };
- servers?: {
- servers: { [key: string]: PulseServerResponse };
- time: number;
- runAt: string;
- };
- slow_jobs?: any;
- slow_outgoing_requests?: any;
- slow_queries?: any;
- slow_requests?: any;
- usage: {
- userRequestCounts: PulseUsageResponse[];
- slowRequestsCounts: PulseUsageResponse[];
- jobsCounts: PulseUsageResponse[];
- time: number;
- runAt: string;
- userRequestsConfig: {
- enabled: boolean;
- sample_rate: number;
- ignore: any[];
- };
- slowRequestsConfig: {
- enabled: boolean;
- sample_rate: number;
- threshold: 1000;
- ignore: any[];
- };
- jobsConfig: {
- enabled: boolean;
- sample_rate: number;
- ignore: any[];
- };
- };
-}
-
-export interface PulseServerResponse {
- name: string;
- cpu_current: number;
- cpu: { [key: string]: string };
- memory_current: number;
- memory_total: number;
- memory: { [key: string]: string };
- storage: { directory: string; total: number; used: number }[];
- updated_at: string;
- recently_reported: boolean;
- runAt: string;
- time: number;
-}
-
-export interface PulseQueueResponse {
- [key: string]: { [key: string]: string | null };
-}
-
-export interface PulseRquestsResponse {
- [key: string]: { [key: string]: string | null };
-}
-
-export interface PulseUsageResponse {
- key: number;
- user: {
- name: string;
- extra: string;
- avatar?: string;
- };
- count: number;
-}
-
export interface SiteAnalyticsResponse {
title: string;
count: number;
diff --git a/routes/channels.php b/routes/channels.php
index cc63c747..61aaebe2 100644
--- a/routes/channels.php
+++ b/routes/channels.php
@@ -23,4 +23,5 @@ Broadcast::channel('dashboard.libraries', function ($user) {
});
Broadcast::channel('dashboard', function () {
+ // Unimplemented
});