Menu and meal upgrades, fixed base64 images
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
@@ -15,6 +15,10 @@ angular.module('mealMenuApp', ['ngSanitize'])
|
||||
$scope.selectedWeek = getWeek(today);
|
||||
$scope.selectedYear = today.getFullYear();
|
||||
$scope.daysOfWeek = ["Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag", "Söndag"];
|
||||
const savedViewMode = localStorage.getItem('mealViewMode');
|
||||
if (savedViewMode === 'list' || savedViewMode === 'card') {
|
||||
$scope.viewMode = savedViewMode;
|
||||
}
|
||||
|
||||
$scope.loadMeals = function () {
|
||||
console.log("Hämtar måltider...");
|
||||
@@ -53,17 +57,23 @@ angular.module('mealMenuApp', ['ngSanitize'])
|
||||
const nameKey = capitalType + 'MealName';
|
||||
|
||||
if (item[idKey]) {
|
||||
const m = $scope.meals.find(x => x.Id === item[idKey]);
|
||||
const m = $scope.meals.find(x => x.Id == item[idKey]);
|
||||
console.log(`Match för ${type} (${day}):`, m);
|
||||
|
||||
$scope.menu[day][type + 'MealId'] = item[idKey];
|
||||
$scope.menu[day][type + 'MealName'] = m?.Name || item[nameKey] || 'Okänd rätt';
|
||||
|
||||
if (m?.ImageUrl && !$scope.menu[day].imageUrl) {
|
||||
$scope.menu[day].imageUrl = m.ImageUrl.startsWith('/')
|
||||
? m.ImageUrl
|
||||
: '/' + m.ImageUrl;
|
||||
if (m && !$scope.menu[day].imageUrl) {
|
||||
if (m.ImageData) {
|
||||
const mime = m.ImageMimeType || "image/jpeg";
|
||||
$scope.menu[day].imageUrl = `data:${mime};base64,${m.ImageData}`;
|
||||
} else if (m.ImageUrl) {
|
||||
$scope.menu[day].imageUrl = m.ImageUrl.startsWith('/')
|
||||
? m.ImageUrl
|
||||
: '/' + m.ImageUrl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -78,18 +88,7 @@ angular.module('mealMenuApp', ['ngSanitize'])
|
||||
};
|
||||
|
||||
$scope.getDayImage = function (day) {
|
||||
const item = $scope.menu[day];
|
||||
const img = item?.imageUrl;
|
||||
|
||||
if (img && img.startsWith('/')) {
|
||||
return img;
|
||||
}
|
||||
|
||||
if (img && !img.startsWith('/')) {
|
||||
return '/' + img; // Fixa ev. saknad inledande snedstreck
|
||||
}
|
||||
|
||||
return '/images/default-meal.jpg';
|
||||
return $scope.menu[day]?.imageUrl || '/images/default-meal.jpg';
|
||||
};
|
||||
|
||||
$scope.getMealIdByDay = function (day) {
|
||||
@@ -130,7 +129,8 @@ angular.module('mealMenuApp', ['ngSanitize'])
|
||||
|
||||
$scope.toggleView = function () {
|
||||
$scope.viewMode = $scope.viewMode === 'list' ? 'card' : 'list';
|
||||
// Uppdatera knappens ikon
|
||||
localStorage.setItem('mealViewMode', $scope.viewMode); // ← spara läget
|
||||
|
||||
setTimeout(() => {
|
||||
const btn = document.getElementById('toggle-view');
|
||||
if (btn) {
|
||||
@@ -140,6 +140,7 @@ angular.module('mealMenuApp', ['ngSanitize'])
|
||||
};
|
||||
|
||||
|
||||
|
||||
console.log("Initierar måltidsladdning...");
|
||||
$scope.loadMeals().then(() => {
|
||||
console.log("Laddar meny efter måltider...");
|
||||
|
||||
Reference in New Issue
Block a user