aClientTable.html 15 KB

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