Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2023-03-17 19:07:49 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-03-17 19:07:49 +0300
commit96786c94189f3d2f3f04c1915529c786228bdf42 (patch)
tree879085e09a3cd485f3246f46be907fe77eb84a1a /web/html/xui/client_modal.html
parentbc56e637376142c370c31b17558fc3778a863bd2 (diff)
alireza
Diffstat (limited to 'web/html/xui/client_modal.html')
-rw-r--r--web/html/xui/client_modal.html133
1 files changed, 133 insertions, 0 deletions
diff --git a/web/html/xui/client_modal.html b/web/html/xui/client_modal.html
new file mode 100644
index 00000000..17381a88
--- /dev/null
+++ b/web/html/xui/client_modal.html
@@ -0,0 +1,133 @@
+{{define "clientsModal"}}
+<a-modal id="client-modal" v-model="clientModal.visible" :title="clientModal.title" @ok="clientModal.ok"
+ :confirm-loading="clientModal.confirmLoading" :closable="true" :mask-closable="false"
+ :class="siderDrawer.isDarkTheme ? darkClass : ''"
+ :ok-text="clientModal.okText" cancel-text='{{ i18n "close" }}'>
+ {{template "form/client"}}
+</a-modal>
+<script>
+
+ const clientModal = {
+ visible: false,
+ confirmLoading: false,
+ title: '',
+ okText: '',
+ dbInbound: new DBInbound(),
+ inbound: new Inbound(),
+ clients: [],
+ clientStats: [],
+ index: null,
+ clientIps: null,
+ isExpired: false,
+ ok() {
+ ObjectUtil.execute(clientModal.confirm, clientModal.inbound, clientModal.dbInbound, clientModal.index);
+ },
+ show({ title='', okText='{{ i18n "sure" }}', index=null, dbInbound=null, confirm=(index, dbInbound)=>{}, isEdit=false }) {
+ this.visible = true;
+ this.title = title;
+ this.okText = okText;
+ this.isEdit = isEdit;
+ this.dbInbound = new DBInbound(dbInbound);
+ this.inbound = dbInbound.toInbound();
+ this.clients = this.getClients(this.inbound.protocol, this.inbound.settings);
+ this.index = index === null ? this.clients.length : index;
+ this.isExpired = isEdit ? this.inbound.isExpiry(this.index) : false;
+ if (!isEdit){
+ this.addClient(this.inbound.protocol, this.clients);
+ }
+ this.clientStats = this.dbInbound.clientStats.find(row => row.email === this.clients[this.index].email);
+ this.confirm = confirm;
+ },
+ getClients(protocol, clientSettings) {
+ switch(protocol){
+ case Protocols.VMESS: return clientSettings.vmesses;
+ case Protocols.VLESS: return clientSettings.vlesses;
+ case Protocols.TROJAN: return clientSettings.trojans;
+ default: return null;
+ }
+ },
+ addClient(protocol, clients) {
+ switch (protocol) {
+ case Protocols.VMESS: return clients.push(new Inbound.VmessSettings.Vmess());
+ case Protocols.VLESS: return clients.push(new Inbound.VLESSSettings.VLESS());
+ case Protocols.TROJAN: return clients.push(new Inbound.TrojanSettings.Trojan());
+ default: return null;
+ }
+ },
+ close() {
+ clientModal.visible = false;
+ clientModal.loading(false);
+ },
+ loading(loading) {
+ clientModal.confirmLoading = loading;
+ },
+ };
+
+ const clientModalApp = new Vue({
+ delimiters: ['[[', ']]'],
+ el: '#client-modal',
+ data: {
+ clientModal,
+ get inbound() {
+ return this.clientModal.inbound;
+ },
+ get client() {
+ return this.clientModal.clients[this.clientModal.index];
+ },
+ get clientStats() {
+ return this.clientModal.clientStats;
+ },
+ get isEdit() {
+ return this.clientModal.isEdit;
+ },
+ get isTrafficExhausted() {
+ if(!clientStats) return false
+ if(clientStats.total == 0) return false
+ if(clientStats.up + clientStats.down < clientStats.total) return false
+ return true
+ },
+ get isExpiry() {
+ return this.clientModal.isExpired
+ },
+ get statsColor() {
+ if(!clientStats) return 'blue'
+ if(clientStats.total === 0) return 'blue'
+ else if(clientStats.total > 0 && (clientStats.down+clientStats.up) < clientStats.total) return 'cyan'
+ else return 'red'
+ }
+ },
+ methods: {
+ getNewEmail(client) {
+ var chars = 'abcdefghijklmnopqrstuvwxyz1234567890';
+ var string = '';
+ var len = 6 + Math.floor(Math.random() * 5);
+ for(var ii=0; ii<len; ii++){
+ string += chars[Math.floor(Math.random() * chars.length)];
+ }
+ client.email = string;
+ },
+ async getDBClientIps(email,event) {
+ const msg = await HttpUtil.post('/xui/inbound/clientIps/'+ email);
+ if (!msg.success) {
+ return;
+ }
+ try {
+ ips = JSON.parse(msg.obj)
+ ips = ips.join(",")
+ event.target.value = ips
+ } catch (error) {
+ // text
+ event.target.value = msg.obj
+ }
+ },
+ async clearDBClientIps(email,event) {
+ const msg = await HttpUtil.post('/xui/inbound/clearClientIps/'+ email);
+ if (!msg.success) {
+ return;
+ }
+ event.target.value = ""
+ },
+ },
+ });
+</script>
+{{end}}