mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
feat: display session locale
This commit is contained in:
1 parent
b5024631f7
commit
994618f71c
3 files changed
+22
-10
No files matched your search
@@ -8,8 +8,10 @@ export interface SessionDocument {
|
|||||||
user: User
|
user: User
|
||||||
quest: string
|
quest: string
|
||||||
status: string
|
status: string
|
||||||
|
locale: string
|
||||||
createdAt: Date
|
createdAt: Date
|
||||||
finishedAt: Date
|
finishedAt: Date
|
||||||
|
lastActivityAt: Date
|
||||||
}
|
}
|
||||||
export interface CommandObject {
|
export interface CommandObject {
|
||||||
command: string
|
command: string
|
||||||
@@ -23,22 +25,15 @@ export interface SessionObject {
|
|||||||
_id: Types.ObjectId
|
_id: Types.ObjectId
|
||||||
user: string
|
user: string
|
||||||
quest: string
|
quest: string
|
||||||
|
locale: string
|
||||||
status: string
|
status: string
|
||||||
createdAt: string
|
createdAt: string
|
||||||
finishedAt: string
|
finishedAt: string
|
||||||
lastActivityAt: string
|
lastActivityAt: string
|
||||||
usedTime: string
|
usedTime: string
|
||||||
commandCount: number
|
commandCount: number
|
||||||
commands: CommandObject[]
|
|
||||||
}
|
}
|
||||||
export interface SessionDetail {
|
export interface SessionDetail extends SessionObject {
|
||||||
_id: Types.ObjectId
|
|
||||||
user: string
|
|
||||||
quest: string
|
|
||||||
status: string
|
|
||||||
createdAt: string
|
|
||||||
finishedAt: string
|
|
||||||
usedTime: string
|
|
||||||
commands: CommandObject[]
|
commands: CommandObject[]
|
||||||
}
|
}
|
||||||
export interface IUser extends Document {
|
export interface IUser extends Document {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export async function sessionList(
|
|||||||
_id,
|
_id,
|
||||||
user,
|
user,
|
||||||
quest,
|
quest,
|
||||||
|
locale,
|
||||||
status,
|
status,
|
||||||
createdAt,
|
createdAt,
|
||||||
finishedAt,
|
finishedAt,
|
||||||
@@ -55,6 +56,7 @@ export async function sessionList(
|
|||||||
_id,
|
_id,
|
||||||
user: user.username, // Assuming `user` is always populated.
|
user: user.username, // Assuming `user` is always populated.
|
||||||
quest,
|
quest,
|
||||||
|
locale: locale ?? 'zh-TW',
|
||||||
status,
|
status,
|
||||||
createdAt: createdAt?.toLocaleString(),
|
createdAt: createdAt?.toLocaleString(),
|
||||||
finishedAt: finishedAt?.toLocaleString(),
|
finishedAt: finishedAt?.toLocaleString(),
|
||||||
@@ -83,14 +85,27 @@ export async function sessionDetail(id: string): Promise<SessionDetail> {
|
|||||||
createdAt: createdAt?.toLocaleString(),
|
createdAt: createdAt?.toLocaleString(),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const { _id, user, quest, status, createdAt, finishedAt } = session
|
const {
|
||||||
|
_id,
|
||||||
|
user,
|
||||||
|
quest,
|
||||||
|
locale,
|
||||||
|
status,
|
||||||
|
createdAt,
|
||||||
|
finishedAt,
|
||||||
|
lastActivityAt,
|
||||||
|
} = session
|
||||||
|
console.log('session: ', session)
|
||||||
return {
|
return {
|
||||||
_id,
|
_id,
|
||||||
user: user.username,
|
user: user.username,
|
||||||
quest,
|
quest,
|
||||||
|
locale: locale ?? 'zh-TW',
|
||||||
status,
|
status,
|
||||||
createdAt: createdAt?.toLocaleString(),
|
createdAt: createdAt?.toLocaleString(),
|
||||||
finishedAt: finishedAt?.toLocaleString(),
|
finishedAt: finishedAt?.toLocaleString(),
|
||||||
|
lastActivityAt: lastActivityAt?.toLocaleDateString(),
|
||||||
|
commandCount: commands.length,
|
||||||
usedTime: finishedAt
|
usedTime: finishedAt
|
||||||
? formatTime(finishedAt.getTime() - createdAt.getTime())
|
? formatTime(finishedAt.getTime() - createdAt.getTime())
|
||||||
: '',
|
: '',
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>User</th>
|
<th>User</th>
|
||||||
<th>Quest</th>
|
<th>Quest</th>
|
||||||
|
<th>Locale</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Created At</th>
|
<th>Created At</th>
|
||||||
<th>Finished At</th>
|
<th>Finished At</th>
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{user}}</td>
|
<td>{{user}}</td>
|
||||||
<td>{{quest}}</td>
|
<td>{{quest}}</td>
|
||||||
|
<td>{{locale}}</td>
|
||||||
<td>{{status}}</td>
|
<td>{{status}}</td>
|
||||||
<td>{{createdAt}}</td>
|
<td>{{createdAt}}</td>
|
||||||
<td>{{finishedAt}}</td>
|
<td>{{finishedAt}}</td>
|
||||||
|
|||||||
Reference in new issue
Block a user