Skip to content

Commit

Permalink
[feature] reset traffics of all client
Browse files Browse the repository at this point in the history
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
  • Loading branch information
MHSanaei and alireza0 committed Apr 25, 2023
1 parent 942b986 commit 6a71ea7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 18 deletions.
45 changes: 38 additions & 7 deletions web/html/xui/inbounds.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,23 @@
<a-card hoverable :class="siderDrawer.isDarkTheme ? darkClass : ''">
<div slot="title">
<a-button type="primary" icon="plus" @click="openAddInbound">{{ i18n "pages.inbounds.addInbound" }}</a-button>
<a-button type="primary" icon="export" @click="exportAllLinks">{{ i18n "pages.inbounds.export" }}</a-button>
<a-button type="primary" icon="reload" @click="resetAllTraffic">{{ i18n "pages.inbounds.resetAllTraffic" }}</a-button>
<a-dropdown :trigger="['click']">
<a-button type="primary" icon="menu">General Actions</a-button>
<a-menu slot="overlay" @click="a => generalActions(a)" :theme="siderDrawer.theme">
<a-menu-item key="export">
<a-icon type="export"></a-icon>
{{ i18n "pages.inbounds.export" }}
</a-menu-item>
<a-menu-item key="resetInbounds">
<a-icon type="reload"></a-icon>
{{ i18n "pages.inbounds.resetAllTraffic" }}
</a-menu-item>
<a-menu-item key="resetClients">
<a-icon type="file-done"></a-icon>
{{ i18n "pages.inbounds.resetAllClientTraffics" }}
</a-menu-item>
</a-menu>
</a-dropdown>
</div>
<a-input v-model.lazy="searchKey" placeholder='{{ i18n "search" }}' autofocus style="max-width: 300px"></a-input>
<a-table :columns="columns" :row-key="dbInbound => dbInbound.id"
Expand All @@ -78,7 +93,7 @@
style="margin-top: 20px"
@change="() => getDBInbounds()">
<template slot="action" slot-scope="text, dbInbound">
<a-icon type="edit" style="font-size: 25px" @click="openEditInbound(dbInbound.id);"></a-icon>
<a-icon type="edit" style="font-size: 22px" @click="openEditInbound(dbInbound.id);"></a-icon>
<a-dropdown :trigger="['click']">
<a @click="e => e.preventDefault()">{{ i18n "pages.inbounds.operate" }}</a>
<a-menu slot="overlay" @click="a => clickAction(a, dbInbound)" :theme="siderDrawer.theme">
Expand All @@ -101,7 +116,7 @@
</a-menu-item>
<a-menu-item key="resetClients">
<a-icon type="file-done"></a-icon>
{{ i18n "pages.inbounds.resetAllClientTraffics"}}
{{ i18n "pages.inbounds.resetInboundClientTraffics"}}
</a-menu-item>
<a-menu-item key="export">
<a-icon type="export"></a-icon>
Expand Down Expand Up @@ -390,6 +405,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":
Expand Down Expand Up @@ -651,7 +681,8 @@
clients = this.getClients(dbInbound.protocol, inbound.settings);
index = this.findIndexOfClient(clients, client);
clients[index].enable = !clients[index].enable;
await this.updateClient(clients[index],dbInboundId, index);
clientId = dbInbound.protocol == "trojan" ? clients[index].password : clients[index].id;
await this.updateClient(clients[index],dbInboundId, clientId);
this.loading(false);
},
async submit(url, data) {
Expand Down Expand Up @@ -691,8 +722,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"}}',
Expand Down
11 changes: 7 additions & 4 deletions web/translation/translate.en_US.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"totalDownUp" = "Total uploads/downloads"
"totalUsage" = "Total usage"
"inboundCount" = "Number of inbound"
"operate" = "Actions"
"operate" = "Menu"
"enable" = "Enable"
"remark" = "Remark"
"protocol" = "Protocol"
Expand Down Expand Up @@ -144,16 +144,19 @@
"resetAllTrafficCancelText" = "Cancel"
"IPLimit" = "IP Limit"
"IPLimitDesc" = "Disable inbound if the count exceeds the entered value (Enter 0 to disable IP limit)"
"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" = "Confirm reset of all traffic for clients of this inbound?"
"resetAllClientTrafficContent" = "Are you sure to reset all traffics of all clients ?"
"Email" = "Email"
"EmailDesc" = "Please provide a unique email address"
"IPLimitlog" = "IP Log"
"IPLimitlogDesc" = "IPs history Log (before enabling inbound after it has been disabled by IP limit, you should clear the log)"
"IPLimitlogclear" = "Clear The Log"
"setDefaultCert" = "Set cert from panel"
"XTLSdec" = "Xray core needs to be 1.7.5 and below"
"XTLSdec" = "Xray core needs to be 1.7.5"
"Realitydec" = "Xray core needs to be 1.8.0 and above"

[pages.client]
Expand Down
9 changes: 6 additions & 3 deletions web/translation/translate.fa_IR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"totalDownUp" = "جمع آپلود/دانلود"
"totalUsage" = "جمع کل"
"inboundCount" = "تعداد سرویس ها"
"operate" = "عملیات"
"operate" = "فهرست"
"enable" = "فعال"
"remark" = "نام"
"protocol" = "پروتکل"
Expand Down Expand Up @@ -140,9 +140,12 @@
"resetAllTraffic" = "ریست ترافیک کل سرویس ها"
"resetAllTrafficTitle" = "ریست ترافیک کل سرویس ها"
"resetAllTrafficContent" = "آیا مطمئن هستید که میخواهید تمام ترافیک سرویس ها را ریست کنید؟"
"resetInboundClientTraffics" = "ریست ترافیک کاربران"
"resetInboundClientTrafficTitle" = "ریست ترافیک کل کاربران"
"resetInboundClientTrafficContent" = "آیا مطمئن هستید که میخواهید تمام ترافیک کاربران این سرویس را ریست کنید؟"
"resetAllClientTraffics" = "ریست ترافیک کاربران"
"resetAllClientTrafficTitle" = "ریست ترافیک کل کاربران"
"resetAllClientTrafficContent" = "آیا مطمئن هستید که میخواهید تمام ترافیک کاربران این سرویس را ریست کنید؟"
"resetAllClientTrafficContent" = "آیا مطمئن هستید که میخواهید تمام ترافیک کاربران را ریست کنید؟"
"IPLimit" = "محدودیت ای پی"
"IPLimitDesc" = "غیرفعال کردن ورودی در صورت بیش از تعداد وارد شده (0 برای غیرفعال کردن محدودیت ای پی )"
"Email" = "ایمیل"
Expand All @@ -151,7 +154,7 @@
"IPLimitlogDesc" = "گزارش سابقه ای پی (قبل از فعال کردن ورودی پس از غیرفعال شدن توسط محدودیت ای پی، باید گزارش را پاک کنید)"
"IPLimitlogclear" = "پاک کردن گزارش ها"
"setDefaultCert" = "استفاده از گواهی پنل"
"XTLSdec" = "هسته Xray باید 1.7.5 و کمتر باشد"
"XTLSdec" = "هسته Xray باید 1.7.5 باشد"
"Realitydec" = "هسته Xray باید 1.8.0 و بالاتر باشد"

[pages.client]
Expand Down
11 changes: 7 additions & 4 deletions web/translation/translate.zh_Hans.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"totalDownUp" = "总上传 / 下载"
"totalUsage" = "总用量"
"inboundCount" = "入站数量"
"operate" = "操作"
"operate" = "菜单"
"enable" = "启用"
"remark" = "备注"
"protocol" = "协议"
Expand Down Expand Up @@ -140,9 +140,12 @@
"resetAllTraffic" = "重置所有入站流量"
"resetAllTrafficTitle" = "重置所有入站流量"
"resetAllTrafficContent" = "您确定要重置所有入站流量吗?"
"resetAllClientTraffics" = "重置客户端流量"
"resetInboundClientTraffics" = "重置客户端流量"
"resetInboundClientTrafficTitle" = "重置所有客户端流量"
"resetInboundClientTrafficContent" = "您确定要重置此入站客户端的所有流量吗?"
"resetAllClientTraffics" = "重置所有客户端流量"
"resetAllClientTrafficTitle" = "重置所有客户端流量"
"resetAllClientTrafficContent" = "您确定要重置此入站客户端的所有流量吗"
"resetAllClientTrafficContent" = "你确定要重置所有客户端的所有流量吗"
"IPLimit" = "IP限制"
"IPLimitDesc" = "如果超过输入的计数则禁用入站(0 表示禁用限制 ip)"
"Email" = "电子邮件"
Expand All @@ -151,7 +154,7 @@
"IPLimitlogDesc" = "IP 历史日志 (通过IP限制禁用inbound之前,需要清空日志)"
"IPLimitlogclear" = "清除日志"
"setDefaultCert" = "从面板设置证书"
"XTLSdec" = "Xray核心需要1.7.5及以下版本"
"XTLSdec" = "Xray核心需要1.7.5"
"Realitydec" = "Xray核心需要1.8.0及以上版本"

[pages.client]
Expand Down

0 comments on commit 6a71ea7

Please sign in to comment.