Skip to content

Commit

Permalink
underway steps
Browse files Browse the repository at this point in the history
  • Loading branch information
neel-bp committed Apr 7, 2023
1 parent 5e74145 commit 656cf1d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions httpinterface/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type StatusResponse struct {
DateTimeString string `json:"dateTimeString"`
Coverage float64 `json:"coverage"`
WebSocketRoute template.URL `json:"websocketRoute"`
Steps []string `json:"steps"`
}

type WebsocketResponse struct {
Expand Down Expand Up @@ -189,12 +190,18 @@ func BuildStatus(w http.ResponseWriter, r *http.Request) {
return
}

projectSteps := make([]string, 0)
for _, step := range project.Steps {
projectSteps = append(projectSteps, strings.Join(step, " "))
}

templateResponse := StatusResponse{
JobState: result,
ProjectName: projectID,
DateTimeString: result.LastBuildStart.Format(time.RFC3339),
Coverage: coverage,
WebSocketRoute: template.URL(fmt.Sprintf("ws://%s/%s/livestatus", r.Host, projectID)),
Steps: projectSteps,
}

tmpl := template.Must(template.ParseFiles("statuspage.html"))
Expand Down
7 changes: 6 additions & 1 deletion statuspage.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ <h3 class="subtitle is-5" id="lastBuildStart">{{.DateTimeString}}</h3>
</div>
</div>
</section>
<section class="section">
<div class="container">
<h1 class="title is-2 has-text-centered">Steps</h1>
</div>
</section>
</body>

<style>
Expand Down Expand Up @@ -79,7 +84,7 @@ <h3 class="subtitle is-5" id="lastBuildStart">{{.DateTimeString}}</h3>

lastBuildStart.innerHTML = time;

var socket = new WebSocket({{.WebSocketRoute}});
var socket = new WebSocket("{{.WebSocketRoute}}");

socket.onmessage = function (message) {
if (message.data != null) {
Expand Down

0 comments on commit 656cf1d

Please sign in to comment.