Skip to content

Commit

Permalink
feat(dashboard): added taskProcessing state
Browse files Browse the repository at this point in the history
Added a taskProcessing state & event to the stack graph & task graph.

Now, pending task nodes are shown with a solid red/pink border, while
in-progress task nodes are shown with the spinning, dashed red/pink
border. This gives a clearer overview of the current state of the task
graph.
  • Loading branch information
thsig committed Apr 18, 2019
1 parent 9e11495 commit 10bc275
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion dashboard/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export interface WsPayload {
version: any
}

export type NodeTask = "taskPending" | "taskComplete" | "taskError"
export type NodeTask = "taskPending" | "taskProcessing" | "taskComplete" | "taskError"
export const nodeTaskTypes: NodeTask[] = ["taskPending", "taskProcessing", "taskComplete", "taskError"]

export interface WsMessage {
type: "event" | "error" | "commandResult"
Expand Down
4 changes: 4 additions & 0 deletions dashboard/src/components/graph/graph.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#chart {
g.taskPending > rect {
stroke: #f17fcd;
}

g.taskProcessing > rect {
stroke: #f17fcd;
stroke-dasharray: 8;
animation: dash 15s linear infinite;
}
Expand Down
13 changes: 4 additions & 9 deletions dashboard/src/components/graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
FetchConfigResponse,
FetchGraphResponse,
WsMessage,
NodeTask,
nodeTaskTypes,
} from "../../api/types"
import Card from "../card"

Expand Down Expand Up @@ -268,8 +268,7 @@ class Chart extends Component<Props, State> {
}

clearClasses(el: HTMLElement) {
const classList: NodeTask[] = ["taskComplete", "taskPending", "taskError"]
for (const className of classList) {
for (const className of nodeTaskTypes) {
el.classList.remove(className)
}
}
Expand All @@ -280,12 +279,8 @@ class Chart extends Component<Props, State> {
if (message.payload.key && node.id === getIdFromTaskKey(message.payload.key)) {
const nodeEl = document.getElementById(node.id)
this.clearClasses(nodeEl)
if (message.name === "taskPending") {
nodeEl.classList.add("taskPending")
} else if (message.name === "taskError") {
nodeEl.classList.add("taskError")
} else if (message.name === "taskComplete") {
nodeEl.classList.add("taskComplete")
if (nodeTaskTypes.find(t => t === message.name)) {
nodeEl.classList.add(message.name) // message.name is of type NodeTask
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions garden-service/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export interface Events {
key: string,
version: ModuleVersion,
},
taskProcessing: {
startedAt: Date,
key: string,
version: ModuleVersion,
},
taskComplete: TaskResult,
taskError: TaskResult,
taskGraphProcessing: {
Expand Down
5 changes: 5 additions & 0 deletions garden-service/src/task-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ export class TaskGraph {
pick(results, dependencyBaseKeys))

try {
this.garden.events.emit("taskProcessing", {
startedAt: new Date(),
key: task.getKey(),
version: task.version,
})
result = await node.process(dependencyResults)
this.garden.events.emit("taskComplete", result)
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions garden-service/test/unit/src/task-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ describe("task-graph", () => {
expect(garden.events.eventLog).to.eql([
{ name: "taskPending", payload: { addedAt: now, key: task.getKey(), version: task.version } },
{ name: "taskGraphProcessing", payload: { startedAt: now } },
{ name: "taskProcessing", payload: { startedAt: now, key: task.getKey(), version: task.version } },
{ name: "taskComplete", payload: result["a"] },
{ name: "taskGraphComplete", payload: { completedAt: now } },
])
Expand Down Expand Up @@ -168,6 +169,7 @@ describe("task-graph", () => {
expect(garden.events.eventLog).to.eql([
{ name: "taskPending", payload: { addedAt: now, key: task.getKey(), version: task.version } },
{ name: "taskGraphProcessing", payload: { startedAt: now } },
{ name: "taskProcessing", payload: { startedAt: now, key: task.getKey(), version: task.version } },
{ name: "taskError", payload: result["a"] },
{ name: "taskGraphComplete", payload: { completedAt: now } },
])
Expand Down

0 comments on commit 10bc275

Please sign in to comment.