Skip to content

Commit

Permalink
🚧 (dashboard) refactor file structure and update settings references
Browse files Browse the repository at this point in the history
Streamline the project by renaming and relocating core files to remove redundancy.
Updated Django settings to include PostgreSQL database settings.
Added psycopg2-binary to dependencies and documented dashboard access in the README.
  • Loading branch information
ssorin committed Oct 30, 2024
1 parent fa7f81f commit 8683289
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 20 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ bootstrap: \
create-api-test-db \
create-metabase-db \
create-prefect-db \
create-dashboard-db \
seed-metabase \
seed-oidc \
create-superuser \
Expand Down Expand Up @@ -100,7 +101,7 @@ run: ## run the api server (and dependencies)
.PHONY: run

run-all: ## run the whole stack
$(COMPOSE_UP) api keycloak metabase notebook opendata
$(COMPOSE_UP) api keycloak metabase notebook opendata dashboard
.PHONY: run-all

run-metabase: ## run the metabase service
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ un navigateur sur l'URL suivante :

Voir la documentation du projet : [./src/client/](./src/client/)

## Utilisation du dashboard

Le dashboard qualicharge est disponible depuis l'url suivante :
[http://localhost:8030](http://localhost:8030).

Voir la documentation du projet dashboard : [./src/dashboard/](./src/dashboard/)

## Licence

QualiCharge est distribué selon les termes de la licence MIT (voir le fichier
Expand Down
12 changes: 6 additions & 6 deletions env.d/dashboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
DASHBOARD_ALLOWED_HOSTS=["0.0.0.0"]
QUALICHARGE_DB_ENGINE=postgresql+psycopg
QUALICHARGE_DB_HOST=postgresql
DASHBOARD_DB_ENGINE=postgresql+psycopg
DASHBOARD_DB_HOST=postgresql
DASHBOARD_DB_NAME=qualicharge-dashboard
QUALICHARGE_DB_PASSWORD=pass
QUALICHARGE_DB_PORT=5432
QUALICHARGE_DB_USER=qualicharge
DASHBOARD_DB_PASSWORD=pass
DASHBOARD_DB_PORT=5432
DASHBOARD_DB_USER=qualicharge
DASHBOARD_DEBUG=1
DASHBOARD_SECRET_KEY=the_secret_key
DASHBOARD_SECRET_KEY=the_secret_key
1 change: 1 addition & 0 deletions src/dashboard/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ name = "pypi"
[packages]
django = "5.1.2"
honcho = "==2.0.0"
psycopg2-binary = "2.9.10"

[dev-packages]

Expand Down
76 changes: 75 additions & 1 deletion src/dashboard/Pipfile.lock

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

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dashboard.settings')

application = get_asgi_application()
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['0.0.0.0']
ALLOWED_HOSTS = ['localhost', '0.0.0.0']


# Application definition
Expand All @@ -50,7 +50,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'core.urls'
ROOT_URLCONF = 'dashboard.urls'

TEMPLATES = [
{
Expand All @@ -68,20 +68,24 @@
},
]

WSGI_APPLICATION = 'core.wsgi.application'
WSGI_APPLICATION = 'dashboard.wsgi.application'


# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "qualicharge-dashboard",
"USER": "qualicharge",
"PASSWORD": "pass",
"HOST": "postgresql",
"PORT": "5432",
}
}



# Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dashboard.settings')

application = get_wsgi_application()
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dashboard.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down
12 changes: 12 additions & 0 deletions src/dashboard/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# QualiCharge Dashboard

The dashboard allows operators to manage all of their data related to qualicharge.

## Access the dashboard
The qualicharge dashboard is available from the url:
[http://localhost:8030](http://localhost:8030).


## License

This work is released under the MIT License (see LICENSE).
4 changes: 2 additions & 2 deletions src/dashboard/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# todo : mode debug or prod
#python manage.py flush --no-input
#python manage.py collectstatic --noinput
python dashboard/manage.py migrate
python manage.py migrate
# todo : add the port (8030) in .env
python3 dashboard/manage.py runserver 0.0.0.0:8030
python3 manage.py runserver 0.0.0.0:8030

0 comments on commit 8683289

Please sign in to comment.