From 3087c1b123f426b7c1306ab634fb84e7943e4217 Mon Sep 17 00:00:00 2001 From: Ali Golzar <57574919+aliglzr@users.noreply.github.com> Date: Thu, 28 Aug 2025 02:40:50 +0330 Subject: Add all-time traffic for inbounds and clients (#3387) * feat(db): add allTime field to Inbound and ClientTraffic models * feat(inbound): increment all_time for inbounds and clients on traffic updates calculate correct all_time traffic on migrate command * feat(ui): show all-time traffic column for inbounds and its clients * i18n: add pages.inbounds.allTimeTraffic label across locales * Add All Time Traffic Usage in inbounds page top banner --- web/html/inbounds.html | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'web/html/inbounds.html') diff --git a/web/html/inbounds.html b/web/html/inbounds.html index 010296eb..142a167c 100644 --- a/web/html/inbounds.html +++ b/web/html/inbounds.html @@ -167,28 +167,35 @@ - + - + - + + + + + + - + + @@ -723,6 +733,11 @@ align: 'center', width: 60, scopedSlots: { customRender: 'traffic' }, + }, { + title: '{{ i18n "pages.inbounds.allTimeTraffic" }}', + align: 'center', + width: 60, + scopedSlots: { customRender: 'allTimeInbound' }, }, { title: '{{ i18n "pages.inbounds.expireDate" }}', align: 'center', @@ -759,6 +774,7 @@ { title: '{{ i18n "online" }}', width: 30, scopedSlots: { customRender: 'online' } }, { title: '{{ i18n "pages.inbounds.client" }}', width: 80, scopedSlots: { customRender: 'client' } }, { title: '{{ i18n "pages.inbounds.traffic" }}', width: 80, align: 'center', scopedSlots: { customRender: 'traffic' } }, + { title: '{{ i18n "pages.inbounds.allTimeTraffic" }}', width: 80, align: 'center', scopedSlots: { customRender: 'allTime' } }, { title: '{{ i18n "pages.inbounds.expireDate" }}', width: 80, align: 'center', scopedSlots: { customRender: 'expiryTime' } }, { title: '{{ i18n "pages.inbounds.createdAt" }}', width: 90, align: 'center', scopedSlots: { customRender: 'createdAt' } }, { title: '{{ i18n "pages.inbounds.updatedAt" }}', width: 90, align: 'center', scopedSlots: { customRender: 'updatedAt' } }, @@ -1419,6 +1435,12 @@ clientStats = dbInbound.clientStats.find(stats => stats.email === email); return clientStats ? clientStats.up + clientStats.down : 0; }, + getAllTimeClient(dbInbound, email) { + if (email.length == 0) return 0; + clientStats = dbInbound.clientStats.find(stats => stats.email === email); + if (!clientStats) return 0; + return clientStats.allTime || (clientStats.up + clientStats.down); + }, getRemStats(dbInbound, email) { if (email.length == 0) return 0; clientStats = dbInbound.clientStats.find(stats => stats.email === email); @@ -1608,11 +1630,12 @@ }, computed: { total() { - let down = 0, up = 0; + let down = 0, up = 0, allTime = 0; let clients = 0, deactive = [], depleted = [], expiring = []; this.dbInbounds.forEach(dbInbound => { down += dbInbound.down; up += dbInbound.up; + allTime += (dbInbound.allTime || (dbInbound.up + dbInbound.down)); if (this.clientCount[dbInbound.id]) { clients += this.clientCount[dbInbound.id].clients; deactive = deactive.concat(this.clientCount[dbInbound.id].deactive); @@ -1623,6 +1646,7 @@ return { down: down, up: up, + allTime: allTime, clients: clients, deactive: deactive, depleted: depleted, -- cgit v1.2.3