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

UI for Database Connection Add and Delete #170

Open
poundifdef opened this issue May 7, 2024 · 10 comments
Open

UI for Database Connection Add and Delete #170

poundifdef opened this issue May 7, 2024 · 10 comments

Comments

@poundifdef
Copy link
Contributor

The goal of this ticket is to add a basic UI to add and delete new database destinations. This will be done purely in SvelteKit. The backend endpoints are already implemented in Go, though you may need to make small changes or fixes.

How to Run

  1. Run the backend: go run .
  2. Run the frontend in a separate terminal: cd frontend; npm run dev
  3. Go to http://localhost:8080/login to log into the dashboard
  4. Then you should be able to go to http://localhost:5173/dashboard to run the sveltekit app

Requirements

  • Everything should be implemented using plain HTML. There is no need to implement any CSS or styling.
  • The UI is a single-page-app which makes ajax calls to our backend in Go.
  • The pull request will be against the svelte-2 branch, not main

Part 1: Delete

  1. If you go to this page, there is a delete button: http://localhost:5173/dashboard/connections/
  2. When the user clicks delete, we should show a confirmation asking if they are sure. The dialog should use this UI element: https://shoelace.style/components/dialog
  3. If the user clicks OK, then make a DELETE fetch request to /api/destinations/{id}.
  4. If the deletion is successful, then show a success alert, otherwise show the error. Use this component for showing alerts: https://shoelace.style/components/alert

Part 2: Add

The user should be able to add new connections.

Show Form

  1. Navigate to this page: http://localhost:5173/dashboard/connections/new/duckdb/
  2. This should make an ajax request to /api/destinations/params/[type] where type is a SvelteKit url parameter
  3. That ajax endpoint will return a list of form fields:
    • name: the name of the field
    • type: the type of form field. It could be text, textarea, password, number, or bool (checkbox)
    • label: the label for the field
    • default: a default value

Here is an example:

{
    "form_fields": [
        {
            "name": "database",
            "type": "text",
            "label": "Database Name",
            "default": ""
        },
        {
            "name": "token",
            "type": "password",
            "label": "MotherDuck Token",
            "default": ""
        }
    ],
    "type": "DuckDB"
}
  1. Using this data, show a form on the page with all of these fields.
  2. Additionally, have a form field for the "Name" of the destination
  3. Finally, there should be a "save" button

Save Data

  1. When the user clicks the save button, make an ajax POST /destinations
  2. The payload should look like this:
{
  "type": [type from URL],
  "name": "user-entered name",
  "settings": {
    "database": "user-entered-db-value",
    "token": "user-entered-token-value"
  }
}
  1. If the POST is successful, then redirect the user to /dashboard/connections
  2. If the POST fails, then show an alert with the error returned from the API.

Testing

This should work with the following four URLs:

  1. http://localhost:5173/dashboard/connections/new/duckdb/
  2. http://localhost:5173/dashboard/connections/new/clickhouse/
  3. http://localhost:5173/dashboard/connections/new/bigquery/
  4. http://localhost:5173/dashboard/connections/new/postgres/
  5. http://localhost:5173/dashboard/connections/new/redshift/

Show a video of your solution working when making your pull request

Copy link

algora-pbc bot commented May 7, 2024

💎 $150 bounty • Scratch Data (YC S21)

Steps to solve:

  1. Start working: Comment /attempt #170 with your implementation plan
  2. Submit work: Create a pull request including /claim #170 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to scratchdata/scratchdata!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @CodeMan99 May 8, 2024, 2:54:34 PM #173
🟢 @mehulmathur16 #172

@CodeMan99
Copy link

Hello 👋

Maybe I'm blind, but I don't see a frontend folder in the main branch?

@poundifdef
Copy link
Contributor Author

Hi! @CodeMan99 it is in a branch called svelte-2

@CodeMan99
Copy link

CodeMan99 commented May 8, 2024

@poundifdef Awesome. Have it up and running.

/attempt #170

Seems straight forward enough. It might take me a moment to spin up on everything.

Would you be interested in adding a devcontainer for this project (vscode docs)? I currently have a docker-compose configuration with a clickhouse sidecar container.

@CodeMan99
Copy link

@poundifdef I am currently working on part 2 (Add connection) and I think you'll be very pleased with the result.

@CodeMan99
Copy link

Almost there!

Copy link

algora-pbc bot commented May 9, 2024

💡 @CodeMan99 submitted a pull request that claims the bounty. You can visit your bounty board to reward.

@CodeMan99
Copy link

@poundifdef Anything else needed here?

@poundifdef
Copy link
Contributor Author

@CodeMan99 Nope, will get the payment processed shortly (hopefully today - there was a bug on the payment screen but I emailed the algora folks and they're fixing!) Will also have new similar bounties coming up soon so stay tuned.

Copy link

algora-pbc bot commented May 10, 2024

🎉🎈 @CodeMan99 has been awarded $150! 🎈🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants