aClientTable.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. <div class="client-cell">
  45. <div class="client-info-row">
  46. <a-tooltip>
  47. <template slot="title">
  48. <template v-if="!isClientEnabled(record, client.email)">{{ i18n "depleted" }}</template>
  49. <template v-else-if="!client.enable">{{ i18n "disabled" }}</template>
  50. <template v-else-if="client.enable && isClientOnline(client.email)">{{ i18n "online" }}</template>
  51. </template>
  52. <a-badge :class="isClientOnline(client.email)? 'online-animation' : ''" :color="client.enable ? statsExpColor(record, client.email) : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'"></a-badge>
  53. </a-tooltip>
  54. <span class="client-email">[[ client.email ]]</span>
  55. </div>
  56. <div v-if="client.comment && client.comment.trim()" style="margin-left: 18px;">
  57. <a-tooltip v-if="client.comment.length > 50" :overlay-class-name="themeSwitcher.currentTheme">
  58. <template slot="title">
  59. [[ client.comment ]]
  60. </template>
  61. <span class="client-comment">[[ client.comment.substring(0, 47) + '...' ]]</span>
  62. </a-tooltip>
  63. <span v-else class="client-comment">[[ client.comment ]]</span>
  64. </div>
  65. </div>
  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 v-if="client.comment && client.comment.trim()">
  186. <td colspan="3" :style="{ textAlign: 'left', borderBottom: '1px solid #f0f0f0', paddingBottom: '8px', marginBottom: '8px' }">
  187. <div :style="{ fontSize: '0.9em', fontWeight: '500', marginBottom: '4px' }">[[ client.email ]]</div>
  188. <div :style="{ fontSize: '0.85em', color: '#666', fontStyle: 'italic', wordBreak: 'break-word', maxWidth: '250px' }">[[ client.comment ]]</div>
  189. </td>
  190. </tr>
  191. <tr v-else>
  192. <td colspan="3" :style="{ textAlign: 'center', fontWeight: '500', paddingBottom: '8px' }">[[ client.email ]]</td>
  193. </tr>
  194. <tr>
  195. <td colspan="3" :style="{ textAlign: 'center' }">{{ i18n "pages.inbounds.traffic" }}</td>
  196. </tr>
  197. <tr>
  198. <td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[ SizeFormatter.sizeFormat(getUpStats(record, client.email) + getDownStats(record, client.email)) ]] </td>
  199. <td width="120px" v-if="!client.enable">
  200. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? 'rgb(72 84 105)' : '#bcbcbc'" :show-info="false" :percent="statsProgress(record, client.email)" />
  201. </td>
  202. <td width="120px" v-else-if="client.totalGB > 0">
  203. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  204. <template slot="content" v-if="client.email">
  205. <table cellpadding="2" width="100%">
  206. <tr>
  207. <td>↑[[ SizeFormatter.sizeFormat(getUpStats(record, client.email)) ]]</td>
  208. <td>↓[[ SizeFormatter.sizeFormat(getDownStats(record, client.email)) ]]</td>
  209. </tr>
  210. <tr>
  211. <td>{{ i18n "remained" }}</td>
  212. <td>[[ SizeFormatter.sizeFormat(getRemStats(record, client.email)) ]]</td>
  213. </tr>
  214. </table>
  215. </template>
  216. <a-progress :stroke-color="clientStatsColor(record, client.email)" :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="statsProgress(record, client.email)" />
  217. </a-popover>
  218. </td>
  219. <td width="120px" v-else class="infinite-bar">
  220. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? '#2c1e32':'#F2EAF1'" :show-info="false" :percent="100"></a-progress>
  221. </td>
  222. <td width="80px">
  223. <template v-if="client.totalGB > 0">[[ client._totalGB + "GB" ]]</template>
  224. <span v-else class="tr-infinity-ch">&infin;</span>
  225. </td>
  226. </tr>
  227. <tr>
  228. <td colspan="3" :style="{ textAlign: 'center' }">
  229. <a-divider :style="{ margin: '0', borderCollapse: 'separate' }"></a-divider>
  230. {{ i18n "pages.inbounds.expireDate" }}
  231. </td>
  232. </tr>
  233. <tr>
  234. <template v-if="client.expiryTime !=0 && client.reset >0">
  235. <td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[ remainedDays(client.expiryTime) ]] </td>
  236. <td width="120px" class="infinite-bar">
  237. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  238. <template slot="content">
  239. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  240. </span>
  241. <span v-else>
  242. <template v-if="app.datepicker === 'gregorian'">
  243. [[ DateUtil.formatMillis(client._expiryTime) ]]
  244. </template>
  245. <template v-else>
  246. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  247. </template>
  248. </span>
  249. </template>
  250. <a-progress :show-info="false" :status="isClientEnabled(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
  251. </a-popover>
  252. </td>
  253. <td width="60px">[[ client.reset + "d" ]]</td>
  254. </template>
  255. <template v-else>
  256. <td colspan="3" :style="{ textAlign: 'center' }">
  257. <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
  258. <template slot="content">
  259. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
  260. </span>
  261. <span v-else>
  262. <template v-if="app.datepicker === 'gregorian'">
  263. [[ DateUtil.formatMillis(client._expiryTime) ]]
  264. </template>
  265. <template v-else>
  266. [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
  267. </template>
  268. </span>
  269. </template>
  270. <a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag>
  271. </a-popover>
  272. <a-tag v-else :color="client.enable ? 'purple' : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'" class="infinite-tag">
  273. <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
  274. <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>
  275. </svg>
  276. </a-tag>
  277. </template>
  278. </td>
  279. </tr>
  280. </table>
  281. </template>
  282. <a-badge>
  283. <a-icon v-if="!client.enable" slot="count" type="pause-circle" theme="filled" :style="{ color: themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc' }"></a-icon>
  284. <a-button shape="round" size="small" :style="{ fontSize: '14px', padding: '0 10px' }">
  285. <a-icon type="solution"></a-icon>
  286. </a-button>
  287. </a-badge>
  288. </a-popover>
  289. </template>
  290. {{end}}