refactor(web): remove deprecated dashboard components and enhance KPI grid
quality / commitlint (push) Skipped
quality / changes (push) Successful in 9s
quality / docker-check (push) Skipped
quality / openapi (push) Successful in 46s
quality / web (push) Successful in 1m16s
quality / go (push) Successful in 2m42s
quality / bird2 (push) Successful in 16s
CD / quality (push) Successful in 5m19s
CD / publish (push) Successful in 7m19s

- Deleted unused components: `DashboardActivityTimeline`, `DashboardFramePanel`, `DashboardModulesGrid`, `DashboardRecentJobsGrid`, and `DashboardRecentRevisionsGrid` to streamline the dashboard.
- Updated `DashboardKpiGrid` to improve KPI display logic, including progress indicators and enhanced badge functionality.
- Refactored `DashboardNetworkHealth` to provide better status representation based on loading states and network conditions.
- Introduced new properties for KPI cards to support progress tracking and improved visual feedback.

This cleanup aims to enhance performance and maintainability of the dashboard while providing a better user experience.
This commit is contained in:
Denozordec
2026-08-31 10:15:59 +07:00
parent e469c421ca
commit dc803bcb34
51 changed files with 1895 additions and 1078 deletions
+62
View File
@@ -5,7 +5,9 @@ import (
"net/http"
"net/http/httptest"
"strings"
"sync/atomic"
"testing"
"time"
"evobgp/internal/store"
)
@@ -194,3 +196,63 @@ func TestCollectModulePrefixRows_CDN304RetriesWithoutETag(t *testing.T) {
t.Fatalf("unexpected collected rows: %+v", collected)
}
}
func TestPrefetchCDNSourceETags_SkipsFreshSources(t *testing.T) {
t.Setenv("EVOBGP_CDN_ALLOW_PRIVATE", "1")
m := store.NewMemory()
m.SeedDemo()
tenant, _, _, _, _ := m.DemoIDs()
mod, err := m.CreateModule(tenant, &store.Module{
Type: "CDN_CIDRS",
Name: "cdn-prefetch-due",
Enabled: true,
})
if err != nil {
t.Fatal(err)
}
var hits atomic.Int32
srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
hits.Add(1)
w.Header().Set("ETag", `"v1"`)
_, _ = w.Write([]byte("198.51.100.0/24\n"))
}))
defer srv.Close()
// Fresh source: refreshed 30s ago with a 3600s interval — prefetch must skip it.
freshAt := time.Now().UTC().Add(-30 * time.Second)
interval := 3600
if _, err := m.CreateCDNSource(tenant, mod.ID, &store.CDNSource{
SourceKind: "txt",
URL: srv.URL,
RefreshIntervalSec: &interval,
LastRefreshedAt: &freshAt,
}); err != nil {
t.Fatal(err)
}
if err := PrefetchCDNSourceETags(context.Background(), m, srv.Client()); err != nil {
t.Fatal(err)
}
if hits.Load() != 0 {
t.Fatalf("fresh source must be skipped by prefetch, got %d HTTP hits", hits.Load())
}
// Stale source: last refresh older than its interval — prefetch must probe it.
staleAt := time.Now().UTC().Add(-7200 * time.Second)
if _, err := m.CreateCDNSource(tenant, mod.ID, &store.CDNSource{
SourceKind: "txt",
URL: srv.URL + "?stale",
RefreshIntervalSec: &interval,
LastRefreshedAt: &staleAt,
}); err != nil {
t.Fatal(err)
}
if err := PrefetchCDNSourceETags(context.Background(), m, srv.Client()); err != nil {
t.Fatal(err)
}
if hits.Load() == 0 {
t.Fatal("stale source must be probed by prefetch")
}
}