From 35ad91a9e05f3487ba627da4dfbea55768b0f845 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Tue, 25 Apr 2023 16:24:13 +0200 Subject: [PATCH] [feature] delete depleted clients --- web/controller/inbound.go | 27 +++++++-- web/html/xui/inbounds.html | 24 +++++++- web/service/inbound.go | 79 ++++++++++++++++++++++++++ web/translation/translate.en_US.toml | 3 + web/translation/translate.fa_IR.toml | 3 + web/translation/translate.zh_Hans.toml | 3 + 6 files changed, 132 insertions(+), 7 deletions(-) diff --git a/web/controller/inbound.go b/web/controller/inbound.go index 5bb7cc12..99b472e5 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -37,6 +37,7 @@ func (a *InboundController) initRouter(g *gin.RouterGroup) { g.POST("/:id/resetClientTraffic/:email", a.resetClientTraffic) g.POST("/resetAllTraffics", a.resetAllTraffics) g.POST("/resetAllClientTraffics/:id", a.resetAllClientTraffics) + g.POST("/delDepletedClients/:id", a.delDepletedClients) } @@ -147,7 +148,7 @@ func (a *InboundController) addInboundClient(c *gin.Context) { err = a.inboundService.AddInboundClient(data) if err != nil { - jsonMsg(c, "something worng!", err) + jsonMsg(c, "Something went wrong!", err) return } jsonMsg(c, "Client(s) added", nil) @@ -166,7 +167,7 @@ func (a *InboundController) delInboundClient(c *gin.Context) { err = a.inboundService.DelInboundClient(id, clientId) if err != nil { - jsonMsg(c, "something worng!", err) + jsonMsg(c, "Something went wrong!", err) return } jsonMsg(c, "Client deleted", nil) @@ -187,7 +188,7 @@ func (a *InboundController) updateInboundClient(c *gin.Context) { err = a.inboundService.UpdateInboundClient(inbound, clientId) if err != nil { - jsonMsg(c, "something worng!", err) + jsonMsg(c, "Something went wrong!", err) return } jsonMsg(c, "Client updated", nil) @@ -206,7 +207,7 @@ func (a *InboundController) resetClientTraffic(c *gin.Context) { err = a.inboundService.ResetClientTraffic(id, email) if err != nil { - jsonMsg(c, "something worng!", err) + jsonMsg(c, "Something went wrong!", err) return } jsonMsg(c, "traffic reseted", nil) @@ -218,7 +219,7 @@ func (a *InboundController) resetClientTraffic(c *gin.Context) { func (a *InboundController) resetAllTraffics(c *gin.Context) { err := a.inboundService.ResetAllTraffics() if err != nil { - jsonMsg(c, "something worng!", err) + jsonMsg(c, "Something went wrong!", err) return } jsonMsg(c, "All traffics reseted", nil) @@ -233,8 +234,22 @@ func (a *InboundController) resetAllClientTraffics(c *gin.Context) { err = a.inboundService.ResetAllClientTraffics(id) if err != nil { - jsonMsg(c, "something worng!", err) + jsonMsg(c, "Something went wrong!", err) return } jsonMsg(c, "All traffics of client reseted", nil) } + +func (a *InboundController) delDepletedClients(c *gin.Context) { + id, err := strconv.Atoi(c.Param("id")) + if err != nil { + jsonMsg(c, I18n(c, "pages.inbounds.revise"), err) + return + } + err = a.inboundService.DelDepletedClients(id) + if err != nil { + jsonMsg(c, "Something went wrong!", err) + return + } + jsonMsg(c, "All delpeted clients are deleted", nil) +} diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index 3236e389..eb53dd63 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -82,6 +82,10 @@ {{ i18n "pages.inbounds.resetAllClientTraffics" }} + + + {{ i18n "pages.inbounds.delDepletedClients" }} + @@ -121,6 +125,10 @@ {{ i18n "pages.inbounds.export"}} + + + {{ i18n "pages.inbounds.delDepletedClients" }} +