From ef0dd10fe761e1cd8db060d6eaaf9b1bee15bc66 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Sat, 18 Feb 2023 16:50:40 +0100 Subject: [PATCH] Simplify codes with fix small view problems --- web/html/xui/form/protocol/trojan.html | 29 +++++----------------- web/html/xui/form/protocol/vless.html | 34 +++++++------------------- web/html/xui/form/protocol/vmess.html | 29 +++++----------------- web/html/xui/inbound_modal.html | 17 ++----------- web/html/xui/inbounds.html | 17 ++----------- 5 files changed, 25 insertions(+), 101 deletions(-) diff --git a/web/html/xui/form/protocol/trojan.html b/web/html/xui/form/protocol/trojan.html index a9421d68..5076d395 100644 --- a/web/html/xui/form/protocol/trojan.html +++ b/web/html/xui/form/protocol/trojan.html @@ -68,19 +68,10 @@ [[ sizeFormat(getUpStats(trojan.email)) ]] / [[ sizeFormat(getDownStats(trojan.email)) ]] used : [[ sizeFormat(getUpStats(trojan.email) + getDownStats(trojan.email)) ]] - - + + - @@ -88,18 +79,10 @@ - - + + - diff --git a/web/html/xui/form/protocol/vless.html b/web/html/xui/form/protocol/vless.html index 88ab97f0..86f6a063 100644 --- a/web/html/xui/form/protocol/vless.html +++ b/web/html/xui/form/protocol/vless.html @@ -70,37 +70,21 @@ [[ sizeFormat(getUpStats(vless.email)) ]] / [[ sizeFormat(getDownStats(vless.email)) ]] used : [[ sizeFormat(getUpStats(vless.email) + getDownStats(vless.email)) ]] - - - - + + + + - - + + - diff --git a/web/html/xui/form/protocol/vmess.html b/web/html/xui/form/protocol/vmess.html index 3b1bf26e..bd46f009 100644 --- a/web/html/xui/form/protocol/vmess.html +++ b/web/html/xui/form/protocol/vmess.html @@ -65,19 +65,10 @@ [[ sizeFormat(getUpStats(vmess.email)) ]] / [[ sizeFormat(getDownStats(vmess.email)) ]] used : [[ sizeFormat(getUpStats(vmess.email) + getDownStats(vmess.email)) ]] - - - + + - @@ -89,18 +80,10 @@ - - + + - diff --git a/web/html/xui/inbound_modal.html b/web/html/xui/inbound_modal.html index 798fc369..fdd1328f 100644 --- a/web/html/xui/inbound_modal.html +++ b/web/html/xui/inbound_modal.html @@ -121,7 +121,6 @@ } } } - }, getDownStats(email) { clientStats = this.inbound.clientStats @@ -137,30 +136,18 @@ } }, isClientEnable(email) { - clientStats = this.inbound.clientStats - if(clientStats.length > 0) - { - for (const key in clientStats) { - if (Object.hasOwnProperty.call(clientStats, key)) { - if(clientStats[key]['email'] == email) - return clientStats[key]['enable'] - - } - } - } + clientStats = this.dbInbound.clientStats ? this.dbInbound.clientStats.find(stats => stats.email === email) : null + return clientStats ? clientStats['enable'] : true }, - getHeaderText(email) { if(email == "") return "Add Client" return email + (this.isClientEnable(email) == true ? ' Active' : ' Deactive') }, - getHeaderStyle(email) { return (this.isClientEnable(email) == true ? '' : 'deactive-client') }, - getNewEmail(client) { var chars = 'abcdefghijklmnopqrstuvwxyz1234567890'; var string = ''; diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index 8b251202..1b3c62e0 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -447,7 +447,6 @@ } } } - }, getDownStats(dbInbound, email) { clientStats = dbInbound.clientStats @@ -476,20 +475,8 @@ } }, isClientEnabled(dbInbound, email) { - clientStats = dbInbound.clientStats - if(clientStats.length > 0) - { - for (const key in clientStats) { - if (Object.hasOwnProperty.call(clientStats, key)) { - if(clientStats[key]['email'] == email) - return clientStats[key]['enable'] - - } - } - } - else{ - return true - } + clientStats = dbInbound.clientStats ? dbInbound.clientStats.find(stats => stats.email === email) : null + return clientStats ? clientStats['enable'] : true }, }, watch: {