Ny meals!
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
elias
2025-06-05 23:23:36 +02:00
parent bc77e39c72
commit b286fed88a
7 changed files with 398 additions and 92 deletions

View File

@@ -44,7 +44,54 @@ angular.module('mealMenuApp', ['ngSanitize'])
});
}).catch(err => console.error("Fel vid hämtning av meny:", err));
$scope.loadSchoolMeals(); // Lägg till här
};
$scope.schoolMeals = [];
$scope.schoolMealsBySchool = [];
$scope.schoolSensors = [
{ name: "William Engelbrektsskolan", entity: "sensor.engelbrektsskolan" },
{ name: "Louise - Nyeds skolan", entity: "sensor.nyedsskola" },
{ name: "Ludwig - Skogsgläntan", entity: "sensor.skogsglantan" }
];
$scope.schoolMealsBySchool = [];
$scope.loadSchoolMeals = function () {
const savedExpanded = JSON.parse(localStorage.getItem("expandedSchools") || "{}");
$scope.schoolMealsBySchool = $scope.schoolSensors.map(sensor => ({
name: sensor.name,
entity: sensor.entity,
days: [],
expanded: savedExpanded[sensor.entity] || false
}));
$scope.schoolMealsBySchool.forEach(school => {
$http.get(`/api/mealmenuapi/skolmat?week=${$scope.selectedWeek}&sensor=${school.entity}`)
.then(res => {
school.days = res.data;
})
.catch(() => {
school.days = [];
});
});
};
$scope.toggleSchoolExpanded = function (school) {
school.expanded = !school.expanded;
const expandedState = {};
$scope.schoolMealsBySchool.forEach(s => {
expandedState[s.entity] = s.expanded;
});
localStorage.setItem("expandedSchools", JSON.stringify(expandedState));
};
$scope.openMeal = function (mealId) {
if (!mealId) return;