Skip to content

Commit

Permalink
feat: add location to "Scheduled" lectures on course page (#1376)
Browse files Browse the repository at this point in the history
* lecture halls linked

* removed hardcoding

* Added verification through regex

* Regex fixed, no more undercase letters

* Auxiliary file created for regex

* Any removed for ESLint

* Prettier errors fixed

* Script no longer global

* Auxilliary file works now

* ESLint fixes

* Reset web directory

* Reset dependency lock

* Checked again

* Reset dependency lock again

* These seemed to have changed too

* Missed one

* Files replaced with default ones

* Something is wrong

* Update home.gohtml

---------

Co-authored-by: Karakoc <[email protected]>
  • Loading branch information
KemalKrKX and Karakoc authored Oct 21, 2024
1 parent 8b3a059 commit e20c189
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions model/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ type StreamDTO struct {
Start time.Time
End time.Time
Duration int32
LectureHall string
}

func (s Stream) ToDTO() StreamDTO {
Expand All @@ -408,6 +409,7 @@ func (s Stream) ToDTO() StreamDTO {
Start: s.Start,
End: s.End,
Duration: duration,
LectureHall: s.RoomCode,
}
}

Expand Down
4 changes: 4 additions & 0 deletions web/template/home.gohtml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
link.setAttribute('href', location.href);
document.head.appendChild(link);
</script>

</head>
<body x-data="home.skeleton()"
@popstate.window="onPopState"
Expand Down Expand Up @@ -590,6 +591,9 @@
<span x-text="`${s.TimeOfStart()} - ${s.TimeOfEnd()}`"></span>
</div>
<h4 x-text="s.Name" class="font-semibold text-1"></h4>
<template x-if="home.isLectureHallValid(s.LectureHall)">
<a :href="`https://nav.tum.de/room/${s.LectureHall}`" class="no-underline" x-text="s.LectureHall"></a>
</template>
</div>
</div>
</article>
Expand Down
1 change: 1 addition & 0 deletions web/ts/entry/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "../components/livestreams";
export * from "../components/course";
export * from "../components/servernotifications";
export * from "../components/main";
export * from "../utilities/lectureHallValidator";
4 changes: 4 additions & 0 deletions web/ts/utilities/lectureHallValidator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function isLectureHallValid(lectureHall: string): boolean {
const regex = /^\d{4}\.[A-Z0-9]{2}\.[A-Z0-9]{3,4}$/;
return regex.test(lectureHall);
}

0 comments on commit e20c189

Please sign in to comment.