Skip to content

Commit

Permalink
Upd: Add dummy data sharing ui
Browse files Browse the repository at this point in the history
Signed-off-by: George J Padayatti <[email protected]>
  • Loading branch information
georgepadayatti committed Nov 5, 2023
1 parent 4c944d4 commit e6c74ed
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package datasharing

import (
"html/template"
"net/http"
)

func ServiceShowDataSharingUiHandler(w http.ResponseWriter, r *http.Request) {
// HTML template
templateContent := `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Consent BB Data Sharing UI</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/decentralised-dataexchange/bb-consent-data-sharing-ui/dist/consentBbDataSharingUi.css"
/>
</head>
<body style="margin: 0px">
<div id="consentBbDataSharingUi"></div>
<script
data-element-id="consentBbDataSharingUi"
id="consentBbDataSharingUi-script"
src="https://cdn.jsdelivr.net/gh/decentralised-dataexchange/bb-consent-data-sharing-ui/dist/consentBbDataSharingUi.js"
></script>
<script>
window.ConsentBbDataSharingUi();
</script>
</body>
</html>
`

// Parse the HTML template
tmpl := template.New("my-template")
tmpl, err := tmpl.Parse(templateContent)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

// Execute the template with the data
err = tmpl.Execute(w, nil)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
3 changes: 3 additions & 0 deletions internal/http_path/v2/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
webhookHandler "github.com/bb-consent/api/internal/handler/v2/config/webhook"
onboardHandler "github.com/bb-consent/api/internal/handler/v2/onboard"
serviceHandler "github.com/bb-consent/api/internal/handler/v2/service"
serviceDataSharingHandler "github.com/bb-consent/api/internal/handler/v2/service/datasharing"
serviceIndividualHandler "github.com/bb-consent/api/internal/handler/v2/service/individual"
m "github.com/bb-consent/api/internal/middleware"
"github.com/casbin/casbin/v2"
Expand Down Expand Up @@ -161,4 +162,6 @@ func SetRoutes(r *mux.Router, e *casbin.Enforcer) {
r.Handle(OnboardUpdateOrganisationAdminAvatar, m.Chain(onboardHandler.OnboardUpdateOrganisationAdminAvatar, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate(), m.AddContentType())).Methods("PUT")

r.Handle(OnboardReadStatus, m.Chain(onboardHandler.OnboardReadStatus, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate(), m.AddContentType())).Methods("GET")

r.Handle(ServiceShowDataSharingUi, m.Chain(serviceDataSharingHandler.ServiceShowDataSharingUiHandler, m.LoggerNoAuth())).Methods("GET")
}
3 changes: 3 additions & 0 deletions internal/http_path/v2/service_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ const ServiceCreateIndividual = "/v2/service/individual"
const ServiceReadIndividual = "/v2/service/individual/{individualId}"
const ServiceUpdateIndividual = "/v2/service/individual/{individualId}"
const ServiceListIndividuals = "/v2/service/individuals"

// Data sharing
const ServiceShowDataSharingUi = "/data-sharing-ui"
2 changes: 1 addition & 1 deletion resources/config

0 comments on commit e6c74ed

Please sign in to comment.