1
0

inbound_info_modal.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. {{define "inboundInfoModal"}}
  2. <a-modal id="inbound-info-modal"
  3. v-model="infoModal.visible" title='{{ i18n "pages.inbounds.details"}}'
  4. :closable="true"
  5. :mask-closable="true"
  6. :class="siderDrawer.isDarkTheme ? darkClass : ''"
  7. :footer="null"
  8. width="600px"
  9. >
  10. <table style="margin-bottom: 10px; width: 100%;">
  11. <tr><td>
  12. <table>
  13. <tr><td>{{ i18n "protocol" }}</td><td><a-tag color="green">[[ dbInbound.protocol ]]</a-tag></td></tr>
  14. <tr><td>{{ i18n "pages.inbounds.address" }}</td><td><a-tag color="blue">[[ dbInbound.address ]]</a-tag></td></tr>
  15. <tr><td>{{ i18n "pages.inbounds.port" }}</td><td><a-tag color="green">[[ dbInbound.port ]]</a-tag></td></tr>
  16. </table>
  17. </td>
  18. <td v-if="dbInbound.isVMess || dbInbound.isVLess || dbInbound.isTrojan || dbInbound.isSS">
  19. <table>
  20. <tr>
  21. <td>{{ i18n "transmission" }}</td><td><a-tag color="green">[[ inbound.network ]]</a-tag></td>
  22. </tr>
  23. <template v-if="inbound.isTcp || inbound.isWs || inbound.isH2">
  24. <tr v-if="inbound.host"><td>{{ i18n "host" }}</td><td><a-tag color="green">[[ inbound.host ]]</a-tag></td></tr>
  25. <tr v-else><td>{{ i18n "host" }}</td><td><a-tag color="orange">{{ i18n "none" }}</a-tag></td></tr>
  26. <tr v-if="inbound.path"><td>{{ i18n "path" }}</td><td><a-tag color="green">[[ inbound.path ]]</a-tag></td></tr>
  27. <tr v-else><td>{{ i18n "path" }}</td><td><a-tag color="orange">{{ i18n "none" }}</a-tag></td></tr>
  28. </template>
  29. <template v-if="inbound.isQuic">
  30. <tr><td>quic {{ i18n "encryption" }}</td><td><a-tag color="green">[[ inbound.quicSecurity ]]</a-tag></td></tr>
  31. <tr><td>quic {{ i18n "password" }}</td><td><a-tag color="green">[[ inbound.quicKey ]]</a-tag></td></tr>
  32. <tr><td>quic {{ i18n "camouflage" }}</td><td><a-tag color="green">[[ inbound.quicType ]]</a-tag></td></tr>
  33. </template>
  34. <template v-if="inbound.isKcp">
  35. <tr><td>kcp {{ i18n "encryption" }}</td><td><a-tag color="green">[[ inbound.kcpType ]]</a-tag></td></tr>
  36. <tr><td>kcp {{ i18n "password" }}</td><td><a-tag color="green">[[ inbound.kcpSeed ]]</a-tag></td></tr>
  37. </template>
  38. <template v-if="inbound.isGrpc">
  39. <tr><td>grpc serviceName</td><td><a-tag color="green">[[ inbound.serviceName ]]</a-tag></td></tr>
  40. </template>
  41. </table>
  42. </td></tr>
  43. <tr colspan="2">
  44. <td v-if="inbound.tls">
  45. tls: <a-tag color="green">{{ i18n "enabled" }}</a-tag><br />
  46. tls {{ i18n "domainName" }}: <a-tag :color="inbound.serverName ? 'green' : 'orange'">[[ inbound.serverName ? inbound.serverName : '' ]]</a-tag>
  47. </td>
  48. <td v-else-if="inbound.xtls">
  49. xtls: <a-tag color="green">{{ i18n "enabled" }}</a-tag><br />
  50. xtls {{ i18n "domainName" }}: <a-tag :color="inbound.serverName ? 'green' : 'orange'">[[ inbound.serverName ? inbound.serverName : '' ]]</a-tag>
  51. </td>
  52. <td v-else>tls: <a-tag color="red">{{ i18n "disabled" }}</a-tag>
  53. </td>
  54. </tr>
  55. </table>
  56. <a-divider>{{ i18n "pages.inbounds.client" }}</a-divider>
  57. <table style="margin-bottom: 10px; width: 100%;">
  58. <tr><th>[[ Object.keys(infoModal.clientSettings)[0] ]]</th><th>[[ Object.keys(infoModal.clientSettings)[1] ]]</th><th>[[ Object.keys(infoModal.clientSettings)[2] ]]</th></tr>
  59. <tr>
  60. <td><a-tag color="green">[[ Object.values(infoModal.clientSettings)[0] ]]</a-tag></td>
  61. <td><a-tag color="green">[[ Object.values(infoModal.clientSettings)[1] ]]</a-tag></td>
  62. <td><a-tag color="green">[[ Object.values(infoModal.clientSettings)[2] ]]</a-tag></td>
  63. </tr>
  64. </table>
  65. <table style="margin-bottom: 10px; width: 100%;">
  66. <tr><th>{{ i18n "usage" }}</th><th>{{ i18n "pages.inbounds.totalFlow" }}</th><th>{{ i18n "pages.inbounds.expireDate" }}</th><th>{{ i18n "enable" }}</th></tr>
  67. <tr>
  68. <td>
  69. <a-tag :color="statsColor(infoModal.clientStats)">
  70. [[ sizeFormat(infoModal.clientStats['up']) ]] /
  71. [[ sizeFormat(infoModal.clientStats['down']) ]]
  72. ([[ sizeFormat(infoModal.clientStats['up'] + infoModal.clientStats['down']) ]])
  73. </a-tag>
  74. </td>
  75. <td>
  76. <a-tag v-if="infoModal.clientSettings.totalGB > 0" :color="statsColor(infoModal.clientStats)">[[ sizeFormat(infoModal.clientSettings.totalGB) ]]</a-tag>
  77. <a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
  78. </td>
  79. <td>
  80. <template v-if="infoModal.clientSettings.expiryTime > 0">
  81. <a-tag :color="infoModal.isExpired ? 'red' : 'blue'">
  82. [[ DateUtil.formatMillis(infoModal.clientSettings.expiryTime) ]]
  83. </a-tag>
  84. </template>
  85. <a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
  86. </td>
  87. <td>
  88. <a-tag v-if="infoModal.clientStats.enable" color="blue">{{ i18n "enabled" }}</a-tag>
  89. <a-tag v-else color="red">{{ i18n "disabled" }}</a-tag>
  90. </td>
  91. </tr>
  92. </table>
  93. <div v-if="dbInbound.hasLink()">
  94. <a-divider>URL</a-divider>
  95. <p>[[ infoModal.link ]]</p>
  96. <button class="ant-btn ant-btn-primary" id="copy-url-link"><a-icon type="snippets"></a-icon>{{ i18n "copy" }}</button>
  97. </div>
  98. </a-modal>
  99. <script>
  100. const infoModal = {
  101. visible: false,
  102. inbound: new Inbound(),
  103. dbInbound: new DBInbound(),
  104. clientSettings: new Inbound.Settings(),
  105. clientStats: [],
  106. upStats: 0,
  107. downStats: 0,
  108. clipboard: null,
  109. link: null,
  110. index: 0,
  111. isExpired: false,
  112. show(dbInbound, index=0) {
  113. this.index = index;
  114. this.inbound = dbInbound.toInbound();
  115. this.dbInbound = new DBInbound(dbInbound);
  116. this.link = dbInbound.genLink(index);
  117. this.clientSettings = Object.values(JSON.parse(this.inbound.settings).clients)[index];
  118. this.clientStats = dbInbound.clientStats;
  119. this.isExpired = this.inbound.isExpiry(index);
  120. if(dbInbound.clientStats.length > 0)
  121. {
  122. for (const key in dbInbound.clientStats) {
  123. if (Object.hasOwnProperty.call(dbInbound.clientStats, key)) {
  124. if(dbInbound.clientStats[key]['email'] == this.clientSettings.email)
  125. this.clientStats = dbInbound.clientStats[key];
  126. }
  127. }
  128. }
  129. this.visible = true;
  130. infoModalApp.$nextTick(() => {
  131. if (this.clipboard === null) {
  132. this.clipboard = new ClipboardJS('#copy-url-link', {
  133. text: () => this.link,
  134. });
  135. this.clipboard.on('success', () => app.$message.success('{{ i18n "copySuccess" }}'));
  136. }
  137. });
  138. },
  139. close() {
  140. infoModal.visible = false;
  141. },
  142. };
  143. const infoModalApp = new Vue({
  144. delimiters: ['[[', ']]'],
  145. el: '#inbound-info-modal',
  146. data: {
  147. infoModal,
  148. get dbInbound() {
  149. return this.infoModal.dbInbound;
  150. },
  151. get inbound() {
  152. return this.infoModal.inbound;
  153. }
  154. },
  155. methods: {
  156. setQrCode(elmentId,index) {
  157. content = infoModal.inbound.genLink(infoModal.dbInbound.address,infoModal.dbInbound.remark,index)
  158. new QRious({
  159. element: document.querySelector('#'+elmentId),
  160. size: 260,
  161. value: content,
  162. });
  163. },
  164. copyTextToClipboard(elmentId,content) {
  165. this.infoModal.clipboard = new ClipboardJS('#' + elmentId, {
  166. text: () => content,
  167. });
  168. this.infoModal.clipboard.on('success', () => {
  169. app.$message.success('{{ i18n "copySuccess" }}')
  170. this.infoModal.clipboard.destroy();
  171. });
  172. },
  173. statsColor(stats) {
  174. if(stats['total'] === 0) return 'blue'
  175. else if(stats['total'] > 0 && (stats['down']+stats['up']) < stats['total']) return 'cyan'
  176. else return 'red'
  177. }
  178. },
  179. });
  180. </script>
  181. {{end}}