8000 feat: duckdb-wasm query UI [DRAFT] by mattrothenberg · Pull Request #39 · githubocto/flat-viewer · GitHub
[go: up one dir, main page]

Skip to content

feat: duckdb-wasm query UI [DRAFT] #39

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

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Prev Previous commit
Next Next commit
pull in grid component
  • Loading branch information
Matt Rothenberg committed May 12, 2022
commit abc4d0b8d5cbfcefcd7d026cee544500eda0fa1d
37 changes: 13 additions & 24 deletions src/components/db-explorer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { sql } from "@codemirror/lang-sql";
import { Grid } from "@githubocto/flat-ui";
import * as duckdb from "@duckdb/duckdb-wasm";
import CodeMirror from "@uiw/react-codemirror";
import React, { useEffect, useMemo, useRef, useState } from "react";
Expand Down Expand Up @@ -150,40 +151,28 @@ function DBExplorerInner(props: DBExplorerInnerProps) {
/>
</div>
<div className="flex-1 flex flex-col h-full overflow-scroll">
<div className="border-b p-2 flex items-center space-x-2 sticky top-0 bg-white z-10">
<div>
<p className="text-xs uppercase tracking-widest font-medium">
# Rows
</p>
{status === "loading" ? (
<span className="skeleton">Loading</span>
) : (
<span>{data && data.numRows}</span>
)}
</div>
<div>
<p className="text-xs uppercase tracking-widest font-medium">
# Columns
</p>
{status === "loading" ? (
<span className="skeleton">Loading</span>
) : (
<span>{data && data.numCols}</span>
)}
</div>
</div>
{status === "error" && error && (
<div className="bg-red-50 border-b border-red-600 p-2 text-sm text-red-600">
{(error as Error)?.message || "An unexpected error occurred."}
</div>
)}
<div className="relative">
<div className="relative flex-1 h-full">
{status === "loading" && (
<div className="absolute top-4 right-4 z-20">
<Spinner />
</div>
)}
<pre>{JSON.stringify(data, null, 2)}</pre>
{data && (
<Grid
data={data.results}
diffData={undefined}
defaultSort={undefined}
defaultStickyColumnName={undefined}
defaultFilters={{}}
downloadFilename={filename}
onChange={() => {}}
/>
)}
</div>
</div>
</>
Expand Down
0