-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add #166 Ability to configure privacy dashboard
- Loading branch information
1 parent
9bf79a6
commit 8c3543a
Showing
6 changed files
with
96 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/v2/handler/privacy_dashboard/config_read_privacy_dashboard.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package privacydashboard | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
|
||
pd "github.com/bb-consent/api/src/v2/privacy_dashboard" | ||
) | ||
|
||
type readPrivacyDashboardResp struct { | ||
HostName string `json:"hostname"` | ||
Version string `json:"version"` | ||
Status int `json:"status"` | ||
StatusStr string `json:"statusStr"` | ||
} | ||
|
||
// ConfigReadPrivacyDashboard Gets the privacy dashboard related info of the organization | ||
func ConfigReadPrivacyDashboard(w http.ResponseWriter, r *http.Request) { | ||
|
||
var resp readPrivacyDashboardResp | ||
if pd.PrivacyDashboard.Hostname == "" { | ||
resp = readPrivacyDashboardResp{ | ||
HostName: pd.PrivacyDashboard.Hostname, | ||
Version: pd.PrivacyDashboard.Version, | ||
Status: pd.DashboardNotConfigured, | ||
StatusStr: pd.DashboardDeploymentStatuses[0].Str, | ||
} | ||
} else { | ||
resp = readPrivacyDashboardResp{ | ||
HostName: pd.PrivacyDashboard.Hostname, | ||
Version: pd.PrivacyDashboard.Version, | ||
Status: pd.DashboardDeployed, | ||
StatusStr: pd.DashboardDeploymentStatuses[2].Str, | ||
} | ||
} | ||
|
||
response, _ := json.Marshal(resp) | ||
w.Header().Set("Content-Type", "application/json") | ||
w.Write(response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package privacydashboard | ||
|
||
import "github.com/bb-consent/api/src/config" | ||
|
||
// DashboardDeploymentStatus id and string of status | ||
type DashboardDeploymentStatus struct { | ||
ID int | ||
Str string | ||
} | ||
|
||
const ( | ||
DashboardNotConfigured = 0 | ||
DashboardRequested = 1 | ||
DashboardDeployed = 2 | ||
) | ||
|
||
var PrivacyDashboard config.PrivacyDashboard | ||
|
||
// Init Initialize the Privacy Dashboard | ||
func Init(config *config.Configuration) { | ||
PrivacyDashboard = config.PrivacyDashboard | ||
} | ||
|
||
// Note: Dont change the ID(s) if new type is needed then add at the end | ||
|
||
// DashboardDeploymentStatuses Array of id and string | ||
var DashboardDeploymentStatuses = []DashboardDeploymentStatus{ | ||
{ID: DashboardNotConfigured, Str: "Not Configured"}, | ||
{ID: DashboardRequested, Str: "Requested"}, | ||
{ID: DashboardDeployed, Str: "Deployed"}} |