Merge branch 'main' of gitlab.com:PhilippHofer/rot
This commit is contained in:
commit
8b4999aeb8
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,5 +2,4 @@ target/
|
|||||||
db.sqlite
|
db.sqlite
|
||||||
.history/
|
.history/
|
||||||
Rocket.toml
|
Rocket.toml
|
||||||
static/*
|
|
||||||
frontend/node_modules/*
|
frontend/node_modules/*
|
||||||
|
112
README.md
112
README.md
@ -1,34 +1,40 @@
|
|||||||
# Notes / Bugfixes
|
# Backend
|
||||||
## Frontend
|
- [] **Create missing backend tests (see below)**
|
||||||
- [] add UI for `trip_type`
|
|
||||||
- [] support esc to close sidebar
|
|
||||||
- [] after an hour(?) of inactivity -> show large popup w/ "maybe old data (ignore) (reload page)" (ignore bc maybe use is actively doing something -> don't throw input away!)
|
|
||||||
|
|
||||||
## Backend
|
|
||||||
- [] Don't show events if time > 1h(?) ago
|
|
||||||
- [] Sync w/ nextcloud
|
|
||||||
- remove most fields (names, ...) from users and add uid
|
|
||||||
- create user_nextcloud table; to be re-created every day(?)
|
|
||||||
- [] ics for registered trips
|
- [] ics for registered trips
|
||||||
|
|
||||||
# Nice to have
|
## New large features
|
||||||
## Frontend
|
### Logbuch
|
||||||
- [] my trips for cox
|
Next:
|
||||||
|
- Make boats updateable (incl. rower + location)
|
||||||
|
- Write tests for model/boat.rs
|
||||||
|
|
||||||
## Backend
|
### Guest-Scheckbuch
|
||||||
- [] exactly same time -> deny registration
|
- guest_trip
|
||||||
- [] automatically add regular planned trip
|
- guest_user_id
|
||||||
- [] User sync w/ nextcloud
|
- amount_trips
|
||||||
- [] Rocket tests for /rest
|
- paid_to_user_id
|
||||||
- [] same day+time: aggregate stats (x people, of which y cox and z rower)
|
- guest_trip_logbook
|
||||||
|
- guest_trip_id
|
||||||
|
- logbook_id
|
||||||
|
|
||||||
# Frontend Process
|
### Bootsreservierungen
|
||||||
´cd frontend´
|
- Confirmation required?
|
||||||
´npm install´
|
- How long in advance is it possible?
|
||||||
´npm run (watch/build)´
|
- Default reservations for some regular events (A+F, USI, ...)?
|
||||||
|
|
||||||
|
### Notifications
|
||||||
|
- notifcations
|
||||||
|
- id
|
||||||
|
- message
|
||||||
|
- category
|
||||||
|
- created_at
|
||||||
|
- read_at: Option<Datetime>
|
||||||
|
- user_id
|
||||||
|
|
||||||
----
|
## Backlog (i.e. don't work on this now)
|
||||||
|
### Sync w/ nextcloud
|
||||||
|
- remove most fields (names, ...) from users and add uid
|
||||||
|
- create user_nextcloud table; to be re-created every day(?)
|
||||||
|
|
||||||
user
|
user
|
||||||
- UID
|
- UID
|
||||||
@ -41,3 +47,59 @@ user_details
|
|||||||
- is_cox (if CATEGORIES = {Steuerleute, Bootsführer})
|
- is_cox (if CATEGORIES = {Steuerleute, Bootsführer})
|
||||||
- is_admin (if CATEGORIES = Admin)
|
- is_admin (if CATEGORIES = Admin)
|
||||||
- is_guest (if person not in nextcloud)
|
- is_guest (if person not in nextcloud)
|
||||||
|
|
||||||
|
### Misc
|
||||||
|
- [] Don't show events if time > 1h(?) ago
|
||||||
|
- [] exactly same time -> deny registration
|
||||||
|
- [] automatically add regular planned trip
|
||||||
|
- [] same day+time: aggregate stats (x people, of which y cox and z rower)
|
||||||
|
- [] Lock trip; noone can register anymore
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Frontend Process
|
||||||
|
´cd frontend´
|
||||||
|
´npm install´
|
||||||
|
´npm run (watch/build)´
|
||||||
|
|
||||||
|
# Notes / Bugfixes
|
||||||
|
## Frontend
|
||||||
|
- [] add UI for `trip_type`
|
||||||
|
- [] support esc to close sidebar
|
||||||
|
- [] after an hour(?) of inactivity -> show large popup w/ "maybe old data (ignore) (reload page)" (ignore bc maybe use is actively doing something -> don't throw input away!)
|
||||||
|
|
||||||
|
|
||||||
|
# Nice to have
|
||||||
|
## Frontend
|
||||||
|
- [] my trips for cox
|
||||||
|
|
||||||
|
# Missing backend tests
|
||||||
|
|
||||||
|
- [x] (index) GET /
|
||||||
|
- [x] (faq) GET /faq
|
||||||
|
- [x] (cal) GET /cal
|
||||||
|
- [x] (FileServer: svelte/build) GET /<path..>
|
||||||
|
- [x] (join) GET /join/<trip_details_id>
|
||||||
|
- [x] (remove) GET /remove/<trip_details_id>
|
||||||
|
- [x] (create) POST /cox/trip
|
||||||
|
- [ ] (update) POST /cox/trip/<trip_id>
|
||||||
|
- [ ] (join) GET /cox/join/<planned_event_id>
|
||||||
|
- [ ] (remove) GET /cox/remove/<planned_event_id>
|
||||||
|
- [ ] (remove_trip) GET /cox/remove/trip/<trip_id>
|
||||||
|
- [ ] (index) GET /auth/
|
||||||
|
- [ ] (login) POST /auth/
|
||||||
|
- [ ] (logout) GET /auth/logout
|
||||||
|
- [ ] (updatepw) POST /auth/set-pw
|
||||||
|
- [ ] (setpw) GET /auth/set-pw/<userid>
|
||||||
|
- [ ] (rss) GET /admin/rss?<key>
|
||||||
|
- [ ] (index) GET /admin/user
|
||||||
|
- [ ] (update) POST /admin/user
|
||||||
|
- [ ] (create) POST /admin/planned-event
|
||||||
|
- [ ] (update) PUT /admin/planned-event
|
||||||
|
- [ ] (create) POST /admin/user/new
|
||||||
|
- [ ] (delete) GET /admin/user/<user>/delete
|
||||||
|
- [ ] (resetpw) GET /admin/user/<user>/reset-pw
|
||||||
|
- [ ] (delete) GET /admin/planned-event/<id>/delete
|
||||||
|
- [ ] (FileServer: static/) GET /public/<path..> [10]
|
||||||
|
- [ ] (login) POST /api/login/
|
||||||
|
- [ ] /tera/admin/boat.rs
|
||||||
|
3
Rocket.toml
Normal file
3
Rocket.toml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[default]
|
||||||
|
secret_key = "/NtVGizglEoyoxBLzsRDWTy4oAG1qDw4J4O+CWJSv+fypD7W9sam8hUY4j90EZsbZk8wEradS5zBoWtWKi3k8w=="
|
||||||
|
rss_key = "rss-key-for-ci"
|
@ -65,3 +65,57 @@ CREATE TABLE IF NOT EXISTS "log" (
|
|||||||
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP
|
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "location" (
|
||||||
|
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"name" text NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "boat" (
|
||||||
|
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"name" text NOT NULL UNIQUE,
|
||||||
|
"amount_seats" integer NOT NULL,
|
||||||
|
"location_id" INTEGER NOT NULL REFERENCES location(id) DEFAULT 1,
|
||||||
|
"owner" INTEGER REFERENCES user(id), -- null: club is owner
|
||||||
|
"year_built" INTEGER,
|
||||||
|
"boatbuilder" TEXT,
|
||||||
|
"default_shipmaster_only_steering" boolean default false not null,
|
||||||
|
"skull" boolean default true NOT NULL, -- false => riemen
|
||||||
|
"external" boolean default false NOT NULL -- false => owned by different club
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "logbook_type" (
|
||||||
|
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"name" text NOT NULL -- e.g. 'Wanderfahrt', 'Regatta'
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "logbook" (
|
||||||
|
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"boat_id" INTEGER NOT NULL REFERENCES boat(id),
|
||||||
|
"shipmaster" INTEGER NOT NULL REFERENCES user(id), -- null: club is owner
|
||||||
|
"shipmaster_only_steering" boolean not null,
|
||||||
|
"departure" text not null,
|
||||||
|
"arrival" text, -- None -> ship is on water
|
||||||
|
"destination" text,
|
||||||
|
"distance_in_km" integer,
|
||||||
|
"comments" text,
|
||||||
|
"type" INTEGER REFERENCES logbook_type(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "rower" (
|
||||||
|
"logbook_id" INTEGER NOT NULL REFERENCES logbook(id),
|
||||||
|
"rower_id" INTEGER NOT NULL REFERENCES user(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "boat_damage" (
|
||||||
|
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"boat_id" INTEGER NOT NULL REFERENCES boat(id),
|
||||||
|
"desc" text not null,
|
||||||
|
"user_id_created" INTEGER NOT NULL REFERENCES user(id),
|
||||||
|
"created_at" text not null default CURRENT_TIMESTAMP,
|
||||||
|
"user_id_fixed" INTEGER REFERENCES user(id), -- none: not fixed yet
|
||||||
|
"fixed_at" text,
|
||||||
|
"user_id_verified" INTEGER REFERENCES user(id),
|
||||||
|
"verified_at" text,
|
||||||
|
"lock_boat" boolean not null default false -- if true: noone can use the boat
|
||||||
|
);
|
||||||
|
|
||||||
|
13
seeds.sql
13
seeds.sql
@ -15,3 +15,16 @@ INSERT INTO "trip" (cox_id, trip_details_id) VALUES(4, 2);
|
|||||||
INSERT INTO "trip_type" (name, desc, question, icon) VALUES ('Regatta', 'Regatta!', 'Kein normales Event. Das ist eine Regatta! Willst du wirklich teilnehmen?', '🏅');
|
INSERT INTO "trip_type" (name, desc, question, icon) VALUES ('Regatta', 'Regatta!', 'Kein normales Event. Das ist eine Regatta! Willst du wirklich teilnehmen?', '🏅');
|
||||||
INSERT INTO "trip_type" (name, desc, question, icon) VALUES ('Lange Ausfahrt', 'Lange Ausfahrt!', 'Das ist eine lange Ausfahrt! Willst du wirklich teilnehmen?', '💪');
|
INSERT INTO "trip_type" (name, desc, question, icon) VALUES ('Lange Ausfahrt', 'Lange Ausfahrt!', 'Das ist eine lange Ausfahrt! Willst du wirklich teilnehmen?', '💪');
|
||||||
INSERT INTO "trip_type" (name, desc, question, icon) VALUES ('Wanderfahrt', 'Wanderfahrt!', 'Kein normales Event. Das ist eine Wanderfahrt! Bitte überprüfe ob du alle Anforderungen erfüllst. Willst du wirklich teilnehmen?', '⛱');
|
INSERT INTO "trip_type" (name, desc, question, icon) VALUES ('Wanderfahrt', 'Wanderfahrt!', 'Kein normales Event. Das ist eine Wanderfahrt! Bitte überprüfe ob du alle Anforderungen erfüllst. Willst du wirklich teilnehmen?', '⛱');
|
||||||
|
INSERT INTO "location" (name) VALUES ('Linz');
|
||||||
|
INSERT INTO "location" (name) VALUES ('Ottensheim');
|
||||||
|
INSERT INTO "boat" (name, amount_seats, location_id) VALUES ('Haichenbach', 1, 1);
|
||||||
|
INSERT INTO "boat" (name, amount_seats, location_id, owner) VALUES ('private_boat_from_rower', 1, 1, 2);
|
||||||
|
INSERT INTO "boat" (name, amount_seats, location_id) VALUES ('Joe', 2, 1);
|
||||||
|
INSERT INTO "boat" (name, amount_seats, location_id) VALUES ('Kaputtes Boot :-(', 7, 1);
|
||||||
|
INSERT INTO "logbook_type" (name) VALUES ('Wanderfahrt');
|
||||||
|
INSERT INTO "logbook_type" (name) VALUES ('Regatta');
|
||||||
|
INSERT INTO "logbook" (boat_id, shipmaster, shipmaster_only_steering, departure) VALUES (2, 2, false, '2142-12-24 10:00');
|
||||||
|
INSERT INTO "logbook" (boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km) VALUES (1, 4, false, '2141-12-24 10:00', '2141-12-24 15:00', 'Ottensheim', 25);
|
||||||
|
INSERT INTO "logbook" (boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km) VALUES (3, 4, false, '2142-12-24 10:00', '2142-12-24 11:30', 'Ottensheim + Regattastrecke', 29);
|
||||||
|
INSERT INTO "rower" (logbook_id, rower_id) VALUES(3,3);
|
||||||
|
INSERT INTO "boat_damage" (boat_id, desc, user_id_created, created_at) VALUES(4,'Dolle bei Position 2 fehlt', 5, '2142-12-24 15:02');
|
||||||
|
196
src/model/boat.rs
Normal file
196
src/model/boat.rs
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use sqlx::{FromRow, SqlitePool};
|
||||||
|
|
||||||
|
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||||
|
pub struct Boat {
|
||||||
|
pub id: i64,
|
||||||
|
pub name: String,
|
||||||
|
pub amount_seats: i64,
|
||||||
|
pub location_id: i64,
|
||||||
|
pub owner: Option<i64>,
|
||||||
|
pub year_built: Option<i64>,
|
||||||
|
pub boatbuilder: Option<String>,
|
||||||
|
#[serde(default = "bool::default")]
|
||||||
|
default_shipmaster_only_steering: bool,
|
||||||
|
#[serde(default = "bool::default")]
|
||||||
|
skull: bool,
|
||||||
|
#[serde(default = "bool::default")]
|
||||||
|
external: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Boat {
|
||||||
|
pub async fn find_by_id(db: &SqlitePool, id: i32) -> Option<Self> {
|
||||||
|
sqlx::query_as!(
|
||||||
|
Self,
|
||||||
|
"
|
||||||
|
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, skull, external
|
||||||
|
FROM boat
|
||||||
|
WHERE id like ?
|
||||||
|
",
|
||||||
|
id
|
||||||
|
)
|
||||||
|
.fetch_one(db)
|
||||||
|
.await
|
||||||
|
.ok()
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// pub async fn find_by_name(db: &SqlitePool, name: &str) -> Option<Self> {
|
||||||
|
// sqlx::query_as!(
|
||||||
|
// User,
|
||||||
|
// "
|
||||||
|
//SELECT id, name, pw, is_cox, is_admin, is_guest, deleted, last_access
|
||||||
|
//FROM user
|
||||||
|
//WHERE name like ?
|
||||||
|
// ",
|
||||||
|
// name
|
||||||
|
// )
|
||||||
|
// .fetch_one(db)
|
||||||
|
// .await
|
||||||
|
// .ok()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
pub async fn all(db: &SqlitePool) -> Vec<Self> {
|
||||||
|
sqlx::query_as!(
|
||||||
|
Boat,
|
||||||
|
"
|
||||||
|
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, skull, external
|
||||||
|
FROM boat
|
||||||
|
ORDER BY amount_seats DESC
|
||||||
|
"
|
||||||
|
)
|
||||||
|
.fetch_all(db)
|
||||||
|
.await
|
||||||
|
.unwrap() //TODO: fixme
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn create(
|
||||||
|
db: &SqlitePool,
|
||||||
|
name: &str,
|
||||||
|
amount_seats: i64,
|
||||||
|
year_built: Option<i64>,
|
||||||
|
boatbuilder: Option<&str>,
|
||||||
|
default_shipmaster_only_steering: bool,
|
||||||
|
skull: bool,
|
||||||
|
external: bool,
|
||||||
|
) -> bool {
|
||||||
|
sqlx::query!(
|
||||||
|
"INSERT INTO boat(name, amount_seats, year_built, boatbuilder, default_shipmaster_only_steering, skull, external) VALUES (?,?,?,?,?,?,?)",
|
||||||
|
name,
|
||||||
|
amount_seats,
|
||||||
|
year_built,
|
||||||
|
boatbuilder,
|
||||||
|
default_shipmaster_only_steering,
|
||||||
|
skull,
|
||||||
|
external
|
||||||
|
)
|
||||||
|
.execute(db)
|
||||||
|
.await
|
||||||
|
.is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update(
|
||||||
|
&self,
|
||||||
|
db: &SqlitePool,
|
||||||
|
name: &str,
|
||||||
|
amount_seats: i64,
|
||||||
|
year_built: Option<i64>,
|
||||||
|
boatbuilder: Option<&str>,
|
||||||
|
default_shipmaster_only_steering: bool,
|
||||||
|
skull: bool,
|
||||||
|
external: bool,
|
||||||
|
location_id: Option<i64>,
|
||||||
|
owner: Option<i64>,
|
||||||
|
) -> bool {
|
||||||
|
sqlx::query!(
|
||||||
|
"UPDATE boat SET name=?, amount_seats=?, year_built=?, boatbuilder=?, default_shipmaster_only_steering=?, skull=?, external=?, location_id=?, owner=? WHERE id=?",
|
||||||
|
name,
|
||||||
|
amount_seats,
|
||||||
|
year_built,
|
||||||
|
boatbuilder,
|
||||||
|
default_shipmaster_only_steering,
|
||||||
|
skull,
|
||||||
|
external,
|
||||||
|
location_id,
|
||||||
|
owner,
|
||||||
|
self.id
|
||||||
|
)
|
||||||
|
.execute(db)
|
||||||
|
.await
|
||||||
|
.is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete(&self, db: &SqlitePool) {
|
||||||
|
sqlx::query!("DELETE FROM boat WHERE id=?", self.id)
|
||||||
|
.execute(db)
|
||||||
|
.await
|
||||||
|
.unwrap(); //Okay, because we can only create a User of a valid id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use crate::{model::boat::Boat, testdb};
|
||||||
|
|
||||||
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_find_correct_id() {
|
||||||
|
let pool = testdb!();
|
||||||
|
let boat = Boat::find_by_id(&pool, 1).await.unwrap();
|
||||||
|
assert_eq!(boat.id, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_find_wrong_id() {
|
||||||
|
let pool = testdb!();
|
||||||
|
let boat = Boat::find_by_id(&pool, 1337).await;
|
||||||
|
assert!(boat.is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_all() {
|
||||||
|
let pool = testdb!();
|
||||||
|
let res = Boat::all(&pool).await;
|
||||||
|
assert!(res.len() > 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_succ_create() {
|
||||||
|
let pool = testdb!();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
Boat::create(
|
||||||
|
&pool,
|
||||||
|
"new-boat-name".into(),
|
||||||
|
42,
|
||||||
|
None,
|
||||||
|
"Best Boatbuilder".into(),
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
.await,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_duplicate_name_create() {
|
||||||
|
let pool = testdb!();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
Boat::create(
|
||||||
|
&pool,
|
||||||
|
"Haichenbach".into(),
|
||||||
|
42,
|
||||||
|
None,
|
||||||
|
"Best Boatbuilder".into(),
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
.await,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
94
src/model/location.rs
Normal file
94
src/model/location.rs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use sqlx::{FromRow, SqlitePool};
|
||||||
|
|
||||||
|
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||||
|
pub struct Location {
|
||||||
|
pub id: i64,
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Location {
|
||||||
|
pub async fn find_by_id(db: &SqlitePool, id: i32) -> Option<Self> {
|
||||||
|
sqlx::query_as!(
|
||||||
|
Self,
|
||||||
|
"
|
||||||
|
SELECT id, name
|
||||||
|
FROM location
|
||||||
|
WHERE id like ?
|
||||||
|
",
|
||||||
|
id
|
||||||
|
)
|
||||||
|
.fetch_one(db)
|
||||||
|
.await
|
||||||
|
.ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn all(db: &SqlitePool) -> Vec<Self> {
|
||||||
|
sqlx::query_as!(
|
||||||
|
Self,
|
||||||
|
"
|
||||||
|
SELECT id, name
|
||||||
|
FROM location
|
||||||
|
"
|
||||||
|
)
|
||||||
|
.fetch_all(db)
|
||||||
|
.await
|
||||||
|
.unwrap() //TODO: fixme
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn create(db: &SqlitePool, name: &str) -> bool {
|
||||||
|
sqlx::query!("INSERT INTO location(name) VALUES (?)", name,)
|
||||||
|
.execute(db)
|
||||||
|
.await
|
||||||
|
.is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete(&self, db: &SqlitePool) {
|
||||||
|
sqlx::query!("DELETE FROM location WHERE id=?", self.id)
|
||||||
|
.execute(db)
|
||||||
|
.await
|
||||||
|
.unwrap(); //Okay, because we can only create a Location of a valid id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use crate::{model::location::Location, testdb};
|
||||||
|
|
||||||
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_find_correct_id() {
|
||||||
|
let pool = testdb!();
|
||||||
|
let location = Location::find_by_id(&pool, 1).await.unwrap();
|
||||||
|
assert_eq!(location.id, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_find_wrong_id() {
|
||||||
|
let pool = testdb!();
|
||||||
|
let location = Location::find_by_id(&pool, 1337).await;
|
||||||
|
assert!(location.is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_all() {
|
||||||
|
let pool = testdb!();
|
||||||
|
let res = Location::all(&pool).await;
|
||||||
|
assert!(res.len() > 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_succ_create() {
|
||||||
|
let pool = testdb!();
|
||||||
|
|
||||||
|
assert_eq!(Location::create(&pool, "new-loc-name".into(),).await, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_duplicate_name_create() {
|
||||||
|
let pool = testdb!();
|
||||||
|
|
||||||
|
assert_eq!(Location::create(&pool, "Linz".into(),).await, false);
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,8 @@ use self::{
|
|||||||
trip::{Trip, TripWithUserAndType},
|
trip::{Trip, TripWithUserAndType},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub mod boat;
|
||||||
|
pub mod location;
|
||||||
pub mod log;
|
pub mod log;
|
||||||
pub mod planned_event;
|
pub mod planned_event;
|
||||||
pub mod trip;
|
pub mod trip;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
use rocket::{
|
use rocket::{form::Form, fs::FileServer, post, routes, Build, FromForm, Rocket, State};
|
||||||
form::Form, fs::FileServer, http::CookieJar, post, routes, Build, FromForm, Rocket, State,
|
|
||||||
};
|
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
|
145
src/tera/admin/boat.rs
Normal file
145
src/tera/admin/boat.rs
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
use crate::model::{
|
||||||
|
boat::Boat,
|
||||||
|
location::Location,
|
||||||
|
user::{AdminUser, User},
|
||||||
|
};
|
||||||
|
use rocket::{
|
||||||
|
form::Form,
|
||||||
|
get, post,
|
||||||
|
request::FlashMessage,
|
||||||
|
response::{Flash, Redirect},
|
||||||
|
routes, FromForm, Route, State,
|
||||||
|
};
|
||||||
|
use rocket_dyn_templates::{tera::Context, Template};
|
||||||
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
|
#[get("/boat")]
|
||||||
|
async fn index(
|
||||||
|
db: &State<SqlitePool>,
|
||||||
|
admin: AdminUser,
|
||||||
|
flash: Option<FlashMessage<'_>>,
|
||||||
|
) -> Template {
|
||||||
|
let boats = Boat::all(db).await;
|
||||||
|
let locations = Location::all(db).await;
|
||||||
|
let users = User::all(db).await;
|
||||||
|
|
||||||
|
let mut context = Context::new();
|
||||||
|
if let Some(msg) = flash {
|
||||||
|
context.insert("flash", &msg.into_inner());
|
||||||
|
}
|
||||||
|
context.insert("boats", &boats);
|
||||||
|
context.insert("locations", &locations);
|
||||||
|
context.insert("users", &users);
|
||||||
|
context.insert("loggedin_user", &admin.user);
|
||||||
|
|
||||||
|
Template::render("admin/boat/index", context.into_json())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("/boat/<boat>/delete")]
|
||||||
|
async fn delete(db: &State<SqlitePool>, _admin: AdminUser, boat: i32) -> Flash<Redirect> {
|
||||||
|
let boat = Boat::find_by_id(db, boat).await;
|
||||||
|
match boat {
|
||||||
|
Some(boat) => {
|
||||||
|
boat.delete(db).await;
|
||||||
|
Flash::success(
|
||||||
|
Redirect::to("/admin/boat"),
|
||||||
|
format!("Sucessfully deleted boat {}", boat.name),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
None => Flash::error(Redirect::to("/admin/boat"), "Boat does not exist"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(FromForm)]
|
||||||
|
struct BoatEditForm<'r> {
|
||||||
|
id: i32,
|
||||||
|
name: &'r str,
|
||||||
|
amount_seats: i64,
|
||||||
|
year_built: Option<i64>,
|
||||||
|
boatbuilder: Option<&'r str>,
|
||||||
|
default_shipmaster_only_steering: bool,
|
||||||
|
skull: bool,
|
||||||
|
external: bool,
|
||||||
|
location_id: Option<i64>,
|
||||||
|
owner: Option<i64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[post("/boat", data = "<data>")]
|
||||||
|
async fn update(
|
||||||
|
db: &State<SqlitePool>,
|
||||||
|
data: Form<BoatEditForm<'_>>,
|
||||||
|
_admin: AdminUser,
|
||||||
|
) -> Flash<Redirect> {
|
||||||
|
let boat = Boat::find_by_id(db, data.id).await;
|
||||||
|
let Some(boat) = boat else {
|
||||||
|
return Flash::error(
|
||||||
|
Redirect::to("/admin/boat"),
|
||||||
|
format!("Boat with ID {} does not exist!", data.id),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
if !boat
|
||||||
|
.update(
|
||||||
|
db,
|
||||||
|
data.name,
|
||||||
|
data.amount_seats,
|
||||||
|
data.year_built,
|
||||||
|
data.boatbuilder,
|
||||||
|
data.default_shipmaster_only_steering,
|
||||||
|
data.skull,
|
||||||
|
data.external,
|
||||||
|
data.location_id,
|
||||||
|
data.owner,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
return Flash::error(
|
||||||
|
Redirect::to("/admin/boat"),
|
||||||
|
format!("Boat with ID {} could not be updated!", data.id),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Flash::success(Redirect::to("/admin/boat"), "Successfully updated boat")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(FromForm)]
|
||||||
|
struct BoatAddForm<'r> {
|
||||||
|
name: &'r str,
|
||||||
|
amount_seats: i64,
|
||||||
|
year_built: Option<i64>,
|
||||||
|
boatbuilder: Option<&'r str>,
|
||||||
|
default_shipmaster_only_steering: bool,
|
||||||
|
skull: bool,
|
||||||
|
external: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[post("/boat/new", data = "<data>")]
|
||||||
|
async fn create(
|
||||||
|
db: &State<SqlitePool>,
|
||||||
|
data: Form<BoatAddForm<'_>>,
|
||||||
|
_admin: AdminUser,
|
||||||
|
) -> Flash<Redirect> {
|
||||||
|
if Boat::create(
|
||||||
|
db,
|
||||||
|
data.name,
|
||||||
|
data.amount_seats,
|
||||||
|
data.year_built,
|
||||||
|
data.boatbuilder,
|
||||||
|
data.default_shipmaster_only_steering,
|
||||||
|
data.skull,
|
||||||
|
data.external,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Flash::success(Redirect::to("/admin/boat"), "Successfully created boat")
|
||||||
|
} else {
|
||||||
|
Flash::error(
|
||||||
|
Redirect::to("/admin/boat"),
|
||||||
|
format!("Error while creating boat {} in DB", data.name),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn routes() -> Vec<Route> {
|
||||||
|
routes![index, create, delete, update]
|
||||||
|
}
|
@ -3,6 +3,7 @@ use sqlx::SqlitePool;
|
|||||||
|
|
||||||
use crate::{model::log::Log, tera::Config};
|
use crate::{model::log::Log, tera::Config};
|
||||||
|
|
||||||
|
pub mod boat;
|
||||||
pub mod planned_event;
|
pub mod planned_event;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ async fn rss(db: &State<SqlitePool>, key: Option<&str>, config: &State<Config>)
|
|||||||
pub fn routes() -> Vec<Route> {
|
pub fn routes() -> Vec<Route> {
|
||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
ret.append(&mut user::routes());
|
ret.append(&mut user::routes());
|
||||||
|
ret.append(&mut boat::routes());
|
||||||
ret.append(&mut planned_event::routes());
|
ret.append(&mut planned_event::routes());
|
||||||
ret.append(&mut routes![rss]);
|
ret.append(&mut routes![rss]);
|
||||||
ret
|
ret
|
||||||
|
@ -159,3 +159,63 @@ async fn remove(db: &State<SqlitePool>, planned_event_id: i64, cox: CoxUser) ->
|
|||||||
pub fn routes() -> Vec<Route> {
|
pub fn routes() -> Vec<Route> {
|
||||||
routes![create, join, remove, remove_trip, update]
|
routes![create, join, remove, remove_trip, update]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use chrono::NaiveDate;
|
||||||
|
use rocket::{
|
||||||
|
http::{ContentType, Status},
|
||||||
|
local::asynchronous::Client,
|
||||||
|
};
|
||||||
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
|
use crate::{model::trip::Trip, testdb};
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_trip_create() {
|
||||||
|
let db = testdb!();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
0,
|
||||||
|
Trip::get_for_day(&db, NaiveDate::from_ymd_opt(2999, 12, 30).unwrap())
|
||||||
|
.await
|
||||||
|
.len()
|
||||||
|
);
|
||||||
|
|
||||||
|
let rocket = rocket::build().manage(db.clone());
|
||||||
|
let rocket = crate::tera::config(rocket);
|
||||||
|
|
||||||
|
let client = Client::tracked(rocket).await.unwrap();
|
||||||
|
let login = client
|
||||||
|
.post("/auth")
|
||||||
|
.header(ContentType::Form) // Set the content type to form
|
||||||
|
.body("name=cox&password=cox"); // Add the form data to the request body;
|
||||||
|
login.dispatch().await;
|
||||||
|
|
||||||
|
let req = client
|
||||||
|
.post("/cox/trip")
|
||||||
|
.header(ContentType::Form)
|
||||||
|
.body("day=2999-12-30&planned_starting_time=12:34&max_people=42&allow_guests=false");
|
||||||
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
|
assert_eq!(response.headers().get("Location").next(), Some("/"));
|
||||||
|
|
||||||
|
let flash_cookie = response
|
||||||
|
.cookies()
|
||||||
|
.get("_flash")
|
||||||
|
.expect("Expected flash cookie");
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
flash_cookie.value(),
|
||||||
|
"7:successAusfahrt erfolgreich erstellt."
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
1,
|
||||||
|
Trip::get_for_day(&db, NaiveDate::from_ymd_opt(2999, 12, 30).unwrap())
|
||||||
|
.await
|
||||||
|
.len()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -11,9 +11,59 @@ async fn faq(user: User) -> Template {
|
|||||||
|
|
||||||
#[get("/cal")]
|
#[get("/cal")]
|
||||||
async fn cal(db: &State<SqlitePool>) -> (ContentType, String) {
|
async fn cal(db: &State<SqlitePool>) -> (ContentType, String) {
|
||||||
|
//TODO: add unit test once proper functionality is there
|
||||||
(ContentType::Calendar, PlannedEvent::get_ics_feed(db).await)
|
(ContentType::Calendar, PlannedEvent::get_ics_feed(db).await)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn routes() -> Vec<Route> {
|
pub fn routes() -> Vec<Route> {
|
||||||
routes![faq, cal]
|
routes![faq, cal]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use rocket::{
|
||||||
|
http::{ContentType, Status},
|
||||||
|
local::asynchronous::Client,
|
||||||
|
};
|
||||||
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
|
use crate::testdb;
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_faq() {
|
||||||
|
let db = testdb!();
|
||||||
|
|
||||||
|
let rocket = rocket::build().manage(db.clone());
|
||||||
|
let rocket = crate::tera::config(rocket);
|
||||||
|
|
||||||
|
let client = Client::tracked(rocket).await.unwrap();
|
||||||
|
let login = client
|
||||||
|
.post("/auth")
|
||||||
|
.header(ContentType::Form) // Set the content type to form
|
||||||
|
.body("name=cox&password=cox"); // Add the form data to the request body;
|
||||||
|
login.dispatch().await;
|
||||||
|
|
||||||
|
let req = client.get("/faq");
|
||||||
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::Ok);
|
||||||
|
|
||||||
|
assert!(response.into_string().await.unwrap().contains("FAQs"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_without_login() {
|
||||||
|
let db = testdb!();
|
||||||
|
|
||||||
|
let rocket = rocket::build().manage(db.clone());
|
||||||
|
let rocket = crate::tera::config(rocket);
|
||||||
|
|
||||||
|
let client = Client::tracked(rocket).await.unwrap();
|
||||||
|
|
||||||
|
let req = client.get("/");
|
||||||
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
|
assert_eq!(response.headers().get("Location").next(), Some("/auth"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
141
src/tera/mod.rs
141
src/tera/mod.rs
@ -123,27 +123,120 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
|
|||||||
.attach(AdHoc::config::<Config>())
|
.attach(AdHoc::config::<Config>())
|
||||||
}
|
}
|
||||||
|
|
||||||
//#[cfg(test)]
|
#[cfg(test)]
|
||||||
//mod test {
|
mod test {
|
||||||
// use crate::testdb;
|
use rocket::{
|
||||||
//
|
http::{ContentType, Status},
|
||||||
// use super::start;
|
local::asynchronous::Client,
|
||||||
// use rocket::http::Status;
|
};
|
||||||
// use rocket::local::asynchronous::Client;
|
use sqlx::SqlitePool;
|
||||||
// use rocket::uri;
|
|
||||||
// use sqlx::SqlitePool;
|
use crate::testdb;
|
||||||
//
|
|
||||||
// #[sqlx::test]
|
#[sqlx::test]
|
||||||
// fn test_not_logged_in() {
|
fn test_index() {
|
||||||
// let pool = testdb!();
|
let db = testdb!();
|
||||||
//
|
|
||||||
// let client = Client::tracked(start(pool))
|
let rocket = rocket::build().manage(db.clone());
|
||||||
// .await
|
let rocket = crate::tera::config(rocket);
|
||||||
// .expect("valid rocket instance");
|
|
||||||
// let response = client.get(uri!(super::index)).dispatch().await;
|
let client = Client::tracked(rocket).await.unwrap();
|
||||||
//
|
let login = client
|
||||||
// assert_eq!(response.status(), Status::SeeOther);
|
.post("/auth")
|
||||||
// let location = response.headers().get("Location").next().unwrap();
|
.header(ContentType::Form) // Set the content type to form
|
||||||
// assert_eq!(location, "/auth");
|
.body("name=cox&password=cox"); // Add the form data to the request body;
|
||||||
// }
|
login.dispatch().await;
|
||||||
//}
|
|
||||||
|
let req = client.get("/");
|
||||||
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::Ok);
|
||||||
|
|
||||||
|
assert!(response.into_string().await.unwrap().contains("Ausfahrten"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_without_login() {
|
||||||
|
let db = testdb!();
|
||||||
|
|
||||||
|
let rocket = rocket::build().manage(db.clone());
|
||||||
|
let rocket = crate::tera::config(rocket);
|
||||||
|
|
||||||
|
let client = Client::tracked(rocket).await.unwrap();
|
||||||
|
|
||||||
|
let req = client.get("/");
|
||||||
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
|
assert_eq!(response.headers().get("Location").next(), Some("/auth"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_join_and_remove() {
|
||||||
|
let db = testdb!();
|
||||||
|
|
||||||
|
let rocket = rocket::build().manage(db.clone());
|
||||||
|
let rocket = crate::tera::config(rocket);
|
||||||
|
|
||||||
|
let client = Client::tracked(rocket).await.unwrap();
|
||||||
|
let login = client
|
||||||
|
.post("/auth")
|
||||||
|
.header(ContentType::Form) // Set the content type to form
|
||||||
|
.body("name=rower&password=rower"); // Add the form data to the request body;
|
||||||
|
login.dispatch().await;
|
||||||
|
|
||||||
|
let req = client.get("/join/1");
|
||||||
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
|
assert_eq!(response.headers().get("Location").next(), Some("/"));
|
||||||
|
|
||||||
|
let flash_cookie = response
|
||||||
|
.cookies()
|
||||||
|
.get("_flash")
|
||||||
|
.expect("Expected flash cookie");
|
||||||
|
|
||||||
|
assert_eq!(flash_cookie.value(), "7:successErfolgreich angemeldet!");
|
||||||
|
|
||||||
|
let req = client.get("/remove/1");
|
||||||
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
|
assert_eq!(response.headers().get("Location").next(), Some("/"));
|
||||||
|
|
||||||
|
let flash_cookie = response
|
||||||
|
.cookies()
|
||||||
|
.get("_flash")
|
||||||
|
.expect("Expected flash cookie");
|
||||||
|
|
||||||
|
assert_eq!(flash_cookie.value(), "7:successErfolgreich abgemeldet!");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_join_invalid_event() {
|
||||||
|
let db = testdb!();
|
||||||
|
|
||||||
|
let rocket = rocket::build().manage(db.clone());
|
||||||
|
let rocket = crate::tera::config(rocket);
|
||||||
|
|
||||||
|
let client = Client::tracked(rocket).await.unwrap();
|
||||||
|
let login = client
|
||||||
|
.post("/auth")
|
||||||
|
.header(ContentType::Form) // Set the content type to form
|
||||||
|
.body("name=rower&password=rower"); // Add the form data to the request body;
|
||||||
|
login.dispatch().await;
|
||||||
|
|
||||||
|
let req = client.get("/join/9999");
|
||||||
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
|
assert_eq!(response.headers().get("Location").next(), Some("/"));
|
||||||
|
|
||||||
|
let flash_cookie = response
|
||||||
|
.cookies()
|
||||||
|
.get("_flash")
|
||||||
|
.expect("Expected flash cookie");
|
||||||
|
|
||||||
|
assert_eq!(flash_cookie.value(), "5:errorTrip_details do not exist.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BIN
static/images/favicon.ico
Normal file
BIN
static/images/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
1
static/main.css
Normal file
1
static/main.css
Normal file
@ -0,0 +1 @@
|
|||||||
|
*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e2e8f0}:before,:after{--tw-content: ""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#94a3b8}input::placeholder,textarea::placeholder{opacity:1;color:#94a3b8}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-y-0{top:0px;bottom:0px}.left-0{left:0px}.z-10{z-index:10}.mx-1{margin-left:.25rem;margin-right:.25rem}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-1{margin-left:.25rem}.ml-4{margin-left:1rem}.mr-1{margin-right:.25rem}.mr-2{margin-right:.5rem}.mr-3{margin-right:.75rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.grid{display:grid}.hidden{display:none}.h-10{height:2.5rem}.h-16{height:4rem}.h-3{height:.75rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-8{height:2rem}.min-h-screen{min-height:100vh}.w-28{width:7rem}.w-3{width:.75rem}.w-4{width:1rem}.w-5{width:1.25rem}.w-auto{width:auto}.w-full{width:100%}.max-w-md{max-width:28rem}.max-w-screen-lg{max-width:1024px}.max-w-screen-xl{max-width:1280px}.flex-shrink-0{flex-shrink:0}.rotate-45{--tw-rotate: 45deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-pointer{cursor:pointer}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-10{gap:2.5rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.-space-y-px>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(-1px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(-1px * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.rounded-md{border-radius:.375rem}.rounded-b-md{border-bottom-right-radius:.375rem;border-bottom-left-radius:.375rem}.rounded-t-md{border-top-left-radius:.375rem;border-top-right-radius:.375rem}.rounded-bl-md{border-bottom-left-radius:.375rem}.rounded-br-md{border-bottom-right-radius:.375rem}.border{border-width:1px}.border-0{border-width:0px}.border-t{border-top-width:1px}.border-t-0{border-top-width:0px}.border-\[\#f43f5e\]{--tw-border-opacity: 1;border-color:rgb(244 63 94 / var(--tw-border-opacity))}.bg-\[\#f43f5e\]{--tw-bg-opacity: 1;background-color:rgb(244 63 94 / var(--tw-bg-opacity))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity))}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(226 232 240 / var(--tw-bg-opacity))}.bg-primary-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity))}.bg-primary-200{--tw-bg-opacity: 1;background-color:rgb(191 219 254 / var(--tw-bg-opacity))}.bg-primary-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity))}.bg-primary-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity))}.bg-primary-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity))}.bg-primary-900{--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity))}.bg-primary-950{--tw-bg-opacity: 1;background-color:rgb(23 37 84 / var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.bg-opacity-80{--tw-bg-opacity: .8}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.pb-3{padding-bottom:.75rem}.pl-3{padding-left:.75rem}.ps-1{-webkit-padding-start:.25rem;padding-inline-start:.25rem}.pt-2{padding-top:.5rem}.pt-8{padding-top:2rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.tracking-wide{letter-spacing:.025em}.text-\[\#f43f5e\]{--tw-text-opacity: 1;color:rgb(244 63 94 / var(--tw-text-opacity))}.text-\[\#ff0000\]{--tw-text-opacity: 1;color:rgb(255 0 0 / var(--tw-text-opacity))}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity))}.text-gray-200{--tw-text-opacity: 1;color:rgb(226 232 240 / var(--tw-text-opacity))}.text-gray-500{--tw-text-opacity: 1;color:rgb(100 116 139 / var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity: 1;color:rgb(71 85 105 / var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity: 1;color:rgb(15 23 42 / var(--tw-text-opacity))}.text-primary-300{--tw-text-opacity: 1;color:rgb(147 197 253 / var(--tw-text-opacity))}.text-primary-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity))}.text-primary-900{--tw-text-opacity: 1;color:rgb(30 58 138 / var(--tw-text-opacity))}.text-primary-950{--tw-text-opacity: 1;color:rgb(23 37 84 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.underline{text-decoration-line:underline}.accent-gray-200{accent-color:#e2e8f0}.accent-primary-600{accent-color:#2563eb}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-inset{--tw-ring-inset: inset}.ring-gray-300{--tw-ring-opacity: 1;--tw-ring-color: rgb(203 213 225 / var(--tw-ring-opacity))}.h1{text-align:center;font-size:1.875rem;line-height:2.25rem;font-weight:700;text-transform:uppercase;letter-spacing:.025em;--tw-text-opacity: 1;color:rgb(30 58 138 / var(--tw-text-opacity))}.sidebar{position:fixed;overflow-y:scroll;top:0;background:white;z-index:2000;width:0;max-width:0;box-shadow:0 1rem 3rem #0000002d}.sidebar.open{background-color:#fff;display:block;height:100vh;right:0;top:0;width:100%;max-width:375px;z-index:40000}.sidebar.slide-in{transition-duration:75ms;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-timing-function:cubic-bezier(0,0,.2,1)}.sidebar.from-right{right:-24rem}.sidebar.from-right.open{right:0}.sidebar.from-left{left:-24rem}.sidebar.from-left.open{left:0}.sidebar-overlay{display:none}.sidebar-overlay.show{background-color:#0003;content:"";display:block;height:100%;left:0;position:fixed;top:0;width:100%;z-index:1025}.sidebar-close{border-radius:100%;flex:0 0 auto;height:1.5rem;width:1.5rem}.sidebar-footer{position:fixed;margin:0 -8px -4px;width:374px;bottom:0}.overlay{overflow:hidden}.btn{display:inline-block;cursor:pointer;border-radius:.375rem;padding:.5rem .75rem;text-align:center;font-size:.875rem;line-height:1.25rem;font-weight:600;--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.btn:focus-visible{outline-style:solid;outline-width:2px;outline-offset:2px}.btn-primary{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity))}.btn-primary:hover{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity))}.btn-primary:focus-visible{outline-color:#2563eb}.btn-dark{--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity))}.btn-dark:hover{--tw-bg-opacity: 1;background-color:rgb(23 37 84 / var(--tw-bg-opacity))}.btn-dark:focus-visible{outline-color:#172554}.btn-gray{--tw-bg-opacity: 1;background-color:rgb(148 163 184 / var(--tw-bg-opacity))}.btn-gray:hover{--tw-bg-opacity: 1;background-color:rgb(100 116 139 / var(--tw-bg-opacity))}.btn-gray:focus-visible{outline-color:#3b82f6}.btn-attention{--tw-bg-opacity: 1;background-color:rgb(244 63 94 / var(--tw-bg-opacity))}.btn-attention:hover{--tw-bg-opacity: 1;background-color:rgb(255 0 0 / var(--tw-bg-opacity))}.btn-attention:focus-visible{outline-color:red}.btn-alert,.btn-alert:hover{--tw-bg-opacity: 1;background-color:rgb(255 0 0 / var(--tw-bg-opacity))}.btn-alert:focus-visible{outline-color:red}.btn-fw{width:7rem}.btn[aria-pressed=true]{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity));--tw-text-opacity: 1;color:rgb(23 37 84 / var(--tw-text-opacity));outline-style:solid;outline-width:2px;outline-offset:2px;outline-color:#2563eb}.link-primary{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity));text-decoration-line:underline}.link-primary:hover{--tw-text-opacity: 1;color:rgb(30 58 138 / var(--tw-text-opacity))}.link-dark{--tw-text-opacity: 1;color:rgb(30 58 138 / var(--tw-text-opacity));text-decoration-line:underline}.link-dark:hover{--tw-text-opacity: 1;color:rgb(23 37 84 / var(--tw-text-opacity))}.link-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity));text-decoration-line:underline}.link-white:hover{--tw-text-opacity: 1;color:rgb(219 234 254 / var(--tw-text-opacity))}.input{position:relative;display:block;width:100%;border-width:0px;padding:.375rem .5rem;--tw-text-opacity: 1;color:rgb(15 23 42 / var(--tw-text-opacity));--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000);--tw-ring-inset: inset;--tw-ring-opacity: 1;--tw-ring-color: rgb(203 213 225 / var(--tw-ring-opacity))}.input::-moz-placeholder{--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity))}.input::placeholder{--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity))}.input:focus{z-index:10;--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000);--tw-ring-inset: inset;--tw-ring-opacity: 1;--tw-ring-color: rgb(37 99 235 / var(--tw-ring-opacity))}@media (min-width: 640px){.input{font-size:.875rem;line-height:1.5rem}}.alert-success{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity))}.alert-error{--tw-bg-opacity: 1;background-color:rgb(244 63 94 / var(--tw-bg-opacity))}.placeholder\:text-gray-400::-moz-placeholder{--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity))}.placeholder\:text-gray-400::placeholder{--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(226 232 240 / var(--tw-bg-opacity))}.hover\:bg-primary-500:hover{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity))}.hover\:bg-primary-950:hover{--tw-bg-opacity: 1;background-color:rgb(23 37 84 / var(--tw-bg-opacity))}.hover\:text-gray-100:hover{--tw-text-opacity: 1;color:rgb(241 245 249 / var(--tw-text-opacity))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(15 23 42 / var(--tw-text-opacity))}.hover\:text-primary-900:hover{--tw-text-opacity: 1;color:rgb(30 58 138 / var(--tw-text-opacity))}.hover\:text-primary-950:hover{--tw-text-opacity: 1;color:rgb(23 37 84 / var(--tw-text-opacity))}.focus\:z-10:focus{z-index:10}.focus\:bg-gray-200:focus{--tw-bg-opacity: 1;background-color:rgb(226 232 240 / var(--tw-bg-opacity))}.focus\:bg-primary-50:focus{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity))}.focus\:bg-primary-950:focus{--tw-bg-opacity: 1;background-color:rgb(23 37 84 / var(--tw-bg-opacity))}.focus\:text-primary-950:focus{--tw-text-opacity: 1;color:rgb(23 37 84 / var(--tw-text-opacity))}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-inset:focus{--tw-ring-inset: inset}.focus\:ring-primary-600:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(37 99 235 / var(--tw-ring-opacity))}.focus-visible\:outline:focus-visible{outline-style:solid}.focus-visible\:outline-2:focus-visible{outline-width:2px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\:outline-primary-600:focus-visible{outline-color:#2563eb}.group:hover .group-hover\:text-primary-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity))}@media (min-width: 640px){.sm\:col-span-2{grid-column:span 2 / span 2}.sm\:mt-0{margin-top:0}.sm\:flex{display:flex}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\:text-sm{font-size:.875rem;line-height:1.25rem}.sm\:leading-6{line-height:1.5rem}}@media (min-width: 768px){.md\:mb-0{margin-bottom:0}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:items-center{align-items:center}}@media (min-width: 1024px){.lg\:col-span-3{grid-column:span 3 / span 3}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:px-8{padding-left:2rem;padding-right:2rem}}@media (min-width: 1280px){.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}}
|
1
static/main.js
Normal file
1
static/main.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
var u=Object.defineProperty;var y=(e,t,s)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var l=(e,t,s)=>(y(e,typeof t!="symbol"?t+"":t,s),s);class p{constructor(t){l(this,"element");l(this,"trigger");l(this,"contentWrapper");l(this,"closeBtn");l(this,"overlay");l(this,"isOpen");this.trigger=t,this.element=document.getElementById(t),this.contentWrapper=document.querySelector("body"),this.overlay=document.querySelector(".sidebar-overlay[data-trigger="+this.trigger+"]"),this.element&&(this.closeBtn=this.element.querySelector("[data-trigger="+this.trigger+"]")),this.isOpen=!1}toggle(){var t;if(this.isOpen=!this.isOpen,this.trigger&&((t=document.getElementById(this.trigger))==null||t.classList.toggle("open")),this.contentWrapper&&this.contentWrapper.classList.toggle("overlay"),this.overlay&&this.overlay.classList.toggle("show"),this.element&&(this.element.ariaModal=this.element.ariaModal==="true"?"false":"true",this.isOpen)){const s=this.element.querySelector(".focus-js");s?s.focus():this.closeBtn.focus()}}}document.addEventListener("DOMContentLoaded",function(){q(),E(),h()});function h(){const e=document.querySelectorAll(".filter-trips-js");let t=new Map;e&&Array.prototype.forEach.call(e,r=>{t.set(r.dataset.action,r.ariaPressed),r.addEventListener("click",()=>{let o=sessionStorage.getItem("tripsFilter");if(o){let i=new Map(JSON.parse(o));for(let a of i.entries())a[0]===r.dataset.action&&a[1]!=="true"?i.set(a[0],"true"):i.set(a[0],"false");sessionStorage.setItem("tripsFilter",JSON.stringify(Array.from(i.entries())))}g(),r.getAttribute("aria-pressed")==="false"?(Array.prototype.forEach.call(e,i=>{i.setAttribute("aria-pressed","false")}),d(r.dataset.action)):r.setAttribute("aria-pressed","false")})});let s=sessionStorage.getItem("tripsFilter");if(s){let r=new Map(JSON.parse(s));for(let o of r.entries())o[1]==="true"&&d(o[0])}else sessionStorage.setItem("tripsFilter",JSON.stringify(Array.from(t.entries())))}function g(){const e=document.querySelectorAll(".reset-js.hidden");e&&Array.prototype.forEach.call(e,t=>{t.classList.remove("hidden")})}function d(e){const t=document.querySelector('button[data-action="'+e+'"]');t&&(t.setAttribute("aria-pressed","true"),m(e))}function m(e){switch(e){case"filter-days":{S();break}case"filter-coxs":{A();break}case"filter-months":{b(e);break}}}function S(){const e=document.querySelectorAll('div[data-trips="0"]');Array.prototype.forEach.call(e,t=>{t.classList.toggle("hidden")})}function A(){const e=document.querySelectorAll('div[data-coxneeded="false"]');Array.prototype.forEach.call(e,t=>{t.classList.toggle("hidden")})}function b(e){const t=["01","02","03","04","05","06","07","08","09","10","11","12"],s=document.querySelector('button[data-action="'+e+'"]');if(s){const r=s.dataset.month;if(r){const o=t.indexOf(r);o>-1&&t.splice(o,1),Array.prototype.forEach.call(t,i=>{const a=document.querySelectorAll('div[data-month="'+i+'"]');Array.prototype.forEach.call(a,n=>{n.classList.toggle("hidden")})})}}}function q(){const e=document.querySelector("#filter-js");e&&(f(e.value),e.addEventListener("input",()=>{f(e.value)}))}function f(e){const t=document.querySelectorAll('form[data-filterable="true"]');let s=document.querySelector("#filter-result-js"),r=0;Array.prototype.forEach.call(t,o=>{var a;let i=(a=o.dataset.filter)==null?void 0:a.toLocaleLowerCase();o.style.display="none",i!=null&&i.includes(e.toLocaleLowerCase())&&(o.style.display="flex",r++)}),s&&(s.innerHTML=r===0?"Kein Ergebnis gefunden":"<strong>"+r+"</strong>"+(r>1?" Ergebnisse":" Ergebnis")+" gefunden")}function E(){const e=document.querySelectorAll("[data-trigger]");e&&Array.prototype.forEach.call(e,t=>{if(t.dataset.trigger){const s=new p(t.dataset.trigger);t.addEventListener("click",r=>{r.preventDefault(),t.dataset.trigger==="sidebar"&&L(t),s.toggle()})}})}function L(e){const t=document.querySelector("#sidebar");if(t&&e.dataset.body&&e.dataset.header){let r=document.querySelector(e.dataset.body).cloneNode(!0),o=t.querySelector(".body-js");const i=r.querySelectorAll('input[type="checkbox"]');if(Array.prototype.forEach.call(i,n=>{var c;n&&((c=n.parentElement)==null||c.setAttribute("for",n.id+"js"),n.id+="js")}),o&&(o.innerHTML="",o.append(r)),e.dataset.day){let n=r.querySelector(".day-js");n&&(n.value=e.dataset.day)}let a=t.querySelector(".header-js");a&&(a.innerHTML=e.dataset.header)}}
|
14
static/manifest.json
Normal file
14
static/manifest.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"main.css": {
|
||||||
|
"file": "main.css",
|
||||||
|
"src": "main.css"
|
||||||
|
},
|
||||||
|
"main.ts": {
|
||||||
|
"css": [
|
||||||
|
"main.css"
|
||||||
|
],
|
||||||
|
"file": "main.js",
|
||||||
|
"isEntry": true,
|
||||||
|
"src": "main.ts"
|
||||||
|
}
|
||||||
|
}
|
91
templates/admin/boat/index.html.tera
Normal file
91
templates/admin/boat/index.html.tera
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
{% import "includes/macros" as macros %}
|
||||||
|
|
||||||
|
{% extends "base" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="max-w-screen-lg w-full">
|
||||||
|
{% if flash %}
|
||||||
|
{{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h1 class="h1">Boats</h1>
|
||||||
|
|
||||||
|
<form action="/admin/boat/new" method="post" class="mt-4 bg-primary-900 rounded-md text-white px-3 pb-3 pt-2 sm:flex items-end justify-between">
|
||||||
|
<div class="w-full">
|
||||||
|
<h2 class="text-md font-bold mb-2 uppercase tracking-wide">Neues Boot hinzufügen</h2>
|
||||||
|
<div class="grid md:grid-cols-3">
|
||||||
|
<div>
|
||||||
|
<label for="name" class="sr-only">Name</label>
|
||||||
|
<input type="text" name="name" class="relative block rounded-md border-0 py-1.5 px-2 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:z-10 focus:ring-2 focus:ring-inset focus:ring-primary-600 sm:text-sm sm:leading-6 mb-2 md:mb-0" placeholder="Name"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="amount_seats" class="sr-only">Anzahl Sitze</label>
|
||||||
|
<input type="number" min=0 name="amount_seats" class="relative block rounded-md border-0 py-1.5 px-2 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:z-10 focus:ring-2 focus:ring-inset focus:ring-primary-600 sm:text-sm sm:leading-6 mb-2 md:mb-0" placeholder="Anzahl Sitze"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="year_built" class="sr-only">Baujahr</label>
|
||||||
|
<input type="number" min="1950" name="year_built" class="relative block rounded-md border-0 py-1.5 px-2 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:z-10 focus:ring-2 focus:ring-inset focus:ring-primary-600 sm:text-sm sm:leading-6 mb-2 md:mb-0" placeholder="Baujahr"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="boatbuilder" class="sr-only">Boatbuilder</label>
|
||||||
|
<input type="text" name="boatbuilder" class="relative block rounded-md border-0 py-1.5 px-2 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:z-10 focus:ring-2 focus:ring-inset focus:ring-primary-600 sm:text-sm sm:leading-6 mb-2 md:mb-0" placeholder="Boatbuilder"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
default_shipmaster_only_steering:
|
||||||
|
<label for="default_shipmaster_only_steering" class="sr-only">default_shipmaster_only_steering</label>
|
||||||
|
<input type="checkbox" name="default_shipmaster_only_steering" class="relative block rounded-md border-0 py-1.5 px-2 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:z-10 focus:ring-2 focus:ring-inset focus:ring-primary-600 sm:text-sm sm:leading-6 mb-2 md:mb-0"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
skull:
|
||||||
|
<label for="skull" class="sr-only">skull</label>
|
||||||
|
<input type="checkbox" name="skull" class="relative block rounded-md border-0 py-1.5 px-2 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:z-10 focus:ring-2 focus:ring-inset focus:ring-primary-600 sm:text-sm sm:leading-6 mb-2 md:mb-0" checked="checked"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
external:
|
||||||
|
<label for="external" class="sr-only">external</label>
|
||||||
|
<input type="checkbox" name="external" class="relative block rounded-md border-0 py-1.5 px-2 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:z-10 focus:ring-2 focus:ring-inset focus:ring-primary-600 sm:text-sm sm:leading-6 mb-2 md:mb-0"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="text-right">
|
||||||
|
<input value="Hinzufügen" type="submit" class="w-28 mt-2 sm:mt-0 rounded-md bg-primary-500 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer"/>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="bg-primary-100 p-3 rounded-b-md grid gap-4">
|
||||||
|
<div id="filter-result-js" class="text-primary-950"></div>
|
||||||
|
{% for boat in boats %}
|
||||||
|
<form action="/admin/boat" data-filterable="true" method="post" class="bg-white p-3 rounded-md flex items-end md:items-center justify-between">
|
||||||
|
<div class="w-full">
|
||||||
|
<input type="hidden" name="id" value="{{ boat.id }}" />
|
||||||
|
<div class="font-bold mb-1">{{ boat.name }}<br />
|
||||||
|
</div>
|
||||||
|
<div class="grid md:grid-cols-3">
|
||||||
|
|
||||||
|
|
||||||
|
{{ macros::input(label='Name', name='name', type='text', value=boat.name) }}
|
||||||
|
{{ macros::input(label='Amount Seats', name='amount_seats', type='number', min=0, value=boat.amount_seats) }}
|
||||||
|
{{ macros::select(data=locations, label='location', select_name='location_id', selected_id=boat.location_id) }}
|
||||||
|
{{ macros::select(data=users, label='users', select_name='owner', selected_id=boat.owner, default="Vereinsboot") }}
|
||||||
|
{{ macros::input(label='Baujahr', name='year_built', type='number', min=1950, value=boat.year_built) }}
|
||||||
|
{{ macros::input(label='Bootsbauer', name='boatbuilder', type='text', value=boat.boatbuilder) }}
|
||||||
|
{{ macros::checkbox(label='default_shipmaster_only_steering', name='default_shipmaster_only_steering', id=loop.index , checked=boat.default_shipmaster_only_steering) }}
|
||||||
|
{{ macros::checkbox(label='skull', name='skull', id=loop.index , checked=boat.skull) }}
|
||||||
|
{{ macros::checkbox(label='external', name='external', id=loop.index , checked=boat.external) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid gap-3">
|
||||||
|
<a href="/admin/boat/{{ boat.id }}/delete" class="inline-block btn btn-alert" onclick="return confirm('Wirklich löschen?');">
|
||||||
|
{% include "includes/delete-icon" %}
|
||||||
|
Löschen
|
||||||
|
</a>
|
||||||
|
<input value="Ändern" type="submit" class="w-28 btn btn-primary"/>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock content %}
|
@ -10,7 +10,7 @@
|
|||||||
{{ macros::checkbox(label='Gäste erlauben', name='allow_guests') }}
|
{{ macros::checkbox(label='Gäste erlauben', name='allow_guests') }}
|
||||||
{{ macros::checkbox(label='Immer anzeigen', name='always_show') }}
|
{{ macros::checkbox(label='Immer anzeigen', name='always_show') }}
|
||||||
{{ macros::input(label='Anmerkungen', name='notes', type='input') }}
|
{{ macros::input(label='Anmerkungen', name='notes', type='input') }}
|
||||||
{{ macros::select(select_name='trip_type', trip_types=trip_types, default='Reguläre Ausfahrt') }}
|
{{ macros::select(data=trip_types, select_name='trip_type', default='Reguläre Ausfahrt') }}
|
||||||
|
|
||||||
<input value="Erstellen" class="w-full btn btn-primary" type="submit" />
|
<input value="Erstellen" class="w-full btn btn-primary" type="submit" />
|
||||||
</form>
|
</form>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
{{ macros::input(label='Anzahl Ruderer (ohne Steuerperson)', name='max_people', type='number', required=true, min='0') }}
|
{{ macros::input(label='Anzahl Ruderer (ohne Steuerperson)', name='max_people', type='number', required=true, min='0') }}
|
||||||
{{ macros::checkbox(label='Gäste erlauben', name='allow_guests') }}
|
{{ macros::checkbox(label='Gäste erlauben', name='allow_guests') }}
|
||||||
{{ macros::input(label='Anmerkungen', name='notes', type='input') }}
|
{{ macros::input(label='Anmerkungen', name='notes', type='input') }}
|
||||||
{{ macros::select(select_name='trip_type', trip_types=trip_types, default='Reguläre Ausfahrt') }}
|
{{ macros::select(data=trip_types, select_name='trip_type', default='Reguläre Ausfahrt') }}
|
||||||
|
|
||||||
<input value="Erstellen" class="w-full btn btn-primary" type="submit" />
|
<input value="Erstellen" class="w-full btn btn-primary" type="submit" />
|
||||||
</form>
|
</form>
|
||||||
|
@ -13,6 +13,12 @@
|
|||||||
<span class="sr-only">FAQs</span>
|
<span class="sr-only">FAQs</span>
|
||||||
</a>
|
</a>
|
||||||
{% if loggedin_user.is_admin %}
|
{% if loggedin_user.is_admin %}
|
||||||
|
<a href="/admin/boat" class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer">
|
||||||
|
BOATS
|
||||||
|
<span class="sr-only">Bootsverwaltung</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
<a href="/admin/user" class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer">
|
<a href="/admin/user" class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer">
|
||||||
<svg class="inline h-4" width="16" height="16" fill="currentColor" class="bi bi-person-lines-fill" viewBox="0 0 16 16"> <path d="M6 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-5 6s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H1zM11 3.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5zm.5 2.5a.5.5 0 0 0 0 1h4a.5.5 0 0 0 0-1h-4zm2 3a.5.5 0 0 0 0 1h2a.5.5 0 0 0 0-1h-2zm0 3a.5.5 0 0 0 0 1h2a.5.5 0 0 0 0-1h-2z"/> </svg>
|
<svg class="inline h-4" width="16" height="16" fill="currentColor" class="bi bi-person-lines-fill" viewBox="0 0 16 16"> <path d="M6 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-5 6s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H1zM11 3.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5zm.5 2.5a.5.5 0 0 0 0 1h4a.5.5 0 0 0 0-1h-4zm2 3a.5.5 0 0 0 0 1h2a.5.5 0 0 0 0-1h-2zm0 3a.5.5 0 0 0 0 1h2a.5.5 0 0 0 0-1h-2z"/> </svg>
|
||||||
<span class="sr-only">Userverwaltung</span>
|
<span class="sr-only">Userverwaltung</span>
|
||||||
@ -41,11 +47,13 @@
|
|||||||
</label>
|
</label>
|
||||||
{% endmacro checkbox %}
|
{% endmacro checkbox %}
|
||||||
|
|
||||||
{% macro select(trip_types, select_name='trip_type', default='', selected_id='') %}
|
{% macro select(data, select_name='trip_type', default='', selected_id='') %}
|
||||||
<select name="{{ select_name }}" class="input rounded-md h-10">
|
<select name="{{ select_name }}" class="input rounded-md h-10">
|
||||||
<option selected value>{{ default }}</option>
|
{% if default %}
|
||||||
{% for trip_type in trip_types %}
|
<option selected value>{{ default }}</option>
|
||||||
<option value="{{ trip_type.id }}" {% if trip_type.id == selected_id %} selected {% endif %}>{{ trip_type.name }}</option>
|
{% endif %}
|
||||||
|
{% for d in data %}
|
||||||
|
<option value="{{ d.id }}" {% if d.id == selected_id %} selected {% endif %}>{{ d.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
{% endmacro select %}
|
{% endmacro select %}
|
||||||
|
Loading…
Reference in New Issue
Block a user