added frontend and updated backend with docker, wrote some initial instructions

This commit is contained in:
Elmar Kresse
2023-09-19 21:34:29 +02:00
parent b8a638a5fe
commit c051995823
87 changed files with 4987 additions and 1574 deletions

View File

@@ -0,0 +1,12 @@
package events
import (
"github.com/labstack/echo/v5"
"github.com/pocketbase/pocketbase"
"htwk-planner/service/db"
)
func GetAllCourses(app *pocketbase.PocketBase, c echo.Context) error {
courses := db.GetAllCourses(app)
return c.JSON(200, courses)
}

View File

@@ -0,0 +1,63 @@
package events
import (
"github.com/labstack/echo/v5"
"github.com/pocketbase/pocketbase"
"htwk-planner/service/db"
"unicode"
)
func GetModulesForCourseDistinct(app *pocketbase.PocketBase, c echo.Context, course string, semester string) error {
modules, err := db.GetAllModulesForCourse(app, course, semester)
replaceEmptyEntryInStringArray(modules, "Sonderveranstaltungen")
if err != nil {
return c.JSON(400, err)
} else {
return c.JSON(200, modules)
}
}
func replaceEmptyEntryInStringArray(modules []string, replacement string) {
//replace empty string with "Sonderveranstaltungen"
for i, module := range modules {
if checkIfOnlyWhitespace(module) {
modules[i] = replacement
}
}
}
func replaceEmptyEntry(modules []struct {
Name string
Course string
}, replacement string) {
//replace empty string with "Sonderveranstaltungen"
for i, module := range modules {
if checkIfOnlyWhitespace(module.Name) {
modules[i].Name = replacement
}
}
}
// check if course is empty or contains only whitespaces
func checkIfOnlyWhitespace(word string) bool {
for _, letter := range word {
if !unicode.IsSpace(letter) || !(letter == int32(160)) {
return false
}
}
return true
}
func GetAllModulesDistinct(app *pocketbase.PocketBase, c echo.Context) error {
modules, err := db.GetAllModulesDistinct(app)
replaceEmptyEntry(modules, "Sonderveranstaltungen")
if err != nil {
return c.JSON(400, err)
} else {
return c.JSON(200, modules)
}
}