This commit is contained in:
oiov
2024-08-03 10:45:39 +08:00
parent 52e197ea4c
commit 8f739d2d4a
17 changed files with 43 additions and 60 deletions
+1 -12
View File
@@ -205,22 +205,11 @@ export default function UsersList({ user }: UrlListProps) {
))
) : (
<EmptyPlaceholder>
<EmptyPlaceholder.Icon name="user" />
<EmptyPlaceholder.Icon name="users" />
<EmptyPlaceholder.Title>No users</EmptyPlaceholder.Title>
<EmptyPlaceholder.Description>
Here don&apos;t have any user yet.
</EmptyPlaceholder.Description>
{/* <Button
className="w-[120px] shrink-0 gap-1"
variant="default"
onClick={() => {
setcurrentEditUser(null);
setShowForm(false);
setShowForm(!isShowForm);
}}
>
Add user
</Button> */}
</EmptyPlaceholder>
)}
</TableBody>
@@ -245,23 +245,11 @@ export default function UserRecordsList({ user, action }: RecordListProps) {
))
) : (
<EmptyPlaceholder>
{/* <EmptyPlaceholder.Icon name="globeLock" /> */}
<EmptyPlaceholder.Icon name="globeLock" />
<EmptyPlaceholder.Title>No records</EmptyPlaceholder.Title>
<EmptyPlaceholder.Description>
You don&apos;t have any record yet. Start creating record.
</EmptyPlaceholder.Description>
<Button
className="w-[120px] shrink-0 gap-1"
variant="default"
onClick={() => {
setCurrentEditRecord(null);
setShowForm(false);
setFormType("add");
setShowForm(!isShowForm);
}}
>
Add record
</Button>
</EmptyPlaceholder>
)}
</TableBody>
+17 -9
View File
@@ -140,7 +140,9 @@ export function DailyPVUVChart({ data }: { data: UrlMeta[] }) {
const triggers = { [TopoJSONMap.selectors.feature]: (d) => d.id };
const refererStats = generateStatsList(data, "referer");
const countryStats = generateStatsList(data, "region");
const cityStats = generateStatsList(data, "city");
const deviceStats = generateStatsList(data, "device");
const browserStats = generateStatsList(data, "browser");
return (
<Card className="rounded-t-none">
@@ -232,8 +234,14 @@ export function DailyPVUVChart({ data }: { data: UrlMeta[] }) {
{refererStats.length > 0 && (
<StatsList data={refererStats} title="Referrers" />
)}
{countryStats.length > 0 && (
<StatsList data={countryStats} title="Regions" />
{cityStats.length > 0 && (
<StatsList data={cityStats} title="Cities" />
)}
{browserStats.length > 0 && (
<StatsList data={browserStats} title="Browsers" />
)}
{deviceStats.length > 0 && (
<StatsList data={deviceStats} title="Devices" />
)}
</div>
@@ -255,10 +263,12 @@ export function StatsList({ data, title }: { data: Stat[]; title: string }) {
<div className="mb-0.5 flex items-center justify-between text-sm">
{isLink(ref.dimension) ? (
<Link
className="font-medium hover:after:content-['↗']"
className="truncate font-medium hover:opacity-70 hover:after:content-['↗']"
href={ref.dimension}
>
{ref.dimension}
{ref.dimension.startsWith("http")
? ref.dimension.split("//")[1]
: ref.dimension}
</Link>
) : (
<p className="font-medium">{ref.dimension}</p>
@@ -269,11 +279,9 @@ export function StatsList({ data, title }: { data: Stat[]; title: string }) {
</div>
<div className="w-full rounded-lg bg-neutral-200 dark:bg-neutral-600">
<div
className="rounded-lg bg-blue-400 p-0.5 text-center text-xs font-medium leading-none text-primary-foreground transition-all duration-300"
className="rounded-lg bg-blue-500 px-0.5 py-1.5 leading-none transition-all duration-300"
style={{ width: `${ref.percentage}` }}
>
{ref.percentage}
</div>
></div>
</div>
</div>
))}
+1 -13
View File
@@ -263,23 +263,11 @@ export default function UserUrlsList({ user, action }: UrlListProps) {
))
) : (
<EmptyPlaceholder>
{/* <EmptyPlaceholder.Icon name="link" /> */}
<EmptyPlaceholder.Icon name="link" />
<EmptyPlaceholder.Title>No urls</EmptyPlaceholder.Title>
<EmptyPlaceholder.Description>
You don&apos;t have any url yet. Start creating url.
</EmptyPlaceholder.Description>
<Button
className="w-[120px] shrink-0 gap-1"
variant="default"
onClick={() => {
setCurrentEditUrl(null);
setShowForm(false);
setFormType("add");
setShowForm(!isShowForm);
}}
>
Add url
</Button>
</EmptyPlaceholder>
)}
</TableBody>
+1 -1
View File
@@ -327,7 +327,7 @@ export function RecordForm({
</Button>
<Button
type="submit"
variant="default"
variant="blue"
disabled={isPending}
className="w-[80px] shrink-0 px-0"
>
+1 -1
View File
@@ -300,7 +300,7 @@ export function UrlForm({
</Button>
<Button
type="submit"
variant="default"
variant="blue"
disabled={isPending}
className="w-[80px] shrink-0 px-0"
>
+1 -1
View File
@@ -216,7 +216,7 @@ export function UserForm({
</Button>
<Button
type="submit"
variant="default"
variant="blue"
disabled={isPending}
className="w-[80px] shrink-0 px-0"
>
+1 -1
View File
@@ -75,7 +75,7 @@ export function UserNameForm({ user }: UserNameFormProps) {
/>
<Button
type="submit"
variant={updated ? "default" : "disable"}
variant={updated ? "blue" : "disable"}
disabled={isPending || !updated}
className="w-[67px] shrink-0 px-0 sm:w-[130px]"
>
+1 -1
View File
@@ -108,7 +108,7 @@ export function UserRoleForm({ user }: UserNameFormProps) {
/>
<Button
type="submit"
variant={updated ? "default" : "disable"}
variant={updated ? "blue" : "disable"}
disabled={isPending || !updated}
className="w-[67px] shrink-0 px-0 sm:w-[130px]"
>
+2
View File
@@ -10,6 +10,7 @@ import {
File,
FileText,
Flame,
Globe,
GlobeLock,
HelpCircle,
Home,
@@ -123,6 +124,7 @@ export const Icons = {
users: Users,
warning: AlertTriangle,
globeLock: GlobeLock,
globe: Globe,
link: Link,
mail: Mail,
};
+1
View File
@@ -19,6 +19,7 @@ const buttonVariants = cva(
link: "underline-offset-4 hover:underline text-primary",
disable:
"border border-input bg-transparent text-neutral-600 cursor-not-allowed",
blue: "bg-bluer text-white hover:bg-blue/90",
},
size: {
default: "h-10 py-2 px-4",
+2 -2
View File
@@ -30,13 +30,13 @@ export const sidebarLinks: SidebarNavItem[] = [
},
{
href: "/admin/records",
icon: "lineChart",
icon: "globe",
title: "Record List",
authorizeOnly: UserRole.ADMIN,
},
{
href: "/admin/urls",
icon: "post",
icon: "link",
title: "URL List",
authorizeOnly: UserRole.ADMIN,
},
+1 -6
View File
@@ -18,18 +18,13 @@ export default auth(async (req) => {
const geo = geolocation(req);
const userLanguage = req.headers.get("accept-language")?.split(",")[0];
const ua = req.headers.get("user-agent");
const ua = req.headers.get("user-agent") || "";
const parser = new UAParser();
parser.setUA(ua);
const browser = parser.getBrowser();
const device = parser.getDevice();
console.log(device, browser);
const referer = req.headers.get("referer") || "(None)";
// const res1 = await fetch(
// `${siteConfig.url}/api/s?slug=${match[0]}&referer=${referer}&ip=${ip}&city=${geo?.city}&region=${geo?.region}&country=${geo?.country}&latitude=${geo?.latitude}&longitude=${geo?.longitude}&flag=${geo?.flag}`,
// );
const res = await fetch(`${siteConfig.url}/api/s`, {
method: "POST",
+1
View File
@@ -106,6 +106,7 @@
"@types/node": "^20.14.11",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@types/ua-parser-js": "^0.7.39",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-config-next": "14.2.5",
+8
View File
@@ -264,6 +264,9 @@ importers:
'@types/react-dom':
specifier: 18.3.0
version: 18.3.0
'@types/ua-parser-js':
specifier: ^0.7.39
version: 0.7.39
autoprefixer:
specifier: ^10.4.19
version: 10.4.19(postcss@8.4.39)
@@ -2813,6 +2816,9 @@ packages:
'@types/topojson@3.2.6':
resolution: {integrity: sha512-ppfdlxjxofWJ66XdLgIlER/85RvpGyfOf8jrWf+3kVIjEatFxEZYD/Ea83jO672Xu1HRzd/ghwlbcZIUNHTskw==}
'@types/ua-parser-js@0.7.39':
resolution: {integrity: sha512-P/oDfpofrdtF5xw433SPALpdSchtJmY7nsJItf8h3KXqOslkbySh8zq4dSWXH2oTjRvJ5PczVEoCZPow6GicLg==}
'@types/ungap__structured-clone@1.2.0':
resolution: {integrity: sha512-ZoaihZNLeZSxESbk9PUAPZOlSpcKx81I1+4emtULDVmBLkYutTcMlCj2K9VNlf9EWODxdO6gkAqEaLorXwZQVA==}
@@ -9377,6 +9383,8 @@ snapshots:
'@types/topojson-simplify': 3.0.3
'@types/topojson-specification': 1.0.5
'@types/ua-parser-js@0.7.39': {}
'@types/ungap__structured-clone@1.2.0': {}
'@types/unist@2.0.10': {}
+2
View File
@@ -24,6 +24,7 @@
--input: 0 0% 89.8%;
--ring: 0 0% 3.9%;
--radius: 0.5rem;
--blue: 210 100% 50%;
--chart-1: 221.2 83.2% 53.3%;
--chart-2: 212 95% 68%;
@@ -52,6 +53,7 @@
--border: 0 0% 14.9%;
--input: 0 0% 14.9%;
--ring: 0 0% 83.1%;
--blue: 215 100% 50%;
--chart-1: 221.2 83.2% 53.3%;
--chart-2: 212 95% 68%;
+1
View File
@@ -26,6 +26,7 @@ const config = {
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
bluer: "hsl(var(--blue))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",