Skip to content

Commit

Permalink
feature: add group, create, upload links to dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
vid277 authored and densumesh committed Jul 30, 2024
1 parent e8de32d commit 3af7d57
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 45 deletions.
88 changes: 73 additions & 15 deletions frontends/dashboard/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { For, createMemo, createSignal, useContext } from "solid-js";
import {
For,
createMemo,
createSignal,
useContext,
Show,
createEffect,
} from "solid-js";
import { UserContext } from "../contexts/UserContext";
import { useNavigate } from "@solidjs/router";
import { IoLogOutOutline, IoOpenOutline } from "solid-icons/io";
import { AiOutlinePlus, AiOutlineUser } from "solid-icons/ai";
import { FaSolidAngleDown, FaSolidAngleRight } from "solid-icons/fa";
import CreateNewOrgModal from "./CreateNewOrgModal";
import { DatasetContext } from "../contexts/DatasetContext";

Expand All @@ -18,6 +26,16 @@ export const Sidebar = () => {
const datasetContext = useContext(DatasetContext);

const [showNewOrgModal, setShowNewOrgModal] = createSignal(false);
const [showSubMenu, setShowSubMenu] = createSignal(
localStorage.getItem("showSubMenu") !== "false",
);

createEffect(() => {
return localStorage.setItem(
"showSubMenu",
showSubMenu() ? "true" : "false",
);
});

const sortedOrgs = createMemo(
() =>
Expand Down Expand Up @@ -74,31 +92,71 @@ export const Sidebar = () => {
<div class="border-b px-4 py-3">
<h5 class="font-semibold text-neutral-600">Admin Tools</h5>
<div class="flex flex-col items-start space-y-1 py-2">
<div class="flex items-center text-neutral-800 hover:text-fuchsia-800">
<a
href={`${searchUiURL}${orgDatasetParams()}`}
target="_blank"
class="flex items-center"
>
Search playground{" "}
<IoOpenOutline class="ml-1 inline-block h-4 w-4" />
</a>
<div class="flex flex-col items-center text-neutral-800">
<div class="flex items-center gap-2">
<button
class="hover:text-fuchsia-800"
onClick={() => setShowSubMenu(!showSubMenu())}
>
{showSubMenu() ? (
<FaSolidAngleDown />
) : (
<FaSolidAngleRight />
)}
</button>
<a
href={`${searchUiURL}${orgDatasetParams()}`}
target="_blank"
class="flex w-full items-center hover:text-fuchsia-800"
>
<span>Search playground</span>
<IoOpenOutline class="ml-1 inline-block h-4 w-4" />
</a>
</div>
<Show when={showSubMenu()}>
<div class="space-y-1 pb-1 pl-4 pt-1">
<a
href={`${searchUiURL}/group${orgDatasetParams()}`}
target="_blank"
class="flex items-center hover:text-fuchsia-800"
>
View Groups{" "}
<IoOpenOutline class="ml-1 inline-block h-4 w-4" />
</a>
<a
href={`${searchUiURL}/create${orgDatasetParams()}`}
target="_blank"
class="flex items-center hover:text-fuchsia-800"
>
Create Chunk{" "}
<IoOpenOutline class="ml-1 inline-block h-4 w-4" />
</a>
<a
href={`${searchUiURL}/upload${orgDatasetParams()}`}
target="_blank"
class="flex items-center hover:text-fuchsia-800"
>
Upload File{" "}
<IoOpenOutline class="ml-1 inline-block h-4 w-4" />
</a>
</div>
</Show>
</div>
<div class="flex items-center text-neutral-800 hover:text-fuchsia-800">
<div class="flex w-full items-center pl-6 text-neutral-800 hover:text-fuchsia-800">
<a
href={`${chatUiURL}${orgDatasetParams()}`}
target="_blank"
class="flex items-center"
class="flex w-full items-center"
>
<span>RAG playground</span>{" "}
<span>RAG playground</span>
<IoOpenOutline class="ml-1 inline-block h-4 w-4" />
</a>
</div>
<div class="flex items-center text-neutral-800 hover:text-fuchsia-800">
<div class="flex w-full items-center pl-6 text-neutral-800 hover:text-fuchsia-800">
<a
href={`${analyticsUiURL}${orgDatasetParams()}`}
target="_blank"
class="flex items-center"
class="flex w-full items-center"
>
Analytics playground{" "}
<IoOpenOutline class="ml-1 inline-block h-4 w-4" />
Expand Down
33 changes: 3 additions & 30 deletions frontends/dashboard/src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
import { createEffect, useContext } from "solid-js";
import { createToast } from "../components/ShowToasts";
import { UserContext } from "../contexts/UserContext";

export const Home = () => {
const api_host: string = import.meta.env.VITE_API_HOST as string;

const userContext = useContext(UserContext);

const login = () => {
fetch(`${api_host}/auth/me`, {
credentials: "include",
})
.then((res) => {
if (res.status === 401) {
window.location.href = `${api_host}/auth?redirect_uri=${window.origin}`;
return;
}
return res.json();
})
.then(() => {
window.location.href = `${
window.origin
}/dashboard/${userContext.selectedOrganizationId?.()}`;
})
.catch((err) => {
console.error(err);
createToast({
title: "Error",
type: "error",
message: "Error logging in",
});
});
};

createEffect(() => {
login();
window.location.href = `${
window.origin
}/dashboard/${userContext.selectedOrganizationId?.()}`;
});
return <div />;
};

0 comments on commit 3af7d57

Please sign in to comment.