Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new dashboard experience #2334

Merged
merged 59 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a995953
feat: init new console
drew-harris Sep 11, 2024
0a4894d
feat: consistent dataset context
drew-harris Sep 12, 2024
59c3e44
feat: even better context
drew-harris Sep 12, 2024
9746173
feat: magicbox
drew-harris Sep 12, 2024
16b8690
styling: shimmer on magic box
drew-harris Sep 12, 2024
108c396
feat: more magic box props
drew-harris Sep 12, 2024
96166f6
feat: magic suspense
drew-harris Sep 12, 2024
0504438
fix: suspense height tracking
drew-harris Sep 12, 2024
9008e91
styling: shimmer class fixes
drew-harris Sep 12, 2024
6fd73c3
feat: events page
drew-harris Sep 12, 2024
6c725b9
feat: api keys
drew-harris Sep 12, 2024
0142c61
feat: dataset sidebar with selector
drew-harris Sep 14, 2024
dd7c4b3
feat: various fixes
drew-harris Sep 14, 2024
419ff8e
feat: better sidebar
drew-harris Sep 14, 2024
98c211a
styling: sidebar icons
drew-harris Sep 15, 2024
c4b00e1
feat: org layout
drew-harris Sep 16, 2024
1333d68
cleanup: small fixes
drew-harris Sep 16, 2024
d764e30
feat: fix usage
drew-harris Sep 16, 2024
5599a44
fix: extract type
drew-harris Sep 16, 2024
64a17f7
feat: dataset overview
drew-harris Sep 16, 2024
68eb0bd
feat: more org fixes
drew-harris Sep 16, 2024
982de8b
feat: add org user page
drew-harris Sep 16, 2024
916ae1c
feat: small fixes
drew-harris Sep 16, 2024
20fbfc1
feat: billing pages
drew-harris Sep 16, 2024
c14b9bd
feat: api keys page
drew-harris Sep 17, 2024
f6955eb
feat: org settings page
drew-harris Sep 17, 2024
b6211c2
feat: add copy id button
drew-harris Sep 17, 2024
6d53c1e
feat: more fixes
drew-harris Sep 17, 2024
1463875
feat: working dataset settings
drew-harris Sep 17, 2024
34c58f8
feat: dataset settings
drew-harris Sep 17, 2024
16726eb
fix: event log
drew-harris Sep 17, 2024
b6078a1
feat: more on dataset homepage
drew-harris Sep 17, 2024
f79089c
feat: add code examples
drew-harris Sep 17, 2024
daec3da
feat: add building something
drew-harris Sep 17, 2024
3261912
feat: fix CI
drew-harris Sep 17, 2024
f1a258d
feat: org switching
drew-harris Sep 17, 2024
a690955
feat: create org
drew-harris Sep 17, 2024
a9bcb4b
fix: fix user cache flashing org select
drew-harris Sep 17, 2024
4cdfa56
fix: auth edge cases
drew-harris Sep 17, 2024
e02dcee
fix: eslint
drew-harris Sep 17, 2024
2eff482
fix: tsc check
drew-harris Sep 17, 2024
ca2f8f2
feat: fix types on tanstack table
drew-harris Sep 18, 2024
6a4aec3
feat: table type safety
drew-harris Sep 18, 2024
bafab64
feat: better api keys table
drew-harris Sep 18, 2024
b509acf
feat: new dataset overview
drew-harris Sep 18, 2024
aca49ae
feat: simplify new org creation
drew-harris Sep 18, 2024
a7805aa
feat: refactor user and invite tables
drew-harris Sep 18, 2024
3e64606
feat: add usage
drew-harris Sep 18, 2024
0c68b0d
fix: eslint
drew-harris Sep 18, 2024
d769c32
cleanup: put port back
drew-harris Sep 18, 2024
eff3e3f
styling: fix z-index conflict btwn tables and org create popup
drew-harris Sep 18, 2024
4aa4388
styling: bottom padding for org billing page
drew-harris Sep 18, 2024
84e055e
feat: add analytics link to playgrounds
drew-harris Sep 18, 2024
18ac778
fix: remove fake delay from testing
drew-harris Sep 18, 2024
ab08a91
styling: add padding to bottom of org homepage
drew-harris Sep 18, 2024
eed8e86
cleanup: remove extra file
drew-harris Sep 18, 2024
15750e6
config: fix vscode config for shared ui lib
skeptrunedev Sep 18, 2024
2f85385
styling: remove double padding and adjust width
skeptrunedev Sep 18, 2024
f00b24e
lint: fix eslint issues in analytics frontend
skeptrunedev Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"./frontends/dashboard",
"./frontends/search",
"./frontends/analytics",
"./frontends/shared",
"./clients/ts-sdk",
"./clients/search-component"
],
Expand Down
47 changes: 30 additions & 17 deletions frontends/analytics/src/components/charts/HeadQueries.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AnalyticsFilter, HeadQuery } from "shared/types";
import { Show } from "solid-js";
import { createMemo, Show } from "solid-js";
import { SortableColumnDef, TanStackTable } from "shared/ui";
import { useHeadQueries } from "../../hooks/data/useHeadQueries";
import { createSolidTable, getCoreRowModel } from "@tanstack/solid-table";
Expand All @@ -20,31 +20,44 @@ const columns: SortableColumnDef<HeadQuery>[] = [
];

