mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-05-08 14:36:13 +00:00
subpage: enabled state
Track and surface a subscription's enabled state from backend to frontend so the UI can show inactive subscriptions and use it in active-state logic. Changes: - sub/subService.go: track hasEnabledClient, set traffic.Enable, add Enabled to PageData and populate it in BuildPageData. - sub/subController.go: include enabled in the page context. - web/html/settings/panel/subscription/subpage.html: emit data-enabled attribute and render an "inactive" tag when disabled. - web/assets/js/subscription.js: read data-enabled and include it in isActive() checks. This ensures subscriptions with no enabled clients are marked inactive in the UI and excluded from being considered active.
This commit is contained in:
@@ -138,6 +138,7 @@ func (a *SUBController) subs(c *gin.Context) {
|
||||
"host": page.Host,
|
||||
"base_path": page.BasePath,
|
||||
"sId": page.SId,
|
||||
"enabled": page.Enabled,
|
||||
"download": page.Download,
|
||||
"upload": page.Upload,
|
||||
"total": page.Total,
|
||||
|
||||
@@ -46,6 +46,7 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, int64, xray.C
|
||||
var result []string
|
||||
var traffic xray.ClientTraffic
|
||||
var lastOnline int64
|
||||
var hasEnabledClient bool
|
||||
var clientTraffics []xray.ClientTraffic
|
||||
inbounds, err := s.getInboundsBySubId(subId)
|
||||
if err != nil {
|
||||
@@ -78,6 +79,9 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, int64, xray.C
|
||||
}
|
||||
for _, client := range clients {
|
||||
if client.SubID == subId {
|
||||
if client.Enable {
|
||||
hasEnabledClient = true
|
||||
}
|
||||
link := s.getLink(inbound, client.Email)
|
||||
result = append(result, link)
|
||||
ct := s.getClientTraffics(inbound.ClientStats, client.Email)
|
||||
@@ -111,6 +115,7 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, int64, xray.C
|
||||
}
|
||||
}
|
||||
}
|
||||
traffic.Enable = hasEnabledClient
|
||||
return result, lastOnline, traffic, nil
|
||||
}
|
||||
|
||||
@@ -1304,6 +1309,7 @@ type PageData struct {
|
||||
Host string
|
||||
BasePath string
|
||||
SId string
|
||||
Enabled bool
|
||||
Download string
|
||||
Upload string
|
||||
Total string
|
||||
@@ -1453,6 +1459,7 @@ func (s *SubService) BuildPageData(subId string, hostHeader string, traffic xray
|
||||
Host: hostHeader,
|
||||
BasePath: basePath,
|
||||
SId: subId,
|
||||
Enabled: traffic.Enable,
|
||||
Download: download,
|
||||
Upload: upload,
|
||||
Total: total,
|
||||
|
||||
Reference in New Issue
Block a user