Skip to content

Commit 35b3a50

Browse files
feat(inbounds): add client usage sort and remove inbound sort option
1 parent 9a3e7b1 commit 35b3a50

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

internal/web/html/xui/inbounds.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@
273273
<a-menu-item key="default">{{ i18n "default" }}</a-menu-item>
274274
<a-menu-item key="alphabet">{{ i18n "alphabet" }}</a-menu-item>
275275
<a-menu-item key="remainingTime">{{ i18n "remained" }}</a-menu-item>
276+
<a-menu-item key="usage">{{ i18n "usage" }}</a-menu-item>
276277
</a-menu>
277278
</a-dropdown>
278279
</a-col>
@@ -1372,6 +1373,17 @@
13721373
const sortBy = this.clientSortBy || 'default';
13731374
if (sortBy === 'alphabet') {
13741375
return clients.sort((a, b) => a.email.localeCompare(b.email));
1376+
} else if (sortBy === 'usage') {
1377+
return clients.sort((a, b) => {
1378+
const aStat = dbInbound.clientStats.find(s => s.email === a.email) || {up: 0, down: 0};
1379+
const bStat = dbInbound.clientStats.find(s => s.email === b.email) || {up: 0, down: 0};
1380+
const aUsage = (aStat.up || 0) + (aStat.down || 0);
1381+
const bUsage = (bStat.up || 0) + (bStat.down || 0);
1382+
if (bUsage !== aUsage) {
1383+
return bUsage - aUsage;
1384+
}
1385+
return (a.email || '').localeCompare(b.email || '');
1386+
});
13751387
} else if (sortBy === 'remainingTime') {
13761388
return clients.sort((a, b) => {
13771389
const aStat = dbInbound.clientStats.find(s => s.email === a.email) || {expiryTime: 0};

0 commit comments

Comments
 (0)