diff --git a/web/controller/inbound.go b/web/controller/inbound.go
index d15c47dd..0add17a1 100644
--- a/web/controller/inbound.go
+++ b/web/controller/inbound.go
@@ -34,7 +34,7 @@ func (a *InboundController) initRouter(g *gin.RouterGroup) {
g.POST("/addClient/", a.addInboundClient)
g.POST("/delClient/:email", a.delInboundClient)
g.POST("/updateClient/:index", a.updateInboundClient)
- g.POST("/resetClientTraffic/:email", a.resetClientTraffic)
+ g.POST("/:id/resetClientTraffic/:email", a.resetClientTraffic)
}
@@ -193,9 +193,14 @@ func (a *InboundController) updateInboundClient(c *gin.Context) {
}
func (a *InboundController) resetClientTraffic(c *gin.Context) {
+ id, err := strconv.Atoi(c.Param("id"))
+ if err != nil {
+ jsonMsg(c, I18n(c, "pages.inbounds.revise"), err)
+ return
+ }
email := c.Param("email")
- err := a.inboundService.ResetClientTraffic(email)
+ err = a.inboundService.ResetClientTraffic(id, email)
if err != nil {
jsonMsg(c, "something worng!", err)
return
diff --git a/web/html/xui/inbound_client_table.html b/web/html/xui/inbound_client_table.html
index c8af5966..4d7bd932 100644
--- a/web/html/xui/inbound_client_table.html
+++ b/web/html/xui/inbound_client_table.html
@@ -14,7 +14,7 @@
{{ i18n "pages.inbounds.resetTraffic" }}
-
+
{{ i18n "delete"}}
diff --git a/web/html/xui/inbound_modal.html b/web/html/xui/inbound_modal.html
index 297c1115..118e2b06 100644
--- a/web/html/xui/inbound_modal.html
+++ b/web/html/xui/inbound_modal.html
@@ -88,24 +88,6 @@
removeClient(index, clients) {
clients.splice(index, 1);
},
- async resetClientTraffic(client,event) {
- const msg = await HttpUtil.post('/xui/inbound/resetClientTraffic/'+ client.email);
- if (!msg.success) {
- return;
- }
- clientStats = this.inbound.clientStats
- if(clientStats.length > 0)
- {
- for (const key in clientStats) {
- if (Object.hasOwnProperty.call(clientStats, key)) {
- if(clientStats[key]['email'] == client.email){
- clientStats[key]['up'] = 0
- clientStats[key]['down'] = 0
- }
- }
- }
- }
- },
isExpiry(index) {
return this.inbound.isExpiry(index)
},
diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html
index e000202c..514fed52 100644
--- a/web/html/xui/inbounds.html
+++ b/web/html/xui/inbounds.html
@@ -474,28 +474,14 @@
return dbInbound.toInbound().settings.trojans
}
},
- resetClientTraffic(client,inbound) {
+ resetClientTraffic(client,dbInbound_Id) {
this.$confirm({
title: '{{ i18n "pages.inbounds.resetTraffic"}}',
content: '{{ i18n "pages.inbounds.resetTrafficContent"}}',
okText: '{{ i18n "reset"}}',
cancelText: '{{ i18n "cancel"}}',
- onOk: () => {
- this.resetClTraffic(client,inbound);
- },
- });
- },
- async resetClTraffic(client,inbound) {
- const msg = await HttpUtil.post('/xui/inbound/resetClientTraffic/'+ client.email);
- if (!msg.success) {
- return;
- }
- clientStats = inbound.clientStats.find(stats => stats.email == client.email)
- if(clientStats.length > 0)
- {
- clientStats.up = 0
- clientStats.down = 0
- }
+ onOk: () => this.submit('/xui/inbound/' + dbInbound_Id + '/resetClientTraffic/'+ client.email),
+ })
},
isExpiry(dbInbound, index) {
return dbInbound.toInbound().isExpiry(index)
diff --git a/web/service/inbound.go b/web/service/inbound.go
index d320868d..105b161d 100644
--- a/web/service/inbound.go
+++ b/web/service/inbound.go
@@ -472,11 +472,11 @@ func (s *InboundService) DelClientStat(tx *gorm.DB, email string) error {
return tx.Where("email = ?", email).Delete(xray.ClientTraffic{}).Error
}
-func (s *InboundService) ResetClientTraffic(clientEmail string) error {
+func (s *InboundService) ResetClientTraffic(id int, clientEmail string) error {
db := database.GetDB()
result := db.Model(xray.ClientTraffic{}).
- Where("email = ?", clientEmail).
+ Where("inbound_id = ? and email = ?", id, clientEmail).
Updates(map[string]interface{}{"enable": true, "up": 0, "down": 0})
err := result.Error