diff --git a/BetterIServ.Backend/Controllers/UnitsController.cs b/BetterIServ.Backend/Controllers/UnitsController.cs index 0fd0271..712009f 100644 --- a/BetterIServ.Backend/Controllers/UnitsController.cs +++ b/BetterIServ.Backend/Controllers/UnitsController.cs @@ -72,6 +72,9 @@ public class UnitsController : ControllerBase { data.Substitutions.Add(substitution); } + + var date = html.DocumentNode.SelectNodes("//body/center[1]")[0].ChildNodes[1]; + data.Date = DateTime.Parse(date.InnerHtml.Split(" ")[0]); return data; } diff --git a/BetterIServ.Backend/Entities/UnitsData.cs b/BetterIServ.Backend/Entities/UnitsData.cs index 2659ecc..79da48a 100644 --- a/BetterIServ.Backend/Entities/UnitsData.cs +++ b/BetterIServ.Backend/Entities/UnitsData.cs @@ -1,6 +1,7 @@ namespace BetterIServ.Backend.Entities; public struct UnitsData { + public DateTime Date { get; set; } public IList Notifications { get; set; } public IList Substitutions { get; set; } } \ No newline at end of file diff --git a/BetterIServ.Backend/Program.cs b/BetterIServ.Backend/Program.cs index e333fc9..73771be 100644 --- a/BetterIServ.Backend/Program.cs +++ b/BetterIServ.Backend/Program.cs @@ -1,3 +1,5 @@ +using PuppeteerSharp; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. @@ -18,6 +20,8 @@ var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { + await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultChromiumRevision); + app.UseSwagger(); app.UseSwaggerUI(); } diff --git a/BetterIServ.Mobile/src/app/api/units.service.ts b/BetterIServ.Mobile/src/app/api/units.service.ts index 1f8b7bf..c38b63c 100644 --- a/BetterIServ.Mobile/src/app/api/units.service.ts +++ b/BetterIServ.Mobile/src/app/api/units.service.ts @@ -30,7 +30,9 @@ export class UnitsService { public async getSubstitutionPlan(date: "today" | "tomorrow"): Promise { if (this.schools[this.iserv.userdata.domain] == undefined) return undefined; const url = this.schools[this.iserv.userdata.domain][date]; - return await firstValueFrom(this.client.get(this.iserv.backend + "/units/substitution?url=" + url)); + const data = await firstValueFrom(this.client.get(this.iserv.backend + "/units/substitution?url=" + url)); + data.date = new Date(data.date); + return data; } } diff --git a/BetterIServ.Mobile/src/app/entities/substitution.ts b/BetterIServ.Mobile/src/app/entities/substitution.ts index 1c3452b..9e93e26 100644 --- a/BetterIServ.Mobile/src/app/entities/substitution.ts +++ b/BetterIServ.Mobile/src/app/entities/substitution.ts @@ -11,6 +11,7 @@ } export interface UnitsData { + date: Date; notifications: string[]; substitutions: Substitution[]; } diff --git a/BetterIServ.Mobile/src/app/pages/home/home.page.html b/BetterIServ.Mobile/src/app/pages/home/home.page.html index a6bc40b..0a5f35a 100644 --- a/BetterIServ.Mobile/src/app/pages/home/home.page.html +++ b/BetterIServ.Mobile/src/app/pages/home/home.page.html @@ -45,6 +45,7 @@ Vertretungsplan + {{subsDate?.toLocaleDateString()}} diff --git a/BetterIServ.Mobile/src/app/pages/home/home.page.scss b/BetterIServ.Mobile/src/app/pages/home/home.page.scss index e6d6614..43cf840 100644 --- a/BetterIServ.Mobile/src/app/pages/home/home.page.scss +++ b/BetterIServ.Mobile/src/app/pages/home/home.page.scss @@ -5,5 +5,5 @@ } .lesson-content { - overflow-x: scroll; + overflow-x: auto; } diff --git a/BetterIServ.Mobile/src/app/pages/home/home.page.ts b/BetterIServ.Mobile/src/app/pages/home/home.page.ts index 484c188..e5ba027 100644 --- a/BetterIServ.Mobile/src/app/pages/home/home.page.ts +++ b/BetterIServ.Mobile/src/app/pages/home/home.page.ts @@ -26,6 +26,7 @@ export class HomePage implements OnInit { public today: Date; public dayName: string; public subs: Substitution[]; + public subsDate: Date; public classData: {class: string, courses: Course[]}; public lessons: Lesson[]; @@ -43,7 +44,13 @@ export class HomePage implements OnInit { this.unreadMails = (await mailPromise).filter(mail => !mail.read); this.classData = await classPromise; - this.subs = (await subsPromise).substitutions.filter(subs => subs.classes.includes(this.classData.class)); + let unitsData = await subsPromise; + + if (this.dateIsPast(unitsData.date, new Date())) { + unitsData = await this.units.getSubstitutionPlan("tomorrow"); + } + this.subs = unitsData.substitutions?.filter(subs => subs.classes.includes(this.classData.class)); + this.subsDate = unitsData.date; if (this.classData.class.startsWith("Q")) { this.subs = this.subs.filter(subs => this.classData.courses.filter(course => course.id == subs.lesson).length > 0); @@ -54,4 +61,8 @@ export class HomePage implements OnInit { } } + private dateIsPast(first: Date, second: Date): boolean { + return first.setHours(0, 0, 0, 0) <= second.setHours(0, 0, 0, 0); + } + } diff --git a/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.html b/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.html index 42f118a..444ff65 100644 --- a/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.html +++ b/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.html @@ -6,7 +6,8 @@ Stundenplan - + + @@ -24,7 +25,7 @@ Farbe - + {{color.name}} @@ -107,6 +108,50 @@ + + + + + + Abbrechen + + Kurse hinzufügen + + Fertig + + + + + + + {{course.name}} + + + + + + + + + + + + + + + + + diff --git a/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.ts b/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.ts index 21c944e..ec78eee 100644 --- a/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.ts +++ b/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.ts @@ -21,6 +21,7 @@ export class SchedulePage implements OnInit { public currentCourse: Course; public timetable: Timetable = {mon: [], tue: [], wed: [], thu: [], fri: []}; public currentLesson: {lesson: Lesson, day: string, time: number}; + public allCourses: Course[]; @ViewChild('courseModal') courseModal: IonModal; @ViewChild('tableModal') tableModal: IonModal; @@ -103,4 +104,27 @@ export class SchedulePage implements OnInit { return rooms[rooms.length - 1]; } + public loadAllCourses() { + this.allCourses = []; + for (let short of Object.keys(this.iserv.courseNames)) { + const name = this.iserv.courseNames[short]; + this.allCourses.push({short, name, id: short, color: this.getRandomColor()}); + } + } + + public getRandomColor(): string { + return this.iserv.colors[Math.floor(Math.random() * this.iserv.colors.length)].val; + } + + public addToAll(name: string, short: string) { + this.allCourses.push({short, name, id: short, color: this.getRandomColor()}); + } + + public saveCourses(event: any) { + if (event.detail.role != "confirm") return; + this.courses = this.allCourses; + delete this.allCourses; + localStorage.setItem("courses", JSON.stringify(this.courses)); + } + } diff --git a/BetterIServ.Mobile/src/app/pages/substitution/substitution.page.html b/BetterIServ.Mobile/src/app/pages/substitution/substitution.page.html index 041f5cf..714f9de 100644 --- a/BetterIServ.Mobile/src/app/pages/substitution/substitution.page.html +++ b/BetterIServ.Mobile/src/app/pages/substitution/substitution.page.html @@ -3,7 +3,7 @@ - Vertretungsplan + Vertretungsplan {{data?.date.toLocaleDateString()}}