Skip to content

Commit

Permalink
data seeds; er diagram; design changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dheidemann committed Oct 12, 2024
1 parent 0563b55 commit 0b68b61
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 25 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PUBLIC_URL="http://localhost:8080"
API_KEY=""
PEPPER_KEY=""

POSTGRES_PASSWORD="password123"
POSTGRES_USER="postgres"
Expand Down
54 changes: 38 additions & 16 deletions frontend/app/ui/planner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export default function Planner() {
const [tyFilter, setTyFilter] = useState<string[]>(searchParams.getAll("ty"));
const [umbrellaSelectionOpen, setUmbrellaSelectionOpen] = useState(false);
const [popupId, setPopupId] = useState(0);
const [currentMinutes, setCurrentMinutes] = useState(0);
const [tabs, setTabs] = useState(false)

const groupedEvents = groupEvents(events);

const createQueryString = useCallback(
(name: string, values: string[]) => {
Expand All @@ -127,6 +131,24 @@ export default function Planner() {
[searchParams]
);

useEffect(() => {
const now = new Date();
const currentMinutes = now.getHours() * 60 + now.getMinutes();
const intervalId = setInterval(() => {
setCurrentMinutes(currentMinutes);
}, 60000);

setCurrentMinutes(currentMinutes);

return () => clearInterval(intervalId);
}, []);

useEffect(() => {
const handleResize = () => {
const newWidth = window.innerWidth;
}
})

useEffect(() => {
const fetchData = async () => {
setLoading(true);
Expand Down Expand Up @@ -174,8 +196,8 @@ export default function Planner() {

const vars: UmbrellasQueryVariables = {
onlyFuture: true,
}
};

const umbrellaData = await client.request<UmbrellasQuery>(
UmbrellasDocument,
vars
Expand All @@ -189,7 +211,6 @@ export default function Planner() {
fetchData();
}, [umbrella]);

const groupedEvents = groupEvents(events);
return (
<div className="space-y-6 min-h-screen flex-col p-8">
<Popover
Expand Down Expand Up @@ -275,7 +296,6 @@ export default function Planner() {
const dayEndDate = new Date(dayEvents[dayEvents.length - 1].to);
const now = new Date();
const tPosition = () => {
const currentMinutes = now.getHours() * 60 + now.getMinutes();
const startTime =
dayStartDate.getHours() * 60 + dayStartDate.getMinutes();
const endTime =
Expand All @@ -296,18 +316,20 @@ export default function Planner() {
</CardDescription>
</CardHeader>
<CardContent className="flex flex-row">
{dayStartDate.getDay() == now.getDay() && (
<div className="relative w-4 mr-[24px]">
<div className="absolute inset-0 w-1 bg-gray-300 mx-auto"></div>
{now.getTime() >= dayStartDate.getTime() &&
now.getTime() <= dayEndDate.getTime() && (
<div
className="absolute left-0 right-0 bg-red-500 w-4 h-4 rounded-full mx-auto"
style={{ top: `${tPosition()}%` }}
></div>
)}
</div>
)}
{dayStartDate.getDay() == now.getDay() &&
getISOWeekNumber(dayStartDate) ===
getISOWeekNumber(now) && (
<div className="relative w-2 mr-[24px]">
<div className="absolute inset-0 w-0.5 bg-gray-300 mx-auto"></div>
{now.getTime() >= dayStartDate.getTime() &&
now.getTime() <= dayEndDate.getTime() && (
<div
className="absolute left-0 right-0 bg-red-500 w-2 h-2 rounded-full mx-auto"
style={{ top: `${tPosition()}%` }}
/>
)}
</div>
)}
<ul className="flex flex-col w-full">
{dayEvents.map((event, eventIndex) => {
const gap = eventIndex
Expand Down
4 changes: 2 additions & 2 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Welcome to the backend.

## api
See [https://fachschaftmathphysinfo.github.io/pepp](https://fachschaftmathphysinfo.github.io/pepp) for documentation on the API.
See the [documentation](https://fachschaftmathphysinfo.github.io/pepp).

## database er-diagram
![ER-Diagram](pepp-er.jpg)
![ER-Diagram](models/pepp-er.svg)
14 changes: 7 additions & 7 deletions server/db/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func seedData(ctx context.Context, db *bun.DB) error {
{
Title: fmt.Sprintf("Vorkurs %s", strconv.Itoa(time.Now().Year())),
Description: "Lorem Ipsum",
From: time.Now(),
From: time.Now().Add(-time.Hour),
To: time.Now().Add(3 * (time.Hour * 24)),
},
{
Expand All @@ -73,8 +73,8 @@ func seedData(ctx context.Context, db *bun.DB) error {
TopicName: "Informatik",
TypeName: "Tutorium",
NeedsTutors: true,
From: time.Now().Add(6 * time.Hour),
To: time.Now().Add(7 * time.Hour),
From: time.Now().Add(-time.Hour),
To: time.Now().Add(time.Hour),
UmbrellaID: &umbrellaID,
},
{
Expand All @@ -83,8 +83,8 @@ func seedData(ctx context.Context, db *bun.DB) error {
TopicName: "Mathe",
TypeName: "Vorlesung",
NeedsTutors: true,
From: time.Now().Add(20 * time.Hour),
To: time.Now().Add(22 * time.Hour),
From: time.Now().Add((24 * time.Hour) * 7),
To: time.Now().Add((24*time.Hour)*7 + 2*time.Hour),
UmbrellaID: &umbrellaID,
},
{
Expand All @@ -93,8 +93,8 @@ func seedData(ctx context.Context, db *bun.DB) error {
TopicName: "Mathe",
TypeName: "Tutorium",
NeedsTutors: true,
From: time.Now().Add(4 * time.Hour),
To: time.Now().Add(5 * time.Hour),
From: time.Now().Add(2 * time.Hour),
To: time.Now().Add(3 * time.Hour),
UmbrellaID: &umbrellaID,
}}
if err := insertData(ctx, db, (*models.Event)(nil), events, "Events"); err != nil {
Expand Down
12 changes: 12 additions & 0 deletions server/models/pepp-er.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed server/pepp-er.jpg
Binary file not shown.

0 comments on commit 0b68b61

Please sign in to comment.