Opensearch embed changes

This commit is contained in:
Darren Clarke 2024-11-28 08:27:20 +01:00
parent 130554d86b
commit a8dd53507d
11 changed files with 237 additions and 178 deletions

View file

@ -3,9 +3,10 @@
import { FC } from "react";
import { OpenSearchWrapper } from "@link-stack/leafcutter-ui";
export const Home: FC = () => (
<OpenSearchWrapper
url="/app/visualize#/edit/237b8f00-e6a0-11ee-94b3-d7b7409294e7?embed=true"
marginTop="0"
/>
type HomeProps = {
url: string;
};
export const Home: FC<HomeProps> = ({ url }) => (
<OpenSearchWrapper url={url} margin={0} />
);

View file

@ -501,7 +501,17 @@ export const Sidebar: FC<SidebarProps> = ({
selected={pathname.endsWith("/reporting")}
open={open}
/>
{leafcutterEnabled && (
{roles.includes("admin") && leafcutterEnabled && (
<MenuItem
name="Opensearch"
href="/opensearch"
Icon={InsightsIcon}
iconSize={20}
selected={pathname.startsWith("/opensearch")}
open={open}
/>
)}
{false && leafcutterEnabled && (
<MenuItem
name="Leafcutter"
href="/leafcutter"

View file

@ -0,0 +1,5 @@
import { OpenSearchWrapper } from "@link-stack/leafcutter-ui";
export default function Page() {
return <OpenSearchWrapper url="/app/visualize#/" margin={50} />;
}

View file

@ -1,9 +1,10 @@
import { Metadata } from "next";
import { redirect } from "next/navigation";
import { getServerSession } from "app/_lib/authentication";
import { Home } from "@link-stack/leafcutter-ui";
import { getUserVisualizations } from "@link-stack/opensearch-common";
import { LeafcutterWrapper } from "@link-stack/leafcutter-ui";
import { Home } from "./_components/Home";
// import { getServerSession } from "app/_lib/authentication";
// import { Home } from "@link-stack/leafcutter-ui";
// import { getUserVisualizations } from "@link-stack/opensearch-common";
// import { LeafcutterWrapper } from "@link-stack/leafcutter-ui";
export const metadata: Metadata = {
title: "CDR Link - Home",
@ -11,21 +12,31 @@ export const metadata: Metadata = {
export default async function Page() {
const leafcutterEnabled = process.env.LEAFCUTTER_ENABLED === "true";
const dashboardURL = process.env.LEAFCUTTER_DEFAULT_DASHBOARD_URL;
if (!leafcutterEnabled) {
redirect("/overview/recent");
}
/*
const session = await getServerSession();
const {
user: { email },
}: any = session;
const visualizations = await getUserVisualizations(email ?? "none", 20);
*/
let visualizations = [];
/*
try {
visualizations = await getUserVisualizations(email ?? "none", 20);
} catch (e) {
console.error(e.meta);
}
return (
<LeafcutterWrapper>
<Home visualizations={visualizations} showWelcome={false} />
</LeafcutterWrapper>
);
*/
return <Home url={dashboardURL} />;
}