Skip to content

Commit

Permalink
Merge branch 'JettyDash:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rsemihkoca authored Feb 28, 2024
2 parents a83bd0a + 93a7b7e commit 1473beb
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 153 deletions.
162 changes: 162 additions & 0 deletions WebsiteApplication/client/components/connections/connectionform.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import {Button, Card, CardBody, CardFooter, Input, Link, Tab, Tabs, useDisclosure} from "@nextui-org/react";
import {DatabaseCards} from "@/components/connections/databasecards";
import React from "react";
import {Key} from "@react-types/shared";


export const ConnectionForm = () => {
const [selectedTab, setSelectedTab] = React.useState<Key>("host");
const [database, setDatabase] = React.useState<string>("")
const [port, setPort] = React.useState<string>("1234"); // Add state for port number

const updatePort = (databaseType: string) => {
switch (databaseType) {
case "MYSQL":
setPort("3306");
break;
case "POSTGRES":
setPort("5432");
break;
case "MSSQL":
setPort("1433");
break;
case "ORACLE":
setPort("1521");
break;
default:
setPort("1234");
break;
}
};
return (
<div className="flex flex-col w-full">
<Card className="max-w-full w-[440px] h-[560px]">
<CardBody className="overflow-hidden">
<Tabs
fullWidth
variant="bordered"
size="sm"
aria-label="Tabs form"
selectedKey={selectedTab}
onSelectionChange={setSelectedTab}
>

<Tab key="host" title="Host">
<form className="flex flex-col gap-4">
<DatabaseCards
onDatabaseSelect={selectedDatabase => {
setDatabase(selectedDatabase);
updatePort(selectedDatabase); // Update port based on selected database
}}
imageSizeClasses={"h-10 w-10"}
baseCardClasses={"size-24"}/>
<div className={"flex flex-row gap-2"}>
<Input
className={"flex-2"}
size="md"
isRequired
label="Database"
placeholder="Enter your database name eg. master"
type="text"
/>
<Input
className={"flex-1"}
isRequired
label="Port"
placeholder={`eg. ${port}`}
type="text"
/>
</div>
<div className={"flex"}>
<Input
className={"flex-1"}
size="md"
isRequired
label="Host"
placeholder="Enter your host eg. example-db.jettydash.com"
type="text"
/>
</div>
<div className={"flex flex-row gap-2"}>
<Input
className={"flex-1"}
isRequired
label="Username"
placeholder="Enter your username"
type="text"/>
<Input
className={"flex-1"}
isRequired
label="Password"
placeholder="Enter your password"
type="password"
/>
</div>

<p className="text-center text-small ">
Need a connection example?{" "}
<Link size="sm" onPress={() => setSelectedTab("Url")}>
Learn More
</Link>
</p>

</form>
</Tab>
<Tab key="url" title="Url">
<form className="flex flex-col gap-4 h-[300px]">
<Input isRequired label="Name" placeholder="Enter your names" type="password"/>
<Input isRequired label="Email" placeholder="Enter your email" type="email"/>
<Input
isRequired
label="Password"
placeholder="Enter your password"
type="password"
/>
<p className="text-center text-small">
Already have an account?{" "}
<Link size="sm" onPress={() => setSelectedTab("host")}>
Host
</Link>
</p>

</form>
</Tab>
</Tabs>
</CardBody>
<CardFooter className={"m-0"}>
<div className="w-full inline-flex flex-col gap-1">
{/*<Button*/}
{/* className={"flex-1"}*/}
{/* size={"md"}*/}
{/* variant="ghost"*/}

{/*>*/}
{/* Cancel*/}
{/*</Button>*/}
{/*<div className={"flex flex-row gap-5"}>*/}
<Button
isDisabled={false}
className={"flex-2"}
size={"md"}
variant="shadow"
color="default" isLoading={false}
>
Test Connection
</Button>
<Button
isDisabled={false}
className={"flex-2"}
size={"md"}
variant="shadow"
color="primary" isLoading={false}
>
Save Connection
</Button>
{/*</div>*/}
</div>

</CardFooter>
</Card>
</div>
);
}
188 changes: 36 additions & 152 deletions WebsiteApplication/client/components/connections/createnewdatabase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,27 @@
//

'use client';
import {Tabs, Tab, Input, Link, Button, Card, CardBody, CardHeader, CardFooter, useDisclosure} from "@nextui-org/react";
import {
Tabs,
Tab,
Input,
Link,
Button,
Card,
CardBody,
CardHeader,
CardFooter,
useDisclosure,
Modal, ModalContent, ModalHeader, ModalBody, ModalFooter
} from "@nextui-org/react";
import React from "react";
import {Key} from "@react-types/shared";
import {DatabaseCards} from "@/components/connections/databasecards";
import {PlusIcon} from "@/components/icons/PlusIcon";

