From 5baa397d1c30411cd13a80e4a8e6771a25205b20 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Tue, 25 Apr 2023 12:26:56 +0200 Subject: [PATCH] [feature] reset traffics of all client --- web/html/xui/inbounds.html | 25 ++++++++++++++++++++++--- web/service/inbound.go | 9 ++++++++- web/translation/translate.en_US.toml | 7 +++++-- web/translation/translate.fa_IR.toml | 5 ++++- web/translation/translate.zh_Hans.toml | 7 +++++-- 5 files changed, 44 insertions(+), 9 deletions(-) diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index ed2df413..ec79e159 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -78,6 +78,10 @@ {{ i18n "pages.inbounds.resetAllTraffic" }} + + + {{ i18n "pages.inbounds.resetAllClientTraffics" }} + @@ -111,7 +115,7 @@ - {{ i18n "pages.inbounds.resetAllClientTraffics"}} + {{ i18n "pages.inbounds.resetInboundClientTraffics"}} @@ -398,6 +402,21 @@ }); } }, + generalActions(action){ + switch (action.key) { + case "export": + this.exportAllLinks(); + break; + case "resetInbounds": + this.resetAllTraffic(); + break; + case "resetClients": + this.resetAllClientTraffics(-1); + break; + case "": + break; + } + }, clickAction(action, dbInbound) { switch (action.key) { case "qrcode": @@ -699,8 +718,8 @@ }, resetAllClientTraffics(dbInboundId) { this.$confirm({ - title: '{{ i18n "pages.inbounds.resetAllClientTrafficTitle"}}', - content: '{{ i18n "pages.inbounds.resetAllClientTrafficContent"}}', + title: dbInboundId>0 ? '{{ i18n "pages.inbounds.resetInboundClientTrafficTitle"}}' : '{{ i18n "pages.inbounds.resetAllClientTrafficTitle"}}', + content: dbInboundId>0 ? '{{ i18n "pages.inbounds.resetInboundClientTrafficContent"}}' : '{{ i18n "pages.inbounds.resetAllClientTrafficContent"}}', class: siderDrawer.isDarkTheme ? darkClass : '', okText: '{{ i18n "reset"}}', cancelText: '{{ i18n "cancel"}}', diff --git a/web/service/inbound.go b/web/service/inbound.go index 293f768e..c8657762 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -643,8 +643,15 @@ func (s *InboundService) ResetClientTraffic(id int, clientEmail string) error { func (s *InboundService) ResetAllClientTraffics(id int) error { db := database.GetDB() + whereText := "inbound_id " + if id == -1 { + whereText += " > ?" + } else { + whereText += " = ?" + } + result := db.Model(xray.ClientTraffic{}). - Where("inbound_id = ?", id). + Where(whereText, id). Updates(map[string]interface{}{"enable": true, "up": 0, "down": 0}) err := result.Error diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index d2e9c10a..88cabc7a 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -138,9 +138,12 @@ "resetAllTraffic" = "Reset All Inbounds Traffic" "resetAllTrafficTitle" = "Reset all inbounds traffic" "resetAllTrafficContent" = "Are you sure to reset all inbounds traffic ?" -"resetAllClientTraffics" = "Reset Clients Traffic" +"resetInboundClientTraffics" = "Reset Clients Traffic" +"resetInboundClientTrafficTitle" = "Reset all clients traffic" +"resetInboundClientTrafficContent" = "Are you sure to reset all traffics of this inbound's clients ?" +"resetAllClientTraffics" = "Reset All Clients Traffic" "resetAllClientTrafficTitle" = "Reset all clients traffic" -"resetAllClientTrafficContent" = "Are you sure to reset all traffics of this inbound's clients ?" +"resetAllClientTrafficContent" = "Are you sure to reset all traffics of all clients ?" "Email" = "Email" "EmailDesc" = "The Email Must Be Completely Unique" "setDefaultCert" = "Set cert from panel" diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index dccf3e32..69550bb1 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -138,9 +138,12 @@ "resetAllTraffic" = "ریست ترافیک کل سرویس ها" "resetAllTrafficTitle" = "ریست ترافیک کل سرویس ها" "resetAllTrafficContent" = "آیا مطمئن هستید که میخواهید تمام ترافیک سرویس ها را ریست کنید؟" +"resetInboundClientTraffics" = "ریست ترافیک کاربران" +"resetInboundClientTrafficTitle" = "ریست ترافیک کل کاربران" +"resetInboundClientTrafficContent" = "آیا مطمئن هستید که میخواهید تمام ترافیک کاربران این سرویس را ریست کنید؟" "resetAllClientTraffics" = "ریست ترافیک کاربران" "resetAllClientTrafficTitle" = "ریست ترافیک کل کاربران" -"resetAllClientTrafficContent" = "آیا مطمئن هستید که میخواهید تمام ترافیک کاربران این سرویس را ریست کنید؟" +"resetAllClientTrafficContent" = "آیا مطمئن هستید که میخواهید تمام ترافیک کاربران را ریست کنید؟" "Email" = "ایمیل" "EmailDesc" = "ایمیل باید کاملا منحصر به فرد باشد" "setDefaultCert" = "استفاده از گواهی پنل" diff --git a/web/translation/translate.zh_Hans.toml b/web/translation/translate.zh_Hans.toml index 12ef032b..9f01a45d 100644 --- a/web/translation/translate.zh_Hans.toml +++ b/web/translation/translate.zh_Hans.toml @@ -138,9 +138,12 @@ "resetAllTraffic" = "重置所有入站流量" "resetAllTrafficTitle" = "重置所有入站流量" "resetAllTrafficContent" = "您确定要重置所有入站流量吗?" -"resetAllClientTraffics" = "重置客户端流量" +"resetInboundClientTraffics" = "重置客户端流量" +"resetInboundClientTrafficTitle" = "重置所有客户端流量" +"resetInboundClientTrafficContent" = "您确定要重置此入站客户端的所有流量吗?" +"resetAllClientTraffics" = "重置所有客户端流量" "resetAllClientTrafficTitle" = "重置所有客户端流量" -"resetAllClientTrafficContent" = "您确定要重置此入站客户端的所有流量吗?" +"resetAllClientTrafficContent" = "你确定要重置所有客户端的所有流量吗?" "Email" = "电子邮件" "EmailDesc" = "电子邮件必须完全唯" "setDefaultCert" = "从面板设置证书"