Init Commit
This commit is contained in:
commit
c038d0ba08
103 changed files with 12517 additions and 0 deletions
19
.env.example
Normal file
19
.env.example
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Postgres section
|
||||||
|
DB_NAME=
|
||||||
|
DB_USER=
|
||||||
|
DB_PASSWORD=
|
||||||
|
DB_HOST=
|
||||||
|
DB_PORT=
|
||||||
|
|
||||||
|
DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}
|
||||||
|
|
||||||
|
# Redis section
|
||||||
|
REDIS_HOST=
|
||||||
|
REDIS_PORT=
|
||||||
|
SECRET_KEY=
|
||||||
|
|
||||||
|
# LDAP section
|
||||||
|
LDAP_ADMIN_PASSWORD=
|
||||||
|
|
||||||
|
# Rust log level
|
||||||
|
RUST_LOG=info
|
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
43
.gitignore
vendored
Normal file
43
.gitignore
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# ---> Rust
|
||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
debug/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||||
|
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||||
|
# Cargo.lock
|
||||||
|
|
||||||
|
# These are backup files generated by rustfmt
|
||||||
|
**/*.rs.bk
|
||||||
|
|
||||||
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
# RustRover
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
.idea/
|
||||||
|
# ---> Vue
|
||||||
|
# gitignore template for Vue.js projects
|
||||||
|
#
|
||||||
|
# Recommended template: Node.gitignore
|
||||||
|
|
||||||
|
# TODO: where does this rule come from?
|
||||||
|
docs/_book
|
||||||
|
|
||||||
|
# TODO: where does this rule come from?
|
||||||
|
test/
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# Added by cargo
|
||||||
|
/target
|
||||||
|
|
||||||
|
# .env
|
||||||
|
.env
|
||||||
|
|
||||||
|
# .direnv
|
||||||
|
.direnv
|
4325
Cargo.lock
generated
Normal file
4325
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
17
Cargo.toml
Normal file
17
Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[workspace]
|
||||||
|
members = ["crates/backend", "crates/migration"]
|
||||||
|
resolver = "3"
|
||||||
|
|
||||||
|
[workspace.package]
|
||||||
|
name = "peer-group-grading"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[workspace.dependencies]
|
||||||
|
migration = { path = "crates/migration" }
|
||||||
|
|
||||||
|
serde = { version = "*", features = ["derive"] }
|
||||||
|
sea-orm = { version = "1.1.0", features = [
|
||||||
|
"runtime-tokio-rustls",
|
||||||
|
"sqlx-postgres",
|
||||||
|
] }
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# peer-group-grading
|
||||||
|
|
||||||
|
Wir sind cool
|
52
backend.Dockerfile
Normal file
52
backend.Dockerfile
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# ---- Stage 1: Build (Static Linking) ----
|
||||||
|
FROM rust:latest as builder
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
# Install the musl target and musl-tools
|
||||||
|
RUN rustup target add x86_64-unknown-linux-musl
|
||||||
|
RUN apt-get update && apt-get install -y musl-tools
|
||||||
|
|
||||||
|
# Create a .cargo directory and configure for static linking with musl
|
||||||
|
RUN mkdir -p .cargo
|
||||||
|
RUN echo '[target.x86_64-unknown-linux-musl]' > .cargo/config.toml
|
||||||
|
RUN echo 'linker = "rust-lld"' >> .cargo/config.toml
|
||||||
|
|
||||||
|
# Copy configuration and lock files needed to resolve dependencies
|
||||||
|
COPY Cargo.toml ./Cargo.toml
|
||||||
|
COPY Cargo.lock ./Cargo.lock
|
||||||
|
COPY crates/backend/Cargo.toml crates/backend/Cargo.toml
|
||||||
|
COPY crates/migration/Cargo.toml crates/migration/Cargo.toml
|
||||||
|
|
||||||
|
# Fetch dependencies based on the lock file.
|
||||||
|
RUN cargo fetch
|
||||||
|
|
||||||
|
# Copy the actual source code for all workspace members
|
||||||
|
COPY crates/backend/ crates/backend/
|
||||||
|
COPY crates/migration/ crates/migration/
|
||||||
|
|
||||||
|
# Build the release binary for the musl target
|
||||||
|
RUN cargo build --release --target x86_64-unknown-linux-musl
|
||||||
|
|
||||||
|
# Debug: List the built binaries to verify what we have
|
||||||
|
RUN ls -la /usr/src/app/target/x86_64-unknown-linux-musl/release/
|
||||||
|
|
||||||
|
# ---- Stage 2: Runtime ----
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
# Install minimal runtime dependencies (ca-certificates is often needed)
|
||||||
|
RUN apk add --no-cache ca-certificates
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy only the statically linked compiled binary from the builder stage
|
||||||
|
COPY --from=builder /usr/src/app/target/x86_64-unknown-linux-musl/release/backend /app/backend
|
||||||
|
|
||||||
|
# Verify the binary exists and is executable
|
||||||
|
RUN ls -la /app && chmod +x /app/backend
|
||||||
|
|
||||||
|
# Expose the port the application listens on
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Set the command to run the application
|
||||||
|
CMD ["/app/backend"]
|
6
bruno/bruno.json
Normal file
6
bruno/bruno.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"version": "1",
|
||||||
|
"name": "pgg-bruno",
|
||||||
|
"type": "collection",
|
||||||
|
"ignore": ["node_modules", ".git"]
|
||||||
|
}
|
4
bruno/environments/local-dev.bru
Normal file
4
bruno/environments/local-dev.bru
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
vars {
|
||||||
|
api_base: http://localhost:8080/api/{{api_version}}
|
||||||
|
api_version: v1
|
||||||
|
}
|
3
bruno/group/folder.bru
Normal file
3
bruno/group/folder.bru
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
meta {
|
||||||
|
name: group
|
||||||
|
}
|
21
bruno/project/Create Project.bru
Normal file
21
bruno/project/Create Project.bru
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
meta {
|
||||||
|
name: Create Project
|
||||||
|
type: http
|
||||||
|
seq: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: {{api_base}}/project
|
||||||
|
body: json
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"name": "{{name}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vars:pre-request {
|
||||||
|
name: FillThisOutButDontCommitIt!
|
||||||
|
}
|
15
bruno/project/Delete Project.bru
Normal file
15
bruno/project/Delete Project.bru
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
meta {
|
||||||
|
name: Delete Project
|
||||||
|
type: http
|
||||||
|
seq: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
delete {
|
||||||
|
url: {{api_base}}/project/:id
|
||||||
|
body: none
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
params:path {
|
||||||
|
id: MyAwesomeUUIDHere!
|
||||||
|
}
|
11
bruno/project/Get Projects.bru
Normal file
11
bruno/project/Get Projects.bru
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
meta {
|
||||||
|
name: Get Projects
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: {{api_base}}/project
|
||||||
|
body: none
|
||||||
|
auth: inherit
|
||||||
|
}
|
15
bruno/project/Get specific Project.bru
Normal file
15
bruno/project/Get specific Project.bru
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
meta {
|
||||||
|
name: Get specific Project
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: {{api_base}}/project/:id
|
||||||
|
body: none
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
params:path {
|
||||||
|
id: 1c2bc42d-20d7-4cec-953f-acf691bad55a
|
||||||
|
}
|
22
bruno/project/Update Project.bru
Normal file
22
bruno/project/Update Project.bru
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
meta {
|
||||||
|
name: Update Project
|
||||||
|
type: http
|
||||||
|
seq: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
put {
|
||||||
|
url: {{api_base}}/project
|
||||||
|
body: json
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"id": "{{project_to_change}}",
|
||||||
|
"name": "ThisProjectHasBeenChanged!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vars:pre-request {
|
||||||
|
project_to_change: 77d0394b-6d61-44a9-97a8-35caa101dc0e
|
||||||
|
}
|
3
bruno/project/folder.bru
Normal file
3
bruno/project/folder.bru
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
meta {
|
||||||
|
name: project
|
||||||
|
}
|
19
bruno/user/Create user.bru
Normal file
19
bruno/user/Create user.bru
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
meta {
|
||||||
|
name: Create user
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: {{api_base}}/user
|
||||||
|
body: json
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"username": "hure",
|
||||||
|
"name": "Dumme Nutte",
|
||||||
|
"password": "nüttchen"
|
||||||
|
}
|
||||||
|
}
|
15
bruno/user/Get user.bru
Normal file
15
bruno/user/Get user.bru
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
meta {
|
||||||
|
name: Get user
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: {{api_base}}/user/:id
|
||||||
|
body: none
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
params:path {
|
||||||
|
id: 293ef329-91b2-4912-ad5d-0277490c7b55
|
||||||
|
}
|
11
bruno/user/Get users.bru
Normal file
11
bruno/user/Get users.bru
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
meta {
|
||||||
|
name: Get users
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: {{api_base}}/user
|
||||||
|
body: none
|
||||||
|
auth: inherit
|
||||||
|
}
|
11
bruno/user/Logout User.bru
Normal file
11
bruno/user/Logout User.bru
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
meta {
|
||||||
|
name: Logout User
|
||||||
|
type: http
|
||||||
|
seq: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: {{api_base}}/auth/logout
|
||||||
|
body: none
|
||||||
|
auth: inherit
|
||||||
|
}
|
18
bruno/user/Verify User.bru
Normal file
18
bruno/user/Verify User.bru
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
meta {
|
||||||
|
name: Verify User
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: {{api_base}}/auth/login
|
||||||
|
body: json
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"username": "hure",
|
||||||
|
"password": "nüttchen"
|
||||||
|
}
|
||||||
|
}
|
3
bruno/user/folder.bru
Normal file
3
bruno/user/folder.bru
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
meta {
|
||||||
|
name: user
|
||||||
|
}
|
44
crates/backend/Cargo.toml
Normal file
44
crates/backend/Cargo.toml
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
[package]
|
||||||
|
name = "backend"
|
||||||
|
version = { workspace = true }
|
||||||
|
edition = { workspace = true }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
migration = { workspace = true }
|
||||||
|
|
||||||
|
actix-web = "4"
|
||||||
|
actix-session = { version = "0.10", features = ["redis-session"] }
|
||||||
|
actix-cors = "0.7"
|
||||||
|
actix-files = "0.6"
|
||||||
|
tracing-actix-web = "0.7.16"
|
||||||
|
|
||||||
|
argon2 = "0.5.3"
|
||||||
|
thiserror = "2"
|
||||||
|
|
||||||
|
env_logger = "0.11"
|
||||||
|
log = "0.4"
|
||||||
|
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
validator = { version = "0.20.0", features = ["derive"] }
|
||||||
|
sea-orm = { version = "1.1", features = [
|
||||||
|
"sqlx-postgres",
|
||||||
|
"runtime-tokio-rustls",
|
||||||
|
"macros",
|
||||||
|
] }
|
||||||
|
uuid = "1"
|
||||||
|
|
||||||
|
dotenvy = "0.15"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
temp-env = "*"
|
||||||
|
serial_test = "*"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
serve = []
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "backend"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[lints.clippy]
|
||||||
|
all = "warn"
|
17
crates/backend/src/controller.rs
Normal file
17
crates/backend/src/controller.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use actix_web::web::{self, ServiceConfig};
|
||||||
|
|
||||||
|
mod auth;
|
||||||
|
mod class;
|
||||||
|
mod group;
|
||||||
|
mod project;
|
||||||
|
mod template;
|
||||||
|
mod user;
|
||||||
|
|
||||||
|
pub fn register_controllers(cfg: &mut ServiceConfig) {
|
||||||
|
cfg.service(web::scope("/project").configure(project::setup))
|
||||||
|
.service(web::scope("/group").configure(group::setup))
|
||||||
|
.service(web::scope("/user").configure(user::setup))
|
||||||
|
.service(web::scope("/class").configure(class::setup))
|
||||||
|
.service(web::scope("/template").configure(template::setup))
|
||||||
|
.service(web::scope("/auth").configure(auth::setup));
|
||||||
|
}
|
49
crates/backend/src/controller/auth.rs
Normal file
49
crates/backend/src/controller/auth.rs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
use actix_session::Session;
|
||||||
|
use actix_web::{
|
||||||
|
HttpRequest, HttpResponse, Responder, post,
|
||||||
|
web::{self, ServiceConfig},
|
||||||
|
};
|
||||||
|
use log::debug;
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
use crate::{Database, error::ApiError};
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct LoginRequest {
|
||||||
|
username: String,
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn setup(cfg: &mut ServiceConfig) {
|
||||||
|
cfg.service(login).service(logout);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[post("/login")]
|
||||||
|
async fn login(
|
||||||
|
db: web::Data<Database>,
|
||||||
|
login_request: web::Json<LoginRequest>,
|
||||||
|
session: Session,
|
||||||
|
) -> Result<impl Responder, ApiError> {
|
||||||
|
let login_request = login_request.into_inner();
|
||||||
|
|
||||||
|
let user_id = db
|
||||||
|
.verify_local_user(&login_request.username, &login_request.password)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if session.get::<String>("user").is_ok() {
|
||||||
|
return Err(ApiError::AlreadyLoggedIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
session.insert("user", user_id)?;
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[post("/logout")]
|
||||||
|
async fn logout(session: Session, request: HttpRequest) -> Result<impl Responder, ApiError> {
|
||||||
|
debug!("request cookies: {:?}", request.cookies());
|
||||||
|
debug!("Session entries: {:?}", session.entries());
|
||||||
|
session.purge();
|
||||||
|
debug!("Session entries after purge: {:?}", session.entries());
|
||||||
|
Ok(HttpResponse::Ok().body("Logged out successfully"))
|
||||||
|
}
|
39
crates/backend/src/controller/class.rs
Normal file
39
crates/backend/src/controller/class.rs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
use actix_web::{delete, get, post, put, Responder};
|
||||||
|
|
||||||
|
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
||||||
|
cfg.service(get_classes)
|
||||||
|
.service(get_class)
|
||||||
|
.service(create_class)
|
||||||
|
.service(update_class)
|
||||||
|
.service(delete_class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[get("")]
|
||||||
|
async fn get_classes() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[get("/{id}")]
|
||||||
|
async fn get_class() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[post("")]
|
||||||
|
async fn create_class() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[put("")]
|
||||||
|
async fn update_class() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[delete("/{id}")]
|
||||||
|
async fn delete_class() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
39
crates/backend/src/controller/group.rs
Normal file
39
crates/backend/src/controller/group.rs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
use actix_web::{delete, get, post, put, Responder};
|
||||||
|
|
||||||
|
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
||||||
|
cfg.service(get_groups)
|
||||||
|
.service(get_groups_for_project)
|
||||||
|
.service(create_group)
|
||||||
|
.service(update_group)
|
||||||
|
.service(delete_group);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[get("")]
|
||||||
|
async fn get_groups() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[get("/{project}")]
|
||||||
|
async fn get_groups_for_project() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[post("")]
|
||||||
|
async fn create_group() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[put("")]
|
||||||
|
async fn update_group() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[delete("/{id}")]
|
||||||
|
async fn delete_group() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
75
crates/backend/src/controller/project.rs
Normal file
75
crates/backend/src/controller/project.rs
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
use actix_web::{delete, get, post, put, web, Result};
|
||||||
|
use uuid::Uuid;
|
||||||
|
use validator::Validate;
|
||||||
|
|
||||||
|
use crate::db::project::CreateProject;
|
||||||
|
use crate::db::Database;
|
||||||
|
use crate::entity;
|
||||||
|
use crate::error::ApiError;
|
||||||
|
|
||||||
|
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
||||||
|
cfg.service(get_project)
|
||||||
|
.service(get_projects)
|
||||||
|
.service(create_project)
|
||||||
|
.service(update_project)
|
||||||
|
.service(delete_project);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("")]
|
||||||
|
async fn get_projects(
|
||||||
|
db: web::Data<Database>,
|
||||||
|
) -> Result<web::Json<Vec<entity::project::Model>>, ApiError> {
|
||||||
|
let projects = db.get_projects().await?;
|
||||||
|
|
||||||
|
Ok(web::Json(projects))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("/{id}")]
|
||||||
|
async fn get_project(
|
||||||
|
db: web::Data<Database>,
|
||||||
|
path: web::Path<Uuid>,
|
||||||
|
) -> Result<web::Json<entity::project::Model>, ApiError> {
|
||||||
|
let id = path.into_inner();
|
||||||
|
|
||||||
|
let project = db.get_project(&id).await?;
|
||||||
|
|
||||||
|
Ok(web::Json(project.unwrap()))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[post("")]
|
||||||
|
async fn create_project(
|
||||||
|
db: web::Data<Database>,
|
||||||
|
create_project: web::Json<CreateProject>,
|
||||||
|
) -> Result<web::Json<entity::project::Model>, ApiError> {
|
||||||
|
create_project.validate()?;
|
||||||
|
let result = db.create_project(create_project.into_inner()).await?;
|
||||||
|
|
||||||
|
Ok(web::Json(result))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[put("/{id}")]
|
||||||
|
async fn update_project(
|
||||||
|
db: web::Data<Database>,
|
||||||
|
path: web::Path<Uuid>,
|
||||||
|
update_project: web::Json<CreateProject>,
|
||||||
|
) -> Result<web::Json<entity::project::Model>, ApiError> {
|
||||||
|
let updated_project = db
|
||||||
|
.update_project(&path, update_project.into_inner())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(web::Json(updated_project))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[delete("/{id}")]
|
||||||
|
async fn delete_project(
|
||||||
|
db: web::Data<Database>,
|
||||||
|
path: web::Path<Uuid>,
|
||||||
|
) -> Result<web::Json<String>, ApiError> {
|
||||||
|
let id = path.into_inner();
|
||||||
|
let result = db.delete_project(&id).await?;
|
||||||
|
|
||||||
|
Ok(web::Json(format!(
|
||||||
|
"Successfully deleted {} project/s with the id: {}",
|
||||||
|
result.rows_affected, id
|
||||||
|
)))
|
||||||
|
}
|
39
crates/backend/src/controller/template.rs
Normal file
39
crates/backend/src/controller/template.rs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
use actix_web::{delete, get, post, put, Responder};
|
||||||
|
|
||||||
|
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
||||||
|
cfg.service(get_templates)
|
||||||
|
.service(get_template)
|
||||||
|
.service(create_template)
|
||||||
|
.service(update_template)
|
||||||
|
.service(delete_template);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[get("")]
|
||||||
|
async fn get_templates() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[get("/{id}")]
|
||||||
|
async fn get_template() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[post("")]
|
||||||
|
async fn create_template() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[put("")]
|
||||||
|
async fn update_template() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#[delete("/{id}")]
|
||||||
|
async fn delete_template() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
66
crates/backend/src/controller/user.rs
Normal file
66
crates/backend/src/controller/user.rs
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
use crate::{Database, entity, error::ApiError};
|
||||||
|
use actix_web::{Responder, delete, get, post, put, web};
|
||||||
|
use serde::Deserialize;
|
||||||
|
use validator::Validate;
|
||||||
|
|
||||||
|
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
||||||
|
cfg.service(get_users)
|
||||||
|
.service(get_user)
|
||||||
|
.service(create_user)
|
||||||
|
.service(delete_user);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Validate)]
|
||||||
|
struct CreateUser {
|
||||||
|
#[validate(length(min = 4))]
|
||||||
|
username: String,
|
||||||
|
name: String,
|
||||||
|
#[validate(length(min = 8))]
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("")]
|
||||||
|
async fn get_users(
|
||||||
|
db: web::Data<Database>,
|
||||||
|
) -> Result<web::Json<Vec<entity::user::Model>>, ApiError> {
|
||||||
|
let users = db.get_users().await?;
|
||||||
|
Ok(web::Json(users))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("/{id}")]
|
||||||
|
async fn get_user(
|
||||||
|
db: web::Data<Database>,
|
||||||
|
id: web::Path<uuid::Uuid>,
|
||||||
|
) -> Result<web::Json<entity::user::Model>, ApiError> {
|
||||||
|
let user = db.get_user(id.into_inner()).await?;
|
||||||
|
|
||||||
|
Ok(web::Json(user.unwrap()))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[post("")]
|
||||||
|
async fn create_user(
|
||||||
|
db: web::Data<Database>,
|
||||||
|
user: web::Json<CreateUser>,
|
||||||
|
) -> Result<web::Json<entity::user::Model>, ApiError> {
|
||||||
|
let user = user.into_inner();
|
||||||
|
let result = db
|
||||||
|
.create_user(user.name, user.username, user.password)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(web::Json(result))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[put("")]
|
||||||
|
async fn update_user() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
#[delete("/{id}")]
|
||||||
|
async fn delete_user(
|
||||||
|
db: web::Data<Database>,
|
||||||
|
id: web::Path<uuid::Uuid>,
|
||||||
|
) -> Result<web::Json<String>, ApiError> {
|
||||||
|
let id = id.into_inner();
|
||||||
|
db.delete_user(id).await?;
|
||||||
|
Ok(web::Json(format!("User {} deleted", id)))
|
||||||
|
}
|
23
crates/backend/src/db.rs
Normal file
23
crates/backend/src/db.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
use sea_orm::{ConnectOptions, DatabaseConnection};
|
||||||
|
|
||||||
|
pub mod entity;
|
||||||
|
mod group;
|
||||||
|
pub mod project;
|
||||||
|
mod user;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Database {
|
||||||
|
conn: DatabaseConnection,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Database {
|
||||||
|
pub async fn new(options: ConnectOptions) -> Result<Self, sea_orm::DbErr> {
|
||||||
|
Ok(Database {
|
||||||
|
conn: sea_orm::Database::connect(options).await?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn connection(&self) -> &DatabaseConnection {
|
||||||
|
&self.conn
|
||||||
|
}
|
||||||
|
}
|
42
crates/backend/src/db/entity/group.rs
Normal file
42
crates/backend/src/db/entity/group.rs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.7
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||||
|
#[sea_orm(table_name = "group")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: Uuid,
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub project_id: Uuid,
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::project::Entity",
|
||||||
|
from = "Column::ProjectId",
|
||||||
|
to = "super::project::Column::Id",
|
||||||
|
on_update = "Cascade",
|
||||||
|
on_delete = "Cascade"
|
||||||
|
)]
|
||||||
|
Project,
|
||||||
|
#[sea_orm(has_many = "super::user_group_project::Entity")]
|
||||||
|
UserGroupProject,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::project::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::Project.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user_group_project::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::UserGroupProject.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
33
crates/backend/src/db/entity/local_auth.rs
Normal file
33
crates/backend/src/db/entity/local_auth.rs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.7
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||||
|
#[sea_orm(table_name = "local_auth")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: Uuid,
|
||||||
|
pub hash: String,
|
||||||
|
pub password_change_required: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::user::Entity",
|
||||||
|
from = "Column::Id",
|
||||||
|
to = "super::user::Column::Id",
|
||||||
|
on_update = "Cascade",
|
||||||
|
on_delete = "Cascade"
|
||||||
|
)]
|
||||||
|
User,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::User.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
9
crates/backend/src/db/entity/mod.rs
Normal file
9
crates/backend/src/db/entity/mod.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.7
|
||||||
|
|
||||||
|
pub mod prelude;
|
||||||
|
|
||||||
|
pub mod group;
|
||||||
|
pub mod local_auth;
|
||||||
|
pub mod project;
|
||||||
|
pub mod user;
|
||||||
|
pub mod user_group_project;
|
7
crates/backend/src/db/entity/prelude.rs
Normal file
7
crates/backend/src/db/entity/prelude.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.7
|
||||||
|
|
||||||
|
pub use super::group::Entity as Group;
|
||||||
|
pub use super::local_auth::Entity as LocalAuth;
|
||||||
|
pub use super::project::Entity as Project;
|
||||||
|
pub use super::user::Entity as User;
|
||||||
|
pub use super::user_group_project::Entity as UserGroupProject;
|
35
crates/backend/src/db/entity/project.rs
Normal file
35
crates/backend/src/db/entity/project.rs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.7
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||||
|
#[sea_orm(table_name = "project")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: Uuid,
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(has_many = "super::group::Entity")]
|
||||||
|
Group,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::group::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::Group.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user_group_project::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
super::group::Relation::UserGroupProject.def()
|
||||||
|
}
|
||||||
|
fn via() -> Option<RelationDef> {
|
||||||
|
Some(super::group::Relation::Project.def().rev())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
36
crates/backend/src/db/entity/user.rs
Normal file
36
crates/backend/src/db/entity/user.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.7
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||||
|
#[sea_orm(table_name = "user")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: Uuid,
|
||||||
|
#[sea_orm(unique)]
|
||||||
|
pub username: String,
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(has_one = "super::local_auth::Entity")]
|
||||||
|
LocalAuth,
|
||||||
|
#[sea_orm(has_many = "super::user_group_project::Entity")]
|
||||||
|
UserGroupProject,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::local_auth::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::LocalAuth.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user_group_project::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::UserGroupProject.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
58
crates/backend/src/db/entity/user_group_project.rs
Normal file
58
crates/backend/src/db/entity/user_group_project.rs
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.7
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||||
|
#[sea_orm(table_name = "user_group_project")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub user_id: Uuid,
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub group_id: Uuid,
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub project_id: Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::group::Entity",
|
||||||
|
from = "(Column::GroupId, Column::ProjectId)",
|
||||||
|
to = "(super::group::Column::Id, super::group::Column::ProjectId)",
|
||||||
|
on_update = "Cascade",
|
||||||
|
on_delete = "Cascade"
|
||||||
|
)]
|
||||||
|
Group,
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::user::Entity",
|
||||||
|
from = "Column::UserId",
|
||||||
|
to = "super::user::Column::Id",
|
||||||
|
on_update = "Cascade",
|
||||||
|
on_delete = "Cascade"
|
||||||
|
)]
|
||||||
|
User,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::group::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::Group.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::User.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::project::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
super::group::Relation::Project.def()
|
||||||
|
}
|
||||||
|
fn via() -> Option<RelationDef> {
|
||||||
|
Some(super::group::Relation::UserGroupProject.def().rev())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
7
crates/backend/src/db/group.rs
Normal file
7
crates/backend/src/db/group.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
use super::Database;
|
||||||
|
|
||||||
|
impl Database {
|
||||||
|
async fn add_user_to_group(&self) {}
|
||||||
|
|
||||||
|
async fn create_group(&self) {}
|
||||||
|
}
|
84
crates/backend/src/db/project.rs
Normal file
84
crates/backend/src/db/project.rs
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
use super::Database;
|
||||||
|
use crate::error::ApiError;
|
||||||
|
use log::debug;
|
||||||
|
|
||||||
|
use crate::entity::project;
|
||||||
|
use sea_orm::ActiveValue::{NotSet, Set, Unchanged};
|
||||||
|
use sea_orm::{ActiveModelTrait, DeleteResult, EntityTrait};
|
||||||
|
use serde::Deserialize;
|
||||||
|
use uuid::Uuid;
|
||||||
|
use validator::Validate;
|
||||||
|
|
||||||
|
#[derive(Deserialize, Validate)]
|
||||||
|
pub struct CreateProject {
|
||||||
|
#[validate(length(min = 3))]
|
||||||
|
name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Database {
|
||||||
|
pub async fn get_projects(&self) -> Result<Vec<project::Model>, ApiError> {
|
||||||
|
debug!("Fetching all projects");
|
||||||
|
|
||||||
|
let projects = project::Entity::find().all(&self.conn).await?;
|
||||||
|
Ok(projects)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_project(&self, id: &Uuid) -> Result<Option<project::Model>, ApiError> {
|
||||||
|
debug!("Fetching project with id: {}", id);
|
||||||
|
|
||||||
|
let project = project::Entity::find_by_id(id.to_owned())
|
||||||
|
.one(&self.conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if project.is_none() {
|
||||||
|
return Err(ApiError::NotFound);
|
||||||
|
}
|
||||||
|
Ok(project)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn create_project(
|
||||||
|
&self,
|
||||||
|
create_project: CreateProject,
|
||||||
|
) -> Result<project::Model, ApiError> {
|
||||||
|
debug!("Creating project with name: {}", create_project.name);
|
||||||
|
|
||||||
|
let project = project::ActiveModel {
|
||||||
|
id: NotSet,
|
||||||
|
name: Set(create_project.name),
|
||||||
|
};
|
||||||
|
|
||||||
|
let project = project.insert(&self.conn).await?;
|
||||||
|
Ok(project)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_project(
|
||||||
|
&self,
|
||||||
|
id: &Uuid,
|
||||||
|
project: CreateProject,
|
||||||
|
) -> Result<project::Model, ApiError> {
|
||||||
|
debug!("Updating project with id: {}", &id);
|
||||||
|
|
||||||
|
let active_model = project::ActiveModel {
|
||||||
|
id: Unchanged(*id),
|
||||||
|
name: Set(project.name),
|
||||||
|
};
|
||||||
|
|
||||||
|
let project = active_model.update(&self.conn).await?;
|
||||||
|
|
||||||
|
Ok(project)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete_project(&self, id: &Uuid) -> Result<DeleteResult, ApiError> {
|
||||||
|
debug!("Deleting project with id: {}", id);
|
||||||
|
|
||||||
|
let project = project::Entity::delete_by_id(id.to_owned())
|
||||||
|
.exec(&self.conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if project.rows_affected == 0 {
|
||||||
|
return Err(ApiError::NotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(project)
|
||||||
|
}
|
||||||
|
}
|
119
crates/backend/src/db/user.rs
Normal file
119
crates/backend/src/db/user.rs
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
use crate::error::ApiError;
|
||||||
|
use argon2::{
|
||||||
|
Argon2, PasswordHash, PasswordVerifier,
|
||||||
|
password_hash::{PasswordHasher, SaltString, rand_core::OsRng},
|
||||||
|
};
|
||||||
|
use sea_orm::{
|
||||||
|
ActiveModelTrait,
|
||||||
|
ActiveValue::{NotSet, Set},
|
||||||
|
ColumnTrait, DbErr, DeleteResult, EntityTrait, ModelTrait, QueryFilter, TransactionTrait,
|
||||||
|
};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::{Database, entity};
|
||||||
|
|
||||||
|
impl Database {
|
||||||
|
pub async fn get_users(&self) -> Result<Vec<entity::user::Model>, ApiError> {
|
||||||
|
let users = entity::user::Entity::find().all(&self.conn).await?;
|
||||||
|
|
||||||
|
Ok(users)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_user(&self, id: Uuid) -> Result<Option<entity::user::Model>, ApiError> {
|
||||||
|
let user = entity::user::Entity::find()
|
||||||
|
.filter(entity::user::Column::Id.eq(id))
|
||||||
|
.one(&self.conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if user.is_none() {
|
||||||
|
return Err(ApiError::NotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(user)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn create_user(
|
||||||
|
&self,
|
||||||
|
name: String,
|
||||||
|
username: String,
|
||||||
|
password: String,
|
||||||
|
) -> Result<entity::user::Model, ApiError> {
|
||||||
|
let argon2 = Argon2::default();
|
||||||
|
|
||||||
|
let salt = SaltString::generate(&mut OsRng);
|
||||||
|
let hash = argon2
|
||||||
|
.hash_password(password.as_bytes(), &salt)
|
||||||
|
.map_err(|err| ApiError::Argon2Error(err.to_string()))?
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
let user = self
|
||||||
|
.conn
|
||||||
|
.transaction::<_, entity::user::Model, DbErr>(|txn| {
|
||||||
|
Box::pin(async move {
|
||||||
|
let user = entity::user::ActiveModel {
|
||||||
|
id: NotSet,
|
||||||
|
name: Set(name),
|
||||||
|
username: Set(username),
|
||||||
|
};
|
||||||
|
|
||||||
|
let user: entity::user::Model = user.insert(txn).await?;
|
||||||
|
|
||||||
|
let local_auth = entity::local_auth::ActiveModel {
|
||||||
|
id: Set(user.id),
|
||||||
|
hash: Set(hash),
|
||||||
|
password_change_required: NotSet,
|
||||||
|
};
|
||||||
|
|
||||||
|
local_auth.insert(txn).await?;
|
||||||
|
Ok(user)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
Ok(user)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn verify_local_user(
|
||||||
|
&self,
|
||||||
|
username: &str,
|
||||||
|
password: &str,
|
||||||
|
) -> Result<Uuid, ApiError> {
|
||||||
|
let user = entity::user::Entity::find()
|
||||||
|
.filter(entity::user::Column::Username.eq(username))
|
||||||
|
.one(&self.conn)
|
||||||
|
.await?
|
||||||
|
.ok_or(ApiError::Unauthorized)?;
|
||||||
|
|
||||||
|
let local_auth = user
|
||||||
|
.find_related(entity::local_auth::Entity)
|
||||||
|
.one(&self.conn)
|
||||||
|
.await?
|
||||||
|
.ok_or(ApiError::Unauthorized)?;
|
||||||
|
|
||||||
|
let argon2 = Argon2::default();
|
||||||
|
|
||||||
|
let password_hash = PasswordHash::new(&local_auth.hash)
|
||||||
|
.map_err(|err| ApiError::Argon2Error(err.to_string()))?;
|
||||||
|
|
||||||
|
if let Err(_) = argon2.verify_password(password.as_bytes(), &password_hash) {
|
||||||
|
return Err(ApiError::Unauthorized);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(user.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete_user(&self, id: Uuid) -> Result<DeleteResult, ApiError> {
|
||||||
|
let user = entity::user::Entity::delete_by_id(id)
|
||||||
|
.exec(&self.conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if user.rows_affected == 0 {
|
||||||
|
return Err(ApiError::NotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(user)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn verify_ldap_user() {}
|
||||||
|
|
||||||
|
pub async fn change_user_password() {}
|
||||||
|
}
|
51
crates/backend/src/error.rs
Normal file
51
crates/backend/src/error.rs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
use actix_web::{HttpResponse, ResponseError, cookie::time::error, http::StatusCode};
|
||||||
|
use sea_orm::TransactionError;
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum ApiError {
|
||||||
|
#[error("Database Error: {0}")]
|
||||||
|
Database(#[from] sea_orm::DbErr),
|
||||||
|
#[error("Unauthorized")]
|
||||||
|
Unauthorized,
|
||||||
|
#[error("Not Found")]
|
||||||
|
NotFound,
|
||||||
|
#[error("Bad Request: {0}")]
|
||||||
|
BadRequest(String),
|
||||||
|
#[error("Validation Error: {0}")]
|
||||||
|
ValidationError(#[from] validator::ValidationErrors),
|
||||||
|
#[error("Argon2 Error: {0}")]
|
||||||
|
Argon2Error(String),
|
||||||
|
#[error("Session insert error: {0}")]
|
||||||
|
SessionInsertError(#[from] actix_session::SessionInsertError),
|
||||||
|
#[error("Already logged in")]
|
||||||
|
AlreadyLoggedIn,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ResponseError for ApiError {
|
||||||
|
fn status_code(&self) -> StatusCode {
|
||||||
|
match self {
|
||||||
|
ApiError::Database(..) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
ApiError::NotFound => StatusCode::NOT_FOUND,
|
||||||
|
ApiError::Unauthorized => StatusCode::UNAUTHORIZED,
|
||||||
|
ApiError::BadRequest(..) => StatusCode::BAD_REQUEST,
|
||||||
|
ApiError::ValidationError(..) => StatusCode::BAD_REQUEST,
|
||||||
|
ApiError::Argon2Error(..) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
ApiError::SessionInsertError(..) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
ApiError::AlreadyLoggedIn => StatusCode::BAD_REQUEST,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn error_response(&self) -> HttpResponse {
|
||||||
|
HttpResponse::build(self.status_code()).body(self.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<TransactionError<sea_orm::DbErr>> for ApiError {
|
||||||
|
fn from(value: TransactionError<sea_orm::DbErr>) -> Self {
|
||||||
|
Self::Database(match value {
|
||||||
|
TransactionError::Connection(e) => e,
|
||||||
|
TransactionError::Transaction(e) => e,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
227
crates/backend/src/main.rs
Normal file
227
crates/backend/src/main.rs
Normal file
|
@ -0,0 +1,227 @@
|
||||||
|
use actix_files::NamedFile;
|
||||||
|
use actix_session::Session;
|
||||||
|
use actix_session::{SessionMiddleware, storage::RedisSessionStore};
|
||||||
|
use actix_web::cookie::SameSite;
|
||||||
|
use actix_web::{App, HttpResponse, HttpServer, cookie::Key, middleware::Logger, web};
|
||||||
|
use log::debug;
|
||||||
|
|
||||||
|
mod controller;
|
||||||
|
mod db;
|
||||||
|
mod error;
|
||||||
|
|
||||||
|
pub use db::Database;
|
||||||
|
pub use db::entity;
|
||||||
|
use log::info;
|
||||||
|
use migration::Migrator;
|
||||||
|
use migration::MigratorTrait;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
struct AppConfig {
|
||||||
|
ldap_auth: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_web::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||||
|
|
||||||
|
let database_url = build_database_url();
|
||||||
|
|
||||||
|
let database = Database::new(database_url.into()).await.unwrap();
|
||||||
|
|
||||||
|
info!("Running migrations");
|
||||||
|
Migrator::up(database.connection(), None).await.unwrap();
|
||||||
|
info!("Migrations completed");
|
||||||
|
|
||||||
|
let redis_conn = connect_to_redis_database().await;
|
||||||
|
|
||||||
|
let app_config = AppConfig { ldap_auth: false };
|
||||||
|
|
||||||
|
// use dotenvy here to get SECRET_KEY
|
||||||
|
let secret_key = Key::generate();
|
||||||
|
debug!("Secret Key {:?}", secret_key.master());
|
||||||
|
|
||||||
|
HttpServer::new(move || {
|
||||||
|
let session_middleware = SessionMiddleware::builder(redis_conn.clone(), secret_key.clone());
|
||||||
|
|
||||||
|
let session_middleware = if cfg!(debug_assertions) {
|
||||||
|
session_middleware.cookie_secure(false)
|
||||||
|
} else {
|
||||||
|
session_middleware
|
||||||
|
.cookie_same_site(SameSite::Strict)
|
||||||
|
.cookie_secure(true)
|
||||||
|
};
|
||||||
|
|
||||||
|
let session_middleware = session_middleware.build();
|
||||||
|
|
||||||
|
let app = App::new()
|
||||||
|
.app_data(web::Data::new(database.clone()))
|
||||||
|
.app_data(web::Data::new(app_config.clone()))
|
||||||
|
.wrap(Logger::default())
|
||||||
|
.wrap(session_middleware)
|
||||||
|
.service(web::scope("/api/v1").configure(controller::register_controllers));
|
||||||
|
|
||||||
|
#[cfg(feature = "serve")]
|
||||||
|
let app = {
|
||||||
|
info!("running serve");
|
||||||
|
app.default_service(
|
||||||
|
web::get().to(async || NamedFile::open_async("./web/index.html").await),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
app
|
||||||
|
})
|
||||||
|
.bind(("0.0.0.0", 8080))?
|
||||||
|
.run()
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
|
fn get_env_var(name: &str) -> dotenvy::Result<String> {
|
||||||
|
dotenvy::var(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
fn get_env_var(name: &str) -> Result<String, std::env::VarError> {
|
||||||
|
std::env::var(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn connect_to_redis_database() -> RedisSessionStore {
|
||||||
|
let redis_host = get_env_var("REDIS_HOST").expect("REDIS_HOST must be set in .env");
|
||||||
|
let redis_port = get_env_var("REDIS_PORT")
|
||||||
|
.map(|x| x.parse::<u16>().expect("REDIS_PORT is not a valid port"))
|
||||||
|
.unwrap_or(6379);
|
||||||
|
let redis_connection_string = format!("redis://{}:{}", redis_host, redis_port);
|
||||||
|
let store = RedisSessionStore::new(redis_connection_string)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
store
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_database_url() -> String {
|
||||||
|
let db_user = get_env_var("DB_USER").unwrap_or_else(|_| "pgg".to_owned());
|
||||||
|
let db_name = get_env_var("DB_NAME").unwrap_or_else(|_| "pgg".to_owned());
|
||||||
|
let db_password = get_env_var("DB_PASSWORD").unwrap_or_else(|_| "pgg".to_owned());
|
||||||
|
let db_host = get_env_var("DB_HOST").expect("DB_HOST must be set in .env");
|
||||||
|
let db_port = get_env_var("DB_PORT")
|
||||||
|
.map(|x| x.parse::<u16>().expect("DB_PORT is not a valid port"))
|
||||||
|
.unwrap_or(5432);
|
||||||
|
|
||||||
|
let result = format!(
|
||||||
|
"postgresql://{}:{}@{}:{}/{}",
|
||||||
|
db_user, db_password, db_host, db_port, db_name
|
||||||
|
);
|
||||||
|
|
||||||
|
println!("Database URL: {}", result);
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use serial_test::serial;
|
||||||
|
use std::env;
|
||||||
|
use temp_env::{with_var, with_vars};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn build_database_url_with_defaults() {
|
||||||
|
with_vars([("DB_HOST", Some("localhost"))], || {
|
||||||
|
let expected_url = "postgresql://pgg:pgg@localhost:5432/pgg";
|
||||||
|
let actual_url = build_database_url();
|
||||||
|
assert_eq!(
|
||||||
|
actual_url, expected_url,
|
||||||
|
"Database URL should use default values for unset env vars."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn build_database_url_with_all_vars() {
|
||||||
|
with_vars(
|
||||||
|
[
|
||||||
|
("DB_USER", Some("testuser")),
|
||||||
|
("DB_NAME", Some("testdb")),
|
||||||
|
("DB_PASSWORD", Some("testpass")),
|
||||||
|
("DB_HOST", Some("otherhost.internal")),
|
||||||
|
("DB_PORT", Some("5433")),
|
||||||
|
],
|
||||||
|
|| {
|
||||||
|
let expected_url = "postgresql://testuser:testpass@otherhost.internal:5433/testdb";
|
||||||
|
let actual_url = build_database_url();
|
||||||
|
assert_eq!(
|
||||||
|
actual_url, expected_url,
|
||||||
|
"Database URL should use all provided env vars."
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
#[should_panic(expected = "DB_HOST must be set in .env")]
|
||||||
|
fn build_database_url_missing_host_panics() {
|
||||||
|
with_var("DB_HOST", None::<&str>, || {
|
||||||
|
build_database_url();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn connect_to_redis_database_with_defaults() {
|
||||||
|
with_vars([("REDIS_HOST", Some("localhost"))], || {
|
||||||
|
let expected_conn_string = "redis://localhost:6379";
|
||||||
|
|
||||||
|
let redis_host = get_env_var("REDIS_HOST").unwrap_or_default();
|
||||||
|
let redis_port = get_env_var("REDIS_PORT")
|
||||||
|
.map(|x| x.parse::<u16>().unwrap_or(6379))
|
||||||
|
.unwrap_or(6379);
|
||||||
|
let actual_conn_string = format!("redis://{redis_host}:{redis_port}");
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
actual_conn_string, expected_conn_string,
|
||||||
|
"Redis connection string should use default port when not specified."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn connect_to_redis_database_with_custom_port() {
|
||||||
|
with_vars(
|
||||||
|
[
|
||||||
|
("REDIS_HOST", Some("redis.internal")),
|
||||||
|
("REDIS_PORT", Some("6380")),
|
||||||
|
],
|
||||||
|
|| {
|
||||||
|
let expected_conn_string = "redis://redis.internal:6380";
|
||||||
|
|
||||||
|
let redis_host = get_env_var("REDIS_HOST").unwrap_or_default();
|
||||||
|
let redis_port = get_env_var("REDIS_PORT")
|
||||||
|
.map(|x| x.parse::<u16>().unwrap_or(6379))
|
||||||
|
.unwrap_or(6379);
|
||||||
|
let actual_conn_string = format!("redis://{}:{}", redis_host, redis_port);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
actual_conn_string, expected_conn_string,
|
||||||
|
"Redis connection string should use specified host and port."
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn check_if_no_env_variables_are_loaded_from_environment_file() {
|
||||||
|
assert_eq!(env::var("DB_NAME"), Err(env::VarError::NotPresent));
|
||||||
|
assert_eq!(env::var("DB_USER"), Err(env::VarError::NotPresent));
|
||||||
|
assert_eq!(env::var("DB_PASSWORD"), Err(env::VarError::NotPresent));
|
||||||
|
assert_eq!(env::var("DB_HOST"), Err(env::VarError::NotPresent));
|
||||||
|
assert_eq!(env::var("DB_PORT"), Err(env::VarError::NotPresent));
|
||||||
|
|
||||||
|
assert_eq!(env::var("REDIS_PORT"), Err(env::VarError::NotPresent));
|
||||||
|
assert_eq!(env::var("REDIS_HOST"), Err(env::VarError::NotPresent));
|
||||||
|
}
|
||||||
|
}
|
12
crates/ldap/Cargo.toml
Normal file
12
crates/ldap/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[package]
|
||||||
|
name = "ldap"
|
||||||
|
version = { workspace = true }
|
||||||
|
edition = { workspace = true }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
actix-web = "4"
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
ldap3 = "0.11"
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
env_logger = "0.11"
|
||||||
|
log = "0.4"
|
70
crates/ldap/src/ldap.rs
Normal file
70
crates/ldap/src/ldap.rs
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
use actix_web::{post, web, App, HttpResponse, HttpServer, Responder};
|
||||||
|
use ldap3::{LdapConn, Scope, SearchEntry};
|
||||||
|
use serde::Deserialize;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
// Struct to deserialize login request payload
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct LoginRequest {
|
||||||
|
username: String,
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTP POST endpoint for user login
|
||||||
|
#[post("/login")]
|
||||||
|
async fn login(credentials: web::Json<LoginRequest>) -> impl Responder {
|
||||||
|
// Get LDAP server and base DN from environment variables or use defaults
|
||||||
|
let ldap_server = env::var("LDAP_SERVER").unwrap_or("ldap://127.0.0.1:389".to_string());
|
||||||
|
let base_dn = env::var("LDAP_BASE_DN").unwrap_or("dc=schule,dc=local".to_string());
|
||||||
|
|
||||||
|
// Authenticate user and return appropriate response
|
||||||
|
match authenticate_user(&ldap_server, &base_dn, &credentials.username, &credentials.password) {
|
||||||
|
Ok(true) => HttpResponse::Ok().body("Login erfolgreich"), // Login successful
|
||||||
|
_ => HttpResponse::Unauthorized().body("Login fehlgeschlagen"), // Login failed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to authenticate user against LDAP server
|
||||||
|
fn authenticate_user(
|
||||||
|
ldap_server: &str,
|
||||||
|
base_dn: &str,
|
||||||
|
username: &str,
|
||||||
|
password: &str,
|
||||||
|
) -> Result<bool, Box<dyn std::error::Error>> {
|
||||||
|
// Establish connection to LDAP server
|
||||||
|
let ldap = LdapConn::new(ldap_server)?;
|
||||||
|
|
||||||
|
// Search for the user in the LDAP directory
|
||||||
|
let (rs, _res) = ldap
|
||||||
|
.search(
|
||||||
|
&format!("ou=users,{}", base_dn), // Search under "ou=users"
|
||||||
|
Scope::Subtree, // Search all levels
|
||||||
|
&format!("(uid={})", username), // Filter by username
|
||||||
|
vec!["dn"], // Retrieve the distinguished name (DN)
|
||||||
|
)?
|
||||||
|
.success()?;
|
||||||
|
|
||||||
|
// If user is found, attempt to authenticate with their DN and password
|
||||||
|
if let Some(entry) = rs.into_iter().next() {
|
||||||
|
let user_dn = SearchEntry::construct(entry).dn; // Extract user DN
|
||||||
|
|
||||||
|
// Reconnect and bind with user credentials
|
||||||
|
let user_ldap = LdapConn::new(ldap_server)?;
|
||||||
|
let auth_result = user_ldap.simple_bind(&user_dn, password)?.success();
|
||||||
|
return Ok(auth_result.is_ok()); // Return true if authentication succeeds
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(false) // Return false if user is not found
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main function to start the Actix Web server
|
||||||
|
#[actix_web::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
|
env_logger::init(); // Initialize logger
|
||||||
|
|
||||||
|
// Start HTTP server and bind to localhost:8080
|
||||||
|
HttpServer::new(|| App::new().service(login))
|
||||||
|
.bind(("127.0.0.1", 8080))?
|
||||||
|
.run()
|
||||||
|
.await
|
||||||
|
}
|
46
crates/ldap/src/lib.rs
Normal file
46
crates/ldap/src/lib.rs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
use ldap3::{LdapConn, Scope, SearchEntry};
|
||||||
|
|
||||||
|
/// Authenticates a user against an LDAP server.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
/// * `ldap_server` - The LDAP server URL.
|
||||||
|
/// * `base_dn` - The base DN for the LDAP directory.
|
||||||
|
/// * `username` - The username to authenticate.
|
||||||
|
/// * `password` - The password for the user.
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
/// * `Ok(true)` if authentication is successful.
|
||||||
|
/// * `Ok(false)` if authentication fails.
|
||||||
|
/// * `Err` if an error occurs during the process.
|
||||||
|
pub fn authenticate_user(
|
||||||
|
ldap_server: &str,
|
||||||
|
base_dn: &str,
|
||||||
|
username: &str,
|
||||||
|
password: &str,
|
||||||
|
) -> Result<bool, Box<dyn std::error::Error>> {
|
||||||
|
// Establish connection to LDAP server
|
||||||
|
let ldap = LdapConn::new(ldap_server)?;
|
||||||
|
|
||||||
|
// Search for the user in the LDAP directory
|
||||||
|
let (rs, _res) = ldap
|
||||||
|
.search(
|
||||||
|
&format!("ou=users,{}", base_dn), // Search under "ou=users"
|
||||||
|
Scope::Subtree, // Search all levels
|
||||||
|
&format!("(uid={})", username), // Filter by username
|
||||||
|
vec!["dn"], // Retrieve the distinguished name (DN)
|
||||||
|
)?
|
||||||
|
.success()?;
|
||||||
|
|
||||||
|
// If user is found, attempt to authenticate with their DN and password
|
||||||
|
if let Some(entry) = rs.into_iter().next() {
|
||||||
|
let user_dn = SearchEntry::construct(entry).dn; // Extract user DN
|
||||||
|
|
||||||
|
// Reconnect and bind with user credentials
|
||||||
|
let user_ldap = LdapConn::new(ldap_server)?;
|
||||||
|
let auth_result = user_ldap.simple_bind(&user_dn, password)?.success();
|
||||||
|
return Ok(auth_result.is_ok()); // Return true if authentication succeeds
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(false) // Return false if user is not found
|
||||||
|
}
|
||||||
|
|
37
crates/ldap/src/main.rs
Normal file
37
crates/ldap/src/main.rs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
use actix_web::{post, web, App, HttpResponse, HttpServer, Responder};
|
||||||
|
use serde::Deserialize;
|
||||||
|
use ldap::authenticate_user; // Import the library function
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
// Struct to deserialize login request payload
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct LoginRequest {
|
||||||
|
username: String,
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTP POST endpoint for user login
|
||||||
|
#[post("/login")]
|
||||||
|
async fn login(credentials: web::Json<LoginRequest>) -> impl Responder {
|
||||||
|
// Get LDAP server and base DN from environment variables or use defaults
|
||||||
|
let ldap_server = env::var("LDAP_SERVER").unwrap_or("ldap://127.0.0.1:389".to_string());
|
||||||
|
let base_dn = env::var("LDAP_BASE_DN").unwrap_or("dc=schule,dc=local".to_string());
|
||||||
|
|
||||||
|
// Authenticate user and return appropriate response
|
||||||
|
match authenticate_user(&ldap_server, &base_dn, &credentials.username, &credentials.password) {
|
||||||
|
Ok(true) => HttpResponse::Ok().body("Login erfolgreich"), // Login successful
|
||||||
|
_ => HttpResponse::Unauthorized().body("Login fehlgeschlagen"), // Login failed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main function to start the Actix Web server
|
||||||
|
#[actix_web::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
|
env_logger::init(); // Initialize logger
|
||||||
|
|
||||||
|
// Start HTTP server and bind to localhost:8080
|
||||||
|
HttpServer::new(|| App::new().service(login))
|
||||||
|
.bind(("127.0.0.1", 8080))?
|
||||||
|
.run()
|
||||||
|
.await
|
||||||
|
}
|
29
crates/ldap/src/user.ldif
Normal file
29
crates/ldap/src/user.ldif
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
dn: ou=users,dc=schule,dc=local
|
||||||
|
objectClass: organizationalUnit
|
||||||
|
ou: users
|
||||||
|
|
||||||
|
dn: uid=schueler1,ou=users,dc=schule,dc=local
|
||||||
|
objectClass: inetOrgPerson
|
||||||
|
objectClass: posixAccount
|
||||||
|
objectClass: shadowAccount
|
||||||
|
cn: Schueler1
|
||||||
|
sn: Mustermann
|
||||||
|
uid: schueler1
|
||||||
|
uidNumber: 1001
|
||||||
|
gidNumber: 1001
|
||||||
|
homeDirectory: /home/schueler1
|
||||||
|
loginShell: /bin/bash
|
||||||
|
userPassword: {SSHA}JDJhJDEwJG5EUFZ6U0pOSmpUckhOajRQY0hWNS5DNEp4Q2Mwa1pQSTZWYVhXeVdDMkFUMkFMY1do
|
||||||
|
|
||||||
|
dn: uid=schueler2,ou=users,dc=schule,dc=local
|
||||||
|
objectClass: inetOrgPerson
|
||||||
|
objectClass: posixAccount
|
||||||
|
objectClass: shadowAccount
|
||||||
|
cn: Schueler2
|
||||||
|
sn: Beispiel
|
||||||
|
uid: schueler2
|
||||||
|
uidNumber: 1002
|
||||||
|
gidNumber: 1002
|
||||||
|
homeDirectory: /home/schueler2
|
||||||
|
loginShell: /bin/bash
|
||||||
|
userPassword: {SSHA}JDJhJDEwJEpNVTRzNUk4Z3dQclA1M2o1bU5FZWZKeTRHTlVndXZ0Q0VhblBuNlZXUENyaFZ4Q3NmS2lH
|
22
crates/migration/Cargo.toml
Normal file
22
crates/migration/Cargo.toml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
[package]
|
||||||
|
name = "migration"
|
||||||
|
version = { workspace = true }
|
||||||
|
edition = { workspace = true }
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "migration"
|
||||||
|
path = "src/lib.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
async-std = { version = "1", features = ["attributes", "tokio1"] }
|
||||||
|
|
||||||
|
[dependencies.sea-orm-migration]
|
||||||
|
version = "1.1.0"
|
||||||
|
features = [
|
||||||
|
# Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI.
|
||||||
|
# View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime.
|
||||||
|
# e.g.
|
||||||
|
"runtime-tokio-rustls", # `ASYNC_RUNTIME` feature
|
||||||
|
"sqlx-postgres", # `DATABASE_DRIVER` feature
|
||||||
|
]
|
41
crates/migration/README.md
Normal file
41
crates/migration/README.md
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
# Running Migrator CLI
|
||||||
|
|
||||||
|
- Generate a new migration file
|
||||||
|
```sh
|
||||||
|
cargo run -- generate MIGRATION_NAME
|
||||||
|
```
|
||||||
|
- Apply all pending migrations
|
||||||
|
```sh
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
|
```sh
|
||||||
|
cargo run -- up
|
||||||
|
```
|
||||||
|
- Apply first 10 pending migrations
|
||||||
|
```sh
|
||||||
|
cargo run -- up -n 10
|
||||||
|
```
|
||||||
|
- Rollback last applied migrations
|
||||||
|
```sh
|
||||||
|
cargo run -- down
|
||||||
|
```
|
||||||
|
- Rollback last 10 applied migrations
|
||||||
|
```sh
|
||||||
|
cargo run -- down -n 10
|
||||||
|
```
|
||||||
|
- Drop all tables from the database, then reapply all migrations
|
||||||
|
```sh
|
||||||
|
cargo run -- fresh
|
||||||
|
```
|
||||||
|
- Rollback all applied migrations, then reapply all migrations
|
||||||
|
```sh
|
||||||
|
cargo run -- refresh
|
||||||
|
```
|
||||||
|
- Rollback all applied migrations
|
||||||
|
```sh
|
||||||
|
cargo run -- reset
|
||||||
|
```
|
||||||
|
- Check the status of all migrations
|
||||||
|
```sh
|
||||||
|
cargo run -- status
|
||||||
|
```
|
523
crates/migration/erm.drawio
Normal file
523
crates/migration/erm.drawio
Normal file
|
@ -0,0 +1,523 @@
|
||||||
|
<mxfile host="65bd71144e">
|
||||||
|
<diagram id="ZVGeBRT34x6V4W1wSxZ6" name="Page-1">
|
||||||
|
<mxGraphModel dx="871" dy="1114" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
||||||
|
<root>
|
||||||
|
<mxCell id="0"/>
|
||||||
|
<mxCell id="1" parent="0"/>
|
||||||
|
<mxCell id="28" value="StudentGroupProject" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;html=1;whiteSpace=wrap;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="640" y="380" width="210" height="180" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="29" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;html=1;" parent="28" vertex="1">
|
||||||
|
<mxGeometry y="30" width="210" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="30" value="PK,FK1" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;html=1;whiteSpace=wrap;" parent="29" vertex="1">
|
||||||
|
<mxGeometry width="60" height="30" as="geometry">
|
||||||
|
<mxRectangle width="60" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="31" value="StudentID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;html=1;whiteSpace=wrap;" parent="29" vertex="1">
|
||||||
|
<mxGeometry x="60" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="32" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;html=1;strokeColor=default;" parent="28" vertex="1">
|
||||||
|
<mxGeometry y="60" width="210" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="33" value="PK, FK" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;html=1;whiteSpace=wrap;" parent="32" vertex="1">
|
||||||
|
<mxGeometry width="60" height="30" as="geometry">
|
||||||
|
<mxRectangle width="60" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="34" value="GroupID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;html=1;whiteSpace=wrap;strokeColor=inherit;" parent="32" vertex="1">
|
||||||
|
<mxGeometry x="60" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="41" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;html=1;strokeColor=default;" parent="28" vertex="1">
|
||||||
|
<mxGeometry y="90" width="210" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="42" value="PK,FK2" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;html=1;whiteSpace=wrap;" parent="41" vertex="1">
|
||||||
|
<mxGeometry width="60" height="30" as="geometry">
|
||||||
|
<mxRectangle width="60" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="43" value="ProjectID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;html=1;whiteSpace=wrap;" parent="41" vertex="1">
|
||||||
|
<mxGeometry x="60" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="35" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;html=1;" parent="28" vertex="1">
|
||||||
|
<mxGeometry y="120" width="210" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="36" value="FK3" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;html=1;whiteSpace=wrap;" parent="35" vertex="1">
|
||||||
|
<mxGeometry width="60" height="30" as="geometry">
|
||||||
|
<mxRectangle width="60" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="37" value="GroupID, LearningFieldID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;html=1;whiteSpace=wrap;" parent="35" vertex="1">
|
||||||
|
<mxGeometry x="60" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="38" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;html=1;" parent="28" vertex="1">
|
||||||
|
<mxGeometry y="150" width="210" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="39" value="FK4" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;html=1;whiteSpace=wrap;" parent="38" vertex="1">
|
||||||
|
<mxGeometry width="60" height="30" as="geometry">
|
||||||
|
<mxRectangle width="60" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="40" value="SubProjectID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;html=1;whiteSpace=wrap;" parent="38" vertex="1">
|
||||||
|
<mxGeometry x="60" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="44" value="Project" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="100" y="610" width="180" height="180" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="45" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;swimlaneLine=1;" parent="44" vertex="1">
|
||||||
|
<mxGeometry y="30" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="46" value="PK" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="45" vertex="1">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="47" value="ProjectID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;whiteSpace=wrap;html=1;" parent="45" vertex="1">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="231" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" vertex="1" parent="44">
|
||||||
|
<mxGeometry y="60" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="232" value="FK" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="231">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="233" value="ClassGroupID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="231">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="48" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="44" vertex="1">
|
||||||
|
<mxGeometry y="90" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="49" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="48" vertex="1">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="50" value="Name" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="48" vertex="1">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="51" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="44" vertex="1">
|
||||||
|
<mxGeometry y="120" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="52" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="51" vertex="1">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="53" value="Row 2" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="51" vertex="1">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="54" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="44" vertex="1">
|
||||||
|
<mxGeometry y="150" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="55" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="54" vertex="1">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="56" value="Row 3" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="54" vertex="1">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="57" value="Group" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="100" y="410" width="180" height="180" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="58" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="57" vertex="1">
|
||||||
|
<mxGeometry y="30" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="59" value="PK" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="58" vertex="1">
|
||||||
|
<mxGeometry width="50" height="30" as="geometry">
|
||||||
|
<mxRectangle width="50" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="60" value="GroupID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;whiteSpace=wrap;html=1;" parent="58" vertex="1">
|
||||||
|
<mxGeometry x="50" width="130" height="30" as="geometry">
|
||||||
|
<mxRectangle width="130" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="106" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="57" vertex="1">
|
||||||
|
<mxGeometry y="60" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="107" value="PK, FK" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="106" vertex="1">
|
||||||
|
<mxGeometry width="50" height="30" as="geometry">
|
||||||
|
<mxRectangle width="50" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="108" value="ProjectID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;whiteSpace=wrap;html=1;" parent="106" vertex="1">
|
||||||
|
<mxGeometry x="50" width="130" height="30" as="geometry">
|
||||||
|
<mxRectangle width="130" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="61" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="57" vertex="1">
|
||||||
|
<mxGeometry y="90" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="62" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="61" vertex="1">
|
||||||
|
<mxGeometry width="50" height="30" as="geometry">
|
||||||
|
<mxRectangle width="50" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="63" value="Row 1" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="61" vertex="1">
|
||||||
|
<mxGeometry x="50" width="130" height="30" as="geometry">
|
||||||
|
<mxRectangle width="130" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="64" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="57" vertex="1">
|
||||||
|
<mxGeometry y="120" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="65" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="64" vertex="1">
|
||||||
|
<mxGeometry width="50" height="30" as="geometry">
|
||||||
|
<mxRectangle width="50" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="66" value="Row 2" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="64" vertex="1">
|
||||||
|
<mxGeometry x="50" width="130" height="30" as="geometry">
|
||||||
|
<mxRectangle width="130" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="67" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="57" vertex="1">
|
||||||
|
<mxGeometry y="150" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="68" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="67" vertex="1">
|
||||||
|
<mxGeometry width="50" height="30" as="geometry">
|
||||||
|
<mxRectangle width="50" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="69" value="Row 3" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="67" vertex="1">
|
||||||
|
<mxGeometry x="50" width="130" height="30" as="geometry">
|
||||||
|
<mxRectangle width="130" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="70" value="student" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="100" y="240" width="180" height="150" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="71" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="70" vertex="1">
|
||||||
|
<mxGeometry y="30" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="72" value="PK, FK" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="71" vertex="1">
|
||||||
|
<mxGeometry width="50" height="30" as="geometry">
|
||||||
|
<mxRectangle width="50" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="73" value="userID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;whiteSpace=wrap;html=1;" parent="71" vertex="1">
|
||||||
|
<mxGeometry x="50" width="130" height="30" as="geometry">
|
||||||
|
<mxRectangle width="130" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="74" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="70" vertex="1">
|
||||||
|
<mxGeometry y="60" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="75" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="74" vertex="1">
|
||||||
|
<mxGeometry width="50" height="30" as="geometry">
|
||||||
|
<mxRectangle width="50" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="76" value="Class" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="74" vertex="1">
|
||||||
|
<mxGeometry x="50" width="130" height="30" as="geometry">
|
||||||
|
<mxRectangle width="130" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="77" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="70" vertex="1">
|
||||||
|
<mxGeometry y="90" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="78" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="77" vertex="1">
|
||||||
|
<mxGeometry width="50" height="30" as="geometry">
|
||||||
|
<mxRectangle width="50" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="79" value="Row 2" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="77" vertex="1">
|
||||||
|
<mxGeometry x="50" width="130" height="30" as="geometry">
|
||||||
|
<mxRectangle width="130" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="80" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="70" vertex="1">
|
||||||
|
<mxGeometry y="120" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="81" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="80" vertex="1">
|
||||||
|
<mxGeometry width="50" height="30" as="geometry">
|
||||||
|
<mxRectangle width="50" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="82" value="Row 3" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="80" vertex="1">
|
||||||
|
<mxGeometry x="50" width="130" height="30" as="geometry">
|
||||||
|
<mxRectangle width="130" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="91" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;edgeStyle=orthogonalEdgeStyle;" parent="1" source="106" target="41" edge="1">
|
||||||
|
<mxGeometry relative="1" as="geometry">
|
||||||
|
<mxPoint x="380" y="630" as="sourcePoint"/>
|
||||||
|
<mxPoint x="540" y="630" as="targetPoint"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="92" value="M" style="resizable=0;html=1;whiteSpace=wrap;align=left;verticalAlign=bottom;" parent="91" connectable="0" vertex="1">
|
||||||
|
<mxGeometry x="-1" relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="93" value="N" style="resizable=0;html=1;whiteSpace=wrap;align=right;verticalAlign=bottom;" parent="91" connectable="0" vertex="1">
|
||||||
|
<mxGeometry x="1" relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="100" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;edgeStyle=orthogonalEdgeStyle;" parent="1" source="71" target="29" edge="1">
|
||||||
|
<mxGeometry relative="1" as="geometry">
|
||||||
|
<mxPoint x="380" y="630" as="sourcePoint"/>
|
||||||
|
<mxPoint x="540" y="630" as="targetPoint"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="101" value="M" style="resizable=0;html=1;whiteSpace=wrap;align=left;verticalAlign=bottom;" parent="100" connectable="0" vertex="1">
|
||||||
|
<mxGeometry x="-1" relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="102" value="N" style="resizable=0;html=1;whiteSpace=wrap;align=right;verticalAlign=bottom;" parent="100" connectable="0" vertex="1">
|
||||||
|
<mxGeometry x="1" relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="103" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;edgeStyle=orthogonalEdgeStyle;" parent="1" source="58" target="32" edge="1">
|
||||||
|
<mxGeometry relative="1" as="geometry">
|
||||||
|
<mxPoint x="380" y="630" as="sourcePoint"/>
|
||||||
|
<mxPoint x="540" y="630" as="targetPoint"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="104" value="M" style="resizable=0;html=1;whiteSpace=wrap;align=left;verticalAlign=bottom;" parent="103" connectable="0" vertex="1">
|
||||||
|
<mxGeometry x="-1" relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="105" value="N" style="resizable=0;html=1;whiteSpace=wrap;align=right;verticalAlign=bottom;" parent="103" connectable="0" vertex="1">
|
||||||
|
<mxGeometry x="1" relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="117" style="edgeStyle=orthogonalEdgeStyle;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;startArrow=classic;startFill=1;" parent="1" source="106" target="45" edge="1">
|
||||||
|
<mxGeometry relative="1" as="geometry">
|
||||||
|
<Array as="points">
|
||||||
|
<mxPoint x="40" y="485"/>
|
||||||
|
<mxPoint x="40" y="655"/>
|
||||||
|
</Array>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="125" value="user" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="100" y="60" width="180" height="150" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="126" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="125" vertex="1">
|
||||||
|
<mxGeometry y="30" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="127" value="PK" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="126" vertex="1">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="128" value="userID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;whiteSpace=wrap;html=1;" parent="126" vertex="1">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="129" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="125" vertex="1">
|
||||||
|
<mxGeometry y="60" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="130" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="129" vertex="1">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="131" value="role" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="129" vertex="1">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="132" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="125" vertex="1">
|
||||||
|
<mxGeometry y="90" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="133" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="132" vertex="1">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="134" value="Row 2" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="132" vertex="1">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="135" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="125" vertex="1">
|
||||||
|
<mxGeometry y="120" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="136" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" parent="135" vertex="1">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="137" value="Row 3" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" parent="135" vertex="1">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="139" style="edgeStyle=orthogonalEdgeStyle;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;endArrow=none;endFill=0;startArrow=classic;startFill=1;" parent="1" source="71" target="126" edge="1">
|
||||||
|
<mxGeometry relative="1" as="geometry">
|
||||||
|
<Array as="points">
|
||||||
|
<mxPoint x="40" y="285"/>
|
||||||
|
<mxPoint x="40" y="105"/>
|
||||||
|
</Array>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="140" value="Class" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="360" y="850" width="180" height="180" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="141" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" vertex="1" parent="140">
|
||||||
|
<mxGeometry y="30" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="142" value="PK" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="141">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="143" value="ClassID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="141">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="144" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" vertex="1" parent="140">
|
||||||
|
<mxGeometry y="60" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="145" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="144">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="146" value="Name" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="144">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="147" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" vertex="1" parent="140">
|
||||||
|
<mxGeometry y="90" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="148" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="147">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="149" value="Row 1" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="147">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="150" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" vertex="1" parent="140">
|
||||||
|
<mxGeometry y="120" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="151" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="150">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="152" value="Row 2" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="150">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="153" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" vertex="1" parent="140">
|
||||||
|
<mxGeometry y="150" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="154" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="153">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="155" value="Row 3" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="153">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="159" value="ClassGroup" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="100" y="820" width="180" height="180" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="160" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" vertex="1" parent="159">
|
||||||
|
<mxGeometry y="30" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="161" value="PK" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="160">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="162" value="ClassGroupID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="160">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="163" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" vertex="1" parent="159">
|
||||||
|
<mxGeometry y="60" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="164" value="FK" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="163">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="165" value="ClassID" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="163">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="166" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" vertex="1" parent="159">
|
||||||
|
<mxGeometry y="90" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="167" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="166">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="168" value="Row 1" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="166">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="169" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" vertex="1" parent="159">
|
||||||
|
<mxGeometry y="120" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="170" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="169">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="171" value="Row 2" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="169">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="172" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" vertex="1" parent="159">
|
||||||
|
<mxGeometry y="150" width="180" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="173" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="172">
|
||||||
|
<mxGeometry width="30" height="30" as="geometry">
|
||||||
|
<mxRectangle width="30" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="174" value="Row 3" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="172">
|
||||||
|
<mxGeometry x="30" width="150" height="30" as="geometry">
|
||||||
|
<mxRectangle width="150" height="30" as="alternateBounds"/>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="175" style="edgeStyle=orthogonalEdgeStyle;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="141" target="163">
|
||||||
|
<mxGeometry relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="176" style="edgeStyle=orthogonalEdgeStyle;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;startArrow=classic;startFill=1;" edge="1" parent="1" source="160" target="231">
|
||||||
|
<mxGeometry relative="1" as="geometry">
|
||||||
|
<Array as="points">
|
||||||
|
<mxPoint x="40" y="865"/>
|
||||||
|
<mxPoint x="40" y="685"/>
|
||||||
|
</Array>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
</root>
|
||||||
|
</mxGraphModel>
|
||||||
|
</diagram>
|
||||||
|
</mxfile>
|
180
crates/migration/src/baseline.rs
Normal file
180
crates/migration/src/baseline.rs
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
use sea_orm_migration::{prelude::*, schema::*};
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
// Replace the sample below with your own migration scripts
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(Project::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(pk_uuid(Project::Id).extra("DEFAULT gen_random_uuid()"))
|
||||||
|
.col(string(Project::Name))
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(Group::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.primary_key(Index::create().col(Group::Id).col(Group::ProjectId))
|
||||||
|
.col(uuid(Group::Id).extra("DEFAULT gen_random_uuid()"))
|
||||||
|
.col(uuid(Group::ProjectId))
|
||||||
|
.col(string(Group::Name))
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-project-id")
|
||||||
|
.from(Group::Table, Group::ProjectId)
|
||||||
|
.to(Project::Table, Project::Id)
|
||||||
|
.on_update(ForeignKeyAction::Cascade)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(User::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(pk_uuid(User::Id).extra("DEFAULT gen_random_uuid()"))
|
||||||
|
.col(string_uniq(User::Username))
|
||||||
|
.col(string(User::Name))
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(UserGroupProject::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(uuid(UserGroupProject::UserId))
|
||||||
|
.col(uuid(UserGroupProject::GroupId))
|
||||||
|
.col(uuid(UserGroupProject::ProjectId))
|
||||||
|
.primary_key(
|
||||||
|
Index::create()
|
||||||
|
.col(UserGroupProject::UserId)
|
||||||
|
.col(UserGroupProject::GroupId)
|
||||||
|
.col(UserGroupProject::ProjectId),
|
||||||
|
)
|
||||||
|
.index(
|
||||||
|
Index::create()
|
||||||
|
.col(UserGroupProject::UserId)
|
||||||
|
.col(UserGroupProject::ProjectId)
|
||||||
|
.unique(),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-user-id")
|
||||||
|
.from(UserGroupProject::Table, UserGroupProject::UserId)
|
||||||
|
.to(User::Table, User::Id)
|
||||||
|
.on_update(ForeignKeyAction::Cascade)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-project-group-id")
|
||||||
|
.from(
|
||||||
|
UserGroupProject::Table,
|
||||||
|
(UserGroupProject::GroupId, UserGroupProject::ProjectId),
|
||||||
|
)
|
||||||
|
.to(Group::Table, (Group::Id, Group::ProjectId))
|
||||||
|
.on_update(ForeignKeyAction::Cascade)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(LocalAuth::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(pk_uuid(LocalAuth::Id))
|
||||||
|
.col(string(LocalAuth::Hash))
|
||||||
|
.col(boolean(LocalAuth::PasswordChangeRequired).default(true))
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-localauth-user")
|
||||||
|
.from(LocalAuth::Table, LocalAuth::Id)
|
||||||
|
.to(User::Table, User::Id)
|
||||||
|
.on_update(ForeignKeyAction::Cascade)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
// Replace the sample below with your own migration scripts
|
||||||
|
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(Project::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(Group::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(User::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(UserGroupProject::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(LocalAuth::Table).to_owned())
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum Project {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
Name,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum Group {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
ProjectId,
|
||||||
|
Name,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum User {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
Username,
|
||||||
|
Name,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum UserGroupProject {
|
||||||
|
Table,
|
||||||
|
UserId,
|
||||||
|
GroupId,
|
||||||
|
ProjectId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum LocalAuth {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
Hash,
|
||||||
|
PasswordChangeRequired,
|
||||||
|
}
|
12
crates/migration/src/lib.rs
Normal file
12
crates/migration/src/lib.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
pub use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
mod baseline;
|
||||||
|
|
||||||
|
pub struct Migrator;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigratorTrait for Migrator {
|
||||||
|
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||||
|
vec![Box::new(baseline::Migration)]
|
||||||
|
}
|
||||||
|
}
|
6
crates/migration/src/main.rs
Normal file
6
crates/migration/src/main.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
#[async_std::main]
|
||||||
|
async fn main() {
|
||||||
|
cli::run_cli(migration::Migrator).await;
|
||||||
|
}
|
8
crates/xtask/Cargo.toml
Normal file
8
crates/xtask/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "xtask"
|
||||||
|
version = { workspace = true }
|
||||||
|
edition = { workspace = true }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
clap ="*"
|
||||||
|
ctrlc ="*"
|
93
crates/xtask/src/main.rs
Normal file
93
crates/xtask/src/main.rs
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
use std::{
|
||||||
|
env::{current_dir, var_os},
|
||||||
|
path::PathBuf,
|
||||||
|
process,
|
||||||
|
};
|
||||||
|
|
||||||
|
use clap::Command;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let workspace_dir = var_os("CARGO_WORKSPACE_DIR")
|
||||||
|
.map(PathBuf::from)
|
||||||
|
.unwrap_or_else(|| current_dir().unwrap());
|
||||||
|
|
||||||
|
let matches = cli().get_matches();
|
||||||
|
|
||||||
|
match matches.subcommand() {
|
||||||
|
Some(("backend", _)) => {
|
||||||
|
process::Command::new("cargo")
|
||||||
|
.arg("run")
|
||||||
|
.arg("-p")
|
||||||
|
.arg("backend")
|
||||||
|
.current_dir(&workspace_dir)
|
||||||
|
.stdout(process::Stdio::inherit())
|
||||||
|
.stderr(process::Stdio::inherit())
|
||||||
|
.status()
|
||||||
|
.expect("running backend");
|
||||||
|
}
|
||||||
|
Some(("frontend", _)) => {
|
||||||
|
process::Command::new("pnpm")
|
||||||
|
.args(["run", "dev"])
|
||||||
|
.current_dir(workspace_dir.join("web"))
|
||||||
|
.stdout(process::Stdio::inherit())
|
||||||
|
.stderr(process::Stdio::inherit())
|
||||||
|
.status()
|
||||||
|
.expect("Running Frontend dev mode");
|
||||||
|
}
|
||||||
|
Some(("entity", submatches)) => match submatches.subcommand() {
|
||||||
|
Some(("generate", _)) => {
|
||||||
|
process::Command::new("sea-orm-cli")
|
||||||
|
.arg("generate")
|
||||||
|
.arg("entity")
|
||||||
|
.arg("-o")
|
||||||
|
.arg("crates/backend/src/db/entity/")
|
||||||
|
.arg("--with-serde")
|
||||||
|
.arg("both")
|
||||||
|
.current_dir(&workspace_dir)
|
||||||
|
.stdout(process::Stdio::inherit())
|
||||||
|
.stderr(process::Stdio::inherit())
|
||||||
|
.status()
|
||||||
|
.expect("running entity generate");
|
||||||
|
}
|
||||||
|
Some(("clean", _)) => {
|
||||||
|
let dir = workspace_dir.join("crates/backend/src/db/entity");
|
||||||
|
let files = dir.read_dir().expect("Failed to read entity directory");
|
||||||
|
for file in files {
|
||||||
|
let file = file.expect("failed to get file path");
|
||||||
|
if file.file_name() == "lib.rs" {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let file_path = file.path();
|
||||||
|
match std::fs::remove_file(&file_path) {
|
||||||
|
Ok(_) => println!("Removed file {}", file_path.display()),
|
||||||
|
Err(_) => println!("Failed to remove file {}", file_path.display()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
panic!(
|
||||||
|
"Unknown command: entity {:?}",
|
||||||
|
submatches.subcommand().map(|c| c.0)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
panic!("Unknown command: {:?}", matches.subcommand().map(|c| c.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cli() -> Command {
|
||||||
|
Command::new("xtask")
|
||||||
|
.about("docusphere useful commands")
|
||||||
|
.subcommand_required(true)
|
||||||
|
.subcommand(Command::new("backend"))
|
||||||
|
.subcommand(Command::new("frontend"))
|
||||||
|
.subcommand(Command::new("start"))
|
||||||
|
.subcommand(
|
||||||
|
Command::new("entity")
|
||||||
|
.subcommand_required(true)
|
||||||
|
.subcommand(Command::new("generate"))
|
||||||
|
.subcommand(Command::new("clean")),
|
||||||
|
)
|
||||||
|
}
|
79
dev-compose.yml
Normal file
79
dev-compose.yml
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: ${DB_NAME}
|
||||||
|
POSTGRES_USER: ${DB_USER}
|
||||||
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "6379:6379"
|
||||||
|
volumes:
|
||||||
|
- redis:/data
|
||||||
|
|
||||||
|
openldap:
|
||||||
|
image: osixia/openldap:latest
|
||||||
|
container_name: openldap
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
LDAP_ORGANISATION: "Schule"
|
||||||
|
LDAP_DOMAIN: "Schule.intern"
|
||||||
|
LDAP_ADMIN_PASSWORD: ${LDAP_ADMIN_PASSWORD}
|
||||||
|
ports:
|
||||||
|
- "389:389"
|
||||||
|
- "636:636"
|
||||||
|
volumes:
|
||||||
|
- openldap_data:/var/lib/ldap
|
||||||
|
- openldap_config:/etc/ldap/slapd.d
|
||||||
|
# Custom LDAP configuration
|
||||||
|
- ./crates/ldap/src/users.ldif:/container/service/slapd/assets/config/bootstrap/ldif/custom/users.ldif
|
||||||
|
|
||||||
|
healthcheck:
|
||||||
|
test:
|
||||||
|
[
|
||||||
|
"CMD",
|
||||||
|
"ldapsearch",
|
||||||
|
"-x",
|
||||||
|
"-H",
|
||||||
|
"ldap://localhost",
|
||||||
|
"-b",
|
||||||
|
"dc=Schule,dc=intern",
|
||||||
|
]
|
||||||
|
interval: 30s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./backend.Dockerfile
|
||||||
|
image: peer-group-grading:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
DB_NAME: ${DB_NAME}
|
||||||
|
DB_USER: ${DB_USER}
|
||||||
|
DB_PASSWORD: ${DB_PASSWORD}
|
||||||
|
DB_HOST: db
|
||||||
|
DB_PORT: 5432
|
||||||
|
REDIS_HOST: redis
|
||||||
|
REDIS_PORT: 6379
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
- redis
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data:
|
||||||
|
redis:
|
||||||
|
openldap_data:
|
||||||
|
openldap_config:
|
27
flake.lock
generated
Normal file
27
flake.lock
generated
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1742889210,
|
||||||
|
"narHash": "sha256-hw63HnwnqU3ZQfsMclLhMvOezpM7RSB0dMAtD5/sOiw=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "698214a32beb4f4c8e3942372c694f40848b360d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
92
flake.nix
Normal file
92
flake.nix
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
inputs@{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
forSystems = f: nixpkgs.lib.attrsets.genAttrs nixpkgs.lib.systems.flakeExposed (system: f system);
|
||||||
|
pkgs' = system: nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
devShells = forSystems (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
pkgs = pkgs' system;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
packages = with pkgs; [
|
||||||
|
corepack_latest
|
||||||
|
nodejs
|
||||||
|
cargo
|
||||||
|
clippy
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
packages = forSystems (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
pkgs = pkgs' system;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
fmt = pkgs.treefmt.withConfig {
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
nixfmt-rfc-style
|
||||||
|
nodePackages.prettier
|
||||||
|
rustfmt
|
||||||
|
];
|
||||||
|
settings = {
|
||||||
|
tree-root-file = ".git/index";
|
||||||
|
formatter = {
|
||||||
|
nixfmt = {
|
||||||
|
command = "nixfmt";
|
||||||
|
includes = [ "*.nix" ];
|
||||||
|
};
|
||||||
|
rustfmt = {
|
||||||
|
command = "rustfmt";
|
||||||
|
options = [
|
||||||
|
"--edition"
|
||||||
|
"2018"
|
||||||
|
];
|
||||||
|
includes = [ "*.rs" ];
|
||||||
|
};
|
||||||
|
prettier = {
|
||||||
|
command = "prettier";
|
||||||
|
options = [ "--write" ];
|
||||||
|
excludes = [ "pnpm-lock.yaml" ];
|
||||||
|
includes = [
|
||||||
|
"*.css"
|
||||||
|
"*.html"
|
||||||
|
"*.js"
|
||||||
|
"*.json"
|
||||||
|
"*.jsx"
|
||||||
|
"*.md"
|
||||||
|
"*.mdx"
|
||||||
|
"*.scss"
|
||||||
|
"*.ts"
|
||||||
|
"*.yaml"
|
||||||
|
"*.yml"
|
||||||
|
"*.vue"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
formatter = forSystems (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
pkgs = pkgs' system;
|
||||||
|
in
|
||||||
|
self.outputs.packages.${system}.fmt
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
9
frontend/.editorconfig
Normal file
9
frontend/.editorconfig
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue,css,scss,sass,less,styl}]
|
||||||
|
charset = utf-8
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
end_of_line = lf
|
||||||
|
max_line_length = 100
|
1
frontend/.gitattributes
vendored
Normal file
1
frontend/.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
* text=auto eol=lf
|
30
frontend/.gitignore
vendored
Normal file
30
frontend/.gitignore
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
coverage
|
||||||
|
*.local
|
||||||
|
|
||||||
|
/cypress/videos/
|
||||||
|
/cypress/screenshots/
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
|
||||||
|
*.tsbuildinfo
|
6
frontend/.prettierrc.json
Normal file
6
frontend/.prettierrc.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/prettierrc",
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 100
|
||||||
|
}
|
9
frontend/.vscode/extensions.json
vendored
Normal file
9
frontend/.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"Vue.volar",
|
||||||
|
"vitest.explorer",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"EditorConfig.EditorConfig",
|
||||||
|
"esbenp.prettier-vscode"
|
||||||
|
]
|
||||||
|
}
|
45
frontend/README.md
Normal file
45
frontend/README.md
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# frontend
|
||||||
|
|
||||||
|
This template should help get you started developing with Vue 3 in Vite.
|
||||||
|
|
||||||
|
## Recommended IDE Setup
|
||||||
|
|
||||||
|
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
|
||||||
|
|
||||||
|
## Type Support for `.vue` Imports in TS
|
||||||
|
|
||||||
|
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
|
||||||
|
|
||||||
|
## Customize configuration
|
||||||
|
|
||||||
|
See [Vite Configuration Reference](https://vite.dev/config/).
|
||||||
|
|
||||||
|
## Project Setup
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compile and Hot-Reload for Development
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Type-Check, Compile and Minify for Production
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Unit Tests with [Vitest](https://vitest.dev/)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm test:unit
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lint with [ESLint](https://eslint.org/)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm lint
|
||||||
|
```
|
1
frontend/env.d.ts
vendored
Normal file
1
frontend/env.d.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/// <reference types="vite/client" />
|
30
frontend/eslint.config.ts
Normal file
30
frontend/eslint.config.ts
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import pluginVue from 'eslint-plugin-vue'
|
||||||
|
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
|
||||||
|
import pluginVitest from '@vitest/eslint-plugin'
|
||||||
|
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
|
||||||
|
|
||||||
|
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
|
||||||
|
// import { configureVueProject } from '@vue/eslint-config-typescript'
|
||||||
|
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
|
||||||
|
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
|
||||||
|
|
||||||
|
export default defineConfigWithVueTs(
|
||||||
|
{
|
||||||
|
name: 'app/files-to-lint',
|
||||||
|
files: ['**/*.{ts,mts,tsx,vue}'],
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'app/files-to-ignore',
|
||||||
|
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
|
||||||
|
},
|
||||||
|
|
||||||
|
pluginVue.configs['flat/essential'],
|
||||||
|
vueTsConfigs.recommended,
|
||||||
|
|
||||||
|
{
|
||||||
|
...pluginVitest.configs.recommended,
|
||||||
|
files: ['src/**/__tests__/*'],
|
||||||
|
},
|
||||||
|
skipFormatting,
|
||||||
|
)
|
13
frontend/index.html
Normal file
13
frontend/index.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" href="/favicon.ico" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Vite App</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
49
frontend/package.json
Normal file
49
frontend/package.json
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{
|
||||||
|
"name": "frontend",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "run-p type-check \"build-only {@}\" --",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"test:unit": "vitest",
|
||||||
|
"build-only": "vite build",
|
||||||
|
"type-check": "vue-tsc --build",
|
||||||
|
"lint": "eslint . --fix",
|
||||||
|
"format": "prettier --write src/"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@primeuix/themes": "^1.0.1",
|
||||||
|
"@primevue/forms": "^4.3.3",
|
||||||
|
"lucide-vue-next": "^0.487.0",
|
||||||
|
"pinia": "^3.0.1",
|
||||||
|
"primevue": "^4.3.3",
|
||||||
|
"vue": "^3.5.13",
|
||||||
|
"vue-router": "^4.5.0",
|
||||||
|
"zod": "^3.24.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tsconfig/node22": "^22.0.0",
|
||||||
|
"@types/jsdom": "^21.1.7",
|
||||||
|
"@types/node": "^22.13.9",
|
||||||
|
"@vitejs/plugin-vue": "^5.2.1",
|
||||||
|
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
||||||
|
"@vitest/eslint-plugin": "^1.1.36",
|
||||||
|
"@vue/eslint-config-prettier": "^10.2.0",
|
||||||
|
"@vue/eslint-config-typescript": "^14.5.0",
|
||||||
|
"@vue/test-utils": "^2.4.6",
|
||||||
|
"@vue/tsconfig": "^0.7.0",
|
||||||
|
"eslint": "^9.21.0",
|
||||||
|
"eslint-plugin-vue": "~10.0.0",
|
||||||
|
"jiti": "^2.4.2",
|
||||||
|
"jsdom": "^26.0.0",
|
||||||
|
"npm-run-all2": "^7.0.2",
|
||||||
|
"prettier": "3.5.3",
|
||||||
|
"typescript": "~5.8.0",
|
||||||
|
"vite": "^6.2.1",
|
||||||
|
"vite-plugin-vue-devtools": "^7.7.2",
|
||||||
|
"vitest": "^3.0.8",
|
||||||
|
"vue-tsc": "^2.2.8"
|
||||||
|
}
|
||||||
|
}
|
BIN
frontend/public/favicon.ico
Normal file
BIN
frontend/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
28
frontend/src/App.vue
Normal file
28
frontend/src/App.vue
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import HeaderNav from './components/HeaderNav.vue'
|
||||||
|
import SideBar from './components/SideBar.vue'
|
||||||
|
import { RouterLink, RouterView } from 'vue-router'
|
||||||
|
|
||||||
|
const isTeacher = ref(true)
|
||||||
|
const isLoggedIn = ref(true)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="sticky top-0">
|
||||||
|
<header>
|
||||||
|
<HeaderNav :isLoggedIn="isLoggedIn" :isTeacher="isTeacher">
|
||||||
|
<template #left-icon>
|
||||||
|
<BoltIcon class="icon" />
|
||||||
|
<!--Hier dann ein richtiges Logo rein-->
|
||||||
|
</template>
|
||||||
|
</HeaderNav>
|
||||||
|
</header>
|
||||||
|
</div>
|
||||||
|
<SideBar :isLoggedIn="isLoggedIn" :isTeacher="isTeacher" />
|
||||||
|
<div>
|
||||||
|
<RouterView />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
86
frontend/src/assets/base.css
Normal file
86
frontend/src/assets/base.css
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
/* color palette from <https://github.com/vuejs/theme> */
|
||||||
|
:root {
|
||||||
|
--vt-c-white: #ffffff;
|
||||||
|
--vt-c-white-soft: #f8f8f8;
|
||||||
|
--vt-c-white-mute: #f2f2f2;
|
||||||
|
|
||||||
|
--vt-c-black: #181818;
|
||||||
|
--vt-c-black-soft: #222222;
|
||||||
|
--vt-c-black-mute: #282828;
|
||||||
|
|
||||||
|
--vt-c-indigo: #2c3e50;
|
||||||
|
|
||||||
|
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
|
||||||
|
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
|
||||||
|
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
|
||||||
|
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
|
||||||
|
|
||||||
|
--vt-c-text-light-1: var(--vt-c-indigo);
|
||||||
|
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
|
||||||
|
--vt-c-text-dark-1: var(--vt-c-white);
|
||||||
|
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* semantic color variables for this project */
|
||||||
|
:root {
|
||||||
|
--color-background: var(--vt-c-white);
|
||||||
|
--color-background-soft: var(--vt-c-white-soft);
|
||||||
|
--color-background-mute: var(--vt-c-white-mute);
|
||||||
|
|
||||||
|
--color-border: var(--vt-c-divider-light-2);
|
||||||
|
--color-border-hover: var(--vt-c-divider-light-1);
|
||||||
|
|
||||||
|
--color-heading: var(--vt-c-text-light-1);
|
||||||
|
--color-text: var(--vt-c-text-light-1);
|
||||||
|
|
||||||
|
--section-gap: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--color-background: var(--vt-c-black);
|
||||||
|
--color-background-soft: var(--vt-c-black-soft);
|
||||||
|
--color-background-mute: var(--vt-c-black-mute);
|
||||||
|
|
||||||
|
--color-border: var(--vt-c-divider-dark-2);
|
||||||
|
--color-border-hover: var(--vt-c-divider-dark-1);
|
||||||
|
|
||||||
|
--color-heading: var(--vt-c-text-dark-1);
|
||||||
|
--color-text: var(--vt-c-text-dark-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
min-height: 100vh;
|
||||||
|
color: var(--color-text);
|
||||||
|
background: var(--color-background);
|
||||||
|
transition:
|
||||||
|
color 0.5s,
|
||||||
|
background-color 0.5s;
|
||||||
|
line-height: 1.6;
|
||||||
|
font-family:
|
||||||
|
Inter,
|
||||||
|
-apple-system,
|
||||||
|
BlinkMacSystemFont,
|
||||||
|
'Segoe UI',
|
||||||
|
Roboto,
|
||||||
|
Oxygen,
|
||||||
|
Ubuntu,
|
||||||
|
Cantarell,
|
||||||
|
'Fira Sans',
|
||||||
|
'Droid Sans',
|
||||||
|
'Helvetica Neue',
|
||||||
|
sans-serif;
|
||||||
|
font-size: 15px;
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
1
frontend/src/assets/logo.svg
Normal file
1
frontend/src/assets/logo.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>
|
After Width: | Height: | Size: 276 B |
20
frontend/src/assets/main.css
Normal file
20
frontend/src/assets/main.css
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
@import './base.css';
|
||||||
|
|
||||||
|
#app {
|
||||||
|
margin-left: 325px;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a,
|
||||||
|
.green {
|
||||||
|
text-decoration: none;
|
||||||
|
color: hsla(160, 100%, 37%, 1);
|
||||||
|
transition: 0.4s;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (hover: hover) {
|
||||||
|
a:hover {
|
||||||
|
background-color: hsla(160, 100%, 37%, 0.2);
|
||||||
|
}
|
||||||
|
}
|
64
frontend/src/components/HeaderNav.vue
Normal file
64
frontend/src/components/HeaderNav.vue
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { LogInIcon, LogOutIcon, BoltIcon } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
isLoggedIn: boolean
|
||||||
|
isTeacher: boolean
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<nav class="header-container">
|
||||||
|
<div class="left-icon">
|
||||||
|
<!-- Platzhalter für ein Icon -->
|
||||||
|
<slot name="left-icon"></slot>
|
||||||
|
</div>
|
||||||
|
<div class="nav-items">
|
||||||
|
<button v-if="!isLoggedIn" class="nav-button">
|
||||||
|
<component :is="LogInIcon" class="icon" />
|
||||||
|
Login
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<button class="nav-button">
|
||||||
|
<component :is="LogOutIcon" class="icon" />
|
||||||
|
Logout
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button v-if="isTeacher" class="nav-button">
|
||||||
|
<component :is="BoltIcon" class="icon" />
|
||||||
|
Lehrerverwaltung
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.header-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-items {
|
||||||
|
display: flex;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
width: 1rem;
|
||||||
|
height: 1rem;
|
||||||
|
}
|
||||||
|
</style>
|
41
frontend/src/components/HelloWorld.vue
Normal file
41
frontend/src/components/HelloWorld.vue
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
defineProps<{
|
||||||
|
msg: string
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="greetings">
|
||||||
|
<h1 class="green">{{ msg }}</h1>
|
||||||
|
<h3>
|
||||||
|
You’ve successfully created a project with
|
||||||
|
<a href="https://vite.dev/" target="_blank" rel="noopener">Vite</a> +
|
||||||
|
<a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>. What's next?
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
h1 {
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 2.6rem;
|
||||||
|
position: relative;
|
||||||
|
top: -10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.greetings h1,
|
||||||
|
.greetings h3 {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.greetings h1,
|
||||||
|
.greetings h3 {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
80
frontend/src/components/MenuBar.vue
Normal file
80
frontend/src/components/MenuBar.vue
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
<template>
|
||||||
|
<div class="card">
|
||||||
|
<Menubar :model="items">
|
||||||
|
<template #item="{ item, props, hasSubmenu }">
|
||||||
|
<router-link v-if="item.route" v-slot="{ href, navigate }" :to="item.route" custom>
|
||||||
|
<a v-ripple :href="href" v-bind="props.action" @click="navigate">
|
||||||
|
<span :class="item.icon" />
|
||||||
|
<span>{{ item.label }}</span>
|
||||||
|
</a>
|
||||||
|
</router-link>
|
||||||
|
<a v-else v-ripple :href="item.url" :target="item.target" v-bind="props.action">
|
||||||
|
<span :class="item.icon" />
|
||||||
|
<span> n/A {{ item.label }}</span>
|
||||||
|
<span v-if="hasSubmenu" class="pi pi-fw pi-angle-down" />
|
||||||
|
</a>
|
||||||
|
</template>
|
||||||
|
</Menubar>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import Menubar from 'primevue/menubar';
|
||||||
|
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
const items = ref([
|
||||||
|
{
|
||||||
|
label: 'Home',
|
||||||
|
icon: 'pi pi-home',
|
||||||
|
route: '/'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Student',
|
||||||
|
icon: 'pi pi-graduation-cap',
|
||||||
|
route: '/Student'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Login',
|
||||||
|
icon: 'pi pi-graduation-cap',
|
||||||
|
route: '/Login'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Projects',
|
||||||
|
icon: 'pi pi-search',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label: 'Components',
|
||||||
|
icon: 'pi pi-bolt'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Blocks',
|
||||||
|
icon: 'pi pi-server'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'UI Kit',
|
||||||
|
icon: 'pi pi-pencil'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Templates',
|
||||||
|
icon: 'pi pi-palette',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label: 'Apollo',
|
||||||
|
icon: 'pi pi-palette'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Ultima',
|
||||||
|
icon: 'pi pi-palette'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Contact',
|
||||||
|
icon: 'pi pi-envelope'
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
</script>
|
54
frontend/src/components/SideBar.vue
Normal file
54
frontend/src/components/SideBar.vue
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import Drawer from 'primevue/drawer'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { useClassStore } from '@/stores/classStore'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
|
const store = useClassStore()
|
||||||
|
|
||||||
|
store.loadClasses()
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
isLoggedIn: boolean
|
||||||
|
isTeacher: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
|
var elements = store.classInfoList
|
||||||
|
var visible = ref(true)
|
||||||
|
var closeIcon = ref(false)
|
||||||
|
|
||||||
|
function setClass(input: number) {
|
||||||
|
store.setActiveClass(input)
|
||||||
|
router.push({ name: 'about' })
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Drawer
|
||||||
|
v-model:visible="visible"
|
||||||
|
:showCloseIcon="closeIcon"
|
||||||
|
:modal="false"
|
||||||
|
:dismissable="false"
|
||||||
|
v-on:hide="visible = true"
|
||||||
|
header="Sidebar"
|
||||||
|
v-if="isLoggedIn"
|
||||||
|
>
|
||||||
|
<div v-if="isTeacher">
|
||||||
|
<ul>
|
||||||
|
<li v-for="item in elements">
|
||||||
|
<p href="/about" @click="setClass(item.id)">{{ item.name }}</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<p href="/about">Offene/Abgegebene Evaluaionsbögen</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p href="/about">Notenübersicht</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</Drawer>
|
||||||
|
</template>
|
94
frontend/src/components/TheWelcome.vue
Normal file
94
frontend/src/components/TheWelcome.vue
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import WelcomeItem from './WelcomeItem.vue'
|
||||||
|
import DocumentationIcon from './icons/IconDocumentation.vue'
|
||||||
|
import ToolingIcon from './icons/IconTooling.vue'
|
||||||
|
import EcosystemIcon from './icons/IconEcosystem.vue'
|
||||||
|
import CommunityIcon from './icons/IconCommunity.vue'
|
||||||
|
import SupportIcon from './icons/IconSupport.vue'
|
||||||
|
|
||||||
|
const openReadmeInEditor = () => fetch('/__open-in-editor?file=README.md')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<WelcomeItem>
|
||||||
|
<template #icon>
|
||||||
|
<DocumentationIcon />
|
||||||
|
</template>
|
||||||
|
<template #heading>Documentation</template>
|
||||||
|
|
||||||
|
Vue’s
|
||||||
|
<a href="https://vuejs.org/" target="_blank" rel="noopener">official documentation</a>
|
||||||
|
provides you with all information you need to get started.
|
||||||
|
</WelcomeItem>
|
||||||
|
|
||||||
|
<WelcomeItem>
|
||||||
|
<template #icon>
|
||||||
|
<ToolingIcon />
|
||||||
|
</template>
|
||||||
|
<template #heading>Tooling</template>
|
||||||
|
|
||||||
|
This project is served and bundled with
|
||||||
|
<a href="https://vite.dev/guide/features.html" target="_blank" rel="noopener">Vite</a>. The
|
||||||
|
recommended IDE setup is
|
||||||
|
<a href="https://code.visualstudio.com/" target="_blank" rel="noopener">VSCode</a>
|
||||||
|
+
|
||||||
|
<a href="https://github.com/johnsoncodehk/volar" target="_blank" rel="noopener">Volar</a>. If
|
||||||
|
you need to test your components and web pages, check out
|
||||||
|
<a href="https://vitest.dev/" target="_blank" rel="noopener">Vitest</a>
|
||||||
|
and
|
||||||
|
<a href="https://www.cypress.io/" target="_blank" rel="noopener">Cypress</a>
|
||||||
|
/
|
||||||
|
<a href="https://playwright.dev/" target="_blank" rel="noopener">Playwright</a>.
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
More instructions are available in
|
||||||
|
<a href="javascript:void(0)" @click="openReadmeInEditor"><code>README.md</code></a
|
||||||
|
>.
|
||||||
|
</WelcomeItem>
|
||||||
|
|
||||||
|
<WelcomeItem>
|
||||||
|
<template #icon>
|
||||||
|
<EcosystemIcon />
|
||||||
|
</template>
|
||||||
|
<template #heading>Ecosystem</template>
|
||||||
|
|
||||||
|
Get official tools and libraries for your project:
|
||||||
|
<a href="https://pinia.vuejs.org/" target="_blank" rel="noopener">Pinia</a>,
|
||||||
|
<a href="https://router.vuejs.org/" target="_blank" rel="noopener">Vue Router</a>,
|
||||||
|
<a href="https://test-utils.vuejs.org/" target="_blank" rel="noopener">Vue Test Utils</a>, and
|
||||||
|
<a href="https://github.com/vuejs/devtools" target="_blank" rel="noopener">Vue Dev Tools</a>. If
|
||||||
|
you need more resources, we suggest paying
|
||||||
|
<a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">Awesome Vue</a>
|
||||||
|
a visit.
|
||||||
|
</WelcomeItem>
|
||||||
|
|
||||||
|
<WelcomeItem>
|
||||||
|
<template #icon>
|
||||||
|
<CommunityIcon />
|
||||||
|
</template>
|
||||||
|
<template #heading>Community</template>
|
||||||
|
|
||||||
|
Got stuck? Ask your question on
|
||||||
|
<a href="https://chat.vuejs.org" target="_blank" rel="noopener">Vue Land</a>
|
||||||
|
(our official Discord server), or
|
||||||
|
<a href="https://stackoverflow.com/questions/tagged/vue.js" target="_blank" rel="noopener"
|
||||||
|
>StackOverflow</a
|
||||||
|
>. You should also follow the official
|
||||||
|
<a href="https://bsky.app/profile/vuejs.org" target="_blank" rel="noopener">@vuejs.org</a>
|
||||||
|
Bluesky account or the
|
||||||
|
<a href="https://x.com/vuejs" target="_blank" rel="noopener">@vuejs</a>
|
||||||
|
X account for latest news in the Vue world.
|
||||||
|
</WelcomeItem>
|
||||||
|
|
||||||
|
<WelcomeItem>
|
||||||
|
<template #icon>
|
||||||
|
<SupportIcon />
|
||||||
|
</template>
|
||||||
|
<template #heading>Support Vue</template>
|
||||||
|
|
||||||
|
As an independent project, Vue relies on community backing for its sustainability. You can help
|
||||||
|
us by
|
||||||
|
<a href="https://vuejs.org/sponsor/" target="_blank" rel="noopener">becoming a sponsor</a>.
|
||||||
|
</WelcomeItem>
|
||||||
|
</template>
|
87
frontend/src/components/WelcomeItem.vue
Normal file
87
frontend/src/components/WelcomeItem.vue
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
<template>
|
||||||
|
<div class="item">
|
||||||
|
<i>
|
||||||
|
<slot name="icon"></slot>
|
||||||
|
</i>
|
||||||
|
<div class="details">
|
||||||
|
<h3>
|
||||||
|
<slot name="heading"></slot>
|
||||||
|
</h3>
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.item {
|
||||||
|
margin-top: 2rem;
|
||||||
|
display: flex;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details {
|
||||||
|
flex: 1;
|
||||||
|
margin-left: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
i {
|
||||||
|
display: flex;
|
||||||
|
place-items: center;
|
||||||
|
place-content: center;
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
|
||||||
|
color: var(--color-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-bottom: 0.4rem;
|
||||||
|
color: var(--color-heading);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.item {
|
||||||
|
margin-top: 0;
|
||||||
|
padding: 0.4rem 0 1rem calc(var(--section-gap) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
i {
|
||||||
|
top: calc(50% - 25px);
|
||||||
|
left: -26px;
|
||||||
|
position: absolute;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
background: var(--color-background);
|
||||||
|
border-radius: 8px;
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item:before {
|
||||||
|
content: ' ';
|
||||||
|
border-left: 1px solid var(--color-border);
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
bottom: calc(50% + 25px);
|
||||||
|
height: calc(50% - 25px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.item:after {
|
||||||
|
content: ' ';
|
||||||
|
border-left: 1px solid var(--color-border);
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: calc(50% + 25px);
|
||||||
|
height: calc(50% - 25px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.item:first-of-type:before {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item:last-of-type:after {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
11
frontend/src/components/__tests__/HelloWorld.spec.ts
Normal file
11
frontend/src/components/__tests__/HelloWorld.spec.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { describe, it, expect } from 'vitest'
|
||||||
|
|
||||||
|
import { mount } from '@vue/test-utils'
|
||||||
|
import HelloWorld from '../HelloWorld.vue'
|
||||||
|
|
||||||
|
describe('HelloWorld', () => {
|
||||||
|
it('renders properly', () => {
|
||||||
|
const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } })
|
||||||
|
expect(wrapper.text()).toContain('Hello Vitest')
|
||||||
|
})
|
||||||
|
})
|
7
frontend/src/components/icons/IconCommunity.vue
Normal file
7
frontend/src/components/icons/IconCommunity.vue
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<template>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
|
||||||
|
<path
|
||||||
|
d="M15 4a1 1 0 1 0 0 2V4zm0 11v-1a1 1 0 0 0-1 1h1zm0 4l-.707.707A1 1 0 0 0 16 19h-1zm-4-4l.707-.707A1 1 0 0 0 11 14v1zm-4.707-1.293a1 1 0 0 0-1.414 1.414l1.414-1.414zm-.707.707l-.707-.707.707.707zM9 11v-1a1 1 0 0 0-.707.293L9 11zm-4 0h1a1 1 0 0 0-1-1v1zm0 4H4a1 1 0 0 0 1.707.707L5 15zm10-9h2V4h-2v2zm2 0a1 1 0 0 1 1 1h2a3 3 0 0 0-3-3v2zm1 1v6h2V7h-2zm0 6a1 1 0 0 1-1 1v2a3 3 0 0 0 3-3h-2zm-1 1h-2v2h2v-2zm-3 1v4h2v-4h-2zm1.707 3.293l-4-4-1.414 1.414 4 4 1.414-1.414zM11 14H7v2h4v-2zm-4 0c-.276 0-.525-.111-.707-.293l-1.414 1.414C5.42 15.663 6.172 16 7 16v-2zm-.707 1.121l3.414-3.414-1.414-1.414-3.414 3.414 1.414 1.414zM9 12h4v-2H9v2zm4 0a3 3 0 0 0 3-3h-2a1 1 0 0 1-1 1v2zm3-3V3h-2v6h2zm0-6a3 3 0 0 0-3-3v2a1 1 0 0 1 1 1h2zm-3-3H3v2h10V0zM3 0a3 3 0 0 0-3 3h2a1 1 0 0 1 1-1V0zM0 3v6h2V3H0zm0 6a3 3 0 0 0 3 3v-2a1 1 0 0 1-1-1H0zm3 3h2v-2H3v2zm1-1v4h2v-4H4zm1.707 4.707l.586-.586-1.414-1.414-.586.586 1.414 1.414z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</template>
|
7
frontend/src/components/icons/IconDocumentation.vue
Normal file
7
frontend/src/components/icons/IconDocumentation.vue
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<template>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" fill="currentColor">
|
||||||
|
<path
|
||||||
|
d="M11 2.253a1 1 0 1 0-2 0h2zm-2 13a1 1 0 1 0 2 0H9zm.447-12.167a1 1 0 1 0 1.107-1.666L9.447 3.086zM1 2.253L.447 1.42A1 1 0 0 0 0 2.253h1zm0 13H0a1 1 0 0 0 1.553.833L1 15.253zm8.447.833a1 1 0 1 0 1.107-1.666l-1.107 1.666zm0-14.666a1 1 0 1 0 1.107 1.666L9.447 1.42zM19 2.253h1a1 1 0 0 0-.447-.833L19 2.253zm0 13l-.553.833A1 1 0 0 0 20 15.253h-1zm-9.553-.833a1 1 0 1 0 1.107 1.666L9.447 14.42zM9 2.253v13h2v-13H9zm1.553-.833C9.203.523 7.42 0 5.5 0v2c1.572 0 2.961.431 3.947 1.086l1.107-1.666zM5.5 0C3.58 0 1.797.523.447 1.42l1.107 1.666C2.539 2.431 3.928 2 5.5 2V0zM0 2.253v13h2v-13H0zm1.553 13.833C2.539 15.431 3.928 15 5.5 15v-2c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM5.5 15c1.572 0 2.961.431 3.947 1.086l1.107-1.666C9.203 13.523 7.42 13 5.5 13v2zm5.053-11.914C11.539 2.431 12.928 2 14.5 2V0c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM14.5 2c1.573 0 2.961.431 3.947 1.086l1.107-1.666C18.203.523 16.421 0 14.5 0v2zm3.5.253v13h2v-13h-2zm1.553 12.167C18.203 13.523 16.421 13 14.5 13v2c1.573 0 2.961.431 3.947 1.086l1.107-1.666zM14.5 13c-1.92 0-3.703.523-5.053 1.42l1.107 1.666C11.539 15.431 12.928 15 14.5 15v-2z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</template>
|
7
frontend/src/components/icons/IconEcosystem.vue
Normal file
7
frontend/src/components/icons/IconEcosystem.vue
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<template>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="20" fill="currentColor">
|
||||||
|
<path
|
||||||
|
d="M11.447 8.894a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm0 1.789a1 1 0 1 0 .894-1.789l-.894 1.789zM7.447 7.106a1 1 0 1 0-.894 1.789l.894-1.789zM10 9a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0H8zm9.447-5.606a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm2 .789a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zM18 5a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0h-2zm-5.447-4.606a1 1 0 1 0 .894-1.789l-.894 1.789zM9 1l.447-.894a1 1 0 0 0-.894 0L9 1zm-2.447.106a1 1 0 1 0 .894 1.789l-.894-1.789zm-6 3a1 1 0 1 0 .894 1.789L.553 4.106zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zm-2-.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 2.789a1 1 0 1 0 .894-1.789l-.894 1.789zM2 5a1 1 0 1 0-2 0h2zM0 7.5a1 1 0 1 0 2 0H0zm8.553 12.394a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 1a1 1 0 1 0 .894 1.789l-.894-1.789zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zM8 19a1 1 0 1 0 2 0H8zm2-2.5a1 1 0 1 0-2 0h2zm-7.447.394a1 1 0 1 0 .894-1.789l-.894 1.789zM1 15H0a1 1 0 0 0 .553.894L1 15zm1-2.5a1 1 0 1 0-2 0h2zm12.553 2.606a1 1 0 1 0 .894 1.789l-.894-1.789zM17 15l.447.894A1 1 0 0 0 18 15h-1zm1-2.5a1 1 0 1 0-2 0h2zm-7.447-5.394l-2 1 .894 1.789 2-1-.894-1.789zm-1.106 1l-2-1-.894 1.789 2 1 .894-1.789zM8 9v2.5h2V9H8zm8.553-4.894l-2 1 .894 1.789 2-1-.894-1.789zm.894 0l-2-1-.894 1.789 2 1 .894-1.789zM16 5v2.5h2V5h-2zm-4.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zm-2.894-1l-2 1 .894 1.789 2-1L8.553.106zM1.447 5.894l2-1-.894-1.789-2 1 .894 1.789zm-.894 0l2 1 .894-1.789-2-1-.894 1.789zM0 5v2.5h2V5H0zm9.447 13.106l-2-1-.894 1.789 2 1 .894-1.789zm0 1.789l2-1-.894-1.789-2 1 .894 1.789zM10 19v-2.5H8V19h2zm-6.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zM2 15v-2.5H0V15h2zm13.447 1.894l2-1-.894-1.789-2 1 .894 1.789zM18 15v-2.5h-2V15h2z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</template>
|
7
frontend/src/components/icons/IconSupport.vue
Normal file
7
frontend/src/components/icons/IconSupport.vue
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<template>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
|
||||||
|
<path
|
||||||
|
d="M10 3.22l-.61-.6a5.5 5.5 0 0 0-7.666.105 5.5 5.5 0 0 0-.114 7.665L10 18.78l8.39-8.4a5.5 5.5 0 0 0-.114-7.665 5.5 5.5 0 0 0-7.666-.105l-.61.61z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</template>
|
19
frontend/src/components/icons/IconTooling.vue
Normal file
19
frontend/src/components/icons/IconTooling.vue
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<!-- This icon is from <https://github.com/Templarian/MaterialDesign>, distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license-->
|
||||||
|
<template>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
aria-hidden="true"
|
||||||
|
role="img"
|
||||||
|
class="iconify iconify--mdi"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
preserveAspectRatio="xMidYMid meet"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M20 18v-4h-3v1h-2v-1H9v1H7v-1H4v4h16M6.33 8l-1.74 4H7v-1h2v1h6v-1h2v1h2.41l-1.74-4H6.33M9 5v1h6V5H9m12.84 7.61c.1.22.16.48.16.8V18c0 .53-.21 1-.6 1.41c-.4.4-.85.59-1.4.59H4c-.55 0-1-.19-1.4-.59C2.21 19 2 18.53 2 18v-4.59c0-.32.06-.58.16-.8L4.5 7.22C4.84 6.41 5.45 6 6.33 6H7V5c0-.55.18-1 .57-1.41C7.96 3.2 8.44 3 9 3h6c.56 0 1.04.2 1.43.59c.39.41.57.86.57 1.41v1h.67c.88 0 1.49.41 1.83 1.22l2.34 5.39z"
|
||||||
|
fill="currentColor"
|
||||||
|
></path>
|
||||||
|
</svg>
|
||||||
|
</template>
|
26
frontend/src/main.ts
Normal file
26
frontend/src/main.ts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import './assets/main.css'
|
||||||
|
|
||||||
|
import { createApp } from 'vue'
|
||||||
|
import { createPinia } from 'pinia'
|
||||||
|
import PrimeVue from 'primevue/config'
|
||||||
|
import Aura from '@primeuix/themes/aura'
|
||||||
|
import Ripple from 'primevue/ripple'
|
||||||
|
import ToastService from 'primevue/toastservice';
|
||||||
|
import App from './App.vue'
|
||||||
|
import router from './router'
|
||||||
|
|
||||||
|
const app = createApp(App)
|
||||||
|
const pinia = createPinia()
|
||||||
|
|
||||||
|
app.use(PrimeVue, {
|
||||||
|
theme: {
|
||||||
|
preset: Aura,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
app.use(pinia)
|
||||||
|
app.use(ToastService);
|
||||||
|
app.use(createPinia())
|
||||||
|
app.use(router)
|
||||||
|
app.directive('ripple', Ripple)
|
||||||
|
|
||||||
|
app.mount('#app')
|
35
frontend/src/router/index.ts
Normal file
35
frontend/src/router/index.ts
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
|
import TeacherView from '../views/TeacherView.vue'
|
||||||
|
|
||||||
|
const router = createRouter({
|
||||||
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
path: '/',
|
||||||
|
name: 'teacher',
|
||||||
|
component: TeacherView,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/about',
|
||||||
|
name: 'about',
|
||||||
|
// route level code-splitting
|
||||||
|
// this generates a separate chunk (About.[hash].js) for this route
|
||||||
|
// which is lazy-loaded when the route is visited.
|
||||||
|
component: () => import('../views/AboutView.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/Student',
|
||||||
|
name: 'Student',
|
||||||
|
|
||||||
|
component: () => import('../views/StudentView.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/Login',
|
||||||
|
name: 'Login',
|
||||||
|
|
||||||
|
component: () => import('../views/LoginView.vue'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
39
frontend/src/stores/classStore.ts
Normal file
39
frontend/src/stores/classStore.ts
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
import { ref, computed } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
interface State {
|
||||||
|
classInfoList: ClassInfo[]
|
||||||
|
classInfo: ClassInfo | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useClassStore = defineStore('class', {
|
||||||
|
state: (): State => {
|
||||||
|
return {
|
||||||
|
classInfoList: [],
|
||||||
|
classInfo: null,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
loadClasses() {
|
||||||
|
/* Beispieldaten */
|
||||||
|
if (this.classInfoList.length < 1) {
|
||||||
|
this.classInfoList.push({ name: 'Steve', id: 1 })
|
||||||
|
this.classInfoList.push({ name: 'Garett', id: 2 })
|
||||||
|
this.classInfoList.push({ name: 'Natalie', id: 3 })
|
||||||
|
this.classInfoList.push({ name: 'Henry', id: 4 })
|
||||||
|
this.classInfoList.push({ name: 'Dawn', id: 5 })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setActiveClass(id: number) {
|
||||||
|
this.classInfoList.map((item) => {
|
||||||
|
if (item.id == id) {
|
||||||
|
this.classInfo = item
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
interface ClassInfo {
|
||||||
|
name: string
|
||||||
|
id: number
|
||||||
|
}
|
12
frontend/src/stores/counter.ts
Normal file
12
frontend/src/stores/counter.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { ref, computed } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const useCounterStore = defineStore('counter', () => {
|
||||||
|
const count = ref(0)
|
||||||
|
const doubleCount = computed(() => count.value * 2)
|
||||||
|
function increment() {
|
||||||
|
count.value++
|
||||||
|
}
|
||||||
|
|
||||||
|
return { count, doubleCount, increment }
|
||||||
|
})
|
46
frontend/src/views/AboutView.vue
Normal file
46
frontend/src/views/AboutView.vue
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import Button from 'primevue/button'
|
||||||
|
import { useClassStore } from '@/stores/classStore'
|
||||||
|
import Accordion from 'primevue/accordion'
|
||||||
|
import AccordionPanel from 'primevue/accordionpanel'
|
||||||
|
import AccordionHeader from 'primevue/accordionheader'
|
||||||
|
import AccordionContent from 'primevue/accordioncontent'
|
||||||
|
|
||||||
|
const store = useClassStore()
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div class="about">
|
||||||
|
<h1>{{ store.classInfo?.name }}</h1>
|
||||||
|
<Accordion value="0">
|
||||||
|
<AccordionPanel value="0">
|
||||||
|
<AccordionHeader>Lernfeld I</AccordionHeader>
|
||||||
|
<AccordionContent>
|
||||||
|
<Button>FE</Button>
|
||||||
|
<Button>LF</Button>
|
||||||
|
<Button>SuK</Button>
|
||||||
|
<Button>Wug</Button>
|
||||||
|
</AccordionContent>
|
||||||
|
</AccordionPanel>
|
||||||
|
<AccordionPanel value="1">
|
||||||
|
<AccordionHeader>Lernfeld II</AccordionHeader>
|
||||||
|
<AccordionContent>
|
||||||
|
<Button>FE</Button>
|
||||||
|
<Button>LF</Button>
|
||||||
|
<Button>SuK</Button>
|
||||||
|
<Button>Wug</Button>
|
||||||
|
</AccordionContent>
|
||||||
|
</AccordionPanel>
|
||||||
|
<AccordionPanel value="2">
|
||||||
|
<AccordionHeader>Lernfeld III</AccordionHeader>
|
||||||
|
<AccordionContent>
|
||||||
|
<Button>FE</Button>
|
||||||
|
<Button>LF</Button>
|
||||||
|
<Button>SuK</Button>
|
||||||
|
<Button>Wug</Button>
|
||||||
|
</AccordionContent>
|
||||||
|
</AccordionPanel>
|
||||||
|
</Accordion>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style></style>
|
76
frontend/src/views/LoginView.vue
Normal file
76
frontend/src/views/LoginView.vue
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
<script setup>
|
||||||
|
import InputText from 'primevue/inputtext'
|
||||||
|
import Button from 'primevue/button'
|
||||||
|
import Message from 'primevue/message'
|
||||||
|
import Password from 'primevue/password'
|
||||||
|
import Checkbox from 'primevue/checkbox'
|
||||||
|
|
||||||
|
import { FormField } from '@primevue/forms'
|
||||||
|
import { Form } from '@primevue/forms'
|
||||||
|
import { zodResolver } from '@primevue/forms/resolvers/zod'
|
||||||
|
import { z } from 'zod'
|
||||||
|
import { useToast } from 'primevue/usetoast'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
const remember = ref(false)
|
||||||
|
|
||||||
|
const toast = useToast()
|
||||||
|
|
||||||
|
const resolver = zodResolver(
|
||||||
|
z.object({
|
||||||
|
username: z.string().min(1, { message: 'Username is required.' }),
|
||||||
|
password: z.string().min(1, { message: 'Password is required.' }),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
const onFormSubmit = ({ valid }) => {
|
||||||
|
if (valid) {
|
||||||
|
toast.add({ severity: 'success', summary: 'Form is submitted.', life: 3000 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="Login">
|
||||||
|
<h1>This is the Login Page</h1>
|
||||||
|
</div>
|
||||||
|
<div class="card flex justify-center">
|
||||||
|
<Form :resolver @submit="onFormSubmit" class="flex flex-col gap-4 w-full sm:w-56">
|
||||||
|
<FormField
|
||||||
|
v-slot="$field"
|
||||||
|
as="section"
|
||||||
|
name="username"
|
||||||
|
initialValue=""
|
||||||
|
class="flex flex-col gap-2"
|
||||||
|
>
|
||||||
|
<InputText type="text" placeholder="Username" />
|
||||||
|
<Message v-if="$field?.invalid" severity="error" size="small" variant="simple">{{
|
||||||
|
$field.error?.message
|
||||||
|
}}</Message>
|
||||||
|
</FormField>
|
||||||
|
<FormField v-slot="$field" asChild name="password" initialValue="">
|
||||||
|
<section class="flex flex-col gap-2">
|
||||||
|
<Password type="text" placeholder="Password" :feedback="false" toggleMask fluid />
|
||||||
|
<Message v-if="$field?.invalid" severity="error" size="small" variant="simple">{{
|
||||||
|
$field.error?.message
|
||||||
|
}}</Message>
|
||||||
|
</section>
|
||||||
|
</FormField>
|
||||||
|
<Button type="submit" severity="secondary" label="Submit" />
|
||||||
|
</Form>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<Checkbox v-model="remember" inputId="rememberme" binary />
|
||||||
|
<label for="rememberme"> Rememberme </label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.about {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
15
frontend/src/views/StudentView.vue
Normal file
15
frontend/src/views/StudentView.vue
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<template>
|
||||||
|
<div class="Student">
|
||||||
|
<h1>This is an Student page</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.about {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
35
frontend/src/views/TeacherView.vue
Normal file
35
frontend/src/views/TeacherView.vue
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useClassStore } from '@/stores/classStore'
|
||||||
|
import Card from 'primevue/card'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
|
const store = useClassStore()
|
||||||
|
|
||||||
|
store.loadClasses()
|
||||||
|
|
||||||
|
var elements = store.classInfoList
|
||||||
|
|
||||||
|
function setClass(input: number) {
|
||||||
|
store.setActiveClass(input)
|
||||||
|
router.push({ name: 'about' })
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<Card v-for="item in elements" class="cards" href="/about" @click="setClass(item.id)">
|
||||||
|
<template #title>{{ item.name }}</template>
|
||||||
|
<template #content>
|
||||||
|
<p class="m-0">Klassebereich von: {{ item.name }}</p>
|
||||||
|
</template>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.cards {
|
||||||
|
outline-style: solid;
|
||||||
|
margin-top: 20px;
|
||||||
|
outline-color: gray;
|
||||||
|
}
|
||||||
|
</style>
|
12
frontend/tsconfig.app.json
Normal file
12
frontend/tsconfig.app.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||||
|
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
||||||
|
"exclude": ["src/**/__tests__/*"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||||
|
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
frontend/tsconfig.json
Normal file
14
frontend/tsconfig.json
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.node.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.app.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.vitest.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
19
frontend/tsconfig.node.json
Normal file
19
frontend/tsconfig.node.json
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"extends": "@tsconfig/node22/tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"vite.config.*",
|
||||||
|
"vitest.config.*",
|
||||||
|
"cypress.config.*",
|
||||||
|
"nightwatch.conf.*",
|
||||||
|
"playwright.config.*",
|
||||||
|
"eslint.config.*"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"noEmit": true,
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||||
|
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"types": ["node"]
|
||||||
|
}
|
||||||
|
}
|
11
frontend/tsconfig.vitest.json
Normal file
11
frontend/tsconfig.vitest.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"extends": "./tsconfig.app.json",
|
||||||
|
"include": ["src/**/__tests__/*", "env.d.ts"],
|
||||||
|
"exclude": [],
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
|
||||||
|
|
||||||
|
"lib": [],
|
||||||
|
"types": ["node", "jsdom"]
|
||||||
|
}
|
||||||
|
}
|
16
frontend/vite.config.ts
Normal file
16
frontend/vite.config.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import { fileURLToPath, URL } from 'node:url'
|
||||||
|
|
||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||||
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||||
|
|
||||||
|
// https://vite.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [vue(), vueJsx(), vueDevTools()],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
14
frontend/vitest.config.ts
Normal file
14
frontend/vitest.config.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import { fileURLToPath } from 'node:url'
|
||||||
|
import { mergeConfig, defineConfig, configDefaults } from 'vitest/config'
|
||||||
|
import viteConfig from './vite.config'
|
||||||
|
|
||||||
|
export default mergeConfig(
|
||||||
|
viteConfig,
|
||||||
|
defineConfig({
|
||||||
|
test: {
|
||||||
|
environment: 'jsdom',
|
||||||
|
exclude: [...configDefaults.exclude, 'e2e/**'],
|
||||||
|
root: fileURLToPath(new URL('./', import.meta.url)),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue