feat: include complete stage name in command

This commit is contained in:
wancat committed 2023-10-29 17:41:38 +08:00
1 parent 8f22babe7d
commit aec0cf84ad
6 files changed
+27 -7

No files matched your search

+14 -3
View File
@@ -51,7 +51,16 @@ export async function sessionList() {
},
])
return sessions.map(
({ _id, user, quest, status, createdAt, finishedAt, commands }) => {
({
_id,
user,
quest,
status,
createdAt,
finishedAt,
commands,
lastActivityAt,
}) => {
return {
_id,
user: user.username,
@@ -59,7 +68,8 @@ export async function sessionList() {
status,
createdAt: createdAt?.toLocaleString(),
finishedAt: finishedAt?.toLocaleString(),
usedTime: finishedAt ? formatTime(finishedAt - createdAt) : '',
lastActivityAt: lastActivityAt?.toLocaleString(),
usedTime: formatTime(lastActivityAt - createdAt),
commandCount: commands?.length,
}
}
@@ -69,9 +79,10 @@ export async function sessionList() {
export async function sessionDetail(id) {
const session = await Session.findById(id).populate('user').exec()
const commands = (await Command.find({ session: id })).map(
({ command, pwd, output, error, createdAt }) => ({
({ command, pwd, output, error, createdAt, stage }) => ({
command: command?.slice(0, 20),
pwd,
stage,
output: output?.slice(0, 50),
error: error?.slice(0, 50),
createdAt: createdAt?.toLocaleString(),
@@ -40,6 +40,7 @@
<th>PWD</th>
<th>Output</th>
<th>Error</th>
<th>Stage</th>
<th>Created At</th>
</tr>
{{#each commands}}
@@ -48,6 +49,7 @@
<td>{{pwd}}</td>
<td>{{output}}</td>
<td>{{error}}</td>
<td>{{stage}}</td>
<td>{{createdAt}}</td>
</tr>
{{/each}}