diff --git a/timetable/static/bundled/timetable/generator-index.ts b/timetable/static/bundled/timetable/generator-index.ts index 72e3bb4d..826e0400 100644 --- a/timetable/static/bundled/timetable/generator-index.ts +++ b/timetable/static/bundled/timetable/generator-index.ts @@ -82,6 +82,7 @@ document.addEventListener("alpine:init", () => { displayedWeekdays: [] as WeekDay[], courses: [] as TimetableSlot[], startSlot: 0, + endSlot: 0, table: { height: 0, width: 0, @@ -150,6 +151,25 @@ document.addEventListener("alpine:init", () => { }; }, + getHours(): [string, object][] { + let hour: number = Number.parseInt( + this.courses + .map((c: TimetableSlot) => c.startHour) + .reduce((res: string, hour: string) => (hour < res ? hour : res), "24:00") + .split(":")[0], + ); + const res: [string, object][] = []; + for (let i = 0; i <= this.endSlot - this.startSlot; i += 60 / MINUTES_PER_SLOT) { + res.push([`${hour}:00`, { top: `${i * SLOT_HEIGHT}px` }]); + hour += 1; + } + return res; + }, + + getWidth() { + return this.displayedWeekdays.length * SLOT_WIDTH + 20; + }, + async savePng() { const elem = document.getElementById("timetable"); const img = (await html2canvas(elem)).toDataURL(); diff --git a/timetable/static/timetable/css/generator.scss b/timetable/static/timetable/css/generator.scss index 6a248532..758892de 100644 --- a/timetable/static/timetable/css/generator.scss +++ b/timetable/static/timetable/css/generator.scss @@ -1,10 +1,17 @@ +@import "core/static/core/colors"; + #timetable { + --hour-side-width: 60px; + display: block; - margin: 2em auto ; + margin: 2em auto; .header { - background-color: white; + background-color: $white-color; + font-weight: bold; box-shadow: none; - width: 100%; + width: calc(100% - var(--hour-side-width) - 10px); + margin-left: var(--hour-side-width); + padding-left: 0; display: flex; flex-direction: row; gap: 0; @@ -15,7 +22,32 @@ } .content { position: relative; + } + .hours { + position: absolute; + width: 40px; + left: 0; + top: -.5em; + + .hour { + position: absolute; + + .hour-bar { + content: ""; + position: absolute; + height: 1px; + background: lightgray; + top: 50%; + left: 100%; + margin-left: 10px; + } + } + } + .courses { + position: absolute; text-align: center; + top: 0; + left: var(--hour-side-width); .slot { background-color: cadetblue; diff --git a/timetable/templates/timetable/generator.jinja b/timetable/templates/timetable/generator.jinja index 560caa87..bbbc52b7 100644 --- a/timetable/templates/timetable/generator.jinja +++ b/timetable/templates/timetable/generator.jinja @@ -28,7 +28,7 @@