adonisjs-server-stats 1.10.3 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/core/field-resolvers.d.ts +64 -0
  2. package/dist/core/formatters.d.ts +15 -0
  3. package/dist/core/index.d.ts +1 -1
  4. package/dist/core/index.js +208 -203
  5. package/dist/react/CacheSection-BYN53kYO.js +135 -0
  6. package/dist/react/CacheStatsBar-CRodCOeP.js +27 -0
  7. package/dist/react/CacheTab-DOhuK05d.js +106 -0
  8. package/dist/react/{ConfigSection-DGgqjAal.js → ConfigSection-B9EHh4Rp.js} +1 -1
  9. package/dist/react/{ConfigTab-H3OnYqmK.js → ConfigTab-C8kriE2b.js} +1 -1
  10. package/dist/react/CustomPaneTab-CvzQS_Wh.js +99 -0
  11. package/dist/react/EmailPreviewOverlay-BmXOAvqG.js +58 -0
  12. package/dist/react/EmailsSection-BJyFJf7A.js +226 -0
  13. package/dist/react/EmailsTab-Ch8jp10B.js +110 -0
  14. package/dist/react/{EventsSection-C7RQW_LY.js → EventsSection-DJPwHeT8.js} +27 -26
  15. package/dist/react/EventsTab-B-FoehXC.js +58 -0
  16. package/dist/react/{InternalsContent-DBzsI0CG.js → InternalsContent-O8ino9oM.js} +133 -109
  17. package/dist/react/InternalsSection-B6VlVx5f.js +22 -0
  18. package/dist/react/InternalsTab-CkEKpRMU.js +17 -0
  19. package/dist/react/JobStatsBar-C7RslAFE.js +30 -0
  20. package/dist/react/JobsSection-DWF4i1t_.js +167 -0
  21. package/dist/react/JobsTab-DqnifQXV.js +129 -0
  22. package/dist/react/LogEntryRow-CMMkqA9M.js +43 -0
  23. package/dist/react/LogsSection-C1xC5aP4.js +198 -0
  24. package/dist/react/LogsTab-CS4sLfLw.js +79 -0
  25. package/dist/react/{OverviewSection-ABP9ueBo.js → OverviewSection-CxvfOR0v.js} +70 -80
  26. package/dist/react/QueriesSection-CrMdU5Ax.js +458 -0
  27. package/dist/react/{QueriesTab-BQzcxEiW.js → QueriesTab-x85PjkyS.js} +22 -21
  28. package/dist/react/RequestsSection-DETN9oZb.js +321 -0
  29. package/dist/react/{RoutesSection-BRhxrtjZ.js → RoutesSection-CmorkJeC.js} +1 -1
  30. package/dist/react/{RoutesTab-CpYH5lUw.js → RoutesTab-CbzBOzpc.js} +12 -12
  31. package/dist/react/SplitPaneWrapper-BiIgT4ND.js +49 -0
  32. package/dist/react/TimeAgoCell-o3KigGfM.js +8 -0
  33. package/dist/react/{TimelineTab-DjLR35Ce.js → TimelineTab-Ue9tUD_n.js} +71 -91
  34. package/dist/react/{index-CsImORX6.js → index-DwDK-4oX.js} +4 -4
  35. package/dist/react/index.js +6 -6
  36. package/dist/react/react/components/shared/CacheStatsBar.d.ts +13 -0
  37. package/dist/react/react/components/shared/EmailPreviewOverlay.d.ts +29 -0
  38. package/dist/react/react/components/shared/JobStatsBar.d.ts +12 -0
  39. package/dist/react/react/components/shared/LogEntryRow.d.ts +9 -0
  40. package/dist/react/react/components/shared/RelatedLogs.d.ts +2 -2
  41. package/dist/react/react/components/shared/SplitPaneWrapper.d.ts +7 -0
  42. package/dist/react/react/components/shared/TimeAgoCell.d.ts +17 -0
  43. package/dist/react/react/hooks/useDiagnosticsData.d.ts +14 -0
  44. package/dist/react/style.css +1 -1
  45. package/dist/src/edge/client/dashboard.js +2 -2
  46. package/dist/src/edge/client/debug-panel-deferred.js +1 -1
  47. package/dist/src/edge/client-vue/dashboard.js +3 -3
  48. package/dist/src/edge/client-vue/debug-panel-deferred.js +4 -4
  49. package/dist/src/styles/components.css +67 -0
  50. package/dist/src/styles/dashboard.css +5 -15
  51. package/dist/src/styles/debug-panel.css +1 -22
  52. package/dist/src/styles/utilities.css +3 -1
  53. package/dist/vue/{CacheSection-ITqvpfH5.js → CacheSection-DT2Mwf_s.js} +1 -1
  54. package/dist/vue/{ConfigSection-DTn3GslE.js → ConfigSection-BwKwS9lh.js} +1 -1
  55. package/dist/vue/CustomPaneTab-Hr1IBHfz.js +172 -0
  56. package/dist/vue/{EmailsSection-DtLJ4XoS.js → EmailsSection-B65g0FVS.js} +1 -1
  57. package/dist/vue/{EventsSection-BOYYz0Ty.js → EventsSection-CxqtVF-o.js} +1 -1
  58. package/dist/vue/{JobsSection-BazTxcJL.js → JobsSection-rMIyMb-g.js} +1 -1
  59. package/dist/vue/{LogsSection-D55PjTKX.js → LogsSection-DmmZVJ7D.js} +1 -1
  60. package/dist/vue/{OverviewSection-1uBKo-Tu.js → OverviewSection-BMabyqw-.js} +49 -50
  61. package/dist/vue/{QueriesSection-rpoZ4ogd.js → QueriesSection-BfDFwGqH.js} +44 -45
  62. package/dist/vue/{QueriesTab-C8_7oprC.js → QueriesTab-DuTG7cpC.js} +30 -31
  63. package/dist/vue/RelatedLogs.vue_vue_type_script_setup_true_lang-Py1iu9GU.js +77 -0
  64. package/dist/vue/{RequestsSection-x7LvT0MC.js → RequestsSection-CTu4jPZ_.js} +143 -147
  65. package/dist/vue/{RoutesSection-CCD0zZqQ.js → RoutesSection-zQZDedL7.js} +1 -1
  66. package/dist/vue/TimelineTab-DHfXsX7t.js +334 -0
  67. package/dist/vue/components/shared/RelatedLogs.vue.d.ts +1 -4
  68. package/dist/vue/{index-C8MxnS7Q.js → index-CM3yNVUR.js} +2 -2
  69. package/dist/vue/index.js +1 -1
  70. package/dist/vue/style.css +1 -1
  71. package/package.json +7 -7
  72. package/dist/react/CacheSection-baMZotSn.js +0 -146
  73. package/dist/react/CacheTab-2cw_rMzj.js +0 -117
  74. package/dist/react/CustomPaneTab-B6r7ha0u.js +0 -98
  75. package/dist/react/EmailsSection-C-UZISG-.js +0 -262
  76. package/dist/react/EmailsTab-DbK4Eobn.js +0 -139
  77. package/dist/react/EventsTab-CfVr7AiM.js +0 -57
  78. package/dist/react/InternalsSection-t7ihcWO-.js +0 -32
  79. package/dist/react/InternalsTab-Oij0A2fN.js +0 -30
  80. package/dist/react/JobsSection-CQHNK_Ls.js +0 -187
  81. package/dist/react/JobsTab-znzf6jzk.js +0 -153
  82. package/dist/react/LogsSection-Dmm3rE2B.js +0 -233
  83. package/dist/react/LogsTab-D8unMV5P.js +0 -108
  84. package/dist/react/QueriesSection-CnmSkznA.js +0 -461
  85. package/dist/react/RelatedLogs-3A8RuGKH.js +0 -52
  86. package/dist/react/RequestsSection-kW79_M7k.js +0 -341
  87. package/dist/vue/CustomPaneTab-BJxT5Dp7.js +0 -172
  88. package/dist/vue/RelatedLogs.vue_vue_type_script_setup_true_lang-CB2_TzYW.js +0 -84
  89. package/dist/vue/TimelineTab-zj5Z5OdT.js +0 -338
