Skip to content

Commit

Permalink
refactor(logs-viewer): api integration (logs fetching, filtering) (#263)
Browse files Browse the repository at this point in the history
* feat(logs): create logs-viewer page and basic ui components: select, multiselect, drawer

* refactor(logs): refactor/restyle logs components; refactor style login page; add json viewer

* feat(logs): add date-time picker

* feat(logs-viewer): api implementation

* refactor(logs-viewer): remove parallel route for drawer; update logs queries

* refactor(logs-viewer): update folder structure, add logs filters, improve drawer ui

* Update LogsFiltersPanel.tsx

---------

Co-authored-by: Konstantinos Kopanidis <[email protected]>
  • Loading branch information
blossomingiris and kkopanidis authored Nov 4, 2024
1 parent ce89db8 commit 8eb5c8a
Show file tree
Hide file tree
Showing 20 changed files with 21,220 additions and 577 deletions.
62 changes: 8 additions & 54 deletions apps/admin/app/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,60 +1,14 @@
'use client';
import { Sidebar } from '@/components/navigation/sidebar';
import { SidebarItem } from '@/components/navigation/sidebarItem';
import { SidebarItemWithSub } from '@/components/navigation/sidebarItemWithSub';
import { navList } from '@/app/(dashboard)/navList';
import { usePathname } from 'next/navigation';

export default function Layout({ children }: { children: React.ReactNode }) {
const pathname = usePathname();
const isActive = (href: string) => pathname === href;
const isSubActive = (href: string) => pathname.includes(href);
import SidebarList from '@/components/navigation/sidebarList';

export default async function Layout({
children,
}: {
children: React.ReactNode;
}) {
return (
<div className={'flex'}>
<Sidebar>
{navList.map(item => {
if (item.children) {
return (
<SidebarItemWithSub
key={item.href}
active={isActive(item.href) || isSubActive(item.href)}
>
<SidebarItem href={item.href} key={item.href}>
{item.icon}
{item.name}
</SidebarItem>
{item.children.map(child => (
<SidebarItem
href={child.href}
active={
isActive(child.href) ||
(child.href !== item.href && isSubActive(child.href))
}
key={child.href}
>
{child.icon}
{child.name}
</SidebarItem>
))}
</SidebarItemWithSub>
);
}
return (
<SidebarItem
href={item.href}
active={isActive(item.href)}
key={item.href}
>
{item.icon}
{item.name}
</SidebarItem>
);
})}
</Sidebar>
<div className="relative flex-grow h-screen overflow-auto main-scrollbar">
{children}
</div>
<SidebarList />
<div className="relative flex-grow h-screen">{children}</div>
</div>
);
}
35 changes: 32 additions & 3 deletions apps/admin/app/(dashboard)/logs-viewer/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
import LogsViewer from '@/components/logs-viewer/LogsViewer';
import { getModules } from '@/lib/api/modules';
import { getLogsLevels, getLogsQueryRange } from '@/lib/api/logs-viewer';
import { knownModuleNames } from '@/lib/models/logs-viewer/constants';

export default async function LogsViewerPage() {
const modules = await getModules();
return <LogsViewer modules={modules} />;
const levelsData = await getLogsLevels();

const logsData = await getLogsQueryRange({
modules: knownModuleNames,
limit: '100',
});

const refreshLogs = async (data: {
modules: string[];
levels: string[];
startDate: number | undefined;
endDate: number | undefined;
limit: string | undefined;
}) => {
'use server';
const logs = await getLogsQueryRange({
...data,
modules: data.modules ? data.modules : knownModuleNames,
limit: data.limit ? data.limit : '100',
});
return logs;
};

return (
<LogsViewer
levelsData={levelsData}
logsData={logsData}
refreshLogs={refreshLogs}
/>
);
}
12 changes: 10 additions & 2 deletions apps/admin/app/(dashboard)/template.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import { usePathname } from 'next/navigation';
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
import Link from 'next/link';
import Image from 'next/image';
import React, { useEffect, useState } from 'react';
Expand Down Expand Up @@ -42,6 +42,7 @@ export default function ModuleHeader({
const [sockets, setSockets] = useState<boolean>(false); // client sockets
const [graphqlAdmin, setGraphqlAdmin] = useState<boolean>(false);
const [restAdmin, setRestAdmin] = useState<boolean>(false);

const [baseUrl, setBaseUrl] = useState<string>('');
const [adminUrl, setAdminUrl] = useState<string>('');
const pathname = usePathname();
Expand All @@ -62,7 +63,13 @@ export default function ModuleHeader({
});
}, []);

if (!moduleName) return <>{children}</>;
if (!moduleName)
return (
<>
<LogsDrawer />
{children}
</>
);

const RESTDocs: {
title: string;
Expand Down Expand Up @@ -223,6 +230,7 @@ export default function ModuleHeader({
</div>
</div>
<div className="container py-10 mx-auto">{children}</div>
<LogsDrawer />
</div>
);
}
7 changes: 1 addition & 6 deletions apps/admin/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,14 @@ export const metadata = {

export default function RootLayout({
children,
logsdrawer,
}: {
logsdrawer: React.ReactNode;
children: React.ReactNode;
}) {
return (
<html lang="en">
<body className={inter.className} style={{ overflow: 'hidden' }}>
<main className={'h-dvh min-w-[1080px] overflow-auto'}>
<ProviderInjector>
{children}
{logsdrawer}
</ProviderInjector>
<ProviderInjector>{children}</ProviderInjector>
</main>
<Toaster />
</body>
Expand Down
Loading

0 comments on commit 8eb5c8a

Please sign in to comment.