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
+23
-11
No files matched your search
@@ -8,8 +8,10 @@ export interface SessionDocument {
|
||||
user: User
|
||||
quest: string
|
||||
status: string
|
||||
locale: string
|
||||
createdAt: Date
|
||||
finishedAt: Date
|
||||
lastActivityAt: Date
|
||||
}
|
||||
export interface CommandObject {
|
||||
command: string
|
||||
@@ -23,22 +25,15 @@ export interface SessionObject {
|
||||
_id: Types.ObjectId
|
||||
user: string
|
||||
quest: string
|
||||
locale: string
|
||||
status: string
|
||||
createdAt: string
|
||||
finishedAt: string
|
||||
lastActivityAt: string
|
||||
usedTime: string
|
||||
commandCount: number
|
||||
commands: CommandObject[]
|
||||
}
|
||||
export interface SessionDetail {
|
||||
_id: Types.ObjectId
|
||||
user: string
|
||||
quest: string
|
||||
status: string
|
||||
createdAt: string
|
||||
finishedAt: string
|
||||
usedTime: string
|
||||
export interface SessionDetail extends SessionObject {
|
||||
commands: CommandObject[]
|
||||
}
|
||||
export interface IUser extends Document {
|
||||
|
||||
@@ -45,6 +45,7 @@ export async function sessionList(
|
||||
_id,
|
||||
user,
|
||||
quest,
|
||||
locale,
|
||||
status,
|
||||
createdAt,
|
||||
finishedAt,
|
||||
@@ -55,6 +56,7 @@ export async function sessionList(
|
||||
_id,
|
||||
user: user.username, // Assuming `user` is always populated.
|
||||
quest,
|
||||
locale: locale ?? 'zh-TW',
|
||||
status,
|
||||
createdAt: createdAt?.toLocaleString(),
|
||||
finishedAt: finishedAt?.toLocaleString(),
|
||||
@@ -83,14 +85,27 @@ export async function sessionDetail(id: string): Promise<SessionDetail> {
|
||||
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 {
|
||||
_id,
|
||||
user: user.username,
|
||||
quest,
|
||||
locale: locale ?? 'zh-TW',
|
||||
status,
|
||||
createdAt: createdAt?.toLocaleString(),
|
||||
finishedAt: finishedAt?.toLocaleString(),
|
||||
lastActivityAt: lastActivityAt?.toLocaleDateString(),
|
||||
commandCount: commands.length,
|
||||
usedTime: finishedAt
|
||||
? formatTime(finishedAt.getTime() - createdAt.getTime())
|
||||
: '',
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Quest</th>
|
||||
<th>Locale</th>
|
||||
<th>Status</th>
|
||||
<th>Created At</th>
|
||||
<th>Finished At</th>
|
||||
@@ -23,6 +24,7 @@
|
||||
<tr>
|
||||
<td>{{user}}</td>
|
||||
<td>{{quest}}</td>
|
||||
<td>{{locale}}</td>
|
||||
<td>{{status}}</td>
|
||||
<td>{{createdAt}}</td>
|
||||
<td>{{finishedAt}}</td>
|
||||
@@ -37,4 +39,4 @@
|
||||
<a href='/sessions?nextKey={{nextKey}}&order={{order}}'><div class='btn'>
|
||||
<h3>Next</h3>
|
||||
</div></a>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user