feat: add user credentials management and health monitoring features
Docker / Docker Build & Push (push) Failing after 28s
Lint / Lint (push) Failing after 6s
Tests / Go backend (push) Failing after 4s
Tests / Dashboard checks (push) Failing after 6s

- Implemented CredentialsDialog for updating user credentials.
- Created auth store with functions for managing authentication state.
- Added HealthWidget to display server health status.
- Introduced health monitoring functionality with polling.
- Developed AppShell layout to manage authentication and loading states.
- Added SettingsDialog for user preferences including theme and language.
- Created utility functions for list management and data fetching.
- Implemented dashboard view mode preferences.
- Integrated search functionality for filtering lists.
- Established theme management with local storage support.
- Added utility functions for class name management.
- Configured SvelteKit for static site generation with fallback.
- Set up Vite for development with proxy support for API calls.
- Created About and List detail pages with data fetching and display.
- Added favicon and updated project configuration files.
This commit is contained in:
Gabriel20xx committed 2026-08-03 22:38:45 +02:00
1 parent a4a3eeb5cc
commit 6c1ea2da47
80 files changed

No files matched your search

+141
View File
@@ -0,0 +1,141 @@
package main
import (
"net/http"
"strconv"
"time"
)
func (s *Server) handleWebData(w http.ResponseWriter, r *http.Request, _ *AuthUser) {
lists, err := s.db.queryLists(r.Context(), false, nil)
if err != nil {
writeJSONError(w, http.StatusInternalServerError, "Failed to fetch data")
return
}
fields, err := s.db.queryFields(r.Context(), false, nil, "")
if err != nil {
writeJSONError(w, http.StatusInternalServerError, "Failed to fetch data")
return
}
items, err := s.db.queryItems(r.Context(), false, nil, "")
if err != nil {
writeJSONError(w, http.StatusInternalServerError, "Failed to fetch data")
return
}
values, err := s.db.queryValues(r.Context(), nil, "")
if err != nil {
writeJSONError(w, http.StatusInternalServerError, "Failed to fetch data")
return
}
itemToList := make(map[string]string, len(items))
for _, item := range items {
itemToList[item.ID] = item.ListID
}
fieldMax := make(map[string]int64)
for _, field := range fields {
if int64(field.UpdatedAt) > fieldMax[field.ListID] {
fieldMax[field.ListID] = int64(field.UpdatedAt)
}
}
itemMax := make(map[string]int64)
for _, item := range items {
if int64(item.UpdatedAt) > itemMax[item.ListID] {
itemMax[item.ListID] = int64(item.UpdatedAt)
}
}
valueMax := make(map[string]int64)
for _, value := range values {
listID := itemToList[value.ItemID]
if listID != "" && int64(value.UpdatedAt) > valueMax[listID] {
valueMax[listID] = int64(value.UpdatedAt)
}
}
type webList struct {
List
EffectiveUpdatedAt int64 `json:"effectiveUpdatedAt"`
}
webLists := make([]webList, 0, len(lists))
for _, list := range lists {
effective := int64(list.UpdatedAt)
if fieldMax[list.ID] > effective {
effective = fieldMax[list.ID]
}
if itemMax[list.ID] > effective {
effective = itemMax[list.ID]
}
if valueMax[list.ID] > effective {
effective = valueMax[list.ID]
}
webLists = append(webLists, webList{List: list, EffectiveUpdatedAt: effective})
}
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Expires", "0")
writeJSON(w, http.StatusOK, map[string]any{
"lists": webLists,
"fields": fields,
"items": items,
"values": values,
"stats": map[string]int{
"lists": len(lists),
"fields": len(fields),
"items": len(items),
"values": len(values),
},
"timestamp": time.Now().UnixMilli(),
})
}
func (s *Server) handleNotificationPoll(w http.ResponseWriter, r *http.Request) {
since, err := strconv.ParseInt(r.URL.Query().Get("since"), 10, 64)
if err != nil || since < 0 {
since = 0
}
deviceID := requestDeviceID(r, "")
query := `
SELECT id, deviceidorigin, eventtype, entitytype, entityid, listid, createdat
FROM notifications
WHERE createdat > $1
`
args := []any{since}
if deviceID != "" {
query += ` AND (deviceidorigin IS NULL OR deviceidorigin <> $2)`
args = append(args, deviceID)
}
query += ` ORDER BY createdat ASC LIMIT 500`
rows, err := s.db.pool.Query(r.Context(), query, args...)
if err != nil {
writeJSONError(w, http.StatusInternalServerError, "Failed to poll notifications")
return
}
defer rows.Close()
events := make([]NotificationEvent, 0)
for rows.Next() {
var event NotificationEvent
var origin, entityID, listID *string
if err := rows.Scan(&event.ID, &origin, &event.EventType, &event.EntityType, &entityID, &listID, &event.CreatedAt); err != nil {
writeJSONError(w, http.StatusInternalServerError, "Failed to poll notifications")
return
}
if origin != nil {
event.DeviceIDOrigin = *origin
}
if entityID != nil {
event.EntityID = *entityID
}
if listID != nil {
event.ListID = *listID
}
events = append(events, event)
}
if err := rows.Err(); err != nil {
writeJSONError(w, http.StatusInternalServerError, "Failed to poll notifications")
return
}
writeJSON(w, http.StatusOK, PollResponse{Notifications: events, ServerTimestamp: time.Now().UnixMilli()})
}