Skip to content

Commit

Permalink
Added file download and image report types
Browse files Browse the repository at this point in the history
  • Loading branch information
akclace committed Nov 30, 2024
1 parent 166b98b commit c1b8cc0
Show file tree
Hide file tree
Showing 8 changed files with 383 additions and 10 deletions.
16 changes: 16 additions & 0 deletions internal/app/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@ func (a *Action) renderResults(w http.ResponseWriter, report string, valuesMap [
return a.renderResultsText(w, valuesStr)
case apptype.JSON:
return a.renderResultsJson(w, valuesMap)
case apptype.DOWNLOAD:
return a.renderResultsDownload(w, valuesMap)
case apptype.IMAGE:
return a.renderResultsImage(w, valuesMap)
default:
// Custom template being used for the results
// Wrap the template output in a div with hx-swap-oob
Expand Down Expand Up @@ -515,6 +519,18 @@ func (a *Action) renderResultsText(w http.ResponseWriter, valuesStr []string) er
return err
}

func (a *Action) renderResultsDownload(w http.ResponseWriter, valuesMap []map[string]any) error {
// Render the result values, using HTMX OOB
err := a.actionTemplate.ExecuteTemplate(w, "result-download", valuesMap)
return err
}

func (a *Action) renderResultsImage(w http.ResponseWriter, valuesMap []map[string]any) error {
// Render the result values, using HTMX OOB
err := a.actionTemplate.ExecuteTemplate(w, "result-image", valuesMap)
return err
}

func (a *Action) renderResultsTable(w http.ResponseWriter, valuesMap []map[string]any) error {
if len(valuesMap) == 0 {
return a.actionTemplate.ExecuteTemplate(w, "result-empty", nil)
Expand Down
Loading

0 comments on commit c1b8cc0

Please sign in to comment.