export const CreateNewDatabase = () => {
const [selectedTab, setSelectedTab] = React.useState<Key>("host");
const [database, setDatabase] = React.useState<string>("")
const [port, setPort] = React.useState<string>("1234"); // Add state for port number
const {isOpen, onOpen, onOpenChange} = useDisclosure();

const updatePort = (databaseType: string) => {
switch (databaseType) {
case "MYSQL":
setPort("3306");
break;
case "POSTGRES":
setPort("5432");
break;
case "MSSQL":
setPort("1433");
break;
case "ORACLE":
setPort("1521");
break;
default:
setPort("1234");
break;
}
};



return (
<>
Expand All @@ -59,136 +47,32 @@ export const CreateNewDatabase = () => {
>
Add New
</Button>
<Modal
isOpen={isOpen}
onOpenChange={onOpenChange}
placement="bottom-center" // center on desktop, bottom on mobile
>
<ModalContent className="flex items-center w-[800px] h-[600px]">
{(onClose) => (
<>
<ModalHeader className="flex flex-col gap-1">New Connection</ModalHeader>
<ModalBody className="w-full h-full">

<div className="flex flex-col w-full">
<Card className="max-w-full w-[440px] h-[560px]">
<CardBody className="overflow-hidden">
<Tabs
fullWidth
variant="bordered"
size="sm"
aria-label="Tabs form"
selectedKey={selectedTab}
onSelectionChange={setSelectedTab}
>

<Tab key="host" title="Host">
<form className="flex flex-col gap-4">
<DatabaseCards
onDatabaseSelect={selectedDatabase => {
setDatabase(selectedDatabase);
updatePort(selectedDatabase); // Update port based on selected database
}}
imageSizeClasses={"h-10 w-10"}
baseCardClasses={"size-24"}/>
<div className={"flex flex-row gap-2"} >
<Input
className={"flex-2"}
size="md"
isRequired
label="Database"
placeholder="Enter your database name eg. master"
type="text"
/>
<Input
className={"flex-1"}
isRequired
label="Port"
placeholder={`eg. ${port}`}
type="text"
/>
</div>
<div className={"flex"} >
<Input
className={"flex-1"}
size="md"
isRequired
label="Host"
placeholder="Enter your host eg. example-db.jettydash.com"
type="text"
/>
</div>
<div className={"flex flex-row gap-2"} >
<Input
className={"flex-1"}
isRequired
label="Username"
placeholder="Enter your username"
type="text"/>
<Input
className={"flex-1"}
isRequired
label="Password"
placeholder="Enter your password"
type="password"
/>
</div>

<p className="text-center text-small ">
Need a connection example?{" "}
<Link size="sm" onPress={() => setSelectedTab("Url")}>
Learn More
</Link>
</p>

</form>
</Tab>
<Tab key="url" title="Url">
<form className="flex flex-col gap-4 h-[300px]">
<Input isRequired label="Name" placeholder="Enter your names" type="password"/>
<Input isRequired label="Email" placeholder="Enter your email" type="email"/>
<Input
isRequired
label="Password"
placeholder="Enter your password"
type="password"
/>
<p className="text-center text-small">
Already have an account?{" "}
<Link size="sm" onPress={() => setSelectedTab("host")}>
Host
</Link>
</p>

</form>
</Tab>
</Tabs>
</CardBody>
<CardFooter className={"m-0"}>
<div className="w-full inline-flex flex-col gap-1">
{/*<Button*/}
{/* className={"flex-1"}*/}
{/* size={"md"}*/}
{/* variant="ghost"*/}
</ModalBody>
<ModalFooter>
<Button color="danger" variant="flat" onPress={onClose}>
Close
</Button>
<Button onPress={onClose}>
Sign in
</Button>
</ModalFooter>
</>
)}
</ModalContent>
</Modal>

{/*>*/}
{/* Cancel*/}
{/*</Button>*/}
{/*<div className={"flex flex-row gap-5"}>*/}
<Button
isDisabled={false}
className={"flex-2"}
size={"md"}
variant="shadow"
color="default" isLoading={false}
>
Test Connection
</Button>
<Button
isDisabled={false}
className={"flex-2"}
size={"md"}
variant="shadow"
color="primary" isLoading={false}
>
Save Connection
</Button>
{/*</div>*/}
</div>

</CardFooter>
</Card>
</div>
</>
)
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import {RadioGroup} from "@nextui-org/react";
import {CustomRadio} from "@/app/(root)/datamodels/customRadio";
import {CustomRadio} from "@/components/connections/customradio";
import Image from "next/image";

interface DatabaseCardsProps {
Expand Down

0 comments on commit 1473beb

Please sign in to comment.