Skip to content

Commit

Permalink
🚀 Add panes
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniovizuete committed Oct 5, 2022
1 parent a80330d commit e697b85
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 79 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Clickhouser - Clickhouse query runner</title>
<title>Clickhouser - ClickHouse query runner</title>
</head>

<body>
Expand Down
91 changes: 91 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@blueprintjs/popover2": "^1.6.7",
"@blueprintjs/table": "^4.6.8",
"@monaco-editor/react": "^4.4.6",
"allotment": "1.17.0",
"monaco-editor": "0.34.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
Expand Down
28 changes: 14 additions & 14 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Allotment } from "allotment";
import { useState } from "react";

import { QueryResult } from "../lib/peform-query";
import "../styles/App.css";
import QueryForm from "./QueryForm";
Expand All @@ -22,19 +24,17 @@ export default function App() {
};

return (
<main className="h-full w-full">
<div className="flex flex-col h-full">
<div className="flex-grow">
<QueryForm
onSuccess={handleOnSuccess}
onError={handleOnError}
onQuery={setLoading}
/>
</div>
<div className="h-full">
<Result result={result} error={error} loading={loading} />
</div>
</div>
</main>
<Allotment vertical>
<Allotment.Pane minSize={100}>
<QueryForm
onSuccess={handleOnSuccess}
onError={handleOnError}
onQuery={setLoading}
/>
</Allotment.Pane>
<Allotment.Pane>
<Result result={result} error={error} loading={loading} />
</Allotment.Pane>
</Allotment>
);
}
133 changes: 71 additions & 62 deletions src/components/QueryForm/QueryForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
Navbar,
} from "@blueprintjs/core";
import { Popover2 } from "@blueprintjs/popover2";
import { Allotment } from "allotment";

import { useState } from "react";
import { QueryParam } from "../../lib/peform-query";
import { GitHubIcon } from "../svgs/GitHub";
import Editor from "./components/Editor";
import ParameterDialog from "./components/ParameterDialog";
Expand Down Expand Up @@ -51,72 +50,82 @@ export default function QueryForm(props: QueryFormParams) {
} = useQueryFormParamaterHandler({ params, setParams });

return (
<main className="h-full w-full">
<Navbar className="mb-2">
<Navbar.Group align={Alignment.LEFT}>
<Navbar.Heading className="font-semibold tracking-tight text-[#eca834]">
Clickhouser
</Navbar.Heading>
<InputGroup
leftIcon="globe-network"
value={serverAddress}
placeholder="Server address"
onChange={(e) => setServerAddress(e.target.value)}
className="flex-grow"
size={40}
/>
<InputGroup
leftIcon="user"
placeholder="Username"
value={username}
onChange={(e) => setUsername(e.target.value)}
/>
<InputGroup
leftIcon="lock"
placeholder="Password"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<Button
icon="play"
intent="warning"
text="Run query"
onClick={runQuery}
disabled={!query}
/>
<Popover2
content={
<ParametersMenu
params={params}
onClickAdd={handleOnAddParameter}
onClickRemove={handleOnRemoveParameter}
onClickEdit={handleOnEditParameter}
<>
<Allotment vertical>
<Allotment.Pane maxSize={48} minSize={48}>
<Navbar className="mb-2">
<Navbar.Group align={Alignment.LEFT}>
<Navbar.Heading className="font-semibold tracking-tight text-[#eca834]">
Clickhouser
</Navbar.Heading>
<InputGroup
leftIcon="globe-network"
value={serverAddress}
placeholder="Server address"
onChange={(e) => setServerAddress(e.target.value)}
className="flex-grow"
size={40}
/>
}
minimal
placement="bottom-start"
>
<Button icon="variable" intent={Intent.NONE} text="Parameters" />
</Popover2>
</Navbar.Group>
<Navbar.Group align={Alignment.RIGHT}>
<a
href="https://github.com/antoniovizuete/clickhouser"
target="_blank"
rel="noreferrer"
>
<GitHubIcon />
</a>
</Navbar.Group>
</Navbar>
<Editor value={query} onChange={setQuery} onCmdEnter={runQuery} />
<InputGroup
leftIcon="user"
placeholder="Username"
value={username}
onChange={(e) => setUsername(e.target.value)}
/>
<InputGroup
leftIcon="lock"
placeholder="Password"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<Button
icon="play"
intent="warning"
text="Run query"
onClick={runQuery}
disabled={!query}
/>
<Popover2
content={
<ParametersMenu
params={params}
onClickAdd={handleOnAddParameter}
onClickRemove={handleOnRemoveParameter}
onClickEdit={handleOnEditParameter}
/>
}
minimal
placement="bottom-start"
>
<Button
icon="variable"
intent={Intent.NONE}
text="Parameters"
/>
</Popover2>
</Navbar.Group>
<Navbar.Group align={Alignment.RIGHT}>
<a
href="https://github.com/antoniovizuete/clickhouser"
target="_blank"
rel="noreferrer"
>
<GitHubIcon />
</a>
</Navbar.Group>
</Navbar>
</Allotment.Pane>
<Allotment.Pane>
<Editor value={query} onChange={setQuery} onCmdEnter={runQuery} />
</Allotment.Pane>
</Allotment>
<ParameterDialog
data={parameterDialogData}
isOpen={isParameterDialogOpen}
onClose={closeParameterDialog}
onConfirm={handleOnConfirmParameterDialog}
/>
</main>
</>
);
}
2 changes: 1 addition & 1 deletion src/components/QueryForm/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Editor({ value, onChange, onCmdEnter }: EditorProps) {

return (
<MonacoEditor
height="50vh"
height="100%"
width="100%"
defaultValue={value ?? "-- TYPE YOUR SQL HERE"}
language="sql"
Expand Down
4 changes: 4 additions & 0 deletions src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ body,
#root {
height: 100vh;
}

:root {
--focus-border: #eca834;
}
Loading

0 comments on commit e697b85

Please sign in to comment.