Optimize Client-traffic-reset

This commit is contained in:
Alireza Ahmadi
2023-03-01 17:08:28 +01:00
parent ae45f9fef2
commit 9e398aaa65
5 changed files with 13 additions and 40 deletions

View File

@@ -14,7 +14,7 @@
</a-tooltip>
<a-tooltip>
<template slot="title">{{ i18n "pages.inbounds.resetTraffic" }}</template>
<a-icon style="font-size: 24px;" type="retweet" @click="resetClientTraffic(client,record)" v-if="client.email.length > 0"></a-icon>
<a-icon style="font-size: 24px;" type="retweet" @click="resetClientTraffic(client,record.id)" v-if="client.email.length > 0"></a-icon>
</a-tooltip>
<a-tooltip>
<template slot="title"><span style="color: #FF4D4F"> {{ i18n "delete"}}</span></template>

View File

@@ -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)
},

View File

@@ -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)