@hed-hog/core 0.0.215 → 0.0.216

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 (36) hide show
  1. package/hedhog/frontend/app/dashboard/[slug]/dashboard-content.tsx.ejs +5 -5
  2. package/hedhog/frontend/app/dashboard/[slug]/widget-renderer.tsx.ejs +1 -1
  3. package/hedhog/frontend/app/dashboard/components/add-widget-selector-dialog.tsx.ejs +312 -0
  4. package/hedhog/frontend/app/dashboard/components/dashboard-grid.tsx.ejs +54 -0
  5. package/hedhog/frontend/app/dashboard/components/draggable-grid.tsx.ejs +132 -0
  6. package/hedhog/frontend/app/dashboard/components/dynamic-widget.tsx.ejs +88 -0
  7. package/hedhog/frontend/app/dashboard/components/index.ts.ejs +6 -0
  8. package/hedhog/frontend/app/dashboard/components/stats.tsx.ejs +93 -0
  9. package/hedhog/frontend/app/dashboard/components/widget-wrapper.tsx.ejs +150 -0
  10. package/hedhog/frontend/app/dashboard/components/widgets/account-security.tsx.ejs +184 -0
  11. package/hedhog/frontend/app/dashboard/components/widgets/active-users-card.tsx.ejs +58 -0
  12. package/hedhog/frontend/app/dashboard/components/widgets/activity-timeline.tsx.ejs +219 -0
  13. package/hedhog/frontend/app/dashboard/components/widgets/email-notifications.tsx.ejs +191 -0
  14. package/hedhog/frontend/app/dashboard/components/widgets/locale-config.tsx.ejs +309 -0
  15. package/hedhog/frontend/app/dashboard/components/widgets/login-history-chart.tsx.ejs +111 -0
  16. package/hedhog/frontend/app/dashboard/components/widgets/mail-config.tsx.ejs +445 -0
  17. package/hedhog/frontend/app/dashboard/components/widgets/mail-sent-card.tsx.ejs +58 -0
  18. package/hedhog/frontend/app/dashboard/components/widgets/mail-sent-chart.tsx.ejs +149 -0
  19. package/hedhog/frontend/app/dashboard/components/widgets/oauth-config.tsx.ejs +296 -0
  20. package/hedhog/frontend/app/dashboard/components/widgets/permissions-card.tsx.ejs +61 -0
  21. package/hedhog/frontend/app/dashboard/components/widgets/permissions-chart.tsx.ejs +152 -0
  22. package/hedhog/frontend/app/dashboard/components/widgets/profile-card.tsx.ejs +186 -0
  23. package/hedhog/frontend/app/dashboard/components/widgets/session-activity-chart.tsx.ejs +183 -0
  24. package/hedhog/frontend/app/dashboard/components/widgets/sessions-today-card.tsx.ejs +62 -0
  25. package/hedhog/frontend/app/dashboard/components/widgets/stat-access-level.tsx.ejs +57 -0
  26. package/hedhog/frontend/app/dashboard/components/widgets/stat-actions-today.tsx.ejs +57 -0
  27. package/hedhog/frontend/app/dashboard/components/widgets/stat-consecutive-days.tsx.ejs +57 -0
  28. package/hedhog/frontend/app/dashboard/components/widgets/stat-online-time.tsx.ejs +57 -0
  29. package/hedhog/frontend/app/dashboard/components/widgets/storage-config.tsx.ejs +340 -0
  30. package/hedhog/frontend/app/dashboard/components/widgets/theme-config.tsx.ejs +275 -0
  31. package/hedhog/frontend/app/dashboard/components/widgets/user-growth-chart.tsx.ejs +210 -0
  32. package/hedhog/frontend/app/dashboard/components/widgets/user-roles.tsx.ejs +130 -0
  33. package/hedhog/frontend/app/dashboard/components/widgets/user-sessions.tsx.ejs +233 -0
  34. package/hedhog/frontend/messages/en.json +143 -1
  35. package/hedhog/frontend/messages/pt.json +143 -1
  36. package/package.json +3 -3
