Skip to content

Dashboard for SSPŠ camps like TechDays and HackDays

License

Notifications You must be signed in to change notification settings

FADAMIS/dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FADAMIS Dashboard

FADAMIS dashboard is a web dashboard used for administrating SSPŠ camps like TechDays or HackDays. API reference below.

Dependencies

  • Docker (instalation guide here)

Instalation

git clone https://github.com/FADAMIS/dashboard
cd dashboard
make config # creates .env files containing configuration info

Now you have to edit some informations that are true to you:

  • in caddy/Caddyfile edit fadamis.live to match your domain
# in project directory
make docker

This builds all images and starts all containers. Every container restarts on host reboot.

After install

When the dashboard is first started, the database will have sample data in camps, admins and foods tables.

Default admin login - admin:admin

API Reference

POST /api/register

Registers a new participant


Request

Headers:

  • Content-Type: application/json

request data data type description
name string participant's name
surname string participant's surname
email string participant's email
phone string participant's phone number
camp_id int camp's id

JSON example

{
    "name": "John",
    "surname": "Smith",
    "email": "[email protected]",
    "phone": "777888999",
    "camp_id": 1
}

cURL example

curl -X POST "http://localhost/api/register" -d '{"name": "John", "surname": "Smith", "email": "[email protected]", "phone": "777888999"}' -H "Content-Type: application/json"

Response


Status code Content Type
200 application/json

Successful response

{
    "message": "register successful"
}

GET /api/camp

Returns all available camps


Request

Headers:

  • None

request data data type
none none

cURL example

curl "http://localhost/api/camp"

Response


Status code Content Type
200 application/json

date is int64 (it is stored as Unix timestamp)

Successful response

{
    "camps": [
        {
            "id": 1,
            "name": "TechDays!",
            "participants": null,
            "date": 1701302400,
            "processed": false
        }
    ]
}

GET /api/food

Returns all available food

  • Also returns ID of the specific food which is later used for participants to order said food

Request

Headers:

  • None

request data data type
none none

cURL example

curl "http://localhost/api/food"

Response


Status code Content Type
200 application/json

Successful response

{
    "foods": [
        {
            "id": 1,
            "name": "pizza",
            "participants": null,
            "image_path": "/images/322989cf390c0e81fbd89727f2ee7d5f402bf652789d88229751eab26ef2e162.jpeg"
        }
    ]
}

POST /api/order/:name

Orders food for the participant specified by :name parameter

  • :name must be a sha256 sum of name+surname+camp_id
  • Example:
sha256(JohnSmith1)
---->
4850eecac63c272e9009385e399f958599a79d96345d2a0e3500d63e7cf2839c
---->
http://localhost/api/order/4850eecac63c272e9009385e399f958599a79d96345d2a0e3500d63e7cf2839c

Request

Headers:

  • Content-Type: application/json

request data data type description
id int food's ID
name string food's name

JSON example

{
    "id": 1,
    "name": "Pizza Prosciutto",
}

cURL example

curl -X POST "http://localhost/api/order/9d3e2c3ef4399d27897e1d918151cac74ed7b2bee028fea50d29d7d8ea3f925e" -d '{"id": 1, "name": "Pizza Prosciutto"}' -H "Content-Type: application/json"

Response


Status code Content Type
200 application/json

Successful response

{
    "food": "Pizza Prosciutto",
    "name": "JohnSmith"
}

POST /api/admin/login

Login endpoint for administrators


Request

Headers:

  • Content-Type: application/json

request data data type description
username string admin's username
password string admin's password

JSON example

{
    "username": "admin",
    "password": "supersecretpassword",
}

cURL example

curl -X POST "http://localhost/api/admin/login" -d '{"username": "admin", "password": "supersecretpassword"}' -H "Content-Type: application/json"

Response


Status code Content Type
200 application/json

Sets a session cookie that expires after 6 hours

Successful response

{
    "message": "login successful",
}

GET /api/admin/participants

Returns all registered participants


Request

Headers:

  • None

request data data type
none none

cURL example

curl "http://localhost/api/participants"

Response


Status code Content Type
200 application/json

Successful response

{
    "participants": [
        {
            "id": 1,
            "name": "John",
            "surname": "Smith",
            "email": "[email protected]",
            "phone": "777888999",
            "food_id": 1                // ID of ordered food
        }
    ]
}

GET /api/admin/food

Returns all available food along with all the participants with specifed food already ordered

  • Also returns ID of the specific food which is later used for participants to order said food

Request

Headers:

  • None

request data data type
none none

cURL example

curl "http://localhost/api/admin/food"

Response


Status code Content Type
200 application/json

Successful response

{
    "foods": [
        {
            "id": 1,
            "name": "none",
            "participants": 
                [
                    {
                        "id": 1,
                        "name": "John",
                        "surname": "Smith", 
                        "email": "[email protected]",
                        "phone": "777888999",
                        "food_id": 1
                    }
                ],
            "image_path": "/images/322989cf390c0e81fbd89727f2ee7d5f402bf652789d88229751eab26ef2e162.jpeg"
        }
    ]
}

POST /api/admin/food

Adds new available food to the database


Request

Headers:

  • Content-Type: multipart/form-data

request data data type description
name string food's name
file File food's image

cURL example

curl -X POST "http://localhost/api/admin/food" -F 'name=Pizza' -F 'file=@/home/admin/pizza.jpg' -H "Content-Type: multipart/form-data"

Image's filename is sha256 checksum of itself + file extension


Allowed file types

  • jpg
  • png

Response


Status code Content Type
200 application/json

Successful response

{
    "message": "food added",
    "food": "Pizza"
}

GET /api/admin/camp

Returns all (even expired) camps


Request

Requires session cookie

Headers:

  • None

request data data type
none none

cURL example

curl "http://localhost/api/admin/camp"

Response


Status code Content Type
200 application/json

Successful response

{
    "foods": [
        {
            "id": 1,
            "name": "TechDays",
            "participants": 
                [
                    {
                        "id": 1,
                        "name": "John",
                        "surname": "Smith", 
                        "email": "[email protected]",
                        "phone": "777888999",
                        "food_id": 1
                    }
                ],
            "date": 1701302400,
            "processed": false
        }
    ]
}

POST /api/admin/camp

Adds new camp to the database


Request

Headers:

  • Content-Type: application/json

request data data type description
name string camp's name
date int64 camp's date as Unix timestamp

cURL example

curl -X POST "http://localhost/api/admin/camp" -d "{'name': 'TechDays', 'date': 1701302400}" -H "Content-Type: application/json"

Response


Status code Content Type
200 application/json

Successful response

{
    "message": "camp added",
    "camp": "TechDays"
}

POST /api/admin/close

Closes camp registration and sends email with information.


Request

Headers:

  • Content-Type: application/json

request data data type description
id uint camp's ID
name string camp's name
date int64 camp's date as Unix timestamp

cURL example

curl -X POST "http://localhost/api/admin/close" -d "{'id': 1, 'name': 'TechDays', 'date': 1701302400}" -H "Content-Type: application/json"

Response


Status code Content Type
200 application/json

Successful response

{
    "message": "camp closed",
    "camp": "TechDays"
}

Backend API written in Go and Gin web framework by Fabucik

Frontend by DuckyScr

About

Dashboard for SSPŠ camps like TechDays and HackDays

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published