fixed some backend errors + added timing management back on home page
This commit is contained in:
@@ -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 courses = new List<string>();
|
||||
if (list?.ChildNodes == null) return new SingleResult<string[]> { Value = Array.Empty<string>() };
|
||||
foreach (var child in list.ChildNodes) {
|
||||
if (child.ChildNodes.Count < 1) continue;
|
||||
courses.Add(child.ChildNodes[0].InnerText);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using Aspose.Email.Clients;
|
||||
using Aspose.Email.Clients.Imap;
|
||||
using BetterIServ.Backend.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -40,6 +41,7 @@ public class MailController : ControllerBase {
|
||||
[HttpPost("list/{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);
|
||||
if (client.ConnectionState != ConnectionState.Open) return Array.Empty<MailContent>();
|
||||
await client.SelectFolderAsync(folder);
|
||||
|
||||
var messages = await client.ListMessagesByPageAsync(20, page, new PageSettingsAsync());
|
||||
|
||||
@@ -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}`));
|
||||
|
||||
if (isJson) return JSON.parse(data.value) as T;
|
||||
else return data.value as T;
|
||||
return data.value as T;
|
||||
}catch {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {Router} from "@angular/router";
|
||||
import {Course, Lesson, Timetable} from "../../entities/course";
|
||||
import {LessonComponent} from "../../components/lesson/lesson.component";
|
||||
import {StorageService} from "../../api/storage.service";
|
||||
import {time} from "ionicons/icons";
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@@ -42,7 +43,7 @@ export class HomePage implements OnInit {
|
||||
const classPromise = this.iserv.getCoursesAndClass();
|
||||
const subsPromise = this.units.getSubstitutionPlan("today");
|
||||
const timetablePromise = this.storage.getItem<Timetable>("timetable");
|
||||
await Promise.all([classPromise, subsPromise]);
|
||||
await Promise.all([classPromise, subsPromise, timetablePromise]);
|
||||
|
||||
this.classData = await classPromise;
|
||||
let unitsData = await subsPromise;
|
||||
@@ -50,7 +51,7 @@ export class HomePage implements OnInit {
|
||||
const timetable = await timetablePromise;
|
||||
|
||||
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)) {
|
||||
|
||||
Reference in New Issue
Block a user