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

client_bulk_modal.html « xui « html « web - github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 19fd4b18a5ace5e2cb6bc53c3b785da5b85cb5ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{{define "clientsBulkModal"}}
<a-modal id="client-bulk-modal" v-model="clientsBulkModal.visible" :title="clientsBulkModal.title" @ok="clientsBulkModal.ok"
         :confirm-loading="clientsBulkModal.confirmLoading" :closable="true" :mask-closable="false"
         :class="siderDrawer.isDarkTheme ? darkClass : ''"
         :ok-text="clientsBulkModal.okText" cancel-text='{{ i18n "close" }}'>
    <a-form layout="inline">
        <a-form-item label='{{ i18n "pages.client.method" }}'>
            <a-select v-model="clientsBulkModal.emailMethod" buttonStyle="solid" style="width: 350px" :dropdown-class-name="siderDrawer.isDarkTheme ? 'ant-card-dark' : ''">
                <a-select-option :value="0">Random</a-select-option>
                <a-select-option :value="1">Random_Prefix</a-select-option>
                <a-select-option :value="2">Random_Prefix+Num</a-select-option>
                <a-select-option :value="3">Random_Prefix+Num+Postfix</a-select-option>
                <a-select-option :value="4">Random_Prefix+Num@Telegram Username</a-select-option>
            </a-select>
        </a-form-item><br />
        <a-form-item v-if="clientsBulkModal.emailMethod>1">
            <span slot="label">{{ i18n "pages.client.first" }}</span>
            <a-input-number v-model="clientsBulkModal.firstNum" :min="1"></a-input-number>
        </a-form-item>
        <a-form-item v-if="clientsBulkModal.emailMethod>1">
            <span slot="label">{{ i18n "pages.client.last" }}</span>
            <a-input-number v-model="clientsBulkModal.lastNum" :min="clientsBulkModal.firstNum"></a-input-number>
        </a-form-item>
        <a-form-item v-if="clientsBulkModal.emailMethod>0">
            <span slot="label">{{ i18n "pages.client.prefix" }}</span>
            <a-input v-model="clientsBulkModal.emailPrefix" style="width: 120px"></a-input>
        </a-form-item>
        <a-form-item v-if="clientsBulkModal.emailMethod>2">
            <span slot="label" v-if="clientsBulkModal.emailMethod == 4">tg_uname</span>
            <span slot="label" v-else>{{ i18n "pages.client.postfix" }}</span>
            <a-input v-model="clientsBulkModal.emailPostfix" style="width: 120px"></a-input>
        </a-form-item>

        <a-form-item v-if="clientsBulkModal.emailMethod < 2">
            <span slot="label">{{ i18n "pages.client.clientCount" }}</span>
            <a-input-number v-model="clientsBulkModal.quantity" :min="1" :max="100"></a-input-number>
        </a-form-item>
        <a-form-item>
            <span slot="label">
                <span >{{ i18n "pages.inbounds.totalFlow" }}</span>(GB)
                <a-tooltip>
                    <template slot="title">
                        0 <span>{{ i18n "pages.inbounds.meansNoLimit" }}</span>
                    </template>
                    <a-icon type="question-circle" theme="filled"></a-icon>
                </a-tooltip>
            </span>
        <a-input-number v-model="clientsBulkModal.totalGB" :min="0"></a-input-number>
        </a-form-item>
        <a-form-item>
            <span slot="label">
                <span >{{ i18n "pages.inbounds.expireDate" }}</span>
                <a-tooltip>
                    <template slot="title">
                        <span>{{ i18n "pages.inbounds.leaveBlankToNeverExpire" }}</span>
                    </template>
                    <a-icon type="question-circle" theme="filled"></a-icon>
                </a-tooltip>
            </span>
            <a-date-picker :show-time="{ format: 'HH:mm' }" format="YYYY-MM-DD HH:mm"
                           :dropdown-class-name="siderDrawer.isDarkTheme ? 'ant-card-dark' : ''"
                           v-model="clientsBulkModal.expiryTime" style="width: 300px;"></a-date-picker>
        </a-form-item>
    </a-form>
</a-modal>
<script>

    const clientsBulkModal = {
        visible: false,
        confirmLoading: false,
        title: '',
        okText: '',
        confirm: null,
        dbInbound: new DBInbound(),
        inbound: new Inbound(),
        clients: [],
        quantity: 1,
        totalGB: 0,
        expiryTime: '',
        emailMethod: 0,
        firstNum: 1,
        lastNum: 1,
        emailPrefix: "",
        emailPostfix: "",
        ok() {
            method=clientsBulkModal.emailMethod;
            if(method>1){
                start=clientsBulkModal.firstNum;
                end=clientsBulkModal.lastNum + 1;
            } else {
                start=0;
                end=clientsBulkModal.quantity;
            }
            prefix = (method>0 && clientsBulkModal.emailPrefix.length>0) ? "_" + clientsBulkModal.emailPrefix : "";
            useNum=(method>1);
            postfix = (method>2 && clientsBulkModal.emailPostfix.length>0) ? (method == 4 ? "@" : "") + clientsBulkModal.emailPostfix : "";
            for (let i = start; i < end; i++) {
                newClient = clientsBulkModal.newClient(clientsBulkModal.dbInbound.protocol);
                newClient.email += useNum ? prefix + i.toString() + postfix : prefix + postfix;
                newClient._totalGB = clientsBulkModal.totalGB;
                newClient._expiryTime = clientsBulkModal.expiryTime;
                clientsBulkModal.clients.push(newClient);
            }
            ObjectUtil.execute(clientsBulkModal.confirm, clientsBulkModal.inbound, clientsBulkModal.dbInbound);
        },
        show({ title='', okText='{{ i18n "sure" }}', dbInbound=null, confirm=(inbound, dbInbound)=>{} }) {
            this.visible = true;
            this.title = title;
            this.okText = okText;
            this.confirm = confirm;
            this.quantity = 1;
            this.totalGB = 0;
            this.expiryTime = '';
            this.emailMethod= 0;
            this.firstNum= 1;
            this.lastNum= 1;
            this.emailPrefix= "";
            this.emailPostfix= "";

            this.dbInbound = new DBInbound(dbInbound);
            this.inbound = dbInbound.toInbound();
            this.clients = this.getClients(this.inbound.protocol, this.inbound.settings);
        },
        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;
            }
        },
        newClient(protocol) {
            switch (protocol) {
                case Protocols.VMESS: return new Inbound.VmessSettings.Vmess();
                case Protocols.VLESS: return new Inbound.VLESSSettings.VLESS();
                case Protocols.TROJAN: return new Inbound.TrojanSettings.Trojan();
                default: return null;
            }
        },
        close() {
            clientsBulkModal.visible = false;
            clientsBulkModal.loading(false);
        },
        loading(loading) {
            clientsBulkModal.confirmLoading = loading;
        },
    };

    const clientsBulkModalApp = new Vue({
        delimiters: ['[[', ']]'],
        el: '#client-bulk-modal',
        data: {
            clientsBulkModal,
            get inbound() {
                return this.clientsBulkModal.inbound;
            },
        },
    });
</script>
{{end}}