Skip to content

Commit cdae6c9

Browse files
Pablo Carmonastarpit
authored andcommitted
add started, end and runtime data to list jobs table
1 parent d325fdb commit cdae6c9

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

package-lock.json

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/plugin-codeflare/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@patternfly/react-core": "^4.224.1",
2929
"open": "^8.4.0",
3030
"pretty-bytes": "^6.0.0",
31+
"pretty-ms": "8.0.0",
3132
"split2": "^4.1.0",
3233
"strip-ansi": "6.0.0",
3334
"tmp": "^0.2.1",

plugins/plugin-codeflare/src/controller/run/get.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { readdir } from "fs"
1818
import { Profiles } from "madwizard"
1919
import { basename, join } from "path"
20+
import prettyMilliseconds from "pretty-ms"
2021
import { Arguments, Table } from "@kui-shell/core"
2122
import { setTabReadonly } from "@kui-shell/plugin-madwizard"
2223

@@ -57,15 +58,27 @@ function statusColor(status: Status) {
5758
case "ERROR":
5859
return "red-background"
5960
case "RUNNING":
60-
return "cyan-background"
61+
return "blue-background"
6162
case "PENDING":
6263
return "yellow-background"
6364
default:
6465
return "gray-background"
6566
}
6667
}
6768

68-
export default async function getProfiles(args: Arguments) {
69+
function formatDate(date: number): string {
70+
if (!date) {
71+
return "Running..."
72+
}
73+
return new Date(date).toLocaleString()
74+
}
75+
76+
function getRunTime(start: number, end: number): string {
77+
const endTime = end || Date.now()
78+
return prettyMilliseconds(endTime - start, { secondsDecimalDigits: 0 })
79+
}
80+
81+
export default async function getRuns(args: Arguments) {
6982
setTabReadonly(args)
7083
const profile = args.parsedOptions.p || args.parsedOptions.profile
7184

@@ -97,6 +110,9 @@ export default async function getProfiles(args: Arguments) {
97110
onclick: () => onClick(_.runDir),
98111
attributes: [
99112
{ key: "STATUS", value: capitalize(_.info.status), tag: "badge", css: statusColor(_.info.status) },
113+
{ key: "STARTED AT", value: formatDate(_.info.start_time) },
114+
{ key: "FINISHED AT", value: formatDate(_.info.end_time) },
115+
{ key: "RUN TIME", value: getRunTime(_.info.start_time, _.info.end_time) },
100116
],
101117
})),
102118
}

0 commit comments

Comments
 (0)