Skip to content

Commit cc5a0c0

Browse files
Feature/43 update reporting to use name and description (#44)
* added name and description to model * added naming + description to the detailed view
1 parent c1a2301 commit cc5a0c0

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

handlers/reporting.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func (r *reportingHandler) ReportingTableCardHandler(context *gin.Context) {
6161
for _, report := range reports {
6262

6363
row := table.ReportingDataTableRow{
64+
Name: report.Name,
6465
ExecutionID: report.ExecutionId,
6566
StartTime: report.Started,
6667
Duration: report.Ended.Sub(report.Started),

models/reporter/reporter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
)
88

99
type PlaybookExecutionReport struct {
10+
Name string `bson:"name" json:"name"`
11+
Description string `bson:"description" json:"description"`
1012
Type string `bson:"type" json:"type"`
1113
ExecutionId string `bson:"execution_id" json:"execution_id"`
1214
PlaybookId string `bson:"playbook_id" json:"playbook_id"`
@@ -19,6 +21,8 @@ type PlaybookExecutionReport struct {
1921
}
2022

2123
type StepExecutionReport struct {
24+
Name string `bson:"name" json:"name"`
25+
Description string `bson:"description" json:"description"`
2226
ExecutionId string `bson:"execution_id" json:"execution_id"`
2327
StepId string `bson:"step_id" json:"step_id"`
2428
Started time.Time `bson:"started" json:"started"`

views/components/table/reporting_table.templ

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const (
1515
htmxTrigger = "load, every 1s"
1616
)
1717

18-
var headers = []string{"Execution ID", "Start Time", "Execution Duration", "Status"}
18+
var headers = []string{"Playbook Name", "Start Time", "Execution Duration", "Status"}
1919

2020
type ReportingTableMeta struct {
2121
Loaded bool
@@ -24,6 +24,7 @@ type ReportingTableMeta struct {
2424

2525
type ReportingDataTableRow struct {
2626
ExecutionID string
27+
Name string
2728
StartTime time.Time
2829
Duration time.Duration
2930
Status string
@@ -90,7 +91,7 @@ templ reportingTableHeaders() {
9091

9192
templ reportingTableDataRow(row ReportingDataTableRow) {
9293
@Td() {
93-
<a href={ templ.URL(fmt.Sprintf("%s%s", reportingDetailedViewEndpoint, row.ExecutionID)) } class="text-blue-800 hover:text-blue-400">{ row.ExecutionID } </a>
94+
<a href={ templ.URL(fmt.Sprintf("%s%s", reportingDetailedViewEndpoint, row.ExecutionID)) } class="text-blue-800 hover:text-blue-400">{ row.Name } </a>
9495
}
9596
@Td() {
9697
{ row.StartTime.Format(time.ANSIC) }

views/dashboards/reporting/reporting_detailed.templ

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ templ section(executionReport reporter.PlaybookExecutionReport) {
6565

6666
templ playbookInfoCard(executionReport reporter.PlaybookExecutionReport) {
6767
@statusIndicator(executionReport.Status)
68-
<span class="text-md mb-8 font-bold text-gray-800">Playbook:</span>
69-
<span>{ executionReport.ExecutionId }</span>
68+
<span class="text-md font-bold text-gray-800 mb-8">{ executionReport.Name }</span>
7069
<hr class="mt-2"/>
7170
<div class="mb-6">
7271
<table class="table-auto text-sm text-gray-600">
@@ -76,7 +75,11 @@ templ playbookInfoCard(executionReport reporter.PlaybookExecutionReport) {
7675
<td>{ executionReport.ExecutionId }</td>
7776
</tr>
7877
<tr>
79-
<th class="pr-4 text-left font-semibold">Started:</th>
78+
<th class="font-semibold text-left pr-4">Description:</th>
79+
<td>{ executionReport.Description }</td>
80+
</tr>
81+
<tr>
82+
<th class="font-semibold text-left pr-4">Started:</th>
8083
<td>{ executionReport.Started.Format(time.ANSIC) }</td>
8184
</tr>
8285
<tr>
@@ -163,20 +166,23 @@ templ formatCacaoVariables(name string, result cacao.Variable) {
163166
</div>
164167
}
165168

166-
templ actionStepInfoCard(executionId string, stepResult reporter.StepExecutionReport) {
169+
templ actionStepInfoCard(stepResult reporter.StepExecutionReport) {
167170
<div { utils.CreateClassAttrs("relative border bg-gray-50 rounded-lg p-4 mb-4", reportingBorderColorStatus(stepResult.Status))... }>
168171
@statusIndicator(stepResult.Status)
169-
<span class="text-md mb-8 font-bold text-gray-800">Action Name:</span>
170-
<span>{ executionId }</span>
172+
<span class="text-md font-bold text-gray-800 mb-8">{ stepResult.Name }</span>
171173
<hr class="mt-2"/>
172174
<table class="table-auto text-sm text-gray-600">
173175
<tbody>
174176
<tr>
175-
<th class="pr-4 text-left font-semibold">Execution ID:</th>
176-
<td>{ executionId }</td>
177+
<th class="font-semibold text-left pr-4">Execution ID:</th>
178+
<td>{ stepResult.ExecutionId }</td>
179+
</tr>
180+
<tr>
181+
<th class="font-semibold text-left pr-4">Description:</th>
182+
<td>{ stepResult.Description }</td>
177183
</tr>
178184
<tr>
179-
<th class="pr-4 text-left font-semibold">Started:</th>
185+
<th class="font-semibold text-left pr-4">Started:</th>
180186
<td>{ stepResult.Started.Format(time.ANSIC) }</td>
181187
</tr>
182188
<tr>
@@ -216,24 +222,24 @@ templ actionStepInfoCards(stepResults map[string]reporter.StepExecutionReport) {
216222

217223
templ timelineView(stepResults map[string]reporter.StepExecutionReport) {
218224
<div class="relative m-4">
219-
<ol class="border-s border-gray-200 dark:border-gray-700">
220-
for executionId, stepResult := range stepResults {
225+
<ol class="border-s border-gray-200 dark:border-gray-700">
226+
for _, stepResult := range stepResults {
221227
<li class="mb-5 ms-6">
222228
<span class="absolute -start-3 flex h-6 w-6 items-center justify-center rounded-full bg-white ring-8 ring-white">
223229
@indicators.ReportingStatusTagNoText(stepResult.Status)
224230
</span>
225-
<h3 class="mb-1 flex items-center text-lg font-semibold text-gray-900 dark:text-white">{ executionId }</h3>
226-
<time class="mb-2 block text-sm font-normal leading-none text-gray-400 dark:text-gray-500">Started: { stepResult.Started.Format(time.ANSIC) }</time>
227-
<time class="mb-2 block text-sm font-normal leading-none text-gray-400 dark:text-gray-500">Duration: { formatDuration(stepResult.Started, stepResult.Ended) }</time>
231+
<h3 class="flex items-center mb-1 text-lg font-semibold text-gray-900 dark:text-white">{ stepResult.Name }</h3>
232+
<time class="block mb-2 text-sm font-normal leading-none text-gray-400 dark:text-gray-500">Started: { stepResult.Started.Format(time.ANSIC) }</time>
233+
<time class="block mb-2 text-sm font-normal leading-none text-gray-400 dark:text-gray-500">Duration: { formatDuration(stepResult.Started, stepResult.Ended) }</time>
228234
</li>
229235
}
230236
</ol>
231237
</div>
232238
}
233239

234240
templ detailedView(stepResults map[string]reporter.StepExecutionReport) {
235-
for executionId, stepResult := range stepResults {
236-
@actionStepInfoCard(executionId, stepResult) {
241+
for _, stepResult := range stepResults {
242+
@actionStepInfoCard(stepResult) {
237243
@expander() {
238244
@expandActionInfoCard(stepResult)
239245
}

0 commit comments

Comments
 (0)