@@ -0,0 +1,183 @@
1
+ 'use client';
2
+
3
+ import {
4
+ Card,
5
+ CardContent,
6
+ CardDescription,
7
+ CardHeader,
8
+ CardTitle,
9
+ } from '@/components/ui/card';
10
+ import { useWidgetData } from '@/hooks/use-widget-data';
11
+ import { IconGripVertical } from '@tabler/icons-react';
12
+ import { useTranslations } from 'next-intl';
13
+ import {
14
+ CartesianGrid,
15
+ Line,
16
+ LineChart,
17
+ ResponsiveContainer,
18
+ Tooltip,
19
+ XAxis,
20
+ YAxis,
21
+ } from 'recharts';
22
+ import { WidgetWrapper } from '../widget-wrapper';
23
+
24
+ function CustomTooltip({
25
+ active,
26
+ payload,
27
+ label,
28
+ }: {
29
+ active?: boolean;
30
+ payload?: Array<{ value: number; dataKey: string }>;
31
+ label?: string;
32
+ }) {
33
+ const t = useTranslations('core.Dashboard');
34
+ if (!active || !payload?.length) return null;
35
+
36
+ return (
37
+ <div className="rounded-lg border bg-card px-3 py-2 shadow-xl">
38
+ <p className="mb-1 text-xs font-medium text-card-foreground">{label}</p>
39
+ {payload.map((entry) => (
40
+ <p key={entry.dataKey} className="text-xs text-muted-foreground">
41
+ <span
42
+ className="mr-1.5 inline-block h-2 w-2 rounded-full"
43
+ style={{
44
+ backgroundColor:
45
+ entry.dataKey === 'active' ? '#10b981' : '#f59e0b',
46
+ }}
47
+ />
48
+ {entry.dataKey === 'active' ? t('active') : t('expired')}:{' '}
49
+ {entry.value}
50
+ </p>
51
+ ))}
52
+ </div>
53
+ );
54
+ }
55
+
56
+ interface SessionActivityChartProps {
57
+ widget?: any;
58
+ onRemove?: () => void;
59
+ }
60
+
61
+ interface UserStatsData {
62
+ charts?: {
63
+ sessionActivity?: Array<{
64
+ hour: string;
65
+ active: number;
66
+ expired: number;
67
+ }>;
68
+ };
69
+ }
70
+
71
+ export default function SessionActivityChart({
72
+ widget,
73
+ onRemove,
74
+ }: SessionActivityChartProps) {
75
+ const t = useTranslations('core.Dashboard');
76
+
77
+ const {
78
+ data: statsData,
79
+ isLoading,
80
+ isAccessDenied,
81
+ isError,
82
+ } = useWidgetData<UserStatsData>({
83
+ endpoint: '/dashboard-core/stats/overview/users',
84
+ queryKey: 'dashboard-stats-users',
85
+ });
86
+
87
+ const data = statsData?.charts?.sessionActivity || [];
88
+
89
+ return (
90
+ <WidgetWrapper
91
+ isLoading={isLoading}
92
+ isAccessDenied={isAccessDenied}
93
+ isError={isError}
94
+ widgetName={widget?.name || t('sessionActivityTitle')}
95
+ onRemove={onRemove}
96
+ >
97
+ <Card className="h-full flex flex-col group">
98
+ <div
99
+ className="drag-handle absolute top-3 left-4 z-10"
100
+ style={{ cursor: 'grab' }}
101
+ >
102
+ <IconGripVertical className="text-muted-foreground/50 size-4 shrink-0" />
103
+ </div>
104
+ <CardHeader className="flex flex-row items-center justify-between pb-2 pt-4">
105
+ <div className="pl-6">
106
+ <CardTitle className="text-base font-semibold">
107
+ {t('sessionActivityTitle')}
108
+ </CardTitle>
109
+ <CardDescription>{t('sessionActivityDescription')}</CardDescription>
110
+ </div>
111
+ </CardHeader>
112
+ <CardContent className="flex-1 pt-0">
113
+ <div className="h-[200px] w-full">
114
+ <ResponsiveContainer width="100%" height="100%">
115
+ <LineChart
116
+ data={data}
117
+ margin={{ top: 5, right: 10, left: -20, bottom: 0 }}
118
+ >
119
+ <CartesianGrid
120
+ strokeDasharray="3 3"
121
+ stroke="currentColor"
122
+ opacity={0.1}
123
+ />
124
+ <XAxis
125
+ dataKey="hour"
126
+ tick={{ fill: 'hsl(var(--muted-foreground))', fontSize: 11 }}
127
+ axisLine={false}
128
+ tickLine={false}
129
+ />
130
+ <YAxis
131
+ tick={{ fill: 'hsl(var(--muted-foreground))', fontSize: 11 }}
132
+ axisLine={false}
133
+ tickLine={false}
134
+ />
135
+ <Tooltip content={<CustomTooltip />} />
136
+ <Line
137
+ type="monotone"
138
+ dataKey="active"
139
+ stroke="#10b981"
140
+ strokeWidth={3}
141
+ dot={false}
142
+ activeDot={{ r: 5, fill: '#10b981' }}
143
+ animationDuration={1500}
144
+ />
145
+ <Line
146
+ type="monotone"
147
+ dataKey="expired"
148
+ stroke="#f59e0b"
149
+ strokeWidth={2.5}
150
+ dot={false}
151
+ strokeDasharray="5 5"
152
+ activeDot={{ r: 4, fill: '#f59e0b' }}
153
+ animationDuration={1500}
154
+ animationBegin={300}
155
+ />
156
+ </LineChart>
157
+ </ResponsiveContainer>
158
+ </div>
159
+ <div className="mt-2 flex items-center justify-center gap-6">
160
+ <div className="flex items-center gap-2">
161
+ <div
162
+ className="h-0.5 w-4 rounded-full"
163
+ style={{ backgroundColor: '#10b981' }}
164
+ />
165
+ <span className="text-xs text-muted-foreground">
166
+ {t('active')}
167
+ </span>
168
+ </div>
169
+ <div className="flex items-center gap-2">
170
+ <div
171
+ className="h-0.5 w-4 rounded-full"
172
+ style={{ backgroundColor: '#f59e0b' }}
173
+ />
174
+ <span className="text-xs text-muted-foreground">
175
+ {t('expired')}
176
+ </span>
177
+ </div>
178
+ </div>
179
+ </CardContent>
180
+ </Card>
181
+ </WidgetWrapper>
182
+ );
183
+ }
@@ -0,0 +1,62 @@
1
+ import { useWidgetData } from '@/hooks/use-widget-data';
2
+ import { Activity } from 'lucide-react';
3
+ import { useTranslations } from 'next-intl';
4
+ import StatCard from '../stats';
5
+ import { WidgetWrapper } from '../widget-wrapper';
6
+
7
+ interface SessionsTodayProps {
8
+ widget?: any;
9
+ onRemove?: () => void;
10
+ }
11
+
12
+ interface UserStatsData {
13
+ cards?: {
14
+ sessionsToday?: {
15
+ value: number;
16
+ change: number | null;
17
+ };
18
+ };
19
+ }
20
+
21
+ export default function SessionsToday({
22
+ widget,
23
+ onRemove,
24
+ }: SessionsTodayProps) {
25
+ const t = useTranslations('core.Dashboard');
26
+
27
+ const { data, isLoading, isAccessDenied, isError } =
28
+ useWidgetData<UserStatsData>({
29
+ endpoint: '/dashboard-core/stats/overview/users',
30
+ queryKey: 'dashboard-stats-users',
31
+ });
32
+
33
+ const value =
34
+ data?.cards?.sessionsToday?.value?.toLocaleString('pt-BR') || '0';
35
+ const change = data?.cards?.sessionsToday?.change;
36
+ const changeType =
37
+ change !== null && change !== undefined && change >= 0 ? 'up' : 'down';
38
+
39
+ return (
40
+ <WidgetWrapper
41
+ isLoading={isLoading}
42
+ isAccessDenied={isAccessDenied}
43
+ isError={isError}
44
+ widgetName={widget?.name || t('sessionsToday')}
45
+ onRemove={onRemove}
46
+ >
47
+ <StatCard
48
+ title={t('sessionsToday')}
49
+ value={value}
50
+ change={
51
+ change !== null && change !== undefined
52
+ ? `${change > 0 ? '+' : ''}${change}%`
53
+ : undefined
54
+ }
55
+ changeType={changeType}
56
+ icon={<Activity className="h-6 w-6 text-emerald-500" />}
57
+ iconBg="bg-emerald-500/10"
58
+ delay={100}
59
+ />
60
+ </WidgetWrapper>
61
+ );
62
+ }
@@ -0,0 +1,57 @@
1
+ 'use client';
2
+
3
+ import { Card, CardContent } from '@/components/ui/card';
4
+ import { useWidgetData } from '@/hooks/use-widget-data';
5
+ import type { AllWidgetsData } from '@/types/widget-data';
6
+ import { Zap } from 'lucide-react';
7
+ import { useTranslations } from 'next-intl';
8
+ import { WidgetWrapper } from '../widget-wrapper';
9
+
10
+ interface StatAccessLevelProps {
11
+ widget?: { name?: string };
12
+ onRemove?: () => void;
13
+ }
14
+
15
+ export default function StatAccessLevel({
16
+ widget,
17
+ onRemove,
18
+ }: StatAccessLevelProps) {
19
+ const t = useTranslations('core.DashboardPage.quickStats');
20
+ const { data, isLoading, isError, isAccessDenied } = useWidgetData<
21
+ AllWidgetsData,
22
+ number
23
+ >({
24
+ endpoint: '/dashboard-core/widgets/me',
25
+ queryKey: 'widget-me',
26
+ select: (d) => d.quickStats.securityLevel,
27
+ });
28
+
29
+ return (
30
+ <WidgetWrapper
31
+ isLoading={isLoading}
32
+ isError={isError}
33
+ isAccessDenied={isAccessDenied}
34
+ widgetName={widget?.name ?? 'stat-access-level'}
35
+ onRemove={onRemove}
36
+ >
37
+ <Card className="h-full overflow-hidden transition-all duration-300 hover:shadow-md">
38
+ <CardContent className="flex h-full items-center gap-4 p-4">
39
+ <div className="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-amber-50 dark:bg-amber-950/40">
40
+ <Zap className="h-5 w-5 text-amber-600 dark:text-amber-400" />
41
+ </div>
42
+ <div className="flex min-w-0 flex-col">
43
+ <span className="text-[11px] font-medium uppercase tracking-wider text-muted-foreground">
44
+ {t('accessLevel')}
45
+ </span>
46
+ <span className="text-2xl font-bold tracking-tight text-foreground">
47
+ {data ? t('accessLevelValue', { level: data }) : '—'}
48
+ </span>
49
+ <span className="text-[11px] text-muted-foreground">
50
+ {t('accessLevelSubtitle')}
51
+ </span>
52
+ </div>
53
+ </CardContent>
54
+ </Card>
55
+ </WidgetWrapper>
56
+ );
57
+ }
@@ -0,0 +1,57 @@
1
+ 'use client';
2
+
3
+ import { Card, CardContent } from '@/components/ui/card';
4
+ import { useWidgetData } from '@/hooks/use-widget-data';
5
+ import type { AllWidgetsData } from '@/types/widget-data';
6
+ import { MousePointerClick } from 'lucide-react';
7
+ import { useTranslations } from 'next-intl';
8
+ import { WidgetWrapper } from '../widget-wrapper';
9
+
10
+ interface StatActionsTodayProps {
11
+ widget?: { name?: string };
12
+ onRemove?: () => void;
13
+ }
14
+
15
+ export default function StatActionsToday({
16
+ widget,
17
+ onRemove,
18
+ }: StatActionsTodayProps) {
19
+ const t = useTranslations('core.DashboardPage.quickStats');
20
+ const { data, isLoading, isError, isAccessDenied } = useWidgetData<
21
+ AllWidgetsData,
22
+ number
23
+ >({
24
+ endpoint: '/dashboard-core/widgets/me',
25
+ queryKey: 'widget-me',
26
+ select: (d) => d.quickStats.actionsToday,
27
+ });
28
+
29
+ return (
30
+ <WidgetWrapper
31
+ isLoading={isLoading}
32
+ isError={isError}
33
+ isAccessDenied={isAccessDenied}
34
+ widgetName={widget?.name ?? 'stat-actions-today'}
35
+ onRemove={onRemove}
36
+ >
37
+ <Card className="h-full overflow-hidden transition-all duration-300 hover:shadow-md">
38
+ <CardContent className="flex h-full items-center gap-4 p-4">
39
+ <div className="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-indigo-50 dark:bg-indigo-950/40">
40
+ <MousePointerClick className="h-5 w-5 text-indigo-600 dark:text-indigo-400" />
41
+ </div>
42
+ <div className="flex min-w-0 flex-col">
43
+ <span className="text-[11px] font-medium uppercase tracking-wider text-muted-foreground">
44
+ {t('actionsToday')}
45
+ </span>
46
+ <span className="text-2xl font-bold tracking-tight text-foreground">
47
+ {data ?? '—'}
48
+ </span>
49
+ <span className="text-[11px] text-muted-foreground">
50
+ {t('actionsTodaySubtitle')}
51
+ </span>
52
+ </div>
53
+ </CardContent>
54
+ </Card>
55
+ </WidgetWrapper>
56
+ );
57
+ }
@@ -0,0 +1,57 @@
1
+ 'use client';
2
+
3
+ import { Card, CardContent } from '@/components/ui/card';
4
+ import { useWidgetData } from '@/hooks/use-widget-data';
5
+ import type { AllWidgetsData } from '@/types/widget-data';
6
+ import { CalendarDays } from 'lucide-react';
7
+ import { useTranslations } from 'next-intl';
8
+ import { WidgetWrapper } from '../widget-wrapper';
9
+
10
+ interface StatConsecutiveDaysProps {
11
+ widget?: { name?: string };
12
+ onRemove?: () => void;
13
+ }
14
+
15
+ export default function StatConsecutiveDays({
16
+ widget,
17
+ onRemove,
18
+ }: StatConsecutiveDaysProps) {
19
+ const t = useTranslations('core.DashboardPage.quickStats');
20
+ const { data, isLoading, isError, isAccessDenied } = useWidgetData<
21
+ AllWidgetsData,
22
+ number
23
+ >({
24
+ endpoint: '/dashboard-core/widgets/me',
25
+ queryKey: 'widget-me',
26
+ select: (d) => d.quickStats.consecutiveDays,
27
+ });
28
+
29
+ return (
30
+ <WidgetWrapper
31
+ isLoading={isLoading}
32
+ isError={isError}
33
+ isAccessDenied={isAccessDenied}
34
+ widgetName={widget?.name ?? 'stat-consecutive-days'}
35
+ onRemove={onRemove}
36
+ >
37
+ <Card className="h-full overflow-hidden transition-all duration-300 hover:shadow-md">
38
+ <CardContent className="flex h-full items-center gap-4 p-4">
39
+ <div className="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-emerald-50 dark:bg-emerald-950/40">
40
+ <CalendarDays className="h-5 w-5 text-emerald-600 dark:text-emerald-400" />
41
+ </div>
42
+ <div className="flex min-w-0 flex-col">
43
+ <span className="text-[11px] font-medium uppercase tracking-wider text-muted-foreground">
44
+ {t('consecutiveDays')}
45
+ </span>
46
+ <span className="text-2xl font-bold tracking-tight text-foreground">
47
+ {data ?? '—'}
48
+ </span>
49
+ <span className="text-[11px] text-muted-foreground">
50
+ {t('consecutiveDaysSubtitle')}
51
+ </span>
52
+ </div>
53
+ </CardContent>
54
+ </Card>
55
+ </WidgetWrapper>
56
+ );
57
+ }
@@ -0,0 +1,57 @@
1
+ 'use client';
2
+
3
+ import { Card, CardContent } from '@/components/ui/card';
4
+ import { useWidgetData } from '@/hooks/use-widget-data';
5
+ import type { AllWidgetsData } from '@/types/widget-data';
6
+ import { Clock } from 'lucide-react';
7
+ import { useTranslations } from 'next-intl';
8
+ import { WidgetWrapper } from '../widget-wrapper';
9
+
10
+ interface StatOnlineTimeProps {
11
+ widget?: { name?: string };
12
+ onRemove?: () => void;
13
+ }
14
+
15
+ export default function StatOnlineTime({
16
+ widget,
17
+ onRemove,
18
+ }: StatOnlineTimeProps) {
19
+ const t = useTranslations('core.DashboardPage.quickStats');
20
+ const { data, isLoading, isError, isAccessDenied } = useWidgetData<
21
+ AllWidgetsData,
22
+ string
23
+ >({
24
+ endpoint: '/dashboard-core/widgets/me',
25
+ queryKey: 'widget-me',
26
+ select: (d) => d.quickStats.onlineTime,
27
+ });
28
+
29
+ return (
30
+ <WidgetWrapper
31
+ isLoading={isLoading}
32
+ isError={isError}
33
+ isAccessDenied={isAccessDenied}
34
+ widgetName={widget?.name ?? 'stat-online-time'}
35
+ onRemove={onRemove}
36
+ >
37
+ <Card className="h-full overflow-hidden transition-all duration-300 hover:shadow-md">
38
+ <CardContent className="flex h-full items-center gap-4 p-4">
39
+ <div className="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-blue-50 dark:bg-blue-950/40">
40
+ <Clock className="h-5 w-5 text-blue-600 dark:text-blue-400" />
41
+ </div>
42
+ <div className="flex min-w-0 flex-col">
43
+ <span className="text-[11px] font-medium uppercase tracking-wider text-muted-foreground">
44
+ {t('onlineTime')}
45
+ </span>
46
+ <span className="text-2xl font-bold tracking-tight text-foreground">
47
+ {data ?? '—'}
48
+ </span>
49
+ <span className="text-[11px] text-muted-foreground">
50
+ {t('onlineTimeSubtitle')}
51
+ </span>
52
+ </div>
53
+ </CardContent>
54
+ </Card>
55
+ </WidgetWrapper>
56
+ );
57
+ }