Compare commits
3 Commits
v0.1.3-tes
...
v0.1.3-tes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
452c7c59b6 | ||
|
|
b059c91388 | ||
|
|
289337f016 |
@@ -591,9 +591,11 @@ func exportHistoryDay(app *guiApp, day time.Time, selected map[string]bool) (str
|
|||||||
}
|
}
|
||||||
|
|
||||||
func exportHistoryDayFromRequest(req historyExportRequest) (string, error) {
|
func exportHistoryDayFromRequest(req historyExportRequest) (string, error) {
|
||||||
|
events := historyEventsFromSnapshot()
|
||||||
|
visits := historyVisitSource()
|
||||||
rows := append([]historyDetailRow(nil), req.Rows...)
|
rows := append([]historyDetailRow(nil), req.Rows...)
|
||||||
if len(rows) == 0 {
|
if len(rows) == 0 {
|
||||||
rows = historyVisitsForDayFromData(nil, req.Day, historyVisitSource(), historyEventsFromSnapshot(), req.Query)
|
rows = historyVisitsForDayFromData(nil, req.Day, visits, events, req.Query)
|
||||||
}
|
}
|
||||||
if len(req.Selected) > 0 {
|
if len(req.Selected) > 0 {
|
||||||
filtered := rows[:0]
|
filtered := rows[:0]
|
||||||
@@ -679,6 +681,9 @@ func exportHistoryDayFromRequest(req historyExportRequest) (string, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
appendExportDayVisits(&b, req.Day, visits, req.Query)
|
||||||
|
appendExportDayEvents(&b, req.Day, events, req.Query)
|
||||||
|
appendExportGuestSnapshot(&b, req.Day, req.Query)
|
||||||
exportDir := runtimeDir()
|
exportDir := runtimeDir()
|
||||||
if strings.TrimSpace(req.ExportDir) != "" {
|
if strings.TrimSpace(req.ExportDir) != "" {
|
||||||
exportDir = normalizeHistoryExportDir(req.ExportDir)
|
exportDir = normalizeHistoryExportDir(req.ExportDir)
|
||||||
@@ -696,6 +701,153 @@ func exportHistoryDayFromRequest(req historyExportRequest) (string, error) {
|
|||||||
return path, nil
|
return path, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func appendExportDayVisits(b *strings.Builder, day time.Time, visits []historyVisitRecord, q historyQuery) {
|
||||||
|
if b == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dayStart, dayEnd := historyDayBounds(day)
|
||||||
|
matched := make([]historyVisitRecord, 0, len(visits))
|
||||||
|
for _, visit := range visits {
|
||||||
|
start := visit.Start
|
||||||
|
if start.IsZero() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
end := visit.End
|
||||||
|
if end.IsZero() {
|
||||||
|
end = time.Now()
|
||||||
|
}
|
||||||
|
if !start.Before(dayEnd) || !end.After(dayStart) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if q.Pattern != nil && !q.Pattern.MatchString(visit.WorldLabel) && !q.Pattern.MatchString(visit.WorldID) && !q.Pattern.MatchString(visit.InstanceID) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
matched = append(matched, visit)
|
||||||
|
}
|
||||||
|
sort.SliceStable(matched, func(i, j int) bool {
|
||||||
|
return matched[i].Start.Before(matched[j].Start)
|
||||||
|
})
|
||||||
|
b.WriteString("\nAll visits:\n")
|
||||||
|
if len(matched) == 0 {
|
||||||
|
b.WriteString("(no visits)\n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, visit := range matched {
|
||||||
|
b.WriteString("- ")
|
||||||
|
b.WriteString(historyTimeRangeLabel(visit.Start, visit.End, visit.Current))
|
||||||
|
b.WriteString(" ")
|
||||||
|
b.WriteString(strings.TrimSpace(visit.WorldLabel))
|
||||||
|
if strings.TrimSpace(visit.WorldID) != "" {
|
||||||
|
b.WriteString(" world_id=")
|
||||||
|
b.WriteString(strings.TrimSpace(visit.WorldID))
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(visit.InstanceID) != "" {
|
||||||
|
b.WriteString(" instance_id=")
|
||||||
|
b.WriteString(strings.TrimSpace(visit.InstanceID))
|
||||||
|
}
|
||||||
|
b.WriteString("\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendExportDayEvents(b *strings.Builder, day time.Time, events []historyEventRecord, q historyQuery) {
|
||||||
|
if b == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dayStart, dayEnd := historyDayBounds(day)
|
||||||
|
matched := make([]historyEventRecord, 0, len(events))
|
||||||
|
for _, ev := range events {
|
||||||
|
if ev.At.IsZero() || ev.At.Before(dayStart) || !ev.At.Before(dayEnd) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
raw := fmt.Sprintf("[%s] %s %s", ev.At.Format("15:04"), ev.Kind, ev.Name)
|
||||||
|
if q.Pattern != nil && !q.Pattern.MatchString(ev.Name) && !q.Pattern.MatchString(raw) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
matched = append(matched, ev)
|
||||||
|
}
|
||||||
|
sort.SliceStable(matched, func(i, j int) bool {
|
||||||
|
if matched[i].At.Equal(matched[j].At) {
|
||||||
|
return strings.ToLower(matched[i].Name) < strings.ToLower(matched[j].Name)
|
||||||
|
}
|
||||||
|
return matched[i].At.Before(matched[j].At)
|
||||||
|
})
|
||||||
|
b.WriteString("\nAll join/leave events:\n")
|
||||||
|
if len(matched) == 0 {
|
||||||
|
b.WriteString("(no events)\n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, ev := range matched {
|
||||||
|
b.WriteString("- ")
|
||||||
|
b.WriteString(ev.At.Format("15:04"))
|
||||||
|
b.WriteString(" ")
|
||||||
|
b.WriteString(ev.Kind)
|
||||||
|
b.WriteString(" ")
|
||||||
|
b.WriteString(strings.TrimSpace(ev.Name))
|
||||||
|
if ev.Raw != "" {
|
||||||
|
b.WriteString(" | ")
|
||||||
|
b.WriteString(strings.TrimSpace(ev.Raw))
|
||||||
|
}
|
||||||
|
b.WriteString("\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendExportGuestSnapshot(b *strings.Builder, day time.Time, q historyQuery) {
|
||||||
|
if b == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guests := readGuestSnapshot()
|
||||||
|
dayStart, dayEnd := historyDayBounds(day)
|
||||||
|
type guestLine struct {
|
||||||
|
name string
|
||||||
|
present bool
|
||||||
|
join time.Time
|
||||||
|
leave time.Time
|
||||||
|
}
|
||||||
|
lines := make([]guestLine, 0, len(guests))
|
||||||
|
for _, guest := range guests {
|
||||||
|
name := strings.TrimSpace(guest.Name)
|
||||||
|
if name == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
inDay := guest.Present ||
|
||||||
|
(!guest.LastJoin.IsZero() && !guest.LastJoin.Before(dayStart) && guest.LastJoin.Before(dayEnd)) ||
|
||||||
|
(!guest.LastLeave.IsZero() && !guest.LastLeave.Before(dayStart) && guest.LastLeave.Before(dayEnd))
|
||||||
|
if !inDay {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if q.Pattern != nil && !q.Pattern.MatchString(name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
lines = append(lines, guestLine{name: name, present: guest.Present, join: guest.LastJoin, leave: guest.LastLeave})
|
||||||
|
}
|
||||||
|
sort.SliceStable(lines, func(i, j int) bool {
|
||||||
|
return strings.ToLower(lines[i].name) < strings.ToLower(lines[j].name)
|
||||||
|
})
|
||||||
|
b.WriteString("\nGuest snapshot:\n")
|
||||||
|
if len(lines) == 0 {
|
||||||
|
b.WriteString("(no guests)\n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, line := range lines {
|
||||||
|
b.WriteString("- ")
|
||||||
|
if line.present {
|
||||||
|
b.WriteString("present ")
|
||||||
|
} else {
|
||||||
|
b.WriteString("left ")
|
||||||
|
}
|
||||||
|
b.WriteString(line.name)
|
||||||
|
if !line.join.IsZero() {
|
||||||
|
b.WriteString(" join=")
|
||||||
|
b.WriteString(line.join.Format("15:04"))
|
||||||
|
}
|
||||||
|
if !line.leave.IsZero() {
|
||||||
|
b.WriteString(" leave=")
|
||||||
|
b.WriteString(line.leave.Format("15:04"))
|
||||||
|
}
|
||||||
|
b.WriteString("\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func cloneHistorySelection(selected map[string]bool) map[string]bool {
|
func cloneHistorySelection(selected map[string]bool) map[string]bool {
|
||||||
if len(selected) == 0 {
|
if len(selected) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -139,6 +140,7 @@ var hwndNoZOrder uintptr = 0x0004
|
|||||||
var hwndNoSize uintptr = 0x0001
|
var hwndNoSize uintptr = 0x0001
|
||||||
var hwndNoActivate uintptr = 0x0010
|
var hwndNoActivate uintptr = 0x0010
|
||||||
var hwndShowWindow uintptr = 0x0040
|
var hwndShowWindow uintptr = 0x0040
|
||||||
|
var swMinimize uintptr = 6
|
||||||
var swRestore uintptr = 9
|
var swRestore uintptr = 9
|
||||||
var swHideControl uintptr = 0
|
var swHideControl uintptr = 0
|
||||||
var swShowControl uintptr = 5
|
var swShowControl uintptr = 5
|
||||||
@@ -328,6 +330,9 @@ func guiLog(text string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runNativeGUI(initialTab string) error {
|
func runNativeGUI(initialTab string) error {
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
user32 := syscall.NewLazyDLL("user32.dll")
|
user32 := syscall.NewLazyDLL("user32.dll")
|
||||||
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
||||||
gdi32 := syscall.NewLazyDLL("gdi32.dll")
|
gdi32 := syscall.NewLazyDLL("gdi32.dll")
|
||||||
@@ -790,8 +795,25 @@ func runNativeGUI(initialTab string) error {
|
|||||||
width = rc.Right
|
width = rc.Right
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if x >= width-42 && x <= width-22 && y >= 12 && y <= 32 {
|
switch {
|
||||||
guiLog("close button ignored to keep GUI visible")
|
case pointInHeaderDot(x, y, width-92, 22):
|
||||||
|
guiLog("window control minimize")
|
||||||
|
if showWindowProc != nil {
|
||||||
|
showWindowProc.Call(hwnd, swMinimize)
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
case pointInHeaderDot(x, y, width-62, 22):
|
||||||
|
guiLog("window control topmost toggle")
|
||||||
|
app.topMost = !app.topMost
|
||||||
|
saveGUISettings(&app)
|
||||||
|
applyTopMost(hwnd, &app)
|
||||||
|
if invalidateRectProc != nil {
|
||||||
|
invalidateRectProc.Call(hwnd, 0, 1)
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
case pointInHeaderDot(x, y, width-32, 22):
|
||||||
|
guiLog("window control close")
|
||||||
|
postQuitMessage.Call(0)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
releaseCapture.Call()
|
releaseCapture.Call()
|
||||||
@@ -894,7 +916,8 @@ func runNativeGUI(initialTab string) error {
|
|||||||
postQuitMessage.Call(0)
|
postQuitMessage.Call(0)
|
||||||
return 0
|
return 0
|
||||||
case wmCloseGUI:
|
case wmCloseGUI:
|
||||||
guiLog("wmClose ignored to keep GUI visible")
|
guiLog("wmClose received")
|
||||||
|
postQuitMessage.Call(0)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
ret, _, _ := defWindowProc.Call(hwnd, uintptr(message), wParam, lParam)
|
ret, _, _ := defWindowProc.Call(hwnd, uintptr(message), wParam, lParam)
|
||||||
@@ -990,6 +1013,10 @@ func refreshGUI(setWindowText *syscall.LazyProc, app *guiApp, reloadData bool) {
|
|||||||
if app == nil {
|
if app == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if app.activeTab == "history" && !reloadData {
|
||||||
|
syncPaneVisibility(app)
|
||||||
|
return
|
||||||
|
}
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
if d := time.Since(start); d > 100*time.Millisecond {
|
if d := time.Since(start); d > 100*time.Millisecond {
|
||||||
@@ -1724,6 +1751,10 @@ func paintMainWindow(hwnd uintptr, app *guiApp) uintptr {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func pointInHeaderDot(x, y, cx, cy int32) bool {
|
||||||
|
return x >= cx-11 && x <= cx+11 && y >= cy-11 && y <= cy+11
|
||||||
|
}
|
||||||
|
|
||||||
func paintFooter(hdc uintptr, rc winRect, app *guiApp) {
|
func paintFooter(hdc uintptr, rc winRect, app *guiApp) {
|
||||||
if app == nil {
|
if app == nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user