inbounds.html 30 KB

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