Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac849d2eb1 | ||
|
|
80cb152b73 | ||
|
|
919642a189 | ||
|
|
3f9a043324 |
14
app.go
14
app.go
@@ -373,6 +373,20 @@ func (a *App) DownloadUpdate() (string, error) {
|
|||||||
return a.updater.DownloadUpdate(*info)
|
return a.updater.DownloadUpdate(*info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PDF EXPORT
|
||||||
|
|
||||||
|
// ExportPDF erstellt eine PDF-Datei des Wochenplans
|
||||||
|
// getWeekPlanByID lädt einen Wochenplan anhand seiner ID
|
||||||
|
func (a *App) getWeekPlanByID(id int) (*WeekPlan, error) {
|
||||||
|
var plan WeekPlan
|
||||||
|
query := "SELECT id, year, week, created_at FROM week_plans WHERE id = ?"
|
||||||
|
err := db.Get(&plan, query, id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get week plan by ID: %w", err)
|
||||||
|
}
|
||||||
|
return &plan, nil
|
||||||
|
}
|
||||||
|
|
||||||
// HILFSFUNKTIONEN
|
// HILFSFUNKTIONEN
|
||||||
|
|
||||||
// loadProductRelations lädt Allergene und Zusatzstoffe für ein Produkt
|
// loadProductRelations lädt Allergene und Zusatzstoffe für ein Produkt
|
||||||
|
|||||||
BIN
build/windows/MicrosoftEdgeWebview2Setup.exe
Normal file
BIN
build/windows/MicrosoftEdgeWebview2Setup.exe
Normal file
Binary file not shown.
@@ -12,7 +12,7 @@ RequestExecutionLevel admin
|
|||||||
!define MUI_UNICON "icon.ico"
|
!define MUI_UNICON "icon.ico"
|
||||||
!define MUI_ABORTWARNING
|
!define MUI_ABORTWARNING
|
||||||
!define MUI_WELCOMEPAGE_TITLE "Speiseplan Setup"
|
!define MUI_WELCOMEPAGE_TITLE "Speiseplan Setup"
|
||||||
!define MUI_WELCOMEPAGE_TEXT "Dieses Programm installiert den Kita-Wochenspeiseplan auf Ihrem Computer.$\r$\n$\r$\nKlicken Sie auf Weiter, um fortzufahren."
|
!define MUI_WELCOMEPAGE_TEXT "Dieses Programm installiert den Kita-Wochenspeiseplan auf Ihrem Computer.$\r$\n$\r$\nBenötigte Komponenten (WebView2) werden automatisch mitinstalliert.$\r$\n$\r$\nKlicken Sie auf Weiter, um fortzufahren."
|
||||||
|
|
||||||
; Seiten
|
; Seiten
|
||||||
!insertmacro MUI_PAGE_WELCOME
|
!insertmacro MUI_PAGE_WELCOME
|
||||||
@@ -28,6 +28,30 @@ RequestExecutionLevel admin
|
|||||||
; Sprache
|
; Sprache
|
||||||
!insertmacro MUI_LANGUAGE "German"
|
!insertmacro MUI_LANGUAGE "German"
|
||||||
|
|
||||||
|
; WebView2 Check Funktion
|
||||||
|
Function CheckWebView2
|
||||||
|
; Prüfe ob WebView2 bereits installiert ist
|
||||||
|
ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
|
||||||
|
${If} $0 == ""
|
||||||
|
ReadRegStr $0 HKCU "SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
|
||||||
|
${EndIf}
|
||||||
|
${If} $0 == ""
|
||||||
|
; WebView2 nicht gefunden — installieren
|
||||||
|
DetailPrint "WebView2 Runtime wird installiert..."
|
||||||
|
SetOutPath "$TEMP"
|
||||||
|
File "MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
ExecWait '"$TEMP\MicrosoftEdgeWebview2Setup.exe" /silent /install' $1
|
||||||
|
${If} $1 != 0
|
||||||
|
MessageBox MB_OK|MB_ICONEXCLAMATION "WebView2 konnte nicht installiert werden (Fehler: $1).$\r$\nBitte installieren Sie es manuell von https://developer.microsoft.com/microsoft-edge/webview2/"
|
||||||
|
${Else}
|
||||||
|
DetailPrint "WebView2 Runtime erfolgreich installiert."
|
||||||
|
${EndIf}
|
||||||
|
Delete "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
${Else}
|
||||||
|
DetailPrint "WebView2 Runtime bereits installiert (Version: $0)."
|
||||||
|
${EndIf}
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
; Hauptinstallation
|
; Hauptinstallation
|
||||||
Section "Speiseplan (erforderlich)" SecMain
|
Section "Speiseplan (erforderlich)" SecMain
|
||||||
SectionIn RO
|
SectionIn RO
|
||||||
@@ -35,9 +59,15 @@ Section "Speiseplan (erforderlich)" SecMain
|
|||||||
File "..\..\build\bin\speiseplan.exe"
|
File "..\..\build\bin\speiseplan.exe"
|
||||||
File "icon.ico"
|
File "icon.ico"
|
||||||
|
|
||||||
|
; WebView2 prüfen und ggf. installieren
|
||||||
|
Call CheckWebView2
|
||||||
|
|
||||||
; Registry
|
; Registry
|
||||||
WriteRegStr HKLM "Software\Speiseplan" "Install_Dir" "$INSTDIR"
|
WriteRegStr HKLM "Software\Speiseplan" "Install_Dir" "$INSTDIR"
|
||||||
|
WriteRegStr HKLM "Software\Speiseplan" "Version" "0.4.7"
|
||||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Speiseplan" "DisplayName" "Speiseplan"
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Speiseplan" "DisplayName" "Speiseplan"
|
||||||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Speiseplan" "DisplayVersion" "0.4.7"
|
||||||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Speiseplan" "Publisher" "Kita Ortrand"
|
||||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Speiseplan" "DisplayIcon" "$INSTDIR\icon.ico"
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Speiseplan" "DisplayIcon" "$INSTDIR\icon.ico"
|
||||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Speiseplan" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Speiseplan" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Speiseplan" "NoModify" 1
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Speiseplan" "NoModify" 1
|
||||||
@@ -57,7 +87,7 @@ SectionEnd
|
|||||||
|
|
||||||
; Komponentenbeschreibungen
|
; Komponentenbeschreibungen
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SecMain} "Das Speiseplan-Programm (erforderlich)."
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecMain} "Das Speiseplan-Programm (erforderlich). WebView2 wird automatisch mitinstalliert."
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "Erstellt eine Verknüpfung auf dem Desktop."
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "Erstellt eine Verknüpfung auf dem Desktop."
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Layout, useSelectedWeek } from './components/Layout';
|
|||||||
import { WeekPlanner } from './components/WeekPlanner';
|
import { WeekPlanner } from './components/WeekPlanner';
|
||||||
import { ProductList } from './components/ProductList';
|
import { ProductList } from './components/ProductList';
|
||||||
import { InfoPage } from './components/InfoPage';
|
import { InfoPage } from './components/InfoPage';
|
||||||
|
import { ErrorBoundary } from './components/ErrorBoundary';
|
||||||
import { useProducts } from './hooks/useProducts';
|
import { useProducts } from './hooks/useProducts';
|
||||||
import './styles/globals.css';
|
import './styles/globals.css';
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ function ProductsPage() {
|
|||||||
// Main App Component
|
// Main App Component
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
|
<ErrorBoundary>
|
||||||
<Router>
|
<Router>
|
||||||
<div className="App min-h-screen bg-gray-50 text-contrast-aa">
|
<div className="App min-h-screen bg-gray-50 text-contrast-aa">
|
||||||
<Routes>
|
<Routes>
|
||||||
@@ -87,6 +89,7 @@ function App() {
|
|||||||
</Routes>
|
</Routes>
|
||||||
</div>
|
</div>
|
||||||
</Router>
|
</Router>
|
||||||
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
58
frontend/src/components/ErrorBoundary.tsx
Normal file
58
frontend/src/components/ErrorBoundary.tsx
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import { Component, ErrorInfo, ReactNode } from 'react';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface State {
|
||||||
|
hasError: boolean;
|
||||||
|
error: Error | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ErrorBoundary extends Component<Props, State> {
|
||||||
|
constructor(props: Props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { hasError: false, error: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
static getDerivedStateFromError(error: Error): State {
|
||||||
|
return { hasError: true, error };
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||||
|
console.error('ErrorBoundary caught:', error, errorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.state.hasError) {
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen flex items-center justify-center bg-gray-50 p-8">
|
||||||
|
<div className="text-center max-w-md">
|
||||||
|
<svg className="mx-auto h-16 w-16 text-red-400 mb-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.996-.833-2.764 0L3.732 16c-.77.833.192 2.5 1.732 2.5z" />
|
||||||
|
</svg>
|
||||||
|
<h1 className="text-2xl font-bold text-gray-900 mb-2">
|
||||||
|
Etwas ist schiefgelaufen
|
||||||
|
</h1>
|
||||||
|
<p className="text-gray-600 mb-6">
|
||||||
|
Ein unerwarteter Fehler ist aufgetreten. Bitte laden Sie die Seite neu.
|
||||||
|
</p>
|
||||||
|
{this.state.error && (
|
||||||
|
<p className="text-sm text-red-600 mb-6 font-mono bg-red-50 p-3 rounded">
|
||||||
|
{this.state.error.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<button
|
||||||
|
onClick={() => window.location.reload()}
|
||||||
|
className="px-6 py-3 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors text-lg"
|
||||||
|
>
|
||||||
|
Seite neu laden
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.props.children;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -79,7 +79,7 @@ export function InfoPage() {
|
|||||||
<div>
|
<div>
|
||||||
<dt className="text-sm font-medium text-gray-500">Version</dt>
|
<dt className="text-sm font-medium text-gray-500">Version</dt>
|
||||||
<dd className="mt-1 text-sm text-gray-900 font-mono">
|
<dd className="mt-1 text-sm text-gray-900 font-mono">
|
||||||
{updateInfo?.current_version || '1.0.0'}
|
{updateInfo?.current_version || '0.4.5'}
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ export function InfoPage() {
|
|||||||
|
|
||||||
<div className="text-sm text-gray-600 space-y-2">
|
<div className="text-sm text-gray-600 space-y-2">
|
||||||
<p>
|
<p>
|
||||||
<strong>Version:</strong> 1.0.0 (Build 2026.02.20)
|
<strong>Version:</strong> 0.4.5 (Build 2026.02.20)
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<strong>Support:</strong> Wenden Sie sich bei Fragen oder Problemen an Ihre IT-Abteilung
|
<strong>Support:</strong> Wenden Sie sich bei Fragen oder Problemen an Ihre IT-Abteilung
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ export function WeekPlanner({ year, week, className = '' }: WeekPlannerProps) {
|
|||||||
setPdfSuccess(null);
|
setPdfSuccess(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// ExportPDF nimmt weekPlanID und outputPath - Go-Seite öffnet Save-Dialog mit leer-string
|
|
||||||
await ExportPDF(weekPlan.id, '');
|
await ExportPDF(weekPlan.id, '');
|
||||||
setPdfSuccess('PDF wurde erfolgreich erstellt.');
|
setPdfSuccess('PDF wurde erfolgreich erstellt.');
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export function useProducts() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const productList = await GetProducts();
|
const productList = await GetProducts();
|
||||||
setProducts(productList);
|
setProducts(productList || []);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : 'Fehler beim Laden der Produkte');
|
setError(err instanceof Error ? err.message : 'Fehler beim Laden der Produkte');
|
||||||
} finally {
|
} finally {
|
||||||
@@ -35,8 +35,8 @@ export function useProducts() {
|
|||||||
GetAdditives()
|
GetAdditives()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
setAllergens(allergenList);
|
setAllergens(allergenList || []);
|
||||||
setAdditives(additiveList);
|
setAdditives(additiveList || []);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : 'Fehler beim Laden der Stammdaten');
|
setError(err instanceof Error ? err.message : 'Fehler beim Laden der Stammdaten');
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,9 @@ export function useProducts() {
|
|||||||
data.additiveIds
|
data.additiveIds
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (newProduct) {
|
||||||
setProducts(prev => [...prev, newProduct]);
|
setProducts(prev => [...prev, newProduct]);
|
||||||
|
}
|
||||||
return newProduct;
|
return newProduct;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : 'Fehler beim Erstellen des Produkts');
|
setError(err instanceof Error ? err.message : 'Fehler beim Erstellen des Produkts');
|
||||||
@@ -90,7 +92,9 @@ export function useProducts() {
|
|||||||
data.additiveIds
|
data.additiveIds
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (updatedProduct) {
|
||||||
setProducts(prev => prev.map(p => p.id === id ? updatedProduct : p));
|
setProducts(prev => prev.map(p => p.id === id ? updatedProduct : p));
|
||||||
|
}
|
||||||
return updatedProduct;
|
return updatedProduct;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : 'Fehler beim Bearbeiten des Produkts');
|
setError(err instanceof Error ? err.message : 'Fehler beim Bearbeiten des Produkts');
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ export function useWeekPlan(year: number, week: number) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const plan = await GetWeekPlan(year, week);
|
const plan = await GetWeekPlan(year, week);
|
||||||
|
// Null-Safety: Go kann null für leere Arrays zurückgeben
|
||||||
|
if (plan) {
|
||||||
|
plan.entries = plan.entries || [];
|
||||||
|
plan.special_days = plan.special_days || [];
|
||||||
|
}
|
||||||
setWeekPlan(plan);
|
setWeekPlan(plan);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : 'Fehler beim Laden des Wochenplans');
|
setError(err instanceof Error ? err.message : 'Fehler beim Laden des Wochenplans');
|
||||||
@@ -35,6 +40,10 @@ export function useWeekPlan(year: number, week: number) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const newPlan = await CreateWeekPlan(year, week);
|
const newPlan = await CreateWeekPlan(year, week);
|
||||||
|
if (newPlan) {
|
||||||
|
newPlan.entries = newPlan.entries || [];
|
||||||
|
newPlan.special_days = newPlan.special_days || [];
|
||||||
|
}
|
||||||
setWeekPlan(newPlan);
|
setWeekPlan(newPlan);
|
||||||
return newPlan;
|
return newPlan;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -52,6 +61,10 @@ export function useWeekPlan(year: number, week: number) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const copiedPlan = await CopyWeekPlan(srcYear, srcWeek, year, week);
|
const copiedPlan = await CopyWeekPlan(srcYear, srcWeek, year, week);
|
||||||
|
if (copiedPlan) {
|
||||||
|
copiedPlan.entries = copiedPlan.entries || [];
|
||||||
|
copiedPlan.special_days = copiedPlan.special_days || [];
|
||||||
|
}
|
||||||
setWeekPlan(copiedPlan);
|
setWeekPlan(copiedPlan);
|
||||||
return copiedPlan;
|
return copiedPlan;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -73,13 +86,22 @@ export function useWeekPlan(year: number, week: number) {
|
|||||||
if (!weekPlan) return null;
|
if (!weekPlan) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const newEntry = await AddPlanEntry(weekPlan.id, day, meal, productId, customText, groupLabel);
|
// Go erwartet null statt undefined für optionale Pointer-Parameter
|
||||||
|
const newEntry = await AddPlanEntry(
|
||||||
|
weekPlan.id,
|
||||||
|
day,
|
||||||
|
meal,
|
||||||
|
productId ?? null,
|
||||||
|
customText ?? null,
|
||||||
|
groupLabel ?? null
|
||||||
|
);
|
||||||
|
|
||||||
// State aktualisieren
|
if (newEntry) {
|
||||||
setWeekPlan(prev => prev ? {
|
setWeekPlan(prev => prev ? {
|
||||||
...prev,
|
...prev,
|
||||||
entries: [...prev.entries, newEntry]
|
entries: [...prev.entries, newEntry]
|
||||||
} : null);
|
} : null);
|
||||||
|
}
|
||||||
|
|
||||||
return newEntry;
|
return newEntry;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -114,13 +136,15 @@ export function useWeekPlan(year: number, week: number) {
|
|||||||
groupLabel?: GroupLabel
|
groupLabel?: GroupLabel
|
||||||
): Promise<PlanEntry | null> => {
|
): Promise<PlanEntry | null> => {
|
||||||
try {
|
try {
|
||||||
const updatedEntry = await UpdatePlanEntry(entryId, 0, '', 0, productId ?? null, customText ?? null, groupLabel ?? null);
|
// Go: UpdatePlanEntry(id int, productID *int, customText *string, groupLabel *string)
|
||||||
|
const updatedEntry = await UpdatePlanEntry(entryId, productId ?? null, customText ?? null, groupLabel ?? null);
|
||||||
|
|
||||||
// State aktualisieren
|
if (updatedEntry) {
|
||||||
setWeekPlan(prev => prev ? {
|
setWeekPlan(prev => prev ? {
|
||||||
...prev,
|
...prev,
|
||||||
entries: prev.entries.map(e => e.id === entryId ? updatedEntry : e)
|
entries: prev.entries.map(e => e.id === entryId ? updatedEntry : e)
|
||||||
} : null);
|
} : null);
|
||||||
|
}
|
||||||
|
|
||||||
return updatedEntry;
|
return updatedEntry;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// Aktuelle Version der App
|
// Aktuelle Version der App
|
||||||
CurrentVersion = "0.4.3"
|
CurrentVersion = "0.4.5"
|
||||||
// Update-Check URL
|
// Update-Check URL
|
||||||
UpdateURL = "https://speiseplan.supertoll.xyz/version.json"
|
UpdateURL = "https://speiseplan.supertoll.xyz/version.json"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user