1- package reporting
1+ package handlers
22
33import (
44 "fmt"
55 "net/http"
66
7- "soarca-gui/models/reporting"
8- utils "soarca-gui/utils"
7+ "soarca-gui/backend"
8+ "soarca-gui/utils"
9+ "soarca-gui/views/components/cards"
10+ "soarca-gui/views/dashboard/reporting"
11+
12+ "github.com/gin-gonic/gin"
913)
1014
1115const (
@@ -14,20 +18,40 @@ const (
1418)
1519
1620type reportingHandler struct {
17- Host string
21+ backend backend. Backend
1822}
1923
20- func NewReportingHandler (host string ) reportingHandler {
21- return reportingHandler {Host : host }
24+ func NewReportingHandler (backend backend. Backend ) reportingHandler {
25+ return reportingHandler {backend : backend }
2226}
2327
24- func (r * reportingHandler ) getReports () ([]reporting.PlaybookExecutionReport , error ) {
25- var response []reporting.PlaybookExecutionReport
26- url := fmt .Sprintf ("%s%s" , r .Host , reportingApiPath )
28+ func ReportingDashboardHandler (context * gin.Context ) {
29+ render := utils .NewTempl (context , http .StatusOK , reporting .ReportingIndex ())
30+
31+ context .Render (http .StatusOK , render )
32+ }
2733
28- reports , err := utils .MakeJsonRequest (url , http .MethodGet , nil , response )
29- if err != nil {
30- return nil , err
34+ func (r * reportingHandler ) ReportingCardHandler (context * gin.Context ) {
35+ id := context .Param ("id" )
36+ updatedCard := cards.ReportingCardData {
37+ Loaded : true ,
38+ ID : fmt .Sprint (id ),
39+ Value : 10 ,
40+ Name : "Executed Playbooks" ,
3141 }
32- return reports , nil
42+
43+ render := utils .NewTempl (context , http .StatusOK , cards .LoadReportingCard (updatedCard ))
44+
45+ context .Render (http .StatusOK , render )
3346}
47+
48+ func (r * reportingHandler ) ReportingIndexHandler (context * gin.Context ) {
49+ render := utils .NewTempl (context , http .StatusOK ,
50+ reporting .ReportingIndex ())
51+
52+ context .Render (http .StatusOK , render )
53+ }
54+
55+ // func (r *reportingHandler) GetReportsHandler() ([]reporting.PlaybookExecutionReport, error) {
56+ // return []reporting.PlaybookExecutionReport{}, nil
57+ // }
0 commit comments