feat(ui): show client last online in table and info modal

This commit is contained in:
Ali Golzar 2025-08-31 17:59:07 +03:30
parent 3f1438bea1
commit 77fa6f8608
3 changed files with 35 additions and 6 deletions

View file

@ -33,12 +33,17 @@
<a-switch v-model="client.enable" @change="switchEnableClient(record.id,client)"></a-switch> <a-switch v-model="client.enable" @change="switchEnableClient(record.id,client)"></a-switch>
</template> </template>
<template slot="online" slot-scope="text, client, index"> <template slot="online" slot-scope="text, client, index">
<template v-if="client.enable && isClientOnline(client.email)"> <a-popover :overlay-class-name="themeSwitcher.currentTheme">
<a-tag color="green">{{ i18n "online" }}</a-tag> <template slot="content" >
</template> {{ i18n "lastOnline" }}: [[ formatLastOnline(client.email) ]]
<template v-else> </template>
<a-tag>{{ i18n "offline" }}</a-tag> <template v-if="client.enable && isClientOnline(client.email)">
</template> <a-tag color="green">{{ i18n "online" }}</a-tag>
</template>
<template v-else>
<a-tag>{{ i18n "offline" }}</a-tag>
</template>
</a-popover>
</template> </template>
<template slot="client" slot-scope="text, client"> <template slot="client" slot-scope="text, client">
<a-space direction="horizontal" :size="2"> <a-space direction="horizontal" :size="2">

View file

@ -807,6 +807,7 @@
defaultKey: '', defaultKey: '',
clientCount: [], clientCount: [],
onlineClients: [], onlineClients: [],
lastOnlineMap: {},
isRefreshEnabled: localStorage.getItem("isRefreshEnabled") === "true" ? true : false, isRefreshEnabled: localStorage.getItem("isRefreshEnabled") === "true" ? true : false,
refreshing: false, refreshing: false,
refreshInterval: Number(localStorage.getItem("refreshInterval")) || 5000, refreshInterval: Number(localStorage.getItem("refreshInterval")) || 5000,
@ -835,6 +836,7 @@
return; return;
} }
await this.getLastOnlineMap();
await this.getOnlineUsers(); await this.getOnlineUsers();
this.setInbounds(msg.obj); this.setInbounds(msg.obj);
@ -849,6 +851,11 @@
} }
this.onlineClients = msg.obj != null ? msg.obj : []; this.onlineClients = msg.obj != null ? msg.obj : [];
}, },
async getLastOnlineMap() {
const msg = await HttpUtil.post('/panel/api/inbounds/lastOnline');
if (!msg.success || !msg.obj) return;
this.lastOnlineMap = msg.obj || {}
},
async getDefaultSettings() { async getDefaultSettings() {
const msg = await HttpUtil.post('/panel/setting/defaultSettings'); const msg = await HttpUtil.post('/panel/setting/defaultSettings');
if (!msg.success) { if (!msg.success) {
@ -1493,6 +1500,17 @@
isClientOnline(email) { isClientOnline(email) {
return this.onlineClients.includes(email); return this.onlineClients.includes(email);
}, },
getLastOnline(email) {
return this.lastOnlineMap[email] || null
},
formatLastOnline(email) {
const ts = this.getLastOnline(email)
if (!ts) return '-'
if (this.datepicker === 'gregorian') {
return DateUtil.formatMillis(ts)
}
return DateUtil.convertToJalalian(moment(ts))
},
isRemovable(dbInboundId) { isRemovable(dbInboundId) {
return this.getInboundClients(this.dbInbounds.find(row => row.id === dbInboundId)).length > 1; return this.getInboundClients(this.dbInbounds.find(row => row.id === dbInboundId)).length > 1;
}, },

View file

@ -217,6 +217,12 @@
</template> </template>
</td> </td>
</tr> </tr>
<tr>
<td>{{ i18n "lastOnline" }}</td>
<td>
<a-tag>[[ app.formatLastOnline(infoModal.clientSettings && infoModal.clientSettings.email ? infoModal.clientSettings.email : '') ]]</a-tag>
</td>
</tr>
<tr v-if="infoModal.clientSettings.comment"> <tr v-if="infoModal.clientSettings.comment">
<td>{{ i18n "comment" }}</td> <td>{{ i18n "comment" }}</td>
<td> <td>