aClientTable.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. {{define "component/aClientTable"}}
  2. <template slot="actions" slot-scope="text, client, index">
  3. <a-tooltip>
  4. <template slot="title">{{ i18n "qrCode" }}</template>
  5. <a-icon :style="{ fontSize: '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="{ fontSize: '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="{ fontSize: '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="{ color: 'var(--color-primary-100)'}"></a-icon>
  19. <a-icon :style="{ fontSize: '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="{ fontSize: '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-space direction="horizontal" :size="2">
  45. <a-tooltip>
  46. <template slot="title">
  47. <template v-if="!isClientEnabled(record, client.email)">{{ i18n "depleted" }}</template>
  48. <template v-else-if="!client.enable">{{ i18n "disabled" }}</template>
  49. <template v-else-if="client.enable && isClientOnline(client.email)">{{ i18n "online" }}</template>
  50. </template>
  51. <a-badge :class="isClientOnline(client.email)? 'online-animation' : ''" :color="client.enable ? statsExpColor(record, client.email) : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'"></a-badge>
  52. </a-tooltip>
  53. <a-space direction="vertical" :size="2">
  54. <span class="client-email">[[ client.email ]]</span>
  55. <template v-if="client.comment && client.comment.trim()">
  56. <a-tooltip v-if="client.comment.length > 50" :overlay-class-name="themeSwitcher.currentTheme">
  57. <template slot="title">
  58. [[ client.comment ]]
  59. </template>
  60. <span class="client-comment">[[ client.comment.substring(0, 47) + '...' ]]</span>
  61. </a-tooltip>
  62. <span v-else class="client-comment">[[ client.comment ]]</span>
  63. </template>
  64. </a-space>
  65. </a-space>
  66. </template>
  67. <template slot="traffic" slot-scope="text, client">
  68. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  69. <template slot="content" v-if="client.email">
  70. <table cellpadding="2" width="100%">
  71. <tr>
  72. <td>↑[[ SizeFormatter.sizeFormat(getUpStats(record, client.email)) ]]</td>
  73. <td>↓[[ SizeFormatter.sizeFormat(getDownStats(record, client.email)) ]]</td>
  74. </tr>
  75. <tr v-if="client.totalGB > 0">
  76. <td>{{ i18n "remained" }}</td>
  77. <td>[[ SizeFormatter.sizeFormat(getRemStats(record, client.email)) ]]</td>
  78. </tr>
  79. </table>
  80. </template>
  81. <table>
  82. <tr class="tr-table-box">
  83. <td class="tr-table-rt"> [[ SizeFormatter.sizeFormat(getSumStats(record, client.email)) ]] </td>
  84. <td class="tr-table-bar" v-if="!client.enable">
  85. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? 'rgb(72 84 105)' : '#bcbcbc'" :show-info="false" :percent="statsProgress(record, client.email)" />
  86. </td>
  87. <td class="tr-table-bar" v-else-if="client.totalGB > 0">
  88. <a-progress :stroke-color="clientStatsColor(record, client.email)" :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="statsProgress(record, client.email)" />
  89. </td>
  90. <td v-else class="infinite-bar tr-table-bar">
  91. <a-progress :show-info="false" :percent="100"></a-progress>
  92. </td>
  93. <td class="tr-table-lt">
  94. <template v-if="client.totalGB > 0">[[ client._totalGB + "GB" ]]</template>
  95. <span v-else class="tr-infinity-ch">&infin;</span>
  96. </td>
  97. </tr>
  98. </table>
  99. </a-popover>
  100. </template>
  101. <template slot="expiryTime" slot-scope="text, client, index">
  102. <template v-if="client.expiryTime !=0 && client.reset >0">
  103. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  104. <template slot="content">
  105. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  106. </span>
  107. <span v-else>
  108. <template v-if="app.datepicker === 'gregorian'">
  109. [[ DateUtil.formatMillis(client._expiryTime) ]]
  110. </template>
  111. <template v-else>
  112. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  113. </template>
  114. </span>
  115. </template>
  116. <table>
  117. <tr class="tr-table-box">
  118. <td class="tr-table-rt"> [[ remainedDays(client.expiryTime) ]] </td>
  119. <td class="infinite-bar tr-table-bar">
  120. <a-progress :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
  121. </td>
  122. <td class="tr-table-lt">[[ client.reset + "d" ]]</td>
  123. </tr>
  124. </table>
  125. </a-popover>
  126. </template>
  127. <template v-else>
  128. <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
  129. <template slot="content">
  130. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  131. </span>
  132. <span v-else>
  133. <template v-if="app.datepicker === 'gregorian'">
  134. [[ DateUtil.formatMillis(client._expiryTime) ]]
  135. </template>
  136. <template v-else>
  137. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  138. </template>
  139. </span>
  140. </template>
  141. <a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag>
  142. </a-popover>
  143. <a-tag v-else :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)" :style="{ border: 'none' }" class="infinite-tag">
  144. <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
  145. <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>
  146. </svg>
  147. </a-tag>
  148. </template>
  149. </template>
  150. <template slot="actionMenu" slot-scope="text, client, index">
  151. <a-dropdown :trigger="['click']">
  152. <a-icon @click="e => e.preventDefault()" type="ellipsis" :style="{ fontSize: '20px' }"></a-icon>
  153. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  154. <a-menu-item v-if="record.hasLink()" @click="showQrcode(record.id,client);">
  155. <a-icon :style="{ fontSize: '14px' }" type="qrcode"></a-icon>
  156. {{ i18n "qrCode" }}
  157. </a-menu-item>
  158. <a-menu-item @click="openEditClient(record.id,client);">
  159. <a-icon :style="{ fontSize: '14px' }" type="edit"></a-icon>
  160. {{ i18n "pages.client.edit" }}
  161. </a-menu-item>
  162. <a-menu-item @click="showInfo(record.id,client);">
  163. <a-icon :style="{ fontSize: '14px' }" type="info-circle"></a-icon>
  164. {{ i18n "info" }}
  165. </a-menu-item>
  166. <a-menu-item @click="resetClientTraffic(client,record.id)" v-if="client.email.length > 0">
  167. <a-icon :style="{ fontSize: '14px' }" type="retweet"></a-icon>
  168. {{ i18n "pages.inbounds.resetTraffic" }}
  169. </a-menu-item>
  170. <a-menu-item v-if="isRemovable(record.id)" @click="delClient(record.id,client)">
  171. <a-icon :style="{ fontSize: '14px' }" type="delete"></a-icon>
  172. <span :style="{ color: '#FF4D4F' }"> {{ i18n "delete"}}</span>
  173. </a-menu-item>
  174. <a-menu-item>
  175. <a-switch v-model="client.enable" size="small" @change="switchEnableClient(record.id,client)"></a-switch>
  176. {{ i18n "enable"}}
  177. </a-menu-item>
  178. </a-menu>
  179. </a-dropdown>
  180. </template>
  181. <template slot="info" slot-scope="text, client, index">
  182. <a-popover placement="bottomRight" :overlay-class-name="themeSwitcher.currentTheme" trigger="click">
  183. <template slot="content">
  184. <table>
  185. <tr>
  186. <td colspan="3" :style="{ textAlign: 'center' }">{{ i18n "pages.inbounds.traffic" }}</td>
  187. </tr>
  188. <tr>
  189. <td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[ SizeFormatter.sizeFormat(getUpStats(record, client.email) + getDownStats(record, client.email)) ]] </td>
  190. <td width="120px" v-if="!client.enable">
  191. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? 'rgb(72 84 105)' : '#bcbcbc'" :show-info="false" :percent="statsProgress(record, client.email)" />
  192. </td>
  193. <td width="120px" v-else-if="client.totalGB > 0">
  194. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  195. <template slot="content" v-if="client.email">
  196. <table cellpadding="2" width="100%">
  197. <tr>
  198. <td>↑[[ SizeFormatter.sizeFormat(getUpStats(record, client.email)) ]]</td>
  199. <td>↓[[ SizeFormatter.sizeFormat(getDownStats(record, client.email)) ]]</td>
  200. </tr>
  201. <tr>
  202. <td>{{ i18n "remained" }}</td>
  203. <td>[[ SizeFormatter.sizeFormat(getRemStats(record, client.email)) ]]</td>
  204. </tr>
  205. </table>
  206. </template>
  207. <a-progress :stroke-color="clientStatsColor(record, client.email)" :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="statsProgress(record, client.email)" />
  208. </a-popover>
  209. </td>
  210. <td width="120px" v-else class="infinite-bar">
  211. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? '#2c1e32':'#F2EAF1'" :show-info="false" :percent="100"></a-progress>
  212. </td>
  213. <td width="80px">
  214. <template v-if="client.totalGB > 0">[[ client._totalGB + "GB" ]]</template>
  215. <span v-else class="tr-infinity-ch">&infin;</span>
  216. </td>
  217. </tr>
  218. <tr>
  219. <td colspan="3" :style="{ textAlign: 'center' }">
  220. <a-divider :style="{ margin: '0', borderCollapse: 'separate' }"></a-divider>
  221. {{ i18n "pages.inbounds.expireDate" }}
  222. </td>
  223. </tr>
  224. <tr>
  225. <template v-if="client.expiryTime !=0 && client.reset >0">
  226. <td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[ remainedDays(client.expiryTime) ]] </td>
  227. <td width="120px" class="infinite-bar">
  228. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  229. <template slot="content">
  230. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  231. </span>
  232. <span v-else>
  233. <template v-if="app.datepicker === 'gregorian'">
  234. [[ DateUtil.formatMillis(client._expiryTime) ]]
  235. </template>
  236. <template v-else>
  237. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  238. </template>
  239. </span>
  240. </template>
  241. <a-progress :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
  242. </a-popover>
  243. </td>
  244. <td width="60px">[[ client.reset + "d" ]]</td>
  245. </template>
  246. <template v-else>
  247. <td colspan="3" :style="{ textAlign: 'center' }">
  248. <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
  249. <template slot="content">
  250. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  251. </span>
  252. <span v-else>
  253. <template v-if="app.datepicker === 'gregorian'">
  254. [[ DateUtil.formatMillis(client._expiryTime) ]]
  255. </template>
  256. <template v-else>
  257. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  258. </template>
  259. </span>
  260. </template>
  261. <a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag>
  262. </a-popover>
  263. <a-tag v-else :color="client.enable ? 'purple' : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'" class="infinite-tag">
  264. <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
  265. <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>
  266. </svg>
  267. </a-tag>
  268. </template>
  269. </td>
  270. </tr>
  271. </table>
  272. </template>
  273. <a-badge>
  274. <a-icon v-if="!client.enable" slot="count" type="pause-circle" theme="filled" :style="{ color: themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc' }"></a-icon>
  275. <a-button shape="round" size="small" :style="{ fontSize: '14px', padding: '0 10px' }">
  276. <a-icon type="solution"></a-icon>
  277. </a-button>
  278. </a-badge>
  279. </a-popover>
  280. </template>
  281. {{end}}