export const HeadQueries = (props: HeadQueriesProps) => {
const { headQueriesQuery, pages } = useHeadQueries({
params: props.params,
const headQueriesData = createMemo(() => {
return useHeadQueries({
params: props.params,
});
});
const table = createSolidTable({
get data() {
return headQueriesQuery.data || [];
},
state: {
pagination: {
pageIndex: pages.page(),
pageSize: 10,

const tableMemo = createMemo(() => {
const { headQueriesQuery, pages } = headQueriesData();
const table = createSolidTable({
get data() {
return headQueriesQuery.data || [];
},
state: {
pagination: {
pageIndex: pages.page(),
pageSize: 10,
},
},
},
columns,
getCoreRowModel: getCoreRowModel(),
manualPagination: true,
columns,
getCoreRowModel: getCoreRowModel(),
manualPagination: true,
});

return table;
});

return (
<>
<Show
fallback={<div class="py-8">Loading...</div>}
when={headQueriesQuery.data}
when={headQueriesData().headQueriesQuery.data}
>
<TanStackTable small pages={pages} perPage={10} table={table} />
<TanStackTable
small
pages={headQueriesData().pages}
perPage={10}
table={tableMemo()}
/>
</Show>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { AnalyticsParams, SearchQueryEvent } from "shared/types";
import { createSignal, Show } from "solid-js";
import { FullScreenModal, SortableColumnDef, TanStackTable } from "shared/ui";
Expand All @@ -21,6 +22,7 @@ const columns: SortableColumnDef<SearchQueryEvent>[] = [
accessorKey: "top_score",
header: "Score",
cell(props) {
// eslint-disable-next-line solid/reactivity
return props.getValue<number>().toFixed(5);
},
},
Expand All @@ -32,6 +34,7 @@ export const LowConfidenceQueries = (props: LowConfidenceQueriesProps) => {
const [current, setCurrent] = createSignal<SearchQueryEvent | null>(null);
const navigate = useBetterNav();
const { pages, lowConfidenceQueriesQuery } = useLowConfidenceQueries({
// eslint-disable-next-line solid/reactivity
params: props.params,
thresholdText: thresholdText,
});
Expand Down Expand Up @@ -99,7 +102,7 @@ export const LowConfidenceQueries = (props: LowConfidenceQueriesProps) => {
perPage={10}
table={table}
onRowClick={(row) => {
setCurrent(row);
setCurrent(row as any);
setOpen(true);
}}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable solid/reactivity */
import { AnalyticsFilter, SearchQueryEvent } from "shared/types";
import { Show } from "solid-js";
import { SortableColumnDef, TanStackTable } from "shared/ui";
Expand Down
33 changes: 20 additions & 13 deletions frontends/analytics/src/components/charts/RagQueries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,27 @@ export const RagQueries = (props: RagQueriesProps) => {
},
]);

const table = createSolidTable({
get data() {
return ragQueriesQuery.data || [];
},
state: {
pagination: {
pageIndex: pages.page(),
pageSize: 10,
const table = createMemo(() => {
const curColumns = columns();

const table = createSolidTable({
get data() {
return ragQueriesQuery.data || [];
},
},
columns: columns(),
getCoreRowModel: getCoreRowModel(),
manualPagination: true,
state: {
pagination: {
pageIndex: pages.page(),
pageSize: 10,
},
},
columns: curColumns,
getCoreRowModel: getCoreRowModel(),
manualPagination: true,
});

return table;
});

const usage = createQuery(() => ({
queryKey: ["rag-usage", { filter: props }],
queryFn: () => {
Expand Down Expand Up @@ -194,7 +201,7 @@ export const RagQueries = (props: RagQueriesProps) => {
pages={pages}
perPage={10}
total={usage?.data?.total_queries}
table={table}
table={table()}
/>
</>
);
Expand Down
15 changes: 12 additions & 3 deletions frontends/analytics/src/hooks/data/useHeadQueries.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { createQuery, useQueryClient } from "@tanstack/solid-query";
import {
createQuery,
CreateQueryResult,
useQueryClient,
} from "@tanstack/solid-query";
import { createEffect, useContext } from "solid-js";
import { getHeadQueries } from "../../api/analytics";
import { DatasetContext } from "../../layouts/TopBarLayout";
import { usePagination } from "../../hooks/usePagination";
import { AnalyticsFilter } from "shared/types";
import { AnalyticsFilter, HeadQuery } from "shared/types";

export interface HeadQueriesData {
headQueriesQuery: CreateQueryResult<HeadQuery[], Error>;
pages: ReturnType<typeof usePagination>;
}

export const useHeadQueries = ({
params,
}: {
params: { filter: AnalyticsFilter };
}) => {
}): HeadQueriesData => {
const dataset = useContext(DatasetContext);
const pages = usePagination();
const queryClient = useQueryClient();
Expand Down
4 changes: 3 additions & 1 deletion frontends/analytics/src/pages/tablePages/SearchTablePage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable solid/reactivity */
import { format } from "date-fns";
import { SearchQueryEvent } from "shared/types";
import { FilterBar } from "../../components/FilterBar";
Expand All @@ -13,6 +14,7 @@ import {
createSolidTable,
getCoreRowModel,
SortingState,
Table,
} from "@tanstack/solid-table";
import { Card } from "../../components/charts/Card";
import { formatSearchMethod } from "../../utils/searchType";
Expand Down Expand Up @@ -117,7 +119,7 @@ export const SearchTablePage = () => {
<TanStackTable
pages={pages}
perPage={10}
table={table}
table={table as unknown as Table<SearchQueryEvent>}
onRowClick={(row: SearchQueryEvent) =>
navigate(`/query/${row.id}`)
}
Expand Down
6 changes: 5 additions & 1 deletion frontends/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"@nozbe/microfuzz": "^1.0.0",
"@sentry/browser": "^7.110.0",
"@solidjs/router": "^0.10.1",
"@tanstack/solid-query": "^5.55.4",
"@tanstack/solid-query-devtools": "^5.55.4",
"@tanstack/solid-table": "^8.20.5",
"cva": "npm:class-variance-authority",
"papaparse": "^5.4.1",
"shared": "*",
"shiki": "^1.10.0",
Expand All @@ -26,12 +30,12 @@
"vite-plugin-runtime-env": "^0.1.1"
},
"devDependencies": {
"config": "*",
"@tailwindcss/typography": "^0.5.10",
"@types/papaparse": "^5.3.14",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "7.14.1",
"autoprefixer": "^10.4.16",
"config": "*",
"eslint": "^8.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-semistandard": "^17.0.0",
Expand Down
5 changes: 3 additions & 2 deletions frontends/dashboard/src/api/createDataset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Dataset, DefaultError, ServerEnvsConfiguration } from "shared/types";
import { Dataset, DefaultError } from "shared/types";
import { DatasetConfigurationDTO } from "trieve-ts-sdk";

const api_host = import.meta.env.VITE_API_HOST as unknown as string;

Expand All @@ -9,7 +10,7 @@ export const createNewDataset = async ({
}: {
name: string;
organizationId: string;
serverConfig: ServerEnvsConfiguration;
serverConfig: DatasetConfigurationDTO;
}) => {
const response = await fetch(`${api_host}/dataset`, {
method: "POST",
Expand Down
1 change: 0 additions & 1 deletion frontends/dashboard/src/assets/solid.svg

This file was deleted.

17 changes: 5 additions & 12 deletions frontends/dashboard/src/components/ApiKeyGenerateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ import {
DisclosurePanel,
} from "terracotta";
import {
ApiKeyRespBody,
DatasetAndUsage,
fromI32ToUserRole,
Organization,
SetUserApiKeyResponse,
} from "shared/types";
import { UserContext } from "../contexts/UserContext";
Expand All @@ -34,14 +32,13 @@ import {
import { Item, MultiSelect } from "./MultiSelect";
import { Tooltip } from "shared/ui";
import { ApiRoutes, RouteScope } from "./Routes";
import { Organization } from "trieve-ts-sdk";

export const ApiKeyGenerateModal = (props: {
openModal: Accessor<boolean>;
closeModal: () => void;

refetch: (
info?: unknown,
) => ApiKeyRespBody[] | Promise<ApiKeyRespBody[]> | null | undefined;
onCreated: () => void;
}) => {
const api_host = import.meta.env.VITE_API_HOST as unknown as string;

Expand Down Expand Up @@ -91,12 +88,6 @@ export const ApiKeyGenerateModal = (props: {
{ initialValue: [] },
);

createEffect(() => {
if (generated()) {
void props.refetch();
}
});

const generateApiKey = () => {
if (role() !== 0 && !role()) return;

Expand Down Expand Up @@ -124,12 +115,14 @@ export const ApiKeyGenerateModal = (props: {
.flat()
: undefined,
}),
// eslint-disable-next-line solid/reactivity
}).then((res) => {
if (res.ok) {
void res.json().then((data) => {
setApiKey((data as SetUserApiKeyResponse).api_key);
});
setGenerated(true);
props.onCreated();
} else {
createToast({ type: "error", title: "Failed to generate API key" });
}
Expand All @@ -150,7 +143,7 @@ export const ApiKeyGenerateModal = (props: {
}, false);

const currentUserRole = createMemo(() => {
const selectedOrgId = userContext.selectedOrganizationId?.();
const selectedOrgId = userContext.selectedOrg().id;
if (!selectedOrgId) return 0;
return (
userContext
Expand Down
Loading
Loading