From e20c1896f7c7f829120623f3504fae7972746620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kemal=20Karako=C3=A7?= <42945832+KemalKrKX@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:59:57 +0200 Subject: [PATCH] feat: add location to "Scheduled" lectures on course page (#1376) * 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 --- model/stream.go | 2 ++ web/template/home.gohtml | 4 ++++ web/ts/entry/home.ts | 1 + web/ts/utilities/lectureHallValidator.ts | 4 ++++ 4 files changed, 11 insertions(+) mode change 100644 => 100755 web/template/home.gohtml create mode 100644 web/ts/utilities/lectureHallValidator.ts diff --git a/model/stream.go b/model/stream.go index fc3572c71..08d070c4b 100755 --- a/model/stream.go +++ b/model/stream.go @@ -385,6 +385,7 @@ type StreamDTO struct { Start time.Time End time.Time Duration int32 + LectureHall string } func (s Stream) ToDTO() StreamDTO { @@ -408,6 +409,7 @@ func (s Stream) ToDTO() StreamDTO { Start: s.Start, End: s.End, Duration: duration, + LectureHall: s.RoomCode, } } diff --git a/web/template/home.gohtml b/web/template/home.gohtml old mode 100644 new mode 100755 index fa40dca79..f3c318b89 --- a/web/template/home.gohtml +++ b/web/template/home.gohtml @@ -37,6 +37,7 @@ link.setAttribute('href', location.href); document.head.appendChild(link); +

+ diff --git a/web/ts/entry/home.ts b/web/ts/entry/home.ts index 9aacde30f..8b0bbe8ab 100644 --- a/web/ts/entry/home.ts +++ b/web/ts/entry/home.ts @@ -4,3 +4,4 @@ export * from "../components/livestreams"; export * from "../components/course"; export * from "../components/servernotifications"; export * from "../components/main"; +export * from "../utilities/lectureHallValidator"; diff --git a/web/ts/utilities/lectureHallValidator.ts b/web/ts/utilities/lectureHallValidator.ts new file mode 100644 index 000000000..b4da3198d --- /dev/null +++ b/web/ts/utilities/lectureHallValidator.ts @@ -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); +}