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"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"slices"
|
||||||
"github.com/go-gl/gl/v3.3-core/gl"
|
"github.com/go-gl/gl/v3.3-core/gl"
|
||||||
"github.com/go-gl/mathgl/mgl32"
|
"github.com/go-gl/mathgl/mgl32"
|
||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
@@ -53,12 +53,15 @@ func (p *LogViewerPage) Init(ctx *PageCtx) error {
|
|||||||
// wrapped := wrapText(formatted, 100)
|
// wrapped := wrapText(formatted, 100)
|
||||||
// p.lines = append(p.lines, strings.Split(wrapped, "\n")...)
|
// p.lines = append(p.lines, strings.Split(wrapped, "\n")...)
|
||||||
// }
|
// }
|
||||||
|
displayLevels := []string{"WARNING", "ERROR", "FATAL"}
|
||||||
|
|
||||||
for _, entry := range logs {
|
for _, entry := range logs {
|
||||||
logTime := time.UnixMilli(entry.Timestamp)
|
if slices.Contains(displayLevels, entry.Level) {
|
||||||
timeStr := logTime.Format("2006-01-02 15:04:05")
|
logTime := time.UnixMilli(entry.Timestamp)
|
||||||
line := fmt.Sprintf("[%s] [%s] %s", timeStr, entry.Level, entry.Message)
|
timeStr := logTime.Format("2006-01-02 15:04")
|
||||||
p.lines = append(p.lines, line)
|
line := fmt.Sprintf("[%s] [%s] %s", timeStr, entry.Level, entry.Message)
|
||||||
|
p.lines = append(p.lines, line)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applicationFont := "Roboto-Regular"
|
applicationFont := "Roboto-Regular"
|
||||||
|
|||||||
@@ -81,9 +81,15 @@ func (p *ProclamationOptions) Init(ctx *PageCtx) error {
|
|||||||
p.isSearchActive = false
|
p.isSearchActive = false
|
||||||
p.scrollTrackWidth = 30
|
p.scrollTrackWidth = 30
|
||||||
p.scrollTrackX = p.ScreenWidth - p.scrollTrackWidth
|
p.scrollTrackX = p.ScreenWidth - p.scrollTrackWidth
|
||||||
|
var err error
|
||||||
|
|
||||||
// Syncronize proclamations first
|
// 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()
|
fm := fontManager.Get()
|
||||||
font, _ := fm.GetFont("Roboto-Regular")
|
font, _ := fm.GetFont("Roboto-Regular")
|
||||||
@@ -108,7 +114,7 @@ func (p *ProclamationOptions) Init(ctx *PageCtx) error {
|
|||||||
|
|
||||||
// Load current selections
|
// Load current selections
|
||||||
var selected []db.Proclamation
|
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 {
|
for _, s := range selected {
|
||||||
if s.ID == defaultProclamationID {
|
if s.ID == defaultProclamationID {
|
||||||
logger.Debug("Found default proclamation in selected list: %s", s.ID)
|
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
|
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))
|
procContentMap := make(map[string]string, len(allProcs))
|
||||||
for _, pr := range allProcs {
|
for _, pr := range allProcs {
|
||||||
if pr.ID == defaultProclamationID {
|
if pr.ID == defaultProclamationID {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ func (p *WiFiSetupPage) Init(ctx *PageCtx) error {
|
|||||||
}
|
}
|
||||||
for _, dev := range p.networkManager.Devices {
|
for _, dev := range p.networkManager.Devices {
|
||||||
if dev.Type == network.TypeWifi {
|
if dev.Type == network.TypeWifi {
|
||||||
d := dev
|
d := dev
|
||||||
p.wifiDevice = &d
|
p.wifiDevice = &d
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -198,13 +198,14 @@ func (p *WiFiSetupPage) handlePasswordInput(sym sdl.Keycode, mod uint16) {
|
|||||||
switch sym {
|
switch sym {
|
||||||
|
|
||||||
case sdl.K_RETURN:
|
case sdl.K_RETURN:
|
||||||
p.exitPasswordMode()
|
p.exitPasswordMode()
|
||||||
|
|
||||||
p.pendingSSID = p.selectedAP.SSID
|
p.pendingSSID = p.selectedAP.SSID
|
||||||
p.isConnecting = true
|
p.isConnecting = true
|
||||||
p.connectionError = ""
|
p.connectionError = ""
|
||||||
p.connectionAttemptTime = time.Now()
|
p.connectionAttemptTime = time.Now()
|
||||||
|
|
||||||
|
|
||||||
err := p.networkManager.Connect(*p.wifiDevice, *p.selectedAP, p.passwordInput)
|
err := p.networkManager.Connect(*p.wifiDevice, *p.selectedAP, p.passwordInput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.isConnecting = false
|
p.isConnecting = false
|
||||||
@@ -383,7 +384,7 @@ func (p *WiFiSetupPage) Update(dt float32) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleConnectionStatusUpdate checks if connection succeeded or failed
|
// handleConnectionStatusUpdate CHECKS0 if connection succeeded or failed
|
||||||
func (p *WiFiSetupPage) handleConnectionStatusUpdate(status *network.ConnectionStatus) {
|
func (p *WiFiSetupPage) handleConnectionStatusUpdate(status *network.ConnectionStatus) {
|
||||||
if !p.isConnecting {
|
if !p.isConnecting {
|
||||||
return
|
return
|
||||||
@@ -411,48 +412,50 @@ func (p *WiFiSetupPage) handleConnectionStatusUpdate(status *network.ConnectionS
|
|||||||
// INCREASE THIS: 5 seconds is way too aggressive.
|
// INCREASE THIS: 5 seconds is way too aggressive.
|
||||||
// Give it at least 20 seconds before assuming the password was wrong.
|
// Give it at least 20 seconds before assuming the password was wrong.
|
||||||
if time.Since(p.connectionAttemptTime) > 20*time.Second {
|
if time.Since(p.connectionAttemptTime) > 20*time.Second {
|
||||||
p.isConnecting = false
|
if time.Since(p.connectionAttemptTime) > 15*time.Second {
|
||||||
p.connectionError = "Connection failed - Check password or signal"
|
p.isConnecting = false
|
||||||
p.isEnteringPassword = true
|
p.connectionError = "Connection failed - Check password or signal"
|
||||||
p.enterPasswordMode()
|
p.isEnteringPassword = true
|
||||||
p.updatePasswordErrorTexture()
|
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 {
|
func (p *WiFiSetupPage) getActiveSSID() string {
|
||||||
if p.networkManager == nil || p.wifiDevice == nil {
|
if p.networkManager == nil || p.wifiDevice == nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
nmObj := p.networkManager.Conn().Object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
|
conn := p.networkManager.Conn()
|
||||||
prop, err := nmObj.GetProperty("org.freedesktop.NetworkManager.ActiveConnections")
|
|
||||||
|
devObj := conn.Object("org.freedesktop.NetworkManager", p.wifiDevice.Path)
|
||||||
|
activeApProp, err := devObj.GetProperty("org.freedesktop.NetworkManager.Device.Wireless.ActiveAccessPoint")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
if paths, ok := prop.Value().([]dbus.ObjectPath); ok {
|
activeApPath, ok := activeApProp.Value().(dbus.ObjectPath)
|
||||||
for _, path := range paths {
|
if !ok || activeApPath == "/" || activeApPath == "" {
|
||||||
acObj := p.networkManager.Conn().Object("org.freedesktop.NetworkManager", path)
|
return ""
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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
|
// 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
|
var storedProclamationSettings []db.Proclamation
|
||||||
database.Select("ID", "Selected").Find(&storedProclamationSettings)
|
database.Select("ID", "Selected").Find(&storedProclamationSettings)
|
||||||
|
|
||||||
// [ID]Selected
|
// [ID]Selected
|
||||||
stash := make(map[string]bool)
|
stash := make(map[string]bool)
|
||||||
for _, row := range storedProclamationSettings {
|
for _, row := range storedProclamationSettings {
|
||||||
@@ -76,6 +77,7 @@ func SyncProclamations(database *gorm.DB) ([]db.Proclamation, error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return nil as err for this statement, does not exit the function
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user