Merge branch '10-roomfinder' of github.com:masterElmar/htwkalender into 10-roomfinder

This commit is contained in:
Tom Wahl
2023-10-28 13:22:02 +02:00
50 changed files with 2432 additions and 498 deletions

View File

@@ -18,3 +18,23 @@ export async function createIndividualFeed(modules: Module[]): Promise<string> {
});
return token;
}
export async function saveIndividualFeed(
token: string,
modules: Module[],
): Promise<string> {
await fetch("/api/collections/feeds/records/" + token, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: '{"modules":' + JSON.stringify(modules) + "}",
})
.then((response) => {
return response.json();
})
.then((response) => {
token = response;
});
return token;
}

View File

@@ -24,8 +24,17 @@ export async function fetchModulesByCourseAndSemester(
return response.json();
})
.then((modulesResponse) => {
modulesResponse.forEach((module: string) =>
modules.push(new Module(module, course, module)),
modulesResponse.forEach((module: Module) =>
modules.push(
new Module(
module.name,
course,
module.name,
module.prof,
semester,
module.events,
),
),
);
});
return modules;
@@ -39,7 +48,16 @@ export async function fetchAllModules(): Promise<Module[]> {
})
.then((responseModules: Module[]) => {
responseModules.forEach((module: Module) => {
modules.push(new Module(module.Name, module.Course, module.Name));
modules.push(
new Module(
module.name,
module.course,
module.name,
module.prof,
module.semester,
module.events,
),
);
});
});

View File

@@ -0,0 +1,27 @@
import { Module } from "../model/module";
export async function fetchModule(name: string): Promise<Module> {
const request = new Request("/api/module", {
method: "GET",
headers: {
"Content-Type": "application/json",
Name: encodeURI(name),
},
});
return await fetch(request)
.then((response) => {
return response.json();
})
.then(
(module: Module) =>
new Module(
module.name,
module.course,
module.name,
module.prof,
module.semester,
module.events,
),
);
}

View File

@@ -0,0 +1,14 @@
import { Module } from "../model/module";
import { Calendar } from "../model/calendar";
export async function getCalender(token: string): Promise<Module[]> {
const request = new Request("/api/collections/feeds/records/" + token, {
method: "GET",
});
return await fetch(request)
.then((response) => {
return response.json();
})
.then((calendarResponse: Calendar) => calendarResponse.modules);
}