Merge pull request 'dev' (#31) from dev into main
Reviewed-on: https://codeberg.org/RhemaWave-Technologies/RhemaWave/pulls/31
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"slices"
|
||||
"github.com/go-gl/gl/v3.3-core/gl"
|
||||
"github.com/go-gl/mathgl/mgl32"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
@@ -53,12 +53,15 @@ func (p *LogViewerPage) Init(ctx *PageCtx) error {
|
||||
// wrapped := wrapText(formatted, 100)
|
||||
// p.lines = append(p.lines, strings.Split(wrapped, "\n")...)
|
||||
// }
|
||||
|
||||
displayLevels := []string{"WARNING", "ERROR", "FATAL"}
|
||||
|
||||
for _, entry := range logs {
|
||||
logTime := time.UnixMilli(entry.Timestamp)
|
||||
timeStr := logTime.Format("2006-01-02 15:04:05")
|
||||
line := fmt.Sprintf("[%s] [%s] %s", timeStr, entry.Level, entry.Message)
|
||||
p.lines = append(p.lines, line)
|
||||
if slices.Contains(displayLevels, entry.Level) {
|
||||
logTime := time.UnixMilli(entry.Timestamp)
|
||||
timeStr := logTime.Format("2006-01-02 15:04")
|
||||
line := fmt.Sprintf("[%s] [%s] %s", timeStr, entry.Level, entry.Message)
|
||||
p.lines = append(p.lines, line)
|
||||
}
|
||||
}
|
||||
|
||||
applicationFont := "Roboto-Regular"
|
||||
|
||||
@@ -81,9 +81,15 @@ func (p *ProclamationOptions) Init(ctx *PageCtx) error {
|
||||
p.isSearchActive = false
|
||||
p.scrollTrackWidth = 30
|
||||
p.scrollTrackX = p.ScreenWidth - p.scrollTrackWidth
|
||||
|
||||
var err error
|
||||
|
||||
// Syncronize proclamations first
|
||||
sync.SyncProclamations(ctx.DbPtr)
|
||||
var allProcs []db.Proclamation
|
||||
allProcs, err = sync.SyncProclamations(ctx.DbPtr)
|
||||
if err != nil {
|
||||
// sync failed, fallback to database
|
||||
ctx.DbPtr.Find(&allProcs)
|
||||
}
|
||||
|
||||
fm := fontManager.Get()
|
||||
font, _ := fm.GetFont("Roboto-Regular")
|
||||
@@ -108,7 +114,7 @@ func (p *ProclamationOptions) Init(ctx *PageCtx) error {
|
||||
|
||||
// Load current selections
|
||||
var selected []db.Proclamation
|
||||
p.Context.DbPtr.Where("selected = ?", true).Where("id != ?", defaultProclamationID).Find(&selected)
|
||||
ctx.DbPtr.Where("selected = ?", true).Where("id != ?", defaultProclamationID).Find(&selected)
|
||||
for _, s := range selected {
|
||||
if s.ID == defaultProclamationID {
|
||||
logger.Debug("Found default proclamation in selected list: %s", s.ID)
|
||||
@@ -116,13 +122,6 @@ func (p *ProclamationOptions) Init(ctx *PageCtx) error {
|
||||
p.activeMap[s.ID] = true
|
||||
}
|
||||
|
||||
// Load ALL proclamations into a lookup map for SearchText population
|
||||
var allProcs []db.Proclamation
|
||||
if err := p.Context.DbPtr.Where("id != ?", defaultProclamationID).Find(&allProcs).Error; err != nil {
|
||||
logger.Error("Failed to fetch proclamations: %s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
procContentMap := make(map[string]string, len(allProcs))
|
||||
for _, pr := range allProcs {
|
||||
if pr.ID == defaultProclamationID {
|
||||
|
||||
@@ -95,7 +95,7 @@ func (p *WiFiSetupPage) Init(ctx *PageCtx) error {
|
||||
}
|
||||
for _, dev := range p.networkManager.Devices {
|
||||
if dev.Type == network.TypeWifi {
|
||||
d := dev
|
||||
d := dev
|
||||
p.wifiDevice = &d
|
||||
break
|
||||
}
|
||||
@@ -198,13 +198,14 @@ func (p *WiFiSetupPage) handlePasswordInput(sym sdl.Keycode, mod uint16) {
|
||||
switch sym {
|
||||
|
||||
case sdl.K_RETURN:
|
||||
p.exitPasswordMode()
|
||||
p.exitPasswordMode()
|
||||
|
||||
p.pendingSSID = p.selectedAP.SSID
|
||||
p.isConnecting = true
|
||||
p.connectionError = ""
|
||||
p.connectionAttemptTime = time.Now()
|
||||
|
||||
|
||||
|
||||
err := p.networkManager.Connect(*p.wifiDevice, *p.selectedAP, p.passwordInput)
|
||||
if err != nil {
|
||||
p.isConnecting = false
|
||||
@@ -383,7 +384,7 @@ func (p *WiFiSetupPage) Update(dt float32) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// handleConnectionStatusUpdate checks if connection succeeded or failed
|
||||
// handleConnectionStatusUpdate CHECKS0 if connection succeeded or failed
|
||||
func (p *WiFiSetupPage) handleConnectionStatusUpdate(status *network.ConnectionStatus) {
|
||||
if !p.isConnecting {
|
||||
return
|
||||
@@ -411,48 +412,50 @@ func (p *WiFiSetupPage) handleConnectionStatusUpdate(status *network.ConnectionS
|
||||
// INCREASE THIS: 5 seconds is way too aggressive.
|
||||
// Give it at least 20 seconds before assuming the password was wrong.
|
||||
if time.Since(p.connectionAttemptTime) > 20*time.Second {
|
||||
p.isConnecting = false
|
||||
p.connectionError = "Connection failed - Check password or signal"
|
||||
p.isEnteringPassword = true
|
||||
p.enterPasswordMode()
|
||||
p.updatePasswordErrorTexture()
|
||||
if time.Since(p.connectionAttemptTime) > 15*time.Second {
|
||||
p.isConnecting = false
|
||||
p.connectionError = "Connection failed - Check password or signal"
|
||||
p.isEnteringPassword = true
|
||||
p.enterPasswordMode()
|
||||
p.updatePasswordErrorTexture()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getActiveSSID queries NetworkManager for the currently active WiFi SSID
|
||||
// getAiveSSID queries NetworkManager for the currently active WiFi SSID
|
||||
func (p *WiFiSetupPage) getActiveSSID() string {
|
||||
if p.networkManager == nil || p.wifiDevice == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
nmObj := p.networkManager.Conn().Object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
|
||||
prop, err := nmObj.GetProperty("org.freedesktop.NetworkManager.ActiveConnections")
|
||||
conn := p.networkManager.Conn()
|
||||
|
||||
devObj := conn.Object("org.freedesktop.NetworkManager", p.wifiDevice.Path)
|
||||
activeApProp, err := devObj.GetProperty("org.freedesktop.NetworkManager.Device.Wireless.ActiveAccessPoint")
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
if paths, ok := prop.Value().([]dbus.ObjectPath); ok {
|
||||
for _, path := range paths {
|
||||
acObj := p.networkManager.Conn().Object("org.freedesktop.NetworkManager", path)
|
||||
devProp, err := acObj.GetProperty("org.freedesktop.NetworkManager.Connection.Active.Devices")
|
||||
if err == nil {
|
||||
if devPaths, ok := devProp.Value().([]dbus.ObjectPath); ok {
|
||||
for _, devPath := range devPaths {
|
||||
if string(devPath) == string(p.wifiDevice.Path) {
|
||||
idProp, err := acObj.GetProperty("org.freedesktop.NetworkManager.Connection.Active.Id")
|
||||
if err == nil {
|
||||
if id, ok := idProp.Value().(string); ok {
|
||||
return id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
activeApPath, ok := activeApProp.Value().(dbus.ObjectPath)
|
||||
if !ok || activeApPath == "/" || activeApPath == "" {
|
||||
return ""
|
||||
}
|
||||
return ""
|
||||
|
||||
apObj := conn.Object("org.freedesktop.NetworkManager", activeApPath)
|
||||
ssidProp, err := apObj.GetProperty("org.freedesktop.NetworkManager.AccessPoint.Ssid")
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
ssidBytes, ok := ssidProp.Value().([]byte)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
|
||||
logger.Info("Active SSID: %s", string(ssidBytes))
|
||||
|
||||
return string(ssidBytes)
|
||||
}
|
||||
|
||||
// refreshNetworkColors updates the colors of network items based on active status
|
||||
|
||||
@@ -33,6 +33,7 @@ func SyncProclamations(database *gorm.DB) ([]db.Proclamation, error) {
|
||||
|
||||
var storedProclamationSettings []db.Proclamation
|
||||
database.Select("ID", "Selected").Find(&storedProclamationSettings)
|
||||
|
||||
// [ID]Selected
|
||||
stash := make(map[string]bool)
|
||||
for _, row := range storedProclamationSettings {
|
||||
@@ -76,6 +77,7 @@ func SyncProclamations(database *gorm.DB) ([]db.Proclamation, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// Return nil as err for this statement, does not exit the function
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user