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

remove django app and add vitejs #94

Merged
merged 1 commit into from
Jan 24, 2024
Merged
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
18 changes: 13 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ name: transcendence

services:
# Front
front:
extends:
file: front/docker/docker-compose.yaml
service: front
front-nginx:
extends:
file: front/docker/docker-compose.yaml
service: front-nginx

front-vite:
extends:
file: front/docker/docker-compose.yaml
service: front-vite

# User management
user-management:
extends:
Expand Down Expand Up @@ -75,7 +76,14 @@ volumes:
driver_opts:
type: none
o: bind
device: front/src/
device: front/app/

front_dist:
driver: local
driver_opts:
type: none
o: bind
device: front/app/dist/

# User management
user_management_postgres_volume:
Expand Down
13 changes: 13 additions & 0 deletions front/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Transcendence App</title>
</head>
<body class="bg-body-secondary">
<div id="app"></div>
<script defer type="module" src="src/js/main.js"></script>
</body>
</html>
19 changes: 19 additions & 0 deletions front/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "app",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"vite": "^5.0.8"
},
"dependencies": {
"@popperjs/core": "^2.11.8",
"bootstrap": "^5.3.2",
"bootstrap-icons": "^1.11.3"
}
}
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
@font-face {
font-family: 'JetBrains Mono';
src: url('/static/fonts/JetBrainsMono-Regular.woff2') format('truetype');
src: url('/fonts/JetBrainsMono-Regular.woff2') format('truetype');
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: 'JetBrains Mono Bold';
src: url('/static/fonts/JetBrainsMono-Bold.woff2') format('truetype');
src: url('/fonts/JetBrainsMono-Bold.woff2') format('truetype');
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: 'JetBrains Mono Light';
src: url('/static/fonts/JetBrainsMono-Light.woff2') format('truetype');
src: url('/fonts/JetBrainsMono-Light.woff2') format('truetype');
font-weight: normal;
font-style: normal;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ export class Navbar extends Component {
${this.generateNavLink('tournaments')}
</li>
</ul>
<div class="d-flex">
<div class="d-flex mb-2 mb-lg-0">
<theme-button-component></theme-button-component>
<form class="d-flex" role="search">
<input class="form-control ms-2 me-2" type="search"
placeholder="Search" aria-label="Search">
</form>
</div>
<div class="d-flex">
${this.logNavPart()}
</div>
</div>
Expand All @@ -97,12 +99,12 @@ export class Navbar extends Component {
return (`
<div id="log-part" class="d-flex align-items-center">
<a class="mx-2">
<i class="fas fa-bell text-dark-emphasis"></i>
<i class="bi bi-bell-fill text-dark-emphasis"></i>
</a>
<div class="dropdown mx-2">
<span class="dropdown-toggle" id="dropdownMenuLink"
data-bs-toggle="dropdown" aria-expanded="false">
<img id="nav-profile-img" src="/static/img/tdameros.jpg" alt="profile image"
<img id="nav-profile-img" src="/img/tdameros.jpg" alt="profile image"
class="rounded-circle"
style="width: 40px; height: 40px;">
<span id="nav-username">@username</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ResetPassword extends Component {
<h2 class="card-title text-center m-5">Reset password</h2>
<form>
<div class="d-flex justify-content-center mb-4">
<i id="email-icon" class="fa fa-envelope fa-5x"></i>
<i class="bi bi-envelope-at-fill" style="font-size: 7rem;"></i>
</div>
<div class="form-group mb-4">
<input type="email" class="form-control" id="email"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export class Signup extends Component {
} else {
this.password.setAttribute('type', 'password');
}
this.passwordEyeIcon.children[0].classList.toggle('fa-eye-slash');
this.passwordEyeIcon.children[0].classList.toggle('fa-eye');
this.passwordEyeIcon.children[0].classList.toggle('bi-eye-fill');
this.passwordEyeIcon.children[0].classList.toggle('bi-eye-slash-fill');
this.passwordHiden = !this.passwordHiden;
}

Expand All @@ -66,8 +66,8 @@ export class Signup extends Component {
} else {
this.confirmPassword.setAttribute('type', 'password');
}
this.confirmPasswordEyeIcon.children[0].classList.toggle('fa-eye-slash');
this.confirmPasswordEyeIcon.children[0].classList.toggle('fa-eye');
this.confirmPasswordEyeIcon.children[0].classList.toggle('bi-eye-fill');
this.confirmPasswordEyeIcon.children[0].classList.toggle('bi-eye-slash-fill');
this.confirmPasswordHiden = !this.confirmPasswordHiden;
}

Expand Down Expand Up @@ -126,7 +126,7 @@ export class Signup extends Component {
<input type="password" class="form-control" id="password"
placeholder="Password">
<span id="password-eye" class="input-group-text eye-box">
<span class="fa fa-fw fa-eye field-icon"></span>
<i class="bi bi-eye-fill"></i>
</span>
<div id="password-feedback" class="invalid-feedback">
Invalid password.
Expand All @@ -138,7 +138,7 @@ export class Signup extends Component {
<input type="password" class="form-control"
id="confirm-password" placeholder="Confirm Password">
<span id="confirm-password-eye" class="input-group-text eye-box">
<span class="fa fa-fw fa-eye field-icon"></span>
<i class="bi bi-eye-fill"></i>
</span>
<div class="invalid-feedback">
Passwords do not match.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap-icons/font/bootstrap-icons.css';
import '../css/style.css';

import * as bootstrap from 'bootstrap'

import { Router, Route } from './Router.js';
import { Home } from "./components/Home.js";
import { Navbar } from "./components/Navbar.js";
Expand All @@ -10,6 +16,7 @@ import {Signin} from "./components/Signin.js";
import {Signup} from "./components/Signup.js";
import {ResetPassword} from "./components/ResetPassword.js";


Theme.init();

customElements.define('home-component', Home);
Expand Down
6 changes: 6 additions & 0 deletions front/app/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
server: {
port: 8080,
hot: true
},
}
11 changes: 0 additions & 11 deletions front/docker/Dockerfile

This file was deleted.

23 changes: 8 additions & 15 deletions front/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
services:

front-nginx:
networks:
- transcendence
Expand All @@ -7,26 +8,18 @@ services:
context: nginx
dockerfile: Dockerfile
ports:
- "80:80"
- "443:443"
depends_on:
- front
- front-vite
volumes:
- front_code:/app/src/
restart: on-failure

- front_dist:/transcendence/

front:
front-vite:
image: node:21-bookworm
networks:
- front
- transcendence
build:
context: .
dockerfile: Dockerfile
command: sh -c "python3 src/manage.py collectstatic --noinput &&
gunicorn --chdir src/ front.wsgi:application -w 4 -b 0.0.0.0:8000"
working_dir: /app
volumes:
- front_code:/app/src/
expose:
- "8000"
- front_code:/app
command: sh -c "npm install && npm run build"
restart: on-failure
11 changes: 3 additions & 8 deletions front/docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,9 @@ http {
include /etc/nginx/mime.types;

location / {
proxy_pass http://front:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /static/ {
alias /app/src/staticfiles/;
root /transcendence/;
index index.html;
try_files $uri $uri/ /index.html;
}
}
}
Empty file removed front/src/__init__.py
Empty file.
Empty file removed front/src/front/__init__.py
Empty file.
16 changes: 0 additions & 16 deletions front/src/front/asgi.py

This file was deleted.

Loading