aClientTable.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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="allTime" slot-scope="text, client">
  102. <a-tag>[[ SizeFormatter.sizeFormat(getAllTimeClient(record, client.email)) ]]</a-tag>
  103. </template>
  104. <template slot="expiryTime" slot-scope="text, client, index">
  105. <template v-if="client.expiryTime !=0 && client.reset >0">
  106. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  107. <template slot="content">
  108. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  109. </span>
  110. <span v-else>
  111. <template v-if="app.datepicker === 'gregorian'">
  112. [[ DateUtil.formatMillis(client._expiryTime) ]]
  113. </template>
  114. <template v-else>
  115. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  116. </template>
  117. </span>
  118. </template>
  119. <table>
  120. <tr class="tr-table-box">
  121. <td class="tr-table-rt"> [[ remainedDays(client.expiryTime) ]] </td>
  122. <td class="infinite-bar tr-table-bar">
  123. <a-progress :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
  124. </td>
  125. <td class="tr-table-lt">[[ client.reset + "d" ]]</td>
  126. </tr>
  127. </table>
  128. </a-popover>
  129. </template>
  130. <template v-else>
  131. <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
  132. <template slot="content">
  133. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  134. </span>
  135. <span v-else>
  136. <template v-if="app.datepicker === 'gregorian'">
  137. [[ DateUtil.formatMillis(client._expiryTime) ]]
  138. </template>
  139. <template v-else>
  140. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  141. </template>
  142. </span>
  143. </template>
  144. <a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag>
  145. </a-popover>
  146. <a-tag v-else :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)" :style="{ border: 'none' }" class="infinite-tag">
  147. <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
  148. <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>
  149. </svg>
  150. </a-tag>
  151. </template>
  152. </template>
  153. <template slot="actionMenu" slot-scope="text, client, index">
  154. <a-dropdown :trigger="['click']">
  155. <a-icon @click="e => e.preventDefault()" type="ellipsis" :style="{ fontSize: '20px' }"></a-icon>
  156. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  157. <a-menu-item v-if="record.hasLink()" @click="showQrcode(record.id,client);">
  158. <a-icon :style="{ fontSize: '14px' }" type="qrcode"></a-icon>
  159. {{ i18n "qrCode" }}
  160. </a-menu-item>
  161. <a-menu-item @click="openEditClient(record.id,client);">
  162. <a-icon :style="{ fontSize: '14px' }" type="edit"></a-icon>
  163. {{ i18n "pages.client.edit" }}
  164. </a-menu-item>
  165. <a-menu-item @click="showInfo(record.id,client);">
  166. <a-icon :style="{ fontSize: '14px' }" type="info-circle"></a-icon>
  167. {{ i18n "info" }}
  168. </a-menu-item>
  169. <a-menu-item @click="resetClientTraffic(client,record.id)" v-if="client.email.length > 0">
  170. <a-icon :style="{ fontSize: '14px' }" type="retweet"></a-icon>
  171. {{ i18n "pages.inbounds.resetTraffic" }}
  172. </a-menu-item>
  173. <a-menu-item v-if="isRemovable(record.id)" @click="delClient(record.id,client)">
  174. <a-icon :style="{ fontSize: '14px' }" type="delete"></a-icon>
  175. <span :style="{ color: '#FF4D4F' }"> {{ i18n "delete"}}</span>
  176. </a-menu-item>
  177. <a-menu-item>
  178. <a-switch v-model="client.enable" size="small" @change="switchEnableClient(record.id,client)"></a-switch>
  179. {{ i18n "enable"}}
  180. </a-menu-item>
  181. </a-menu>
  182. </a-dropdown>
  183. </template>
  184. <template slot="info" slot-scope="text, client, index">
  185. <a-popover placement="bottomRight" :overlay-class-name="themeSwitcher.currentTheme" trigger="click">
  186. <template slot="content">
  187. <table>
  188. <tr>
  189. <td colspan="3" :style="{ textAlign: 'center' }">{{ i18n "pages.inbounds.traffic" }}</td>
  190. </tr>
  191. <tr>
  192. <td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[ SizeFormatter.sizeFormat(getUpStats(record, client.email) + getDownStats(record, client.email)) ]] </td>
  193. <td width="120px" v-if="!client.enable">
  194. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? 'rgb(72 84 105)' : '#bcbcbc'" :show-info="false" :percent="statsProgress(record, client.email)" />
  195. </td>
  196. <td width="120px" v-else-if="client.totalGB > 0">
  197. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  198. <template slot="content" v-if="client.email">
  199. <table cellpadding="2" width="100%">
  200. <tr>
  201. <td>↑[[ SizeFormatter.sizeFormat(getUpStats(record, client.email)) ]]</td>
  202. <td>↓[[ SizeFormatter.sizeFormat(getDownStats(record, client.email)) ]]</td>
  203. </tr>
  204. <tr>
  205. <td>{{ i18n "remained" }}</td>
  206. <td>[[ SizeFormatter.sizeFormat(getRemStats(record, client.email)) ]]</td>
  207. </tr>
  208. </table>
  209. </template>
  210. <a-progress :stroke-color="clientStatsColor(record, client.email)" :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="statsProgress(record, client.email)" />
  211. </a-popover>
  212. </td>
  213. <td width="120px" v-else class="infinite-bar">
  214. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? '#2c1e32':'#F2EAF1'" :show-info="false" :percent="100"></a-progress>
  215. </td>
  216. <td width="80px">
  217. <template v-if="client.totalGB > 0">[[ client._totalGB + "GB" ]]</template>
  218. <span v-else class="tr-infinity-ch">&infin;</span>
  219. </td>
  220. </tr>
  221. <tr>
  222. <td colspan="3" :style="{ textAlign: 'center' }">
  223. <a-divider :style="{ margin: '0', borderCollapse: 'separate' }"></a-divider>
  224. {{ i18n "pages.inbounds.expireDate" }}
  225. </td>
  226. </tr>
  227. <tr>
  228. <template v-if="client.expiryTime !=0 && client.reset >0">
  229. <td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[ remainedDays(client.expiryTime) ]] </td>
  230. <td width="120px" class="infinite-bar">
  231. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  232. <template slot="content">
  233. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  234. </span>
  235. <span v-else>
  236. <template v-if="app.datepicker === 'gregorian'">
  237. [[ DateUtil.formatMillis(client._expiryTime) ]]
  238. </template>
  239. <template v-else>
  240. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  241. </template>
  242. </span>
  243. </template>
  244. <a-progress :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
  245. </a-popover>
  246. </td>
  247. <td width="60px">[[ client.reset + "d" ]]</td>
  248. </template>
  249. <template v-else>
  250. <td colspan="3" :style="{ textAlign: 'center' }">
  251. <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
  252. <template slot="content">
  253. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  254. </span>
  255. <span v-else>
  256. <template v-if="app.datepicker === 'gregorian'">
  257. [[ DateUtil.formatMillis(client._expiryTime) ]]
  258. </template>
  259. <template v-else>
  260. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  261. </template>
  262. </span>
  263. </template>
  264. <a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag>
  265. </a-popover>
  266. <a-tag v-else :color="client.enable ? 'purple' : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'" class="infinite-tag">
  267. <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
  268. <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>
  269. </svg>
  270. </a-tag>
  271. </template>
  272. </td>
  273. </tr>
  274. </table>
  275. </template>
  276. <a-badge>
  277. <a-icon v-if="!client.enable" slot="count" type="pause-circle" theme="filled" :style="{ color: themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc' }"></a-icon>
  278. <a-button shape="round" size="small" :style="{ fontSize: '14px', padding: '0 10px' }">
  279. <a-icon type="solution"></a-icon>
  280. </a-button>
  281. </a-badge>
  282. </a-popover>
  283. </template>
  284. <template slot="createdAt" slot-scope="text, client, index">
  285. <template v-if="client.created_at">
  286. <template v-if="app.datepicker === 'gregorian'">
  287. [[ DateUtil.formatMillis(client.created_at) ]]
  288. </template>
  289. <template v-else>
  290. [[ DateUtil.convertToJalalian(moment(client.created_at)) ]]
  291. </template>
  292. </template>
  293. <template v-else>
  294. -
  295. </template>
  296. </template>
  297. <template slot="updatedAt" slot-scope="text, client, index">
  298. <template v-if="client.updated_at">
  299. <template v-if="app.datepicker === 'gregorian'">
  300. [[ DateUtil.formatMillis(client.updated_at) ]]
  301. </template>
  302. <template v-else>
  303. [[ DateUtil.convertToJalalian(moment(client.updated_at)) ]]
  304. </template>
  305. </template>
  306. <template v-else>
  307. -
  308. </template>
  309. </template>
  310. {{end}}