inbounds.html 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. {{template "head" .}}
  4. <style>
  5. @media (min-width: 769px) {
  6. .ant-layout-content {
  7. margin: 24px 16px;
  8. }
  9. }
  10. .ant-col-sm-24 {
  11. margin-top: 10px;
  12. }
  13. </style>
  14. <body>
  15. <a-layout id="app" v-cloak>
  16. {{ template "commonSider" . }}
  17. <a-layout id="content-layout" :style="siderDrawer.isDarkTheme ? bgDarkStyle : ''">
  18. <a-layout-content>
  19. <a-spin :spinning="spinning" :delay="500" tip="loading">
  20. <transition name="list" appear>
  21. <a-tag v-if="false" color="red" style="margin-bottom: 10px">
  22. Please go to the panel settings as soon as possible to modify the username and password, otherwise there may be a risk of leaking account information
  23. </a-tag>
  24. </transition>
  25. <transition name="list" appear>
  26. <a-card hoverable style="margin-bottom: 20px;" :class="siderDrawer.isDarkTheme ? darkClass : ''">
  27. <a-row>
  28. <a-col :xs="24" :sm="24" :lg="12">
  29. {{ i18n "pages.inbounds.totalDownUp" }}:
  30. <a-tag color="green">[[ sizeFormat(total.up) ]] / [[ sizeFormat(total.down) ]]</a-tag>
  31. </a-col>
  32. <a-col :xs="24" :sm="24" :lg="12">
  33. {{ i18n "pages.inbounds.totalUsage" }}:
  34. <a-tag color="green">[[ sizeFormat(total.up + total.down) ]]</a-tag>
  35. </a-col>
  36. <a-col :xs="24" :sm="24" :lg="12">
  37. {{ i18n "pages.inbounds.inboundCount" }}:
  38. <a-tag color="green">[[ dbInbounds.length ]]</a-tag>
  39. </a-col>
  40. <a-col :xs="24" :sm="24" :lg="12">
  41. {{ i18n "clients" }}:
  42. <a-tag color="green">[[ total.clients ]]</a-tag>
  43. <a-tag color="blue">{{ i18n "enabled" }} [[ total.active ]]</a-tag>
  44. <a-tag color="red">{{ i18n "disabled" }} [[ total.deactive ]]</a-tag>
  45. </a-col>
  46. </a-row>
  47. </a-card>
  48. </transition>
  49. <transition name="list" appear>
  50. <a-card hoverable :class="siderDrawer.isDarkTheme ? darkClass : ''">
  51. <div slot="title">
  52. <a-button type="primary" icon="plus" @click="openAddInbound">{{ i18n "pages.inbounds.addInbound" }}</a-button>
  53. <a-button type="primary" icon="export" @click="exportAllLinks">{{ i18n "pages.inbounds.export" }}</a-button>
  54. </div>
  55. <a-input v-model.lazy="searchKey" placeholder="{{ i18n "search" }}" autofocus style="max-width: 300px"></a-input>
  56. <a-table :columns="columns" :row-key="dbInbound => dbInbound.id"
  57. :data-source="searchedInbounds"
  58. :loading="spinning" :scroll="{ x: 1300 }"
  59. :pagination="false"
  60. style="margin-top: 20px"
  61. @change="() => getDBInbounds()">
  62. <template slot="action" slot-scope="text, dbInbound">
  63. <a-icon type="edit" style="font-size: 25px" @click="openEditInbound(dbInbound.id);"></a-icon>
  64. <a-dropdown :trigger="['click']">
  65. <a @click="e => e.preventDefault()">{{ i18n "pages.inbounds.operate" }}</a>
  66. <a-menu slot="overlay" @click="a => clickAction(a, dbInbound)" :theme="siderDrawer.theme" style="border: 1px solid rgba(255, 255, 255, 0.65);">
  67. <a-menu-item v-if="dbInbound.isSS" key="qrcode">
  68. <a-icon type="qrcode"></a-icon>
  69. {{ i18n "qrCode" }}
  70. </a-menu-item>
  71. <a-menu-item key="edit">
  72. <a-icon type="edit"></a-icon>
  73. {{ i18n "edit" }}
  74. </a-menu-item>
  75. <template v-if="dbInbound.isTrojan || dbInbound.isVLess || dbInbound.isVMess">
  76. <a-menu-item key="addClient">
  77. <a-icon type="user"></a-icon>
  78. {{ i18n "pages.client.add"}}
  79. </a-menu-item>
  80. <a-menu-item key="addBulkClient">
  81. <a-icon type="team"></a-icon>
  82. {{ i18n "pages.client.bulk"}}
  83. </a-menu-item>
  84. <a-menu-item key="export">
  85. <a-icon type="export"></a-icon>
  86. {{ i18n "pages.inbounds.export"}}
  87. </a-menu-item>
  88. </template>
  89. <template v-else>
  90. <a-menu-item key="showInfo">
  91. <a-icon type="info-circle"></a-icon>
  92. {{ i18n "info"}}
  93. </a-menu-item>
  94. </template>
  95. <a-menu-item key="resetTraffic">
  96. <a-icon type="retweet"></a-icon> {{ i18n "pages.inbounds.resetTraffic" }}
  97. </a-menu-item>
  98. <a-menu-item key="delete">
  99. <span style="color: #FF4D4F">
  100. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  101. </span>
  102. </a-menu-item>
  103. </a-menu>
  104. </a-dropdown>
  105. </template>
  106. <template slot="protocol" slot-scope="text, dbInbound">
  107. <a-tag color="blue">[[ dbInbound.protocol ]]</a-tag>
  108. </template>
  109. <template slot="traffic" slot-scope="text, dbInbound">
  110. <a-tag color="blue">[[ sizeFormat(dbInbound.up) ]] / [[ sizeFormat(dbInbound.down) ]]</a-tag>
  111. <template v-if="dbInbound.total > 0">
  112. <a-tag v-if="dbInbound.up + dbInbound.down < dbInbound.total" color="cyan">[[ sizeFormat(dbInbound.total) ]]</a-tag>
  113. <a-tag v-else color="red">[[ sizeFormat(dbInbound.total) ]]</a-tag>
  114. </template>
  115. <a-tag v-else color="green">{{ i18n "unlimited" }}</a-tag>
  116. </template>
  117. <template slot="stream" slot-scope="text, dbInbound, index">
  118. <template v-if="dbInbound.isVMess || dbInbound.isVLess || dbInbound.isTrojan || dbInbound.isSS">
  119. <a-tag color="green">[[ inbounds[index].stream.network ]]</a-tag>
  120. <a-tag v-if="inbounds[index].stream.isTls" color="blue">tls</a-tag>
  121. <a-tag v-if="inbounds[index].stream.isXTls" color="blue">xtls</a-tag>
  122. </template>
  123. <template v-else>{{ i18n "none" }}</template>
  124. </template>
  125. <template slot="enable" slot-scope="text, dbInbound">
  126. <a-switch v-model="dbInbound.enable" @change="switchEnable(dbInbound.id)"></a-switch>
  127. </template>
  128. <template slot="expiryTime" slot-scope="text, dbInbound">
  129. <template v-if="dbInbound.expiryTime > 0">
  130. <a-tag v-if="dbInbound.isExpiry" color="red">
  131. [[ DateUtil.formatMillis(dbInbound.expiryTime) ]]
  132. </a-tag>
  133. <a-tag v-else color="blue">
  134. [[ DateUtil.formatMillis(dbInbound.expiryTime) ]]
  135. </a-tag>
  136. </template>
  137. <a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
  138. </template>
  139. <template slot="expandedRowRender" slot-scope="record">
  140. <a-table
  141. v-if="(record.protocol === Protocols.VLESS) || (record.protocol === Protocols.VMESS)"
  142. :row-key="client => client.id"
  143. :columns="innerColumns"
  144. :data-source="getInboundClients(record)"
  145. :pagination="false"
  146. >
  147. {{template "client_table"}}
  148. </a-table>
  149. <a-table
  150. v-else-if="record.protocol === Protocols.TROJAN"
  151. :row-key="client => client.id"
  152. :columns="innerTrojanColumns"
  153. :data-source="getInboundClients(record)"
  154. :pagination="false"
  155. >
  156. {{template "client_table"}}
  157. </a-table>
  158. </template>
  159. </a-table>
  160. </a-card>
  161. </transition>
  162. </a-spin>
  163. </a-layout-content>
  164. </a-layout>
  165. </a-layout>
  166. {{template "js" .}}
  167. <script>
  168. const columns = [{
  169. title: '{{ i18n "pages.inbounds.operate" }}',
  170. align: 'center',
  171. width: 60,
  172. scopedSlots: { customRender: 'action' },
  173. }, {
  174. title: '{{ i18n "pages.inbounds.enable" }}',
  175. align: 'center',
  176. width: 40,
  177. scopedSlots: { customRender: 'enable' },
  178. }, {
  179. title: "ID",
  180. align: 'center',
  181. dataIndex: "id",
  182. width: 30,
  183. }, {
  184. title: '{{ i18n "pages.inbounds.remark" }}',
  185. align: 'center',
  186. width: 80,
  187. dataIndex: "remark",
  188. }, {
  189. title: '{{ i18n "pages.inbounds.protocol" }}',
  190. align: 'center',
  191. width: 50,
  192. scopedSlots: { customRender: 'protocol' },
  193. }, {
  194. title: '{{ i18n "pages.inbounds.port" }}',
  195. align: 'center',
  196. dataIndex: "port",
  197. width: 40,
  198. }, {
  199. title: '{{ i18n "pages.inbounds.traffic" }}↑|↓',
  200. align: 'center',
  201. width: 150,
  202. scopedSlots: { customRender: 'traffic' },
  203. }, {
  204. title: '{{ i18n "pages.inbounds.transportConfig" }}',
  205. align: 'center',
  206. width: 60,
  207. scopedSlots: { customRender: 'stream' },
  208. }, {
  209. title: '{{ i18n "pages.inbounds.expireDate" }}',
  210. align: 'center',
  211. width: 80,
  212. scopedSlots: { customRender: 'expiryTime' },
  213. }];
  214. const innerColumns = [
  215. { title: '{{ i18n "pages.inbounds.operate" }}', width: 70, scopedSlots: { customRender: 'actions' } },
  216. { title: '{{ i18n "pages.inbounds.client" }}', width: 60, scopedSlots: { customRender: 'client' } },
  217. { title: '{{ i18n "pages.inbounds.traffic" }}↑|↓', width: 100, scopedSlots: { customRender: 'traffic' } },
  218. { title: '{{ i18n "pages.inbounds.expireDate" }}', width: 70, scopedSlots: { customRender: 'expiryTime' } },
  219. { title: 'UID', width: 150, dataIndex: "id" },
  220. ];
  221. const innerTrojanColumns = [
  222. { title: '{{ i18n "pages.inbounds.operate" }}', width: 70, scopedSlots: { customRender: 'actions' } },
  223. { title: '{{ i18n "pages.inbounds.client" }}', width: 60, scopedSlots: { customRender: 'client' } },
  224. { title: '{{ i18n "pages.inbounds.traffic" }}↑|↓', width: 100, scopedSlots: { customRender: 'traffic' } },
  225. { title: '{{ i18n "pages.inbounds.expireDate" }}', width: 70, scopedSlots: { customRender: 'expiryTime' } },
  226. { title: 'Password', width: 100, dataIndex: "password" },
  227. ];
  228. const app = new Vue({
  229. delimiters: ['[[', ']]'],
  230. el: '#app',
  231. data: {
  232. siderDrawer,
  233. spinning: false,
  234. inbounds: [],
  235. dbInbounds: [],
  236. searchKey: '',
  237. searchedInbounds: [],
  238. },
  239. methods: {
  240. loading(spinning=true) {
  241. this.spinning = spinning;
  242. },
  243. async getDBInbounds() {
  244. this.loading();
  245. const msg = await HttpUtil.post('/xui/inbound/list');
  246. this.loading(false);
  247. if (!msg.success) {
  248. return;
  249. }
  250. this.setInbounds(msg.obj);
  251. this.searchKey = '';
  252. },
  253. setInbounds(dbInbounds) {
  254. this.inbounds.splice(0);
  255. this.dbInbounds.splice(0);
  256. this.searchedInbounds.splice(0);
  257. for (const inbound of dbInbounds) {
  258. const dbInbound = new DBInbound(inbound);
  259. this.inbounds.push(dbInbound.toInbound());
  260. this.dbInbounds.push(dbInbound);
  261. this.searchedInbounds.push(dbInbound);
  262. }
  263. },
  264. searchInbounds(key) {
  265. if (ObjectUtil.isEmpty(key)) {
  266. this.searchedInbounds = this.dbInbounds.slice();
  267. } else {
  268. this.searchedInbounds.splice(0, this.searchedInbounds.length);
  269. this.dbInbounds.forEach(inbound => {
  270. if (ObjectUtil.deepSearch(inbound, key)) {
  271. const newInbound = new DBInbound(inbound);
  272. const inboundSettings = JSON.parse(inbound.settings);
  273. if (inboundSettings.hasOwnProperty('clients')){
  274. const searchedSettings = { "clients": [] };
  275. inboundSettings.clients.forEach(client => {
  276. if (ObjectUtil.deepSearch(client, key)){
  277. searchedSettings.clients.push(client);
  278. }
  279. });
  280. newInbound.settings = Inbound.Settings.fromJson(inbound.protocol, searchedSettings);
  281. }
  282. this.searchedInbounds.push(newInbound);
  283. }
  284. });
  285. }
  286. },
  287. clickAction(action, dbInbound) {
  288. switch (action.key) {
  289. case "qrcode":
  290. this.showQrcode(dbInbound);
  291. break;
  292. case "showInfo":
  293. this.showInfo(dbInbound);
  294. break;
  295. case "edit":
  296. this.openEditInbound(dbInbound.id);
  297. break;
  298. case "addClient":
  299. this.openAddClient(dbInbound.id)
  300. break;
  301. case "addBulkClient":
  302. this.openAddBulkClient(dbInbound.id)
  303. break;
  304. case "export":
  305. this.inboundLinks(dbInbound.id);
  306. break;
  307. case "resetTraffic":
  308. this.resetTraffic(dbInbound.id);
  309. break;
  310. case "delete":
  311. this.delInbound(dbInbound.id);
  312. break;
  313. }
  314. },
  315. openAddInbound() {
  316. inModal.show({
  317. title: '{{ i18n "pages.inbounds.addInbound"}}',
  318. okText: '{{ i18n "pages.inbounds.addTo"}}',
  319. cancelText: '{{ i18n "close" }}',
  320. confirm: async (inbound, dbInbound) => {
  321. inModal.loading();
  322. await this.addInbound(inbound, dbInbound);
  323. inModal.close();
  324. },
  325. isEdit: false
  326. });
  327. },
  328. openEditInbound(dbInboundId) {
  329. dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
  330. const inbound = dbInbound.toInbound();
  331. inModal.show({
  332. title: '{{ i18n "pages.inbounds.modifyInbound"}}',
  333. okText: '{{ i18n "pages.inbounds.revise"}}',
  334. cancelText: '{{ i18n "close" }}',
  335. inbound: inbound,
  336. dbInbound: dbInbound,
  337. confirm: async (inbound, dbInbound) => {
  338. inModal.loading();
  339. await this.updateInbound(inbound, dbInbound);
  340. inModal.close();
  341. },
  342. isEdit: true
  343. });
  344. },
  345. async addInbound(inbound, dbInbound) {
  346. const data = {
  347. up: dbInbound.up,
  348. down: dbInbound.down,
  349. total: dbInbound.total,
  350. remark: dbInbound.remark,
  351. enable: dbInbound.enable,
  352. expiryTime: dbInbound.expiryTime,
  353. listen: inbound.listen,
  354. port: inbound.port,
  355. protocol: inbound.protocol,
  356. settings: inbound.settings.toString(),
  357. };
  358. if (inbound.canEnableStream()) data.streamSettings = inbound.stream.toString();
  359. if (inbound.canSniffing()) data.sniffing = inbound.sniffing.toString();
  360. await this.submit('/xui/inbound/add', data, inModal);
  361. },
  362. async updateInbound(inbound, dbInbound) {
  363. const data = {
  364. up: dbInbound.up,
  365. down: dbInbound.down,
  366. total: dbInbound.total,
  367. remark: dbInbound.remark,
  368. enable: dbInbound.enable,
  369. expiryTime: dbInbound.expiryTime,
  370. listen: inbound.listen,
  371. port: inbound.port,
  372. protocol: inbound.protocol,
  373. settings: inbound.settings.toString(),
  374. };
  375. if (inbound.canEnableStream()) data.streamSettings = inbound.stream.toString();
  376. if (inbound.canSniffing()) data.sniffing = inbound.sniffing.toString();
  377. await this.submit(`/xui/inbound/update/${dbInbound.id}`, data, inModal);
  378. },
  379. openAddClient(dbInboundId) {
  380. dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
  381. clientModal.show({
  382. title: '{{ i18n "pages.client.add"}}',
  383. okText: '{{ i18n "pages.client.submitAdd"}}',
  384. dbInbound: dbInbound,
  385. confirm: async (inbound, dbInbound, index) => {
  386. clientModal.loading();
  387. await this.addClient(inbound, dbInbound);
  388. clientModal.close();
  389. },
  390. isEdit: false
  391. });
  392. },
  393. openAddBulkClient(dbInboundId) {
  394. dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
  395. clientsBulkModal.show({
  396. title: '{{ i18n "pages.client.bulk"}} ' + dbInbound.remark,
  397. okText: '{{ i18n "pages.client.bulk"}}',
  398. dbInbound: dbInbound,
  399. confirm: async (inbound, dbInbound) => {
  400. clientsBulkModal.loading();
  401. await this.addClient(inbound, dbInbound);
  402. clientsBulkModal.close();
  403. },
  404. });
  405. },
  406. openEditClient(dbInboundId, client) {
  407. dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
  408. clients = this.getInboundClients(dbInbound);
  409. index = this.findIndexOfClient(clients, client);
  410. clientModal.show({
  411. title: '{{ i18n "pages.client.edit"}}',
  412. okText: '{{ i18n "pages.client.submitEdit"}}',
  413. dbInbound: dbInbound,
  414. index: index,
  415. confirm: async (inbound, dbInbound, index) => {
  416. clientModal.loading();
  417. await this.updateClient(inbound, dbInbound, index);
  418. clientModal.close();
  419. },
  420. isEdit: true
  421. });
  422. },
  423. findIndexOfClient(clients,client) {
  424. firstKey = Object.keys(client)[0];
  425. return clients.findIndex(c => c[firstKey] === client[firstKey]);
  426. },
  427. async addClient(inbound, dbInbound) {
  428. const data = {
  429. id: dbInbound.id,
  430. settings: inbound.settings.toString(),
  431. };
  432. await this.submit('/xui/inbound/addClient', data);
  433. },
  434. async updateClient(inbound, dbInbound, index) {
  435. const data = {
  436. id: dbInbound.id,
  437. settings: inbound.settings.toString(),
  438. };
  439. await this.submit(`/xui/inbound/updateClient/${index}`, data);
  440. },
  441. resetTraffic(dbInboundId) {
  442. dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
  443. this.$confirm({
  444. title: '{{ i18n "pages.inbounds.resetTraffic"}}',
  445. content: '{{ i18n "pages.inbounds.resetTrafficContent"}}',
  446. class: siderDrawer.isDarkTheme ? darkClass : '',
  447. okText: '{{ i18n "reset"}}',
  448. cancelText: '{{ i18n "cancel"}}',
  449. onOk: () => {
  450. const inbound = dbInbound.toInbound();
  451. dbInbound.up = 0;
  452. dbInbound.down = 0;
  453. this.updateInbound(inbound, dbInbound);
  454. },
  455. });
  456. },
  457. delInbound(dbInboundId) {
  458. this.$confirm({
  459. title: '{{ i18n "pages.inbounds.deleteInbound"}}',
  460. content: '{{ i18n "pages.inbounds.deleteInboundContent"}}',
  461. class: siderDrawer.isDarkTheme ? darkClass : '',
  462. okText: '{{ i18n "delete"}}',
  463. cancelText: '{{ i18n "cancel"}}',
  464. onOk: () => this.submit('/xui/inbound/del/' + dbInboundId),
  465. });
  466. },
  467. delClient(dbInboundId,client) {
  468. dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
  469. newDbInbound = new DBInbound(dbInbound);
  470. inbound = newDbInbound.toInbound();
  471. clients = this.getClients(dbInbound.protocol, inbound.settings);
  472. index = this.findIndexOfClient(clients, client);
  473. clients.splice(index, 1);
  474. const data = {
  475. id: dbInboundId,
  476. settings: inbound.settings.toString(),
  477. };
  478. this.$confirm({
  479. title: '{{ i18n "pages.inbounds.deleteInbound"}}',
  480. content: '{{ i18n "pages.inbounds.deleteInboundContent"}}',
  481. class: siderDrawer.isDarkTheme ? darkClass : '',
  482. okText: '{{ i18n "delete"}}',
  483. cancelText: '{{ i18n "cancel"}}',
  484. onOk: () => this.submit('/xui/inbound/delClient/' + client.email, data),
  485. });
  486. },
  487. getClients(protocol, clientSettings) {
  488. switch(protocol){
  489. case Protocols.VMESS: return clientSettings.vmesses;
  490. case Protocols.VLESS: return clientSettings.vlesses;
  491. case Protocols.TROJAN: return clientSettings.trojans;
  492. default: return null;
  493. }
  494. },
  495. showQrcode(dbInbound, clientIndex) {
  496. const link = dbInbound.genLink(clientIndex);
  497. qrModal.show('{{ i18n "qrCode"}}', link, dbInbound);
  498. },
  499. showInfo(dbInbound, index) {
  500. infoModal.show(dbInbound, index);
  501. },
  502. switchEnable(dbInboundId) {
  503. dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
  504. this.submit(`/xui/inbound/update/${dbInboundId}`, dbInbound);
  505. },
  506. async submit(url, data) {
  507. const msg = await HttpUtil.postWithModal(url, data);
  508. if (msg.success) {
  509. await this.getDBInbounds();
  510. }
  511. },
  512. getInboundClients(dbInbound) {
  513. if(dbInbound.protocol == Protocols.VLESS) {
  514. return dbInbound.toInbound().settings.vlesses
  515. } else if(dbInbound.protocol == Protocols.VMESS) {
  516. return dbInbound.toInbound().settings.vmesses
  517. } else if(dbInbound.protocol == Protocols.TROJAN) {
  518. return dbInbound.toInbound().settings.trojans
  519. }
  520. },
  521. resetClientTraffic(client,dbInboundId) {
  522. this.$confirm({
  523. title: '{{ i18n "pages.inbounds.resetTraffic"}}',
  524. content: '{{ i18n "pages.inbounds.resetTrafficContent"}}',
  525. class: siderDrawer.isDarkTheme ? darkClass : '',
  526. okText: '{{ i18n "reset"}}',
  527. cancelText: '{{ i18n "cancel"}}',
  528. onOk: () => this.submit('/xui/inbound/' + dbInboundId + '/resetClientTraffic/'+ client.email),
  529. })
  530. },
  531. isExpiry(dbInbound, index) {
  532. return dbInbound.toInbound().isExpiry(index)
  533. },
  534. getUpStats(dbInbound, email) {
  535. if(email.length == 0) return 0
  536. clientStats = dbInbound.clientStats.find(stats => stats.email === email)
  537. return clientStats ? clientStats.up : 0
  538. },
  539. getDownStats(dbInbound, email) {
  540. if(email.length == 0) return 0
  541. clientStats = dbInbound.clientStats.find(stats => stats.email === email)
  542. return clientStats ? clientStats.down : 0
  543. },
  544. isTrafficExhausted(dbInbound, email) {
  545. if(email.length == 0) return false
  546. clientStats = dbInbound.clientStats.find(stats => stats.email === email)
  547. return clientStats ? clientStats.down + clientStats.up > clientStats.total : false
  548. },
  549. isClientEnabled(dbInbound, email) {
  550. clientStats = dbInbound.clientStats ? dbInbound.clientStats.find(stats => stats.email === email) : null
  551. return clientStats ? clientStats['enable'] : true
  552. },
  553. isRemovable(dbInbound_id){
  554. return this.getInboundClients(this.dbInbounds.find(row => row.id === dbInbound_id)).length > 1
  555. },
  556. inboundLinks(dbInboundId) {
  557. dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
  558. txtModal.show('{{ i18n "pages.inbounds.export"}}',dbInbound.genInboundLinks,dbInbound.remark);
  559. },
  560. exportAllLinks() {
  561. let copyText = '';
  562. for (const dbInbound of this.dbInbounds) {
  563. copyText += dbInbound.genInboundLinks
  564. }
  565. txtModal.show('{{ i18n "pages.inbounds.export"}}',copyText,'All-Inbounds');
  566. },
  567. },
  568. watch: {
  569. searchKey: debounce(function (newVal) {
  570. this.searchInbounds(newVal);
  571. }, 500)
  572. },
  573. mounted() {
  574. this.getDBInbounds();
  575. },
  576. computed: {
  577. total() {
  578. let down = 0, up = 0;
  579. let clients = 0, active = 0, deactive = 0;
  580. this.dbInbounds.forEach(dbInbound => {
  581. down += dbInbound.down;
  582. up += dbInbound.up;
  583. inbound = dbInbound.toInbound();
  584. clients = this.getClients(dbInbound.protocol, inbound.settings);
  585. if(clients){
  586. if(dbInbound.enable){
  587. isClientEnable = false;
  588. clients.forEach(client => {
  589. isClientEnable = client.email == "" ? true: this.isClientEnabled(dbInbound,client.email);
  590. isClientEnable ? active++ : deactive++;
  591. });
  592. } else {
  593. deactive += clients.length;
  594. }
  595. } else {
  596. dbInbound.enable ? active++ : deactive++;
  597. }
  598. });
  599. return {
  600. down: down,
  601. up: up,
  602. clients: active + deactive,
  603. active: active,
  604. deactive: deactive,
  605. };
  606. }
  607. },
  608. });
  609. </script>
  610. {{template "inboundModal"}}
  611. {{template "promptModal"}}
  612. {{template "qrcodeModal"}}
  613. {{template "textModal"}}
  614. {{template "inboundInfoModal"}}
  615. {{template "clientsModal"}}
  616. {{template "clientsBulkModal"}}
  617. </body>
  618. </html>