@@ -1,187 +0,0 @@
1
- import { jsxs as l, jsx as a, Fragment as C } from "react/jsx-runtime";
2
- import { useState as c, useCallback as D } from "react";
3
- import { extractJobs as F, extractJobStats as J, JOB_STATUS_FILTERS as T, getJobStatusBadgeColor as A, formatDuration as B, timeAgo as _, formatTime as L } from "adonisjs-server-stats/core";
4
- import { a as R, B as $, J as M } from "./index-CsImORX6.js";
5
- import { D as O } from "./DataTable-YyShr5B-.js";
6
- import { F as U } from "./FilterBar-CQ7bD669.js";
7
- import { P as E } from "./Pagination-BkmzUDY8.js";
8
- function H({ options: N = {} }) {
9
- const [v, m] = c(1), [p, j] = c(""), [o, f] = c("all"), [x, d] = c(
10
- {}
11
- ), b = {};
12
- o !== "all" && (b.status = o);
13
- const { data: h, meta: n, isLoading: S, error: k, refresh: u, mutate: y } = R("jobs", {
14
- ...N,
15
- page: v,
16
- search: p,
17
- filters: b
18
- }), g = F(h), r = J(h), w = D(
19
- async (s) => {
20
- d((e) => ({ ...e, [s]: "pending" }));
21
- try {
22
- await y(`jobs/${s}/retry`), d((e) => ({ ...e, [s]: "success" })), setTimeout(() => {
23
- d((e) => {
24
- const t = { ...e };
25
- return delete t[s], t;
26
- }), u();
27
- }, 1e3);
28
- } catch {
29
- d((e) => {
30
- const t = { ...e };
31
- return delete t[s], t;
32
- });
33
- }
34
- },
35
- [y, u]
36
- );
37
- return /* @__PURE__ */ l("div", { children: [
38
- r && /* @__PURE__ */ l("div", { className: "ss-dash-job-stats", children: [
39
- /* @__PURE__ */ l("div", { className: "ss-dash-job-stat", children: [
40
- /* @__PURE__ */ a("span", { className: "ss-dash-job-stat-label", children: "Active:" }),
41
- /* @__PURE__ */ a("span", { className: "ss-dash-job-stat-value", children: r.active ?? 0 })
42
- ] }),
43
- /* @__PURE__ */ l("div", { className: "ss-dash-job-stat", children: [
44
- /* @__PURE__ */ a("span", { className: "ss-dash-job-stat-label", children: "Waiting:" }),
45
- /* @__PURE__ */ a("span", { className: "ss-dash-job-stat-value", children: r.waiting ?? 0 })
46
- ] }),
47
- /* @__PURE__ */ l("div", { className: "ss-dash-job-stat", children: [
48
- /* @__PURE__ */ a("span", { className: "ss-dash-job-stat-label", children: "Delayed:" }),
49
- /* @__PURE__ */ a("span", { className: "ss-dash-job-stat-value", children: r.delayed ?? 0 })
50
- ] }),
51
- /* @__PURE__ */ l("div", { className: "ss-dash-job-stat", children: [
52
- /* @__PURE__ */ a("span", { className: "ss-dash-job-stat-label", children: "Completed:" }),
53
- /* @__PURE__ */ a("span", { className: "ss-dash-job-stat-value", children: r.completed ?? 0 })
54
- ] }),
55
- /* @__PURE__ */ l("div", { className: "ss-dash-job-stat", children: [
56
- /* @__PURE__ */ a("span", { className: "ss-dash-job-stat-label", children: "Failed:" }),
57
- /* @__PURE__ */ a("span", { className: "ss-dash-job-stat-value", style: { color: "var(--ss-red-fg)" }, children: r.failed ?? 0 })
58
- ] })
59
- ] }),
60
- /* @__PURE__ */ a(
61
- U,
62
- {
63
- search: p,
64
- onSearchChange: j,
65
- placeholder: "Filter jobs...",
66
- summary: `${n?.total ?? g.length} jobs`,
67
- children: /* @__PURE__ */ a("div", { className: "ss-dash-btn-group", children: T.map((s) => /* @__PURE__ */ a(
68
- "button",
69
- {
70
- type: "button",
71
- className: `ss-dash-btn ${o === s ? "ss-dash-active" : ""}`,
72
- onClick: () => {
73
- f(s), m(1);
74
- },
75
- children: s.charAt(0).toUpperCase() + s.slice(1)
76
- },
77
- s
78
- )) })
79
- }
80
- ),
81
- S && !h ? /* @__PURE__ */ a("div", { className: "ss-dash-empty", children: "Loading jobs..." }) : k ? /* @__PURE__ */ a("div", { className: "ss-dash-empty", children: "Jobs/Queue not available" }) : /* @__PURE__ */ l(C, { children: [
82
- /* @__PURE__ */ a("div", { className: "ss-dash-table-wrap", children: /* @__PURE__ */ a(
83
- O,
84
- {
85
- columns: [
86
- {
87
- key: "id",
88
- label: "ID",
89
- width: "40px",
90
- render: (s) => /* @__PURE__ */ a("span", { style: { color: "var(--ss-dim)" }, children: s })
91
- },
92
- {
93
- key: "name",
94
- label: "Name",
95
- render: (s) => /* @__PURE__ */ a("span", { style: { color: "var(--ss-text)" }, title: s, children: s })
96
- },
97
- {
98
- key: "status",
99
- label: "Status",
100
- width: "90px",
101
- render: (s) => /* @__PURE__ */ a($, { color: A(s), children: s })
102
- },
103
- {
104
- key: "payload",
105
- label: "Payload",
106
- render: (s, e) => /* @__PURE__ */ a(M, { data: s || e?.data, maxPreviewLength: 60 })
107
- },
108
- {
109
- key: "attempts",
110
- label: "Tries",
111
- width: "50px",
112
- render: (s, e) => /* @__PURE__ */ a(
113
- "span",
114
- {
115
- style: {
116
- color: "var(--ss-muted)",
117
- textAlign: "center",
118
- display: "block"
119
- },
120
- children: s || e.attemptsMade || 0
121
- }
122
- )
123
- },
124
- {
125
- key: "duration",
126
- label: "Duration",
127
- width: "75px",
128
- render: (s) => /* @__PURE__ */ a("span", { className: "ss-dash-duration", children: s !== null ? B(s) : "-" })
129
- },
130
- {
131
- key: "timestamp",
132
- label: "Time",
133
- width: "70px",
134
- render: (s, e) => {
135
- const t = s || e?.createdAt || e?.processedAt || e?.created_at;
136
- return /* @__PURE__ */ a(
137
- "span",
138
- {
139
- className: "ss-dash-event-time",
140
- style: { whiteSpace: "nowrap" },
141
- title: L(t),
142
- children: _(t)
143
- }
144
- );
145
- }
146
- },
147
- {
148
- key: "_actions",
149
- label: "",
150
- width: "50px",
151
- render: (s, e) => {
152
- const t = e.id, i = x[t];
153
- return e.status !== "failed" ? null : /* @__PURE__ */ a(
154
- "button",
155
- {
156
- type: "button",
157
- className: "ss-dash-retry-btn",
158
- disabled: i === "pending" || i === "success",
159
- onClick: (P) => {
160
- P.stopPropagation(), w(t);
161
- },
162
- children: i === "pending" ? "..." : i === "success" ? "OK" : "Retry"
163
- }
164
- );
165
- }
166
- }
167
- ],
168
- data: g,
169
- emptyMessage: "No jobs found"
170
- }
171
- ) }),
172
- n && /* @__PURE__ */ a(
173
- E,
174
- {
175
- page: n.page,
176
- lastPage: n.lastPage,
177
- total: n.total,
178
- onPageChange: m
179
- }
180
- )
181
- ] })
182
- ] });
183
- }
184
- export {
185
- H as JobsSection,
186
- H as default
187
- };
@@ -1,153 +0,0 @@
1
- import { jsx as s, jsxs as t } from "react/jsx-runtime";
2
- import { useState as b, useMemo as C, useCallback as j } from "react";
3
- import { extractJobs as D, extractJobStats as F, JOB_STATUS_FILTERS as J, getJobStatusCssClass as $, formatDuration as B, timeAgo as L, formatTime as R } from "adonisjs-server-stats/core";
4
- import { u as k } from "./useDashboardApiBase-Bi36pJ2L.js";
5
- import { u as P, J as _ } from "./index-CsImORX6.js";
6
- import { u as E } from "./useResizableTable-CNJmACdt.js";
7
- import { F as O } from "./FilterBar-CQ7bD669.js";
8
- function W({ options: c, dashboardPath: f }) {
9
- const { dashApiBase: h, resolvedOptions: y } = k(f, c), { data: i, isLoading: v, error: g } = P("jobs", y), [n, x] = b(""), [o, w] = b("all"), [u, p] = b(null), m = C(() => {
10
- const e = D(i), a = o === "all" ? e : e.filter((d) => d.status === o);
11
- if (!n) return a;
12
- const l = n.toLowerCase();
13
- return a.filter((d) => d.name?.toLowerCase().includes(l) || d.id?.toString().includes(l));
14
- }, [i, o, n]), A = j(
15
- async (e) => {
16
- p(e);
17
- try {
18
- const { baseUrl: a = "", authToken: l } = c || {}, d = h || c?.debugEndpoint || "/admin/api/debug", T = `${a}${d}/jobs/${e}/retry`, N = { Accept: "application/json" };
19
- l && (N.Authorization = `Bearer ${l}`), await fetch(T, {
20
- method: "POST",
21
- headers: N,
22
- credentials: l ? "omit" : "same-origin"
23
- });
24
- } catch {
25
- }
26
- p(null);
27
- },
28
- [c, h]
29
- ), S = E([m]);
30
- if (!h)
31
- return /* @__PURE__ */ s("div", { className: "ss-dbg-empty", children: "Queue inspector not available (no dashboard configured)" });
32
- if (v && !i)
33
- return /* @__PURE__ */ s("div", { className: "ss-dbg-empty", children: "Loading jobs..." });
34
- if (g)
35
- return /* @__PURE__ */ t("div", { className: "ss-dbg-empty", children: [
36
- "Error: ",
37
- g.message
38
- ] });
39
- if (!i)
40
- return /* @__PURE__ */ s("div", { className: "ss-dbg-empty", children: "Queue inspector not available" });
41
- const r = F(i);
42
- return /* @__PURE__ */ t("div", { children: [
43
- /* @__PURE__ */ s(
44
- O,
45
- {
46
- search: n,
47
- onSearchChange: x,
48
- placeholder: "Filter jobs...",
49
- summary: `${m.length} jobs`
50
- }
51
- ),
52
- /* @__PURE__ */ t("div", { className: "ss-dbg-job-stats-area", children: [
53
- /* @__PURE__ */ t("div", { className: "ss-dbg-job-stats", children: [
54
- /* @__PURE__ */ t("div", { className: "ss-dbg-job-stat", children: [
55
- /* @__PURE__ */ s("span", { className: "ss-dbg-job-stat-label", children: "Active:" }),
56
- /* @__PURE__ */ s("span", { className: "ss-dbg-job-stat-value", children: r?.active ?? 0 })
57
- ] }),
58
- /* @__PURE__ */ t("div", { className: "ss-dbg-job-stat", children: [
59
- /* @__PURE__ */ s("span", { className: "ss-dbg-job-stat-label", children: "Waiting:" }),
60
- /* @__PURE__ */ s("span", { className: "ss-dbg-job-stat-value", children: r?.waiting ?? 0 })
61
- ] }),
62
- /* @__PURE__ */ t("div", { className: "ss-dbg-job-stat", children: [
63
- /* @__PURE__ */ s("span", { className: "ss-dbg-job-stat-label", children: "Delayed:" }),
64
- /* @__PURE__ */ s("span", { className: "ss-dbg-job-stat-value", children: r?.delayed ?? 0 })
65
- ] }),
66
- /* @__PURE__ */ t("div", { className: "ss-dbg-job-stat", children: [
67
- /* @__PURE__ */ s("span", { className: "ss-dbg-job-stat-label", children: "Completed:" }),
68
- /* @__PURE__ */ s("span", { className: "ss-dbg-job-stat-value", children: r?.completed ?? 0 })
69
- ] }),
70
- /* @__PURE__ */ t("div", { className: "ss-dbg-job-stat", children: [
71
- /* @__PURE__ */ s("span", { className: "ss-dbg-job-stat-label", children: "Failed:" }),
72
- /* @__PURE__ */ s("span", { className: "ss-dbg-job-stat-value ss-dbg-c-red", children: r?.failed ?? 0 })
73
- ] })
74
- ] }),
75
- /* @__PURE__ */ s("div", { className: "ss-dbg-log-filters", children: J.map((e) => /* @__PURE__ */ s(
76
- "button",
77
- {
78
- type: "button",
79
- className: `ss-dbg-job-filter ${o === e ? "ss-dbg-active" : ""}`,
80
- onClick: () => w(e),
81
- children: e
82
- },
83
- e
84
- )) })
85
- ] }),
86
- m.length === 0 ? /* @__PURE__ */ s("div", { className: "ss-dbg-empty", children: "No jobs found" }) : /* @__PURE__ */ t("table", { ref: S, className: "ss-dbg-table", children: [
87
- /* @__PURE__ */ t("colgroup", { children: [
88
- /* @__PURE__ */ s("col", { style: { width: "50px" } }),
89
- /* @__PURE__ */ s("col", { style: { width: "15%" } }),
90
- /* @__PURE__ */ s("col", { style: { width: "80px" } }),
91
- /* @__PURE__ */ s("col", {}),
92
- /* @__PURE__ */ s("col", { style: { width: "50px" } }),
93
- /* @__PURE__ */ s("col", { style: { width: "80px" } }),
94
- /* @__PURE__ */ s("col", { style: { width: "80px" } }),
95
- /* @__PURE__ */ s("col", { style: { width: "60px" } })
96
- ] }),
97
- /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ t("tr", { children: [
98
- /* @__PURE__ */ s("th", { children: "ID" }),
99
- /* @__PURE__ */ s("th", { children: "Name" }),
100
- /* @__PURE__ */ s("th", { children: "Status" }),
101
- /* @__PURE__ */ s("th", { children: "Payload" }),
102
- /* @__PURE__ */ s("th", { children: "Tries" }),
103
- /* @__PURE__ */ s("th", { children: "Duration" }),
104
- /* @__PURE__ */ s("th", { children: "Time" }),
105
- /* @__PURE__ */ s("th", {})
106
- ] }) }),
107
- /* @__PURE__ */ s("tbody", { children: m.map((e) => {
108
- const a = e;
109
- return /* @__PURE__ */ t("tr", { children: [
110
- /* @__PURE__ */ s("td", { className: "ss-dbg-c-dim", children: e.id }),
111
- /* @__PURE__ */ s("td", { className: "ss-dbg-c-sql", title: e.name, children: e.name }),
112
- /* @__PURE__ */ s("td", { children: /* @__PURE__ */ s("span", { className: `ss-dbg-badge ${$(e.status)}`, children: e.status }) }),
113
- /* @__PURE__ */ s("td", { children: /* @__PURE__ */ s(
114
- _,
115
- {
116
- data: e.payload || e.data,
117
- maxPreviewLength: 60,
118
- classPrefix: "ss-dbg"
119
- }
120
- ) }),
121
- /* @__PURE__ */ s("td", { className: "ss-dbg-c-muted", style: { textAlign: "center" }, children: e.attempts || a.attemptsMade || 0 }),
122
- /* @__PURE__ */ s("td", { className: "ss-dbg-duration", children: e.duration !== null ? B(e.duration) : "-" }),
123
- /* @__PURE__ */ s(
124
- "td",
125
- {
126
- className: "ss-dbg-event-time",
127
- title: R(
128
- e.timestamp || e.createdAt || a.processedAt || a.created_at
129
- ),
130
- children: L(
131
- e.timestamp || e.createdAt || a.processedAt || a.created_at
132
- )
133
- }
134
- ),
135
- /* @__PURE__ */ s("td", { children: e.status === "failed" && /* @__PURE__ */ s(
136
- "button",
137
- {
138
- type: "button",
139
- className: "ss-dbg-retry-btn",
140
- onClick: () => A(e.id),
141
- disabled: u === e.id,
142
- children: u === e.id ? "..." : "Retry"
143
- }
144
- ) })
145
- ] }, e.id);
146
- }) })
147
- ] })
148
- ] });
149
- }
150
- export {
151
- W as JobsTab,
152
- W as default
153
- };
@@ -1,233 +0,0 @@
1
- import { jsxs as a, jsx as s } from "react/jsx-runtime";
2
- import M, { useState as l, useCallback as c } from "react";
3
- import { LOG_LEVELS as U, resolveLogLevel as z, resolveLogMessage as H, resolveLogRequestId as Q, resolveLogTimestamp as W, getStructuredData as X, getLogLevelCssClass as Y, timeAgo as Z, formatTime as ee } from "adonisjs-server-stats/core";
4
- import { a as se, J as te } from "./index-CsImORX6.js";
5
- import { F as ae } from "./FilterBar-CQ7bD669.js";
6
- import { P as le } from "./Pagination-BkmzUDY8.js";
7
- function he({ options: D = {} }) {
8
- const [R, i] = l(1), [L, V] = l(""), [r, S] = l("all"), [n, v] = l(""), [p, f] = l(""), [N, k] = l([]), [b, A] = l("level"), [q, K] = l("equals"), [y, _] = l(""), [C, O] = l(null), o = {};
9
- r !== "all" && (o.level = r), n && (o.request_id = n), N.forEach((e, t) => {
10
- o[`filter_field_${t}`] = e.field, o[`filter_op_${t}`] = e.operator, o[`filter_value_${t}`] = e.value;
11
- });
12
- const { data: x, meta: d, isLoading: j } = se("logs", {
13
- ...D,
14
- page: R,
15
- search: L,
16
- filters: o
17
- }), $ = x || [], P = c((e) => {
18
- v(e), f(e), i(1);
19
- }, []), J = c(() => {
20
- const e = p.trim();
21
- v(e), i(1);
22
- }, [p]), E = c(() => {
23
- v(""), f(""), i(1);
24
- }, []), T = c(() => {
25
- S("all"), i(1);
26
- }, []), w = c(() => {
27
- const e = y.trim();
28
- e && (k((t) => [
29
- ...t,
30
- { field: b, operator: q, value: e }
31
- ]), _(""));
32
- }, [b, q, y]), B = c((e) => {
33
- k((t) => t.filter((I, F) => F !== e));
34
- }, []), G = r !== "all" || n !== "" || N.length > 0;
35
- return /* @__PURE__ */ a("div", { children: [
36
- /* @__PURE__ */ s(
37
- ae,
38
- {
39
- search: L,
40
- onSearchChange: V,
41
- placeholder: "Search logs...",
42
- summary: `${d?.total ?? 0} logs`,
43
- children: /* @__PURE__ */ a("div", { className: "ss-dash-log-filters", children: [
44
- U.map((e) => /* @__PURE__ */ s(
45
- "button",
46
- {
47
- type: "button",
48
- className: `ss-dash-log-filter ${r === e ? "ss-dash-active" : ""}`,
49
- onClick: () => {
50
- S(e), i(1);
51
- },
52
- children: e
53
- },
54
- e
55
- )),
56
- /* @__PURE__ */ s(
57
- "input",
58
- {
59
- type: "text",
60
- className: "ss-dash-filter-input ss-dash-reqid-input",
61
- placeholder: "Filter by request ID...",
62
- value: p,
63
- onChange: (e) => f(e.target.value),
64
- onKeyDown: (e) => e.key === "Enter" && J()
65
- }
66
- ),
67
- (p || n) && /* @__PURE__ */ s(
68
- "button",
69
- {
70
- type: "button",
71
- className: "ss-dash-btn ss-dash-reqid-clear",
72
- onClick: () => {
73
- E();
74
- },
75
- children: "Clear"
76
- }
77
- )
78
- ] })
79
- }
80
- ),
81
- /* @__PURE__ */ a("div", { className: "ss-dash-structured-search", children: [
82
- /* @__PURE__ */ a(
83
- "select",
84
- {
85
- className: "ss-dash-filter-select",
86
- value: b,
87
- onChange: (e) => A(e.target.value),
88
- children: [
89
- /* @__PURE__ */ s("option", { value: "level", children: "level" }),
90
- /* @__PURE__ */ s("option", { value: "message", children: "message" }),
91
- /* @__PURE__ */ s("option", { value: "request_id", children: "request_id" }),
92
- /* @__PURE__ */ s("option", { value: "userId", children: "userId" }),
93
- /* @__PURE__ */ s("option", { value: "email", children: "email" }),
94
- /* @__PURE__ */ s("option", { value: "path", children: "path" })
95
- ]
96
- }
97
- ),
98
- /* @__PURE__ */ a(
99
- "select",
100
- {
101
- className: "ss-dash-filter-select",
102
- value: q,
103
- onChange: (e) => K(e.target.value),
104
- children: [
105
- /* @__PURE__ */ s("option", { value: "equals", children: "equals" }),
106
- /* @__PURE__ */ s("option", { value: "contains", children: "contains" }),
107
- /* @__PURE__ */ s("option", { value: "starts_with", children: "starts with" })
108
- ]
109
- }
110
- ),
111
- /* @__PURE__ */ s(
112
- "input",
113
- {
114
- className: "ss-dash-filter-input",
115
- placeholder: "Value...",
116
- value: y,
117
- onChange: (e) => _(e.target.value),
118
- onKeyDown: (e) => e.key === "Enter" && w()
119
- }
120
- ),
121
- /* @__PURE__ */ s("button", { type: "button", className: "ss-dash-btn", onClick: w, children: "Add" })
122
- ] }),
123
- G && /* @__PURE__ */ a("div", { className: "ss-dash-filter-chips", children: [
124
- r !== "all" && /* @__PURE__ */ a("span", { className: "ss-dash-filter-chip", children: [
125
- "level: ",
126
- r,
127
- /* @__PURE__ */ s(
128
- "button",
129
- {
130
- type: "button",
131
- className: "ss-dash-filter-chip-remove",
132
- onClick: T,
133
- children: "×"
134
- }
135
- )
136
- ] }),
137
- n && /* @__PURE__ */ a("span", { className: "ss-dash-filter-chip", children: [
138
- "requestId: ",
139
- n.slice(0, 8),
140
- "...",
141
- /* @__PURE__ */ s(
142
- "button",
143
- {
144
- type: "button",
145
- className: "ss-dash-filter-chip-remove",
146
- onClick: E,
147
- children: "×"
148
- }
149
- )
150
- ] }),
151
- N.map((e, t) => /* @__PURE__ */ a("span", { className: "ss-dash-filter-chip", children: [
152
- e.field,
153
- " ",
154
- e.operator,
155
- ' "',
156
- e.value,
157
- '"',
158
- /* @__PURE__ */ s(
159
- "button",
160
- {
161
- type: "button",
162
- className: "ss-dash-filter-chip-remove",
163
- onClick: () => B(t),
164
- children: "×"
165
- }
166
- )
167
- ] }, t))
168
- ] }),
169
- j && !x ? /* @__PURE__ */ s("div", { className: "ss-dash-empty", children: "Loading logs..." }) : $.length === 0 ? /* @__PURE__ */ a("div", { className: "ss-dash-empty", children: [
170
- "No log entries",
171
- n ? ` matching request ${n}` : r !== "all" ? ` for ${r}` : ""
172
- ] }) : /* @__PURE__ */ s("div", { className: "ss-dash-log-entries", children: $.map((e, t) => {
173
- const I = z(e), F = H(e), h = Q(e), m = W(e), u = X(e);
174
- return /* @__PURE__ */ a(M.Fragment, { children: [
175
- /* @__PURE__ */ a(
176
- "div",
177
- {
178
- className: `ss-dash-log-entry${u ? " ss-dash-log-entry-expandable" : ""}`,
179
- onClick: () => u && O(C === t ? null : t),
180
- children: [
181
- /* @__PURE__ */ s(
182
- "span",
183
- {
184
- className: `ss-dash-log-level ${Y(I, "ss-dash-log-level")}`,
185
- children: I.toUpperCase()
186
- }
187
- ),
188
- /* @__PURE__ */ s("span", { className: "ss-dash-log-time", title: m ? ee(m) : "", children: m ? Z(m) : "-" }),
189
- h ? /* @__PURE__ */ s(
190
- "span",
191
- {
192
- className: "ss-dash-log-reqid",
193
- title: h,
194
- onClick: (g) => {
195
- g.stopPropagation(), P(h);
196
- },
197
- role: "button",
198
- tabIndex: 0,
199
- onKeyDown: (g) => {
200
- g.key === "Enter" && (g.stopPropagation(), P(h));
201
- },
202
- children: h.slice(0, 8)
203
- }
204
- ) : /* @__PURE__ */ s("span", { className: "ss-dash-log-reqid-empty", children: "--" }),
205
- u ? /* @__PURE__ */ s(
206
- "span",
207
- {
208
- className: `ss-dash-log-expand-icon${C === t ? " ss-dash-log-expand-icon-open" : ""}`,
209
- children: "▶"
210
- }
211
- ) : /* @__PURE__ */ s("span", { style: { width: 14 } }),
212
- /* @__PURE__ */ s("span", { className: "ss-dash-log-msg", children: F })
213
- ]
214
- }
215
- ),
216
- C === t && u && /* @__PURE__ */ s("div", { className: "ss-dash-log-detail", children: /* @__PURE__ */ s(te, { data: u, classPrefix: "ss-dash", defaultExpanded: !0 }) })
217
- ] }, e.id || t);
218
- }) }),
219
- d && /* @__PURE__ */ s(
220
- le,
221
- {
222
- page: d.page,
223
- lastPage: d.lastPage,
224
- total: d.total,
225
- onPageChange: i
226
- }
227
- )
228
- ] });
229
- }
230
- export {
231
- he as LogsSection,
232
- he as default
233
- };
@@ -1,108 +0,0 @@
1
- import { jsx as s, jsxs as l } from "react/jsx-runtime";
2
- import q, { useState as m, useMemo as I, useCallback as E } from "react";
3
- import { filterLogsByLevel as S, resolveLogRequestId as y, resolveLogMessage as N, LOG_LEVELS as D, resolveLogLevel as R, resolveLogTimestamp as $, getStructuredData as A, getLogLevelCssClass as P, timeAgo as T, formatTime as j } from "adonisjs-server-stats/core";
4
- import { u as B, J } from "./index-CsImORX6.js";
5
- import { F as M } from "./FilterBar-CQ7bD669.js";
6
- function _({ options: x }) {
7
- const { data: r, isLoading: C, error: h } = B("logs", x), [p, w] = m("all"), [d, F] = m(""), [o, f] = m(""), [u, k] = m(null), b = I(() => {
8
- let e = Array.isArray(r) ? r : r?.logs || r?.entries || [];
9
- if (e = S(e, p), o) {
10
- const t = o.toLowerCase();
11
- e = e.filter((a) => y(a).toLowerCase().includes(t));
12
- }
13
- if (d) {
14
- const t = d.toLowerCase();
15
- e = e.filter((a) => N(a).toLowerCase().includes(t));
16
- }
17
- return e;
18
- }, [r, p, d, o]), L = E((e) => {
19
- f((t) => t === e ? "" : e);
20
- }, []);
21
- return C && !r ? /* @__PURE__ */ s("div", { className: "ss-dbg-empty", children: "Loading logs..." }) : h ? /* @__PURE__ */ l("div", { className: "ss-dbg-empty", children: [
22
- "Error: ",
23
- h.message
24
- ] }) : /* @__PURE__ */ l("div", { children: [
25
- /* @__PURE__ */ l("div", { className: "ss-dbg-log-filters", children: [
26
- D.map((e) => /* @__PURE__ */ s(
27
- "button",
28
- {
29
- type: "button",
30
- className: `ss-dbg-log-filter ${p === e ? "ss-dbg-active" : ""}`,
31
- onClick: () => w(e),
32
- children: e
33
- },
34
- e
35
- )),
36
- o && /* @__PURE__ */ l(
37
- "button",
38
- {
39
- type: "button",
40
- className: "ss-dbg-log-filter ss-dbg-active",
41
- onClick: () => f(""),
42
- children: [
43
- "req: ",
44
- o.slice(0, 8),
45
- " x"
46
- ]
47
- }
48
- ),
49
- /* @__PURE__ */ l("span", { className: "ss-dbg-summary", style: { marginLeft: "auto" }, children: [
50
- b.length,
51
- " entries"
52
- ] })
53
- ] }),
54
- /* @__PURE__ */ s(
55
- M,
56
- {
57
- search: d,
58
- onSearchChange: F,
59
- placeholder: "Filter log messages..."
60
- }
61
- ),
62
- /* @__PURE__ */ s("div", { style: { overflow: "auto", flex: 1 }, children: b.length === 0 ? /* @__PURE__ */ s("div", { className: "ss-dbg-empty", children: "No log entries" }) : b.slice(0, 200).map((e, t) => {
63
- const a = R(e), v = N(e), c = $(e), n = y(e), i = A(e);
64
- return /* @__PURE__ */ l(q.Fragment, { children: [
65
- /* @__PURE__ */ l(
66
- "div",
67
- {
68
- className: `ss-dbg-log-entry${i ? " ss-dbg-log-entry-expandable" : ""}`,
69
- onClick: () => i && k(u === t ? null : t),
70
- children: [
71
- /* @__PURE__ */ s("span", { className: `ss-dbg-log-level ${P(a)}`, children: a.toUpperCase() }),
72
- /* @__PURE__ */ s("span", { className: "ss-dbg-log-time", title: c ? j(c) : "", children: c ? T(c) : "-" }),
73
- n ? /* @__PURE__ */ s(
74
- "span",
75
- {
76
- className: "ss-dbg-log-reqid",
77
- onClick: (g) => {
78
- g.stopPropagation(), L(n);
79
- },
80
- role: "button",
81
- tabIndex: 0,
82
- title: n,
83
- onKeyDown: (g) => {
84
- g.key === "Enter" && (g.stopPropagation(), L(n));
85
- },
86
- children: n.slice(0, 8)
87
- }
88
- ) : /* @__PURE__ */ s("span", { className: "ss-dbg-log-reqid-empty", children: "-" }),
89
- i ? /* @__PURE__ */ s(
90
- "span",
91
- {
92
- className: `ss-dbg-log-expand-icon${u === t ? " ss-dbg-log-expand-icon-open" : ""}`,
93
- children: "▶"
94
- }
95
- ) : /* @__PURE__ */ s("span", { style: { width: 14 } }),
96
- /* @__PURE__ */ s("span", { className: "ss-dbg-log-msg", children: v })
97
- ]
98
- }
99
- ),
100
- u === t && i && /* @__PURE__ */ s("div", { className: "ss-dbg-log-detail", children: /* @__PURE__ */ s(J, { data: i, classPrefix: "ss-dbg", defaultExpanded: !0 }) })
101
- ] }, t);
102
- }) })
103
- ] });
104
- }
105
- export {
106
- _ as LogsTab,
107
- _ as default
108
- };