inbound_client_table.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. {{define "client_table"}}
  2. <template slot="actions" slot-scope="text, client, index">
  3. <a-tooltip>
  4. <template slot="title">{{ i18n "qrCode" }}</template>
  5. <a-icon style="font-size: 24px;" class="normal-icon" type="qrcode" v-if="record.hasLink()" @click="showQrcode(record.id,client);"></a-icon>
  6. </a-tooltip>
  7. <a-tooltip>
  8. <template slot="title">{{ i18n "pages.client.edit" }}</template>
  9. <a-icon style="font-size: 24px;" class="normal-icon" type="edit" @click="openEditClient(record.id,client);"></a-icon>
  10. </a-tooltip>
  11. <a-tooltip>
  12. <template slot="title">{{ i18n "info" }}</template>
  13. <a-icon style="font-size: 24px;" class="normal-icon" type="info-circle" @click="showInfo(record.id,client);"></a-icon>
  14. </a-tooltip>
  15. <a-tooltip>
  16. <template slot="title">{{ i18n "pages.inbounds.resetTraffic" }}</template>
  17. <a-popconfirm @confirm="resetClientTraffic(client,record.id,false)" title='{{ i18n "pages.inbounds.resetTrafficContent"}}' :overlay-class-name="themeSwitcher.currentTheme" ok-text='{{ i18n "reset"}}' cancel-text='{{ i18n "cancel"}}'>
  18. <a-icon slot="icon" type="question-circle-o" :style="themeSwitcher.isDarkTheme ? 'color: var(--color-primary-100)' : 'color: var(--color-primary-100)'"></a-icon>
  19. <a-icon style="font-size: 24px; cursor: pointer;" class="normal-icon" type="retweet" v-if="client.email.length > 0"></a-icon>
  20. </a-popconfirm>
  21. </a-tooltip>
  22. <a-tooltip>
  23. <template slot="title">
  24. <span style="color: #FF4D4F"> {{ i18n "delete"}}</span>
  25. </template>
  26. <a-popconfirm @confirm="delClient(record.id,client,false)" title='{{ i18n "pages.inbounds.deleteClientContent"}}' :overlay-class-name="themeSwitcher.currentTheme" ok-text='{{ i18n "delete"}}' ok-type="danger" cancel-text='{{ i18n "cancel"}}'>
  27. <a-icon slot="icon" type="question-circle-o" style="color: #e04141"></a-icon>
  28. <a-icon style="font-size: 24px; cursor: pointer;" class="delete-icon" type="delete" v-if="isRemovable(record.id)"></a-icon>
  29. </a-popconfirm>
  30. </a-tooltip>
  31. </template>
  32. <template slot="enable" slot-scope="text, client, index">
  33. <a-switch v-model="client.enable" @change="switchEnableClient(record.id,client)"></a-switch>
  34. </template>
  35. <template slot="online" slot-scope="text, client, index">
  36. <template v-if="client.enable && isClientOnline(client.email)">
  37. <a-tag color="green">{{ i18n "online" }}</a-tag>
  38. </template>
  39. <template v-else>
  40. <a-tag>{{ i18n "offline" }}</a-tag>
  41. </template>
  42. </template>
  43. <template slot="client" slot-scope="text, client">
  44. <a-tooltip>
  45. <template slot="title">
  46. <template v-if="!isClientEnabled(record, client.email)">{{ i18n "depleted" }}</template>
  47. <template v-else-if="!client.enable">{{ i18n "disabled" }}</template>
  48. <template v-else-if="client.enable && isClientOnline(client.email)">{{ i18n "online" }}</template>
  49. </template>
  50. <a-badge :class="isClientOnline(client.email)? 'online-animation' : ''" :color="client.enable ? statsExpColor(record, client.email) : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'"></a-badge>
  51. </a-tooltip> [[ client.email ]]
  52. </template>
  53. <template slot="traffic" slot-scope="text, client">
  54. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  55. <template slot="content" v-if="client.email">
  56. <table cellpadding="2" width="100%">
  57. <tr>
  58. <td>↑[[ sizeFormat(getUpStats(record, client.email)) ]]</td>
  59. <td>↓[[ sizeFormat(getDownStats(record, client.email)) ]]</td>
  60. </tr>
  61. <tr v-if="client.totalGB > 0">
  62. <td>{{ i18n "remained" }}</td>
  63. <td>[[ sizeFormat(getRemStats(record, client.email)) ]]</td>
  64. </tr>
  65. </table>
  66. </template>
  67. <table>
  68. <tr class="tr-table-box">
  69. <td class="tr-table-rt"> [[ sizeFormat(getSumStats(record, client.email)) ]] </td>
  70. <td class="tr-table-bar" v-if="!client.enable">
  71. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? 'rgb(72 84 105)' : '#bcbcbc'" :show-info="false" :percent="statsProgress(record, client.email)" />
  72. </td>
  73. <td class="tr-table-bar" v-else-if="client.totalGB > 0">
  74. <a-progress :stroke-color="clientStatsColor(record, client.email)" :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="statsProgress(record, client.email)" />
  75. </td>
  76. <td v-else class="infinite-bar tr-table-bar">
  77. <a-progress :show-info="false" :percent="100"></a-progress>
  78. </td>
  79. <td class="tr-table-lt">
  80. <template v-if="client.totalGB > 0">[[ client._totalGB + "GB" ]]</template>
  81. <span v-else class="tr-infinity-ch">&infin;</span>
  82. </td>
  83. </tr>
  84. </table>
  85. </a-popover>
  86. </template>
  87. <template slot="expiryTime" slot-scope="text, client, index">
  88. <template v-if="client.expiryTime !=0 && client.reset >0">
  89. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  90. <template slot="content">
  91. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  92. </span>
  93. <span v-else>
  94. <template v-if="app.datepicker === 'gregorian'">
  95. [[ DateUtil.formatMillis(client._expiryTime) ]]
  96. </template>
  97. <template v-else>
  98. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  99. </template>
  100. </span>
  101. </template>
  102. <table>
  103. <tr class="tr-table-box">
  104. <td class="tr-table-rt"> [[ remainedDays(client.expiryTime) ]] </td>
  105. <td class="infinite-bar tr-table-bar">
  106. <a-progress :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
  107. </td>
  108. <td class="tr-table-lt">[[ client.reset + "d" ]]</td>
  109. </tr>
  110. </table>
  111. </a-popover>
  112. </template>
  113. <template v-else>
  114. <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
  115. <template slot="content">
  116. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  117. </span>
  118. <span v-else>
  119. <template v-if="app.datepicker === 'gregorian'">
  120. [[ DateUtil.formatMillis(client._expiryTime) ]]
  121. </template>
  122. <template v-else>
  123. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  124. </template>
  125. </span>
  126. </template>
  127. <a-tag style="min-width: 50px; border: none;" :color="userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag>
  128. </a-popover>
  129. <a-tag v-else :color="userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)" style="border: none;" class="infinite-tag">
  130. <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
  131. <path d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z" fill="currentColor"></path>
  132. </svg>
  133. </a-tag>
  134. </template>
  135. </template>
  136. <template slot="actionMenu" slot-scope="text, client, index">
  137. <a-dropdown :trigger="['click']">
  138. <a-icon @click="e => e.preventDefault()" type="ellipsis" style="font-size: 20px;"></a-icon>
  139. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  140. <a-menu-item v-if="record.hasLink()" @click="showQrcode(record.id,client);">
  141. <a-icon style="font-size: 14px;" type="qrcode"></a-icon>
  142. {{ i18n "qrCode" }}
  143. </a-menu-item>
  144. <a-menu-item @click="openEditClient(record.id,client);">
  145. <a-icon style="font-size: 14px;" type="edit"></a-icon>
  146. {{ i18n "pages.client.edit" }}
  147. </a-menu-item>
  148. <a-menu-item @click="showInfo(record.id,client);">
  149. <a-icon style="font-size: 14px;" type="info-circle"></a-icon>
  150. {{ i18n "info" }}
  151. </a-menu-item>
  152. <a-menu-item @click="resetClientTraffic(client,record.id)" v-if="client.email.length > 0">
  153. <a-icon style="font-size: 14px;" type="retweet"></a-icon>
  154. {{ i18n "pages.inbounds.resetTraffic" }}
  155. </a-menu-item>
  156. <a-menu-item v-if="isRemovable(record.id)" @click="delClient(record.id,client)">
  157. <a-icon style="font-size: 14px;" type="delete"></a-icon>
  158. <span style="color: #FF4D4F"> {{ i18n "delete"}}</span>
  159. </a-menu-item>
  160. <a-menu-item>
  161. <a-switch v-model="client.enable" size="small" @change="switchEnableClient(record.id,client)"></a-switch>
  162. {{ i18n "enable"}}
  163. </a-menu-item>
  164. </a-menu>
  165. </a-dropdown>
  166. </template>
  167. <template slot="info" slot-scope="text, client, index">
  168. <a-popover placement="bottomRight" :overlay-class-name="themeSwitcher.currentTheme" trigger="click">
  169. <template slot="content">
  170. <table>
  171. <tr>
  172. <td colspan="3" style="text-align: center;">{{ i18n "pages.inbounds.traffic" }}</td>
  173. </tr>
  174. <tr>
  175. <td width="80px" style="margin:0; text-align: right;font-size: 1em;"> [[ sizeFormat(getUpStats(record, client.email) + getDownStats(record, client.email)) ]] </td>
  176. <td width="120px" v-if="!client.enable">
  177. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? 'rgb(72 84 105)' : '#bcbcbc'" :show-info="false" :percent="statsProgress(record, client.email)" />
  178. </td>
  179. <td width="120px" v-else-if="client.totalGB > 0">
  180. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  181. <template slot="content" v-if="client.email">
  182. <table cellpadding="2" width="100%">
  183. <tr>
  184. <td>↑[[ sizeFormat(getUpStats(record, client.email)) ]]</td>
  185. <td>↓[[ sizeFormat(getDownStats(record, client.email)) ]]</td>
  186. </tr>
  187. <tr>
  188. <td>{{ i18n "remained" }}</td>
  189. <td>[[ sizeFormat(getRemStats(record, client.email)) ]]</td>
  190. </tr>
  191. </table>
  192. </template>
  193. <a-progress :stroke-color="clientStatsColor(record, client.email)" :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="statsProgress(record, client.email)" />
  194. </a-popover>
  195. </td>
  196. <td width="120px" v-else class="infinite-bar">
  197. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? '#2c1e32':'#F2EAF1'" :show-info="false" :percent="100"></a-progress>
  198. </td>
  199. <td width="80px">
  200. <template v-if="client.totalGB > 0">[[ client._totalGB + "GB" ]]</template>
  201. <span v-else class="tr-infinity-ch">&infin;</span>
  202. </td>
  203. </tr>
  204. <tr>
  205. <td colspan="3" style="text-align: center;">
  206. <a-divider style="margin: 0; border-collapse: separate;"></a-divider>
  207. {{ i18n "pages.inbounds.expireDate" }}
  208. </td>
  209. </tr>
  210. <tr>
  211. <template v-if="client.expiryTime !=0 && client.reset >0">
  212. <td width="80px" style="margin:0; text-align: right;font-size: 1em;"> [[ remainedDays(client.expiryTime) ]] </td>
  213. <td width="120px" class="infinite-bar">
  214. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  215. <template slot="content">
  216. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  217. </span>
  218. <span v-else>
  219. <template v-if="app.datepicker === 'gregorian'">
  220. [[ DateUtil.formatMillis(client._expiryTime) ]]
  221. </template>
  222. <template v-else>
  223. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  224. </template>
  225. </span>
  226. </template>
  227. <a-progress :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
  228. </a-popover>
  229. </td>
  230. <td width="60px">[[ client.reset + "d" ]]</td>
  231. </template>
  232. <template v-else>
  233. <td colspan="3" style="text-align: center;">
  234. <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
  235. <template slot="content">
  236. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  237. </span>
  238. <span v-else>
  239. <template v-if="app.datepicker === 'gregorian'">
  240. [[ DateUtil.formatMillis(client._expiryTime) ]]
  241. </template>
  242. <template v-else>
  243. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  244. </template>
  245. </span>
  246. </template>
  247. <a-tag style="min-width: 50px; border: none;" :color="userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag>
  248. </a-popover>
  249. <a-tag v-else :color="client.enable ? 'purple' : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'" class="infinite-tag">
  250. <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
  251. <path d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z" fill="currentColor"></path>
  252. </svg>
  253. </a-tag>
  254. </template>
  255. </td>
  256. </tr>
  257. </table>
  258. </template>
  259. <a-badge>
  260. <a-icon v-if="!client.enable" slot="count" type="pause-circle" theme="filled" :style="'color: ' + themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'"></a-icon>
  261. <a-button shape="round" size="small" style="font-size: 14px; padding: 0 10px;">
  262. <a-icon type="solution"></a-icon>
  263. </a-button>
  264. </a-badge>
  265. </a-popover>
  266. </template>
  267. {{end}}