Archived
Private
Public Access
1
0

fixed some backend errors + added timing management back on home page

This commit is contained in:
2023-09-05 08:24:25 +02:00
parent f3cf6977c4
commit 80ba0dc027
4 changed files with 7 additions and 3 deletions

View File

@@ -64,6 +64,7 @@ public class IServController : ControllerBase {
var list = html.DocumentNode.SelectSingleNode("//body/div/div[2]/div[3]/div/div/div[2]/div/div/div/div/ul[1]"); var list = html.DocumentNode.SelectSingleNode("//body/div/div[2]/div[3]/div/div/div[2]/div/div/div/div/ul[1]");
var courses = new List<string>(); var courses = new List<string>();
if (list?.ChildNodes == null) return new SingleResult<string[]> { Value = Array.Empty<string>() };
foreach (var child in list.ChildNodes) { foreach (var child in list.ChildNodes) {
if (child.ChildNodes.Count < 1) continue; if (child.ChildNodes.Count < 1) continue;
courses.Add(child.ChildNodes[0].InnerText); courses.Add(child.ChildNodes[0].InnerText);

View File

@@ -1,6 +1,7 @@
using System.Net; using System.Net;
using System.Net.Mail; using System.Net.Mail;
using System.Text; using System.Text;
using Aspose.Email.Clients;
using Aspose.Email.Clients.Imap; using Aspose.Email.Clients.Imap;
using BetterIServ.Backend.Entities; using BetterIServ.Backend.Entities;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -40,6 +41,7 @@ public class MailController : ControllerBase {
[HttpPost("list/{page}")] [HttpPost("list/{page}")]
public async Task<ActionResult<MailContent[]>> GetMails([FromBody] Credentials credentials, [FromQuery] string folder, [FromRoute] int page) { public async Task<ActionResult<MailContent[]>> GetMails([FromBody] Credentials credentials, [FromQuery] string folder, [FromRoute] int page) {
using var client = new ImapClient($"imap.{credentials.Domain}", credentials.Username, credentials.Password); using var client = new ImapClient($"imap.{credentials.Domain}", credentials.Username, credentials.Password);
if (client.ConnectionState != ConnectionState.Open) return Array.Empty<MailContent>();
await client.SelectFolderAsync(folder); await client.SelectFolderAsync(folder);
var messages = await client.ListMessagesByPageAsync(20, page, new PageSettingsAsync()); var messages = await client.ListMessagesByPageAsync(20, page, new PageSettingsAsync());

View File

@@ -17,7 +17,7 @@ export class StorageService {
const data = await firstValueFrom(this.client.get<{value: string}>(environment.backend + `/storage?user=${IServService.userdata.username}&item=${item}`)); const data = await firstValueFrom(this.client.get<{value: string}>(environment.backend + `/storage?user=${IServService.userdata.username}&item=${item}`));
if (isJson) return JSON.parse(data.value) as T; if (isJson) return JSON.parse(data.value) as T;
else return data.value as T; return data.value as T;
}catch { }catch {
return defaultValue; return defaultValue;
} }

View File

@@ -13,6 +13,7 @@ import {Router} from "@angular/router";
import {Course, Lesson, Timetable} from "../../entities/course"; import {Course, Lesson, Timetable} from "../../entities/course";
import {LessonComponent} from "../../components/lesson/lesson.component"; import {LessonComponent} from "../../components/lesson/lesson.component";
import {StorageService} from "../../api/storage.service"; import {StorageService} from "../../api/storage.service";
import {time} from "ionicons/icons";
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
@@ -42,7 +43,7 @@ export class HomePage implements OnInit {
const classPromise = this.iserv.getCoursesAndClass(); const classPromise = this.iserv.getCoursesAndClass();
const subsPromise = this.units.getSubstitutionPlan("today"); const subsPromise = this.units.getSubstitutionPlan("today");
const timetablePromise = this.storage.getItem<Timetable>("timetable"); const timetablePromise = this.storage.getItem<Timetable>("timetable");
await Promise.all([classPromise, subsPromise]); await Promise.all([classPromise, subsPromise, timetablePromise]);
this.classData = await classPromise; this.classData = await classPromise;
let unitsData = await subsPromise; let unitsData = await subsPromise;
@@ -50,7 +51,7 @@ export class HomePage implements OnInit {
const timetable = await timetablePromise; const timetable = await timetablePromise;
if (scheduleDay != undefined && timetable != undefined) { if (scheduleDay != undefined && timetable != undefined) {
this.lessons = timetable[scheduleDay].filter(lesson => lesson != undefined && this.storage.isLessonThisWeek(lesson)); this.lessons = timetable[scheduleDay].filter((lesson: Lesson) => lesson != undefined && this.storage.isLessonThisWeek(lesson));
} }
if (this.dateIsPast(unitsData.date, this.today)) { if (this.dateIsPast(unitsData.date, this.today)) {