Skip to content

feat: auth #14

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: "3.8"
services:
querymaker-server-db:
container_name: querymaker-local-db
networks:
- querymaker-server
image: postgres:14.1-alpine
restart: always
environment:
- POSTGRES_DB=querymaker_local
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- "5435:5432"
volumes:
- querymaker-server-db:/var/lib/postgresql/querymaker-server-db/data
volumes:
querymaker-server-db:
driver: local
networks:
querymaker-server: # spins up querymaker-server which local server can connect to
5 changes: 4 additions & 1 deletion frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
NEXTAUTH_SECRET=
20 changes: 18 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"migrate:dev": "npx dotenv -e .env.local -- prisma migrate dev",
"db:push": "npx dotenv -e .env.local -- prisma db push",
"migrate:reset": "npx dotenv -e .env.local -- prisma migrate reset",
"db:seed": "npx dotenv -e .env.local -- prisma db seed",
"prisma:generate": "npx dotenv -e .env.local -- prisma generate",
"prisma:studio": "npx dotenv -e .env.local -- prisma studio",
"production:build": "npx prisma generate && npx prisma migrate deploy && next build"
},
"dependencies": {
"@chakra-ui/icons": "^2.0.18",
Expand All @@ -17,6 +24,9 @@
"@headlessui/react": "^1.7.14",
"@heroicons/react": "^2.0.17",
"@monaco-editor/react": "^4.5.0",
"@next-auth/prisma-adapter": "^1.0.6",
"@next/font": "^13.4.1",
"@prisma/client": "^4.14.0",
"@reduxjs/toolkit": "^1.9.5",
"@tanstack/react-query": "^4.29.3",
"@types/uuid": "^9.0.1",
Expand All @@ -26,6 +36,7 @@
"localforage": "^1.10.0",
"monaco-editor": "^0.37.1",
"next": "13.3.0",
"next-auth": "^4.22.1",
"openai": "^3.2.1",
"pg": "^8.10.0",
"react": "18.2.0",
Expand All @@ -48,13 +59,18 @@
"@types/uuid": "^9.0.1",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"dotenv-cli": "^7.2.1",
"eslint": "8.34.0",
"eslint-config-next": "13.1.6",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import": "^2.27.5",
"lint-staged": "^13.1.2",
"prettier": "^2.8.7"
"prettier": "^2.8.7",
"prisma": "^4.14.0"
},
"prisma": {
"schema": "src/lib/prisma/schema.prisma"
},
"lint-staged": {
"**/*.{js,jsx,ts,tsx}": [
Expand Down
Binary file added frontend/public/demo-video.mp4
Binary file not shown.
Binary file modified frontend/public/favicon.ico
Binary file not shown.
Binary file added frontend/public/generate_query.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/public/googleicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion frontend/public/next.svg

This file was deleted.

Binary file added frontend/public/robot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion frontend/public/vercel.svg

This file was deleted.

12 changes: 6 additions & 6 deletions frontend/src/components/common/APIKeyInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useAppDispatch, useAppSelector } from "@/hooks/reduxHooks";
import { updateConfig } from "@/redux/slices/config/configSlice";
import { selectOpenAIKey } from "@/redux/slices/config/configSliceSelector";
import { SHOW_OPEN_AI_KEY_MODAL } from "@/storage/keys";
import { localForageStore } from "@/storage/storage-provider";
import {
Button,
HStack,
Expand All @@ -12,8 +14,6 @@ import {
import { FC, useEffect, useState } from "react";
import { IoIosEye, IoIosEyeOff } from "react-icons/io";
import { TimeoutText } from "../common/TimeoutText";
import { localForageStore } from "@/storage/storage-provider";
import { SHOW_OPEN_AI_KEY_MODAL } from "@/storage/keys";
import { BasicButton } from "./BasicButton";

type APIKeyInputProps = {
Expand Down Expand Up @@ -81,19 +81,19 @@ export const APIKeyInput: FC<APIKeyInputProps> = ({ onSave }) => {
bg={"purple.500"}
color={"white"}
_hover={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_active={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_focus={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_disabled={{
bg: "purple.100",
bg: "purple.300",
}}
onClick={handleSave}
>
Expand Down
53 changes: 0 additions & 53 deletions frontend/src/components/common/OpenAIKeyModal.tsx

This file was deleted.

24 changes: 12 additions & 12 deletions frontend/src/components/common/QueryPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -520,19 +520,19 @@ export const QueryPanel: FC<QueryPanelProps> = ({ id }) => {
display="flex"
w={32}
_hover={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_active={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_focus={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_disabled={{
bg: "purple.100",
bg: "purple.300",
}}
isLoading={isLoadingGenerateCommand}
isDisabled={generateCommandIsDisabled}
Expand Down Expand Up @@ -578,19 +578,19 @@ export const QueryPanel: FC<QueryPanelProps> = ({ id }) => {
display="flex"
w={32}
_hover={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_active={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_focus={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_disabled={{
bg: "purple.100",
bg: "purple.300",
}}
isDisabled={executeCommandIsDisabled}
spinner={<Spinner size="sm" />}
Expand Down Expand Up @@ -763,19 +763,19 @@ export const QueryPanel: FC<QueryPanelProps> = ({ id }) => {
display="flex"
w={32}
_hover={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_active={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_focus={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_disabled={{
bg: "purple.100",
bg: "purple.300",
}}
isLoading={isLoadingGenerateChart}
isDisabled={runChartGenerateIsDisabled}
Expand Down
78 changes: 78 additions & 0 deletions frontend/src/components/common/SettingsModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import {
Button,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
Text,
VStack,
} from "@chakra-ui/react";
import { signOut } from "next-auth/react";
import { FC } from "react";
import { APIKeyInput } from "./APIKeyInput";

type SettingModalProps = {
isOpen: boolean;
onClose: () => void;
};

export const SettingsModal: FC<SettingModalProps> = ({ isOpen, onClose }) => {
const handleSave = () => {
onClose();
};
const handleSignOut = async () => {
await signOut({
callbackUrl: "/",
});
};
return (
<Modal isOpen={isOpen} onClose={onClose} isCentered size="2xl">
<ModalOverlay />
<ModalContent>
<ModalHeader>Input your OpenAI Key</ModalHeader>
<ModalCloseButton />
<ModalBody>
<VStack spacing={8}>
<VStack
w="100%"
minH="48"
h="100%"
justifyContent={"center"}
display="flex"
spacing={4}
>
<APIKeyInput onSave={handleSave} />
<Text textAlign="center">
We do not upload, log, or store your API key outside of your
browser storage.{" "}
</Text>
</VStack>
<Button
aria-label="Edit datasource"
variant="unstyled"
color={"red.500"}
fontSize={"xs"}
border={"1px solid"}
borderColor={"red.500"}
_hover={{
bg: "red.50",
}}
display="flex"
px={2}
py={0}
borderRadius={1}
onClick={handleSignOut}
w={60}
>
Sign out
</Button>
</VStack>
</ModalBody>
<ModalFooter></ModalFooter>
</ModalContent>
</Modal>
);
};
14 changes: 7 additions & 7 deletions frontend/src/components/datasource/DatasourceInputModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { useCheckConnection } from "@/hooks/mutations/useCheckConnection";
import { useAppDispatch } from "@/hooks/reduxHooks";
import { upsertDatasource } from "@/redux/slices/datasource/datasourceSlice";
import {
DatasourceType,
PGConnectionConfig,
} from "@/types/redux/slices/datasource";
import {
Box,
FormControl,
Expand All @@ -27,10 +31,6 @@ import { v4 as uuidv4 } from "uuid";
import { BasicButton } from "../common/BasicButton";
import { BasicLinkButton } from "../common/BasicLinkButton";
import { BasicInput } from "../common/Input";
import {
DatasourceType,
PGConnectionConfig,
} from "@/types/redux/slices/datasource";

type AddDatasourceModalProps = {
isOpen: boolean;
Expand Down Expand Up @@ -312,15 +312,15 @@ export const DatasourceInputModal: FC<AddDatasourceModalProps> = ({
bg={"purple.500"}
color={"white"}
_hover={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_active={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
_focus={{
bg: "purple.100",
bg: "purple.300",
cursor: "pointer",
}}
type="submit"
Expand Down
Loading